diff options
-rw-r--r-- | koch.nim | 2 | ||||
-rwxr-xr-x | lib/wrappers/libcurl.nim | 494 | ||||
-rw-r--r-- | lib/wrappers/pcre.nim | 285 | ||||
-rwxr-xr-x | lib/wrappers/tre.nim | 186 | ||||
-rw-r--r-- | rod/nimrod.ini | 3 |
5 files changed, 968 insertions, 2 deletions
diff --git a/koch.nim b/koch.nim index 498ff20f9..4df8edbed 100644 --- a/koch.nim +++ b/koch.nim @@ -64,7 +64,7 @@ proc inno(args: string) = # make sure we have generated the c2nim and niminst executables: buildTool("tools/niminst", args) buildTool("rod/c2nim/c2nim", args) - exec("tools/niminst --var:version=$# inno rod/nimrod" % NimrodVersion) + exec("tools" / "niminst --var:version=$# inno rod/nimrod" % NimrodVersion) proc install(args: string) = exec("sh ./build.sh") diff --git a/lib/wrappers/libcurl.nim b/lib/wrappers/libcurl.nim new file mode 100755 index 000000000..875f1cbc8 --- /dev/null +++ b/lib/wrappers/libcurl.nim @@ -0,0 +1,494 @@ +# +# $Id: header,v 1.1 2000/07/13 06:33:45 michael Exp $ +# This file is part of the Free Pascal packages +# Copyright (c) 1999-2000 by the Free Pascal development team +# +# See the file COPYING.FPC, included in this distribution, +# for details about the copyright. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# ********************************************************************** +# +# the curl library is governed by its own copyright, see the curl +# website for this. +# + +{.deadCodeElim: on.} + +import + times + +when defined(windows): + const + libname = "libcurl.dll" +elif defined(macosx): + const + libname = "libcurl-7.19.3.dylib" +elif defined(unix): + const + libname = "libcurl.so.4" +type + Pcalloc_callback* = ptr Tcalloc_callback + Pclosepolicy* = ptr Tclosepolicy + Pforms* = ptr Tforms + Pftpauth* = ptr Tftpauth + Pftpmethod* = ptr Tftpmethod + Pftpssl* = ptr Tftpssl + PHTTP_VERSION* = ptr THTTP_VERSION + Phttppost* = ptr Thttppost + PPcurl_httppost* = ptr Phttppost + Pinfotype* = ptr Tinfotype + Plock_access* = ptr Tlock_access + Plock_data* = ptr Tlock_data + Pmalloc_callback* = ptr tmalloc_callback + PNETRC_OPTION* = ptr TNETRC_OPTION + Pproxytype* = ptr Tproxytype + Prealloc_callback* = ptr trealloc_callback + Pslist* = ptr Tslist + Psocket* = ptr Tsocket + PSSL_VERSION* = ptr TSSL_VERSION + Pstrdup_callback* = ptr Tstrdup_callback + PTIMECOND* = ptr TTIMECOND + Pversion_info_data* = ptr Tversion_info_data + Pcode* = ptr Tcode + PFORMcode* = ptr TFORMcode + Pformoption* = ptr Tformoption + PINFO* = ptr TINFO + Piocmd* = ptr Tiocmd + Pioerr* = ptr Tioerr + PM* = ptr TM + PMcode* = ptr TMcode + PMoption* = ptr TMoption + PMSG* = ptr TMSG + Poption* = ptr Toption + PSH* = ptr TSH + PSHcode* = ptr TSHcode + PSHoption* = ptr TSHoption + Pversion* = ptr Tversion + Pfd_set* = pointer + PCurl* = ptr TCurl + TCurl* = pointer + Thttppost*{.final, pure.} = object + next*: Phttppost + name*: cstring + namelength*: int32 + contents*: cstring + contentslength*: int32 + buffer*: cstring + bufferlength*: int32 + contenttype*: cstring + contentheader*: Pslist + more*: Phttppost + flags*: int32 + showfilename*: cstring + + Tprogress_callback* = proc (clientp: pointer, dltotal: float64, + dlnow: float64, ultotal: float64, + ulnow: float64): int32 {.cdecl.} + Twrite_callback* = proc (buffer: cstring, size: int, nitems: int, + outstream: pointer): int{.cdecl.} + Tread_callback* = proc (buffer: cstring, size: int, nitems: int, + instream: pointer): int{.cdecl.} + Tpasswd_callback* = proc (clientp: pointer, prompt: cstring, buffer: cstring, + buflen: int32): int32{.cdecl.} + Tioerr* = enum + IOE_OK, IOE_UNKNOWNCMD, IOE_FAILRESTART, IOE_LAST + Tiocmd* = enum + IOCMD_NOP, IOCMD_RESTARTREAD, IOCMD_LAST + Tioctl_callback* = proc (handle: PCurl, cmd: int32, clientp: pointer): Tioerr{. + cdecl.} + Tmalloc_callback* = proc (size: int): pointer{.cdecl.} + Tfree_callback* = proc (p: pointer){.cdecl.} + Trealloc_callback* = proc (p: pointer, size: int): pointer{.cdecl.} + Tstrdup_callback* = proc (str: cstring): cstring{.cdecl.} + Tcalloc_callback* = proc (nmemb: int, size: int): pointer + Tinfotype* = enum + INFO_TEXT = 0, INFO_HEADER_IN, INFO_HEADER_OUT, INFO_DATA_IN, INFO_DATA_OUT, + INFO_SSL_DATA_IN, INFO_SSL_DATA_OUT, INFO_END + Tdebug_callback* = proc (handle: PCurl, theType: Tinfotype, data: cstring, + size: int, userptr: pointer): int32{.cdecl.} + Tcode* = enum + E_OK = 0, E_UNSUPPORTED_PROTOCOL, E_FAILED_INIT, E_URL_MALFORMAT, + E_URL_MALFORMAT_USER, E_COULDNT_RESOLVE_PROXY, E_COULDNT_RESOLVE_HOST, + E_COULDNT_CONNECT, E_FTP_WEIRD_SERVER_REPLY, E_FTP_ACCESS_DENIED, + E_FTP_USER_PASSWORD_INCORRECT, E_FTP_WEIRD_PASS_REPLY, + E_FTP_WEIRD_USER_REPLY, E_FTP_WEIRD_PASV_REPLY, E_FTP_WEIRD_227_FORMAT, + E_FTP_CANT_GET_HOST, E_FTP_CANT_RECONNECT, E_FTP_COULDNT_SET_BINARY, + E_PARTIAL_FILE, E_FTP_COULDNT_RETR_FILE, E_FTP_WRITE_ERROR, + E_FTP_QUOTE_ERROR, E_HTTP_RETURNED_ERROR, E_WRITE_ERROR, E_MALFORMAT_USER, + E_FTP_COULDNT_STOR_FILE, E_READ_ERROR, E_OUT_OF_MEMORY, + E_OPERATION_TIMEOUTED, E_FTP_COULDNT_SET_ASCII, E_FTP_PORT_FAILED, + E_FTP_COULDNT_USE_REST, E_FTP_COULDNT_GET_SIZE, E_HTTP_RANGE_ERROR, + E_HTTP_POST_ERROR, E_SSL_CONNECT_ERROR, E_BAD_DOWNLOAD_RESUME, + E_FILE_COULDNT_READ_FILE, E_LDAP_CANNOT_BIND, E_LDAP_SEARCH_FAILED, + E_LIBRARY_NOT_FOUND, E_FUNCTION_NOT_FOUND, E_ABORTED_BY_CALLBACK, + E_BAD_FUNCTION_ARGUMENT, E_BAD_CALLING_ORDER, E_INTERFACE_FAILED, + E_BAD_PASSWORD_ENTERED, E_TOO_MANY_REDIRECTS, E_UNKNOWN_TELNET_OPTION, + E_TELNET_OPTION_SYNTAX, E_OBSOLETE, E_SSL_PEER_CERTIFICATE, E_GOT_NOTHING, + E_SSL_ENGINE_NOTFOUND, E_SSL_ENGINE_SETFAILED, E_SEND_ERROR, E_RECV_ERROR, + E_SHARE_IN_USE, E_SSL_CERTPROBLEM, E_SSL_CIPHER, E_SSL_CACERT, + E_BAD_CONTENT_ENCODING, E_LDAP_INVALID_URL, E_FILESIZE_EXCEEDED, + E_FTP_SSL_FAILED, E_SEND_FAIL_REWIND, E_SSL_ENGINE_INITFAILED, + E_LOGIN_DENIED, E_TFTP_NOTFOUND, E_TFTP_PERM, E_TFTP_DISKFULL, + E_TFTP_ILLEGAL, E_TFTP_UNKNOWNID, E_TFTP_EXISTS, E_TFTP_NOSUCHUSER, + E_CONV_FAILED, E_CONV_REQD, LAST + Tconv_callback* = proc (buffer: cstring, len: int): Tcode{.cdecl.} + Tssl_ctx_callback* = proc (curl: PCurl, ssl_ctx, userptr: pointer): Tcode{.cdecl.} + Tproxytype* = enum + PROXY_HTTP = 0, PROXY_SOCKS4 = 4, PROXY_SOCKS5 = 5 + Tftpssl* = enum + FTPSSL_NONE, FTPSSL_TRY, FTPSSL_CONTROL, FTPSSL_ALL, FTPSSL_LAST + Tftpauth* = enum + FTPAUTH_DEFAULT, FTPAUTH_SSL, FTPAUTH_TLS, FTPAUTH_LAST + Tftpmethod* = enum + FTPMETHOD_DEFAULT, FTPMETHOD_MULTICWD, FTPMETHOD_NOCWD, FTPMETHOD_SINGLECWD, + FTPMETHOD_LAST + Toption* = enum + OPT_PORT = 0 + 3, OPT_TIMEOUT = 0 + 13, OPT_INFILESIZE = 0 + 14, + OPT_LOW_SPEED_LIMIT = 0 + 19, OPT_LOW_SPEED_TIME = 0 + 20, + OPT_RESUME_FROM = 0 + 21, OPT_CRLF = 0 + 27, OPT_SSLVERSION = 0 + 32, + OPT_TIMECONDITION = 0 + 33, OPT_TIMEVALUE = 0 + 34, OPT_VERBOSE = 0 + 41, + OPT_HEADER = 0 + 42, OPT_NOPROGRESS = 0 + 43, OPT_NOBODY = 0 + 44, + OPT_FAILONERROR = 0 + 45, OPT_UPLOAD = 0 + 46, OPT_POST = 0 + 47, + OPT_FTPLISTONLY = 0 + 48, OPT_FTPAPPEND = 0 + 50, OPT_NETRC = 0 + 51, + OPT_FOLLOWLOCATION = 0 + 52, OPT_TRANSFERTEXT = 0 + 53, OPT_PUT = 0 + 54, + OPT_AUTOREFERER = 0 + 58, OPT_PROXYPORT = 0 + 59, + OPT_POSTFIELDSIZE = 0 + 60, OPT_HTTPPROXYTUNNEL = 0 + 61, + OPT_SSL_VERIFYPEER = 0 + 64, OPT_MAXREDIRS = 0 + 68, OPT_FILETIME = 0 + 69, + OPT_MAXCONNECTS = 0 + 71, OPT_CLOSEPOLICY = 0 + 72, + OPT_FRESH_CONNECT = 0 + 74, OPT_FORBID_REUSE = 0 + 75, + OPT_CONNECTTIMEOUT = 0 + 78, OPT_HTTPGET = 0 + 80, + OPT_SSL_VERIFYHOST = 0 + 81, OPT_HTTP_VERSION = 0 + 84, + OPT_FTP_USE_EPSV = 0 + 85, OPT_SSLENGINE_DEFAULT = 0 + 90, + OPT_DNS_USE_GLOBAL_CACHE = 0 + 91, OPT_DNS_CACHE_TIMEOUT = 0 + 92, + OPT_COOKIESESSION = 0 + 96, OPT_BUFFERSIZE = 0 + 98, OPT_NOSIGNAL = 0 + 99, + OPT_PROXYTYPE = 0 + 101, OPT_UNRESTRICTED_AUTH = 0 + 105, + OPT_FTP_USE_EPRT = 0 + 106, OPT_HTTPAUTH = 0 + 107, + OPT_FTP_CREATE_MISSING_DIRS = 0 + 110, OPT_PROXYAUTH = 0 + 111, + OPT_FTP_RESPONSE_TIMEOUT = 0 + 112, OPT_IPRESOLVE = 0 + 113, + OPT_MAXFILESIZE = 0 + 114, OPT_FTP_SSL = 0 + 119, OPT_TCP_NODELAY = 0 + 121, + OPT_FTPSSLAUTH = 0 + 129, OPT_IGNORE_CONTENT_LENGTH = 0 + 136, + OPT_FTP_SKIP_PASV_IP = 0 + 137, OPT_FTP_FILEMETHOD = 0 + 138, + OPT_LOCALPORT = 0 + 139, OPT_LOCALPORTRANGE = 0 + 140, + OPT_CONNECT_ONLY = 0 + 141, OPT_FILE = 10000 + 1, OPT_URL = 10000 + 2, + OPT_PROXY = 10000 + 4, OPT_USERPWD = 10000 + 5, + OPT_PROXYUSERPWD = 10000 + 6, OPT_RANGE = 10000 + 7, OPT_INFILE = 10000 + 9, + OPT_ERRORBUFFER = 10000 + 10, OPT_POSTFIELDS = 10000 + 15, + OPT_REFERER = 10000 + 16, OPT_FTPPORT = 10000 + 17, + OPT_USERAGENT = 10000 + 18, OPT_COOKIE = 10000 + 22, + OPT_HTTPHEADER = 10000 + 23, OPT_HTTPPOST = 10000 + 24, + OPT_SSLCERT = 10000 + 25, OPT_SSLCERTPASSWD = 10000 + 26, + OPT_QUOTE = 10000 + 28, OPT_WRITEHEADER = 10000 + 29, + OPT_COOKIEFILE = 10000 + 31, OPT_CUSTOMREQUEST = 10000 + 36, + OPT_STDERR = 10000 + 37, OPT_POSTQUOTE = 10000 + 39, + OPT_WRITEINFO = 10000 + 40, OPT_PROGRESSDATA = 10000 + 57, + OPT_INTERFACE = 10000 + 62, OPT_KRB4LEVEL = 10000 + 63, + OPT_CAINFO = 10000 + 65, OPT_TELNETOPTIONS = 10000 + 70, + OPT_RANDOM_FILE = 10000 + 76, OPT_EGDSOCKET = 10000 + 77, + OPT_COOKIEJAR = 10000 + 82, OPT_SSL_CIPHER_LIST = 10000 + 83, + OPT_SSLCERTTYPE = 10000 + 86, OPT_SSLKEY = 10000 + 87, + OPT_SSLKEYTYPE = 10000 + 88, OPT_SSLENGINE = 10000 + 89, + OPT_PREQUOTE = 10000 + 93, OPT_DEBUGDATA = 10000 + 95, + OPT_CAPATH = 10000 + 97, OPT_SHARE = 10000 + 100, + OPT_ENCODING = 10000 + 102, OPT_PRIVATE = 10000 + 103, + OPT_HTTP200ALIASES = 10000 + 104, OPT_SSL_CTX_DATA = 10000 + 109, + OPT_NETRC_FILE = 10000 + 118, OPT_SOURCE_USERPWD = 10000 + 123, + OPT_SOURCE_PREQUOTE = 10000 + 127, OPT_SOURCE_POSTQUOTE = 10000 + 128, + OPT_IOCTLDATA = 10000 + 131, OPT_SOURCE_URL = 10000 + 132, + OPT_SOURCE_QUOTE = 10000 + 133, OPT_FTP_ACCOUNT = 10000 + 134, + OPT_COOKIELIST = 10000 + 135, OPT_FTP_ALTERNATIVE_TO_USER = 10000 + 147, + OPT_LASTENTRY = 10000 + 148, OPT_WRITEFUNCTION = 20000 + 11, + OPT_READFUNCTION = 20000 + 12, OPT_PROGRESSFUNCTION = 20000 + 56, + OPT_HEADERFUNCTION = 20000 + 79, OPT_DEBUGFUNCTION = 20000 + 94, + OPT_SSL_CTX_FUNCTION = 20000 + 108, OPT_IOCTLFUNCTION = 20000 + 130, + OPT_CONV_FROM_NETWORK_FUNCTION = 20000 + 142, + OPT_CONV_TO_NETWORK_FUNCTION = 20000 + 143, + OPT_CONV_FROM_UTF8_FUNCTION = 20000 + 144, + OPT_INFILESIZE_LARGE = 30000 + 115, OPT_RESUME_FROM_LARGE = 30000 + 116, + OPT_MAXFILESIZE_LARGE = 30000 + 117, OPT_POSTFIELDSIZE_LARGE = 30000 + 120, + OPT_MAX_SEND_SPEED_LARGE = 30000 + 145, + OPT_MAX_RECV_SPEED_LARGE = 30000 + 146 + THTTP_VERSION* = enum + HTTP_VERSION_NONE, HTTP_VERSION_1_0, HTTP_VERSION_1_1, HTTP_VERSION_LAST + TNETRC_OPTION* = enum + NETRC_IGNORED, NETRC_OPTIONAL, NETRC_REQUIRED, NETRC_LAST + TSSL_VERSION* = enum + SSLVERSION_DEFAULT, SSLVERSION_TLSv1, SSLVERSION_SSLv2, SSLVERSION_SSLv3, + SSLVERSION_LAST + TTIMECOND* = enum + TIMECOND_NONE, TIMECOND_IFMODSINCE, TIMECOND_IFUNMODSINCE, TIMECOND_LASTMOD, + TIMECOND_LAST + Tformoption* = enum + FORM_NOTHING, FORM_COPYNAME, FORM_PTRNAME, FORM_NAMELENGTH, + FORM_COPYCONTENTS, FORM_PTRCONTENTS, FORM_CONTENTSLENGTH, FORM_FILECONTENT, + FORM_ARRAY, FORM_OBSOLETE, FORM_FILE, FORM_BUFFER, FORM_BUFFERPTR, + FORM_BUFFERLENGTH, FORM_CONTENTTYPE, FORM_CONTENTHEADER, FORM_FILENAME, + FORM_END, FORM_OBSOLETE2, FORM_LASTENTRY + Tforms*{.pure, final.} = object + option*: Tformoption + value*: cstring + + TFORMcode* = enum + FORMADD_OK, FORMADD_MEMORY, FORMADD_OPTION_TWICE, FORMADD_NULL, + FORMADD_UNKNOWN_OPTION, FORMADD_INCOMPLETE, FORMADD_ILLEGAL_ARRAY, + FORMADD_DISABLED, FORMADD_LAST + Tformget_callback* = proc (arg: pointer, buf: cstring, length: int): int{. + cdecl.} + Tslist*{.pure, final.} = object + data*: cstring + next*: Pslist + + TINFO* = enum + INFO_NONE = 0, INFO_LASTONE = 30, INFO_EFFECTIVE_URL = 0x00100000 + 1, + INFO_CONTENT_TYPE = 0x00100000 + 18, INFO_PRIVATE = 0x00100000 + 21, + INFO_FTP_ENTRY_PATH = 0x00100000 + 30, INFO_RESPONSE_CODE = 0x00200000 + 2, + INFO_HEADER_SIZE = 0x00200000 + 11, INFO_REQUEST_SIZE = 0x00200000 + 12, + INFO_SSL_VERIFYRESULT = 0x00200000 + 13, INFO_FILETIME = 0x00200000 + 14, + INFO_REDIRECT_COUNT = 0x00200000 + 20, + INFO_HTTP_CONNECTCODE = 0x00200000 + 22, + INFO_HTTPAUTH_AVAIL = 0x00200000 + 23, + INFO_PROXYAUTH_AVAIL = 0x00200000 + 24, INFO_OS_ERRNO = 0x00200000 + 25, + INFO_NUM_CONNECTS = 0x00200000 + 26, INFO_LASTSOCKET = 0x00200000 + 29, + INFO_TOTAL_TIME = 0x00300000 + 3, INFO_NAMELOOKUP_TIME = 0x00300000 + 4, + INFO_CONNECT_TIME = 0x00300000 + 5, INFO_PRETRANSFER_TIME = 0x00300000 + 6, + INFO_SIZE_UPLOAD = 0x00300000 + 7, INFO_SIZE_DOWNLOAD = 0x00300000 + 8, + INFO_SPEED_DOWNLOAD = 0x00300000 + 9, INFO_SPEED_UPLOAD = 0x00300000 + 10, + INFO_CONTENT_LENGTH_DOWNLOAD = 0x00300000 + 15, + INFO_CONTENT_LENGTH_UPLOAD = 0x00300000 + 16, + INFO_STARTTRANSFER_TIME = 0x00300000 + 17, + INFO_REDIRECT_TIME = 0x00300000 + 19, INFO_SSL_ENGINES = 0x00400000 + 27, + INFO_COOKIELIST = 0x00400000 + 28 + Tclosepolicy* = enum + CLOSEPOLICY_NONE, CLOSEPOLICY_OLDEST, CLOSEPOLICY_LEAST_RECENTLY_USED, + CLOSEPOLICY_LEAST_TRAFFIC, CLOSEPOLICY_SLOWEST, CLOSEPOLICY_CALLBACK, + CLOSEPOLICY_LAST + Tlock_data* = enum + LOCK_DATA_NONE = 0, LOCK_DATA_SHARE, LOCK_DATA_COOKIE, LOCK_DATA_DNS, + LOCK_DATA_SSL_SESSION, LOCK_DATA_CONNECT, LOCK_DATA_LAST + Tlock_access* = enum + LOCK_ACCESS_NONE = 0, LOCK_ACCESS_SHARED = 1, LOCK_ACCESS_SINGLE = 2, + LOCK_ACCESS_LAST + Tlock_function* = proc (handle: PCurl, data: Tlock_data, + locktype: Tlock_access, + userptr: pointer){.cdecl.} + Tunlock_function* = proc (handle: PCurl, data: Tlock_data, userptr: pointer){. + cdecl.} + TSH* = pointer + TSHcode* = enum + SHE_OK, SHE_BAD_OPTION, SHE_IN_USE, SHE_INVALID, SHE_NOMEM, SHE_LAST + TSHoption* = enum + SHOPT_NONE, SHOPT_SHARE, SHOPT_UNSHARE, SHOPT_LOCKFUNC, SHOPT_UNLOCKFUNC, + SHOPT_USERDATA, SHOPT_LAST + Tversion* = enum + VERSION_FIRST, VERSION_SECOND, VERSION_THIRD, VERSION_LAST + Tversion_info_data*{.pure, final.} = object + age*: Tversion + version*: cstring + version_num*: int32 + host*: cstring + features*: int32 + ssl_version*: cstring + ssl_version_num*: int32 + libz_version*: cstring + protocols*: cstringArray + ares*: cstring + ares_num*: int32 + libidn*: cstring + iconv_ver_num*: int32 + + TM* = pointer + Tsocket* = int32 + TMcode* = enum + M_CALL_MULTI_PERFORM = - 1, M_OK = 0, M_BAD_HANDLE, M_BAD_EASY_HANDLE, + M_OUT_OF_MEMORY, M_INTERNAL_ERROR, M_BAD_SOCKET, M_UNKNOWN_OPTION, M_LAST + TMSGEnum* = enum + MSG_NONE, MSG_DONE, MSG_LAST + TMsg*{.pure, final.} = object + msg*: TMSGEnum + easy_handle*: PCurl + whatever*: Pointer #data : record + # case longint of + # 0 : ( whatever : pointer ); + # 1 : ( result : CURLcode ); + # end; + + Tsocket_callback* = proc (easy: PCurl, s: Tsocket, what: int32, + userp, socketp: pointer): int32{.cdecl.} + TMoption* = enum + MOPT_SOCKETDATA = 10000 + 2, MOPT_LASTENTRY = 10000 + 3, + MOPT_SOCKETFUNCTION = 20000 + 1 + +const + OPT_SSLKEYPASSWD* = OPT_SSLCERTPASSWD + AUTH_ANY* = not (0) + AUTH_BASIC* = 1 shl 0 + AUTH_ANYSAFE* = not (AUTH_BASIC) + AUTH_DIGEST* = 1 shl 1 + AUTH_GSSNEGOTIATE* = 1 shl 2 + AUTH_NONE* = 0 + AUTH_NTLM* = 1 shl 3 + E_ALREADY_COMPLETE* = 99999 + E_FTP_BAD_DOWNLOAD_RESUME* = E_BAD_DOWNLOAD_RESUME + E_FTP_PARTIAL_FILE* = E_PARTIAL_FILE + E_HTTP_NOT_FOUND* = E_HTTP_RETURNED_ERROR + E_HTTP_PORT_FAILED* = E_INTERFACE_FAILED + E_OPERATION_TIMEDOUT* = E_OPERATION_TIMEOUTED + ERROR_SIZE* = 256 + FORMAT_OFF_T* = "%ld" + GLOBAL_NOTHING* = 0 + GLOBAL_SSL* = 1 shl 0 + GLOBAL_WIN32* = 1 shl 1 + GLOBAL_ALL* = GLOBAL_SSL or GLOBAL_WIN32 + GLOBAL_DEFAULT* = GLOBAL_ALL + INFO_DOUBLE* = 0x00300000 + INFO_HTTP_CODE* = INFO_RESPONSE_CODE + INFO_LONG* = 0x00200000 + INFO_MASK* = 0x000FFFFF + INFO_SLIST* = 0x00400000 + INFO_STRING* = 0x00100000 + INFO_TYPEMASK* = 0x00F00000 + IPRESOLVE_V4* = 1 + IPRESOLVE_V6* = 2 + IPRESOLVE_WHATEVER* = 0 + MAX_WRITE_SIZE* = 16384 + M_CALL_MULTI_SOCKET* = M_CALL_MULTI_PERFORM + OPT_CLOSEFUNCTION* = - (5) + OPT_FTPASCII* = OPT_TRANSFERTEXT + OPT_HEADERDATA* = OPT_WRITEHEADER + OPT_HTTPREQUEST* = - (1) + OPT_MUTE* = - (2) + OPT_PASSWDDATA* = - (4) + OPT_PASSWDFUNCTION* = - (3) + OPT_PASV_HOST* = - (9) + OPT_READDATA* = OPT_INFILE + OPT_SOURCE_HOST* = - (6) + OPT_SOURCE_PATH* = - (7) + OPT_SOURCE_PORT* = - (8) + OPTTYPE_FUNCTIONPOINT* = 20000 + OPTTYPE_LONG* = 0 + OPTTYPE_OBJECTPOINT* = 10000 + OPTTYPE_OFF_T* = 30000 + OPT_WRITEDATA* = OPT_FILE + POLL_IN* = 1 + POLL_INOUT* = 3 + POLL_NONE* = 0 + POLL_OUT* = 2 + POLL_REMOVE* = 4 + READFUNC_ABORT* = 0x10000000 + SOCKET_BAD* = - (1) + SOCKET_TIMEOUT* = SOCKET_BAD + VERSION_ASYNCHDNS* = 1 shl 7 + VERSION_CONV* = 1 shl 12 + VERSION_DEBUG* = 1 shl 6 + VERSION_GSSNEGOTIATE* = 1 shl 5 + VERSION_IDN* = 1 shl 10 + VERSION_IPV6* = 1 shl 0 + VERSION_KERBEROS4* = 1 shl 1 + VERSION_LARGEFILE* = 1 shl 9 + VERSION_LIBZ* = 1 shl 3 + VERSION_NOW* = VERSION_THIRD + VERSION_NTLM* = 1 shl 4 + VERSION_SPNEGO* = 1 shl 8 + VERSION_SSL* = 1 shl 2 + VERSION_SSPI* = 1 shl 11 + FILE_OFFSET_BITS* = 0 + FILESIZEBITS* = 0 + FUNCTIONPOINT* = OPTTYPE_FUNCTIONPOINT + HTTPPOST_BUFFER* = 1 shl 4 + HTTPPOST_FILENAME* = 1 shl 0 + HTTPPOST_PTRBUFFER* = 1 shl 5 + HTTPPOST_PTRCONTENTS* = 1 shl 3 + HTTPPOST_PTRNAME* = 1 shl 2 + HTTPPOST_READFILE* = 1 shl 1 + LIBCURL_VERSION* = "7.15.5" + LIBCURL_VERSION_MAJOR* = 7 + LIBCURL_VERSION_MINOR* = 15 + LIBCURL_VERSION_NUM* = 0x00070F05 + LIBCURL_VERSION_PATCH* = 5 + +proc strequal*(s1, s2: cstring): int32{.cdecl, dynlib: libname, + importc: "curl_strequal".} +proc strnequal*(s1, s2: cstring, n: int): int32{.cdecl, dynlib: libname, + importc: "curl_strnequal".} +proc formadd*(httppost, last_post: PPcurl_httppost): TFORMcode{.cdecl, varargs, + dynlib: libname, importc: "curl_formadd".} +proc formget*(form: Phttppost, arg: pointer, append: Tformget_callback): int32{. + cdecl, dynlib: libname, importc: "curl_formget".} +proc formfree*(form: Phttppost){.cdecl, dynlib: libname, + importc: "curl_formfree".} +proc getenv*(variable: cstring): cstring{.cdecl, dynlib: libname, + importc: "curl_getenv".} +proc version*(): cstring{.cdecl, dynlib: libname, importc: "curl_version".} +proc easy_escape*(handle: PCurl, str: cstring, len: int32): cstring{.cdecl, + dynlib: libname, importc: "curl_easy_escape".} +proc escape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname, + importc: "curl_escape".} +proc easy_unescape*(handle: PCurl, str: cstring, len: int32, outlength: var int32): cstring{. + cdecl, dynlib: libname, importc: "curl_easy_unescape".} +proc unescape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname, + importc: "curl_unescape".} +proc free*(p: pointer){.cdecl, dynlib: libname, importc: "curl_free".} +proc global_init*(flags: int32): Tcode{.cdecl, dynlib: libname, + importc: "curl_global_init".} +proc global_init_mem*(flags: int32, m: Tmalloc_callback, f: Tfree_callback, + r: Trealloc_callback, s: Tstrdup_callback, + c: Tcalloc_callback): Tcode{.cdecl, dynlib: libname, + importc: "curl_global_init_mem".} +proc global_cleanup*(){.cdecl, dynlib: libname, importc: "curl_global_cleanup".} +proc slist_append*(slist: Pslist, p: cstring): Pslist{.cdecl, dynlib: libname, + importc: "curl_slist_append".} +proc slist_free_all*(para1: Pslist){.cdecl, dynlib: libname, + importc: "curl_slist_free_all".} +proc getdate*(p: cstring, unused: ptr TTime): TTime{.cdecl, dynlib: libname, + importc: "curl_getdate".} +proc share_init*(): PSH{.cdecl, dynlib: libname, importc: "curl_share_init".} +proc share_setopt*(para1: PSH, option: TSHoption): TSHcode{.cdecl, varargs, + dynlib: libname, importc: "curl_share_setopt".} +proc share_cleanup*(para1: PSH): TSHcode{.cdecl, dynlib: libname, + importc: "curl_share_cleanup".} +proc version_info*(para1: Tversion): Pversion_info_data{.cdecl, dynlib: libname, + importc: "curl_version_info".} +proc easy_strerror*(para1: Tcode): cstring{.cdecl, dynlib: libname, + importc: "curl_easy_strerror".} +proc share_strerror*(para1: TSHcode): cstring{.cdecl, dynlib: libname, + importc: "curl_share_strerror".} +proc easy_init*(): PCurl{.cdecl, dynlib: libname, importc: "curl_easy_init".} +proc easy_setopt*(curl: PCurl, option: Toption): Tcode{.cdecl, varargs, dynlib: libname, + importc: "curl_easy_setopt".} +proc easy_perform*(curl: PCurl): Tcode{.cdecl, dynlib: libname, + importc: "curl_easy_perform".} +proc easy_cleanup*(curl: PCurl){.cdecl, dynlib: libname, importc: "curl_easy_cleanup".} +proc easy_getinfo*(curl: PCurl, info: TINFO): Tcode{.cdecl, varargs, dynlib: libname, + importc: "curl_easy_getinfo".} +proc easy_duphandle*(curl: PCurl): PCurl{.cdecl, dynlib: libname, + importc: "curl_easy_duphandle".} +proc easy_reset*(curl: PCurl){.cdecl, dynlib: libname, importc: "curl_easy_reset".} +proc multi_init*(): PM{.cdecl, dynlib: libname, importc: "curl_multi_init".} +proc multi_add_handle*(multi_handle: PM, handle: PCurl): TMcode{.cdecl, + dynlib: libname, importc: "curl_multi_add_handle".} +proc multi_remove_handle*(multi_handle: PM, handle: PCurl): TMcode{.cdecl, + dynlib: libname, importc: "curl_multi_remove_handle".} +proc multi_fdset*(multi_handle: PM, read_fd_set: Pfd_set, write_fd_set: Pfd_set, + exc_fd_set: Pfd_set, max_fd: var int32): TMcode{.cdecl, + dynlib: libname, importc: "curl_multi_fdset".} +proc multi_perform*(multi_handle: PM, running_handles: var int32): TMcode{. + cdecl, dynlib: libname, importc: "curl_multi_perform".} +proc multi_cleanup*(multi_handle: PM): TMcode{.cdecl, dynlib: libname, + importc: "curl_multi_cleanup".} +proc multi_info_read*(multi_handle: PM, msgs_in_queue: var int32): PMsg{.cdecl, + dynlib: libname, importc: "curl_multi_info_read".} +proc multi_strerror*(para1: TMcode): cstring{.cdecl, dynlib: libname, + importc: "curl_multi_strerror".} +proc multi_socket*(multi_handle: PM, s: Tsocket, running_handles: var int32): TMcode{. + cdecl, dynlib: libname, importc: "curl_multi_socket".} +proc multi_socket_all*(multi_handle: PM, running_handles: var int32): TMcode{. + cdecl, dynlib: libname, importc: "curl_multi_socket_all".} +proc multi_timeout*(multi_handle: PM, milliseconds: var int32): TMcode{.cdecl, + dynlib: libname, importc: "curl_multi_timeout".} +proc multi_setopt*(multi_handle: PM, option: TMoption): TMcode{.cdecl, varargs, + dynlib: libname, importc: "curl_multi_setopt".} +proc multi_assign*(multi_handle: PM, sockfd: Tsocket, sockp: pointer): TMcode{. + cdecl, dynlib: libname, importc: "curl_multi_assign".} diff --git a/lib/wrappers/pcre.nim b/lib/wrappers/pcre.nim new file mode 100644 index 000000000..7e75035da --- /dev/null +++ b/lib/wrappers/pcre.nim @@ -0,0 +1,285 @@ +#************************************************ +# Perl-Compatible Regular Expressions * +#*********************************************** +# This is the public header file for the PCRE library, to be #included by +#applications that call the PCRE functions. +# +# Copyright (c) 1997-2010 University of Cambridge +# +#----------------------------------------------------------------------------- +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# Neither the name of the University of Cambridge nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +#ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +#INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +#CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +#ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +#POSSIBILITY OF SUCH DAMAGE. +#----------------------------------------------------------------------------- +# + +when not defined(pcreDll): + when hostOS == "windows": + const pcreDll = "pcre3.dll" + elif hostOS == "macosx": + const pcreDll = "libpcre.dynlib" + else: + const pcreDll = "libpcre.so(.3|)" + +# The current PCRE version information. + +const + MAJOR* = 8 + MINOR* = 10 + PRERELEASE* = true + DATE* = "2010-06-25" + +# When an application links to a PCRE DLL in Windows, the symbols that are +#imported have to be identified as such. When building PCRE, the appropriate +#export setting is defined in pcre_internal.h, which includes this file. So we +#don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. + +# Have to include stdlib.h in order to ensure that size_t is defined; +#it is needed here for malloc. + +# Allow for C++ users + +# Options. Some are compile-time only, some are run-time only, and some are +#both, so we keep them all distinct. + +const + CASELESS* = 0x00000001 + MULTILINE* = 0x00000002 + DOTALL* = 0x00000004 + EXTENDED* = 0x00000008 + ANCHORED* = 0x00000010 + DOLLAR_ENDONLY* = 0x00000020 + EXTRA* = 0x00000040 + NOTBOL* = 0x00000080 + NOTEOL* = 0x00000100 + UNGREEDY* = 0x00000200 + NOTEMPTY* = 0x00000400 + UTF8* = 0x00000800 + NO_AUTO_CAPTURE* = 0x00001000 + NO_UTF8_CHECK* = 0x00002000 + AUTO_CALLOUT* = 0x00004000 + PARTIAL_SOFT* = 0x00008000 + PARTIAL* = 0x00008000 # Backwards compatible synonym + DFA_SHORTEST* = 0x00010000 + DFA_RESTART* = 0x00020000 + FIRSTLINE* = 0x00040000 + DUPNAMES* = 0x00080000 + NEWLINE_CR* = 0x00100000 + NEWLINE_LF* = 0x00200000 + NEWLINE_CRLF* = 0x00300000 + NEWLINE_ANY* = 0x00400000 + NEWLINE_ANYCRLF* = 0x00500000 + BSR_ANYCRLF* = 0x00800000 + BSR_UNICODE* = 0x01000000 + JAVASCRIPT_COMPAT* = 0x02000000 + NO_START_OPTIMIZE* = 0x04000000 + NO_START_OPTIMISE* = 0x04000000 + PARTIAL_HARD* = 0x08000000 + NOTEMPTY_ATSTART* = 0x10000000 + UCP* = 0x20000000 + +# Exec-time and get/set-time error codes + +const + ERROR_NOMATCH* = (- 1) + ERROR_NULL* = (- 2) + ERROR_BADOPTION* = (- 3) + ERROR_BADMAGIC* = (- 4) + ERROR_UNKNOWN_OPCODE* = (- 5) + ERROR_UNKNOWN_NODE* = (- 5) # For backward compatibility + ERROR_NOMEMORY* = (- 6) + ERROR_NOSUBSTRING* = (- 7) + ERROR_MATCHLIMIT* = (- 8) + ERROR_CALLOUT* = (- 9) # Never used by PCRE itself + ERROR_BADUTF8* = (- 10) + ERROR_BADUTF8_OFFSET* = (- 11) + ERROR_PARTIAL* = (- 12) + ERROR_BADPARTIAL* = (- 13) + ERROR_INTERNAL* = (- 14) + ERROR_BADCOUNT* = (- 15) + ERROR_DFA_UITEM* = (- 16) + ERROR_DFA_UCOND* = (- 17) + ERROR_DFA_UMLIMIT* = (- 18) + ERROR_DFA_WSSIZE* = (- 19) + ERROR_DFA_RECURSE* = (- 20) + ERROR_RECURSIONLIMIT* = (- 21) + ERROR_NULLWSLIMIT* = (- 22) # No longer actually used + ERROR_BADNEWLINE* = (- 23) + +# Request types for pcre_fullinfo() + +const + INFO_OPTIONS* = 0 + INFO_SIZE* = 1 + INFO_CAPTURECOUNT* = 2 + INFO_BACKREFMAX* = 3 + INFO_FIRSTBYTE* = 4 + INFO_FIRSTCHAR* = 4 # For backwards compatibility + INFO_FIRSTTABLE* = 5 + INFO_LASTLITERAL* = 6 + INFO_NAMEENTRYSIZE* = 7 + INFO_NAMECOUNT* = 8 + INFO_NAMETABLE* = 9 + INFO_STUDYSIZE* = 10 + INFO_DEFAULT_TABLES* = 11 + INFO_OKPARTIAL* = 12 + INFO_JCHANGED* = 13 + INFO_HASCRORLF* = 14 + INFO_MINLENGTH* = 15 + +# Request types for pcre_config(). Do not re-arrange, in order to remain +#compatible. + +const + CONFIG_UTF8* = 0 + CONFIG_NEWLINE* = 1 + CONFIG_LINK_SIZE* = 2 + CONFIG_POSIX_MALLOC_THRESHOLD* = 3 + CONFIG_MATCH_LIMIT* = 4 + CONFIG_STACKRECURSE* = 5 + CONFIG_UNICODE_PROPERTIES* = 6 + CONFIG_MATCH_LIMIT_RECURSION* = 7 + CONFIG_BSR* = 8 + +# Bit flags for the pcre_extra structure. Do not re-arrange or redefine +#these bits, just add new ones on the end, in order to remain compatible. + +const + EXTRA_STUDY_DATA* = 0x00000001 + EXTRA_MATCH_LIMIT* = 0x00000002 + EXTRA_CALLOUT_DATA* = 0x00000004 + EXTRA_TABLES* = 0x00000008 + EXTRA_MATCH_LIMIT_RECURSION* = 0x00000010 + EXTRA_MARK* = 0x00000020 + +# Types + +type + TPcre*{.pure, final.} = object + PPcre* = ptr TPcre + +# When PCRE is compiled as a C++ library, the subject pointer type can be +#replaced with a custom type. For conventional use, the public interface is a +#const char *. + +# The structure for passing additional data to pcre_exec(). This is defined in +#such as way as to be extensible. Always add new fields at the end, in order to +#remain compatible. + +type + Textra*{.pure, final.} = object + flags*: int ## Bits for which fields are set + study_data*: pointer ## Opaque data from pcre_study() + match_limit*: int ## Maximum number of calls to match() + callout_data*: pointer ## Data passed back in callouts + tables*: ptr char ## Pointer to character tables + match_limit_recursion*: int ## Max recursive calls to match() + mark*: ptr ptr char ## For passing back a mark pointer + + +# The structure for passing out data via the pcre_callout_function. We use a +#structure so that new fields can be added on the end in future versions, +#without changing the API of the function, thereby allowing old clients to work +#without modification. + +type + Tcallout_block*{.pure, final.} = object + version*: cint ## Identifies version of block + callout_number*: cint ## Number compiled into pattern + offset_vector*: ptr cint ## The offset vector + subject*: cstring ## The subject being matched + subject_length*: cint ## The length of the subject + start_match*: cint ## Offset to start of this match attempt + current_position*: cint ## Where we currently are in the subject + capture_top*: cint ## Max current capture + capture_last*: cint ## Most recently closed capture + callout_data*: pointer ## Data passed in with the call + pattern_position*: cint ## Offset to next item in the pattern + next_item_length*: cint ## Length of next item in the pattern + +# Indirection for store get and free functions. These can be set to +#alternative malloc/free functions if required. Special ones are used in the +#non-recursive case for "frames". There is also an optional callout function +#that is triggered by the (?) regex item. For Virtual Pascal, these definitions +#have to take another form. + +# Exported PCRE functions + +proc compile*(a2: cstring, a3: cint, a4: ptr cstring, a5: ptr cint, + a6: ptr char): ptr TPcre{.cdecl, importc: "pcre_compile", + dynlib: pcredll.} +proc compile2*(a2: cstring, a3: cint, a4: ptr cint, a5: ptr cstring, + a6: ptr cint, a7: ptr char): ptr TPcre{.cdecl, + importc: "pcre_compile2", dynlib: pcredll.} +proc config*(a2: cint, a3: pointer): cint{.cdecl, importc: "pcre_config", + dynlib: pcredll.} +proc copy_named_substring*(a2: ptr TPcre, a3: cstring, a4: ptr cint, a5: cint, + a6: cstring, a7: cstring, a8: cint): cint{.cdecl, + importc: "pcre_copy_named_substring", dynlib: pcredll.} +proc copy_substring*(a2: cstring, a3: ptr cint, a4: cint, a5: cint, + a6: cstring, + a7: cint): cint{.cdecl, importc: "pcre_copy_substring", + dynlib: pcredll.} +proc dfa_exec*(a2: ptr TPcre, a3: ptr Textra, a4: cstring, a5: cint, + a6: cint, a7: cint, a8: ptr cint, a9: cint, a10: ptr cint, + a11: cint): cint{.cdecl, importc: "pcre_dfa_exec", + dynlib: pcredll.} +proc exec*(a2: ptr TPcre, a3: ptr Textra, a4: cstring, a5: cint, a6: cint, + a7: cint, a8: ptr cint, a9: cint): cint {. + cdecl, importc: "pcre_exec", dynlib: pcredll.} +proc free_substring*(a2: cstring){.cdecl, importc: "pcre_free_substring", + dynlib: pcredll.} +proc free_substring_list*(a2: cstringArray){.cdecl, + importc: "pcre_free_substring_list", dynlib: pcredll.} +proc fullinfo*(a2: ptr TPcre, a3: ptr Textra, a4: cint, a5: pointer): cint{. + cdecl, importc: "pcre_fullinfo", dynlib: pcredll.} +proc get_named_substring*(a2: ptr TPcre, a3: cstring, a4: ptr cint, a5: cint, + a6: cstring, a7: cstringArray): cint{.cdecl, + importc: "pcre_get_named_substring", dynlib: pcredll.} +proc get_stringnumber*(a2: ptr TPcre, a3: cstring): cint{.cdecl, + importc: "pcre_get_stringnumber", dynlib: pcredll.} +proc get_stringtable_entries*(a2: ptr TPcre, a3: cstring, a4: cstringArray, + a5: cstringArray): cint{.cdecl, + importc: "pcre_get_stringtable_entries", dynlib: pcredll.} +proc get_substring*(a2: cstring, a3: ptr cint, a4: cint, a5: cint, + a6: cstringArray): cint{.cdecl, + importc: "pcre_get_substring", dynlib: pcredll.} +proc get_substring_list*(a2: cstring, a3: ptr cint, a4: cint, + a5: ptr cstringArray): cint{.cdecl, + importc: "pcre_get_substring_list", dynlib: pcredll.} +proc info*(a2: ptr TPcre, a3: ptr cint, a4: ptr cint): cint{.cdecl, + importc: "pcre_info", dynlib: pcredll.} +proc maketables*(): ptr char{.cdecl, importc: "pcre_maketables", + dynlib: pcredll.} +proc refcount*(a2: ptr TPcre, a3: cint): cint{.cdecl, importc: "pcre_refcount", + dynlib: pcredll.} +proc study*(a2: ptr TPcre, a3: cint, a4: cstringArray): ptr Textra{.cdecl, + importc: "pcre_study", dynlib: pcredll.} +proc version*(): cstring{.cdecl, importc: "pcre_version", dynlib: pcredll.} + +var + pcre_free*: proc (p: ptr TPcre) {.cdecl.} + + diff --git a/lib/wrappers/tre.nim b/lib/wrappers/tre.nim new file mode 100755 index 000000000..f83d402c0 --- /dev/null +++ b/lib/wrappers/tre.nim @@ -0,0 +1,186 @@ +# +# tre.h - TRE public API definitions +# +# This software is released under a BSD-style license. +# See the file LICENSE for details and copyright. +# +# + +when not defined(treDll): + when hostOS == "windows": + const treDll = "tre.dll" + elif hostOS == "macosx": + const treDll = "libtre.dynlib" + else: + const treDll = "libtre.so(.5|)" + +const + APPROX* = 1 ## approximate matching functionality + MULTIBYTE* = 1 ## multibyte character set support. + VERSION* = "0.8.0" ## TRE version string. + VERSION_1* = 0 ## TRE version level 1. + VERSION_2* = 8 ## TRE version level 2. + VERSION_3* = 0 ## TRE version level 3. + + +# If the we're not using system regex.h, we need to define the +# structs and enums ourselves. + +type + TRegoff* = cint + TRegex*{.pure, final.} = object + re_nsub*: int ## Number of parenthesized subexpressions. + value*: pointer ## For internal use only. + + TRegmatch*{.pure, final.} = object + rm_so*: TRegoff + rm_eo*: TRegoff + + TReg_errcode*{.size: 4.} = enum ## POSIX tre_regcomp() return error codes. + ## (In the order listed in the standard.) + REG_OK = 0, ## No error. + REG_NOMATCH, ## No match. + REG_BADPAT, ## Invalid regexp. + REG_ECOLLATE, ## Unknown collating element. + REG_ECTYPE, ## Unknown character class name. + REG_EESCAPE, ## Trailing backslash. + REG_ESUBREG, ## Invalid back reference. + REG_EBRACK, ## "[]" imbalance + REG_EPAREN, ## "\(\)" or "()" imbalance + REG_EBRACE, ## "\{\}" or "{}" imbalance + REG_BADBR, ## Invalid content of {} + REG_ERANGE, ## Invalid use of range operator + REG_ESPACE, ## Out of memory. + REG_BADRPT ## Invalid use of repetition operators. + +# POSIX tre_regcomp() flags. + +const + REG_EXTENDED* = 1 + REG_ICASE* = (REG_EXTENDED shl 1) + REG_NEWLINE* = (REG_ICASE shl 1) + REG_NOSUB* = (REG_NEWLINE shl 1) + +# Extra tre_regcomp() flags. + +const + REG_BASIC* = 0 + REG_LITERAL* = (REG_NOSUB shl 1) + REG_RIGHT_ASSOC* = (REG_LITERAL shl 1) + REG_UNGREEDY* = (REG_RIGHT_ASSOC shl 1) + +# POSIX tre_regexec() flags. + +const + REG_NOTBOL* = 1 + REG_NOTEOL* = (REG_NOTBOL shl 1) + +# Extra tre_regexec() flags. + +const + REG_APPROX_MATCHER* = (REG_NOTEOL shl 1) + REG_BACKTRACKING_MATCHER* = (REG_APPROX_MATCHER shl 1) + +# The maximum number of iterations in a bound expression. + +const + RE_DUP_MAX* = 255 + +# The POSIX.2 regexp functions + +proc regcomp*(preg: var TRegex, regex: cstring, cflags: cint): cint{.cdecl, + importc: "tre_regcomp", dynlib: treDll.} +proc regexec*(preg: var TRegex, string: cstring, nmatch: int, + pmatch: ptr TRegmatch, eflags: cint): cint{.cdecl, + importc: "tre_regexec", dynlib: treDll.} +proc regerror*(errcode: cint, preg: var TRegex, errbuf: cstring, + errbuf_size: int): int{.cdecl, importc: "tre_regerror", + dynlib: treDll.} +proc regfree*(preg: var TRegex){.cdecl, importc: "tre_regfree", dynlib: treDll.} +# Versions with a maximum length argument and therefore the capability to +# handle null characters in the middle of the strings (not in POSIX.2). + +proc regncomp*(preg: var TRegex, regex: cstring, len: int, cflags: cint): cint{. + cdecl, importc: "tre_regncomp", dynlib: treDll.} +proc regnexec*(preg: var TRegex, string: cstring, len: int, nmatch: int, + pmatch: ptr TRegmatch, eflags: cint): cint{.cdecl, + importc: "tre_regnexec", dynlib: treDll.} +# Approximate matching parameter struct. + +type + TRegaparams*{.pure, final.} = object + cost_ins*: cint ## Default cost of an inserted character. + cost_del*: cint ## Default cost of a deleted character. + cost_subst*: cint ## Default cost of a substituted character. + max_cost*: cint ## Maximum allowed cost of a match. + max_ins*: cint ## Maximum allowed number of inserts. + max_del*: cint ## Maximum allowed number of deletes. + max_subst*: cint ## Maximum allowed number of substitutes. + max_err*: cint ## Maximum allowed number of errors total. + + +# Approximate matching result struct. + +type + TRegamatch*{.pure, final.} = object + nmatch*: int ## Length of pmatch[] array. + pmatch*: ptr TRegmatch ## Submatch data. + cost*: cint ## Cost of the match. + num_ins*: cint ## Number of inserts in the match. + num_del*: cint ## Number of deletes in the match. + num_subst*: cint ## Number of substitutes in the match. + + +# Approximate matching functions. + +proc regaexec*(preg: var TRegex, string: cstring, match: ptr TRegamatch, + params: TRegaparams, eflags: cint): cint{.cdecl, + importc: "tre_regaexec", dynlib: treDll.} +proc reganexec*(preg: var TRegex, string: cstring, len: int, + match: ptr TRegamatch, params: TRegaparams, + eflags: cint): cint{. + cdecl, importc: "tre_reganexec", dynlib: treDll.} +# Sets the parameters to default values. + +proc regaparams_default*(params: ptr TRegaparams){.cdecl, + importc: "tre_regaparams_default", dynlib: treDll.} + +type + TStrSource*{.pure, final.} = object + get_next_char*: proc (c: cstring, pos_add: ptr cint, + context: pointer): cint{.cdecl.} + rewind*: proc (pos: int, context: pointer){.cdecl.} + compare*: proc (pos1: int, pos2: int, len: int, context: pointer): cint{. + cdecl.} + context*: pointer + + +proc reguexec*(preg: var TRegex, string: ptr TStrSource, nmatch: int, + pmatch: ptr TRegmatch, eflags: cint): cint{.cdecl, + importc: "tre_reguexec", dynlib: treDll.} + +proc runtimeVersion*(): cstring{.cdecl, importc: "tre_version", dynlib: treDll.} + # Returns the version string. The returned string is static. + +proc config*(query: cint, result: pointer): cint{.cdecl, importc: "tre_config", + dynlib: treDll.} + # Returns the value for a config parameter. The type to which `result` + # must point to depends of the value of `query`, see documentation for + # more details. + +const + CONFIG_APPROX* = 0 + CONFIG_WCHAR* = 1 + CONFIG_MULTIBYTE* = 2 + CONFIG_SYSTEM_ABI* = 3 + CONFIG_VERSION* = 4 + +# Returns 1 if the compiled pattern has back references, 0 if not. + +proc have_backrefs*(preg: var TRegex): cint{.cdecl, + importc: "tre_have_backrefs", dynlib: treDll.} +# Returns 1 if the compiled pattern uses approximate matching features, +# 0 if not. + +proc have_approx*(preg: var TRegex): cint{.cdecl, importc: "tre_have_approx", + dynlib: treDll.} diff --git a/rod/nimrod.ini b/rod/nimrod.ini index ce5ab5de2..8491a46ac 100644 --- a/rod/nimrod.ini +++ b/rod/nimrod.ini @@ -113,6 +113,7 @@ Files: "examples/*.tmpl" Files: "bin/nimrod.exe" Files: "bin/c2nim.exe" Files: "bin/niminst.exe" +Files: "deps/*.dll" Files: "koch.exe" Files: "dist/mingw" Files: "start.bat" @@ -127,7 +128,7 @@ InstallScript: "yes" UninstallScript: "yes" [InnoSetup] -path = r"c:\program files\inno setup 5\iscc.exe" +path = r"c:\programme\inno setup 5\iscc.exe" flags = "/Q" [C_Compiler] |