mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-27 10:56:28 +00:00
version 0.7.6
This commit is contained in:
642
lib/base/libcurl.nim
Normal file
642
lib/base/libcurl.nim
Normal file
@@ -0,0 +1,642 @@
|
||||
#
|
||||
# $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.
|
||||
#
|
||||
|
||||
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
|
||||
Pcurl_calloc_callback* = ptr Tcurl_calloc_callback
|
||||
Pcurl_closepolicy* = ptr Tcurl_closepolicy
|
||||
Pcurl_forms* = ptr Tcurl_forms
|
||||
Pcurl_ftpauth* = ptr Tcurl_ftpauth
|
||||
Pcurl_ftpmethod* = ptr Tcurl_ftpmethod
|
||||
Pcurl_ftpssl* = ptr Tcurl_ftpssl
|
||||
PCURL_HTTP_VERSION* = ptr TCURL_HTTP_VERSION
|
||||
Pcurl_httppost* = ptr Tcurl_httppost
|
||||
PPcurl_httppost* = ptr Pcurl_httppost
|
||||
Pcurl_infotype* = ptr Tcurl_infotype
|
||||
Pcurl_lock_access* = ptr Tcurl_lock_access
|
||||
Pcurl_lock_data* = ptr Tcurl_lock_data
|
||||
Pcurl_malloc_callback* = ptr tcurl_malloc_callback
|
||||
PCURL_NETRC_OPTION* = ptr TCURL_NETRC_OPTION
|
||||
Pcurl_proxytype* = ptr Tcurl_proxytype
|
||||
Pcurl_realloc_callback* = ptr tcurl_realloc_callback
|
||||
Pcurl_slist* = ptr Tcurl_slist
|
||||
Pcurl_socket* = ptr Tcurl_socket
|
||||
PCURL_SSL_VERSION* = ptr TCURL_SSL_VERSION
|
||||
Pcurl_strdup_callback* = ptr Tcurl_strdup_callback
|
||||
PCURL_TIMECOND* = ptr TCURL_TIMECOND
|
||||
Pcurl_version_info_data* = ptr Tcurl_version_info_data
|
||||
PCURLcode* = ptr TCURLcode
|
||||
PCURLFORMcode* = ptr TCURLFORMcode
|
||||
PCURLformoption* = ptr TCURLformoption
|
||||
PCURLINFO* = ptr TCURLINFO
|
||||
Pcurliocmd* = ptr Tcurliocmd
|
||||
Pcurlioerr* = ptr Tcurlioerr
|
||||
PCURLM* = ptr TCURLM
|
||||
PCURLMcode* = ptr TCURLMcode
|
||||
PCURLMoption* = ptr TCURLMoption
|
||||
PCURLMSG* = ptr TCURLMSG
|
||||
PCURLoption* = ptr TCURLoption
|
||||
PCURLSH* = ptr TCURLSH
|
||||
PCURLSHcode* = ptr TCURLSHcode
|
||||
PCURLSHoption* = ptr TCURLSHoption
|
||||
PCURLversion* = ptr TCURLversion
|
||||
Pfd_set* = pointer
|
||||
PCURL* = ptr TCurl
|
||||
TCurl* = pointer
|
||||
Tcurl_httppost* {.final, pure.} = object
|
||||
next*: Pcurl_httppost
|
||||
name*: cstring
|
||||
namelength*: int32
|
||||
contents*: cstring
|
||||
contentslength*: int32
|
||||
buffer*: cstring
|
||||
bufferlength*: int32
|
||||
contenttype*: cstring
|
||||
contentheader*: Pcurl_slist
|
||||
more*: Pcurl_httppost
|
||||
flags*: int32
|
||||
showfilename*: cstring
|
||||
|
||||
Tcurl_progress_callback* = proc (clientp: pointer, dltotal: float64,
|
||||
dlnow: float64, ultotal: float64,
|
||||
ulnow: float64): int32{.cdecl.}
|
||||
Tcurl_write_callback* = proc (buffer: cstring, size: int, nitems: int,
|
||||
outstream: pointer): int{.cdecl.}
|
||||
Tcurl_read_callback* = proc (buffer: cstring, size: int, nitems: int,
|
||||
instream: pointer): int{.cdecl.}
|
||||
Tcurl_passwd_callback* = proc (clientp: pointer, prompt: cstring,
|
||||
buffer: cstring, buflen: int32): int32{.cdecl.}
|
||||
Tcurlioerr* = enum
|
||||
CURLIOE_OK, CURLIOE_UNKNOWNCMD, CURLIOE_FAILRESTART, CURLIOE_LAST
|
||||
Tcurliocmd* = enum
|
||||
CURLIOCMD_NOP, CURLIOCMD_RESTARTREAD, CURLIOCMD_LAST
|
||||
Tcurl_ioctl_callback* = proc (handle: PCURL, cmd: int32,
|
||||
clientp: pointer): Tcurlioerr {.cdecl.}
|
||||
Tcurl_malloc_callback* = proc (size: int): pointer {.cdecl.}
|
||||
Tcurl_free_callback* = proc (p: pointer) {.cdecl.}
|
||||
Tcurl_realloc_callback* = proc (p: pointer, size: int): pointer {.cdecl.}
|
||||
Tcurl_strdup_callback* = proc (str: cstring): cstring {.cdecl.}
|
||||
Tcurl_calloc_callback* = proc (nmemb: int, size: int): pointer
|
||||
Tcurl_infotype* = enum
|
||||
CURLINFO_TEXT = 0, CURLINFO_HEADER_IN, CURLINFO_HEADER_OUT,
|
||||
CURLINFO_DATA_IN, CURLINFO_DATA_OUT, CURLINFO_SSL_DATA_IN,
|
||||
CURLINFO_SSL_DATA_OUT, CURLINFO_END
|
||||
Tcurl_debug_callback* = proc (handle: PCURL, theType: Tcurl_infotype,
|
||||
data: cstring, size: int,
|
||||
userptr: pointer): int32 {.cdecl.}
|
||||
TCURLcode* = enum
|
||||
CURLE_OK = 0, CURLE_UNSUPPORTED_PROTOCOL, CURLE_FAILED_INIT,
|
||||
CURLE_URL_MALFORMAT, CURLE_URL_MALFORMAT_USER, CURLE_COULDNT_RESOLVE_PROXY,
|
||||
CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT,
|
||||
CURLE_FTP_WEIRD_SERVER_REPLY, CURLE_FTP_ACCESS_DENIED,
|
||||
CURLE_FTP_USER_PASSWORD_INCORRECT, CURLE_FTP_WEIRD_PASS_REPLY,
|
||||
CURLE_FTP_WEIRD_USER_REPLY, CURLE_FTP_WEIRD_PASV_REPLY,
|
||||
CURLE_FTP_WEIRD_227_FORMAT, CURLE_FTP_CANT_GET_HOST,
|
||||
CURLE_FTP_CANT_RECONNECT, CURLE_FTP_COULDNT_SET_BINARY, CURLE_PARTIAL_FILE,
|
||||
CURLE_FTP_COULDNT_RETR_FILE, CURLE_FTP_WRITE_ERROR, CURLE_FTP_QUOTE_ERROR,
|
||||
CURLE_HTTP_RETURNED_ERROR, CURLE_WRITE_ERROR, CURLE_MALFORMAT_USER,
|
||||
CURLE_FTP_COULDNT_STOR_FILE, CURLE_READ_ERROR, CURLE_OUT_OF_MEMORY,
|
||||
CURLE_OPERATION_TIMEOUTED, CURLE_FTP_COULDNT_SET_ASCII,
|
||||
CURLE_FTP_PORT_FAILED, CURLE_FTP_COULDNT_USE_REST,
|
||||
CURLE_FTP_COULDNT_GET_SIZE, CURLE_HTTP_RANGE_ERROR, CURLE_HTTP_POST_ERROR,
|
||||
CURLE_SSL_CONNECT_ERROR, CURLE_BAD_DOWNLOAD_RESUME,
|
||||
CURLE_FILE_COULDNT_READ_FILE, CURLE_LDAP_CANNOT_BIND,
|
||||
CURLE_LDAP_SEARCH_FAILED, CURLE_LIBRARY_NOT_FOUND, CURLE_FUNCTION_NOT_FOUND,
|
||||
CURLE_ABORTED_BY_CALLBACK, CURLE_BAD_FUNCTION_ARGUMENT,
|
||||
CURLE_BAD_CALLING_ORDER, CURLE_INTERFACE_FAILED, CURLE_BAD_PASSWORD_ENTERED,
|
||||
CURLE_TOO_MANY_REDIRECTS, CURLE_UNKNOWN_TELNET_OPTION,
|
||||
CURLE_TELNET_OPTION_SYNTAX, CURLE_OBSOLETE, CURLE_SSL_PEER_CERTIFICATE,
|
||||
CURLE_GOT_NOTHING, CURLE_SSL_ENGINE_NOTFOUND, CURLE_SSL_ENGINE_SETFAILED,
|
||||
CURLE_SEND_ERROR, CURLE_RECV_ERROR, CURLE_SHARE_IN_USE,
|
||||
CURLE_SSL_CERTPROBLEM, CURLE_SSL_CIPHER, CURLE_SSL_CACERT,
|
||||
CURLE_BAD_CONTENT_ENCODING, CURLE_LDAP_INVALID_URL, CURLE_FILESIZE_EXCEEDED,
|
||||
CURLE_FTP_SSL_FAILED, CURLE_SEND_FAIL_REWIND, CURLE_SSL_ENGINE_INITFAILED,
|
||||
CURLE_LOGIN_DENIED, CURLE_TFTP_NOTFOUND, CURLE_TFTP_PERM,
|
||||
CURLE_TFTP_DISKFULL, CURLE_TFTP_ILLEGAL, CURLE_TFTP_UNKNOWNID,
|
||||
CURLE_TFTP_EXISTS, CURLE_TFTP_NOSUCHUSER, CURLE_CONV_FAILED,
|
||||
CURLE_CONV_REQD, CURL_LAST
|
||||
Tcurl_conv_callback* = proc (buffer: cstring, len: int): TCURLcode {.cdecl.}
|
||||
Tcurl_ssl_ctx_callback* = proc (curl: PCURL,
|
||||
ssl_ctx, userptr: pointer): TCURLcode {.cdecl.}
|
||||
Tcurl_proxytype* = enum
|
||||
CURLPROXY_HTTP = 0, CURLPROXY_SOCKS4 = 4, CURLPROXY_SOCKS5 = 5
|
||||
Tcurl_ftpssl* = enum
|
||||
CURLFTPSSL_NONE, CURLFTPSSL_TRY, CURLFTPSSL_CONTROL, CURLFTPSSL_ALL,
|
||||
CURLFTPSSL_LAST
|
||||
Tcurl_ftpauth* = enum
|
||||
CURLFTPAUTH_DEFAULT, CURLFTPAUTH_SSL, CURLFTPAUTH_TLS, CURLFTPAUTH_LAST
|
||||
Tcurl_ftpmethod* = enum
|
||||
CURLFTPMETHOD_DEFAULT, CURLFTPMETHOD_MULTICWD, CURLFTPMETHOD_NOCWD,
|
||||
CURLFTPMETHOD_SINGLECWD, CURLFTPMETHOD_LAST
|
||||
TCURLoption* = enum
|
||||
CURLOPT_PORT = 0 + 3,
|
||||
CURLOPT_TIMEOUT = 0 + 13,
|
||||
CURLOPT_INFILESIZE = 0 + 14,
|
||||
CURLOPT_LOW_SPEED_LIMIT = 0 + 19,
|
||||
CURLOPT_LOW_SPEED_TIME = 0 + 20,
|
||||
CURLOPT_RESUME_FROM = 0 + 21,
|
||||
CURLOPT_CRLF = 0 + 27,
|
||||
CURLOPT_SSLVERSION = 0 + 32,
|
||||
CURLOPT_TIMECONDITION = 0 + 33,
|
||||
CURLOPT_TIMEVALUE = 0 + 34,
|
||||
CURLOPT_VERBOSE = 0 + 41,
|
||||
CURLOPT_HEADER = 0 + 42,
|
||||
CURLOPT_NOPROGRESS = 0 + 43,
|
||||
CURLOPT_NOBODY = 0 + 44,
|
||||
CURLOPT_FAILONERROR = 0 + 45,
|
||||
CURLOPT_UPLOAD = 0 + 46,
|
||||
CURLOPT_POST = 0 + 47,
|
||||
CURLOPT_FTPLISTONLY = 0 + 48,
|
||||
CURLOPT_FTPAPPEND = 0 + 50,
|
||||
CURLOPT_NETRC = 0 + 51,
|
||||
CURLOPT_FOLLOWLOCATION = 0 + 52,
|
||||
CURLOPT_TRANSFERTEXT = 0 + 53,
|
||||
CURLOPT_PUT = 0 + 54,
|
||||
CURLOPT_AUTOREFERER = 0 + 58,
|
||||
CURLOPT_PROXYPORT = 0 + 59,
|
||||
CURLOPT_POSTFIELDSIZE = 0 + 60,
|
||||
CURLOPT_HTTPPROXYTUNNEL = 0 + 61,
|
||||
CURLOPT_SSL_VERIFYPEER = 0 + 64,
|
||||
CURLOPT_MAXREDIRS = 0 + 68,
|
||||
CURLOPT_FILETIME = 0 + 69,
|
||||
CURLOPT_MAXCONNECTS = 0 + 71,
|
||||
CURLOPT_CLOSEPOLICY = 0 + 72,
|
||||
CURLOPT_FRESH_CONNECT = 0 + 74,
|
||||
CURLOPT_FORBID_REUSE = 0 + 75,
|
||||
CURLOPT_CONNECTTIMEOUT = 0 + 78,
|
||||
CURLOPT_HTTPGET = 0 + 80,
|
||||
CURLOPT_SSL_VERIFYHOST = 0 + 81,
|
||||
CURLOPT_HTTP_VERSION = 0 + 84,
|
||||
CURLOPT_FTP_USE_EPSV = 0 + 85,
|
||||
CURLOPT_SSLENGINE_DEFAULT = 0 + 90,
|
||||
CURLOPT_DNS_USE_GLOBAL_CACHE = 0 + 91,
|
||||
CURLOPT_DNS_CACHE_TIMEOUT = 0 + 92,
|
||||
CURLOPT_COOKIESESSION = 0 + 96,
|
||||
CURLOPT_BUFFERSIZE = 0 + 98,
|
||||
CURLOPT_NOSIGNAL = 0 + 99,
|
||||
CURLOPT_PROXYTYPE = 0 + 101,
|
||||
CURLOPT_UNRESTRICTED_AUTH = 0 + 105,
|
||||
CURLOPT_FTP_USE_EPRT = 0 + 106,
|
||||
CURLOPT_HTTPAUTH = 0 + 107,
|
||||
CURLOPT_FTP_CREATE_MISSING_DIRS = 0 + 110,
|
||||
CURLOPT_PROXYAUTH = 0 + 111,
|
||||
CURLOPT_FTP_RESPONSE_TIMEOUT = 0 + 112,
|
||||
CURLOPT_IPRESOLVE = 0 + 113,
|
||||
CURLOPT_MAXFILESIZE = 0 + 114,
|
||||
CURLOPT_FTP_SSL = 0 + 119,
|
||||
CURLOPT_TCP_NODELAY = 0 + 121,
|
||||
CURLOPT_FTPSSLAUTH = 0 + 129,
|
||||
CURLOPT_IGNORE_CONTENT_LENGTH = 0 + 136,
|
||||
CURLOPT_FTP_SKIP_PASV_IP = 0 + 137,
|
||||
CURLOPT_FTP_FILEMETHOD = 0 + 138,
|
||||
CURLOPT_LOCALPORT = 0 + 139,
|
||||
CURLOPT_LOCALPORTRANGE = 0 + 140,
|
||||
CURLOPT_CONNECT_ONLY = 0 + 141,
|
||||
|
||||
CURLOPT_FILE = 10000 + 1,
|
||||
CURLOPT_URL = 10000 + 2,
|
||||
CURLOPT_PROXY = 10000 + 4,
|
||||
CURLOPT_USERPWD = 10000 + 5,
|
||||
CURLOPT_PROXYUSERPWD = 10000 + 6,
|
||||
CURLOPT_RANGE = 10000 + 7,
|
||||
CURLOPT_INFILE = 10000 + 9,
|
||||
CURLOPT_ERRORBUFFER = 10000 + 10,
|
||||
CURLOPT_POSTFIELDS = 10000 + 15,
|
||||
CURLOPT_REFERER = 10000 + 16,
|
||||
CURLOPT_FTPPORT = 10000 + 17,
|
||||
CURLOPT_USERAGENT = 10000 + 18,
|
||||
CURLOPT_COOKIE = 10000 + 22,
|
||||
CURLOPT_HTTPHEADER = 10000 + 23,
|
||||
CURLOPT_HTTPPOST = 10000 + 24,
|
||||
CURLOPT_SSLCERT = 10000 + 25,
|
||||
CURLOPT_SSLCERTPASSWD = 10000 + 26,
|
||||
CURLOPT_QUOTE = 10000 + 28,
|
||||
CURLOPT_WRITEHEADER = 10000 + 29,
|
||||
CURLOPT_COOKIEFILE = 10000 + 31,
|
||||
CURLOPT_CUSTOMREQUEST = 10000 + 36,
|
||||
CURLOPT_STDERR = 10000 + 37,
|
||||
CURLOPT_POSTQUOTE = 10000 + 39,
|
||||
CURLOPT_WRITEINFO = 10000 + 40,
|
||||
CURLOPT_PROGRESSDATA = 10000 + 57,
|
||||
CURLOPT_INTERFACE = 10000 + 62,
|
||||
CURLOPT_KRB4LEVEL = 10000 + 63,
|
||||
CURLOPT_CAINFO = 10000 + 65,
|
||||
CURLOPT_TELNETOPTIONS = 10000 + 70,
|
||||
CURLOPT_RANDOM_FILE = 10000 + 76,
|
||||
CURLOPT_EGDSOCKET = 10000 + 77,
|
||||
CURLOPT_COOKIEJAR = 10000 + 82,
|
||||
CURLOPT_SSL_CIPHER_LIST = 10000 + 83,
|
||||
CURLOPT_SSLCERTTYPE = 10000 + 86,
|
||||
CURLOPT_SSLKEY = 10000 + 87,
|
||||
CURLOPT_SSLKEYTYPE = 10000 + 88,
|
||||
CURLOPT_SSLENGINE = 10000 + 89,
|
||||
CURLOPT_PREQUOTE = 10000 + 93,
|
||||
CURLOPT_DEBUGDATA = 10000 + 95,
|
||||
CURLOPT_CAPATH = 10000 + 97,
|
||||
CURLOPT_SHARE = 10000 + 100,
|
||||
CURLOPT_ENCODING = 10000 + 102,
|
||||
CURLOPT_PRIVATE = 10000 + 103,
|
||||
CURLOPT_HTTP200ALIASES = 10000 + 104,
|
||||
CURLOPT_SSL_CTX_DATA = 10000 + 109,
|
||||
CURLOPT_NETRC_FILE = 10000 + 118,
|
||||
CURLOPT_SOURCE_USERPWD = 10000 + 123,
|
||||
CURLOPT_SOURCE_PREQUOTE = 10000 + 127,
|
||||
CURLOPT_SOURCE_POSTQUOTE = 10000 + 128,
|
||||
CURLOPT_IOCTLDATA = 10000 + 131,
|
||||
CURLOPT_SOURCE_URL = 10000 + 132,
|
||||
CURLOPT_SOURCE_QUOTE = 10000 + 133,
|
||||
CURLOPT_FTP_ACCOUNT = 10000 + 134,
|
||||
CURLOPT_COOKIELIST = 10000 + 135,
|
||||
CURLOPT_FTP_ALTERNATIVE_TO_USER = 10000 + 147,
|
||||
CURLOPT_LASTENTRY = 10000 + 148,
|
||||
|
||||
CURLOPT_WRITEFUNCTION = 20000 + 11,
|
||||
CURLOPT_READFUNCTION = 20000 + 12,
|
||||
CURLOPT_PROGRESSFUNCTION = 20000 + 56,
|
||||
CURLOPT_HEADERFUNCTION = 20000 + 79,
|
||||
CURLOPT_DEBUGFUNCTION = 20000 + 94,
|
||||
CURLOPT_SSL_CTX_FUNCTION = 20000 + 108,
|
||||
CURLOPT_IOCTLFUNCTION = 20000 + 130,
|
||||
CURLOPT_CONV_FROM_NETWORK_FUNCTION = 20000 + 142,
|
||||
CURLOPT_CONV_TO_NETWORK_FUNCTION = 20000 + 143,
|
||||
CURLOPT_CONV_FROM_UTF8_FUNCTION = 20000 + 144,
|
||||
|
||||
CURLOPT_INFILESIZE_LARGE = 30000 + 115,
|
||||
CURLOPT_RESUME_FROM_LARGE = 30000 + 116,
|
||||
CURLOPT_MAXFILESIZE_LARGE = 30000 + 117,
|
||||
CURLOPT_POSTFIELDSIZE_LARGE = 30000 + 120,
|
||||
CURLOPT_MAX_SEND_SPEED_LARGE = 30000 + 145,
|
||||
CURLOPT_MAX_RECV_SPEED_LARGE = 30000 + 146
|
||||
|
||||
|
||||
TCURL_HTTP_VERSION* = enum
|
||||
CURL_HTTP_VERSION_NONE, CURL_HTTP_VERSION_1_0, CURL_HTTP_VERSION_1_1,
|
||||
CURL_HTTP_VERSION_LAST
|
||||
|
||||
TCURL_NETRC_OPTION* = enum
|
||||
CURL_NETRC_IGNORED, CURL_NETRC_OPTIONAL, CURL_NETRC_REQUIRED,
|
||||
CURL_NETRC_LAST
|
||||
|
||||
TCURL_SSL_VERSION* = enum
|
||||
CURL_SSLVERSION_DEFAULT, CURL_SSLVERSION_TLSv1, CURL_SSLVERSION_SSLv2,
|
||||
CURL_SSLVERSION_SSLv3, CURL_SSLVERSION_LAST
|
||||
|
||||
TCURL_TIMECOND* = enum
|
||||
CURL_TIMECOND_NONE, CURL_TIMECOND_IFMODSINCE, CURL_TIMECOND_IFUNMODSINCE,
|
||||
CURL_TIMECOND_LASTMOD, CURL_TIMECOND_LAST
|
||||
|
||||
TCURLformoption* = enum
|
||||
CURLFORM_NOTHING, CURLFORM_COPYNAME, CURLFORM_PTRNAME, CURLFORM_NAMELENGTH,
|
||||
CURLFORM_COPYCONTENTS, CURLFORM_PTRCONTENTS, CURLFORM_CONTENTSLENGTH,
|
||||
CURLFORM_FILECONTENT, CURLFORM_ARRAY, CURLFORM_OBSOLETE, CURLFORM_FILE,
|
||||
CURLFORM_BUFFER, CURLFORM_BUFFERPTR, CURLFORM_BUFFERLENGTH,
|
||||
CURLFORM_CONTENTTYPE, CURLFORM_CONTENTHEADER, CURLFORM_FILENAME,
|
||||
CURLFORM_END, CURLFORM_OBSOLETE2, CURLFORM_LASTENTRY
|
||||
|
||||
Tcurl_forms* {.pure, final.} = object
|
||||
option*: TCURLformoption
|
||||
value*: cstring
|
||||
|
||||
TCURLFORMcode* = enum
|
||||
CURL_FORMADD_OK, CURL_FORMADD_MEMORY, CURL_FORMADD_OPTION_TWICE,
|
||||
CURL_FORMADD_NULL, CURL_FORMADD_UNKNOWN_OPTION, CURL_FORMADD_INCOMPLETE,
|
||||
CURL_FORMADD_ILLEGAL_ARRAY, CURL_FORMADD_DISABLED, CURL_FORMADD_LAST
|
||||
|
||||
Tcurl_formget_callback* = proc (arg: pointer, buf: cstring,
|
||||
length: int): int {.cdecl.}
|
||||
Tcurl_slist* {.pure, final.} = object
|
||||
data*: cstring
|
||||
next*: Pcurl_slist
|
||||
|
||||
TCURLINFO* = enum
|
||||
CURLINFO_NONE = 0,
|
||||
CURLINFO_LASTONE = 30,
|
||||
CURLINFO_EFFECTIVE_URL = 0x00100000 + 1,
|
||||
CURLINFO_CONTENT_TYPE = 0x00100000 + 18,
|
||||
CURLINFO_PRIVATE = 0x00100000 + 21,
|
||||
CURLINFO_FTP_ENTRY_PATH = 0x00100000 + 30,
|
||||
|
||||
CURLINFO_RESPONSE_CODE = 0x00200000 + 2,
|
||||
CURLINFO_HEADER_SIZE = 0x00200000 + 11,
|
||||
CURLINFO_REQUEST_SIZE = 0x00200000 + 12,
|
||||
CURLINFO_SSL_VERIFYRESULT = 0x00200000 + 13,
|
||||
CURLINFO_FILETIME = 0x00200000 + 14,
|
||||
CURLINFO_REDIRECT_COUNT = 0x00200000 + 20,
|
||||
CURLINFO_HTTP_CONNECTCODE = 0x00200000 + 22,
|
||||
CURLINFO_HTTPAUTH_AVAIL = 0x00200000 + 23,
|
||||
CURLINFO_PROXYAUTH_AVAIL = 0x00200000 + 24,
|
||||
CURLINFO_OS_ERRNO = 0x00200000 + 25,
|
||||
CURLINFO_NUM_CONNECTS = 0x00200000 + 26,
|
||||
CURLINFO_LASTSOCKET = 0x00200000 + 29,
|
||||
|
||||
CURLINFO_TOTAL_TIME = 0x00300000 + 3,
|
||||
CURLINFO_NAMELOOKUP_TIME = 0x00300000 + 4,
|
||||
CURLINFO_CONNECT_TIME = 0x00300000 + 5,
|
||||
CURLINFO_PRETRANSFER_TIME = 0x00300000 + 6,
|
||||
CURLINFO_SIZE_UPLOAD = 0x00300000 + 7,
|
||||
CURLINFO_SIZE_DOWNLOAD = 0x00300000 + 8,
|
||||
CURLINFO_SPEED_DOWNLOAD = 0x00300000 + 9,
|
||||
CURLINFO_SPEED_UPLOAD = 0x00300000 + 10,
|
||||
CURLINFO_CONTENT_LENGTH_DOWNLOAD = 0x00300000 + 15,
|
||||
CURLINFO_CONTENT_LENGTH_UPLOAD = 0x00300000 + 16,
|
||||
CURLINFO_STARTTRANSFER_TIME = 0x00300000 + 17,
|
||||
CURLINFO_REDIRECT_TIME = 0x00300000 + 19,
|
||||
|
||||
CURLINFO_SSL_ENGINES = 0x00400000 + 27,
|
||||
CURLINFO_COOKIELIST = 0x00400000 + 28
|
||||
|
||||
Tcurl_closepolicy* = enum
|
||||
CURLCLOSEPOLICY_NONE, CURLCLOSEPOLICY_OLDEST,
|
||||
CURLCLOSEPOLICY_LEAST_RECENTLY_USED, CURLCLOSEPOLICY_LEAST_TRAFFIC,
|
||||
CURLCLOSEPOLICY_SLOWEST, CURLCLOSEPOLICY_CALLBACK, CURLCLOSEPOLICY_LAST
|
||||
Tcurl_lock_data* = enum
|
||||
CURL_LOCK_DATA_NONE = 0, CURL_LOCK_DATA_SHARE, CURL_LOCK_DATA_COOKIE,
|
||||
CURL_LOCK_DATA_DNS, CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_DATA_CONNECT,
|
||||
CURL_LOCK_DATA_LAST
|
||||
Tcurl_lock_access* = enum
|
||||
CURL_LOCK_ACCESS_NONE = 0, CURL_LOCK_ACCESS_SHARED = 1,
|
||||
CURL_LOCK_ACCESS_SINGLE = 2, CURL_LOCK_ACCESS_LAST
|
||||
|
||||
Tcurl_lock_function* = proc (handle: PCURL, data: Tcurl_lock_data,
|
||||
locktype: Tcurl_lock_access,
|
||||
userptr: pointer) {.cdecl.}
|
||||
Tcurl_unlock_function* = proc (handle: PCURL, data: Tcurl_lock_data,
|
||||
userptr: pointer) {.cdecl.}
|
||||
TCURLSH* = pointer
|
||||
TCURLSHcode* = enum
|
||||
CURLSHE_OK, CURLSHE_BAD_OPTION, CURLSHE_IN_USE, CURLSHE_INVALID,
|
||||
CURLSHE_NOMEM, CURLSHE_LAST
|
||||
|
||||
TCURLSHoption* = enum
|
||||
CURLSHOPT_NONE, CURLSHOPT_SHARE, CURLSHOPT_UNSHARE, CURLSHOPT_LOCKFUNC,
|
||||
CURLSHOPT_UNLOCKFUNC, CURLSHOPT_USERDATA, CURLSHOPT_LAST
|
||||
|
||||
TCURLversion* = enum
|
||||
CURLVERSION_FIRST, CURLVERSION_SECOND, CURLVERSION_THIRD, CURLVERSION_LAST
|
||||
|
||||
Tcurl_version_info_data* {.pure, final.} = object
|
||||
age*: TCURLversion
|
||||
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
|
||||
|
||||
TCURLM* = pointer
|
||||
Tcurl_socket* = int32
|
||||
TCURLMcode* = enum
|
||||
CURLM_CALL_MULTI_PERFORM = -1,
|
||||
CURLM_OK = 0,
|
||||
CURLM_BAD_HANDLE,
|
||||
CURLM_BAD_EASY_HANDLE,
|
||||
CURLM_OUT_OF_MEMORY,
|
||||
CURLM_INTERNAL_ERROR,
|
||||
CURLM_BAD_SOCKET,
|
||||
CURLM_UNKNOWN_OPTION,
|
||||
CURLM_LAST
|
||||
|
||||
TCURLMSGEnum* = enum
|
||||
CURLMSG_NONE, CURLMSG_DONE, CURLMSG_LAST
|
||||
TCURLMsg* {.pure, final.} = object
|
||||
msg*: TCURLMSGEnum
|
||||
easy_handle*: PCURL
|
||||
whatever*: Pointer #data : record
|
||||
# case longint of
|
||||
# 0 : ( whatever : pointer );
|
||||
# 1 : ( result : CURLcode );
|
||||
# end;
|
||||
|
||||
Tcurl_socket_callback* = proc (easy: PCURL, s: Tcurl_socket, what: int32,
|
||||
userp, socketp: pointer): int32 {.cdecl.}
|
||||
TCURLMoption* = enum
|
||||
CURLMOPT_SOCKETDATA = 10000 + 2,
|
||||
CURLMOPT_LASTENTRY = 10000 + 3,
|
||||
CURLMOPT_SOCKETFUNCTION = 20000 + 1
|
||||
|
||||
const
|
||||
CURLOPT_SSLKEYPASSWD* = CURLOPT_SSLCERTPASSWD
|
||||
|
||||
CURLAUTH_ANY* = not (0)
|
||||
CURLAUTH_BASIC* = 1 shl 0
|
||||
CURLAUTH_ANYSAFE* = not (CURLAUTH_BASIC)
|
||||
CURLAUTH_DIGEST* = 1 shl 1
|
||||
CURLAUTH_GSSNEGOTIATE* = 1 shl 2
|
||||
CURLAUTH_NONE* = 0
|
||||
CURLAUTH_NTLM* = 1 shl 3
|
||||
CURLE_ALREADY_COMPLETE* = 99999
|
||||
CURLE_FTP_BAD_DOWNLOAD_RESUME* = CURLE_BAD_DOWNLOAD_RESUME
|
||||
CURLE_FTP_PARTIAL_FILE* = CURLE_PARTIAL_FILE
|
||||
CURLE_HTTP_NOT_FOUND* = CURLE_HTTP_RETURNED_ERROR
|
||||
CURLE_HTTP_PORT_FAILED* = CURLE_INTERFACE_FAILED
|
||||
CURLE_OPERATION_TIMEDOUT* = CURLE_OPERATION_TIMEOUTED
|
||||
CURL_ERROR_SIZE* = 256
|
||||
CURL_FORMAT_OFF_T* = "%ld"
|
||||
CURL_GLOBAL_NOTHING* = 0
|
||||
CURL_GLOBAL_SSL* = 1 shl 0
|
||||
CURL_GLOBAL_WIN32* = 1 shl 1
|
||||
CURL_GLOBAL_ALL* = CURL_GLOBAL_SSL or CURL_GLOBAL_WIN32
|
||||
CURL_GLOBAL_DEFAULT* = CURL_GLOBAL_ALL
|
||||
CURLINFO_DOUBLE* = 0x00300000
|
||||
CURLINFO_HTTP_CODE* = CURLINFO_RESPONSE_CODE
|
||||
CURLINFO_LONG* = 0x00200000
|
||||
CURLINFO_MASK* = 0x000FFFFF
|
||||
CURLINFO_SLIST* = 0x00400000
|
||||
CURLINFO_STRING* = 0x00100000
|
||||
CURLINFO_TYPEMASK* = 0x00F00000
|
||||
CURL_IPRESOLVE_V4* = 1
|
||||
CURL_IPRESOLVE_V6* = 2
|
||||
CURL_IPRESOLVE_WHATEVER* = 0
|
||||
CURL_MAX_WRITE_SIZE* = 16384
|
||||
CURLM_CALL_MULTI_SOCKET* = CURLM_CALL_MULTI_PERFORM
|
||||
CURLOPT_CLOSEFUNCTION* = - (5)
|
||||
CURLOPT_FTPASCII* = CURLOPT_TRANSFERTEXT
|
||||
CURLOPT_HEADERDATA* = CURLOPT_WRITEHEADER
|
||||
CURLOPT_HTTPREQUEST* = - (1)
|
||||
CURLOPT_MUTE* = - (2)
|
||||
CURLOPT_PASSWDDATA* = - (4)
|
||||
CURLOPT_PASSWDFUNCTION* = - (3)
|
||||
CURLOPT_PASV_HOST* = - (9)
|
||||
CURLOPT_READDATA* = CURLOPT_INFILE
|
||||
CURLOPT_SOURCE_HOST* = - (6)
|
||||
CURLOPT_SOURCE_PATH* = - (7)
|
||||
CURLOPT_SOURCE_PORT* = - (8)
|
||||
CURLOPTTYPE_FUNCTIONPOINT* = 20000
|
||||
CURLOPTTYPE_LONG* = 0
|
||||
CURLOPTTYPE_OBJECTPOINT* = 10000
|
||||
CURLOPTTYPE_OFF_T* = 30000
|
||||
CURLOPT_WRITEDATA* = CURLOPT_FILE
|
||||
CURL_POLL_IN* = 1
|
||||
CURL_POLL_INOUT* = 3
|
||||
CURL_POLL_NONE* = 0
|
||||
CURL_POLL_OUT* = 2
|
||||
CURL_POLL_REMOVE* = 4
|
||||
CURL_READFUNC_ABORT* = 0x10000000
|
||||
CURL_SOCKET_BAD* = - (1)
|
||||
CURL_SOCKET_TIMEOUT* = CURL_SOCKET_BAD
|
||||
CURL_VERSION_ASYNCHDNS* = 1 shl 7
|
||||
CURL_VERSION_CONV* = 1 shl 12
|
||||
CURL_VERSION_DEBUG* = 1 shl 6
|
||||
CURL_VERSION_GSSNEGOTIATE* = 1 shl 5
|
||||
CURL_VERSION_IDN* = 1 shl 10
|
||||
CURL_VERSION_IPV6* = 1 shl 0
|
||||
CURL_VERSION_KERBEROS4* = 1 shl 1
|
||||
CURL_VERSION_LARGEFILE* = 1 shl 9
|
||||
CURL_VERSION_LIBZ* = 1 shl 3
|
||||
CURLVERSION_NOW* = CURLVERSION_THIRD
|
||||
CURL_VERSION_NTLM* = 1 shl 4
|
||||
CURL_VERSION_SPNEGO* = 1 shl 8
|
||||
CURL_VERSION_SSL* = 1 shl 2
|
||||
CURL_VERSION_SSPI* = 1 shl 11
|
||||
FILE_OFFSET_BITS* = 0
|
||||
FILESIZEBITS* = 0
|
||||
FUNCTIONPOINT* = CURLOPTTYPE_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 curl_strequal*(s1, s2: cstring): int32{.cdecl,
|
||||
dynlib: libname, importc: "curl_strequal".}
|
||||
proc curl_strnequal*(s1, s2: cstring, n: int): int32 {.cdecl,
|
||||
dynlib: libname, importc: "curl_strnequal".}
|
||||
proc curl_formadd*(httppost, last_post: PPcurl_httppost): TCURLFORMcode {.
|
||||
cdecl, varargs, dynlib: libname, importc: "curl_formadd".}
|
||||
|
||||
proc curl_formget*(form: Pcurl_httppost, arg: pointer,
|
||||
append: Tcurl_formget_callback): int32 {.cdecl,
|
||||
dynlib: libname, importc: "curl_formget".}
|
||||
proc curl_formfree*(form: Pcurl_httppost){.cdecl, dynlib: libname,
|
||||
importc: "curl_formfree".}
|
||||
proc curl_getenv*(variable: cstring): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_getenv".}
|
||||
proc curl_version*(): cstring{.cdecl, dynlib: libname, importc: "curl_version".}
|
||||
proc curl_easy_escape*(handle: PCURL, str: cstring, len: int32): cstring{.cdecl,
|
||||
dynlib: libname, importc: "curl_easy_escape".}
|
||||
proc curl_escape*(str: cstring, len: int32): cstring{.cdecl,
|
||||
dynlib: libname, importc: "curl_escape".}
|
||||
proc curl_easy_unescape*(handle: PCURL, str: cstring, len: int32,
|
||||
outlength: var int32): cstring{.cdecl,
|
||||
dynlib: libname, importc: "curl_easy_unescape".}
|
||||
proc curl_unescape*(str: cstring, len: int32): cstring{.cdecl,
|
||||
dynlib: libname, importc: "curl_unescape".}
|
||||
proc curl_free*(p: pointer){.cdecl, dynlib: libname,
|
||||
importc: "curl_free".}
|
||||
proc curl_global_init*(flags: int32): TCURLcode {.cdecl, dynlib: libname,
|
||||
importc: "curl_global_init".}
|
||||
proc curl_global_init_mem*(flags: int32, m: Tcurl_malloc_callback,
|
||||
f: Tcurl_free_callback, r: Tcurl_realloc_callback,
|
||||
s: Tcurl_strdup_callback,
|
||||
c: Tcurl_calloc_callback): TCURLcode {.
|
||||
cdecl, dynlib: libname, importc: "curl_global_init_mem".}
|
||||
proc curl_global_cleanup*() {.cdecl, dynlib: libname,
|
||||
importc: "curl_global_cleanup".}
|
||||
proc curl_slist_append*(curl_slist: Pcurl_slist, P: cstring): Pcurl_slist {.
|
||||
cdecl, dynlib: libname, importc: "curl_slist_append".}
|
||||
proc curl_slist_free_all*(para1: Pcurl_slist) {.cdecl, dynlib: libname,
|
||||
importc: "curl_slist_free_all".}
|
||||
proc curl_getdate*(p: cstring, unused: ptr TTime): TTime {.cdecl,
|
||||
dynlib: libname, importc: "curl_getdate".}
|
||||
proc curl_share_init*(): PCURLSH{.cdecl, dynlib: libname,
|
||||
importc: "curl_share_init".}
|
||||
proc curl_share_setopt*(para1: PCURLSH, option: TCURLSHoption): TCURLSHcode {.
|
||||
cdecl, varargs, dynlib: libname, importc: "curl_share_setopt".}
|
||||
|
||||
proc curl_share_cleanup*(para1: PCURLSH): TCURLSHcode {.cdecl,
|
||||
dynlib: libname, importc: "curl_share_cleanup".}
|
||||
proc curl_version_info*(para1: TCURLversion): Pcurl_version_info_data{.cdecl,
|
||||
dynlib: libname, importc: "curl_version_info".}
|
||||
proc curl_easy_strerror*(para1: TCURLcode): cstring {.cdecl,
|
||||
dynlib: libname, importc: "curl_easy_strerror".}
|
||||
proc curl_share_strerror*(para1: TCURLSHcode): cstring {.cdecl,
|
||||
dynlib: libname, importc: "curl_share_strerror".}
|
||||
proc curl_easy_init*(): PCURL {.cdecl, dynlib: libname,
|
||||
importc: "curl_easy_init".}
|
||||
proc curl_easy_setopt*(curl: PCURL, option: TCURLoption): TCURLcode {.cdecl,
|
||||
varargs, dynlib: libname, importc: "curl_easy_setopt".}
|
||||
|
||||
proc curl_easy_perform*(curl: PCURL): TCURLcode {.cdecl, dynlib: libname,
|
||||
importc: "curl_easy_perform".}
|
||||
proc curl_easy_cleanup*(curl: PCURL) {.cdecl, dynlib: libname,
|
||||
importc: "curl_easy_cleanup".}
|
||||
proc curl_easy_getinfo*(curl: PCURL, info: TCURLINFO): TCURLcode {.
|
||||
cdecl, varargs, dynlib: libname, importc: "curl_easy_getinfo".}
|
||||
|
||||
proc curl_easy_duphandle*(curl: PCURL): PCURL {.cdecl, dynlib: libname,
|
||||
importc: "curl_easy_duphandle".}
|
||||
proc curl_easy_reset*(curl: PCURL) {.cdecl, dynlib: libname,
|
||||
importc: "curl_easy_reset".}
|
||||
proc curl_multi_init*(): PCURLM {.cdecl, dynlib: libname,
|
||||
importc: "curl_multi_init".}
|
||||
proc curl_multi_add_handle*(multi_handle: PCURLM,
|
||||
curl_handle: PCURL): TCURLMcode {.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_add_handle".}
|
||||
proc curl_multi_remove_handle*(multi_handle: PCURLM,
|
||||
curl_handle: PCURL): TCURLMcode {.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_remove_handle".}
|
||||
proc curl_multi_fdset*(multi_handle: PCURLM, read_fd_set: Pfd_set,
|
||||
write_fd_set: Pfd_set, exc_fd_set: Pfd_set,
|
||||
max_fd: var int32): TCURLMcode {.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_fdset".}
|
||||
proc curl_multi_perform*(multi_handle: PCURLM,
|
||||
running_handles: var int32): TCURLMcode {.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_perform".}
|
||||
proc curl_multi_cleanup*(multi_handle: PCURLM): TCURLMcode {.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_cleanup".}
|
||||
proc curl_multi_info_read*(multi_handle: PCURLM,
|
||||
msgs_in_queue: var int32): PCURLMsg {.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_info_read".}
|
||||
proc curl_multi_strerror*(para1: TCURLMcode): cstring {.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_strerror".}
|
||||
proc curl_multi_socket*(multi_handle: PCURLM, s: Tcurl_socket,
|
||||
running_handles: var int32): TCURLMcode {.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_socket".}
|
||||
proc curl_multi_socket_all*(multi_handle: PCURLM,
|
||||
running_handles: var int32): TCURLMcode {.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_socket_all".}
|
||||
proc curl_multi_timeout*(multi_handle: PCURLM, milliseconds: var int32): TCURLMcode{.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_timeout".}
|
||||
proc curl_multi_setopt*(multi_handle: PCURLM, option: TCURLMoption): TCURLMcode{.
|
||||
cdecl, varargs, dynlib: libname, importc: "curl_multi_setopt".}
|
||||
|
||||
proc curl_multi_assign*(multi_handle: PCURLM, sockfd: Tcurl_socket,
|
||||
sockp: pointer): TCURLMcode {.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_assign".}
|
||||
|
||||
|
||||
1155
lib/base/mysql.nim
Normal file
1155
lib/base/mysql.nim
Normal file
File diff suppressed because it is too large
Load Diff
376
lib/base/sqlite3.nim
Normal file
376
lib/base/sqlite3.nim
Normal file
@@ -0,0 +1,376 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
when defined(windows):
|
||||
const Sqlite3Lib = "sqlite3.dll"
|
||||
elif defined(macosx):
|
||||
const Sqlite3Lib = "sqlite-3.6.13.dylib"
|
||||
else:
|
||||
const Sqlite3Lib = "libsqlite3.so"
|
||||
|
||||
const
|
||||
SQLITE_INTEGER* = 1
|
||||
SQLITE_FLOAT* = 2
|
||||
SQLITE_BLOB* = 4
|
||||
SQLITE_NULL* = 5
|
||||
SQLITE_TEXT* = 3
|
||||
SQLITE3_TEXT* = 3
|
||||
SQLITE_UTF8* = 1
|
||||
SQLITE_UTF16LE* = 2
|
||||
SQLITE_UTF16BE* = 3 # Use native byte order
|
||||
SQLITE_UTF16* = 4 # sqlite3_create_function only
|
||||
SQLITE_ANY* = 5 #sqlite_exec return values
|
||||
SQLITE_OK* = 0
|
||||
SQLITE_ERROR* = 1 # SQL error or missing database
|
||||
SQLITE_INTERNAL* = 2 # An internal logic error in SQLite
|
||||
SQLITE_PERM* = 3 # Access permission denied
|
||||
SQLITE_ABORT* = 4 # Callback routine requested an abort
|
||||
SQLITE_BUSY* = 5 # The database file is locked
|
||||
SQLITE_LOCKED* = 6 # A table in the database is locked
|
||||
SQLITE_NOMEM* = 7 # A malloc() failed
|
||||
SQLITE_READONLY* = 8 # Attempt to write a readonly database
|
||||
SQLITE_INTERRUPT* = 9 # Operation terminated by sqlite3_interrupt()
|
||||
SQLITE_IOERR* = 10 # Some kind of disk I/O error occurred
|
||||
SQLITE_CORRUPT* = 11 # The database disk image is malformed
|
||||
SQLITE_NOTFOUND* = 12 # (Internal Only) Table or record not found
|
||||
SQLITE_FULL* = 13 # Insertion failed because database is full
|
||||
SQLITE_CANTOPEN* = 14 # Unable to open the database file
|
||||
SQLITE_PROTOCOL* = 15 # Database lock protocol error
|
||||
SQLITE_EMPTY* = 16 # Database is empty
|
||||
SQLITE_SCHEMA* = 17 # The database schema changed
|
||||
SQLITE_TOOBIG* = 18 # Too much data for one row of a table
|
||||
SQLITE_CONSTRAINT* = 19 # Abort due to contraint violation
|
||||
SQLITE_MISMATCH* = 20 # Data type mismatch
|
||||
SQLITE_MISUSE* = 21 # Library used incorrectly
|
||||
SQLITE_NOLFS* = 22 # Uses OS features not supported on host
|
||||
SQLITE_AUTH* = 23 # Authorization denied
|
||||
SQLITE_FORMAT* = 24 # Auxiliary database format error
|
||||
SQLITE_RANGE* = 25 # 2nd parameter to sqlite3_bind out of range
|
||||
SQLITE_NOTADB* = 26 # File opened that is not a database file
|
||||
SQLITE_ROW* = 100 # sqlite3_step() has another row ready
|
||||
SQLITE_DONE* = 101 # sqlite3_step() has finished executing
|
||||
SQLITE_COPY* = 0
|
||||
SQLITE_CREATE_INDEX* = 1
|
||||
SQLITE_CREATE_TABLE* = 2
|
||||
SQLITE_CREATE_TEMP_INDEX* = 3
|
||||
SQLITE_CREATE_TEMP_TABLE* = 4
|
||||
SQLITE_CREATE_TEMP_TRIGGER* = 5
|
||||
SQLITE_CREATE_TEMP_VIEW* = 6
|
||||
SQLITE_CREATE_TRIGGER* = 7
|
||||
SQLITE_CREATE_VIEW* = 8
|
||||
SQLITE_DELETE* = 9
|
||||
SQLITE_DROP_INDEX* = 10
|
||||
SQLITE_DROP_TABLE* = 11
|
||||
SQLITE_DROP_TEMP_INDEX* = 12
|
||||
SQLITE_DROP_TEMP_TABLE* = 13
|
||||
SQLITE_DROP_TEMP_TRIGGER* = 14
|
||||
SQLITE_DROP_TEMP_VIEW* = 15
|
||||
SQLITE_DROP_TRIGGER* = 16
|
||||
SQLITE_DROP_VIEW* = 17
|
||||
SQLITE_INSERT* = 18
|
||||
SQLITE_PRAGMA* = 19
|
||||
SQLITE_READ* = 20
|
||||
SQLITE_SELECT* = 21
|
||||
SQLITE_TRANSACTION* = 22
|
||||
SQLITE_UPDATE* = 23
|
||||
SQLITE_ATTACH* = 24
|
||||
SQLITE_DETACH* = 25
|
||||
SQLITE_ALTER_TABLE* = 26
|
||||
SQLITE_REINDEX* = 27
|
||||
SQLITE_DENY* = 1
|
||||
SQLITE_IGNORE* = 2 # Original from sqlite3.h:
|
||||
##define SQLITE_STATIC ((void(*)(void *))0)
|
||||
##define SQLITE_TRANSIENT ((void(*)(void *))-1)
|
||||
|
||||
const
|
||||
SQLITE_STATIC* = nil
|
||||
SQLITE_TRANSIENT* = cast[pointer](-1)
|
||||
|
||||
type
|
||||
sqlite_int64* = int64
|
||||
PPPChar* = ptr ptr cstring
|
||||
TSqlite3 {.pure, final.} = object
|
||||
Psqlite3* = ptr TSqlite3
|
||||
PPSqlite3* = ptr PSqlite3
|
||||
TSqlLite3Context {.pure, final.} = object
|
||||
Psqlite3_context* = ptr TSqlLite3Context
|
||||
Tsqlite3_stmt {.pure, final.} = object
|
||||
Psqlite3_stmt* = ptr TSqlite3_stmt
|
||||
PPsqlite3_stmt* = ptr Psqlite3_stmt
|
||||
Tsqlite3_value {.pure, final.} = object
|
||||
Psqlite3_value* = ptr Tsqlite3_value
|
||||
PPsqlite3_value* = ptr Psqlite3_value #Callback function types
|
||||
#Notice that most functions
|
||||
#were named using as prefix the
|
||||
#function name that uses them,
|
||||
#rather than describing their functions
|
||||
Tsqlite3_callback* = proc (para1: pointer, para2: int32, para3: var cstring,
|
||||
para4: var cstring): int32{.cdecl.}
|
||||
Tbind_destructor_func* = proc (para1: pointer){.cdecl.}
|
||||
Tcreate_function_step_func* = proc (para1: Psqlite3_context, para2: int32,
|
||||
para3: PPsqlite3_value){.cdecl.}
|
||||
Tcreate_function_func_func* = proc (para1: Psqlite3_context, para2: int32,
|
||||
para3: PPsqlite3_value){.cdecl.}
|
||||
Tcreate_function_final_func* = proc (para1: Psqlite3_context){.cdecl.}
|
||||
Tsqlite3_result_func* = proc (para1: pointer){.cdecl.}
|
||||
Tsqlite3_create_collation_func* = proc (para1: pointer, para2: int32,
|
||||
para3: pointer, para4: int32, para5: pointer): int32{.cdecl.}
|
||||
Tsqlite3_collation_needed_func* = proc (para1: pointer, para2: Psqlite3,
|
||||
eTextRep: int32, para4: cstring){.cdecl.}
|
||||
|
||||
proc sqlite3_close*(para1: Psqlite3): int32{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_close".}
|
||||
proc sqlite3_exec*(para1: Psqlite3, sql: cstring, para3: Tsqlite3_callback,
|
||||
para4: pointer, errmsg: var cstring): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_exec".}
|
||||
proc sqlite3_last_insert_rowid*(para1: Psqlite3): sqlite_int64{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_last_insert_rowid".}
|
||||
proc sqlite3_changes*(para1: Psqlite3): int32{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_changes".}
|
||||
proc sqlite3_total_changes*(para1: Psqlite3): int32{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_total_changes".}
|
||||
proc sqlite3_interrupt*(para1: Psqlite3){.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_interrupt".}
|
||||
proc sqlite3_complete*(sql: cstring): int32{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_complete".}
|
||||
proc sqlite3_complete16*(sql: pointer): int32{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_complete16".}
|
||||
proc sqlite3_busy_handler*(para1: Psqlite3,
|
||||
para2: proc (para1: pointer, para2: int32): int32 {.cdecl.},
|
||||
para3: pointer): int32{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_busy_handler".}
|
||||
proc sqlite3_busy_timeout*(para1: Psqlite3, ms: int32): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_busy_timeout".}
|
||||
proc sqlite3_get_table*(para1: Psqlite3, sql: cstring, resultp: var cstringArray,
|
||||
nrow, ncolumn: var cint, errmsg: ptr cstring): int32{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_get_table".}
|
||||
proc sqlite3_free_table*(result: cstringArray){.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_free_table".}
|
||||
# Todo: see how translate sqlite3_mprintf, sqlite3_vmprintf, sqlite3_snprintf
|
||||
# function sqlite3_mprintf(_para1:Pchar; args:array of const):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_mprintf';
|
||||
proc sqlite3_mprintf*(para1: cstring): cstring{.cdecl, varargs, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_mprintf".}
|
||||
#function sqlite3_vmprintf(_para1:Pchar; _para2:va_list):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_vmprintf';
|
||||
proc sqlite3_free*(z: cstring){.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_free".}
|
||||
#function sqlite3_snprintf(_para1:longint; _para2:Pchar; _para3:Pchar; args:array of const):Pchar;cdecl; external Sqlite3Lib name 'sqlite3_snprintf';
|
||||
proc sqlite3_snprintf*(para1: int32, para2: cstring, para3: cstring): cstring{.
|
||||
cdecl, dynlib: Sqlite3Lib, varargs, importc: "sqlite3_snprintf".}
|
||||
proc sqlite3_set_authorizer*(para1: Psqlite3,
|
||||
xAuth: proc (para1: pointer, para2: int32,
|
||||
para3: cstring, para4: cstring,
|
||||
para5: cstring,
|
||||
para6: cstring): int32{.cdecl.},
|
||||
pUserData: pointer): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_set_authorizer".}
|
||||
proc sqlite3_trace*(para1: Psqlite3,
|
||||
xTrace: proc (para1: pointer, para2: cstring){.cdecl.},
|
||||
para3: pointer): pointer{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_trace".}
|
||||
proc sqlite3_progress_handler*(para1: Psqlite3, para2: int32,
|
||||
para3: proc (para1: pointer): int32 {.cdecl.},
|
||||
para4: pointer){.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_progress_handler".}
|
||||
proc sqlite3_commit_hook*(para1: Psqlite3,
|
||||
para2: proc (para1: pointer): int32{.cdecl.},
|
||||
para3: pointer): pointer{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_commit_hook".}
|
||||
proc sqlite3_open*(filename: cstring, ppDb: var Psqlite3): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_open".}
|
||||
proc sqlite3_open16*(filename: pointer, ppDb: var Psqlite3): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_open16".}
|
||||
proc sqlite3_errcode*(db: Psqlite3): int32{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_errcode".}
|
||||
proc sqlite3_errmsg*(para1: Psqlite3): cstring{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_errmsg".}
|
||||
proc sqlite3_errmsg16*(para1: Psqlite3): pointer{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_errmsg16".}
|
||||
proc sqlite3_prepare*(db: Psqlite3, zSql: cstring, nBytes: int32,
|
||||
ppStmt: PPsqlite3_stmt, pzTail: ptr cstring): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_prepare".}
|
||||
proc sqlite3_prepare16*(db: Psqlite3, zSql: pointer, nBytes: int32,
|
||||
ppStmt: PPsqlite3_stmt, pzTail: var pointer): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_prepare16".}
|
||||
proc sqlite3_bind_blob*(para1: Psqlite3_stmt, para2: int32, para3: pointer,
|
||||
n: int32, para5: Tbind_destructor_func): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_bind_blob".}
|
||||
proc sqlite3_bind_double*(para1: Psqlite3_stmt, para2: int32, para3: float64): int32{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_double".}
|
||||
proc sqlite3_bind_int*(para1: Psqlite3_stmt, para2: int32, para3: int32): int32{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_int".}
|
||||
proc sqlite3_bind_int64*(para1: Psqlite3_stmt, para2: int32, para3: sqlite_int64): int32{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_int64".}
|
||||
proc sqlite3_bind_null*(para1: Psqlite3_stmt, para2: int32): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_bind_null".}
|
||||
proc sqlite3_bind_text*(para1: Psqlite3_stmt, para2: int32, para3: cstring,
|
||||
n: int32, para5: Tbind_destructor_func): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_bind_text".}
|
||||
proc sqlite3_bind_text16*(para1: Psqlite3_stmt, para2: int32, para3: pointer,
|
||||
para4: int32, para5: Tbind_destructor_func): int32{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_text16".}
|
||||
#function sqlite3_bind_value(_para1:Psqlite3_stmt; _para2:longint; _para3:Psqlite3_value):longint;cdecl; external Sqlite3Lib name 'sqlite3_bind_value';
|
||||
#These overloaded functions were introduced to allow the use of SQLITE_STATIC and SQLITE_TRANSIENT
|
||||
#It's the c world man ;-)
|
||||
proc sqlite3_bind_blob*(para1: Psqlite3_stmt, para2: int32, para3: pointer,
|
||||
n: int32, para5: int32): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_bind_blob".}
|
||||
proc sqlite3_bind_text*(para1: Psqlite3_stmt, para2: int32, para3: cstring,
|
||||
n: int32, para5: int32): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_bind_text".}
|
||||
proc sqlite3_bind_text16*(para1: Psqlite3_stmt, para2: int32, para3: pointer,
|
||||
para4: int32, para5: int32): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_bind_text16".}
|
||||
proc sqlite3_bind_parameter_count*(para1: Psqlite3_stmt): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_bind_parameter_count".}
|
||||
proc sqlite3_bind_parameter_name*(para1: Psqlite3_stmt, para2: int32): cstring{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_parameter_name".}
|
||||
proc sqlite3_bind_parameter_index*(para1: Psqlite3_stmt, zName: cstring): int32{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_bind_parameter_index".}
|
||||
#function sqlite3_clear_bindings(_para1:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_clear_bindings';
|
||||
proc sqlite3_column_count*(pStmt: Psqlite3_stmt): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_count".}
|
||||
proc sqlite3_column_name*(para1: Psqlite3_stmt, para2: int32): cstring{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_name".}
|
||||
proc sqlite3_column_name16*(para1: Psqlite3_stmt, para2: int32): pointer{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_name16".}
|
||||
proc sqlite3_column_decltype*(para1: Psqlite3_stmt, i: int32): cstring{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_decltype".}
|
||||
proc sqlite3_column_decltype16*(para1: Psqlite3_stmt, para2: int32): pointer{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_column_decltype16".}
|
||||
proc sqlite3_step*(para1: Psqlite3_stmt): int32{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_step".}
|
||||
proc sqlite3_data_count*(pStmt: Psqlite3_stmt): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_data_count".}
|
||||
proc sqlite3_column_blob*(para1: Psqlite3_stmt, iCol: int32): pointer{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_blob".}
|
||||
proc sqlite3_column_bytes*(para1: Psqlite3_stmt, iCol: int32): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_bytes".}
|
||||
proc sqlite3_column_bytes16*(para1: Psqlite3_stmt, iCol: int32): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_bytes16".}
|
||||
proc sqlite3_column_double*(para1: Psqlite3_stmt, iCol: int32): float64{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_double".}
|
||||
proc sqlite3_column_int*(para1: Psqlite3_stmt, iCol: int32): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_int".}
|
||||
proc sqlite3_column_int64*(para1: Psqlite3_stmt, iCol: int32): sqlite_int64{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_column_int64".}
|
||||
proc sqlite3_column_text*(para1: Psqlite3_stmt, iCol: int32): cstring{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_text".}
|
||||
proc sqlite3_column_text16*(para1: Psqlite3_stmt, iCol: int32): pointer{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_text16".}
|
||||
proc sqlite3_column_type*(para1: Psqlite3_stmt, iCol: int32): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_column_type".}
|
||||
proc sqlite3_finalize*(pStmt: Psqlite3_stmt): int32{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_finalize".}
|
||||
proc sqlite3_reset*(pStmt: Psqlite3_stmt): int32{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_reset".}
|
||||
proc sqlite3_create_function*(para1: Psqlite3, zFunctionName: cstring,
|
||||
nArg: int32, eTextRep: int32, para5: pointer,
|
||||
xFunc: Tcreate_function_func_func,
|
||||
xStep: Tcreate_function_step_func,
|
||||
xFinal: Tcreate_function_final_func): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_create_function".}
|
||||
proc sqlite3_create_function16*(para1: Psqlite3, zFunctionName: pointer,
|
||||
nArg: int32, eTextRep: int32, para5: pointer,
|
||||
xFunc: Tcreate_function_func_func,
|
||||
xStep: Tcreate_function_step_func,
|
||||
xFinal: Tcreate_function_final_func): int32{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_create_function16".}
|
||||
proc sqlite3_aggregate_count*(para1: Psqlite3_context): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_aggregate_count".}
|
||||
proc sqlite3_value_blob*(para1: Psqlite3_value): pointer{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_value_blob".}
|
||||
proc sqlite3_value_bytes*(para1: Psqlite3_value): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_value_bytes".}
|
||||
proc sqlite3_value_bytes16*(para1: Psqlite3_value): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_value_bytes16".}
|
||||
proc sqlite3_value_double*(para1: Psqlite3_value): float64{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_value_double".}
|
||||
proc sqlite3_value_int*(para1: Psqlite3_value): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_value_int".}
|
||||
proc sqlite3_value_int64*(para1: Psqlite3_value): sqlite_int64{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_value_int64".}
|
||||
proc sqlite3_value_text*(para1: Psqlite3_value): cstring{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_value_text".}
|
||||
proc sqlite3_value_text16*(para1: Psqlite3_value): pointer{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_value_text16".}
|
||||
proc sqlite3_value_text16le*(para1: Psqlite3_value): pointer{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_value_text16le".}
|
||||
proc sqlite3_value_text16be*(para1: Psqlite3_value): pointer{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_value_text16be".}
|
||||
proc sqlite3_value_type*(para1: Psqlite3_value): int32{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_value_type".}
|
||||
proc sqlite3_aggregate_context*(para1: Psqlite3_context, nBytes: int32): pointer{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_aggregate_context".}
|
||||
proc sqlite3_user_data*(para1: Psqlite3_context): pointer{.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_user_data".}
|
||||
proc sqlite3_get_auxdata*(para1: Psqlite3_context, para2: int32): pointer{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_get_auxdata".}
|
||||
proc sqlite3_set_auxdata*(para1: Psqlite3_context, para2: int32, para3: pointer,
|
||||
para4: proc (para1: pointer) {.cdecl.}){.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_set_auxdata".}
|
||||
proc sqlite3_result_blob*(para1: Psqlite3_context, para2: pointer, para3: int32,
|
||||
para4: Tsqlite3_result_func){.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_result_blob".}
|
||||
proc sqlite3_result_double*(para1: Psqlite3_context, para2: float64){.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_result_double".}
|
||||
proc sqlite3_result_error*(para1: Psqlite3_context, para2: cstring, para3: int32){.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_result_error".}
|
||||
proc sqlite3_result_error16*(para1: Psqlite3_context, para2: pointer,
|
||||
para3: int32){.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_result_error16".}
|
||||
proc sqlite3_result_int*(para1: Psqlite3_context, para2: int32){.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_result_int".}
|
||||
proc sqlite3_result_int64*(para1: Psqlite3_context, para2: sqlite_int64){.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_result_int64".}
|
||||
proc sqlite3_result_null*(para1: Psqlite3_context){.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_result_null".}
|
||||
proc sqlite3_result_text*(para1: Psqlite3_context, para2: cstring, para3: int32,
|
||||
para4: Tsqlite3_result_func){.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_result_text".}
|
||||
proc sqlite3_result_text16*(para1: Psqlite3_context, para2: pointer,
|
||||
para3: int32, para4: Tsqlite3_result_func){.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_result_text16".}
|
||||
proc sqlite3_result_text16le*(para1: Psqlite3_context, para2: pointer,
|
||||
para3: int32, para4: Tsqlite3_result_func){.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_result_text16le".}
|
||||
proc sqlite3_result_text16be*(para1: Psqlite3_context, para2: pointer,
|
||||
para3: int32, para4: Tsqlite3_result_func){.cdecl,
|
||||
dynlib: Sqlite3Lib, importc: "sqlite3_result_text16be".}
|
||||
proc sqlite3_result_value*(para1: Psqlite3_context, para2: Psqlite3_value){.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_result_value".}
|
||||
proc sqlite3_create_collation*(para1: Psqlite3, zName: cstring, eTextRep: int32,
|
||||
para4: pointer,
|
||||
xCompare: Tsqlite3_create_collation_func): int32{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_create_collation".}
|
||||
proc sqlite3_create_collation16*(para1: Psqlite3, zName: cstring,
|
||||
eTextRep: int32, para4: pointer,
|
||||
xCompare: Tsqlite3_create_collation_func): int32{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_create_collation16".}
|
||||
proc sqlite3_collation_needed*(para1: Psqlite3, para2: pointer,
|
||||
para3: Tsqlite3_collation_needed_func): int32{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_collation_needed".}
|
||||
proc sqlite3_collation_needed16*(para1: Psqlite3, para2: pointer,
|
||||
para3: Tsqlite3_collation_needed_func): int32{.
|
||||
cdecl, dynlib: Sqlite3Lib, importc: "sqlite3_collation_needed16".}
|
||||
proc sqlite3_libversion*(): cstring{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_libversion".}
|
||||
#Alias for allowing better code portability (win32 is not working with external variables)
|
||||
proc sqlite3_version*(): cstring{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_libversion".}
|
||||
# Not published functions
|
||||
proc sqlite3_libversion_number*(): int32{.cdecl, dynlib: Sqlite3Lib,
|
||||
importc: "sqlite3_libversion_number".}
|
||||
#function sqlite3_key(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_key';
|
||||
#function sqlite3_rekey(db:Psqlite3; pKey:pointer; nKey:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_rekey';
|
||||
#function sqlite3_sleep(_para1:longint):longint;cdecl; external Sqlite3Lib name 'sqlite3_sleep';
|
||||
#function sqlite3_expired(_para1:Psqlite3_stmt):longint;cdecl; external Sqlite3Lib name 'sqlite3_expired';
|
||||
#function sqlite3_global_recover:longint;cdecl; external Sqlite3Lib name 'sqlite3_global_recover';
|
||||
# implementation
|
||||
310
lib/base/terminal.nim
Normal file
310
lib/base/terminal.nim
Normal file
@@ -0,0 +1,310 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module contains a few procedures to control the *terminal*
|
||||
## (also called *console*). On UNIX, the implementation simply uses ANSI escape
|
||||
## sequences and does not depend on any other module, on Windows it uses the
|
||||
## Windows API.
|
||||
## Changing the style is permanent even after program termination! Use the
|
||||
## code ``system.addQuitProc(resetAttributes)`` to restore the defaults.
|
||||
|
||||
when defined(windows):
|
||||
import windows, os
|
||||
|
||||
var
|
||||
conHandle: THandle
|
||||
# = createFile("CONOUT$", GENERIC_WRITE, 0, nil, OPEN_ALWAYS, 0, 0)
|
||||
|
||||
block:
|
||||
var hTemp = GetStdHandle(STD_OUTPUT_HANDLE())
|
||||
if DuplicateHandle(GetCurrentProcess(), hTemp, GetCurrentProcess(),
|
||||
addr(conHandle), 0, 1, DUPLICATE_SAME_ACCESS) == 0:
|
||||
OSError()
|
||||
|
||||
proc getCursorPos(): tuple [x,y: int] =
|
||||
var c: TCONSOLE_SCREEN_BUFFER_INFO
|
||||
if GetConsoleScreenBufferInfo(conHandle, addr(c)) == 0: OSError()
|
||||
return (int(c.dwCursorPosition.x), int(c.dwCursorPosition.y))
|
||||
|
||||
proc getAttributes(): int16 =
|
||||
var c: TCONSOLE_SCREEN_BUFFER_INFO
|
||||
# workaround Windows bugs: try several times
|
||||
if GetConsoleScreenBufferInfo(conHandle, addr(c)) != 0:
|
||||
return c.wAttributes
|
||||
else:
|
||||
OSError()
|
||||
return 0x70'i16 # ERROR: return white background, black text
|
||||
|
||||
var
|
||||
oldAttr = getAttributes()
|
||||
|
||||
proc setCursorPos*(x, y: int) =
|
||||
## sets the terminal's cursor to the (x,y) position. (0,0) is the
|
||||
## upper left of the screen.
|
||||
when defined(windows):
|
||||
var c: TCoord
|
||||
c.x = int16(x)
|
||||
c.y = int16(y)
|
||||
if SetConsoleCursorPosition(conHandle, c) == 0: OSError()
|
||||
else:
|
||||
stdout.write("\e[" & $y & ';' & $x & 'f')
|
||||
|
||||
proc setCursorXPos*(x: int) =
|
||||
## sets the terminal's cursor to the x position. The y position is
|
||||
## not changed.
|
||||
when defined(windows):
|
||||
var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO
|
||||
var hStdout = conHandle
|
||||
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()
|
||||
var origin = scrbuf.dwCursorPosition
|
||||
origin.x = int16(x)
|
||||
if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
|
||||
else:
|
||||
stdout.write("\e[" & $x & 'G')
|
||||
|
||||
when defined(windows):
|
||||
proc setCursorYPos*(y: int) =
|
||||
## sets the terminal's cursor to the y position. The x position is
|
||||
## not changed. **Warning**: This is not supported on UNIX!
|
||||
when defined(windows):
|
||||
var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO
|
||||
var hStdout = conHandle
|
||||
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()
|
||||
var origin = scrbuf.dwCursorPosition
|
||||
origin.y = int16(y)
|
||||
if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
|
||||
else:
|
||||
nil
|
||||
|
||||
proc CursorUp*(count=1) =
|
||||
## Moves the cursor up by `count` rows.
|
||||
when defined(windows):
|
||||
var p = getCursorPos()
|
||||
dec(p.y, count)
|
||||
setCursorPos(p.x, p.y)
|
||||
else:
|
||||
stdout.write("\e[" & $count & 'A')
|
||||
|
||||
proc CursorDown*(count=1) =
|
||||
## Moves the cursor down by `count` rows.
|
||||
when defined(windows):
|
||||
var p = getCursorPos()
|
||||
inc(p.y, count)
|
||||
setCursorPos(p.x, p.y)
|
||||
else:
|
||||
stdout.write("\e[" & $count & 'B')
|
||||
|
||||
proc CursorForward*(count=1) =
|
||||
## Moves the cursor forward by `count` columns.
|
||||
when defined(windows):
|
||||
var p = getCursorPos()
|
||||
inc(p.x, count)
|
||||
setCursorPos(p.x, p.y)
|
||||
else:
|
||||
stdout.write("\e[" & $count & 'C')
|
||||
|
||||
proc CursorBackward*(count=1) =
|
||||
## Moves the cursor backward by `count` columns.
|
||||
when defined(windows):
|
||||
var p = getCursorPos()
|
||||
dec(p.x, count)
|
||||
setCursorPos(p.x, p.y)
|
||||
else:
|
||||
stdout.write("\e[" & $count & 'D')
|
||||
|
||||
when true:
|
||||
nil
|
||||
else:
|
||||
proc EraseLineEnd* =
|
||||
## Erases from the current cursor position to the end of the current line.
|
||||
when defined(windows):
|
||||
nil
|
||||
else:
|
||||
stdout.write("\e[K")
|
||||
|
||||
proc EraseLineStart* =
|
||||
## Erases from the current cursor position to the start of the current line.
|
||||
when defined(windows):
|
||||
nil
|
||||
else:
|
||||
stdout.write("\e[1K")
|
||||
|
||||
proc EraseDown* =
|
||||
## Erases the screen from the current line down to the bottom of the screen.
|
||||
when defined(windows):
|
||||
nil
|
||||
else:
|
||||
stdout.write("\e[J")
|
||||
|
||||
proc EraseUp* =
|
||||
## Erases the screen from the current line up to the top of the screen.
|
||||
when defined(windows):
|
||||
nil
|
||||
else:
|
||||
stdout.write("\e[1J")
|
||||
|
||||
proc EraseLine* =
|
||||
## Erases the entire current line.
|
||||
when defined(windows):
|
||||
var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO
|
||||
var numwrote: DWORD
|
||||
var hStdout = conHandle
|
||||
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()
|
||||
var origin = scrbuf.dwCursorPosition
|
||||
origin.x = 0'i16
|
||||
if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
|
||||
var ht = scrbuf.dwSize.Y - origin.Y
|
||||
var wt = scrbuf.dwSize.X - origin.X
|
||||
if FillConsoleOutputCharacter(hStdout,' ', ht*wt,
|
||||
origin, addr(numwrote)) == 0:
|
||||
OSError()
|
||||
if FillConsoleOutputAttribute(hStdout, scrbuf.wAttributes, ht * wt,
|
||||
scrbuf.dwCursorPosition, addr(numwrote)) == 0:
|
||||
OSError()
|
||||
else:
|
||||
stdout.write("\e[2K")
|
||||
setCursorXPos(0)
|
||||
|
||||
proc EraseScreen* =
|
||||
## Erases the screen with the background colour and moves the cursor to home.
|
||||
when defined(windows):
|
||||
var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO
|
||||
var numwrote: DWORD
|
||||
var origin: TCoord # is inititalized to 0, 0
|
||||
var hStdout = conHandle
|
||||
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()
|
||||
if FillConsoleOutputCharacter(hStdout, ' ', scrbuf.dwSize.X*scrbuf.dwSize.Y,
|
||||
origin, addr(numwrote)) == 0:
|
||||
OSError()
|
||||
if FillConsoleOutputAttribute(hStdout, scrbuf.wAttributes,
|
||||
scrbuf.dwSize.X * scrbuf.dwSize.Y,
|
||||
origin, addr(numwrote)) == 0:
|
||||
OSError()
|
||||
setCursorXPos(0)
|
||||
else:
|
||||
stdout.write("\e[2J")
|
||||
|
||||
proc ResetAttributes* {.noconv.} =
|
||||
## resets all attributes; it is advisable to register this as a quit proc
|
||||
## with ``system.addQuitProc(resetAttributes)``.
|
||||
when defined(windows):
|
||||
discard SetConsoleTextAttribute(conHandle, oldAttr)
|
||||
else:
|
||||
stdout.write("\e[0m")
|
||||
|
||||
type
|
||||
TStyle* = enum ## different styles for text output
|
||||
styleBright = 1, ## bright text
|
||||
styleDim, ## dim text
|
||||
styleUnknown, ## unknown
|
||||
styleUnderscore = 4, ## underscored text
|
||||
styleBlink, ## blinking/bold text
|
||||
styleReverse, ## unknown
|
||||
styleHidden ## hidden text
|
||||
|
||||
when not defined(windows):
|
||||
var
|
||||
gFG = 0
|
||||
gBG = 0
|
||||
|
||||
proc WriteStyled*(txt: string, style: set[TStyle] = {styleBright}) =
|
||||
## writes the text `txt` in a given `style`.
|
||||
when defined(windows):
|
||||
var a = 0'i16
|
||||
if styleBright in style: a = a or int16(FOREGROUND_INTENSITY)
|
||||
if styleBlink in style: a = a or int16(BACKGROUND_INTENSITY)
|
||||
if styleReverse in style: a = a or 0x4000'i16 # COMMON_LVB_REVERSE_VIDEO
|
||||
if styleUnderscore in style: a = a or 0x8000'i16 # COMMON_LVB_UNDERSCORE
|
||||
var old = getAttributes()
|
||||
discard SetConsoleTextAttribute(conHandle, old or a)
|
||||
stdout.write(txt)
|
||||
discard SetConsoleTextAttribute(conHandle, old)
|
||||
else:
|
||||
for s in items(style):
|
||||
stdout.write("\e[" & $ord(s) & 'm')
|
||||
stdout.write(txt)
|
||||
resetAttributes()
|
||||
if gFG != 0:
|
||||
stdout.write("\e[" & $ord(gFG) & 'm')
|
||||
if gBG != 0:
|
||||
stdout.write("\e[" & $ord(gBG) & 'm')
|
||||
|
||||
type
|
||||
TForegroundColor* = enum ## terminal's foreground colors
|
||||
fgBlack = 30, ## black
|
||||
fgRed, ## red
|
||||
fgGreen, ## green
|
||||
fgYellow, ## yellow
|
||||
fgBlue, ## blue
|
||||
fgMagenta, ## magenta
|
||||
fgCyan, ## cyan
|
||||
fgWhite ## white
|
||||
|
||||
TBackgroundColor* = enum ## terminal's background colors
|
||||
bgBlack = 40, ## black
|
||||
bgRed, ## red
|
||||
bgGreen, ## green
|
||||
bgYellow, ## yellow
|
||||
bgBlue, ## blue
|
||||
bgMagenta, ## magenta
|
||||
bgCyan, ## cyan
|
||||
bgWhite ## white
|
||||
|
||||
proc setForegroundColor*(fg: TForegroundColor, bright=false) =
|
||||
## sets the terminal's foreground color
|
||||
when defined(windows):
|
||||
var old = getAttributes() and not 0x0007
|
||||
if bright:
|
||||
old = old or FOREGROUND_INTENSITY
|
||||
const lookup: array [TForegroundColor, int] = [
|
||||
0,
|
||||
(FOREGROUND_RED),
|
||||
(FOREGROUND_GREEN),
|
||||
(FOREGROUND_RED or FOREGROUND_GREEN),
|
||||
(FOREGROUND_BLUE),
|
||||
(FOREGROUND_RED or FOREGROUND_BLUE),
|
||||
(FOREGROUND_BLUE or FOREGROUND_GREEN),
|
||||
(FOREGROUND_BLUE or FOREGROUND_GREEN or FOREGROUND_RED)]
|
||||
discard SetConsoleTextAttribute(conHandle, toU16(old or lookup[fg]))
|
||||
else:
|
||||
gFG = ord(fg)
|
||||
if bright: inc(gFG, 60)
|
||||
stdout.write("\e[" & $gFG & 'm')
|
||||
|
||||
proc setBackgroundColor*(bg: TBackgroundColor, bright=false) =
|
||||
## sets the terminal's background color
|
||||
when defined(windows):
|
||||
var old = getAttributes() and not 0x0070
|
||||
if bright:
|
||||
old = old or BACKGROUND_INTENSITY
|
||||
const lookup: array [TBackgroundColor, int] = [
|
||||
0,
|
||||
(BACKGROUND_RED),
|
||||
(BACKGROUND_GREEN),
|
||||
(BACKGROUND_RED or BACKGROUND_GREEN),
|
||||
(BACKGROUND_BLUE),
|
||||
(BACKGROUND_RED or BACKGROUND_BLUE),
|
||||
(BACKGROUND_BLUE or BACKGROUND_GREEN),
|
||||
(BACKGROUND_BLUE or BACKGROUND_GREEN or BACKGROUND_RED)]
|
||||
discard SetConsoleTextAttribute(conHandle, toU16(old or lookup[bg]))
|
||||
else:
|
||||
gBG = ord(bg)
|
||||
if bright: inc(gBG, 60)
|
||||
stdout.write("\e[" & $gBG & 'm')
|
||||
|
||||
when isMainModule:
|
||||
system.addQuitProc(resetAttributes)
|
||||
write(stdout, "never mind")
|
||||
eraseLine()
|
||||
#setCursorPos(2, 2)
|
||||
writeStyled("styled text ", {styleBright, styleBlink, styleUnderscore})
|
||||
setBackGroundColor(bgCyan, true)
|
||||
setForeGroundColor(fgBlue)
|
||||
writeln(stdout, "ordinary text")
|
||||
|
||||
57
lib/base/web.nim
Normal file
57
lib/base/web.nim
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module contains simple high-level procedures for dealing with the
|
||||
## web. Use cases:
|
||||
##
|
||||
## * requesting URLs
|
||||
## * sending and retrieving emails
|
||||
## * sending and retrieving files from an FTP server
|
||||
##
|
||||
## Currently only requesting URLs is implemented. The implementation depends
|
||||
## on the libcurl library!
|
||||
|
||||
import libcurl, streams
|
||||
|
||||
proc curlwrapperWrite(p: pointer, size, nmemb: int,
|
||||
data: pointer): int {.cdecl.} =
|
||||
var stream = cast[PStream](data)
|
||||
stream.writeData(stream, p, size*nmemb)
|
||||
return size*nmemb
|
||||
|
||||
proc URLretrieveStream*(url: string): PStream =
|
||||
## retrieves the given `url` and returns a stream which one can read from to
|
||||
## obtain the contents. Returns nil if an error occurs.
|
||||
result = newStringStream()
|
||||
var hCurl = curl_easy_init()
|
||||
if hCurl == nil: return nil
|
||||
if curl_easy_setopt(hCurl, CURLOPT_URL, url) != CURLE_OK: return nil
|
||||
if curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION,
|
||||
curlwrapperWrite) != CURLE_OK: return nil
|
||||
if curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, result) != CURLE_OK: return nil
|
||||
if curl_easy_perform(hCurl) != CURLE_OK: return nil
|
||||
curl_easy_cleanup(hCurl)
|
||||
|
||||
proc URLretrieveString*(url: string): string =
|
||||
## retrieves the given `url` and returns the contents. Returns nil if an
|
||||
## error occurs.
|
||||
var stream = newStringStream()
|
||||
var hCurl = curl_easy_init()
|
||||
if hCurl == nil: return nil
|
||||
if curl_easy_setopt(hCurl, CURLOPT_URL, url) != CURLE_OK: return nil
|
||||
if curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION,
|
||||
curlwrapperWrite) != CURLE_OK: return nil
|
||||
if curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, stream) != CURLE_OK: return nil
|
||||
if curl_easy_perform(hCurl) != CURLE_OK: return nil
|
||||
curl_easy_cleanup(hCurl)
|
||||
result = stream.data
|
||||
|
||||
when isMainModule:
|
||||
echo URLretrieveString("http://nimrod.ethexor.com/")
|
||||
|
||||
Reference in New Issue
Block a user