version 0.7.6
This commit is contained in:
parent
e792940f52
commit
08bc9ac03c
29 changed files with 5926 additions and 0 deletions
67
boot.nim
Normal file
67
boot.nim
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Nimrod Bootstrap Program
|
||||||
|
# (c) Copyright 2009 Andreas Rumpf
|
||||||
|
#
|
||||||
|
# See the file "copying.txt", included in this
|
||||||
|
# distribution, for details about the copyright.
|
||||||
|
#
|
||||||
|
|
||||||
|
import
|
||||||
|
os, strutils
|
||||||
|
|
||||||
|
const
|
||||||
|
BootCmd = "nimrod cc --compile:build/platdef.c $1 rod/nimrod.nim"
|
||||||
|
PlatdefCTmpl = """
|
||||||
|
/* Generated by boot.nim */
|
||||||
|
char* nimOS(void) { return "$1"; }
|
||||||
|
char* nimCPU(void) { return "$2"; }
|
||||||
|
"""
|
||||||
|
|
||||||
|
proc exec(cmd: string) =
|
||||||
|
echo(cmd)
|
||||||
|
if executeShellCommand(cmd) != 0: quit("FAILURE")
|
||||||
|
|
||||||
|
proc writePlatdefC =
|
||||||
|
var f: TFile
|
||||||
|
if openFile(f, "build/platdef.c", fmWrite):
|
||||||
|
write(f, PlatdefcTmpl % [system.hostOS, system.hostCPU])
|
||||||
|
closeFile(f)
|
||||||
|
else:
|
||||||
|
quit("Cannot write 'build/platdef.c'\n")
|
||||||
|
|
||||||
|
proc rodsrc =
|
||||||
|
const
|
||||||
|
blacklist = ["nsystem", "nmath", "nos", "ntime", "strutils"]
|
||||||
|
cmd = "nimrod boot --skip_proj_cfg -o:rod/$1.nim nim/$1"
|
||||||
|
for fi in walkFiles("nim/*.pas"):
|
||||||
|
var f = extractFileTrunk(fi)
|
||||||
|
if find(blacklist, f) >= 0: continue
|
||||||
|
var r = "rod" / appendFileExt(f, "nim")
|
||||||
|
if not existsFile(r) or fileNewer(fi, r):
|
||||||
|
Exec(cmd % f)
|
||||||
|
|
||||||
|
proc boot(args: string) =
|
||||||
|
writePlatdefC()
|
||||||
|
rodsrc()
|
||||||
|
var newExe = appendFileExt("rod/nimrod", ExeExt)
|
||||||
|
var oldExe = appendFileExt("bin/nimrod", ExeExt)
|
||||||
|
for i in 1..2:
|
||||||
|
Echo("iteration: ", $i)
|
||||||
|
# use the new executable to compile the files in the bootstrap directory:
|
||||||
|
Exec(Bootcmd % args)
|
||||||
|
if sameFileContent(newExe, oldExe):
|
||||||
|
Echo("executables are equal: SUCCESS!")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
Echo("executables are not equal: compile once again...")
|
||||||
|
# move the new executable to bin directory:
|
||||||
|
os.moveFile(oldExe, newExe)
|
||||||
|
Echo("[Warning] executables are still not equal")
|
||||||
|
|
||||||
|
var a = ""
|
||||||
|
for i in 1 .. paramCount():
|
||||||
|
add(a, ' ')
|
||||||
|
add(a, paramStr(i))
|
||||||
|
boot(a)
|
||||||
|
|
||||||
7
examples/hallo.nim
Normal file
7
examples/hallo.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Hallo world program
|
||||||
|
|
||||||
|
import strutils
|
||||||
|
|
||||||
|
echo($(parseFloat("0.5")* toFloat(5000) / toFloat(parseInt("5000"))))
|
||||||
|
|
||||||
|
echo("Hallo world!")
|
||||||
58
examples/htmlrefs.nim
Normal file
58
examples/htmlrefs.nim
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
# Example program to show the new parsexml module
|
||||||
|
# This program reads an HTML file and writes all its used links to stdout.
|
||||||
|
# Errors and whitespace are ignored.
|
||||||
|
# (c) 2009 Andreas Rumpf
|
||||||
|
|
||||||
|
import os, streams, parsexml, strutils
|
||||||
|
|
||||||
|
proc `=?=` (a, b: string): bool =
|
||||||
|
# little trick: define our own comparator that ignores case
|
||||||
|
return cmpIgnoreCase(a, b) == 0
|
||||||
|
|
||||||
|
if paramCount() < 1:
|
||||||
|
quit("Usage: htmlrefs filename[.html]")
|
||||||
|
|
||||||
|
var links = 0 # count the number of links
|
||||||
|
var filename = appendFileExt(ParamStr(1), "html")
|
||||||
|
var s = newFileStream(filename, fmRead)
|
||||||
|
if s == nil: quit("cannot open the file" & filename)
|
||||||
|
var x: TXmlParser
|
||||||
|
open(x, s, filename)
|
||||||
|
next(x) # get first event
|
||||||
|
block mainLoop:
|
||||||
|
while true:
|
||||||
|
case x.kind
|
||||||
|
of xmlElementOpen:
|
||||||
|
# the <a href = "xyz"> tag we are interested in always has an attribute,
|
||||||
|
# thus we search for ``xmlElementOpen`` and not for ``xmlElementStart``
|
||||||
|
if x.elementName =?= "a":
|
||||||
|
x.next()
|
||||||
|
if x.kind == xmlAttribute:
|
||||||
|
if x.attrKey =?= "href":
|
||||||
|
var link = x.attrValue
|
||||||
|
inc(links)
|
||||||
|
# skip until we have an ``xmlElementClose`` event
|
||||||
|
while true:
|
||||||
|
x.next()
|
||||||
|
case x.kind
|
||||||
|
of xmlEof: break mainLoop
|
||||||
|
of xmlElementClose: break
|
||||||
|
else: nil
|
||||||
|
x.next() # skip ``xmlElementClose``
|
||||||
|
# now we have the description for the ``a`` element
|
||||||
|
var desc = ""
|
||||||
|
while x.kind == xmlCharData:
|
||||||
|
desc.add(x.charData)
|
||||||
|
x.next()
|
||||||
|
Echo(desc & ": " & link)
|
||||||
|
else:
|
||||||
|
x.next()
|
||||||
|
of xmlEof: break # end of file reached
|
||||||
|
of xmlError:
|
||||||
|
Echo(errorMsg(x))
|
||||||
|
x.next()
|
||||||
|
else: x.next() # skip other events
|
||||||
|
|
||||||
|
echo($links & " link(s) found!")
|
||||||
|
x.close()
|
||||||
|
|
||||||
37
examples/htmltitle.nim
Normal file
37
examples/htmltitle.nim
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Example program to show the new parsexml module
|
||||||
|
# This program reads an HTML file and writes its title to stdout.
|
||||||
|
# Errors and whitespace are ignored.
|
||||||
|
# (c) 2009 Andreas Rumpf
|
||||||
|
|
||||||
|
import os, streams, parsexml, strutils
|
||||||
|
|
||||||
|
if paramCount() < 1:
|
||||||
|
quit("Usage: htmltitle filename[.html]")
|
||||||
|
|
||||||
|
var filename = appendFileExt(ParamStr(1), "html")
|
||||||
|
var s = newFileStream(filename, fmRead)
|
||||||
|
if s == nil: quit("cannot open the file" & filename)
|
||||||
|
var x: TXmlParser
|
||||||
|
open(x, s, filename)
|
||||||
|
while true:
|
||||||
|
x.next()
|
||||||
|
case x.kind
|
||||||
|
of xmlElementStart:
|
||||||
|
if cmpIgnoreCase(x.elementName, "title") == 0:
|
||||||
|
var title = ""
|
||||||
|
x.next() # skip "<title>"
|
||||||
|
while x.kind == xmlCharData:
|
||||||
|
title.add(x.charData)
|
||||||
|
x.next()
|
||||||
|
if x.kind == xmlElementEnd and cmpIgnoreCase(x.elementName, "title") == 0:
|
||||||
|
Echo("Title: " & title)
|
||||||
|
quit(0) # Success!
|
||||||
|
else:
|
||||||
|
echo(x.errorMsgExpected("/title"))
|
||||||
|
|
||||||
|
of xmlEof: break # end of file reached
|
||||||
|
else: nil # ignore other events
|
||||||
|
|
||||||
|
quit("Could not determine title!")
|
||||||
|
x.close()
|
||||||
|
|
||||||
5
examples/readme.txt
Normal file
5
examples/readme.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
In this directory you will find several examples for how to use the Nimrod
|
||||||
|
library.
|
||||||
|
|
||||||
|
Copyright (c) 2004-2009 Andreas Rumpf.
|
||||||
|
All rights reserved.
|
||||||
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/")
|
||||||
|
|
||||||
621
lib/parsexml.nim
Normal file
621
lib/parsexml.nim
Normal file
|
|
@ -0,0 +1,621 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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 implements a simple high performance `XML`:idx: / `HTML`:idx:
|
||||||
|
## parser.
|
||||||
|
## The only encoding that is supported is UTF-8. The parser has been designed
|
||||||
|
## to be somewhat error correcting, so that even most "wild HTML" found on the
|
||||||
|
## web can be parsed with it. **Note:** This parser does not check that each
|
||||||
|
## ``<tag>`` has a corresponding ``</tag>``! These checks have do be
|
||||||
|
## implemented by the client code for various reasons:
|
||||||
|
##
|
||||||
|
## * Old HTML contains tags that have no end tag: ``<br>`` for example.
|
||||||
|
## * HTML tags are case insensitive, XML tags are case sensitive. Since this
|
||||||
|
## library can parse both, only the client knows which comparison is to be
|
||||||
|
## used.
|
||||||
|
## * Thus the checks would have been very difficult to implement properly with
|
||||||
|
## little benefit, especially since they are simple to implement in the
|
||||||
|
## client. The client should use the `errorMsgExpected` proc to generate
|
||||||
|
## a nice error message that fits to the other error messages this library
|
||||||
|
## creates.
|
||||||
|
##
|
||||||
|
##
|
||||||
|
## Example 1: Retrieve HTML title
|
||||||
|
## ==============================
|
||||||
|
##
|
||||||
|
## The file ``examples/htmltitle.nim`` demonstrates how to use the
|
||||||
|
## XML parser to accomplish a simple task: To determine the title of an HTML
|
||||||
|
## document.
|
||||||
|
##
|
||||||
|
## .. code-block:: nimrod
|
||||||
|
## :file: examples/htmltitle.nim
|
||||||
|
##
|
||||||
|
##
|
||||||
|
## Example 2: Retrieve all HTML links
|
||||||
|
## ==================================
|
||||||
|
##
|
||||||
|
## The file ``examples/htmlrefs.nim`` demonstrates how to use the
|
||||||
|
## XML parser to accomplish another simple task: To determine all the links
|
||||||
|
## an HTML document contains.
|
||||||
|
##
|
||||||
|
## .. code-block:: nimrod
|
||||||
|
## :file: examples/htmlrefs.nim
|
||||||
|
##
|
||||||
|
|
||||||
|
import
|
||||||
|
hashes, strutils, lexbase, streams, unicode
|
||||||
|
|
||||||
|
# the parser treats ``<br />`` as ``<br></br>``
|
||||||
|
|
||||||
|
type
|
||||||
|
TXmlEventKind* = enum ## enumation of all events that may occur when parsing
|
||||||
|
xmlError, ## an error ocurred during parsing
|
||||||
|
xmlEof, ## end of file reached
|
||||||
|
xmlCharData, ## character data
|
||||||
|
xmlWhitespace, ## whitespace has been parsed
|
||||||
|
xmlComment, ## a comment has been parsed
|
||||||
|
xmlPI, ## processing instruction (``<?name something ?>``)
|
||||||
|
xmlElementStart, ## ``<elem>``
|
||||||
|
xmlElementEnd, ## ``</elem>``
|
||||||
|
xmlElementOpen, ## ``<elem
|
||||||
|
xmlAttribute, ## ``key = "value"`` pair
|
||||||
|
xmlElementClose, ## ``>``
|
||||||
|
xmlCData, ## ``<![CDATA[`` ... data ... ``]]>``
|
||||||
|
xmlEntity, ## &entity;
|
||||||
|
xmlSpecial ## ``<! ... data ... >``
|
||||||
|
|
||||||
|
TXmlError* = enum ## enumeration that lists all errors that can occur
|
||||||
|
errNone, ## no error
|
||||||
|
errEndOfCDataExpected, ## ``]]>`` expected
|
||||||
|
errNameExpected, ## name expected
|
||||||
|
errSemicolonExpected, ## ``;`` expected
|
||||||
|
errQmGtExpected, ## ``?>`` expected
|
||||||
|
errGtExpected, ## ``>`` expected
|
||||||
|
errEqExpected, ## ``=`` expected
|
||||||
|
errQuoteExpected, ## ``"`` or ``'`` expected
|
||||||
|
errEndOfCommentExpected ## ``-->`` expected
|
||||||
|
|
||||||
|
TParserState = enum
|
||||||
|
stateStart, stateNormal, stateAttr, stateEmptyElementTag, stateError
|
||||||
|
|
||||||
|
TXmlParseOption* = enum ## options for the XML parser
|
||||||
|
reportWhitespace, ## report whitespace
|
||||||
|
reportComments ## report comments
|
||||||
|
|
||||||
|
TXmlParser* = object of TBaseLexer ## the parser object.
|
||||||
|
a, b: string
|
||||||
|
kind: TXmlEventKind
|
||||||
|
err: TXmlError
|
||||||
|
state: TParserState
|
||||||
|
filename: string
|
||||||
|
options: set[TXmlParseOption]
|
||||||
|
|
||||||
|
const
|
||||||
|
errorMessages: array [TXmlError, string] = [
|
||||||
|
"no error",
|
||||||
|
"']]>' expected",
|
||||||
|
"name expected",
|
||||||
|
"';' expected",
|
||||||
|
"'?>' expected",
|
||||||
|
"'>' expected",
|
||||||
|
"'=' expected",
|
||||||
|
"'\"' or \"'\" expected",
|
||||||
|
"'-->' expected"
|
||||||
|
]
|
||||||
|
|
||||||
|
proc open*(my: var TXmlParser, input: PStream, filename: string,
|
||||||
|
options: set[TXmlParseOption] = {}) =
|
||||||
|
## initializes the parser with an input stream. `Filename` is only used
|
||||||
|
## for nice error messages. The parser's behaviour can be controlled by
|
||||||
|
## the `options` parameter: If `options` contains ``reportWhitespace``
|
||||||
|
## a whitespace token is reported as an ``xmlWhitespace`` event.
|
||||||
|
## If `options` contains ``reportComments`` a comment token is reported as an
|
||||||
|
## ``xmlComment`` event.
|
||||||
|
lexbase.open(my, input)
|
||||||
|
my.filename = filename
|
||||||
|
my.state = stateStart
|
||||||
|
my.kind = xmlError
|
||||||
|
my.a = ""
|
||||||
|
my.b = ""
|
||||||
|
my.options = options
|
||||||
|
|
||||||
|
proc close*(my: var TXmlParser) {.inline.} =
|
||||||
|
## closes the parser `my` and its associated input stream.
|
||||||
|
lexbase.close(my)
|
||||||
|
|
||||||
|
proc charData*(my: TXmlParser): string {.inline.} =
|
||||||
|
## returns the character data for the events: ``xmlCharData``,
|
||||||
|
## ``xmlWhitespace``, ``xmlComment``, ``xmlCData``, ``xmlSpecial``
|
||||||
|
assert(my.kind in {xmlCharData, xmlWhitespace, xmlComment, xmlCData,
|
||||||
|
xmlSpecial})
|
||||||
|
return my.a
|
||||||
|
|
||||||
|
proc kind*(my: TXmlParser): TXmlEventKind {.inline.} =
|
||||||
|
## returns the current event type for the XML parser
|
||||||
|
return my.kind
|
||||||
|
|
||||||
|
proc elementName*(my: TXmlParser): string {.inline.} =
|
||||||
|
## returns the element name for the events: ``xmlElementStart``,
|
||||||
|
## ``xmlElementEnd``, ``xmlElementOpen``
|
||||||
|
assert(my.kind in {xmlElementStart, xmlElementEnd, xmlElementOpen})
|
||||||
|
return my.a
|
||||||
|
|
||||||
|
proc entityName*(my: TXmlParser): string {.inline.} =
|
||||||
|
## returns the entity name for the event: ``xmlEntity``
|
||||||
|
assert(my.kind == xmlEntity)
|
||||||
|
return my.a
|
||||||
|
|
||||||
|
proc attrKey*(my: TXmlParser): string {.inline.} =
|
||||||
|
## returns the attribute key for the event ``xmlAttribute``
|
||||||
|
assert(my.kind == xmlAttribute)
|
||||||
|
return my.a
|
||||||
|
|
||||||
|
proc attrValue*(my: TXmlParser): string {.inline.} =
|
||||||
|
## returns the attribute value for the event ``xmlAttribute``
|
||||||
|
assert(my.kind == xmlAttribute)
|
||||||
|
return my.b
|
||||||
|
|
||||||
|
proc PIName*(my: TXmlParser): string {.inline.} =
|
||||||
|
## returns the processing instruction name for the event ``xmlPI``
|
||||||
|
assert(my.kind == xmlPI)
|
||||||
|
return my.a
|
||||||
|
|
||||||
|
proc PIRest*(my: TXmlParser): string {.inline.} =
|
||||||
|
## returns the rest of the processing instruction for the event ``xmlPI``
|
||||||
|
assert(my.kind == xmlPI)
|
||||||
|
return my.b
|
||||||
|
|
||||||
|
proc getColumn*(my: TXmlParser): int {.inline.} =
|
||||||
|
## get the current column the parser has arrived at.
|
||||||
|
result = getColNumber(my, my.bufPos)
|
||||||
|
|
||||||
|
proc getLine*(my: TXmlParser): int {.inline.} =
|
||||||
|
## get the current line the parser has arrived at.
|
||||||
|
result = my.linenumber
|
||||||
|
|
||||||
|
proc getFilename*(my: TXmlParser): string {.inline.} =
|
||||||
|
## get the filename of the file that the parser processes.
|
||||||
|
result = my.filename
|
||||||
|
|
||||||
|
proc errorMsg*(my: TXmlParser): string =
|
||||||
|
## returns a helpful error message for the event ``xmlError``
|
||||||
|
assert(my.kind == xmlError)
|
||||||
|
result = "$1($2, $3) Error: $4" % [
|
||||||
|
my.filename, $getLine(my), $getColumn(my), errorMessages[my.err]]
|
||||||
|
|
||||||
|
proc errorMsgExpected*(my: TXmlParser, tag: string): string =
|
||||||
|
## returns an error message "<tag> expected" in the same format as the
|
||||||
|
## other error messages
|
||||||
|
result = "$1($2, $3) Error: $4" % [
|
||||||
|
my.filename, $getLine(my), $getColumn(my), "<$1> expected" % tag]
|
||||||
|
|
||||||
|
proc markError(my: var TXmlParser, kind: TXmlError) {.inline.} =
|
||||||
|
my.err = kind
|
||||||
|
my.state = stateError
|
||||||
|
|
||||||
|
proc parseCDATA(my: var TXMLParser) =
|
||||||
|
var pos = my.bufpos + len("<![CDATA[")
|
||||||
|
var buf = my.buf
|
||||||
|
while true:
|
||||||
|
case buf[pos]
|
||||||
|
of ']':
|
||||||
|
if buf[pos+1] == ']' and buf[pos+2] == '>':
|
||||||
|
inc(pos, 3)
|
||||||
|
break
|
||||||
|
add(my.a, ']')
|
||||||
|
inc(pos)
|
||||||
|
of '\0':
|
||||||
|
markError(my, errEndOfCDataExpected)
|
||||||
|
break
|
||||||
|
of '\c':
|
||||||
|
pos = lexbase.HandleCR(my, pos)
|
||||||
|
add(my.a, '\L')
|
||||||
|
of '\L':
|
||||||
|
pos = lexbase.HandleLF(my, pos)
|
||||||
|
add(my.a, '\L')
|
||||||
|
else:
|
||||||
|
add(my.a, buf[pos])
|
||||||
|
inc(pos)
|
||||||
|
my.bufpos = pos # store back
|
||||||
|
my.kind = xmlCDATA
|
||||||
|
|
||||||
|
proc parseComment(my: var TXMLParser) =
|
||||||
|
var pos = my.bufpos + len("<!--")
|
||||||
|
var buf = my.buf
|
||||||
|
while true:
|
||||||
|
case buf[pos]
|
||||||
|
of '-':
|
||||||
|
if buf[pos+1] == '-' and buf[pos+2] == '>':
|
||||||
|
inc(pos, 3)
|
||||||
|
break
|
||||||
|
if my.options.contains(reportComments): add(my.a, '-')
|
||||||
|
inc(pos)
|
||||||
|
of '\0':
|
||||||
|
markError(my, errEndOfCommentExpected)
|
||||||
|
break
|
||||||
|
of '\c':
|
||||||
|
pos = lexbase.HandleCR(my, pos)
|
||||||
|
if my.options.contains(reportComments): add(my.a, '\L')
|
||||||
|
of '\L':
|
||||||
|
pos = lexbase.HandleLF(my, pos)
|
||||||
|
if my.options.contains(reportComments): add(my.a, '\L')
|
||||||
|
else:
|
||||||
|
if my.options.contains(reportComments): add(my.a, buf[pos])
|
||||||
|
inc(pos)
|
||||||
|
my.bufpos = pos
|
||||||
|
my.kind = xmlComment
|
||||||
|
|
||||||
|
proc parseWhitespace(my: var TXmlParser, skip=False) =
|
||||||
|
var pos = my.bufpos
|
||||||
|
var buf = my.buf
|
||||||
|
while true:
|
||||||
|
case buf[pos]
|
||||||
|
of ' ', '\t':
|
||||||
|
if not skip: add(my.a, buf[pos])
|
||||||
|
Inc(pos)
|
||||||
|
of '\c':
|
||||||
|
# the specification says that CR-LF, CR are to be transformed to LF
|
||||||
|
pos = lexbase.HandleCR(my, pos)
|
||||||
|
if not skip: add(my.a, '\L')
|
||||||
|
of '\L':
|
||||||
|
pos = lexbase.HandleLF(my, pos)
|
||||||
|
if not skip: add(my.a, '\L')
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
my.bufpos = pos
|
||||||
|
|
||||||
|
const
|
||||||
|
NameStartChar = {'A'..'Z', 'a'..'z', '_', ':', '\128'..'\255'}
|
||||||
|
NameChar = {'A'..'Z', 'a'..'z', '0'..'9', '.', '-', '_', ':', '\128'..'\255'}
|
||||||
|
|
||||||
|
proc parseName(my: var TXmlParser, dest: var string) =
|
||||||
|
var pos = my.bufpos
|
||||||
|
var buf = my.buf
|
||||||
|
if buf[pos] in nameStartChar:
|
||||||
|
while true:
|
||||||
|
add(dest, buf[pos])
|
||||||
|
inc(pos)
|
||||||
|
if buf[pos] notin NameChar: break
|
||||||
|
my.bufpos = pos
|
||||||
|
else:
|
||||||
|
markError(my, errNameExpected)
|
||||||
|
|
||||||
|
proc parseEntity(my: var TXmlParser, dest: var string) =
|
||||||
|
var pos = my.bufpos+1
|
||||||
|
var buf = my.buf
|
||||||
|
my.kind = xmlCharData
|
||||||
|
if buf[pos] == '#':
|
||||||
|
var r: TRune
|
||||||
|
inc(pos)
|
||||||
|
if buf[pos] == 'x':
|
||||||
|
inc(pos)
|
||||||
|
while true:
|
||||||
|
case buf[pos]
|
||||||
|
of '0'..'9': r = (r shl 4) or (ord(buf[pos]) - ord('0'))
|
||||||
|
of 'a'..'f': r = (r shl 4) or (ord(buf[pos]) - ord('a') + 10)
|
||||||
|
of 'A'..'F': r = (r shl 4) or (ord(buf[pos]) - ord('A') + 10)
|
||||||
|
else: break
|
||||||
|
inc(pos)
|
||||||
|
else:
|
||||||
|
while buf[pos] in {'0'..'9'}:
|
||||||
|
r = r * 10 + (ord(buf[pos]) - ord('0'))
|
||||||
|
inc(pos)
|
||||||
|
add(dest, toUTF8(r))
|
||||||
|
elif buf[pos] == 'l' and buf[pos+1] == 't':
|
||||||
|
add(dest, '<')
|
||||||
|
inc(pos, 2)
|
||||||
|
elif buf[pos] == 'g' and buf[pos+1] == 't':
|
||||||
|
add(dest, '>')
|
||||||
|
inc(pos, 2)
|
||||||
|
elif buf[pos] == 'a' and buf[pos+1] == 'm' and buf[pos+2] == 'p':
|
||||||
|
add(dest, '&')
|
||||||
|
inc(pos, 3)
|
||||||
|
elif buf[pos] == 'a' and buf[pos+1] == 'p' and buf[pos+2] == 'o' and
|
||||||
|
buf[pos+3] == 's':
|
||||||
|
add(dest, '\'')
|
||||||
|
inc(pos, 4)
|
||||||
|
elif buf[pos] == 'q' and buf[pos+1] == 'u' and buf[pos+2] == 'o' and
|
||||||
|
buf[pos+3] == 't':
|
||||||
|
add(dest, '"')
|
||||||
|
inc(pos, 4)
|
||||||
|
else:
|
||||||
|
my.bufpos = pos
|
||||||
|
parseName(my, dest)
|
||||||
|
pos = my.bufpos
|
||||||
|
if my.err != errNameExpected:
|
||||||
|
my.kind = xmlEntity
|
||||||
|
else:
|
||||||
|
add(dest, '&')
|
||||||
|
if buf[pos] == ';':
|
||||||
|
inc(pos)
|
||||||
|
else:
|
||||||
|
markError(my, errSemiColonExpected)
|
||||||
|
my.bufpos = pos
|
||||||
|
|
||||||
|
proc parsePI(my: var TXmlParser) =
|
||||||
|
inc(my.bufpos, "<?".len)
|
||||||
|
parseName(my, my.a)
|
||||||
|
var pos = my.bufpos
|
||||||
|
var buf = my.buf
|
||||||
|
setLen(my.b, 0)
|
||||||
|
while true:
|
||||||
|
case buf[pos]
|
||||||
|
of '\0':
|
||||||
|
markError(my, errQmGtExpected)
|
||||||
|
break
|
||||||
|
of '?':
|
||||||
|
if buf[pos+1] == '>':
|
||||||
|
inc(pos, 2)
|
||||||
|
break
|
||||||
|
add(my.b, '?')
|
||||||
|
inc(pos)
|
||||||
|
of '\c':
|
||||||
|
# the specification says that CR-LF, CR are to be transformed to LF
|
||||||
|
pos = lexbase.HandleCR(my, pos)
|
||||||
|
add(my.b, '\L')
|
||||||
|
of '\L':
|
||||||
|
pos = lexbase.HandleLF(my, pos)
|
||||||
|
add(my.b, '\L')
|
||||||
|
else:
|
||||||
|
add(my.b, buf[pos])
|
||||||
|
inc(pos)
|
||||||
|
my.bufpos = pos
|
||||||
|
my.kind = xmlPI
|
||||||
|
|
||||||
|
proc parseSpecial(my: var TXmlParser) =
|
||||||
|
# things that start with <!
|
||||||
|
var pos = my.bufpos + 2
|
||||||
|
var buf = my.buf
|
||||||
|
var opentags = 0
|
||||||
|
while true:
|
||||||
|
case buf[pos]
|
||||||
|
of '\0':
|
||||||
|
markError(my, errGtExpected)
|
||||||
|
break
|
||||||
|
of '<':
|
||||||
|
inc(opentags)
|
||||||
|
inc(pos)
|
||||||
|
add(my.a, '<')
|
||||||
|
of '>':
|
||||||
|
if opentags <= 0:
|
||||||
|
inc(pos)
|
||||||
|
break
|
||||||
|
dec(opentags)
|
||||||
|
inc(pos)
|
||||||
|
add(my.a, '>')
|
||||||
|
of '\c':
|
||||||
|
pos = lexbase.HandleCR(my, pos)
|
||||||
|
add(my.a, '\L')
|
||||||
|
of '\L':
|
||||||
|
pos = lexbase.HandleLF(my, pos)
|
||||||
|
add(my.a, '\L')
|
||||||
|
else:
|
||||||
|
add(my.a, buf[pos])
|
||||||
|
inc(pos)
|
||||||
|
my.bufpos = pos
|
||||||
|
my.kind = xmlSpecial
|
||||||
|
|
||||||
|
proc parseTag(my: var TXmlParser) =
|
||||||
|
inc(my.bufpos)
|
||||||
|
parseName(my, my.a)
|
||||||
|
# if we have no name, do not interpret the '<':
|
||||||
|
if my.a.len == 0:
|
||||||
|
my.kind = xmlCharData
|
||||||
|
add(my.a, '<')
|
||||||
|
return
|
||||||
|
parseWhitespace(my, skip=True)
|
||||||
|
if my.buf[my.bufpos] in NameStartChar:
|
||||||
|
# an attribute follows:
|
||||||
|
my.kind = xmlElementOpen
|
||||||
|
my.state = stateAttr
|
||||||
|
else:
|
||||||
|
my.kind = xmlElementStart
|
||||||
|
if my.buf[my.bufpos] == '/' and my.buf[my.bufpos+1] == '>':
|
||||||
|
inc(my.bufpos, 2)
|
||||||
|
my.state = stateEmptyElementTag
|
||||||
|
elif my.buf[my.bufpos] == '>':
|
||||||
|
inc(my.bufpos)
|
||||||
|
else:
|
||||||
|
markError(my, errGtExpected)
|
||||||
|
|
||||||
|
proc parseEndTag(my: var TXmlParser) =
|
||||||
|
inc(my.bufpos, 2)
|
||||||
|
parseName(my, my.a)
|
||||||
|
parseWhitespace(my, skip=True)
|
||||||
|
if my.buf[my.bufpos] == '>':
|
||||||
|
inc(my.bufpos)
|
||||||
|
else:
|
||||||
|
markError(my, errGtExpected)
|
||||||
|
my.kind = xmlElementEnd
|
||||||
|
|
||||||
|
proc parseAttribute(my: var TXmlParser) =
|
||||||
|
my.kind = xmlAttribute
|
||||||
|
setLen(my.a, 0)
|
||||||
|
setLen(my.b, 0)
|
||||||
|
parseName(my, my.a)
|
||||||
|
# if we have no name, we have '<tag attr= key %&$$%':
|
||||||
|
if my.a.len == 0:
|
||||||
|
markError(my, errGtExpected)
|
||||||
|
return
|
||||||
|
parseWhitespace(my, skip=True)
|
||||||
|
if my.buf[my.bufpos] != '=':
|
||||||
|
markError(my, errEqExpected)
|
||||||
|
return
|
||||||
|
inc(my.bufpos)
|
||||||
|
parseWhitespace(my, skip=True)
|
||||||
|
|
||||||
|
var pos = my.bufpos
|
||||||
|
var buf = my.buf
|
||||||
|
if buf[pos] in {'\'', '"'}:
|
||||||
|
var quote = buf[pos]
|
||||||
|
var pendingSpace = false
|
||||||
|
inc(pos)
|
||||||
|
while true:
|
||||||
|
case buf[pos]
|
||||||
|
of '\0':
|
||||||
|
markError(my, errQuoteExpected)
|
||||||
|
break
|
||||||
|
of '&':
|
||||||
|
if pendingSpace:
|
||||||
|
add(my.b, ' ')
|
||||||
|
pendingSpace = false
|
||||||
|
my.bufpos = pos
|
||||||
|
parseEntity(my, my.b)
|
||||||
|
my.kind = xmlAttribute # parseEntity overwrites my.kind!
|
||||||
|
pos = my.bufpos
|
||||||
|
of ' ', '\t':
|
||||||
|
pendingSpace = true
|
||||||
|
inc(pos)
|
||||||
|
of '\c':
|
||||||
|
pos = lexbase.HandleCR(my, pos)
|
||||||
|
pendingSpace = true
|
||||||
|
of '\L':
|
||||||
|
pos = lexbase.HandleLF(my, pos)
|
||||||
|
pendingSpace = true
|
||||||
|
else:
|
||||||
|
if buf[pos] == quote:
|
||||||
|
inc(pos)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
if pendingSpace:
|
||||||
|
add(my.b, ' ')
|
||||||
|
pendingSpace = false
|
||||||
|
add(my.b, buf[pos])
|
||||||
|
inc(pos)
|
||||||
|
else:
|
||||||
|
markError(my, errQuoteExpected)
|
||||||
|
my.bufpos = pos
|
||||||
|
parseWhitespace(my, skip=True)
|
||||||
|
|
||||||
|
proc parseCharData(my: var TXmlParser) =
|
||||||
|
var pos = my.bufpos
|
||||||
|
var buf = my.buf
|
||||||
|
while true:
|
||||||
|
case buf[pos]
|
||||||
|
of '\0', '<', '&': break
|
||||||
|
of '\c':
|
||||||
|
# the specification says that CR-LF, CR are to be transformed to LF
|
||||||
|
pos = lexbase.HandleCR(my, pos)
|
||||||
|
add(my.a, '\L')
|
||||||
|
of '\L':
|
||||||
|
pos = lexbase.HandleLF(my, pos)
|
||||||
|
add(my.a, '\L')
|
||||||
|
else:
|
||||||
|
add(my.a, buf[pos])
|
||||||
|
inc(pos)
|
||||||
|
my.bufpos = pos
|
||||||
|
my.kind = xmlCharData
|
||||||
|
|
||||||
|
proc rawGetTok(my: var TXmlParser) =
|
||||||
|
my.kind = xmlError
|
||||||
|
setLen(my.a, 0)
|
||||||
|
var pos = my.bufpos
|
||||||
|
var buf = my.buf
|
||||||
|
case buf[pos]
|
||||||
|
of '<':
|
||||||
|
case buf[pos+1]
|
||||||
|
of '/':
|
||||||
|
parseEndTag(my)
|
||||||
|
of '!':
|
||||||
|
if buf[pos+2] == '[' and buf[pos+3] == 'C' and buf[pos+4] == 'D' and
|
||||||
|
buf[pos+5] == 'A' and buf[pos+6] == 'T' and buf[pos+7] == 'A' and
|
||||||
|
buf[pos+8] == '[':
|
||||||
|
parseCDATA(my)
|
||||||
|
elif buf[pos+2] == '-' and buf[pos+3] == '-':
|
||||||
|
parseComment(my)
|
||||||
|
else:
|
||||||
|
parseSpecial(my)
|
||||||
|
of '?':
|
||||||
|
parsePI(my)
|
||||||
|
else:
|
||||||
|
parseTag(my)
|
||||||
|
of ' ', '\t', '\c', '\l':
|
||||||
|
parseWhiteSpace(my)
|
||||||
|
my.kind = xmlWhitespace
|
||||||
|
of '\0':
|
||||||
|
my.kind = xmlEof
|
||||||
|
of '&':
|
||||||
|
parseEntity(my, my.a)
|
||||||
|
else:
|
||||||
|
parseCharData(my)
|
||||||
|
assert my.kind != xmlError
|
||||||
|
|
||||||
|
proc getTok(my: var TXmlParser) =
|
||||||
|
while true:
|
||||||
|
rawGetTok(my)
|
||||||
|
case my.kind
|
||||||
|
of xmlComment:
|
||||||
|
if my.options.contains(reportComments): break
|
||||||
|
of xmlWhitespace:
|
||||||
|
if my.options.contains(reportWhitespace): break
|
||||||
|
else: break
|
||||||
|
|
||||||
|
proc next*(my: var TXmlParser) =
|
||||||
|
## retrieves the first/next event. This controls the parser.
|
||||||
|
case my.state
|
||||||
|
of stateNormal:
|
||||||
|
getTok(my)
|
||||||
|
of stateStart:
|
||||||
|
getTok(my)
|
||||||
|
if my.kind == xmlPI and my.a == "xml":
|
||||||
|
# just skip the first ``<?xml >`` processing instruction
|
||||||
|
getTok(my)
|
||||||
|
my.state = stateNormal
|
||||||
|
of stateAttr:
|
||||||
|
# parse an attribute key-value pair:
|
||||||
|
if my.buf[my.bufpos] == '>':
|
||||||
|
my.kind = xmlElementClose
|
||||||
|
inc(my.bufpos)
|
||||||
|
my.state = stateNormal
|
||||||
|
elif my.buf[my.bufpos] == '/' and my.buf[my.bufpos+1] == '>':
|
||||||
|
my.kind = xmlElementClose
|
||||||
|
inc(my.bufpos, 2)
|
||||||
|
my.state = stateEmptyElementTag
|
||||||
|
else:
|
||||||
|
parseAttribute(my)
|
||||||
|
# state remains the same
|
||||||
|
of stateEmptyElementTag:
|
||||||
|
my.state = stateNormal
|
||||||
|
my.kind = xmlElementEnd
|
||||||
|
of stateError:
|
||||||
|
my.kind = xmlError
|
||||||
|
my.state = stateNormal
|
||||||
|
|
||||||
|
when isMainModule:
|
||||||
|
import os
|
||||||
|
var s = newFileStream(ParamStr(1), fmRead)
|
||||||
|
if s == nil: quit("cannot open the file" & ParamStr(1))
|
||||||
|
var x: TXmlParser
|
||||||
|
open(x, s, ParamStr(1))
|
||||||
|
while true:
|
||||||
|
next(x)
|
||||||
|
case x.kind
|
||||||
|
of xmlError: Echo(x.errorMsg())
|
||||||
|
of xmlEof: break
|
||||||
|
of xmlCharData: echo(x.charData)
|
||||||
|
of xmlWhitespace: echo("|$1|" % x.charData)
|
||||||
|
of xmlComment: echo("<!-- $1 -->" % x.charData)
|
||||||
|
of xmlPI: echo("<? $1 ## $2 ?>" % [x.PIName, x.PIRest])
|
||||||
|
of xmlElementStart: echo("<$1>" % x.elementName)
|
||||||
|
of xmlElementEnd: echo("</$1>" % x.elementName)
|
||||||
|
|
||||||
|
of xmlElementOpen: echo("<$1" % x.elementName)
|
||||||
|
of xmlAttribute:
|
||||||
|
echo("Key: " & x.attrKey)
|
||||||
|
echo("Value: " & x.attrValue)
|
||||||
|
|
||||||
|
of xmlElementClose: echo(">")
|
||||||
|
of xmlCData:
|
||||||
|
echo("<![CDATA[$1]]>" % x.charData)
|
||||||
|
of xmlEntity:
|
||||||
|
echo("&$1;" % x.entityName)
|
||||||
|
of xmlSpecial:
|
||||||
|
echo("SPECIAL: " & x.charData)
|
||||||
|
close(x)
|
||||||
|
|
||||||
824
lib/posix/detect.nim
Normal file
824
lib/posix/detect.nim
Normal file
|
|
@ -0,0 +1,824 @@
|
||||||
|
# Posix detect program
|
||||||
|
# (c) 2009 Andreas Rumpf
|
||||||
|
|
||||||
|
# This program produces a C program that produces a Nimrod include file.
|
||||||
|
# The Nimrod include file lists the values of each POSIX constant.
|
||||||
|
# This is needed because POSIX is brain-dead: It only cares for C, any other
|
||||||
|
# language is ignored. It would have been easier had they specified the
|
||||||
|
# concrete values of the constants. Sigh.
|
||||||
|
|
||||||
|
import os, strutils
|
||||||
|
|
||||||
|
const
|
||||||
|
cc = "gcc -o $1 $1.c"
|
||||||
|
|
||||||
|
cfile = """
|
||||||
|
/* Generated by detect.nim */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
$1
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
FILE* f;
|
||||||
|
f = fopen("$3_$4_consts.nim", "w+");
|
||||||
|
fputs("# Generated by detect.nim\nconst\n", f);
|
||||||
|
$2
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
TTypeKind = enum
|
||||||
|
cint, cshort, clong, cstring, pointer
|
||||||
|
|
||||||
|
var
|
||||||
|
hd = ""
|
||||||
|
tl = ""
|
||||||
|
|
||||||
|
proc myExec(cmd: string): bool =
|
||||||
|
return executeShellCommand(cmd) == 0
|
||||||
|
|
||||||
|
proc header(s: string): bool =
|
||||||
|
const testh = "testh"
|
||||||
|
var f: TFile
|
||||||
|
if openFile(f, appendFileExt(testh, "c"), fmWrite):
|
||||||
|
f.write("#include $1\n" % s)
|
||||||
|
f.write("int main() { return 0; }\n")
|
||||||
|
closeFile(f)
|
||||||
|
result = myExec(cc % testh)
|
||||||
|
removeFile(appendFileExt(testh, "c"))
|
||||||
|
if result:
|
||||||
|
addf(hd, "#include $1\n", s)
|
||||||
|
echo("Found: ", s)
|
||||||
|
else:
|
||||||
|
echo("Not found: ", s)
|
||||||
|
|
||||||
|
proc main =
|
||||||
|
const gen = "genconsts"
|
||||||
|
var f: TFile
|
||||||
|
if openFile(f, appendFileExt(gen, "c"), fmWrite):
|
||||||
|
f.write(cfile % [hd, tl, system.hostOS, system.hostCPU])
|
||||||
|
closeFile(f)
|
||||||
|
if not myExec(cc % gen): quit(1)
|
||||||
|
if not myExec("./" & gen): quit(1)
|
||||||
|
removeFile(appendFileExt(gen, "c"))
|
||||||
|
echo("Success")
|
||||||
|
|
||||||
|
proc v(name: string, typ: TTypeKind=cint) =
|
||||||
|
var n = if name[0] == '_': copy(name, 1) else: name
|
||||||
|
var t = $typ
|
||||||
|
case typ
|
||||||
|
of pointer:
|
||||||
|
addf(tl,
|
||||||
|
"#ifdef $3\n fprintf(f, \" $1* = cast[$2](%p)\\n\", $3);\n#endif\n",
|
||||||
|
n, t, name)
|
||||||
|
|
||||||
|
of cstring:
|
||||||
|
addf(tl,
|
||||||
|
"#ifdef $3\n fprintf(f, \" $1* = $2(\\\"%s\\\")\\n\", $3);\n#endif\n",
|
||||||
|
n, t, name)
|
||||||
|
of clong:
|
||||||
|
addf(tl,
|
||||||
|
"#ifdef $3\n fprintf(f, \" $1* = $2(%ld)\\n\", $3);\n#endif\n",
|
||||||
|
n, t, name)
|
||||||
|
else:
|
||||||
|
addf(tl,
|
||||||
|
"#ifdef $3\n fprintf(f, \" $1* = $2(%d)\\n\", $3);\n#endif\n",
|
||||||
|
n, t, name)
|
||||||
|
|
||||||
|
if header("<aio.h>"):
|
||||||
|
v("AIO_ALLDONE")
|
||||||
|
v("AIO_CANCELED")
|
||||||
|
v("AIO_NOTCANCELED")
|
||||||
|
v("LIO_NOP")
|
||||||
|
v("LIO_NOWAIT")
|
||||||
|
v("LIO_READ")
|
||||||
|
v("LIO_WAIT")
|
||||||
|
v("LIO_WRITE")
|
||||||
|
|
||||||
|
if header("<dlfcn.h>"):
|
||||||
|
v("RTLD_LAZY")
|
||||||
|
v("RTLD_NOW")
|
||||||
|
v("RTLD_GLOBAL")
|
||||||
|
v("RTLD_LOCAL")
|
||||||
|
|
||||||
|
if header("<errno.h>"):
|
||||||
|
v("E2BIG")
|
||||||
|
v("EACCES")
|
||||||
|
v("EADDRINUSE")
|
||||||
|
v("EADDRNOTAVAIL")
|
||||||
|
v("EAFNOSUPPORT")
|
||||||
|
v("EAGAIN")
|
||||||
|
v("EALREADY")
|
||||||
|
v("EBADF")
|
||||||
|
v("EBADMSG")
|
||||||
|
v("EBUSY")
|
||||||
|
v("ECANCELED")
|
||||||
|
v("ECHILD")
|
||||||
|
v("ECONNABORTED")
|
||||||
|
v("ECONNREFUSED")
|
||||||
|
v("ECONNRESET")
|
||||||
|
v("EDEADLK")
|
||||||
|
v("EDESTADDRREQ")
|
||||||
|
v("EDOM")
|
||||||
|
v("EDQUOT")
|
||||||
|
v("EEXIST")
|
||||||
|
v("EFAULT")
|
||||||
|
v("EFBIG")
|
||||||
|
v("EHOSTUNREACH")
|
||||||
|
v("EIDRM")
|
||||||
|
v("EILSEQ")
|
||||||
|
v("EINPROGRESS")
|
||||||
|
v("EINTR")
|
||||||
|
v("EINVAL")
|
||||||
|
v("EIO")
|
||||||
|
v("EISCONN")
|
||||||
|
v("EISDIR")
|
||||||
|
v("ELOOP")
|
||||||
|
v("EMFILE")
|
||||||
|
v("EMLINK")
|
||||||
|
v("EMSGSIZE")
|
||||||
|
v("EMULTIHOP")
|
||||||
|
v("ENAMETOOLONG")
|
||||||
|
v("ENETDOWN")
|
||||||
|
v("ENETRESET")
|
||||||
|
v("ENETUNREACH")
|
||||||
|
v("ENFILE")
|
||||||
|
v("ENOBUFS")
|
||||||
|
v("ENODATA")
|
||||||
|
v("ENODEV")
|
||||||
|
v("ENOENT")
|
||||||
|
v("ENOEXEC")
|
||||||
|
v("ENOLCK")
|
||||||
|
v("ENOLINK")
|
||||||
|
v("ENOMEM")
|
||||||
|
v("ENOMSG")
|
||||||
|
v("ENOPROTOOPT")
|
||||||
|
v("ENOSPC")
|
||||||
|
v("ENOSR")
|
||||||
|
v("ENOSTR")
|
||||||
|
v("ENOSYS")
|
||||||
|
v("ENOTCONN")
|
||||||
|
v("ENOTDIR")
|
||||||
|
v("ENOTEMPTY")
|
||||||
|
v("ENOTSOCK")
|
||||||
|
v("ENOTSUP")
|
||||||
|
v("ENOTTY")
|
||||||
|
v("ENXIO")
|
||||||
|
v("EOPNOTSUPP")
|
||||||
|
v("EOVERFLOW")
|
||||||
|
v("EPERM")
|
||||||
|
v("EPIPE")
|
||||||
|
v("EPROTO")
|
||||||
|
v("EPROTONOSUPPORT")
|
||||||
|
v("EPROTOTYPE")
|
||||||
|
v("ERANGE")
|
||||||
|
v("EROFS")
|
||||||
|
v("ESPIPE")
|
||||||
|
v("ESRCH")
|
||||||
|
v("ESTALE")
|
||||||
|
v("ETIME")
|
||||||
|
v("ETIMEDOUT")
|
||||||
|
v("ETXTBSY")
|
||||||
|
v("EWOULDBLOCK")
|
||||||
|
v("EXDEV")
|
||||||
|
|
||||||
|
if header("<fcntl.h>"):
|
||||||
|
v("F_DUPFD")
|
||||||
|
v("F_GETFD")
|
||||||
|
v("F_SETFD")
|
||||||
|
v("F_GETFL")
|
||||||
|
v("F_SETFL")
|
||||||
|
v("F_GETLK")
|
||||||
|
v("F_SETLK")
|
||||||
|
v("F_SETLKW")
|
||||||
|
v("F_GETOWN")
|
||||||
|
v("F_SETOWN")
|
||||||
|
v("FD_CLOEXEC")
|
||||||
|
v("F_RDLCK")
|
||||||
|
v("F_UNLCK")
|
||||||
|
v("F_WRLCK")
|
||||||
|
v("O_CREAT")
|
||||||
|
v("O_EXCL")
|
||||||
|
v("O_NOCTTY")
|
||||||
|
v("O_TRUNC")
|
||||||
|
v("O_APPEND")
|
||||||
|
v("O_DSYNC")
|
||||||
|
v("O_NONBLOCK")
|
||||||
|
v("O_RSYNC")
|
||||||
|
v("O_SYNC")
|
||||||
|
v("O_ACCMODE")
|
||||||
|
v("O_RDONLY")
|
||||||
|
v("O_RDWR")
|
||||||
|
v("O_WRONLY")
|
||||||
|
v("POSIX_FADV_NORMAL")
|
||||||
|
v("POSIX_FADV_SEQUENTIAL")
|
||||||
|
v("POSIX_FADV_RANDOM")
|
||||||
|
v("POSIX_FADV_WILLNEED")
|
||||||
|
v("POSIX_FADV_DONTNEED")
|
||||||
|
v("POSIX_FADV_NOREUSE")
|
||||||
|
|
||||||
|
if header("<fenv.h>"):
|
||||||
|
v("FE_DIVBYZERO")
|
||||||
|
v("FE_INEXACT")
|
||||||
|
v("FE_INVALID")
|
||||||
|
v("FE_OVERFLOW")
|
||||||
|
v("FE_UNDERFLOW")
|
||||||
|
v("FE_ALL_EXCEPT")
|
||||||
|
v("FE_DOWNWARD")
|
||||||
|
v("FE_TONEAREST")
|
||||||
|
v("FE_TOWARDZERO")
|
||||||
|
v("FE_UPWARD")
|
||||||
|
v("FE_DFL_ENV", pointer)
|
||||||
|
|
||||||
|
if header("<fmtmsg.h>"):
|
||||||
|
v("MM_HARD")
|
||||||
|
v("MM_SOFT")
|
||||||
|
v("MM_FIRM")
|
||||||
|
v("MM_APPL")
|
||||||
|
v("MM_UTIL")
|
||||||
|
v("MM_OPSYS")
|
||||||
|
v("MM_RECOVER")
|
||||||
|
v("MM_NRECOV")
|
||||||
|
v("MM_HALT")
|
||||||
|
v("MM_ERROR")
|
||||||
|
v("MM_WARNING")
|
||||||
|
v("MM_INFO")
|
||||||
|
v("MM_NOSEV")
|
||||||
|
v("MM_PRINT")
|
||||||
|
v("MM_CONSOLE")
|
||||||
|
v("MM_OK")
|
||||||
|
v("MM_NOTOK")
|
||||||
|
v("MM_NOMSG")
|
||||||
|
v("MM_NOCON")
|
||||||
|
|
||||||
|
if header("<fnmatch.h>"):
|
||||||
|
v("FNM_NOMATCH")
|
||||||
|
v("FNM_PATHNAME")
|
||||||
|
v("FNM_PERIOD")
|
||||||
|
v("FNM_NOESCAPE")
|
||||||
|
v("FNM_NOSYS")
|
||||||
|
|
||||||
|
if header("<ftw.h>"):
|
||||||
|
v("FTW_F")
|
||||||
|
v("FTW_D")
|
||||||
|
v("FTW_DNR")
|
||||||
|
v("FTW_DP")
|
||||||
|
v("FTW_NS")
|
||||||
|
v("FTW_SL")
|
||||||
|
v("FTW_SLN")
|
||||||
|
v("FTW_PHYS")
|
||||||
|
v("FTW_MOUNT")
|
||||||
|
v("FTW_DEPTH")
|
||||||
|
v("FTW_CHDIR")
|
||||||
|
|
||||||
|
if header("<glob.h>"):
|
||||||
|
v("GLOB_APPEND")
|
||||||
|
v("GLOB_DOOFFS")
|
||||||
|
v("GLOB_ERR")
|
||||||
|
v("GLOB_MARK")
|
||||||
|
v("GLOB_NOCHECK")
|
||||||
|
v("GLOB_NOESCAPE")
|
||||||
|
v("GLOB_NOSORT")
|
||||||
|
v("GLOB_ABORTED")
|
||||||
|
v("GLOB_NOMATCH")
|
||||||
|
v("GLOB_NOSPACE")
|
||||||
|
v("GLOB_NOSYS")
|
||||||
|
|
||||||
|
if header("<langinfo.h>"):
|
||||||
|
v("CODESET")
|
||||||
|
v("D_T_FMT")
|
||||||
|
v("D_FMT")
|
||||||
|
v("T_FMT")
|
||||||
|
v("T_FMT_AMPM")
|
||||||
|
v("AM_STR")
|
||||||
|
v("PM_STR")
|
||||||
|
v("DAY_1")
|
||||||
|
v("DAY_2")
|
||||||
|
v("DAY_3")
|
||||||
|
v("DAY_4")
|
||||||
|
v("DAY_5")
|
||||||
|
v("DAY_6")
|
||||||
|
v("DAY_7")
|
||||||
|
v("ABDAY_1")
|
||||||
|
v("ABDAY_2")
|
||||||
|
v("ABDAY_3")
|
||||||
|
v("ABDAY_4")
|
||||||
|
v("ABDAY_5")
|
||||||
|
v("ABDAY_6")
|
||||||
|
v("ABDAY_7")
|
||||||
|
v("MON_1")
|
||||||
|
v("MON_2")
|
||||||
|
v("MON_3")
|
||||||
|
v("MON_4")
|
||||||
|
v("MON_5")
|
||||||
|
v("MON_6")
|
||||||
|
v("MON_7")
|
||||||
|
v("MON_8")
|
||||||
|
v("MON_9")
|
||||||
|
v("MON_10")
|
||||||
|
v("MON_11")
|
||||||
|
v("MON_12")
|
||||||
|
v("ABMON_1")
|
||||||
|
v("ABMON_2")
|
||||||
|
v("ABMON_3")
|
||||||
|
v("ABMON_4")
|
||||||
|
v("ABMON_5")
|
||||||
|
v("ABMON_6")
|
||||||
|
v("ABMON_7")
|
||||||
|
v("ABMON_8")
|
||||||
|
v("ABMON_9")
|
||||||
|
v("ABMON_10")
|
||||||
|
v("ABMON_11")
|
||||||
|
v("ABMON_12")
|
||||||
|
v("ERA")
|
||||||
|
v("ERA_D_FMT")
|
||||||
|
v("ERA_D_T_FMT")
|
||||||
|
v("ERA_T_FMT")
|
||||||
|
v("ALT_DIGITS")
|
||||||
|
v("RADIXCHAR")
|
||||||
|
v("THOUSEP")
|
||||||
|
v("YESEXPR")
|
||||||
|
v("NOEXPR")
|
||||||
|
v("CRNCYSTR")
|
||||||
|
|
||||||
|
if header("<locale.h>"):
|
||||||
|
v("LC_ALL") #{.importc, header: .}: cint
|
||||||
|
v("LC_COLLATE") #{.importc, header: "<locale.h>".}: cint
|
||||||
|
v("LC_CTYPE") #{.importc, header: "<locale.h>".}: cint
|
||||||
|
v("LC_MESSAGES") #{.importc, header: "<locale.h>".}: cint
|
||||||
|
v("LC_MONETARY") #{.importc, header: "<locale.h>".}: cint
|
||||||
|
v("LC_NUMERIC") #{.importc, header: "<locale.h>".}: cint
|
||||||
|
v("LC_TIME") #{.importc, header: "<locale.h>".}: cint
|
||||||
|
|
||||||
|
if header("<pthread.h>"):
|
||||||
|
v("PTHREAD_BARRIER_SERIAL_THREAD")
|
||||||
|
v("PTHREAD_CANCEL_ASYNCHRONOUS")
|
||||||
|
v("PTHREAD_CANCEL_ENABLE")
|
||||||
|
v("PTHREAD_CANCEL_DEFERRED")
|
||||||
|
v("PTHREAD_CANCEL_DISABLE")
|
||||||
|
#v("PTHREAD_CANCELED")
|
||||||
|
#v("PTHREAD_COND_INITIALIZER")
|
||||||
|
v("PTHREAD_CREATE_DETACHED")
|
||||||
|
v("PTHREAD_CREATE_JOINABLE")
|
||||||
|
v("PTHREAD_EXPLICIT_SCHED")
|
||||||
|
v("PTHREAD_INHERIT_SCHED")
|
||||||
|
v("PTHREAD_MUTEX_DEFAULT")
|
||||||
|
v("PTHREAD_MUTEX_ERRORCHECK")
|
||||||
|
#v("PTHREAD_MUTEX_INITIALIZER")
|
||||||
|
v("PTHREAD_MUTEX_NORMAL")
|
||||||
|
v("PTHREAD_MUTEX_RECURSIVE") #{.importc, header: "<pthread.h>".}: cint
|
||||||
|
v("PTHREAD_ONCE_INIT") #{.importc, header: "<pthread.h>".}: cint
|
||||||
|
v("PTHREAD_PRIO_INHERIT") #{.importc, header: "<pthread.h>".}: cint
|
||||||
|
v("PTHREAD_PRIO_NONE") #{.importc, header: "<pthread.h>".}: cint
|
||||||
|
v("PTHREAD_PRIO_PROTECT") #{.importc, header: "<pthread.h>".}: cint
|
||||||
|
v("PTHREAD_PROCESS_SHARED") #{.importc, header: "<pthread.h>".}: cint
|
||||||
|
v("PTHREAD_PROCESS_PRIVATE") #{.importc, header: "<pthread.h>".}: cint
|
||||||
|
v("PTHREAD_SCOPE_PROCESS") #{.importc, header: "<pthread.h>".}: cint
|
||||||
|
v("PTHREAD_SCOPE_SYSTEM") #{.importc, header: "<pthread.h>".}: cint
|
||||||
|
|
||||||
|
if header("<unistd.h>"):
|
||||||
|
v("_POSIX_ASYNC_IO")
|
||||||
|
v("_POSIX_PRIO_IO")
|
||||||
|
v("_POSIX_SYNC_IO")
|
||||||
|
v("F_OK")
|
||||||
|
v("R_OK")
|
||||||
|
v("W_OK")
|
||||||
|
v("X_OK")
|
||||||
|
|
||||||
|
v("_CS_PATH")
|
||||||
|
v("_CS_POSIX_V6_ILP32_OFF32_CFLAGS")
|
||||||
|
v("_CS_POSIX_V6_ILP32_OFF32_LDFLAGS")
|
||||||
|
v("_CS_POSIX_V6_ILP32_OFF32_LIBS")
|
||||||
|
v("_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS")
|
||||||
|
v("_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS")
|
||||||
|
v("_CS_POSIX_V6_ILP32_OFFBIG_LIBS")
|
||||||
|
v("_CS_POSIX_V6_LP64_OFF64_CFLAGS")
|
||||||
|
v("_CS_POSIX_V6_LP64_OFF64_LDFLAGS")
|
||||||
|
v("_CS_POSIX_V6_LP64_OFF64_LIBS")
|
||||||
|
v("_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS")
|
||||||
|
v("_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS")
|
||||||
|
v("_CS_POSIX_V6_LPBIG_OFFBIG_LIBS")
|
||||||
|
v("_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS")
|
||||||
|
|
||||||
|
v("F_LOCK")
|
||||||
|
v("F_TEST") #{.importc: "F_TEST", header: "<unistd.h>".}: cint
|
||||||
|
v("F_TLOCK") #{.importc: "F_TLOCK", header: "<unistd.h>".}: cint
|
||||||
|
v("F_ULOCK") #{.importc: "F_ULOCK", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_2_SYMLINKS") #{.importc: "_PC_2_SYMLINKS", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_ALLOC_SIZE_MIN")
|
||||||
|
v("_PC_ASYNC_IO") #{.importc: "_PC_ASYNC_IO", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_CHOWN_RESTRICTED")
|
||||||
|
v("_PC_FILESIZEBITS") #{.importc: "_PC_FILESIZEBITS", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_LINK_MAX") #{.importc: "_PC_LINK_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_MAX_CANON") #{.importc: "_PC_MAX_CANON", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_MAX_INPUT") #{.importc: "_PC_MAX_INPUT", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_NAME_MAX") #{.importc: "_PC_NAME_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_NO_TRUNC") #{.importc: "_PC_NO_TRUNC", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_PATH_MAX") #{.importc: "_PC_PATH_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_PIPE_BUF") #{.importc: "_PC_PIPE_BUF", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_PRIO_IO") #{.importc: "_PC_PRIO_IO", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_REC_INCR_XFER_SIZE")
|
||||||
|
v("_PC_REC_MIN_XFER_SIZE")
|
||||||
|
v("_PC_REC_XFER_ALIGN")
|
||||||
|
v("_PC_SYMLINK_MAX") #{.importc: "_PC_SYMLINK_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_SYNC_IO") #{.importc: "_PC_SYNC_IO", header: "<unistd.h>".}: cint
|
||||||
|
v("_PC_VDISABLE") #{.importc: "_PC_VDISABLE", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_C_BIND") #{.importc: "_SC_2_C_BIND", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_C_DEV") #{.importc: "_SC_2_C_DEV", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_CHAR_TERM") #{.importc: "_SC_2_CHAR_TERM", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_FORT_DEV") #{.importc: "_SC_2_FORT_DEV", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_FORT_RUN") #{.importc: "_SC_2_FORT_RUN", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_LOCALEDEF") #{.importc: "_SC_2_LOCALEDEF", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_PBS") #{.importc: "_SC_2_PBS", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_PBS_ACCOUNTING")
|
||||||
|
v("_SC_2_PBS_CHECKPOINT")
|
||||||
|
v("_SC_2_PBS_LOCATE") #{.importc: "_SC_2_PBS_LOCATE", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_PBS_MESSAGE") #{.importc: "_SC_2_PBS_MESSAGE", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_PBS_TRACK") #{.importc: "_SC_2_PBS_TRACK", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_SW_DEV") #{.importc: "_SC_2_SW_DEV", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_UPE") #{.importc: "_SC_2_UPE", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_2_VERSION") #{.importc: "_SC_2_VERSION", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_ADVISORY_INFO") #{.importc: "_SC_ADVISORY_INFO", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_AIO_LISTIO_MAX")
|
||||||
|
v("_SC_AIO_MAX") #{.importc: "_SC_AIO_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_AIO_PRIO_DELTA_MAX")
|
||||||
|
v("_SC_ARG_MAX") #{.importc: "_SC_ARG_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_ASYNCHRONOUS_IO")
|
||||||
|
v("_SC_ATEXIT_MAX") #{.importc: "_SC_ATEXIT_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_BARRIERS") #{.importc: "_SC_BARRIERS", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_BC_BASE_MAX") #{.importc: "_SC_BC_BASE_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_BC_DIM_MAX") #{.importc: "_SC_BC_DIM_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_BC_SCALE_MAX") #{.importc: "_SC_BC_SCALE_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_BC_STRING_MAX") #{.importc: "_SC_BC_STRING_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_CHILD_MAX") #{.importc: "_SC_CHILD_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_CLK_TCK") #{.importc: "_SC_CLK_TCK", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_CLOCK_SELECTION")
|
||||||
|
v("_SC_COLL_WEIGHTS_MAX")
|
||||||
|
v("_SC_CPUTIME") #{.importc: "_SC_CPUTIME", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_DELAYTIMER_MAX")
|
||||||
|
v("_SC_EXPR_NEST_MAX") #{.importc: "_SC_EXPR_NEST_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_FSYNC") #{.importc: "_SC_FSYNC", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_GETGR_R_SIZE_MAX")
|
||||||
|
v("_SC_GETPW_R_SIZE_MAX")
|
||||||
|
v("_SC_HOST_NAME_MAX") #{.importc: "_SC_HOST_NAME_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_IOV_MAX") #{.importc: "_SC_IOV_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_IPV6") #{.importc: "_SC_IPV6", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_JOB_CONTROL") #{.importc: "_SC_JOB_CONTROL", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_LINE_MAX") #{.importc: "_SC_LINE_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_LOGIN_NAME_MAX")
|
||||||
|
v("_SC_MAPPED_FILES") #{.importc: "_SC_MAPPED_FILES", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_MEMLOCK") #{.importc: "_SC_MEMLOCK", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_MEMLOCK_RANGE") #{.importc: "_SC_MEMLOCK_RANGE", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_MEMORY_PROTECTION")
|
||||||
|
v("_SC_MESSAGE_PASSING")
|
||||||
|
v("_SC_MONOTONIC_CLOCK")
|
||||||
|
v("_SC_MQ_OPEN_MAX") #{.importc: "_SC_MQ_OPEN_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_MQ_PRIO_MAX") #{.importc: "_SC_MQ_PRIO_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_NGROUPS_MAX") #{.importc: "_SC_NGROUPS_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_OPEN_MAX") #{.importc: "_SC_OPEN_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_PAGE_SIZE") #{.importc: "_SC_PAGE_SIZE", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_PRIORITIZED_IO")
|
||||||
|
v("_SC_PRIORITY_SCHEDULING")
|
||||||
|
v("_SC_RAW_SOCKETS") #{.importc: "_SC_RAW_SOCKETS", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_RE_DUP_MAX") #{.importc: "_SC_RE_DUP_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_READER_WRITER_LOCKS")
|
||||||
|
v("_SC_REALTIME_SIGNALS")
|
||||||
|
v("_SC_REGEXP") #{.importc: "_SC_REGEXP", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_RTSIG_MAX") #{.importc: "_SC_RTSIG_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_SAVED_IDS") #{.importc: "_SC_SAVED_IDS", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_SEM_NSEMS_MAX") #{.importc: "_SC_SEM_NSEMS_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_SEM_VALUE_MAX") #{.importc: "_SC_SEM_VALUE_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_SEMAPHORES") #{.importc: "_SC_SEMAPHORES", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_SHARED_MEMORY_OBJECTS")
|
||||||
|
v("_SC_SHELL") #{.importc: "_SC_SHELL", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_SIGQUEUE_MAX") #{.importc: "_SC_SIGQUEUE_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_SPAWN") #{.importc: "_SC_SPAWN", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_SPIN_LOCKS") #{.importc: "_SC_SPIN_LOCKS", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_SPORADIC_SERVER")
|
||||||
|
v("_SC_SS_REPL_MAX") #{.importc: "_SC_SS_REPL_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_STREAM_MAX") #{.importc: "_SC_STREAM_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_SYMLOOP_MAX") #{.importc: "_SC_SYMLOOP_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_SYNCHRONIZED_IO")
|
||||||
|
v("_SC_THREAD_ATTR_STACKADDR")
|
||||||
|
v("_SC_THREAD_ATTR_STACKSIZE")
|
||||||
|
v("_SC_THREAD_CPUTIME")
|
||||||
|
v("_SC_THREAD_DESTRUCTOR_ITERATIONS")
|
||||||
|
v("_SC_THREAD_KEYS_MAX")
|
||||||
|
v("_SC_THREAD_PRIO_INHERIT")
|
||||||
|
v("_SC_THREAD_PRIO_PROTECT")
|
||||||
|
v("_SC_THREAD_PRIORITY_SCHEDULING")
|
||||||
|
v("_SC_THREAD_PROCESS_SHARED")
|
||||||
|
v("_SC_THREAD_SAFE_FUNCTIONS")
|
||||||
|
v("_SC_THREAD_SPORADIC_SERVER")
|
||||||
|
v("_SC_THREAD_STACK_MIN")
|
||||||
|
v("_SC_THREAD_THREADS_MAX")
|
||||||
|
v("_SC_THREADS") #{.importc: "_SC_THREADS", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_TIMEOUTS") #{.importc: "_SC_TIMEOUTS", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_TIMER_MAX") #{.importc: "_SC_TIMER_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_TIMERS") #{.importc: "_SC_TIMERS", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_TRACE") #{.importc: "_SC_TRACE", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_TRACE_EVENT_FILTER")
|
||||||
|
v("_SC_TRACE_EVENT_NAME_MAX")
|
||||||
|
v("_SC_TRACE_INHERIT") #{.importc: "_SC_TRACE_INHERIT", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_TRACE_LOG") #{.importc: "_SC_TRACE_LOG", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_TRACE_NAME_MAX")
|
||||||
|
v("_SC_TRACE_SYS_MAX") #{.importc: "_SC_TRACE_SYS_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_TRACE_USER_EVENT_MAX")
|
||||||
|
v("_SC_TTY_NAME_MAX") #{.importc: "_SC_TTY_NAME_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_TYPED_MEMORY_OBJECTS")
|
||||||
|
v("_SC_TZNAME_MAX") #{.importc: "_SC_TZNAME_MAX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_V6_ILP32_OFF32")
|
||||||
|
v("_SC_V6_ILP32_OFFBIG")
|
||||||
|
v("_SC_V6_LP64_OFF64") #{.importc: "_SC_V6_LP64_OFF64", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_V6_LPBIG_OFFBIG")
|
||||||
|
v("_SC_VERSION") #{.importc: "_SC_VERSION", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_XBS5_ILP32_OFF32")
|
||||||
|
v("_SC_XBS5_ILP32_OFFBIG")
|
||||||
|
v("_SC_XBS5_LP64_OFF64")
|
||||||
|
v("_SC_XBS5_LPBIG_OFFBIG")
|
||||||
|
v("_SC_XOPEN_CRYPT") #{.importc: "_SC_XOPEN_CRYPT", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_XOPEN_ENH_I18N")
|
||||||
|
v("_SC_XOPEN_LEGACY") #{.importc: "_SC_XOPEN_LEGACY", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_XOPEN_REALTIME")
|
||||||
|
v("_SC_XOPEN_REALTIME_THREADS")
|
||||||
|
v("_SC_XOPEN_SHM") #{.importc: "_SC_XOPEN_SHM", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_XOPEN_STREAMS") #{.importc: "_SC_XOPEN_STREAMS", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_XOPEN_UNIX") #{.importc: "_SC_XOPEN_UNIX", header: "<unistd.h>".}: cint
|
||||||
|
v("_SC_XOPEN_VERSION") #{.importc: "_SC_XOPEN_VERSION", header: "<unistd.h>".}: cint
|
||||||
|
|
||||||
|
v("SEEK_SET") #{.importc, header: "<unistd.h>".}: cint
|
||||||
|
v("SEEK_CUR") #{.importc, header: "<unistd.h>".}: cint
|
||||||
|
v("SEEK_END") #{.importc, header: "<unistd.h>".}: cint
|
||||||
|
|
||||||
|
|
||||||
|
if header("<semaphore.h>"):
|
||||||
|
v("SEM_FAILED", pointer)
|
||||||
|
|
||||||
|
if header("<sys/ipc.h>"):
|
||||||
|
v("IPC_CREAT") #{.importc, header: .}: cint
|
||||||
|
v("IPC_EXCL") #{.importc, header: "<sys/ipc.h>".}: cint
|
||||||
|
v("IPC_NOWAIT") #{.importc, header: "<sys/ipc.h>".}: cint
|
||||||
|
v("IPC_PRIVATE") #{.importc, header: "<sys/ipc.h>".}: cint
|
||||||
|
v("IPC_RMID") #{.importc, header: "<sys/ipc.h>".}: cint
|
||||||
|
v("IPC_SET") #{.importc, header: "<sys/ipc.h>".}: cint
|
||||||
|
v("IPC_STAT") #{.importc, header: "<sys/ipc.h>".}: cint
|
||||||
|
|
||||||
|
if header("<sys/stat.h>"):
|
||||||
|
v("S_IFMT") #{.importc, header: .}: cint
|
||||||
|
v("S_IFBLK") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IFCHR") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IFIFO") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IFREG") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IFDIR") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IFLNK") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IFSOCK") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IRWXU") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IRUSR") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IWUSR") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IXUSR") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IRWXG") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IRGRP") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IWGRP") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IXGRP") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IRWXO") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IROTH") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IWOTH") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_IXOTH") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_ISUID") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_ISGID") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
v("S_ISVTX") #{.importc, header: "<sys/stat.h>".}: cint
|
||||||
|
|
||||||
|
if header("<sys/statvfs.h>"):
|
||||||
|
v("ST_RDONLY") #{.importc, header: .}: cint
|
||||||
|
v("ST_NOSUID") #{.importc, header: "<sys/statvfs.h>".}: cint
|
||||||
|
|
||||||
|
if header("<sys/mman.h>"):
|
||||||
|
v("PROT_READ") #{.importc, header: .}: cint
|
||||||
|
v("PROT_WRITE") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("PROT_EXEC") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("PROT_NONE") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("MAP_SHARED") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("MAP_PRIVATE") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("MAP_FIXED") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("MS_ASYNC") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("MS_SYNC") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("MS_INVALIDATE") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("MCL_CURRENT") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("MCL_FUTURE") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
|
||||||
|
v("MAP_FAILED", pointer)
|
||||||
|
v("POSIX_MADV_NORMAL") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("POSIX_MADV_SEQUENTIAL") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("POSIX_MADV_RANDOM") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("POSIX_MADV_WILLNEED") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("POSIX_MADV_DONTNEED") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("POSIX_TYPED_MEM_ALLOCATE") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("POSIX_TYPED_MEM_ALLOCATE_CONTIG") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
v("POSIX_TYPED_MEM_MAP_ALLOCATABLE") #{.importc, header: "<sys/mman.h>".}: cint
|
||||||
|
|
||||||
|
if header("<time.h>"):
|
||||||
|
v("CLOCKS_PER_SEC", clong)
|
||||||
|
v("CLOCK_PROCESS_CPUTIME_ID")
|
||||||
|
v("CLOCK_THREAD_CPUTIME_ID")
|
||||||
|
v("CLOCK_REALTIME")
|
||||||
|
v("TIMER_ABSTIME")
|
||||||
|
v("CLOCK_MONOTONIC")
|
||||||
|
|
||||||
|
if header("<sys/wait.h>"):
|
||||||
|
v("WNOHANG") #{.importc, header: .}: cint
|
||||||
|
v("WUNTRACED") #{.importc, header: "<sys/wait.h>".}: cint
|
||||||
|
#v("WEXITSTATUS")
|
||||||
|
#v("WIFCONTINUED")
|
||||||
|
#v("WIFEXITED")
|
||||||
|
#v("WIFSIGNALED")
|
||||||
|
#v("WIFSTOPPED")
|
||||||
|
#v("WSTOPSIG")
|
||||||
|
#v("WTERMSIG")
|
||||||
|
v("WEXITED") #{.importc, header: "<sys/wait.h>".}: cint
|
||||||
|
v("WSTOPPED") #{.importc, header: "<sys/wait.h>".}: cint
|
||||||
|
v("WCONTINUED") #{.importc, header: "<sys/wait.h>".}: cint
|
||||||
|
v("WNOWAIT") #{.importc, header: "<sys/wait.h>".}: cint
|
||||||
|
v("P_ALL") #{.importc, header: "<sys/wait.h>".}: cint
|
||||||
|
v("P_PID") #{.importc, header: "<sys/wait.h>".}: cint
|
||||||
|
v("P_PGID") #{.importc, header: "<sys/wait.h>".}: cint
|
||||||
|
|
||||||
|
if header("<signal.h>"):
|
||||||
|
v("SIGEV_NONE") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGEV_SIGNAL") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGEV_THREAD") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGABRT") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGALRM") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGBUS") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGCHLD") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGCONT") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGFPE") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGHUP") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGILL") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGINT") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGKILL") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGPIPE") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGQUIT") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGSEGV") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGSTOP") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGTERM") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGTSTP") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGTTIN") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGTTOU") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGUSR1") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGUSR2") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGPOLL") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGPROF") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGSYS") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGTRAP") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGURG") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGVTALRM") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGXCPU") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGXFSZ") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SA_NOCLDSTOP") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIG_BLOCK") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIG_UNBLOCK") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIG_SETMASK") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SA_ONSTACK") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SA_RESETHAND") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SA_RESTART") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SA_SIGINFO") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SA_NOCLDWAIT") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SA_NODEFER") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SS_ONSTACK") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SS_DISABLE") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("MINSIGSTKSZ") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
v("SIGSTKSZ") #{.importc, header: "<signal.h>".}: cint
|
||||||
|
|
||||||
|
if header("<nl_types.h>"):
|
||||||
|
v("NL_SETD") #{.importc, header: .}: cint
|
||||||
|
v("NL_CAT_LOCALE") #{.importc, header: "<nl_types.h>".}: cint
|
||||||
|
|
||||||
|
if header("<sched.h>"):
|
||||||
|
v("SCHED_FIFO")
|
||||||
|
v("SCHED_RR")
|
||||||
|
v("SCHED_SPORADIC")
|
||||||
|
v("SCHED_OTHER")
|
||||||
|
|
||||||
|
if header("<sys/select.h>"):
|
||||||
|
v("FD_SETSIZE")
|
||||||
|
|
||||||
|
if header("<net/if.h>"):
|
||||||
|
v("IF_NAMESIZE")
|
||||||
|
|
||||||
|
if header("<sys/socket.h>"):
|
||||||
|
v("SCM_RIGHTS") #{.importc, header: .}: cint
|
||||||
|
v("SOCK_DGRAM") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SOCK_RAW") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SOCK_SEQPACKET") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SOCK_STREAM") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SOL_SOCKET") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_ACCEPTCONN") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_BROADCAST") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_DEBUG") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_DONTROUTE") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_ERROR") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_KEEPALIVE") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_LINGER") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_OOBINLINE") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_RCVBUF") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_RCVLOWAT") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_RCVTIMEO") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_REUSEADDR") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_SNDBUF") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_SNDLOWAT") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_SNDTIMEO") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SO_TYPE") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SOMAXCONN") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("MSG_CTRUNC") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("MSG_DONTROUTE") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("MSG_EOR") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("MSG_OOB") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("MSG_PEEK") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("MSG_TRUNC") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("MSG_WAITALL") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("AF_INET") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("AF_INET6") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("AF_UNIX") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("AF_UNSPEC") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SHUT_RD") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SHUT_RDWR") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
v("SHUT_WR") #{.importc, header: "<sys/socket.h>".}: cint
|
||||||
|
|
||||||
|
if header("<netinet/in.h>"):
|
||||||
|
v("IPPROTO_IP") #{.importc, header: .}: cint
|
||||||
|
v("IPPROTO_IPV6") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
v("IPPROTO_ICMP") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
v("IPPROTO_RAW") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
v("IPPROTO_TCP") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
v("IPPROTO_UDP") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
v("INADDR_ANY") #{.importc, header: "<netinet/in.h>".}: TinAddrScalar
|
||||||
|
v("INADDR_BROADCAST") #{.importc, header: "<netinet/in.h>".}: TinAddrScalar
|
||||||
|
v("INET_ADDRSTRLEN") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
|
||||||
|
v("IPV6_JOIN_GROUP") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
v("IPV6_LEAVE_GROUP") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
v("IPV6_MULTICAST_HOPS") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
v("IPV6_MULTICAST_IF") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
v("IPV6_MULTICAST_LOOP") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
v("IPV6_UNICAST_HOPS") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
v("IPV6_V6ONLY") #{.importc, header: "<netinet/in.h>".}: cint
|
||||||
|
|
||||||
|
v("TCP_NODELAY") #{.importc, header: "<netinet/tcp.h>".}: cint
|
||||||
|
|
||||||
|
if header("<netdb.h>"):
|
||||||
|
v("IPPORT_RESERVED")
|
||||||
|
|
||||||
|
v("HOST_NOT_FOUND")
|
||||||
|
v("NO_DATA")
|
||||||
|
v("NO_RECOVERY")
|
||||||
|
v("TRY_AGAIN")
|
||||||
|
|
||||||
|
v("AI_PASSIVE")
|
||||||
|
v("AI_CANONNAME")
|
||||||
|
v("AI_NUMERICHOST")
|
||||||
|
v("AI_NUMERICSERV")
|
||||||
|
v("AI_V4MAPPED")
|
||||||
|
v("AI_ALL")
|
||||||
|
v("AI_ADDRCONFIG")
|
||||||
|
|
||||||
|
v("NI_NOFQDN")
|
||||||
|
v("NI_NUMERICHOST")
|
||||||
|
v("NI_NAMEREQD")
|
||||||
|
v("NI_NUMERICSERV")
|
||||||
|
v("NI_NUMERICSCOPE")
|
||||||
|
v("NI_DGRAM")
|
||||||
|
v("EAI_AGAIN")
|
||||||
|
v("EAI_BADFLAGS")
|
||||||
|
v("EAI_FAIL")
|
||||||
|
v("EAI_FAMILY")
|
||||||
|
v("EAI_MEMORY")
|
||||||
|
v("EAI_NONAME")
|
||||||
|
v("EAI_SERVICE")
|
||||||
|
v("EAI_SOCKTYPE")
|
||||||
|
v("EAI_SYSTEM")
|
||||||
|
v("EAI_OVERFLOW")
|
||||||
|
|
||||||
|
if header("<poll.h>"):
|
||||||
|
v("POLLIN", cshort)
|
||||||
|
v("POLLRDNORM", cshort)
|
||||||
|
v("POLLRDBAND", cshort)
|
||||||
|
v("POLLPRI", cshort)
|
||||||
|
v("POLLOUT", cshort)
|
||||||
|
v("POLLWRNORM", cshort)
|
||||||
|
v("POLLWRBAND", cshort)
|
||||||
|
v("POLLERR", cshort)
|
||||||
|
v("POLLHUP", cshort)
|
||||||
|
v("POLLNVAL", cshort)
|
||||||
|
|
||||||
|
if header("<spawn.h>"):
|
||||||
|
v("POSIX_SPAWN_RESETIDS")
|
||||||
|
v("POSIX_SPAWN_SETPGROUP")
|
||||||
|
v("POSIX_SPAWN_SETSCHEDPARAM")
|
||||||
|
v("POSIX_SPAWN_SETSCHEDULER")
|
||||||
|
v("POSIX_SPAWN_SETSIGDEF")
|
||||||
|
v("POSIX_SPAWN_SETSIGMASK")
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
620
lib/posix/linux_amd64_consts.nim
Normal file
620
lib/posix/linux_amd64_consts.nim
Normal file
|
|
@ -0,0 +1,620 @@
|
||||||
|
# Generated by detect.nim
|
||||||
|
const
|
||||||
|
AIO_ALLDONE* = cint(2)
|
||||||
|
AIO_CANCELED* = cint(0)
|
||||||
|
AIO_NOTCANCELED* = cint(1)
|
||||||
|
LIO_NOP* = cint(2)
|
||||||
|
LIO_NOWAIT* = cint(1)
|
||||||
|
LIO_READ* = cint(0)
|
||||||
|
LIO_WAIT* = cint(0)
|
||||||
|
LIO_WRITE* = cint(1)
|
||||||
|
RTLD_LAZY* = cint(1)
|
||||||
|
RTLD_NOW* = cint(2)
|
||||||
|
RTLD_GLOBAL* = cint(256)
|
||||||
|
RTLD_LOCAL* = cint(0)
|
||||||
|
E2BIG* = cint(7)
|
||||||
|
EACCES* = cint(13)
|
||||||
|
EADDRINUSE* = cint(98)
|
||||||
|
EADDRNOTAVAIL* = cint(99)
|
||||||
|
EAFNOSUPPORT* = cint(97)
|
||||||
|
EAGAIN* = cint(11)
|
||||||
|
EALREADY* = cint(114)
|
||||||
|
EBADF* = cint(9)
|
||||||
|
EBADMSG* = cint(74)
|
||||||
|
EBUSY* = cint(16)
|
||||||
|
ECANCELED* = cint(125)
|
||||||
|
ECHILD* = cint(10)
|
||||||
|
ECONNABORTED* = cint(103)
|
||||||
|
ECONNREFUSED* = cint(111)
|
||||||
|
ECONNRESET* = cint(104)
|
||||||
|
EDEADLK* = cint(35)
|
||||||
|
EDESTADDRREQ* = cint(89)
|
||||||
|
EDOM* = cint(33)
|
||||||
|
EDQUOT* = cint(122)
|
||||||
|
EEXIST* = cint(17)
|
||||||
|
EFAULT* = cint(14)
|
||||||
|
EFBIG* = cint(27)
|
||||||
|
EHOSTUNREACH* = cint(113)
|
||||||
|
EIDRM* = cint(43)
|
||||||
|
EILSEQ* = cint(84)
|
||||||
|
EINPROGRESS* = cint(115)
|
||||||
|
EINTR* = cint(4)
|
||||||
|
EINVAL* = cint(22)
|
||||||
|
EIO* = cint(5)
|
||||||
|
EISCONN* = cint(106)
|
||||||
|
EISDIR* = cint(21)
|
||||||
|
ELOOP* = cint(40)
|
||||||
|
EMFILE* = cint(24)
|
||||||
|
EMLINK* = cint(31)
|
||||||
|
EMSGSIZE* = cint(90)
|
||||||
|
EMULTIHOP* = cint(72)
|
||||||
|
ENAMETOOLONG* = cint(36)
|
||||||
|
ENETDOWN* = cint(100)
|
||||||
|
ENETRESET* = cint(102)
|
||||||
|
ENETUNREACH* = cint(101)
|
||||||
|
ENFILE* = cint(23)
|
||||||
|
ENOBUFS* = cint(105)
|
||||||
|
ENODATA* = cint(61)
|
||||||
|
ENODEV* = cint(19)
|
||||||
|
ENOENT* = cint(2)
|
||||||
|
ENOEXEC* = cint(8)
|
||||||
|
ENOLCK* = cint(37)
|
||||||
|
ENOLINK* = cint(67)
|
||||||
|
ENOMEM* = cint(12)
|
||||||
|
ENOMSG* = cint(42)
|
||||||
|
ENOPROTOOPT* = cint(92)
|
||||||
|
ENOSPC* = cint(28)
|
||||||
|
ENOSR* = cint(63)
|
||||||
|
ENOSTR* = cint(60)
|
||||||
|
ENOSYS* = cint(38)
|
||||||
|
ENOTCONN* = cint(107)
|
||||||
|
ENOTDIR* = cint(20)
|
||||||
|
ENOTEMPTY* = cint(39)
|
||||||
|
ENOTSOCK* = cint(88)
|
||||||
|
ENOTSUP* = cint(95)
|
||||||
|
ENOTTY* = cint(25)
|
||||||
|
ENXIO* = cint(6)
|
||||||
|
EOPNOTSUPP* = cint(95)
|
||||||
|
EOVERFLOW* = cint(75)
|
||||||
|
EPERM* = cint(1)
|
||||||
|
EPIPE* = cint(32)
|
||||||
|
EPROTO* = cint(71)
|
||||||
|
EPROTONOSUPPORT* = cint(93)
|
||||||
|
EPROTOTYPE* = cint(91)
|
||||||
|
ERANGE* = cint(34)
|
||||||
|
EROFS* = cint(30)
|
||||||
|
ESPIPE* = cint(29)
|
||||||
|
ESRCH* = cint(3)
|
||||||
|
ESTALE* = cint(116)
|
||||||
|
ETIME* = cint(62)
|
||||||
|
ETIMEDOUT* = cint(110)
|
||||||
|
ETXTBSY* = cint(26)
|
||||||
|
EWOULDBLOCK* = cint(11)
|
||||||
|
EXDEV* = cint(18)
|
||||||
|
F_DUPFD* = cint(0)
|
||||||
|
F_GETFD* = cint(1)
|
||||||
|
F_SETFD* = cint(2)
|
||||||
|
F_GETFL* = cint(3)
|
||||||
|
F_SETFL* = cint(4)
|
||||||
|
F_GETLK* = cint(5)
|
||||||
|
F_SETLK* = cint(6)
|
||||||
|
F_SETLKW* = cint(7)
|
||||||
|
F_GETOWN* = cint(9)
|
||||||
|
F_SETOWN* = cint(8)
|
||||||
|
FD_CLOEXEC* = cint(1)
|
||||||
|
F_RDLCK* = cint(0)
|
||||||
|
F_UNLCK* = cint(2)
|
||||||
|
F_WRLCK* = cint(1)
|
||||||
|
O_CREAT* = cint(64)
|
||||||
|
O_EXCL* = cint(128)
|
||||||
|
O_NOCTTY* = cint(256)
|
||||||
|
O_TRUNC* = cint(512)
|
||||||
|
O_APPEND* = cint(1024)
|
||||||
|
O_DSYNC* = cint(4096)
|
||||||
|
O_NONBLOCK* = cint(2048)
|
||||||
|
O_RSYNC* = cint(4096)
|
||||||
|
O_SYNC* = cint(4096)
|
||||||
|
O_ACCMODE* = cint(3)
|
||||||
|
O_RDONLY* = cint(0)
|
||||||
|
O_RDWR* = cint(2)
|
||||||
|
O_WRONLY* = cint(1)
|
||||||
|
POSIX_FADV_NORMAL* = cint(0)
|
||||||
|
POSIX_FADV_SEQUENTIAL* = cint(2)
|
||||||
|
POSIX_FADV_RANDOM* = cint(1)
|
||||||
|
POSIX_FADV_WILLNEED* = cint(3)
|
||||||
|
POSIX_FADV_DONTNEED* = cint(4)
|
||||||
|
POSIX_FADV_NOREUSE* = cint(5)
|
||||||
|
FE_DIVBYZERO* = cint(4)
|
||||||
|
FE_INEXACT* = cint(32)
|
||||||
|
FE_INVALID* = cint(1)
|
||||||
|
FE_OVERFLOW* = cint(8)
|
||||||
|
FE_UNDERFLOW* = cint(16)
|
||||||
|
FE_ALL_EXCEPT* = cint(61)
|
||||||
|
FE_DOWNWARD* = cint(1024)
|
||||||
|
FE_TONEAREST* = cint(0)
|
||||||
|
FE_TOWARDZERO* = cint(3072)
|
||||||
|
FE_UPWARD* = cint(2048)
|
||||||
|
FE_DFL_ENV* = cast[pointer](0xffffffffffffffff)
|
||||||
|
MM_HARD* = cint(1)
|
||||||
|
MM_SOFT* = cint(2)
|
||||||
|
MM_FIRM* = cint(4)
|
||||||
|
MM_APPL* = cint(8)
|
||||||
|
MM_UTIL* = cint(16)
|
||||||
|
MM_OPSYS* = cint(32)
|
||||||
|
MM_RECOVER* = cint(64)
|
||||||
|
MM_NRECOV* = cint(128)
|
||||||
|
MM_HALT* = cint(1)
|
||||||
|
MM_ERROR* = cint(2)
|
||||||
|
MM_WARNING* = cint(3)
|
||||||
|
MM_INFO* = cint(4)
|
||||||
|
MM_NOSEV* = cint(0)
|
||||||
|
MM_PRINT* = cint(256)
|
||||||
|
MM_CONSOLE* = cint(512)
|
||||||
|
MM_OK* = cint(0)
|
||||||
|
MM_NOTOK* = cint(-1)
|
||||||
|
MM_NOMSG* = cint(1)
|
||||||
|
MM_NOCON* = cint(4)
|
||||||
|
FNM_NOMATCH* = cint(1)
|
||||||
|
FNM_PATHNAME* = cint(1)
|
||||||
|
FNM_PERIOD* = cint(4)
|
||||||
|
FNM_NOESCAPE* = cint(2)
|
||||||
|
FTW_F* = cint(0)
|
||||||
|
FTW_D* = cint(1)
|
||||||
|
FTW_DNR* = cint(2)
|
||||||
|
FTW_NS* = cint(3)
|
||||||
|
FTW_SL* = cint(4)
|
||||||
|
GLOB_APPEND* = cint(32)
|
||||||
|
GLOB_DOOFFS* = cint(8)
|
||||||
|
GLOB_ERR* = cint(1)
|
||||||
|
GLOB_MARK* = cint(2)
|
||||||
|
GLOB_NOCHECK* = cint(16)
|
||||||
|
GLOB_NOESCAPE* = cint(64)
|
||||||
|
GLOB_NOSORT* = cint(4)
|
||||||
|
GLOB_ABORTED* = cint(2)
|
||||||
|
GLOB_NOMATCH* = cint(3)
|
||||||
|
GLOB_NOSPACE* = cint(1)
|
||||||
|
GLOB_NOSYS* = cint(4)
|
||||||
|
CODESET* = cint(14)
|
||||||
|
D_T_FMT* = cint(131112)
|
||||||
|
D_FMT* = cint(131113)
|
||||||
|
T_FMT* = cint(131114)
|
||||||
|
T_FMT_AMPM* = cint(131115)
|
||||||
|
AM_STR* = cint(131110)
|
||||||
|
PM_STR* = cint(131111)
|
||||||
|
DAY_1* = cint(131079)
|
||||||
|
DAY_2* = cint(131080)
|
||||||
|
DAY_3* = cint(131081)
|
||||||
|
DAY_4* = cint(131082)
|
||||||
|
DAY_5* = cint(131083)
|
||||||
|
DAY_6* = cint(131084)
|
||||||
|
DAY_7* = cint(131085)
|
||||||
|
ABDAY_1* = cint(131072)
|
||||||
|
ABDAY_2* = cint(131073)
|
||||||
|
ABDAY_3* = cint(131074)
|
||||||
|
ABDAY_4* = cint(131075)
|
||||||
|
ABDAY_5* = cint(131076)
|
||||||
|
ABDAY_6* = cint(131077)
|
||||||
|
ABDAY_7* = cint(131078)
|
||||||
|
MON_1* = cint(131098)
|
||||||
|
MON_2* = cint(131099)
|
||||||
|
MON_3* = cint(131100)
|
||||||
|
MON_4* = cint(131101)
|
||||||
|
MON_5* = cint(131102)
|
||||||
|
MON_6* = cint(131103)
|
||||||
|
MON_7* = cint(131104)
|
||||||
|
MON_8* = cint(131105)
|
||||||
|
MON_9* = cint(131106)
|
||||||
|
MON_10* = cint(131107)
|
||||||
|
MON_11* = cint(131108)
|
||||||
|
MON_12* = cint(131109)
|
||||||
|
ABMON_1* = cint(131086)
|
||||||
|
ABMON_2* = cint(131087)
|
||||||
|
ABMON_3* = cint(131088)
|
||||||
|
ABMON_4* = cint(131089)
|
||||||
|
ABMON_5* = cint(131090)
|
||||||
|
ABMON_6* = cint(131091)
|
||||||
|
ABMON_7* = cint(131092)
|
||||||
|
ABMON_8* = cint(131093)
|
||||||
|
ABMON_9* = cint(131094)
|
||||||
|
ABMON_10* = cint(131095)
|
||||||
|
ABMON_11* = cint(131096)
|
||||||
|
ABMON_12* = cint(131097)
|
||||||
|
ERA* = cint(131116)
|
||||||
|
ERA_D_FMT* = cint(131118)
|
||||||
|
ERA_D_T_FMT* = cint(131120)
|
||||||
|
ERA_T_FMT* = cint(131121)
|
||||||
|
ALT_DIGITS* = cint(131119)
|
||||||
|
RADIXCHAR* = cint(65536)
|
||||||
|
THOUSEP* = cint(65537)
|
||||||
|
YESEXPR* = cint(327680)
|
||||||
|
NOEXPR* = cint(327681)
|
||||||
|
CRNCYSTR* = cint(262159)
|
||||||
|
LC_ALL* = cint(6)
|
||||||
|
LC_COLLATE* = cint(3)
|
||||||
|
LC_CTYPE* = cint(0)
|
||||||
|
LC_MESSAGES* = cint(5)
|
||||||
|
LC_MONETARY* = cint(4)
|
||||||
|
LC_NUMERIC* = cint(1)
|
||||||
|
LC_TIME* = cint(2)
|
||||||
|
PTHREAD_BARRIER_SERIAL_THREAD* = cint(-1)
|
||||||
|
PTHREAD_CANCEL_ASYNCHRONOUS* = cint(1)
|
||||||
|
PTHREAD_CANCEL_ENABLE* = cint(0)
|
||||||
|
PTHREAD_CANCEL_DEFERRED* = cint(0)
|
||||||
|
PTHREAD_CANCEL_DISABLE* = cint(1)
|
||||||
|
PTHREAD_CREATE_DETACHED* = cint(1)
|
||||||
|
PTHREAD_CREATE_JOINABLE* = cint(0)
|
||||||
|
PTHREAD_EXPLICIT_SCHED* = cint(1)
|
||||||
|
PTHREAD_INHERIT_SCHED* = cint(0)
|
||||||
|
PTHREAD_ONCE_INIT* = cint(0)
|
||||||
|
PTHREAD_PROCESS_SHARED* = cint(1)
|
||||||
|
PTHREAD_PROCESS_PRIVATE* = cint(0)
|
||||||
|
PTHREAD_SCOPE_PROCESS* = cint(1)
|
||||||
|
PTHREAD_SCOPE_SYSTEM* = cint(0)
|
||||||
|
POSIX_ASYNC_IO* = cint(1)
|
||||||
|
F_OK* = cint(0)
|
||||||
|
R_OK* = cint(4)
|
||||||
|
W_OK* = cint(2)
|
||||||
|
X_OK* = cint(1)
|
||||||
|
CS_PATH* = cint(0)
|
||||||
|
CS_POSIX_V6_ILP32_OFF32_CFLAGS* = cint(1116)
|
||||||
|
CS_POSIX_V6_ILP32_OFF32_LDFLAGS* = cint(1117)
|
||||||
|
CS_POSIX_V6_ILP32_OFF32_LIBS* = cint(1118)
|
||||||
|
CS_POSIX_V6_ILP32_OFFBIG_CFLAGS* = cint(1120)
|
||||||
|
CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS* = cint(1121)
|
||||||
|
CS_POSIX_V6_ILP32_OFFBIG_LIBS* = cint(1122)
|
||||||
|
CS_POSIX_V6_LP64_OFF64_CFLAGS* = cint(1124)
|
||||||
|
CS_POSIX_V6_LP64_OFF64_LDFLAGS* = cint(1125)
|
||||||
|
CS_POSIX_V6_LP64_OFF64_LIBS* = cint(1126)
|
||||||
|
CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS* = cint(1128)
|
||||||
|
CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS* = cint(1129)
|
||||||
|
CS_POSIX_V6_LPBIG_OFFBIG_LIBS* = cint(1130)
|
||||||
|
CS_POSIX_V6_WIDTH_RESTRICTED_ENVS* = cint(1)
|
||||||
|
F_LOCK* = cint(1)
|
||||||
|
F_TEST* = cint(3)
|
||||||
|
F_TLOCK* = cint(2)
|
||||||
|
F_ULOCK* = cint(0)
|
||||||
|
PC_2_SYMLINKS* = cint(20)
|
||||||
|
PC_ALLOC_SIZE_MIN* = cint(18)
|
||||||
|
PC_ASYNC_IO* = cint(10)
|
||||||
|
PC_CHOWN_RESTRICTED* = cint(6)
|
||||||
|
PC_FILESIZEBITS* = cint(13)
|
||||||
|
PC_LINK_MAX* = cint(0)
|
||||||
|
PC_MAX_CANON* = cint(1)
|
||||||
|
PC_MAX_INPUT* = cint(2)
|
||||||
|
PC_NAME_MAX* = cint(3)
|
||||||
|
PC_NO_TRUNC* = cint(7)
|
||||||
|
PC_PATH_MAX* = cint(4)
|
||||||
|
PC_PIPE_BUF* = cint(5)
|
||||||
|
PC_PRIO_IO* = cint(11)
|
||||||
|
PC_REC_INCR_XFER_SIZE* = cint(14)
|
||||||
|
PC_REC_MIN_XFER_SIZE* = cint(16)
|
||||||
|
PC_REC_XFER_ALIGN* = cint(17)
|
||||||
|
PC_SYMLINK_MAX* = cint(19)
|
||||||
|
PC_SYNC_IO* = cint(9)
|
||||||
|
PC_VDISABLE* = cint(8)
|
||||||
|
SC_2_C_BIND* = cint(47)
|
||||||
|
SC_2_C_DEV* = cint(48)
|
||||||
|
SC_2_CHAR_TERM* = cint(95)
|
||||||
|
SC_2_FORT_DEV* = cint(49)
|
||||||
|
SC_2_FORT_RUN* = cint(50)
|
||||||
|
SC_2_LOCALEDEF* = cint(52)
|
||||||
|
SC_2_PBS* = cint(168)
|
||||||
|
SC_2_PBS_ACCOUNTING* = cint(169)
|
||||||
|
SC_2_PBS_CHECKPOINT* = cint(175)
|
||||||
|
SC_2_PBS_LOCATE* = cint(170)
|
||||||
|
SC_2_PBS_MESSAGE* = cint(171)
|
||||||
|
SC_2_PBS_TRACK* = cint(172)
|
||||||
|
SC_2_SW_DEV* = cint(51)
|
||||||
|
SC_2_UPE* = cint(97)
|
||||||
|
SC_2_VERSION* = cint(46)
|
||||||
|
SC_ADVISORY_INFO* = cint(132)
|
||||||
|
SC_AIO_LISTIO_MAX* = cint(23)
|
||||||
|
SC_AIO_MAX* = cint(24)
|
||||||
|
SC_AIO_PRIO_DELTA_MAX* = cint(25)
|
||||||
|
SC_ARG_MAX* = cint(0)
|
||||||
|
SC_ASYNCHRONOUS_IO* = cint(12)
|
||||||
|
SC_ATEXIT_MAX* = cint(87)
|
||||||
|
SC_BARRIERS* = cint(133)
|
||||||
|
SC_BC_BASE_MAX* = cint(36)
|
||||||
|
SC_BC_DIM_MAX* = cint(37)
|
||||||
|
SC_BC_SCALE_MAX* = cint(38)
|
||||||
|
SC_BC_STRING_MAX* = cint(39)
|
||||||
|
SC_CHILD_MAX* = cint(1)
|
||||||
|
SC_CLK_TCK* = cint(2)
|
||||||
|
SC_CLOCK_SELECTION* = cint(137)
|
||||||
|
SC_COLL_WEIGHTS_MAX* = cint(40)
|
||||||
|
SC_CPUTIME* = cint(138)
|
||||||
|
SC_DELAYTIMER_MAX* = cint(26)
|
||||||
|
SC_EXPR_NEST_MAX* = cint(42)
|
||||||
|
SC_FSYNC* = cint(15)
|
||||||
|
SC_GETGR_R_SIZE_MAX* = cint(69)
|
||||||
|
SC_GETPW_R_SIZE_MAX* = cint(70)
|
||||||
|
SC_HOST_NAME_MAX* = cint(180)
|
||||||
|
SC_IOV_MAX* = cint(60)
|
||||||
|
SC_IPV6* = cint(235)
|
||||||
|
SC_JOB_CONTROL* = cint(7)
|
||||||
|
SC_LINE_MAX* = cint(43)
|
||||||
|
SC_LOGIN_NAME_MAX* = cint(71)
|
||||||
|
SC_MAPPED_FILES* = cint(16)
|
||||||
|
SC_MEMLOCK* = cint(17)
|
||||||
|
SC_MEMLOCK_RANGE* = cint(18)
|
||||||
|
SC_MEMORY_PROTECTION* = cint(19)
|
||||||
|
SC_MESSAGE_PASSING* = cint(20)
|
||||||
|
SC_MONOTONIC_CLOCK* = cint(149)
|
||||||
|
SC_MQ_OPEN_MAX* = cint(27)
|
||||||
|
SC_MQ_PRIO_MAX* = cint(28)
|
||||||
|
SC_NGROUPS_MAX* = cint(3)
|
||||||
|
SC_OPEN_MAX* = cint(4)
|
||||||
|
SC_PAGE_SIZE* = cint(30)
|
||||||
|
SC_PRIORITIZED_IO* = cint(13)
|
||||||
|
SC_PRIORITY_SCHEDULING* = cint(10)
|
||||||
|
SC_RAW_SOCKETS* = cint(236)
|
||||||
|
SC_RE_DUP_MAX* = cint(44)
|
||||||
|
SC_READER_WRITER_LOCKS* = cint(153)
|
||||||
|
SC_REALTIME_SIGNALS* = cint(9)
|
||||||
|
SC_REGEXP* = cint(155)
|
||||||
|
SC_RTSIG_MAX* = cint(31)
|
||||||
|
SC_SAVED_IDS* = cint(8)
|
||||||
|
SC_SEM_NSEMS_MAX* = cint(32)
|
||||||
|
SC_SEM_VALUE_MAX* = cint(33)
|
||||||
|
SC_SEMAPHORES* = cint(21)
|
||||||
|
SC_SHARED_MEMORY_OBJECTS* = cint(22)
|
||||||
|
SC_SHELL* = cint(157)
|
||||||
|
SC_SIGQUEUE_MAX* = cint(34)
|
||||||
|
SC_SPAWN* = cint(159)
|
||||||
|
SC_SPIN_LOCKS* = cint(154)
|
||||||
|
SC_SPORADIC_SERVER* = cint(160)
|
||||||
|
SC_STREAM_MAX* = cint(5)
|
||||||
|
SC_SYMLOOP_MAX* = cint(173)
|
||||||
|
SC_SYNCHRONIZED_IO* = cint(14)
|
||||||
|
SC_THREAD_ATTR_STACKADDR* = cint(77)
|
||||||
|
SC_THREAD_ATTR_STACKSIZE* = cint(78)
|
||||||
|
SC_THREAD_CPUTIME* = cint(139)
|
||||||
|
SC_THREAD_DESTRUCTOR_ITERATIONS* = cint(73)
|
||||||
|
SC_THREAD_KEYS_MAX* = cint(74)
|
||||||
|
SC_THREAD_PRIO_INHERIT* = cint(80)
|
||||||
|
SC_THREAD_PRIO_PROTECT* = cint(81)
|
||||||
|
SC_THREAD_PRIORITY_SCHEDULING* = cint(79)
|
||||||
|
SC_THREAD_PROCESS_SHARED* = cint(82)
|
||||||
|
SC_THREAD_SAFE_FUNCTIONS* = cint(68)
|
||||||
|
SC_THREAD_SPORADIC_SERVER* = cint(161)
|
||||||
|
SC_THREAD_STACK_MIN* = cint(75)
|
||||||
|
SC_THREAD_THREADS_MAX* = cint(76)
|
||||||
|
SC_THREADS* = cint(67)
|
||||||
|
SC_TIMEOUTS* = cint(164)
|
||||||
|
SC_TIMER_MAX* = cint(35)
|
||||||
|
SC_TIMERS* = cint(11)
|
||||||
|
SC_TRACE* = cint(181)
|
||||||
|
SC_TRACE_EVENT_FILTER* = cint(182)
|
||||||
|
SC_TRACE_INHERIT* = cint(183)
|
||||||
|
SC_TRACE_LOG* = cint(184)
|
||||||
|
SC_TTY_NAME_MAX* = cint(72)
|
||||||
|
SC_TYPED_MEMORY_OBJECTS* = cint(165)
|
||||||
|
SC_TZNAME_MAX* = cint(6)
|
||||||
|
SC_V6_ILP32_OFF32* = cint(176)
|
||||||
|
SC_V6_ILP32_OFFBIG* = cint(177)
|
||||||
|
SC_V6_LP64_OFF64* = cint(178)
|
||||||
|
SC_V6_LPBIG_OFFBIG* = cint(179)
|
||||||
|
SC_VERSION* = cint(29)
|
||||||
|
SC_XBS5_ILP32_OFF32* = cint(125)
|
||||||
|
SC_XBS5_ILP32_OFFBIG* = cint(126)
|
||||||
|
SC_XBS5_LP64_OFF64* = cint(127)
|
||||||
|
SC_XBS5_LPBIG_OFFBIG* = cint(128)
|
||||||
|
SC_XOPEN_CRYPT* = cint(92)
|
||||||
|
SC_XOPEN_ENH_I18N* = cint(93)
|
||||||
|
SC_XOPEN_LEGACY* = cint(129)
|
||||||
|
SC_XOPEN_REALTIME* = cint(130)
|
||||||
|
SC_XOPEN_REALTIME_THREADS* = cint(131)
|
||||||
|
SC_XOPEN_SHM* = cint(94)
|
||||||
|
SC_XOPEN_UNIX* = cint(91)
|
||||||
|
SC_XOPEN_VERSION* = cint(89)
|
||||||
|
SEEK_SET* = cint(0)
|
||||||
|
SEEK_CUR* = cint(1)
|
||||||
|
SEEK_END* = cint(2)
|
||||||
|
SEM_FAILED* = cast[pointer]((nil))
|
||||||
|
IPC_CREAT* = cint(512)
|
||||||
|
IPC_EXCL* = cint(1024)
|
||||||
|
IPC_NOWAIT* = cint(2048)
|
||||||
|
IPC_PRIVATE* = cint(0)
|
||||||
|
IPC_RMID* = cint(0)
|
||||||
|
IPC_SET* = cint(1)
|
||||||
|
IPC_STAT* = cint(2)
|
||||||
|
S_IFMT* = cint(61440)
|
||||||
|
S_IFBLK* = cint(24576)
|
||||||
|
S_IFCHR* = cint(8192)
|
||||||
|
S_IFIFO* = cint(4096)
|
||||||
|
S_IFREG* = cint(32768)
|
||||||
|
S_IFDIR* = cint(16384)
|
||||||
|
S_IFLNK* = cint(40960)
|
||||||
|
S_IFSOCK* = cint(49152)
|
||||||
|
S_IRWXU* = cint(448)
|
||||||
|
S_IRUSR* = cint(256)
|
||||||
|
S_IWUSR* = cint(128)
|
||||||
|
S_IXUSR* = cint(64)
|
||||||
|
S_IRWXG* = cint(56)
|
||||||
|
S_IRGRP* = cint(32)
|
||||||
|
S_IWGRP* = cint(16)
|
||||||
|
S_IXGRP* = cint(8)
|
||||||
|
S_IRWXO* = cint(7)
|
||||||
|
S_IROTH* = cint(4)
|
||||||
|
S_IWOTH* = cint(2)
|
||||||
|
S_IXOTH* = cint(1)
|
||||||
|
S_ISUID* = cint(2048)
|
||||||
|
S_ISGID* = cint(1024)
|
||||||
|
S_ISVTX* = cint(512)
|
||||||
|
ST_RDONLY* = cint(1)
|
||||||
|
ST_NOSUID* = cint(2)
|
||||||
|
PROT_READ* = cint(1)
|
||||||
|
PROT_WRITE* = cint(2)
|
||||||
|
PROT_EXEC* = cint(4)
|
||||||
|
PROT_NONE* = cint(0)
|
||||||
|
MAP_SHARED* = cint(1)
|
||||||
|
MAP_PRIVATE* = cint(2)
|
||||||
|
MAP_FIXED* = cint(16)
|
||||||
|
MS_ASYNC* = cint(1)
|
||||||
|
MS_SYNC* = cint(4)
|
||||||
|
MS_INVALIDATE* = cint(2)
|
||||||
|
MCL_CURRENT* = cint(1)
|
||||||
|
MCL_FUTURE* = cint(2)
|
||||||
|
MAP_FAILED* = cast[pointer](0xffffffffffffffff)
|
||||||
|
POSIX_MADV_NORMAL* = cint(0)
|
||||||
|
POSIX_MADV_SEQUENTIAL* = cint(2)
|
||||||
|
POSIX_MADV_RANDOM* = cint(1)
|
||||||
|
POSIX_MADV_WILLNEED* = cint(3)
|
||||||
|
POSIX_MADV_DONTNEED* = cint(4)
|
||||||
|
CLOCKS_PER_SEC* = clong(1000000)
|
||||||
|
CLOCK_PROCESS_CPUTIME_ID* = cint(2)
|
||||||
|
CLOCK_THREAD_CPUTIME_ID* = cint(3)
|
||||||
|
CLOCK_REALTIME* = cint(0)
|
||||||
|
TIMER_ABSTIME* = cint(1)
|
||||||
|
CLOCK_MONOTONIC* = cint(1)
|
||||||
|
WNOHANG* = cint(1)
|
||||||
|
WUNTRACED* = cint(2)
|
||||||
|
WEXITED* = cint(4)
|
||||||
|
WSTOPPED* = cint(2)
|
||||||
|
WCONTINUED* = cint(8)
|
||||||
|
WNOWAIT* = cint(16777216)
|
||||||
|
SIGEV_NONE* = cint(1)
|
||||||
|
SIGEV_SIGNAL* = cint(0)
|
||||||
|
SIGEV_THREAD* = cint(2)
|
||||||
|
SIGABRT* = cint(6)
|
||||||
|
SIGALRM* = cint(14)
|
||||||
|
SIGBUS* = cint(7)
|
||||||
|
SIGCHLD* = cint(17)
|
||||||
|
SIGCONT* = cint(18)
|
||||||
|
SIGFPE* = cint(8)
|
||||||
|
SIGHUP* = cint(1)
|
||||||
|
SIGILL* = cint(4)
|
||||||
|
SIGINT* = cint(2)
|
||||||
|
SIGKILL* = cint(9)
|
||||||
|
SIGPIPE* = cint(13)
|
||||||
|
SIGQUIT* = cint(3)
|
||||||
|
SIGSEGV* = cint(11)
|
||||||
|
SIGSTOP* = cint(19)
|
||||||
|
SIGTERM* = cint(15)
|
||||||
|
SIGTSTP* = cint(20)
|
||||||
|
SIGTTIN* = cint(21)
|
||||||
|
SIGTTOU* = cint(22)
|
||||||
|
SIGUSR1* = cint(10)
|
||||||
|
SIGUSR2* = cint(12)
|
||||||
|
SIGPOLL* = cint(29)
|
||||||
|
SIGPROF* = cint(27)
|
||||||
|
SIGSYS* = cint(31)
|
||||||
|
SIGTRAP* = cint(5)
|
||||||
|
SIGURG* = cint(23)
|
||||||
|
SIGVTALRM* = cint(26)
|
||||||
|
SIGXCPU* = cint(24)
|
||||||
|
SIGXFSZ* = cint(25)
|
||||||
|
SA_NOCLDSTOP* = cint(1)
|
||||||
|
SIG_BLOCK* = cint(0)
|
||||||
|
SIG_UNBLOCK* = cint(1)
|
||||||
|
SIG_SETMASK* = cint(2)
|
||||||
|
SA_ONSTACK* = cint(134217728)
|
||||||
|
SA_RESETHAND* = cint(-2147483648)
|
||||||
|
SA_RESTART* = cint(268435456)
|
||||||
|
SA_SIGINFO* = cint(4)
|
||||||
|
SA_NOCLDWAIT* = cint(2)
|
||||||
|
SA_NODEFER* = cint(1073741824)
|
||||||
|
SS_ONSTACK* = cint(1)
|
||||||
|
SS_DISABLE* = cint(2)
|
||||||
|
MINSIGSTKSZ* = cint(2048)
|
||||||
|
SIGSTKSZ* = cint(8192)
|
||||||
|
NL_SETD* = cint(1)
|
||||||
|
NL_CAT_LOCALE* = cint(1)
|
||||||
|
SCHED_FIFO* = cint(1)
|
||||||
|
SCHED_RR* = cint(2)
|
||||||
|
SCHED_OTHER* = cint(0)
|
||||||
|
FD_SETSIZE* = cint(1024)
|
||||||
|
IF_NAMESIZE* = cint(16)
|
||||||
|
SCM_RIGHTS* = cint(1)
|
||||||
|
SOCK_DGRAM* = cint(2)
|
||||||
|
SOCK_RAW* = cint(3)
|
||||||
|
SOCK_SEQPACKET* = cint(5)
|
||||||
|
SOCK_STREAM* = cint(1)
|
||||||
|
SOL_SOCKET* = cint(1)
|
||||||
|
SO_ACCEPTCONN* = cint(30)
|
||||||
|
SO_BROADCAST* = cint(6)
|
||||||
|
SO_DEBUG* = cint(1)
|
||||||
|
SO_DONTROUTE* = cint(5)
|
||||||
|
SO_ERROR* = cint(4)
|
||||||
|
SO_KEEPALIVE* = cint(9)
|
||||||
|
SO_LINGER* = cint(13)
|
||||||
|
SO_OOBINLINE* = cint(10)
|
||||||
|
SO_RCVBUF* = cint(8)
|
||||||
|
SO_RCVLOWAT* = cint(18)
|
||||||
|
SO_RCVTIMEO* = cint(20)
|
||||||
|
SO_REUSEADDR* = cint(2)
|
||||||
|
SO_SNDBUF* = cint(7)
|
||||||
|
SO_SNDLOWAT* = cint(19)
|
||||||
|
SO_SNDTIMEO* = cint(21)
|
||||||
|
SO_TYPE* = cint(3)
|
||||||
|
SOMAXCONN* = cint(128)
|
||||||
|
MSG_CTRUNC* = cint(8)
|
||||||
|
MSG_DONTROUTE* = cint(4)
|
||||||
|
MSG_EOR* = cint(128)
|
||||||
|
MSG_OOB* = cint(1)
|
||||||
|
MSG_PEEK* = cint(2)
|
||||||
|
MSG_TRUNC* = cint(32)
|
||||||
|
MSG_WAITALL* = cint(256)
|
||||||
|
AF_INET* = cint(2)
|
||||||
|
AF_INET6* = cint(10)
|
||||||
|
AF_UNIX* = cint(1)
|
||||||
|
AF_UNSPEC* = cint(0)
|
||||||
|
SHUT_RD* = cint(0)
|
||||||
|
SHUT_RDWR* = cint(2)
|
||||||
|
SHUT_WR* = cint(1)
|
||||||
|
IPPROTO_IP* = cint(0)
|
||||||
|
IPPROTO_IPV6* = cint(41)
|
||||||
|
IPPROTO_ICMP* = cint(1)
|
||||||
|
IPPROTO_RAW* = cint(255)
|
||||||
|
IPPROTO_TCP* = cint(6)
|
||||||
|
IPPROTO_UDP* = cint(17)
|
||||||
|
INADDR_ANY* = cint(0)
|
||||||
|
INADDR_BROADCAST* = cint(-1)
|
||||||
|
INET_ADDRSTRLEN* = cint(16)
|
||||||
|
IPV6_JOIN_GROUP* = cint(20)
|
||||||
|
IPV6_LEAVE_GROUP* = cint(21)
|
||||||
|
IPV6_MULTICAST_HOPS* = cint(18)
|
||||||
|
IPV6_MULTICAST_IF* = cint(17)
|
||||||
|
IPV6_MULTICAST_LOOP* = cint(19)
|
||||||
|
IPV6_UNICAST_HOPS* = cint(16)
|
||||||
|
IPV6_V6ONLY* = cint(26)
|
||||||
|
IPPORT_RESERVED* = cint(1024)
|
||||||
|
HOST_NOT_FOUND* = cint(1)
|
||||||
|
NO_DATA* = cint(4)
|
||||||
|
NO_RECOVERY* = cint(3)
|
||||||
|
TRY_AGAIN* = cint(2)
|
||||||
|
AI_PASSIVE* = cint(1)
|
||||||
|
AI_CANONNAME* = cint(2)
|
||||||
|
AI_NUMERICHOST* = cint(4)
|
||||||
|
AI_NUMERICSERV* = cint(1024)
|
||||||
|
AI_V4MAPPED* = cint(8)
|
||||||
|
AI_ALL* = cint(16)
|
||||||
|
AI_ADDRCONFIG* = cint(32)
|
||||||
|
NI_NOFQDN* = cint(4)
|
||||||
|
NI_NUMERICHOST* = cint(1)
|
||||||
|
NI_NAMEREQD* = cint(8)
|
||||||
|
NI_NUMERICSERV* = cint(2)
|
||||||
|
NI_DGRAM* = cint(16)
|
||||||
|
EAI_AGAIN* = cint(-3)
|
||||||
|
EAI_BADFLAGS* = cint(-1)
|
||||||
|
EAI_FAIL* = cint(-4)
|
||||||
|
EAI_FAMILY* = cint(-6)
|
||||||
|
EAI_MEMORY* = cint(-10)
|
||||||
|
EAI_NONAME* = cint(-2)
|
||||||
|
EAI_SERVICE* = cint(-8)
|
||||||
|
EAI_SOCKTYPE* = cint(-7)
|
||||||
|
EAI_SYSTEM* = cint(-11)
|
||||||
|
EAI_OVERFLOW* = cint(-12)
|
||||||
|
POLLIN* = cshort(1)
|
||||||
|
POLLPRI* = cshort(2)
|
||||||
|
POLLOUT* = cshort(4)
|
||||||
|
POLLERR* = cshort(8)
|
||||||
|
POLLHUP* = cshort(16)
|
||||||
|
POLLNVAL* = cshort(32)
|
||||||
|
POSIX_SPAWN_RESETIDS* = cint(1)
|
||||||
|
POSIX_SPAWN_SETPGROUP* = cint(2)
|
||||||
|
POSIX_SPAWN_SETSCHEDPARAM* = cint(16)
|
||||||
|
POSIX_SPAWN_SETSCHEDULER* = cint(32)
|
||||||
|
POSIX_SPAWN_SETSIGDEF* = cint(4)
|
||||||
|
POSIX_SPAWN_SETSIGMASK* = cint(8)
|
||||||
620
lib/posix/linux_consts.nim
Normal file
620
lib/posix/linux_consts.nim
Normal file
|
|
@ -0,0 +1,620 @@
|
||||||
|
# Generated by detect.nim
|
||||||
|
const
|
||||||
|
AIO_ALLDONE* = cint(2)
|
||||||
|
AIO_CANCELED* = cint(0)
|
||||||
|
AIO_NOTCANCELED* = cint(1)
|
||||||
|
LIO_NOP* = cint(2)
|
||||||
|
LIO_NOWAIT* = cint(1)
|
||||||
|
LIO_READ* = cint(0)
|
||||||
|
LIO_WAIT* = cint(0)
|
||||||
|
LIO_WRITE* = cint(1)
|
||||||
|
RTLD_LAZY* = cint(1)
|
||||||
|
RTLD_NOW* = cint(2)
|
||||||
|
RTLD_GLOBAL* = cint(256)
|
||||||
|
RTLD_LOCAL* = cint(0)
|
||||||
|
E2BIG* = cint(7)
|
||||||
|
EACCES* = cint(13)
|
||||||
|
EADDRINUSE* = cint(98)
|
||||||
|
EADDRNOTAVAIL* = cint(99)
|
||||||
|
EAFNOSUPPORT* = cint(97)
|
||||||
|
EAGAIN* = cint(11)
|
||||||
|
EALREADY* = cint(114)
|
||||||
|
EBADF* = cint(9)
|
||||||
|
EBADMSG* = cint(74)
|
||||||
|
EBUSY* = cint(16)
|
||||||
|
ECANCELED* = cint(125)
|
||||||
|
ECHILD* = cint(10)
|
||||||
|
ECONNABORTED* = cint(103)
|
||||||
|
ECONNREFUSED* = cint(111)
|
||||||
|
ECONNRESET* = cint(104)
|
||||||
|
EDEADLK* = cint(35)
|
||||||
|
EDESTADDRREQ* = cint(89)
|
||||||
|
EDOM* = cint(33)
|
||||||
|
EDQUOT* = cint(122)
|
||||||
|
EEXIST* = cint(17)
|
||||||
|
EFAULT* = cint(14)
|
||||||
|
EFBIG* = cint(27)
|
||||||
|
EHOSTUNREACH* = cint(113)
|
||||||
|
EIDRM* = cint(43)
|
||||||
|
EILSEQ* = cint(84)
|
||||||
|
EINPROGRESS* = cint(115)
|
||||||
|
EINTR* = cint(4)
|
||||||
|
EINVAL* = cint(22)
|
||||||
|
EIO* = cint(5)
|
||||||
|
EISCONN* = cint(106)
|
||||||
|
EISDIR* = cint(21)
|
||||||
|
ELOOP* = cint(40)
|
||||||
|
EMFILE* = cint(24)
|
||||||
|
EMLINK* = cint(31)
|
||||||
|
EMSGSIZE* = cint(90)
|
||||||
|
EMULTIHOP* = cint(72)
|
||||||
|
ENAMETOOLONG* = cint(36)
|
||||||
|
ENETDOWN* = cint(100)
|
||||||
|
ENETRESET* = cint(102)
|
||||||
|
ENETUNREACH* = cint(101)
|
||||||
|
ENFILE* = cint(23)
|
||||||
|
ENOBUFS* = cint(105)
|
||||||
|
ENODATA* = cint(61)
|
||||||
|
ENODEV* = cint(19)
|
||||||
|
ENOENT* = cint(2)
|
||||||
|
ENOEXEC* = cint(8)
|
||||||
|
ENOLCK* = cint(37)
|
||||||
|
ENOLINK* = cint(67)
|
||||||
|
ENOMEM* = cint(12)
|
||||||
|
ENOMSG* = cint(42)
|
||||||
|
ENOPROTOOPT* = cint(92)
|
||||||
|
ENOSPC* = cint(28)
|
||||||
|
ENOSR* = cint(63)
|
||||||
|
ENOSTR* = cint(60)
|
||||||
|
ENOSYS* = cint(38)
|
||||||
|
ENOTCONN* = cint(107)
|
||||||
|
ENOTDIR* = cint(20)
|
||||||
|
ENOTEMPTY* = cint(39)
|
||||||
|
ENOTSOCK* = cint(88)
|
||||||
|
ENOTSUP* = cint(95)
|
||||||
|
ENOTTY* = cint(25)
|
||||||
|
ENXIO* = cint(6)
|
||||||
|
EOPNOTSUPP* = cint(95)
|
||||||
|
EOVERFLOW* = cint(75)
|
||||||
|
EPERM* = cint(1)
|
||||||
|
EPIPE* = cint(32)
|
||||||
|
EPROTO* = cint(71)
|
||||||
|
EPROTONOSUPPORT* = cint(93)
|
||||||
|
EPROTOTYPE* = cint(91)
|
||||||
|
ERANGE* = cint(34)
|
||||||
|
EROFS* = cint(30)
|
||||||
|
ESPIPE* = cint(29)
|
||||||
|
ESRCH* = cint(3)
|
||||||
|
ESTALE* = cint(116)
|
||||||
|
ETIME* = cint(62)
|
||||||
|
ETIMEDOUT* = cint(110)
|
||||||
|
ETXTBSY* = cint(26)
|
||||||
|
EWOULDBLOCK* = cint(11)
|
||||||
|
EXDEV* = cint(18)
|
||||||
|
F_DUPFD* = cint(0)
|
||||||
|
F_GETFD* = cint(1)
|
||||||
|
F_SETFD* = cint(2)
|
||||||
|
F_GETFL* = cint(3)
|
||||||
|
F_SETFL* = cint(4)
|
||||||
|
F_GETLK* = cint(5)
|
||||||
|
F_SETLK* = cint(6)
|
||||||
|
F_SETLKW* = cint(7)
|
||||||
|
F_GETOWN* = cint(9)
|
||||||
|
F_SETOWN* = cint(8)
|
||||||
|
FD_CLOEXEC* = cint(1)
|
||||||
|
F_RDLCK* = cint(0)
|
||||||
|
F_UNLCK* = cint(2)
|
||||||
|
F_WRLCK* = cint(1)
|
||||||
|
O_CREAT* = cint(64)
|
||||||
|
O_EXCL* = cint(128)
|
||||||
|
O_NOCTTY* = cint(256)
|
||||||
|
O_TRUNC* = cint(512)
|
||||||
|
O_APPEND* = cint(1024)
|
||||||
|
O_DSYNC* = cint(4096)
|
||||||
|
O_NONBLOCK* = cint(2048)
|
||||||
|
O_RSYNC* = cint(4096)
|
||||||
|
O_SYNC* = cint(4096)
|
||||||
|
O_ACCMODE* = cint(3)
|
||||||
|
O_RDONLY* = cint(0)
|
||||||
|
O_RDWR* = cint(2)
|
||||||
|
O_WRONLY* = cint(1)
|
||||||
|
POSIX_FADV_NORMAL* = cint(0)
|
||||||
|
POSIX_FADV_SEQUENTIAL* = cint(2)
|
||||||
|
POSIX_FADV_RANDOM* = cint(1)
|
||||||
|
POSIX_FADV_WILLNEED* = cint(3)
|
||||||
|
POSIX_FADV_DONTNEED* = cint(4)
|
||||||
|
POSIX_FADV_NOREUSE* = cint(5)
|
||||||
|
FE_DIVBYZERO* = cint(4)
|
||||||
|
FE_INEXACT* = cint(32)
|
||||||
|
FE_INVALID* = cint(1)
|
||||||
|
FE_OVERFLOW* = cint(8)
|
||||||
|
FE_UNDERFLOW* = cint(16)
|
||||||
|
FE_ALL_EXCEPT* = cint(61)
|
||||||
|
FE_DOWNWARD* = cint(1024)
|
||||||
|
FE_TONEAREST* = cint(0)
|
||||||
|
FE_TOWARDZERO* = cint(3072)
|
||||||
|
FE_UPWARD* = cint(2048)
|
||||||
|
FE_DFL_ENV* = cast[pointer](0xffffffffffffffff)
|
||||||
|
MM_HARD* = cint(1)
|
||||||
|
MM_SOFT* = cint(2)
|
||||||
|
MM_FIRM* = cint(4)
|
||||||
|
MM_APPL* = cint(8)
|
||||||
|
MM_UTIL* = cint(16)
|
||||||
|
MM_OPSYS* = cint(32)
|
||||||
|
MM_RECOVER* = cint(64)
|
||||||
|
MM_NRECOV* = cint(128)
|
||||||
|
MM_HALT* = cint(1)
|
||||||
|
MM_ERROR* = cint(2)
|
||||||
|
MM_WARNING* = cint(3)
|
||||||
|
MM_INFO* = cint(4)
|
||||||
|
MM_NOSEV* = cint(0)
|
||||||
|
MM_PRINT* = cint(256)
|
||||||
|
MM_CONSOLE* = cint(512)
|
||||||
|
MM_OK* = cint(0)
|
||||||
|
MM_NOTOK* = cint(-1)
|
||||||
|
MM_NOMSG* = cint(1)
|
||||||
|
MM_NOCON* = cint(4)
|
||||||
|
FNM_NOMATCH* = cint(1)
|
||||||
|
FNM_PATHNAME* = cint(1)
|
||||||
|
FNM_PERIOD* = cint(4)
|
||||||
|
FNM_NOESCAPE* = cint(2)
|
||||||
|
FTW_F* = cint(0)
|
||||||
|
FTW_D* = cint(1)
|
||||||
|
FTW_DNR* = cint(2)
|
||||||
|
FTW_NS* = cint(3)
|
||||||
|
FTW_SL* = cint(4)
|
||||||
|
GLOB_APPEND* = cint(32)
|
||||||
|
GLOB_DOOFFS* = cint(8)
|
||||||
|
GLOB_ERR* = cint(1)
|
||||||
|
GLOB_MARK* = cint(2)
|
||||||
|
GLOB_NOCHECK* = cint(16)
|
||||||
|
GLOB_NOESCAPE* = cint(64)
|
||||||
|
GLOB_NOSORT* = cint(4)
|
||||||
|
GLOB_ABORTED* = cint(2)
|
||||||
|
GLOB_NOMATCH* = cint(3)
|
||||||
|
GLOB_NOSPACE* = cint(1)
|
||||||
|
GLOB_NOSYS* = cint(4)
|
||||||
|
CODESET* = cint(14)
|
||||||
|
D_T_FMT* = cint(131112)
|
||||||
|
D_FMT* = cint(131113)
|
||||||
|
T_FMT* = cint(131114)
|
||||||
|
T_FMT_AMPM* = cint(131115)
|
||||||
|
AM_STR* = cint(131110)
|
||||||
|
PM_STR* = cint(131111)
|
||||||
|
DAY_1* = cint(131079)
|
||||||
|
DAY_2* = cint(131080)
|
||||||
|
DAY_3* = cint(131081)
|
||||||
|
DAY_4* = cint(131082)
|
||||||
|
DAY_5* = cint(131083)
|
||||||
|
DAY_6* = cint(131084)
|
||||||
|
DAY_7* = cint(131085)
|
||||||
|
ABDAY_1* = cint(131072)
|
||||||
|
ABDAY_2* = cint(131073)
|
||||||
|
ABDAY_3* = cint(131074)
|
||||||
|
ABDAY_4* = cint(131075)
|
||||||
|
ABDAY_5* = cint(131076)
|
||||||
|
ABDAY_6* = cint(131077)
|
||||||
|
ABDAY_7* = cint(131078)
|
||||||
|
MON_1* = cint(131098)
|
||||||
|
MON_2* = cint(131099)
|
||||||
|
MON_3* = cint(131100)
|
||||||
|
MON_4* = cint(131101)
|
||||||
|
MON_5* = cint(131102)
|
||||||
|
MON_6* = cint(131103)
|
||||||
|
MON_7* = cint(131104)
|
||||||
|
MON_8* = cint(131105)
|
||||||
|
MON_9* = cint(131106)
|
||||||
|
MON_10* = cint(131107)
|
||||||
|
MON_11* = cint(131108)
|
||||||
|
MON_12* = cint(131109)
|
||||||
|
ABMON_1* = cint(131086)
|
||||||
|
ABMON_2* = cint(131087)
|
||||||
|
ABMON_3* = cint(131088)
|
||||||
|
ABMON_4* = cint(131089)
|
||||||
|
ABMON_5* = cint(131090)
|
||||||
|
ABMON_6* = cint(131091)
|
||||||
|
ABMON_7* = cint(131092)
|
||||||
|
ABMON_8* = cint(131093)
|
||||||
|
ABMON_9* = cint(131094)
|
||||||
|
ABMON_10* = cint(131095)
|
||||||
|
ABMON_11* = cint(131096)
|
||||||
|
ABMON_12* = cint(131097)
|
||||||
|
ERA* = cint(131116)
|
||||||
|
ERA_D_FMT* = cint(131118)
|
||||||
|
ERA_D_T_FMT* = cint(131120)
|
||||||
|
ERA_T_FMT* = cint(131121)
|
||||||
|
ALT_DIGITS* = cint(131119)
|
||||||
|
RADIXCHAR* = cint(65536)
|
||||||
|
THOUSEP* = cint(65537)
|
||||||
|
YESEXPR* = cint(327680)
|
||||||
|
NOEXPR* = cint(327681)
|
||||||
|
CRNCYSTR* = cint(262159)
|
||||||
|
LC_ALL* = cint(6)
|
||||||
|
LC_COLLATE* = cint(3)
|
||||||
|
LC_CTYPE* = cint(0)
|
||||||
|
LC_MESSAGES* = cint(5)
|
||||||
|
LC_MONETARY* = cint(4)
|
||||||
|
LC_NUMERIC* = cint(1)
|
||||||
|
LC_TIME* = cint(2)
|
||||||
|
PTHREAD_BARRIER_SERIAL_THREAD* = cint(-1)
|
||||||
|
PTHREAD_CANCEL_ASYNCHRONOUS* = cint(1)
|
||||||
|
PTHREAD_CANCEL_ENABLE* = cint(0)
|
||||||
|
PTHREAD_CANCEL_DEFERRED* = cint(0)
|
||||||
|
PTHREAD_CANCEL_DISABLE* = cint(1)
|
||||||
|
PTHREAD_CREATE_DETACHED* = cint(1)
|
||||||
|
PTHREAD_CREATE_JOINABLE* = cint(0)
|
||||||
|
PTHREAD_EXPLICIT_SCHED* = cint(1)
|
||||||
|
PTHREAD_INHERIT_SCHED* = cint(0)
|
||||||
|
PTHREAD_ONCE_INIT* = cint(0)
|
||||||
|
PTHREAD_PROCESS_SHARED* = cint(1)
|
||||||
|
PTHREAD_PROCESS_PRIVATE* = cint(0)
|
||||||
|
PTHREAD_SCOPE_PROCESS* = cint(1)
|
||||||
|
PTHREAD_SCOPE_SYSTEM* = cint(0)
|
||||||
|
POSIX_ASYNC_IO* = cint(1)
|
||||||
|
F_OK* = cint(0)
|
||||||
|
R_OK* = cint(4)
|
||||||
|
W_OK* = cint(2)
|
||||||
|
X_OK* = cint(1)
|
||||||
|
CS_PATH* = cint(0)
|
||||||
|
CS_POSIX_V6_ILP32_OFF32_CFLAGS* = cint(1116)
|
||||||
|
CS_POSIX_V6_ILP32_OFF32_LDFLAGS* = cint(1117)
|
||||||
|
CS_POSIX_V6_ILP32_OFF32_LIBS* = cint(1118)
|
||||||
|
CS_POSIX_V6_ILP32_OFFBIG_CFLAGS* = cint(1120)
|
||||||
|
CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS* = cint(1121)
|
||||||
|
CS_POSIX_V6_ILP32_OFFBIG_LIBS* = cint(1122)
|
||||||
|
CS_POSIX_V6_LP64_OFF64_CFLAGS* = cint(1124)
|
||||||
|
CS_POSIX_V6_LP64_OFF64_LDFLAGS* = cint(1125)
|
||||||
|
CS_POSIX_V6_LP64_OFF64_LIBS* = cint(1126)
|
||||||
|
CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS* = cint(1128)
|
||||||
|
CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS* = cint(1129)
|
||||||
|
CS_POSIX_V6_LPBIG_OFFBIG_LIBS* = cint(1130)
|
||||||
|
CS_POSIX_V6_WIDTH_RESTRICTED_ENVS* = cint(1)
|
||||||
|
F_LOCK* = cint(1)
|
||||||
|
F_TEST* = cint(3)
|
||||||
|
F_TLOCK* = cint(2)
|
||||||
|
F_ULOCK* = cint(0)
|
||||||
|
PC_2_SYMLINKS* = cint(20)
|
||||||
|
PC_ALLOC_SIZE_MIN* = cint(18)
|
||||||
|
PC_ASYNC_IO* = cint(10)
|
||||||
|
PC_CHOWN_RESTRICTED* = cint(6)
|
||||||
|
PC_FILESIZEBITS* = cint(13)
|
||||||
|
PC_LINK_MAX* = cint(0)
|
||||||
|
PC_MAX_CANON* = cint(1)
|
||||||
|
PC_MAX_INPUT* = cint(2)
|
||||||
|
PC_NAME_MAX* = cint(3)
|
||||||
|
PC_NO_TRUNC* = cint(7)
|
||||||
|
PC_PATH_MAX* = cint(4)
|
||||||
|
PC_PIPE_BUF* = cint(5)
|
||||||
|
PC_PRIO_IO* = cint(11)
|
||||||
|
PC_REC_INCR_XFER_SIZE* = cint(14)
|
||||||
|
PC_REC_MIN_XFER_SIZE* = cint(16)
|
||||||
|
PC_REC_XFER_ALIGN* = cint(17)
|
||||||
|
PC_SYMLINK_MAX* = cint(19)
|
||||||
|
PC_SYNC_IO* = cint(9)
|
||||||
|
PC_VDISABLE* = cint(8)
|
||||||
|
SC_2_C_BIND* = cint(47)
|
||||||
|
SC_2_C_DEV* = cint(48)
|
||||||
|
SC_2_CHAR_TERM* = cint(95)
|
||||||
|
SC_2_FORT_DEV* = cint(49)
|
||||||
|
SC_2_FORT_RUN* = cint(50)
|
||||||
|
SC_2_LOCALEDEF* = cint(52)
|
||||||
|
SC_2_PBS* = cint(168)
|
||||||
|
SC_2_PBS_ACCOUNTING* = cint(169)
|
||||||
|
SC_2_PBS_CHECKPOINT* = cint(175)
|
||||||
|
SC_2_PBS_LOCATE* = cint(170)
|
||||||
|
SC_2_PBS_MESSAGE* = cint(171)
|
||||||
|
SC_2_PBS_TRACK* = cint(172)
|
||||||
|
SC_2_SW_DEV* = cint(51)
|
||||||
|
SC_2_UPE* = cint(97)
|
||||||
|
SC_2_VERSION* = cint(46)
|
||||||
|
SC_ADVISORY_INFO* = cint(132)
|
||||||
|
SC_AIO_LISTIO_MAX* = cint(23)
|
||||||
|
SC_AIO_MAX* = cint(24)
|
||||||
|
SC_AIO_PRIO_DELTA_MAX* = cint(25)
|
||||||
|
SC_ARG_MAX* = cint(0)
|
||||||
|
SC_ASYNCHRONOUS_IO* = cint(12)
|
||||||
|
SC_ATEXIT_MAX* = cint(87)
|
||||||
|
SC_BARRIERS* = cint(133)
|
||||||
|
SC_BC_BASE_MAX* = cint(36)
|
||||||
|
SC_BC_DIM_MAX* = cint(37)
|
||||||
|
SC_BC_SCALE_MAX* = cint(38)
|
||||||
|
SC_BC_STRING_MAX* = cint(39)
|
||||||
|
SC_CHILD_MAX* = cint(1)
|
||||||
|
SC_CLK_TCK* = cint(2)
|
||||||
|
SC_CLOCK_SELECTION* = cint(137)
|
||||||
|
SC_COLL_WEIGHTS_MAX* = cint(40)
|
||||||
|
SC_CPUTIME* = cint(138)
|
||||||
|
SC_DELAYTIMER_MAX* = cint(26)
|
||||||
|
SC_EXPR_NEST_MAX* = cint(42)
|
||||||
|
SC_FSYNC* = cint(15)
|
||||||
|
SC_GETGR_R_SIZE_MAX* = cint(69)
|
||||||
|
SC_GETPW_R_SIZE_MAX* = cint(70)
|
||||||
|
SC_HOST_NAME_MAX* = cint(180)
|
||||||
|
SC_IOV_MAX* = cint(60)
|
||||||
|
SC_IPV6* = cint(235)
|
||||||
|
SC_JOB_CONTROL* = cint(7)
|
||||||
|
SC_LINE_MAX* = cint(43)
|
||||||
|
SC_LOGIN_NAME_MAX* = cint(71)
|
||||||
|
SC_MAPPED_FILES* = cint(16)
|
||||||
|
SC_MEMLOCK* = cint(17)
|
||||||
|
SC_MEMLOCK_RANGE* = cint(18)
|
||||||
|
SC_MEMORY_PROTECTION* = cint(19)
|
||||||
|
SC_MESSAGE_PASSING* = cint(20)
|
||||||
|
SC_MONOTONIC_CLOCK* = cint(149)
|
||||||
|
SC_MQ_OPEN_MAX* = cint(27)
|
||||||
|
SC_MQ_PRIO_MAX* = cint(28)
|
||||||
|
SC_NGROUPS_MAX* = cint(3)
|
||||||
|
SC_OPEN_MAX* = cint(4)
|
||||||
|
SC_PAGE_SIZE* = cint(30)
|
||||||
|
SC_PRIORITIZED_IO* = cint(13)
|
||||||
|
SC_PRIORITY_SCHEDULING* = cint(10)
|
||||||
|
SC_RAW_SOCKETS* = cint(236)
|
||||||
|
SC_RE_DUP_MAX* = cint(44)
|
||||||
|
SC_READER_WRITER_LOCKS* = cint(153)
|
||||||
|
SC_REALTIME_SIGNALS* = cint(9)
|
||||||
|
SC_REGEXP* = cint(155)
|
||||||
|
SC_RTSIG_MAX* = cint(31)
|
||||||
|
SC_SAVED_IDS* = cint(8)
|
||||||
|
SC_SEM_NSEMS_MAX* = cint(32)
|
||||||
|
SC_SEM_VALUE_MAX* = cint(33)
|
||||||
|
SC_SEMAPHORES* = cint(21)
|
||||||
|
SC_SHARED_MEMORY_OBJECTS* = cint(22)
|
||||||
|
SC_SHELL* = cint(157)
|
||||||
|
SC_SIGQUEUE_MAX* = cint(34)
|
||||||
|
SC_SPAWN* = cint(159)
|
||||||
|
SC_SPIN_LOCKS* = cint(154)
|
||||||
|
SC_SPORADIC_SERVER* = cint(160)
|
||||||
|
SC_STREAM_MAX* = cint(5)
|
||||||
|
SC_SYMLOOP_MAX* = cint(173)
|
||||||
|
SC_SYNCHRONIZED_IO* = cint(14)
|
||||||
|
SC_THREAD_ATTR_STACKADDR* = cint(77)
|
||||||
|
SC_THREAD_ATTR_STACKSIZE* = cint(78)
|
||||||
|
SC_THREAD_CPUTIME* = cint(139)
|
||||||
|
SC_THREAD_DESTRUCTOR_ITERATIONS* = cint(73)
|
||||||
|
SC_THREAD_KEYS_MAX* = cint(74)
|
||||||
|
SC_THREAD_PRIO_INHERIT* = cint(80)
|
||||||
|
SC_THREAD_PRIO_PROTECT* = cint(81)
|
||||||
|
SC_THREAD_PRIORITY_SCHEDULING* = cint(79)
|
||||||
|
SC_THREAD_PROCESS_SHARED* = cint(82)
|
||||||
|
SC_THREAD_SAFE_FUNCTIONS* = cint(68)
|
||||||
|
SC_THREAD_SPORADIC_SERVER* = cint(161)
|
||||||
|
SC_THREAD_STACK_MIN* = cint(75)
|
||||||
|
SC_THREAD_THREADS_MAX* = cint(76)
|
||||||
|
SC_THREADS* = cint(67)
|
||||||
|
SC_TIMEOUTS* = cint(164)
|
||||||
|
SC_TIMER_MAX* = cint(35)
|
||||||
|
SC_TIMERS* = cint(11)
|
||||||
|
SC_TRACE* = cint(181)
|
||||||
|
SC_TRACE_EVENT_FILTER* = cint(182)
|
||||||
|
SC_TRACE_INHERIT* = cint(183)
|
||||||
|
SC_TRACE_LOG* = cint(184)
|
||||||
|
SC_TTY_NAME_MAX* = cint(72)
|
||||||
|
SC_TYPED_MEMORY_OBJECTS* = cint(165)
|
||||||
|
SC_TZNAME_MAX* = cint(6)
|
||||||
|
SC_V6_ILP32_OFF32* = cint(176)
|
||||||
|
SC_V6_ILP32_OFFBIG* = cint(177)
|
||||||
|
SC_V6_LP64_OFF64* = cint(178)
|
||||||
|
SC_V6_LPBIG_OFFBIG* = cint(179)
|
||||||
|
SC_VERSION* = cint(29)
|
||||||
|
SC_XBS5_ILP32_OFF32* = cint(125)
|
||||||
|
SC_XBS5_ILP32_OFFBIG* = cint(126)
|
||||||
|
SC_XBS5_LP64_OFF64* = cint(127)
|
||||||
|
SC_XBS5_LPBIG_OFFBIG* = cint(128)
|
||||||
|
SC_XOPEN_CRYPT* = cint(92)
|
||||||
|
SC_XOPEN_ENH_I18N* = cint(93)
|
||||||
|
SC_XOPEN_LEGACY* = cint(129)
|
||||||
|
SC_XOPEN_REALTIME* = cint(130)
|
||||||
|
SC_XOPEN_REALTIME_THREADS* = cint(131)
|
||||||
|
SC_XOPEN_SHM* = cint(94)
|
||||||
|
SC_XOPEN_UNIX* = cint(91)
|
||||||
|
SC_XOPEN_VERSION* = cint(89)
|
||||||
|
SEEK_SET* = cint(0)
|
||||||
|
SEEK_CUR* = cint(1)
|
||||||
|
SEEK_END* = cint(2)
|
||||||
|
SEM_FAILED* = cast[pointer]((nil))
|
||||||
|
IPC_CREAT* = cint(512)
|
||||||
|
IPC_EXCL* = cint(1024)
|
||||||
|
IPC_NOWAIT* = cint(2048)
|
||||||
|
IPC_PRIVATE* = cint(0)
|
||||||
|
IPC_RMID* = cint(0)
|
||||||
|
IPC_SET* = cint(1)
|
||||||
|
IPC_STAT* = cint(2)
|
||||||
|
S_IFMT* = cint(61440)
|
||||||
|
S_IFBLK* = cint(24576)
|
||||||
|
S_IFCHR* = cint(8192)
|
||||||
|
S_IFIFO* = cint(4096)
|
||||||
|
S_IFREG* = cint(32768)
|
||||||
|
S_IFDIR* = cint(16384)
|
||||||
|
S_IFLNK* = cint(40960)
|
||||||
|
S_IFSOCK* = cint(49152)
|
||||||
|
S_IRWXU* = cint(448)
|
||||||
|
S_IRUSR* = cint(256)
|
||||||
|
S_IWUSR* = cint(128)
|
||||||
|
S_IXUSR* = cint(64)
|
||||||
|
S_IRWXG* = cint(56)
|
||||||
|
S_IRGRP* = cint(32)
|
||||||
|
S_IWGRP* = cint(16)
|
||||||
|
S_IXGRP* = cint(8)
|
||||||
|
S_IRWXO* = cint(7)
|
||||||
|
S_IROTH* = cint(4)
|
||||||
|
S_IWOTH* = cint(2)
|
||||||
|
S_IXOTH* = cint(1)
|
||||||
|
S_ISUID* = cint(2048)
|
||||||
|
S_ISGID* = cint(1024)
|
||||||
|
S_ISVTX* = cint(512)
|
||||||
|
ST_RDONLY* = cint(1)
|
||||||
|
ST_NOSUID* = cint(2)
|
||||||
|
PROT_READ* = cint(1)
|
||||||
|
PROT_WRITE* = cint(2)
|
||||||
|
PROT_EXEC* = cint(4)
|
||||||
|
PROT_NONE* = cint(0)
|
||||||
|
MAP_SHARED* = cint(1)
|
||||||
|
MAP_PRIVATE* = cint(2)
|
||||||
|
MAP_FIXED* = cint(16)
|
||||||
|
MS_ASYNC* = cint(1)
|
||||||
|
MS_SYNC* = cint(4)
|
||||||
|
MS_INVALIDATE* = cint(2)
|
||||||
|
MCL_CURRENT* = cint(1)
|
||||||
|
MCL_FUTURE* = cint(2)
|
||||||
|
MAP_FAILED* = cast[pointer](0xffffffffffffffff)
|
||||||
|
POSIX_MADV_NORMAL* = cint(0)
|
||||||
|
POSIX_MADV_SEQUENTIAL* = cint(2)
|
||||||
|
POSIX_MADV_RANDOM* = cint(1)
|
||||||
|
POSIX_MADV_WILLNEED* = cint(3)
|
||||||
|
POSIX_MADV_DONTNEED* = cint(4)
|
||||||
|
CLOCKS_PER_SEC* = clong(1000000)
|
||||||
|
CLOCK_PROCESS_CPUTIME_ID* = cint(2)
|
||||||
|
CLOCK_THREAD_CPUTIME_ID* = cint(3)
|
||||||
|
CLOCK_REALTIME* = cint(0)
|
||||||
|
TIMER_ABSTIME* = cint(1)
|
||||||
|
CLOCK_MONOTONIC* = cint(1)
|
||||||
|
WNOHANG* = cint(1)
|
||||||
|
WUNTRACED* = cint(2)
|
||||||
|
WEXITED* = cint(4)
|
||||||
|
WSTOPPED* = cint(2)
|
||||||
|
WCONTINUED* = cint(8)
|
||||||
|
WNOWAIT* = cint(16777216)
|
||||||
|
SIGEV_NONE* = cint(1)
|
||||||
|
SIGEV_SIGNAL* = cint(0)
|
||||||
|
SIGEV_THREAD* = cint(2)
|
||||||
|
SIGABRT* = cint(6)
|
||||||
|
SIGALRM* = cint(14)
|
||||||
|
SIGBUS* = cint(7)
|
||||||
|
SIGCHLD* = cint(17)
|
||||||
|
SIGCONT* = cint(18)
|
||||||
|
SIGFPE* = cint(8)
|
||||||
|
SIGHUP* = cint(1)
|
||||||
|
SIGILL* = cint(4)
|
||||||
|
SIGINT* = cint(2)
|
||||||
|
SIGKILL* = cint(9)
|
||||||
|
SIGPIPE* = cint(13)
|
||||||
|
SIGQUIT* = cint(3)
|
||||||
|
SIGSEGV* = cint(11)
|
||||||
|
SIGSTOP* = cint(19)
|
||||||
|
SIGTERM* = cint(15)
|
||||||
|
SIGTSTP* = cint(20)
|
||||||
|
SIGTTIN* = cint(21)
|
||||||
|
SIGTTOU* = cint(22)
|
||||||
|
SIGUSR1* = cint(10)
|
||||||
|
SIGUSR2* = cint(12)
|
||||||
|
SIGPOLL* = cint(29)
|
||||||
|
SIGPROF* = cint(27)
|
||||||
|
SIGSYS* = cint(31)
|
||||||
|
SIGTRAP* = cint(5)
|
||||||
|
SIGURG* = cint(23)
|
||||||
|
SIGVTALRM* = cint(26)
|
||||||
|
SIGXCPU* = cint(24)
|
||||||
|
SIGXFSZ* = cint(25)
|
||||||
|
SA_NOCLDSTOP* = cint(1)
|
||||||
|
SIG_BLOCK* = cint(0)
|
||||||
|
SIG_UNBLOCK* = cint(1)
|
||||||
|
SIG_SETMASK* = cint(2)
|
||||||
|
SA_ONSTACK* = cint(134217728)
|
||||||
|
SA_RESETHAND* = cint(-2147483648)
|
||||||
|
SA_RESTART* = cint(268435456)
|
||||||
|
SA_SIGINFO* = cint(4)
|
||||||
|
SA_NOCLDWAIT* = cint(2)
|
||||||
|
SA_NODEFER* = cint(1073741824)
|
||||||
|
SS_ONSTACK* = cint(1)
|
||||||
|
SS_DISABLE* = cint(2)
|
||||||
|
MINSIGSTKSZ* = cint(2048)
|
||||||
|
SIGSTKSZ* = cint(8192)
|
||||||
|
NL_SETD* = cint(1)
|
||||||
|
NL_CAT_LOCALE* = cint(1)
|
||||||
|
SCHED_FIFO* = cint(1)
|
||||||
|
SCHED_RR* = cint(2)
|
||||||
|
SCHED_OTHER* = cint(0)
|
||||||
|
FD_SETSIZE* = cint(1024)
|
||||||
|
IF_NAMESIZE* = cint(16)
|
||||||
|
SCM_RIGHTS* = cint(1)
|
||||||
|
SOCK_DGRAM* = cint(2)
|
||||||
|
SOCK_RAW* = cint(3)
|
||||||
|
SOCK_SEQPACKET* = cint(5)
|
||||||
|
SOCK_STREAM* = cint(1)
|
||||||
|
SOL_SOCKET* = cint(1)
|
||||||
|
SO_ACCEPTCONN* = cint(30)
|
||||||
|
SO_BROADCAST* = cint(6)
|
||||||
|
SO_DEBUG* = cint(1)
|
||||||
|
SO_DONTROUTE* = cint(5)
|
||||||
|
SO_ERROR* = cint(4)
|
||||||
|
SO_KEEPALIVE* = cint(9)
|
||||||
|
SO_LINGER* = cint(13)
|
||||||
|
SO_OOBINLINE* = cint(10)
|
||||||
|
SO_RCVBUF* = cint(8)
|
||||||
|
SO_RCVLOWAT* = cint(18)
|
||||||
|
SO_RCVTIMEO* = cint(20)
|
||||||
|
SO_REUSEADDR* = cint(2)
|
||||||
|
SO_SNDBUF* = cint(7)
|
||||||
|
SO_SNDLOWAT* = cint(19)
|
||||||
|
SO_SNDTIMEO* = cint(21)
|
||||||
|
SO_TYPE* = cint(3)
|
||||||
|
SOMAXCONN* = cint(128)
|
||||||
|
MSG_CTRUNC* = cint(8)
|
||||||
|
MSG_DONTROUTE* = cint(4)
|
||||||
|
MSG_EOR* = cint(128)
|
||||||
|
MSG_OOB* = cint(1)
|
||||||
|
MSG_PEEK* = cint(2)
|
||||||
|
MSG_TRUNC* = cint(32)
|
||||||
|
MSG_WAITALL* = cint(256)
|
||||||
|
AF_INET* = cint(2)
|
||||||
|
AF_INET6* = cint(10)
|
||||||
|
AF_UNIX* = cint(1)
|
||||||
|
AF_UNSPEC* = cint(0)
|
||||||
|
SHUT_RD* = cint(0)
|
||||||
|
SHUT_RDWR* = cint(2)
|
||||||
|
SHUT_WR* = cint(1)
|
||||||
|
IPPROTO_IP* = cint(0)
|
||||||
|
IPPROTO_IPV6* = cint(41)
|
||||||
|
IPPROTO_ICMP* = cint(1)
|
||||||
|
IPPROTO_RAW* = cint(255)
|
||||||
|
IPPROTO_TCP* = cint(6)
|
||||||
|
IPPROTO_UDP* = cint(17)
|
||||||
|
INADDR_ANY* = cint(0)
|
||||||
|
INADDR_BROADCAST* = cint(-1)
|
||||||
|
INET_ADDRSTRLEN* = cint(16)
|
||||||
|
IPV6_JOIN_GROUP* = cint(20)
|
||||||
|
IPV6_LEAVE_GROUP* = cint(21)
|
||||||
|
IPV6_MULTICAST_HOPS* = cint(18)
|
||||||
|
IPV6_MULTICAST_IF* = cint(17)
|
||||||
|
IPV6_MULTICAST_LOOP* = cint(19)
|
||||||
|
IPV6_UNICAST_HOPS* = cint(16)
|
||||||
|
IPV6_V6ONLY* = cint(26)
|
||||||
|
IPPORT_RESERVED* = cint(1024)
|
||||||
|
HOST_NOT_FOUND* = cint(1)
|
||||||
|
NO_DATA* = cint(4)
|
||||||
|
NO_RECOVERY* = cint(3)
|
||||||
|
TRY_AGAIN* = cint(2)
|
||||||
|
AI_PASSIVE* = cint(1)
|
||||||
|
AI_CANONNAME* = cint(2)
|
||||||
|
AI_NUMERICHOST* = cint(4)
|
||||||
|
AI_NUMERICSERV* = cint(1024)
|
||||||
|
AI_V4MAPPED* = cint(8)
|
||||||
|
AI_ALL* = cint(16)
|
||||||
|
AI_ADDRCONFIG* = cint(32)
|
||||||
|
NI_NOFQDN* = cint(4)
|
||||||
|
NI_NUMERICHOST* = cint(1)
|
||||||
|
NI_NAMEREQD* = cint(8)
|
||||||
|
NI_NUMERICSERV* = cint(2)
|
||||||
|
NI_DGRAM* = cint(16)
|
||||||
|
EAI_AGAIN* = cint(-3)
|
||||||
|
EAI_BADFLAGS* = cint(-1)
|
||||||
|
EAI_FAIL* = cint(-4)
|
||||||
|
EAI_FAMILY* = cint(-6)
|
||||||
|
EAI_MEMORY* = cint(-10)
|
||||||
|
EAI_NONAME* = cint(-2)
|
||||||
|
EAI_SERVICE* = cint(-8)
|
||||||
|
EAI_SOCKTYPE* = cint(-7)
|
||||||
|
EAI_SYSTEM* = cint(-11)
|
||||||
|
EAI_OVERFLOW* = cint(-12)
|
||||||
|
POLLIN* = cshort(1)
|
||||||
|
POLLPRI* = cshort(2)
|
||||||
|
POLLOUT* = cshort(4)
|
||||||
|
POLLERR* = cshort(8)
|
||||||
|
POLLHUP* = cshort(16)
|
||||||
|
POLLNVAL* = cshort(32)
|
||||||
|
POSIX_SPAWN_RESETIDS* = cint(1)
|
||||||
|
POSIX_SPAWN_SETPGROUP* = cint(2)
|
||||||
|
POSIX_SPAWN_SETSCHEDPARAM* = cint(16)
|
||||||
|
POSIX_SPAWN_SETSCHEDULER* = cint(32)
|
||||||
|
POSIX_SPAWN_SETSIGDEF* = cint(4)
|
||||||
|
POSIX_SPAWN_SETSIGMASK* = cint(8)
|
||||||
10
tests/curltest.nim
Normal file
10
tests/curltest.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
import
|
||||||
|
libcurl
|
||||||
|
|
||||||
|
var hCurl = curl_easy_init()
|
||||||
|
if hCurl != nil:
|
||||||
|
discard curl_easy_setopt(hCurl, CURLOPT_VERBOSE, True)
|
||||||
|
discard curl_easy_setopt(hCurl, CURLOPT_URL, "http://nimrod.ethexor.com")
|
||||||
|
discard curl_easy_perform(hCurl)
|
||||||
|
curl_easy_cleanup(hCurl)
|
||||||
|
|
||||||
249
tests/md5.nim
Normal file
249
tests/md5.nim
Normal file
|
|
@ -0,0 +1,249 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Nimrod's Runtime Library
|
||||||
|
# (c) Copyright 2009 Andreas Rumpf
|
||||||
|
#
|
||||||
|
# See the file "copying.txt", included in this
|
||||||
|
# distribution, for details about the copyright.
|
||||||
|
#
|
||||||
|
|
||||||
|
## Module for computing MD5 checksums.
|
||||||
|
|
||||||
|
type
|
||||||
|
MD5State = array[0..3, int32]
|
||||||
|
MD5Block = array[0..15, int32]
|
||||||
|
MD5CBits = array[0..7, int8]
|
||||||
|
MD5Digest* = array[0..15, int8]
|
||||||
|
MD5Buffer = array[0..63, int8]
|
||||||
|
MD5Context* {.final.} = object
|
||||||
|
State: MD5State
|
||||||
|
Count: array[0..1, int32]
|
||||||
|
Buffer: MD5Buffer
|
||||||
|
|
||||||
|
const
|
||||||
|
padding: cstring = "\x80\0\0\0" &
|
||||||
|
"\0\0\0\0\0\0\0\0" &
|
||||||
|
"\0\0\0\0\0\0\0\0" &
|
||||||
|
"\0\0\0\0\0\0\0\0" &
|
||||||
|
"\0\0\0\0\0\0\0\0" &
|
||||||
|
"\0\0\0\0\0\0\0\0" &
|
||||||
|
"\0\0\0\0\0\0\0\0" &
|
||||||
|
"\0\0\0\0\0\0\0\0" &
|
||||||
|
"\0\0\0\0"
|
||||||
|
|
||||||
|
proc F(x, y, z: int32): int32 {.inline.} =
|
||||||
|
Result = (x and y) or ((not x) and z)
|
||||||
|
|
||||||
|
proc G(x, y, z: int32): int32 {.inline.} =
|
||||||
|
Result = (x and z) or (y and (not z))
|
||||||
|
|
||||||
|
proc H(x, y, z: int32): int32 {.inline.} =
|
||||||
|
Result = x xor y xor z
|
||||||
|
|
||||||
|
proc I(x, y, z: int32): int32 {.inline.} =
|
||||||
|
Result = y xor (x or (not z))
|
||||||
|
|
||||||
|
proc rot(x: var int32, n: int8) {.inline.} =
|
||||||
|
x = toU32(x shl ze(n)) or (x shr toU32(32 -% ze(n)))
|
||||||
|
|
||||||
|
proc FF(a: var int32, b, c, d, x: int32, s: int8, ac: int32) =
|
||||||
|
a = a +% F(b, c, d) +% x +% ac
|
||||||
|
rot(a, s)
|
||||||
|
a = a +% b
|
||||||
|
|
||||||
|
proc GG(a: var int32, b, c, d, x: int32, s: int8, ac: int32) =
|
||||||
|
a = a +% G(b, c, d) +% x +% ac
|
||||||
|
rot(a, s)
|
||||||
|
a = a +% b
|
||||||
|
|
||||||
|
proc HH(a: var int32, b, c, d, x: int32, s: int8, ac: int32) =
|
||||||
|
a = a +% H(b, c, d) +% x +% ac
|
||||||
|
rot(a, s)
|
||||||
|
a = a +% b
|
||||||
|
|
||||||
|
proc II(a: var int32, b, c, d, x: int32, s: int8, ac: int32) =
|
||||||
|
a = a +% I(b, c, d) +% x +% ac
|
||||||
|
rot(a, s)
|
||||||
|
a = a +% b
|
||||||
|
|
||||||
|
proc encode(dest: var MD5Block, src: cstring) =
|
||||||
|
var j = 0
|
||||||
|
for i in 0..high(dest):
|
||||||
|
dest[i] = toU32(ord(src[j]) or
|
||||||
|
ord(src[j+1]) shl 8 or
|
||||||
|
ord(src[j+2]) shl 16 or
|
||||||
|
ord(src[j+3]) shl 24)
|
||||||
|
inc(j, 4)
|
||||||
|
|
||||||
|
proc decode(dest: var openarray[int8], src: openarray[int32]) =
|
||||||
|
var i = 0
|
||||||
|
for j in 0..high(src):
|
||||||
|
dest[i] = toU8(src[j] and 0xff'i32)
|
||||||
|
dest[i+1] = toU8(src[j] shr 8'i32 and 0xff'i32)
|
||||||
|
dest[i+2] = toU8(src[j] shr 16'i32 and 0xff'i32)
|
||||||
|
dest[i+3] = toU8(src[j] shr 24'i32 and 0xff'i32)
|
||||||
|
inc(i, 4)
|
||||||
|
|
||||||
|
proc transform(Buffer: pointer, State: var MD5State) =
|
||||||
|
var
|
||||||
|
myBlock: MD5Block
|
||||||
|
encode(myBlock, cast[cstring](buffer))
|
||||||
|
var a = State[0]
|
||||||
|
var b = State[1]
|
||||||
|
var c = State[2]
|
||||||
|
var d = State[3]
|
||||||
|
FF(a, b, c, d, myBlock[0], 7'i8, 0xD76AA478'i32)
|
||||||
|
FF(d, a, b, c, myBlock[1], 12'i8, 0xE8C7B756'i32)
|
||||||
|
FF(c, d, a, b, myBlock[2], 17'i8, 0x242070DB'i32)
|
||||||
|
FF(b, c, d, a, myBlock[3], 22'i8, 0xC1BDCEEE'i32)
|
||||||
|
FF(a, b, c, d, myBlock[4], 7'i8, 0xF57C0FAF'i32)
|
||||||
|
FF(d, a, b, c, myBlock[5], 12'i8, 0x4787C62A'i32)
|
||||||
|
FF(c, d, a, b, myBlock[6], 17'i8, 0xA8304613'i32)
|
||||||
|
FF(b, c, d, a, myBlock[7], 22'i8, 0xFD469501'i32)
|
||||||
|
FF(a, b, c, d, myBlock[8], 7'i8, 0x698098D8'i32)
|
||||||
|
FF(d, a, b, c, myBlock[9], 12'i8, 0x8B44F7AF'i32)
|
||||||
|
FF(c, d, a, b, myBlock[10], 17'i8, 0xFFFF5BB1'i32)
|
||||||
|
FF(b, c, d, a, myBlock[11], 22'i8, 0x895CD7BE'i32)
|
||||||
|
FF(a, b, c, d, myBlock[12], 7'i8, 0x6B901122'i32)
|
||||||
|
FF(d, a, b, c, myBlock[13], 12'i8, 0xFD987193'i32)
|
||||||
|
FF(c, d, a, b, myBlock[14], 17'i8, 0xA679438E'i32)
|
||||||
|
FF(b, c, d, a, myBlock[15], 22'i8, 0x49B40821'i32)
|
||||||
|
GG(a, b, c, d, myBlock[1], 5'i8, 0xF61E2562'i32)
|
||||||
|
GG(d, a, b, c, myBlock[6], 9'i8, 0xC040B340'i32)
|
||||||
|
GG(c, d, a, b, myBlock[11], 14'i8, 0x265E5A51'i32)
|
||||||
|
GG(b, c, d, a, myBlock[0], 20'i8, 0xE9B6C7AA'i32)
|
||||||
|
GG(a, b, c, d, myBlock[5], 5'i8, 0xD62F105D'i32)
|
||||||
|
GG(d, a, b, c, myBlock[10], 9'i8, 0x02441453'i32)
|
||||||
|
GG(c, d, a, b, myBlock[15], 14'i8, 0xD8A1E681'i32)
|
||||||
|
GG(b, c, d, a, myBlock[4], 20'i8, 0xE7D3FBC8'i32)
|
||||||
|
GG(a, b, c, d, myBlock[9], 5'i8, 0x21E1CDE6'i32)
|
||||||
|
GG(d, a, b, c, myBlock[14], 9'i8, 0xC33707D6'i32)
|
||||||
|
GG(c, d, a, b, myBlock[3], 14'i8, 0xF4D50D87'i32)
|
||||||
|
GG(b, c, d, a, myBlock[8], 20'i8, 0x455A14ED'i32)
|
||||||
|
GG(a, b, c, d, myBlock[13], 5'i8, 0xA9E3E905'i32)
|
||||||
|
GG(d, a, b, c, myBlock[2], 9'i8, 0xFCEFA3F8'i32)
|
||||||
|
GG(c, d, a, b, myBlock[7], 14'i8, 0x676F02D9'i32)
|
||||||
|
GG(b, c, d, a, myBlock[12], 20'i8, 0x8D2A4C8A'i32)
|
||||||
|
HH(a, b, c, d, myBlock[5], 4'i8, 0xFFFA3942'i32)
|
||||||
|
HH(d, a, b, c, myBlock[8], 11'i8, 0x8771F681'i32)
|
||||||
|
HH(c, d, a, b, myBlock[11], 16'i8, 0x6D9D6122'i32)
|
||||||
|
HH(b, c, d, a, myBlock[14], 23'i8, 0xFDE5380C'i32)
|
||||||
|
HH(a, b, c, d, myBlock[1], 4'i8, 0xA4BEEA44'i32)
|
||||||
|
HH(d, a, b, c, myBlock[4], 11'i8, 0x4BDECFA9'i32)
|
||||||
|
HH(c, d, a, b, myBlock[7], 16'i8, 0xF6BB4B60'i32)
|
||||||
|
HH(b, c, d, a, myBlock[10], 23'i8, 0xBEBFBC70'i32)
|
||||||
|
HH(a, b, c, d, myBlock[13], 4'i8, 0x289B7EC6'i32)
|
||||||
|
HH(d, a, b, c, myBlock[0], 11'i8, 0xEAA127FA'i32)
|
||||||
|
HH(c, d, a, b, myBlock[3], 16'i8, 0xD4EF3085'i32)
|
||||||
|
HH(b, c, d, a, myBlock[6], 23'i8, 0x04881D05'i32)
|
||||||
|
HH(a, b, c, d, myBlock[9], 4'i8, 0xD9D4D039'i32)
|
||||||
|
HH(d, a, b, c, myBlock[12], 11'i8, 0xE6DB99E5'i32)
|
||||||
|
HH(c, d, a, b, myBlock[15], 16'i8, 0x1FA27CF8'i32)
|
||||||
|
HH(b, c, d, a, myBlock[2], 23'i8, 0xC4AC5665'i32)
|
||||||
|
II(a, b, c, d, myBlock[0], 6'i8, 0xF4292244'i32)
|
||||||
|
II(d, a, b, c, myBlock[7], 10'i8, 0x432AFF97'i32)
|
||||||
|
II(c, d, a, b, myBlock[14], 15'i8, 0xAB9423A7'i32)
|
||||||
|
II(b, c, d, a, myBlock[5], 21'i8, 0xFC93A039'i32)
|
||||||
|
II(a, b, c, d, myBlock[12], 6'i8, 0x655B59C3'i32)
|
||||||
|
II(d, a, b, c, myBlock[3], 10'i8, 0x8F0CCC92'i32)
|
||||||
|
II(c, d, a, b, myBlock[10], 15'i8, 0xFFEFF47D'i32)
|
||||||
|
II(b, c, d, a, myBlock[1], 21'i8, 0x85845DD1'i32)
|
||||||
|
II(a, b, c, d, myBlock[8], 6'i8, 0x6FA87E4F'i32)
|
||||||
|
II(d, a, b, c, myBlock[15], 10'i8, 0xFE2CE6E0'i32)
|
||||||
|
II(c, d, a, b, myBlock[6], 15'i8, 0xA3014314'i32)
|
||||||
|
II(b, c, d, a, myBlock[13], 21'i8, 0x4E0811A1'i32)
|
||||||
|
II(a, b, c, d, myBlock[4], 6'i8, 0xF7537E82'i32)
|
||||||
|
II(d, a, b, c, myBlock[11], 10'i8, 0xBD3AF235'i32)
|
||||||
|
II(c, d, a, b, myBlock[2], 15'i8, 0x2AD7D2BB'i32)
|
||||||
|
II(b, c, d, a, myBlock[9], 21'i8, 0xEB86D391'i32)
|
||||||
|
State[0] = State[0] +% a
|
||||||
|
State[1] = State[1] +% b
|
||||||
|
State[2] = State[2] +% c
|
||||||
|
State[3] = State[3] +% d
|
||||||
|
|
||||||
|
proc MD5Init*(c: var MD5Context) =
|
||||||
|
## initializes a MD5Context
|
||||||
|
c.State[0] = 0x67452301'i32
|
||||||
|
c.State[1] = 0xEFCDAB89'i32
|
||||||
|
c.State[2] = 0x98BADCFE'i32
|
||||||
|
c.State[3] = 0x10325476'i32
|
||||||
|
c.Count[0] = 0'i32
|
||||||
|
c.Count[1] = 0'i32
|
||||||
|
ZeroMem(addr(c.Buffer), SizeOf(MD5Buffer))
|
||||||
|
|
||||||
|
proc MD5Update*(c: var MD5Context, input: cstring, len: int) =
|
||||||
|
## updates the MD5Context with the `input` data of length `len`
|
||||||
|
var input = input
|
||||||
|
var Index = (c.Count[0] shr 3) and 0x3F
|
||||||
|
c.Count[0] = c.count[0] +% toU32(len shl 3)
|
||||||
|
if c.Count[0] < (len shl 3): c.Count[1] = c.count[1] +% 1'i32
|
||||||
|
c.Count[1] = c.count[1] +% toU32(len shr 29)
|
||||||
|
var PartLen = 64 - Index
|
||||||
|
if len >= PartLen:
|
||||||
|
CopyMem(addr(c.Buffer[Index]), Input, PartLen)
|
||||||
|
transform(addr(c.Buffer), c.State)
|
||||||
|
var i = PartLen
|
||||||
|
while i + 63 < len:
|
||||||
|
Transform(addr(Input[I]), c.State)
|
||||||
|
inc(i, 64)
|
||||||
|
CopyMem(addr(c.Buffer[0]), addr(Input[i]), len-i)
|
||||||
|
else:
|
||||||
|
CopyMem(addr(c.Buffer[Index]), addr(Input[0]), len)
|
||||||
|
|
||||||
|
proc MD5Final*(c: var MD5Context, digest: var MD5Digest) =
|
||||||
|
## finishes the MD5Context and stores the result in `digest`
|
||||||
|
var
|
||||||
|
Bits: MD5CBits
|
||||||
|
PadLen: int
|
||||||
|
decode(bits, c.Count)
|
||||||
|
var Index = (c.Count[0] shr 3) and 0x3F
|
||||||
|
if Index < 56: PadLen = 56 - Index
|
||||||
|
else: PadLen = 120 - Index
|
||||||
|
MD5Update(c, padding, PadLen)
|
||||||
|
MD5Update(c, cast[cstring](addr(Bits)), 8)
|
||||||
|
decode(digest, c.State)
|
||||||
|
ZeroMem(addr(c), SizeOf(MD5Context))
|
||||||
|
|
||||||
|
proc toMD5*(s: string): MD5Digest =
|
||||||
|
## computes the MD5Digest value for a string `s`
|
||||||
|
var c: MD5Context
|
||||||
|
MD5Init(c)
|
||||||
|
MD5Update(c, cstring(s), len(s))
|
||||||
|
MD5Final(c, result)
|
||||||
|
|
||||||
|
proc `$`*(D: MD5Digest): string =
|
||||||
|
## converts a MD5Digest value into its string representation
|
||||||
|
const digits = "0123456789abcdef"
|
||||||
|
result = ""
|
||||||
|
for i in 0..15:
|
||||||
|
add(result, Digits[(D[I] shr 4) and 0xF])
|
||||||
|
add(result, Digits[D[I] and 0xF])
|
||||||
|
|
||||||
|
proc myMD5*(s: string): string =
|
||||||
|
var
|
||||||
|
c: MD5Context
|
||||||
|
d: MD5Digest
|
||||||
|
MD5Init(c)
|
||||||
|
MD5Update(c, cstring(s), len(s))
|
||||||
|
MD5Final(c, d)
|
||||||
|
result = $d
|
||||||
|
|
||||||
|
proc `==`*(D1, D2: MD5Digest): bool =
|
||||||
|
## checks if two MD5Digest values are identical
|
||||||
|
for i in 0..15:
|
||||||
|
if D1[i] != D2[i]: return false
|
||||||
|
return true
|
||||||
|
|
||||||
|
var x = myMD5("Franz jagt im komplett verwahrlosten Taxi quer durch Bayern")
|
||||||
|
assert(x == "a3cca2b2aa1e3b5b3b5aad99a8529074")
|
||||||
|
|
||||||
|
md5("Frank jagt im komplett verwahrlosten Taxi quer durch Bayern") =
|
||||||
|
7e716d0e702df0505fc72e2b89467910
|
||||||
|
|
||||||
|
Der Hash einer Zeichenfolge der Länge Null ist:
|
||||||
|
|
||||||
|
md5("") = d41d8cd98f00b204e9800998ecf8427e
|
||||||
|
|
||||||
|
|
||||||
|
echo x
|
||||||
|
|
||||||
9
tests/mrecmod2.nim
Normal file
9
tests/mrecmod2.nim
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Module B
|
||||||
|
import trecmod2
|
||||||
|
|
||||||
|
proc p*(x: trecmod2.T1): trecmod2.T1 =
|
||||||
|
# this works because the compiler has already
|
||||||
|
# added T1 to trecmod2's interface symbol table
|
||||||
|
return x + 1
|
||||||
|
|
||||||
|
|
||||||
59
tests/tbintree.nim
Normal file
59
tests/tbintree.nim
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
type
|
||||||
|
TBinaryTree[T] = object # TBinaryTree is a generic type with
|
||||||
|
# with generic param ``T``
|
||||||
|
le, ri: ref TBinaryTree[T] # left and right subtrees; may be nil
|
||||||
|
data: T # the data stored in a node
|
||||||
|
PBinaryTree*[T] = ref TBinaryTree[T] # type that is exported
|
||||||
|
|
||||||
|
proc newNode*[T](data: T): PBinaryTree[T] =
|
||||||
|
# constructor for a node
|
||||||
|
new(result)
|
||||||
|
result.dat = data
|
||||||
|
|
||||||
|
proc add*[T](root: var PBinaryTree[T], n: PBinaryTree[T]) =
|
||||||
|
# insert a node into the tree
|
||||||
|
if root == nil:
|
||||||
|
root = n
|
||||||
|
else:
|
||||||
|
var it = root
|
||||||
|
while it != nil:
|
||||||
|
# compare the data items; uses the generic ``cmd`` proc that works for
|
||||||
|
# any type that has a ``==`` and ``<`` operator
|
||||||
|
var c = cmp(it.data, n.data)
|
||||||
|
if c < 0:
|
||||||
|
if it.le == nil:
|
||||||
|
it.le = n
|
||||||
|
return
|
||||||
|
it = it.le
|
||||||
|
else:
|
||||||
|
if it.ri == nil:
|
||||||
|
it.ri = n
|
||||||
|
return
|
||||||
|
it = it.ri
|
||||||
|
|
||||||
|
proc add*[T](root: var PBinaryTree[T], data: T) =
|
||||||
|
# convenience proc:
|
||||||
|
add(root, newNode(data))
|
||||||
|
|
||||||
|
iterator preorder*[T](root: PBinaryTree[T]): T =
|
||||||
|
# Preorder traversal of a binary tree.
|
||||||
|
# Since recursive iterators are not yet implemented,
|
||||||
|
# this uses an explicit stack:
|
||||||
|
var stack: seq[PBinaryTree[T]] = @[root]
|
||||||
|
while stack.len > 0:
|
||||||
|
var n = stack[stack.len-1]
|
||||||
|
setLen(stack, stack.len-1) # pop `n` of the stack
|
||||||
|
while n != nil:
|
||||||
|
yield n
|
||||||
|
add(stack, n.ri) # push right subtree onto the stack
|
||||||
|
n = n.le # and follow the left pointer
|
||||||
|
|
||||||
|
var
|
||||||
|
root: PBinaryTree[string] # instantiate a PBinaryTree with the type string
|
||||||
|
add(root, newNode("hallo")) # instantiates generic procs ``newNode`` and ``add``
|
||||||
|
#add(root, "world") # instantiates the second ``add`` proc
|
||||||
|
#for str in preorder(root):
|
||||||
|
# stdout.writeln(str)
|
||||||
|
|
||||||
|
#OUT halloworld
|
||||||
|
|
||||||
25
tests/tclosure.nim
Normal file
25
tests/tclosure.nim
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Test the closure implementation
|
||||||
|
|
||||||
|
proc map(n: var openarray[int], fn: proc (x: int): int {.closure}) =
|
||||||
|
for i in 0..n.len-1:
|
||||||
|
n[i] = fn(n[i])
|
||||||
|
|
||||||
|
proc foldr(n: openarray[int], fn: proc (x, y: int): int {.closure}): int =
|
||||||
|
result = 0
|
||||||
|
for i in 0..n.len-1:
|
||||||
|
result = fn(result, n[i])
|
||||||
|
|
||||||
|
var
|
||||||
|
myData: array[0..9, int] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
|
|
||||||
|
proc testA() =
|
||||||
|
var p = 0
|
||||||
|
map(myData, lambda (x: int): int =
|
||||||
|
result = x + 1 shl (lambda (y: int): int =
|
||||||
|
return y + 1
|
||||||
|
)(0)
|
||||||
|
inc(p), 88)
|
||||||
|
|
||||||
|
testA()
|
||||||
|
for x in items(myData):
|
||||||
|
echo x
|
||||||
3
tests/techo.nim
Normal file
3
tests/techo.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Simplest Nimrod program
|
||||||
|
|
||||||
|
echo "Hallo, World!"
|
||||||
10
tests/titer2.nim
Normal file
10
tests/titer2.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Try to break the transformation pass:
|
||||||
|
iterator iterAndZero(a: var openArray[int]): int =
|
||||||
|
for i in 0..len(a)-1:
|
||||||
|
yield a[i]
|
||||||
|
a[i] = 0
|
||||||
|
|
||||||
|
var x = [[1, 2, 3], [4, 5, 6]]
|
||||||
|
for y in iterAndZero(x[0]): write(stdout, $y)
|
||||||
|
#OUT 123
|
||||||
|
|
||||||
15
tests/tnot.nim
Normal file
15
tests/tnot.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# BUG: following compiles, but should not:
|
||||||
|
|
||||||
|
proc nodeOfDegree(x: Int): bool =
|
||||||
|
result = false
|
||||||
|
|
||||||
|
proc main =
|
||||||
|
for j in 0..2:
|
||||||
|
for i in 0..10:
|
||||||
|
if not nodeOfDegree(1) >= 0: #ERROR
|
||||||
|
Echo "Yes"
|
||||||
|
else:
|
||||||
|
Echo "No"
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
82
tests/toop1.nim
Normal file
82
tests/toop1.nim
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
# Test the stuff in the tutorial
|
||||||
|
import macros
|
||||||
|
|
||||||
|
type
|
||||||
|
TFigure = object of TObject # abstract base class:
|
||||||
|
draw: proc (my: var TFigure) # concrete classes implement this proc
|
||||||
|
|
||||||
|
proc init(f: var TFigure) =
|
||||||
|
f.draw = nil
|
||||||
|
|
||||||
|
type
|
||||||
|
TCircle = object of TFigure
|
||||||
|
radius: int
|
||||||
|
|
||||||
|
proc drawCircle(my: var TCircle) = stdout.writeln("o " & $my.radius)
|
||||||
|
|
||||||
|
proc init(my: var TCircle) =
|
||||||
|
init(TFigure(my)) # call base constructor
|
||||||
|
my.radius = 5
|
||||||
|
my.draw = drawCircle
|
||||||
|
|
||||||
|
type
|
||||||
|
TRectangle = object of TFigure
|
||||||
|
width, height: int
|
||||||
|
|
||||||
|
proc drawRectangle(my: var TRectangle) = stdout.write("[]")
|
||||||
|
|
||||||
|
proc init(my: var TRectangle) =
|
||||||
|
init(TFigure(my)) # call base constructor
|
||||||
|
my.width = 5
|
||||||
|
my.height = 10
|
||||||
|
my.draw = drawRectangle
|
||||||
|
|
||||||
|
macro `!` (n: expr): expr =
|
||||||
|
result = newNimNode(nnkCall, n)
|
||||||
|
var dot = newNimNode(nnkDotExpr, n)
|
||||||
|
dot.add(n[1]) # obj
|
||||||
|
if n[2].kind == nnkCall:
|
||||||
|
# transforms ``obj!method(arg1, arg2, ...)`` to
|
||||||
|
# ``(obj.method)(obj, arg1, arg2, ...)``
|
||||||
|
dot.add(n[2][0]) # method
|
||||||
|
result.add(dot)
|
||||||
|
result.add(n[1]) # obj
|
||||||
|
for i in 1..n[2].len-1:
|
||||||
|
result.add(n[2][i])
|
||||||
|
else:
|
||||||
|
# transforms ``obj!method`` to
|
||||||
|
# ``(obj.method)(obj)``
|
||||||
|
dot.add(n[2]) # method
|
||||||
|
result.add(dot)
|
||||||
|
result.add(n[1]) # obj
|
||||||
|
|
||||||
|
type
|
||||||
|
TSocket* = object of TObject
|
||||||
|
FHost: int # cannot be accessed from the outside of the module
|
||||||
|
# the `F` prefix is a convention to avoid clashes since
|
||||||
|
# the accessors are named `host`
|
||||||
|
|
||||||
|
proc `host=`*(s: var TSocket, value: int) {.inline.} =
|
||||||
|
## setter of hostAddr
|
||||||
|
s.FHost = value
|
||||||
|
|
||||||
|
proc host*(s: TSocket): int {.inline.} =
|
||||||
|
## getter of hostAddr
|
||||||
|
return s.FHost
|
||||||
|
|
||||||
|
var
|
||||||
|
s: TSocket
|
||||||
|
s.host = 34 # same as `host=`(s, 34)
|
||||||
|
stdout.write(s.host)
|
||||||
|
|
||||||
|
# now use these classes:
|
||||||
|
var
|
||||||
|
r: TRectangle
|
||||||
|
c: TCircle
|
||||||
|
init(r)
|
||||||
|
init(c)
|
||||||
|
r!draw
|
||||||
|
c!draw()
|
||||||
|
|
||||||
|
#OUT 34[]o 5
|
||||||
|
|
||||||
5
tests/topena1.nim
Normal file
5
tests/topena1.nim
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Tests a special bug
|
||||||
|
|
||||||
|
var
|
||||||
|
x: ref openarray[string] #ERROR_MSG invalid type
|
||||||
|
|
||||||
10
tests/trecmod2.nim
Normal file
10
tests/trecmod2.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
type
|
||||||
|
T1* = int # Module A exports the type ``T1``
|
||||||
|
|
||||||
|
import mrecmod2 # the compiler starts parsing B
|
||||||
|
|
||||||
|
proc main() =
|
||||||
|
var i = p(3) # works because B has been parsed completely here
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
13
tests/tseq2.nim
Normal file
13
tests/tseq2.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
|
||||||
|
proc `*` *(a, b: seq[int]): seq[int] =
|
||||||
|
# allocate a new sequence:
|
||||||
|
newSeq(result, len(a))
|
||||||
|
# multiply two int sequences:
|
||||||
|
for i in 0..len(a)-1: result[i] = a[i] * b[i]
|
||||||
|
|
||||||
|
when isMainModule:
|
||||||
|
# test the new ``*`` operator for sequences:
|
||||||
|
assert(@[1, 2, 3] * @[1, 2, 3] == @[1, 4, 9])
|
||||||
|
|
||||||
|
|
||||||
8
tests/tsimmeth.nim
Normal file
8
tests/tsimmeth.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Test method simulation
|
||||||
|
|
||||||
|
import strutils
|
||||||
|
|
||||||
|
var x = "hallo world!".toLower.toUpper
|
||||||
|
x.echo()
|
||||||
|
#OUT HALLO WORLD!
|
||||||
|
|
||||||
14
tests/ttempl2.nim
Normal file
14
tests/ttempl2.nim
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
template declareInScope(x: expr, t: typeDesc): stmt =
|
||||||
|
var x: t
|
||||||
|
|
||||||
|
template declareInNewScope(x: expr, t: typeDesc): stmt =
|
||||||
|
# open a new scope:
|
||||||
|
block:
|
||||||
|
var x: t
|
||||||
|
|
||||||
|
declareInScope(a, int)
|
||||||
|
a = 42 # works, `a` is known here
|
||||||
|
|
||||||
|
declareInNewScope(b, int)
|
||||||
|
b = 42 #ERROR_MSG undeclared identifier: 'b'
|
||||||
|
|
||||||
15
tests/ttempl3.nim
Normal file
15
tests/ttempl3.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
template withOpenFile(f, filename, mode: expr, actions: stmt): stmt =
|
||||||
|
block:
|
||||||
|
var f: TFile
|
||||||
|
if openFile(f, filename, mode):
|
||||||
|
try:
|
||||||
|
actions
|
||||||
|
finally:
|
||||||
|
closeFile(f)
|
||||||
|
else:
|
||||||
|
quit("cannot open for writing: " & filename)
|
||||||
|
|
||||||
|
withOpenFile(txt, "ttempl3.txt", fmWrite):
|
||||||
|
writeln(txt, "line 1")
|
||||||
|
txt.writeln("line 2")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue