mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-14 03:25:54 +00:00
preparations for more Nimble packages; clear licensing; fixes #2949
This commit is contained in:
66
doc/lib.txt
66
doc/lib.txt
@@ -394,13 +394,6 @@ Miscellaneous
|
||||
This module implements new experimental features. Currently the syntax
|
||||
sugar for anonymous procedures.
|
||||
|
||||
Database support
|
||||
----------------
|
||||
|
||||
* `redis <redis.html>`_
|
||||
This module implements a redis client. It allows you to connect to a
|
||||
redis-server instance, send commands and receive replies.
|
||||
|
||||
|
||||
Modules for JS backend
|
||||
---------------------------
|
||||
@@ -439,27 +432,10 @@ Database support
|
||||
Other
|
||||
-----
|
||||
|
||||
* `graphics <graphics.html>`_
|
||||
This module implements graphical output for Nim; the current
|
||||
implementation uses SDL but the interface is meant to support multiple
|
||||
backends some day.
|
||||
|
||||
* `dialogs <dialogs.html>`_
|
||||
This module implements portable dialogs for Nim; the implementation
|
||||
builds on the GTK interface. On Windows, native dialogs are shown if
|
||||
appropriate.
|
||||
|
||||
* `zipfiles <zipfiles.html>`_
|
||||
This module implements a zip archive creator/reader/modifier.
|
||||
|
||||
* `ssl <ssl.html>`_
|
||||
This module provides an easy to use sockets-style
|
||||
Nim interface to the OpenSSL library.
|
||||
|
||||
* `rdstdin <rdstdin.html>`_
|
||||
This module contains code for reading from `stdin`:idx:. On UNIX the GNU
|
||||
readline library is wrapped and set up.
|
||||
|
||||
|
||||
Wrappers
|
||||
========
|
||||
@@ -470,20 +446,8 @@ not contained in the distribution. You can then find them on the website.
|
||||
Windows specific
|
||||
----------------
|
||||
|
||||
* `windows <windows.html>`_
|
||||
Contains a wrapper for the Win32 API.
|
||||
* `winlean <winlean.html>`_
|
||||
Contains a wrapper for a small subset of the Win32 API.
|
||||
* `shellapi <shellapi.html>`_
|
||||
Contains a wrapper for the ``shellapi.h`` header.
|
||||
* `shfolder <shfolder.html>`_
|
||||
Contains a wrapper for the ``shfolder.h`` header.
|
||||
* `mmsystem <mmsystem.html>`_
|
||||
Contains a wrapper for the ``mmsystem.h`` header.
|
||||
* `psapi <psapi.html>`_
|
||||
Contains a wrapper for the ``psapi.h`` header.
|
||||
* `nb30 <nb30.html>`_
|
||||
This module contains the definitions for portable NetBIOS 3.0 support.
|
||||
|
||||
|
||||
UNIX specific
|
||||
@@ -491,12 +455,6 @@ UNIX specific
|
||||
|
||||
* `posix <posix.html>`_
|
||||
Contains a wrapper for the POSIX standard.
|
||||
* `readline <readline.html>`_
|
||||
Part of the wrapper for the GNU readline library.
|
||||
* `history <history.html>`_
|
||||
Part of the wrapper for the GNU readline library.
|
||||
* `rltypedefs <rltypedefs.html>`_
|
||||
Part of the wrapper for the GNU readline library.
|
||||
|
||||
|
||||
Regular expressions
|
||||
@@ -504,8 +462,6 @@ Regular expressions
|
||||
|
||||
* `pcre <pcre.html>`_
|
||||
Wrapper for the PCRE library.
|
||||
* `tre <tre.html>`_
|
||||
Wrapper for the TRE library.
|
||||
|
||||
|
||||
GUI libraries
|
||||
@@ -526,15 +482,6 @@ Database support
|
||||
Contains a wrapper for SQLite 3 API.
|
||||
* `odbcsql <odbcsql.html>`_
|
||||
interface to the ODBC driver.
|
||||
* `sphinx <sphinx.html>`_
|
||||
Nim wrapper for ``sphinx``.
|
||||
|
||||
|
||||
XML Processing
|
||||
--------------
|
||||
|
||||
* `expat <expat.html>`_
|
||||
Wrapper of the expat XML parser.
|
||||
|
||||
|
||||
Network Programming and Internet Protocols
|
||||
@@ -553,16 +500,6 @@ Network Programming and Internet Protocols
|
||||
Wrapper for OpenSSL.
|
||||
|
||||
|
||||
Data Compression and Archiving
|
||||
------------------------------
|
||||
|
||||
* `zlib <zlib.html>`_
|
||||
Wrapper for the zlib library.
|
||||
|
||||
* `libzip <libzip.html>`_
|
||||
Interface to the `lib zip <http://www.nih.at/libzip/index.html>`_ library by
|
||||
Dieter Baron and Thomas Klausner.
|
||||
|
||||
|
||||
Scientific computing
|
||||
--------------------
|
||||
@@ -570,8 +507,9 @@ Scientific computing
|
||||
* `libsvm <libsvm.html>`_
|
||||
Low level wrapper for `lib svm <http://www.csie.ntu.edu.tw/~cjlin/libsvm/>`_.
|
||||
|
||||
|
||||
Nimble
|
||||
====================
|
||||
======
|
||||
|
||||
Nimble is a package manager for the Nim programming language.
|
||||
For instructions on how to install Nimble packages see
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2012 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module implements a zip archive creator/reader/modifier.
|
||||
|
||||
import
|
||||
streams, libzip, times, os, strutils
|
||||
|
||||
type
|
||||
ZipArchive* = object of RootObj ## represents a zip archive
|
||||
mode: FileMode
|
||||
w: PZip
|
||||
{.deprecated: [TZipArchive: ZipArchive].}
|
||||
|
||||
proc zipError(z: var ZipArchive) =
|
||||
var e: ref IOError
|
||||
new(e)
|
||||
e.msg = $zip_strerror(z.w)
|
||||
raise e
|
||||
|
||||
proc open*(z: var ZipArchive, filename: string, mode: FileMode = fmRead): bool =
|
||||
## Opens a zip file for reading, writing or appending. All file modes are
|
||||
## supported. Returns true iff successful, false otherwise.
|
||||
var err, flags: int32
|
||||
case mode
|
||||
of fmRead, fmReadWriteExisting, fmAppend: flags = 0
|
||||
of fmWrite:
|
||||
if existsFile(filename): removeFile(filename)
|
||||
flags = ZIP_CREATE or ZIP_EXCL
|
||||
of fmReadWrite: flags = ZIP_CREATE
|
||||
z.w = zip_open(filename, flags, addr(err))
|
||||
z.mode = mode
|
||||
result = z.w != nil
|
||||
|
||||
proc close*(z: var ZipArchive) =
|
||||
## Closes a zip file.
|
||||
zip_close(z.w)
|
||||
|
||||
proc createDir*(z: var ZipArchive, dir: string) =
|
||||
## Creates a directory within the `z` archive. This does not fail if the
|
||||
## directory already exists. Note that for adding a file like
|
||||
## ``"path1/path2/filename"`` it is not necessary
|
||||
## to create the ``"path/path2"`` subdirectories - it will be done
|
||||
## automatically by ``addFile``.
|
||||
assert(z.mode != fmRead)
|
||||
discard zip_add_dir(z.w, dir)
|
||||
zip_error_clear(z.w)
|
||||
|
||||
proc addFile*(z: var ZipArchive, dest, src: string) =
|
||||
## Adds the file `src` to the archive `z` with the name `dest`. `dest`
|
||||
## may contain a path that will be created.
|
||||
assert(z.mode != fmRead)
|
||||
if not fileExists(src):
|
||||
raise newException(IOError, "File '" & src & "' does not exist")
|
||||
var zipsrc = zip_source_file(z.w, src, 0, -1)
|
||||
if zipsrc == nil:
|
||||
#echo("Dest: " & dest)
|
||||
#echo("Src: " & src)
|
||||
zipError(z)
|
||||
if zip_add(z.w, dest, zipsrc) < 0'i32:
|
||||
zip_source_free(zipsrc)
|
||||
zipError(z)
|
||||
|
||||
proc addFile*(z: var ZipArchive, file: string) =
|
||||
## A shortcut for ``addFile(z, file, file)``, i.e. the name of the source is
|
||||
## the name of the destination.
|
||||
addFile(z, file, file)
|
||||
|
||||
proc mySourceCallback(state, data: pointer, len: int,
|
||||
cmd: ZipSourceCmd): int {.cdecl.} =
|
||||
var src = cast[Stream](state)
|
||||
case cmd
|
||||
of ZIP_SOURCE_OPEN:
|
||||
if src.setPositionImpl != nil: setPosition(src, 0) # reset
|
||||
of ZIP_SOURCE_READ:
|
||||
result = readData(src, data, len)
|
||||
of ZIP_SOURCE_CLOSE: close(src)
|
||||
of ZIP_SOURCE_STAT:
|
||||
var stat = cast[PZipStat](data)
|
||||
zip_stat_init(stat)
|
||||
stat.size = high(int32)-1 # we don't know the size
|
||||
stat.mtime = getTime()
|
||||
result = sizeof(ZipStat)
|
||||
of ZIP_SOURCE_ERROR:
|
||||
var err = cast[ptr array[0..1, cint]](data)
|
||||
err[0] = ZIP_ER_INTERNAL
|
||||
err[1] = 0
|
||||
result = 2*sizeof(cint)
|
||||
of constZIP_SOURCE_FREE: GC_unref(src)
|
||||
else: assert(false)
|
||||
|
||||
proc addFile*(z: var ZipArchive, dest: string, src: Stream) =
|
||||
## Adds a file named with `dest` to the archive `z`. `dest`
|
||||
## may contain a path. The file's content is read from the `src` stream.
|
||||
assert(z.mode != fmRead)
|
||||
GC_ref(src)
|
||||
var zipsrc = zip_source_function(z.w, mySourceCallback, cast[pointer](src))
|
||||
if zipsrc == nil: zipError(z)
|
||||
if zip_add(z.w, dest, zipsrc) < 0'i32:
|
||||
zip_source_free(zipsrc)
|
||||
zipError(z)
|
||||
|
||||
# -------------- zip file stream ---------------------------------------------
|
||||
|
||||
type
|
||||
TZipFileStream = object of StreamObj
|
||||
f: PZipFile
|
||||
atEnd: bool
|
||||
|
||||
PZipFileStream* =
|
||||
ref TZipFileStream ## a reader stream of a file within a zip archive
|
||||
|
||||
proc fsClose(s: Stream) = zip_fclose(PZipFileStream(s).f)
|
||||
proc fsAtEnd(s: Stream): bool = PZipFileStream(s).atEnd
|
||||
proc fsReadData(s: Stream, buffer: pointer, bufLen: int): int =
|
||||
result = zip_fread(PZipFileStream(s).f, buffer, bufLen)
|
||||
if result == 0:
|
||||
PZipFileStream(s).atEnd = true
|
||||
|
||||
proc newZipFileStream(f: PZipFile): PZipFileStream =
|
||||
new(result)
|
||||
result.f = f
|
||||
result.atEnd = false
|
||||
result.closeImpl = fsClose
|
||||
result.readDataImpl = fsReadData
|
||||
result.atEndImpl = fsAtEnd
|
||||
# other methods are nil!
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
proc getStream*(z: var ZipArchive, filename: string): PZipFileStream =
|
||||
## returns a stream that can be used to read the file named `filename`
|
||||
## from the archive `z`. Returns nil in case of an error.
|
||||
## The returned stream does not support the `setPosition`, `getPosition`,
|
||||
## `writeData` or `atEnd` methods.
|
||||
var x = zip_fopen(z.w, filename, 0'i32)
|
||||
if x != nil: result = newZipFileStream(x)
|
||||
|
||||
iterator walkFiles*(z: var ZipArchive): string =
|
||||
## walks over all files in the archive `z` and returns the filename
|
||||
## (including the path).
|
||||
var i = 0'i32
|
||||
var num = zip_get_num_files(z.w)
|
||||
while i < num:
|
||||
yield $zip_get_name(z.w, i, 0'i32)
|
||||
inc(i)
|
||||
|
||||
|
||||
proc extractFile*(z: var ZipArchive, srcFile: string, dest: Stream) =
|
||||
## extracts a file from the zip archive `z` to the destination stream.
|
||||
var strm = getStream(z, srcFile)
|
||||
while true:
|
||||
if not strm.atEnd:
|
||||
dest.write(strm.readStr(1))
|
||||
else: break
|
||||
dest.flush()
|
||||
strm.close()
|
||||
|
||||
proc extractFile*(z: var ZipArchive, srcFile: string, dest: string) =
|
||||
## extracts a file from the zip archive `z` to the destination filename.
|
||||
var file = newFileStream(dest, fmWrite)
|
||||
extractFile(z, srcFile, file)
|
||||
file.close()
|
||||
|
||||
proc extractAll*(z: var ZipArchive, dest: string) =
|
||||
## extracts all files from archive `z` to the destination directory.
|
||||
for file in walkFiles(z):
|
||||
if file.endsWith("/"):
|
||||
createDir(dest / file)
|
||||
else:
|
||||
extractFile(z, file, dest / file)
|
||||
|
||||
when not defined(testing) and isMainModule:
|
||||
var zip: ZipArchive
|
||||
if not zip.open("nim-0.11.0.zip"):
|
||||
raise newException(IOError, "opening zip failed")
|
||||
zip.extractAll("test")
|
||||
@@ -355,7 +355,7 @@ when isMainModule:
|
||||
var srt1 = [1,2,3,4,4,4,4,5]
|
||||
var srt2 = ["iello","hello"]
|
||||
var srt3 = [1.0,1.0,1.0]
|
||||
var srt4 = []
|
||||
var srt4: seq[int] = @[]
|
||||
assert srt1.isSorted(cmp) == true
|
||||
assert srt2.isSorted(cmp) == false
|
||||
assert srt3.isSorted(cmp) == true
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,236 +0,0 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2006 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
# NetBIOS 3.0 interface unit
|
||||
|
||||
# This module contains the definitions for portable NetBIOS 3.0 support.
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
import # Data structure templates
|
||||
windows
|
||||
|
||||
const
|
||||
NCBNAMSZ* = 16 # absolute length of a net name
|
||||
MAX_LANA* = 254 # lana's in range 0 to MAX_LANA inclusive
|
||||
|
||||
type # Network Control Block
|
||||
PNCB* = ptr NCB
|
||||
NCBPostProc* = proc (P: PNCB) {.stdcall.}
|
||||
NCB* {.final.} = object # Structure returned to the NCB command NCBASTAT is ADAPTER_STATUS followed
|
||||
# by an array of NAME_BUFFER structures.
|
||||
ncb_command*: char # command code
|
||||
ncb_retcode*: char # return code
|
||||
ncb_lsn*: char # local session number
|
||||
ncb_num*: char # number of our network name
|
||||
ncb_buffer*: cstring # address of message buffer
|
||||
ncb_length*: int16 # size of message buffer
|
||||
ncb_callname*: array[0..NCBNAMSZ - 1, char] # blank-padded name of remote
|
||||
ncb_name*: array[0..NCBNAMSZ - 1, char] # our blank-padded netname
|
||||
ncb_rto*: char # rcv timeout/retry count
|
||||
ncb_sto*: char # send timeout/sys timeout
|
||||
ncb_post*: NCBPostProc # POST routine address
|
||||
ncb_lana_num*: char # lana (adapter) number
|
||||
ncb_cmd_cplt*: char # 0xff => commmand pending
|
||||
ncb_reserve*: array[0..9, char] # reserved, used by BIOS
|
||||
ncb_event*: Handle # HANDLE to Win32 event which
|
||||
# will be set to the signalled
|
||||
# state when an ASYNCH command
|
||||
# completes
|
||||
|
||||
PAdapterStatus* = ptr AdapterStatus
|
||||
AdapterStatus* {.final.} = object
|
||||
adapter_address*: array[0..5, char]
|
||||
rev_major*: char
|
||||
reserved0*: char
|
||||
adapter_type*: char
|
||||
rev_minor*: char
|
||||
duration*: int16
|
||||
frmr_recv*: int16
|
||||
frmr_xmit*: int16
|
||||
iframe_recv_err*: int16
|
||||
xmit_aborts*: int16
|
||||
xmit_success*: DWORD
|
||||
recv_success*: DWORD
|
||||
iframe_xmit_err*: int16
|
||||
recv_buff_unavail*: int16
|
||||
t1_timeouts*: int16
|
||||
ti_timeouts*: int16
|
||||
reserved1*: DWORD
|
||||
free_ncbs*: int16
|
||||
max_cfg_ncbs*: int16
|
||||
max_ncbs*: int16
|
||||
xmit_buf_unavail*: int16
|
||||
max_dgram_size*: int16
|
||||
pending_sess*: int16
|
||||
max_cfg_sess*: int16
|
||||
max_sess*: int16
|
||||
max_sess_pkt_size*: int16
|
||||
name_count*: int16
|
||||
|
||||
PNameBuffer* = ptr NameBuffer
|
||||
NameBuffer* {.final.} = object
|
||||
name*: array[0..NCBNAMSZ - 1, char]
|
||||
name_num*: char
|
||||
name_flags*: char
|
||||
{.deprecated: [TNCB: NCB, TNCBPostProc: NCBPostProc,
|
||||
TAdapterStatus: AdapterStatus, TNameBuffer: NameBuffer].}
|
||||
|
||||
|
||||
const # values for name_flags bits.
|
||||
NAME_FLAGS_MASK* = 0x00000087
|
||||
GROUP_NAME* = 0x00000080
|
||||
UNIQUE_NAME* = 0x00000000
|
||||
REGISTERING* = 0x00000000
|
||||
REGISTERED* = 0x00000004
|
||||
DEREGISTERED* = 0x00000005
|
||||
DUPLICATE* = 0x00000006
|
||||
DUPLICATE_DEREG* = 0x00000007
|
||||
|
||||
type # Structure returned to the NCB command NCBSSTAT is SESSION_HEADER followed
|
||||
# by an array of SESSION_BUFFER structures. If the NCB_NAME starts with an
|
||||
# asterisk then an array of these structures is returned containing the
|
||||
# status for all names.
|
||||
PSessionHeader* = ptr SessionHeader
|
||||
SessionHeader* {.final.} = object
|
||||
sess_name*: char
|
||||
num_sess*: char
|
||||
rcv_dg_outstanding*: char
|
||||
rcv_any_outstanding*: char
|
||||
|
||||
PSessionBuffer* = ptr SessionBuffer
|
||||
SessionBuffer* {.final.} = object
|
||||
lsn*: char
|
||||
state*: char
|
||||
local_name*: array[0..NCBNAMSZ - 1, char]
|
||||
remote_name*: array[0..NCBNAMSZ - 1, char]
|
||||
rcvs_outstanding*: char
|
||||
sends_outstanding*: char
|
||||
{.deprecated: [TSessionHeader: SessionHeader, TSessionBuffer: SessionBuffer].}
|
||||
|
||||
|
||||
const # Values for state
|
||||
LISTEN_OUTSTANDING* = 0x00000001
|
||||
CALL_PENDING* = 0x00000002
|
||||
SESSION_ESTABLISHED* = 0x00000003
|
||||
HANGUP_PENDING* = 0x00000004
|
||||
HANGUP_COMPLETE* = 0x00000005
|
||||
SESSION_ABORTED* = 0x00000006
|
||||
|
||||
type # Structure returned to the NCB command NCBENUM.
|
||||
# On a system containing lana's 0, 2 and 3, a structure with
|
||||
# length =3, lana[0]=0, lana[1]=2 and lana[2]=3 will be returned.
|
||||
PLanaEnum* = ptr TLanaEnum
|
||||
TLanaEnum* {.final.} = object # Structure returned to the NCB command NCBFINDNAME is FIND_NAME_HEADER followed
|
||||
# by an array of FIND_NAME_BUFFER structures.
|
||||
len*: char # Number of valid entries in lana[]
|
||||
lana*: array[0..MAX_LANA, char]
|
||||
|
||||
PFindNameHeader* = ptr FindNameHeader
|
||||
FindNameHeader* {.final.} = object
|
||||
node_count*: int16
|
||||
reserved*: char
|
||||
unique_group*: char
|
||||
|
||||
PFindNameBuffer* = ptr FindNameBuffer
|
||||
FindNameBuffer* {.final.} = object # Structure provided with NCBACTION. The purpose of NCBACTION is to provide
|
||||
# transport specific extensions to netbios.
|
||||
len*: char
|
||||
access_control*: char
|
||||
frame_control*: char
|
||||
destination_addr*: array[0..5, char]
|
||||
source_addr*: array[0..5, char]
|
||||
routing_info*: array[0..17, char]
|
||||
|
||||
PActionHeader* = ptr ActionHeader
|
||||
ActionHeader* {.final.} = object
|
||||
transport_id*: int32
|
||||
action_code*: int16
|
||||
reserved*: int16
|
||||
{.deprecated: [TFindNameHeader: FindNameHeader, TFindNameBuffer: FindNameBuffer,
|
||||
TActionHeader: ActionHeader].}
|
||||
|
||||
const # Values for transport_id
|
||||
ALL_TRANSPORTS* = "M\0\0\0"
|
||||
MS_NBF* = "MNBF" # Special values and constants
|
||||
|
||||
const # NCB Command codes
|
||||
NCBCALL* = 0x00000010 # NCB CALL
|
||||
NCBLISTEN* = 0x00000011 # NCB LISTEN
|
||||
NCBHANGUP* = 0x00000012 # NCB HANG UP
|
||||
NCBSEND* = 0x00000014 # NCB SEND
|
||||
NCBRECV* = 0x00000015 # NCB RECEIVE
|
||||
NCBRECVANY* = 0x00000016 # NCB RECEIVE ANY
|
||||
NCBCHAINSEND* = 0x00000017 # NCB CHAIN SEND
|
||||
NCBDGSEND* = 0x00000020 # NCB SEND DATAGRAM
|
||||
NCBDGRECV* = 0x00000021 # NCB RECEIVE DATAGRAM
|
||||
NCBDGSENDBC* = 0x00000022 # NCB SEND BROADCAST DATAGRAM
|
||||
NCBDGRECVBC* = 0x00000023 # NCB RECEIVE BROADCAST DATAGRAM
|
||||
NCBADDNAME* = 0x00000030 # NCB ADD NAME
|
||||
NCBDELNAME* = 0x00000031 # NCB DELETE NAME
|
||||
NCBRESET* = 0x00000032 # NCB RESET
|
||||
NCBASTAT* = 0x00000033 # NCB ADAPTER STATUS
|
||||
NCBSSTAT* = 0x00000034 # NCB SESSION STATUS
|
||||
NCBCANCEL* = 0x00000035 # NCB CANCEL
|
||||
NCBADDGRNAME* = 0x00000036 # NCB ADD GROUP NAME
|
||||
NCBENUM* = 0x00000037 # NCB ENUMERATE LANA NUMBERS
|
||||
NCBUNLINK* = 0x00000070 # NCB UNLINK
|
||||
NCBSENDNA* = 0x00000071 # NCB SEND NO ACK
|
||||
NCBCHAINSENDNA* = 0x00000072 # NCB CHAIN SEND NO ACK
|
||||
NCBLANSTALERT* = 0x00000073 # NCB LAN STATUS ALERT
|
||||
NCBACTION* = 0x00000077 # NCB ACTION
|
||||
NCBFINDNAME* = 0x00000078 # NCB FIND NAME
|
||||
NCBTRACE* = 0x00000079 # NCB TRACE
|
||||
ASYNCH* = 0x00000080 # high bit set = asynchronous
|
||||
# NCB Return codes
|
||||
NRC_GOODRET* = 0x00000000 # good return
|
||||
# also returned when ASYNCH request accepted
|
||||
NRC_BUFLEN* = 0x00000001 # illegal buffer length
|
||||
NRC_ILLCMD* = 0x00000003 # illegal command
|
||||
NRC_CMDTMO* = 0x00000005 # command timed out
|
||||
NRC_INCOMP* = 0x00000006 # message incomplete, issue another command
|
||||
NRC_BADDR* = 0x00000007 # illegal buffer address
|
||||
NRC_SNUMOUT* = 0x00000008 # session number out of range
|
||||
NRC_NORES* = 0x00000009 # no resource available
|
||||
NRC_SCLOSED* = 0x0000000A # session closed
|
||||
NRC_CMDCAN* = 0x0000000B # command cancelled
|
||||
NRC_DUPNAME* = 0x0000000D # duplicate name
|
||||
NRC_NAMTFUL* = 0x0000000E # name table full
|
||||
NRC_ACTSES* = 0x0000000F # no deletions, name has active sessions
|
||||
NRC_LOCTFUL* = 0x00000011 # local session table full
|
||||
NRC_REMTFUL* = 0x00000012 # remote session table full
|
||||
NRC_ILLNN* = 0x00000013 # illegal name number
|
||||
NRC_NOCALL* = 0x00000014 # no callname
|
||||
NRC_NOWILD* = 0x00000015 # cannot put * in NCB_NAME
|
||||
NRC_INUSE* = 0x00000016 # name in use on remote adapter
|
||||
NRC_NAMERR* = 0x00000017 # name deleted
|
||||
NRC_SABORT* = 0x00000018 # session ended abnormally
|
||||
NRC_NAMCONF* = 0x00000019 # name conflict detected
|
||||
NRC_IFBUSY* = 0x00000021 # interface busy, IRET before retrying
|
||||
NRC_TOOMANY* = 0x00000022 # too many commands outstanding, retry later
|
||||
NRC_BRIDGE* = 0x00000023 # NCB_lana_num field invalid
|
||||
NRC_CANOCCR* = 0x00000024 # command completed while cancel occurring
|
||||
NRC_CANCEL* = 0x00000026 # command not valid to cancel
|
||||
NRC_DUPENV* = 0x00000030 # name defined by anther local process
|
||||
NRC_ENVNOTDEF* = 0x00000034 # environment undefined. RESET required
|
||||
NRC_OSRESNOTAV* = 0x00000035 # required OS resources exhausted
|
||||
NRC_MAXAPPS* = 0x00000036 # max number of applications exceeded
|
||||
NRC_NOSAPS* = 0x00000037 # no saps available for netbios
|
||||
NRC_NORESOURCES* = 0x00000038 # requested resources are not available
|
||||
NRC_INVADDRESS* = 0x00000039 # invalid ncb address or length > segment
|
||||
NRC_INVDDID* = 0x0000003B # invalid NCB DDID
|
||||
NRC_LOCKFAIL* = 0x0000003C # lock of user area failed
|
||||
NRC_OPENERR* = 0x0000003F # NETBIOS not loaded
|
||||
NRC_SYSTEM* = 0x00000040 # system error
|
||||
NRC_PENDING* = 0x000000FF # asynchronous command is not yet finished
|
||||
# main user entry point for NetBIOS 3.0
|
||||
# Usage: Result = Netbios( pncb );
|
||||
|
||||
proc Netbios*(P: PNCB): char{.stdcall, dynlib: "netapi32.dll",
|
||||
importc: "Netbios".}
|
||||
# implementation
|
||||
@@ -1,202 +0,0 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2009 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
# PSAPI interface unit
|
||||
|
||||
# Contains the definitions for the APIs provided by PSAPI.DLL
|
||||
|
||||
import # Data structure templates
|
||||
Windows
|
||||
|
||||
const
|
||||
psapiDll = "psapi.dll"
|
||||
|
||||
proc EnumProcesses*(lpidProcess: ptr DWORD, cb: DWORD,
|
||||
cbNeeded: ptr DWORD): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "EnumProcesses".}
|
||||
proc EnumProcessModules*(hProcess: HANDLE, lphModule: ptr HMODULE, cb: DWORD, lpcbNeeded: LPDWORD): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "EnumProcessModules".}
|
||||
|
||||
proc GetModuleBaseNameA*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetModuleBaseNameA".}
|
||||
proc GetModuleBaseNameW*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetModuleBaseNameW".}
|
||||
when defined(winUnicode):
|
||||
proc GetModuleBaseName*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetModuleBaseNameW".}
|
||||
else:
|
||||
proc GetModuleBaseName*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetModuleBaseNameA".}
|
||||
|
||||
proc GetModuleFileNameExA*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetModuleFileNameExA".}
|
||||
proc GetModuleFileNameExW*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetModuleFileNameExW".}
|
||||
when defined(winUnicode):
|
||||
proc GetModuleFileNameEx*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetModuleFileNameExW".}
|
||||
else:
|
||||
proc GetModuleFileNameEx*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetModuleFileNameExA".}
|
||||
|
||||
type
|
||||
MODULEINFO* {.final.} = object
|
||||
lpBaseOfDll*: LPVOID
|
||||
SizeOfImage*: DWORD
|
||||
EntryPoint*: LPVOID
|
||||
LPMODULEINFO* = ptr MODULEINFO
|
||||
|
||||
proc GetModuleInformation*(hProcess: HANDLE, hModule: HMODULE, lpmodinfo: LPMODULEINFO, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetModuleInformation".}
|
||||
proc EmptyWorkingSet*(hProcess: HANDLE): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "EmptyWorkingSet".}
|
||||
proc QueryWorkingSet*(hProcess: HANDLE, pv: PVOID, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "QueryWorkingSet".}
|
||||
proc QueryWorkingSetEx*(hProcess: HANDLE, pv: PVOID, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "QueryWorkingSetEx".}
|
||||
proc InitializeProcessForWsWatch*(hProcess: HANDLE): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "InitializeProcessForWsWatch".}
|
||||
|
||||
type
|
||||
PSAPI_WS_WATCH_INFORMATION* {.final.} = object
|
||||
FaultingPc*: LPVOID
|
||||
FaultingVa*: LPVOID
|
||||
PPSAPI_WS_WATCH_INFORMATION* = ptr PSAPI_WS_WATCH_INFORMATION
|
||||
|
||||
proc GetWsChanges*(hProcess: HANDLE, lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetWsChanges".}
|
||||
|
||||
proc GetMappedFileNameA*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetMappedFileNameA".}
|
||||
proc GetMappedFileNameW*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetMappedFileNameW".}
|
||||
when defined(winUnicode):
|
||||
proc GetMappedFileName*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetMappedFileNameW".}
|
||||
else:
|
||||
proc GetMappedFileName*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetMappedFileNameA".}
|
||||
|
||||
proc EnumDeviceDrivers*(lpImageBase: LPVOID, cb: DWORD, lpcbNeeded: LPDWORD): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "EnumDeviceDrivers".}
|
||||
|
||||
proc GetDeviceDriverBaseNameA*(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetDeviceDriverBaseNameA".}
|
||||
proc GetDeviceDriverBaseNameW*(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetDeviceDriverBaseNameW".}
|
||||
when defined(winUnicode):
|
||||
proc GetDeviceDriverBaseName*(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetDeviceDriverBaseNameW".}
|
||||
else:
|
||||
proc GetDeviceDriverBaseName*(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetDeviceDriverBaseNameA".}
|
||||
|
||||
proc GetDeviceDriverFileNameA*(ImageBase: LPVOID, lpFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetDeviceDriverFileNameA".}
|
||||
proc GetDeviceDriverFileNameW*(ImageBase: LPVOID, lpFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetDeviceDriverFileNameW".}
|
||||
when defined(winUnicode):
|
||||
proc GetDeviceDriverFileName*(ImageBase: LPVOID, lpFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetDeviceDriverFileNameW".}
|
||||
else:
|
||||
proc GetDeviceDriverFileName*(ImageBase: LPVOID, lpFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetDeviceDriverFileNameA".}
|
||||
|
||||
type
|
||||
PROCESS_MEMORY_COUNTERS* {.final.} = object
|
||||
cb*: DWORD
|
||||
PageFaultCount*: DWORD
|
||||
PeakWorkingSetSize: SIZE_T
|
||||
WorkingSetSize: SIZE_T
|
||||
QuotaPeakPagedPoolUsage: SIZE_T
|
||||
QuotaPagedPoolUsage: SIZE_T
|
||||
QuotaPeakNonPagedPoolUsage: SIZE_T
|
||||
QuotaNonPagedPoolUsage: SIZE_T
|
||||
PagefileUsage: SIZE_T
|
||||
PeakPagefileUsage: SIZE_T
|
||||
PPROCESS_MEMORY_COUNTERS* = ptr PROCESS_MEMORY_COUNTERS
|
||||
|
||||
type
|
||||
PROCESS_MEMORY_COUNTERS_EX* {.final.} = object
|
||||
cb*: DWORD
|
||||
PageFaultCount*: DWORD
|
||||
PeakWorkingSetSize: SIZE_T
|
||||
WorkingSetSize: SIZE_T
|
||||
QuotaPeakPagedPoolUsage: SIZE_T
|
||||
QuotaPagedPoolUsage: SIZE_T
|
||||
QuotaPeakNonPagedPoolUsage: SIZE_T
|
||||
QuotaNonPagedPoolUsage: SIZE_T
|
||||
PagefileUsage: SIZE_T
|
||||
PeakPagefileUsage: SIZE_T
|
||||
PrivateUsage: SIZE_T
|
||||
PPROCESS_MEMORY_COUNTERS_EX* = ptr PROCESS_MEMORY_COUNTERS_EX
|
||||
|
||||
proc GetProcessMemoryInfo*(hProcess: HANDLE, ppsmemCounters: PPROCESS_MEMORY_COUNTERS, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetProcessMemoryInfo".}
|
||||
|
||||
type
|
||||
PERFORMANCE_INFORMATION* {.final.} = object
|
||||
cb*: DWORD
|
||||
CommitTotal: SIZE_T
|
||||
CommitLimit: SIZE_T
|
||||
CommitPeak: SIZE_T
|
||||
PhysicalTotal: SIZE_T
|
||||
PhysicalAvailable: SIZE_T
|
||||
SystemCache: SIZE_T
|
||||
KernelTotal: SIZE_T
|
||||
KernelPaged: SIZE_T
|
||||
KernelNonpaged: SIZE_T
|
||||
PageSize: SIZE_T
|
||||
HandleCount*: DWORD
|
||||
ProcessCount*: DWORD
|
||||
ThreadCount*: DWORD
|
||||
PPERFORMANCE_INFORMATION* = ptr PERFORMANCE_INFORMATION
|
||||
# Skip definition of PERFORMACE_INFORMATION...
|
||||
|
||||
proc GetPerformanceInfo*(pPerformanceInformation: PPERFORMANCE_INFORMATION, cb: DWORD): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetPerformanceInfo".}
|
||||
|
||||
type
|
||||
ENUM_PAGE_FILE_INFORMATION* {.final.} = object
|
||||
cb*: DWORD
|
||||
Reserved*: DWORD
|
||||
TotalSize: SIZE_T
|
||||
TotalInUse: SIZE_T
|
||||
PeakUsage: SIZE_T
|
||||
PENUM_PAGE_FILE_INFORMATION* = ptr ENUM_PAGE_FILE_INFORMATION
|
||||
|
||||
# Callback procedure
|
||||
type
|
||||
PENUM_PAGE_FILE_CALLBACKW* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCWSTR): WINBOOL{.stdcall.}
|
||||
PENUM_PAGE_FILE_CALLBACKA* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCSTR): WINBOOL{.stdcall.}
|
||||
|
||||
#TODO
|
||||
proc EnumPageFilesA*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "EnumPageFilesA".}
|
||||
proc EnumPageFilesW*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "EnumPageFilesW".}
|
||||
when defined(winUnicode):
|
||||
proc EnumPageFiles*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "EnumPageFilesW".}
|
||||
type PENUM_PAGE_FILE_CALLBACK* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCWSTR): WINBOOL{.stdcall.}
|
||||
else:
|
||||
proc EnumPageFiles*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID): WINBOOL {.stdcall,
|
||||
dynlib: psapiDll, importc: "EnumPageFilesA".}
|
||||
type PENUM_PAGE_FILE_CALLBACK* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCSTR): WINBOOL{.stdcall.}
|
||||
|
||||
proc GetProcessImageFileNameA*(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetProcessImageFileNameA".}
|
||||
proc GetProcessImageFileNameW*(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetProcessImageFileNameW".}
|
||||
when defined(winUnicode):
|
||||
proc GetProcessImageFileName*(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetProcessImageFileNameW".}
|
||||
else:
|
||||
proc GetProcessImageFileName*(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||
dynlib: psapiDll, importc: "GetProcessImageFileNameA".}
|
||||
@@ -1,863 +0,0 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2006 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
# leave out unused functions so the unit can be used on win2000 as well
|
||||
|
||||
#+-------------------------------------------------------------------------
|
||||
#
|
||||
# Microsoft Windows
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
#
|
||||
# File: shellapi.h
|
||||
#
|
||||
# Header translation by Marco van de Voort for Free Pascal Platform
|
||||
# SDK dl'ed January 2002
|
||||
#
|
||||
#--------------------------------------------------------------------------
|
||||
|
||||
#
|
||||
# shellapi.h - SHELL.DLL functions, types, and definitions
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
import
|
||||
windows
|
||||
|
||||
type
|
||||
HDROP* = Handle
|
||||
UINT_PTR* = ptr uint32
|
||||
DWORD_PTR* = ptr DWORD
|
||||
PHICON* = ptr HICON
|
||||
PBool* = ptr bool
|
||||
STARTUPINFOW* {.final.} = object # a guess. Omission should get fixed in Windows.
|
||||
cb*: DWORD
|
||||
lpReserved*: LPTSTR
|
||||
lpDesktop*: LPTSTR
|
||||
lpTitle*: LPTSTR
|
||||
dwX*: DWORD
|
||||
dwY*: DWORD
|
||||
dwXSize*: DWORD
|
||||
dwYSize*: DWORD
|
||||
dwXCountChars*: DWORD
|
||||
dwYCountChars*: DWORD
|
||||
dwFillAttribute*: DWORD
|
||||
dwFlags*: DWORD
|
||||
wShowWindow*: int16
|
||||
cbReserved2*: int16
|
||||
lpReserved2*: LPBYTE
|
||||
hStdInput*: HANDLE
|
||||
hStdOutput*: HANDLE
|
||||
hStdError*: HANDLE
|
||||
|
||||
LPSTARTUPINFOW* = ptr STARTUPINFOW
|
||||
PSTARTUPINFOW* = ptr STARTUPINFOW #unicode
|
||||
{.deprecated: [TSTARTUPINFOW: STARTUPINFOW].}
|
||||
|
||||
proc DragQueryFileA*(arg1: HDROP, arg2: uint32, arg3: LPSTR, arg4: uint32): uint32{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "DragQueryFileA".}
|
||||
proc DragQueryFileW*(arg1: HDROP, arg2: uint32, arg3: LPWSTR, arg4: uint32): uint32{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "DragQueryFileW".}
|
||||
proc DragQueryFile*(arg1: HDROP, arg2: uint32, arg3: LPSTR, arg4: uint32): uint32{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "DragQueryFileA".}
|
||||
proc DragQueryFile*(arg1: HDROP, arg2: uint32, arg3: LPWSTR, arg4: uint32): uint32{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "DragQueryFileW".}
|
||||
proc DragQueryPoint*(arg1: HDROP, arg2: LPPOINT): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "DragQueryPoint".}
|
||||
proc DragFinish*(arg1: HDROP){.stdcall, dynlib: "shell32.dll",
|
||||
importc: "DragFinish".}
|
||||
proc DragAcceptFiles*(hwnd: HWND, arg2: bool){.stdcall, dynlib: "shell32.dll",
|
||||
importc: "DragAcceptFiles".}
|
||||
proc ShellExecuteA*(hwnd: HWND, lpOperation: LPCSTR, lpFile: LPCSTR,
|
||||
lpParameters: LPCSTR, lpDirectory: LPCSTR, nShowCmd: int32): HInst{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".}
|
||||
proc ShellExecuteW*(hwnd: HWND, lpOperation: LPCWSTR, lpFile: LPCWSTR,
|
||||
lpParameters: LPCWSTR, lpDirectory: LPCWSTR, nShowCmd: int32): HInst{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW".}
|
||||
proc ShellExecute*(hwnd: HWND, lpOperation: LPCSTR, lpFile: LPCSTR,
|
||||
lpParameters: LPCSTR, lpDirectory: LPCSTR, nShowCmd: int32): HInst{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".}
|
||||
proc ShellExecute*(hwnd: HWND, lpOperation: LPCWSTR, lpFile: LPCWSTR,
|
||||
lpParameters: LPCWSTR, lpDirectory: LPCWSTR, nShowCmd: int32): HInst{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW".}
|
||||
proc FindExecutableA*(lpFile: LPCSTR, lpDirectory: LPCSTR, lpResult: LPSTR): HInst{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "FindExecutableA".}
|
||||
proc FindExecutableW*(lpFile: LPCWSTR, lpDirectory: LPCWSTR, lpResult: LPWSTR): HInst{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "FindExecutableW".}
|
||||
proc FindExecutable*(lpFile: LPCSTR, lpDirectory: LPCSTR, lpResult: LPSTR): HInst{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "FindExecutableA".}
|
||||
proc FindExecutable*(lpFile: LPCWSTR, lpDirectory: LPCWSTR, lpResult: LPWSTR): HInst{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "FindExecutableW".}
|
||||
proc CommandLineToArgvW*(lpCmdLine: LPCWSTR, pNumArgs: ptr int32): PLPWSTR{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "CommandLineToArgvW".}
|
||||
proc ShellAboutA*(hwnd: HWND, szApp: LPCSTR, szOtherStuff: LPCSTR, hIcon: HICON): int32{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ShellAboutA".}
|
||||
proc ShellAboutW*(hwnd: HWND, szApp: LPCWSTR, szOtherStuff: LPCWSTR,
|
||||
hIcon: HICON): int32{.stdcall, dynlib: "shell32.dll",
|
||||
importc: "ShellAboutW".}
|
||||
proc ShellAbout*(hwnd: HWND, szApp: LPCSTR, szOtherStuff: LPCSTR, hIcon: HICON): int32{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ShellAboutA".}
|
||||
proc ShellAbout*(hwnd: HWND, szApp: LPCWSTR, szOtherStuff: LPCWSTR, hIcon: HICON): int32{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ShellAboutW".}
|
||||
proc DuplicateIcon*(inst: HINST, icon: HICON): HIcon{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "DuplicateIcon".}
|
||||
proc ExtractAssociatedIconA*(hInst: HINST, lpIconPath: LPSTR, lpiIcon: LPWORD): HICON{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconA".}
|
||||
proc ExtractAssociatedIconW*(hInst: HINST, lpIconPath: LPWSTR, lpiIcon: LPWORD): HICON{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconW".}
|
||||
proc ExtractAssociatedIcon*(hInst: HINST, lpIconPath: LPSTR, lpiIcon: LPWORD): HICON{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconA".}
|
||||
proc ExtractAssociatedIcon*(hInst: HINST, lpIconPath: LPWSTR, lpiIcon: LPWORD): HICON{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ExtractAssociatedIconW".}
|
||||
proc ExtractIconA*(hInst: HINST, lpszExeFileName: LPCSTR, nIconIndex: uint32): HICON{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ExtractIconA".}
|
||||
proc ExtractIconW*(hInst: HINST, lpszExeFileName: LPCWSTR, nIconIndex: uint32): HICON{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ExtractIconW".}
|
||||
proc ExtractIcon*(hInst: HINST, lpszExeFileName: LPCSTR, nIconIndex: uint32): HICON{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ExtractIconA".}
|
||||
proc ExtractIcon*(hInst: HINST, lpszExeFileName: LPCWSTR, nIconIndex: uint32): HICON{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ExtractIconW".}
|
||||
# if(WINVER >= 0x0400)
|
||||
type # init with sizeof(DRAGINFO)
|
||||
DRAGINFOA* {.final.} = object
|
||||
uSize*: uint32
|
||||
pt*: POINT
|
||||
fNC*: bool
|
||||
lpFileList*: LPSTR
|
||||
grfKeyState*: DWORD
|
||||
|
||||
LPDRAGINFOA* = ptr DRAGINFOA # init with sizeof(DRAGINFO)
|
||||
DRAGINFOW* {.final.} = object
|
||||
uSize*: uint32
|
||||
pt*: POINT
|
||||
fNC*: bool
|
||||
lpFileList*: LPWSTR
|
||||
grfKeyState*: DWORD
|
||||
|
||||
LPDRAGINFOW* = ptr DRAGINFOW
|
||||
{.deprecated: [TDRAGINFOA: DRAGINFOA, TDRAGINFOW: DRAGINFOW].}
|
||||
|
||||
when defined(UNICODE):
|
||||
type
|
||||
DRAGINFO* = DRAGINFOW
|
||||
LPDRAGINFO* = LPDRAGINFOW
|
||||
{.deprecated: [TDRAGINFO: DRAGINFOW].}
|
||||
else:
|
||||
type
|
||||
DRAGINFO* = DRAGINFOA
|
||||
LPDRAGINFO* = LPDRAGINFOA
|
||||
{.deprecated: [TDRAGINFO: DRAGINFOW].}
|
||||
const
|
||||
ABM_NEW* = 0x00000000
|
||||
ABM_REMOVE* = 0x00000001
|
||||
ABM_QUERYPOS* = 0x00000002
|
||||
ABM_SETPOS* = 0x00000003
|
||||
ABM_GETSTATE* = 0x00000004
|
||||
ABM_GETTASKBARPOS* = 0x00000005
|
||||
ABM_ACTIVATE* = 0x00000006 # lParam == TRUE/FALSE means activate/deactivate
|
||||
ABM_GETAUTOHIDEBAR* = 0x00000007
|
||||
ABM_SETAUTOHIDEBAR* = 0x00000008 # this can fail at any time. MUST check the result
|
||||
# lParam = TRUE/FALSE Set/Unset
|
||||
# uEdge = what edge
|
||||
ABM_WINDOWPOSCHANGED* = 0x00000009
|
||||
ABM_SETSTATE* = 0x0000000A
|
||||
ABN_STATECHANGE* = 0x00000000 # these are put in the wparam of callback messages
|
||||
ABN_POSCHANGED* = 0x00000001
|
||||
ABN_FULLSCREENAPP* = 0x00000002
|
||||
ABN_WINDOWARRANGE* = 0x00000003 # lParam == TRUE means hide
|
||||
# flags for get state
|
||||
ABS_AUTOHIDE* = 0x00000001
|
||||
ABS_ALWAYSONTOP* = 0x00000002
|
||||
ABE_LEFT* = 0
|
||||
ABE_TOP* = 1
|
||||
ABE_RIGHT* = 2
|
||||
ABE_BOTTOM* = 3
|
||||
|
||||
type
|
||||
AppBarData* {.final.} = object
|
||||
cbSize*: DWORD
|
||||
hWnd*: HWND
|
||||
uCallbackMessage*: uint32
|
||||
uEdge*: uint32
|
||||
rc*: RECT
|
||||
lParam*: LPARAM # message specific
|
||||
|
||||
PAPPBARDATA* = ptr AppBarData
|
||||
{.deprecated: [TAPPBARDATA: AppBarData].}
|
||||
|
||||
proc SHAppBarMessage*(dwMessage: DWORD, pData: APPBARDATA): UINT_PTR{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHAppBarMessage".}
|
||||
#
|
||||
# EndAppBar
|
||||
#
|
||||
proc DoEnvironmentSubstA*(szString: LPSTR, cchString: uint32): DWORD{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "DoEnvironmentSubstA".}
|
||||
proc DoEnvironmentSubstW*(szString: LPWSTR, cchString: uint32): DWORD{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "DoEnvironmentSubstW".}
|
||||
proc DoEnvironmentSubst*(szString: LPSTR, cchString: uint32): DWORD{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "DoEnvironmentSubstA".}
|
||||
proc DoEnvironmentSubst*(szString: LPWSTR, cchString: uint32): DWORD{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "DoEnvironmentSubstW".}
|
||||
#Macro
|
||||
proc EIRESID*(x: int32): int32
|
||||
proc ExtractIconExA*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: PHICON,
|
||||
phiconSmall: PHICON, nIcons: uint32): uint32{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "ExtractIconExA".}
|
||||
proc ExtractIconExW*(lpszFile: LPCWSTR, nIconIndex: int32, phiconLarge: PHICON,
|
||||
phiconSmall: PHICON, nIcons: uint32): uint32{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "ExtractIconExW".}
|
||||
proc ExtractIconExA*(lpszFile: LPCSTR, nIconIndex: int32,
|
||||
phiconLarge: var HICON, phiconSmall: var HIcon,
|
||||
nIcons: uint32): uint32{.stdcall, dynlib: "shell32.dll",
|
||||
importc: "ExtractIconExA".}
|
||||
proc ExtractIconExW*(lpszFile: LPCWSTR, nIconIndex: int32,
|
||||
phiconLarge: var HICON, phiconSmall: var HIcon,
|
||||
nIcons: uint32): uint32{.stdcall, dynlib: "shell32.dll",
|
||||
importc: "ExtractIconExW".}
|
||||
proc ExtractIconEx*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: PHICON,
|
||||
phiconSmall: PHICON, nIcons: uint32): uint32{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "ExtractIconExA".}
|
||||
proc ExtractIconEx*(lpszFile: LPCWSTR, nIconIndex: int32, phiconLarge: PHICON,
|
||||
phiconSmall: PHICON, nIcons: uint32): uint32{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "ExtractIconExW".}
|
||||
proc ExtractIconEx*(lpszFile: LPCSTR, nIconIndex: int32, phiconLarge: var HICON,
|
||||
phiconSmall: var HIcon, nIcons: uint32): uint32{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "ExtractIconExA".}
|
||||
proc ExtractIconEx*(lpszFile: LPCWSTR, nIconIndex: int32,
|
||||
phiconLarge: var HICON, phiconSmall: var HIcon, nIcons: uint32): uint32{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "ExtractIconExW".}
|
||||
#
|
||||
# Shell File Operations
|
||||
#
|
||||
#ifndef FO_MOVE //these need to be kept in sync with the ones in shlobj.h}
|
||||
const
|
||||
FO_MOVE* = 0x00000001
|
||||
FO_COPY* = 0x00000002
|
||||
FO_DELETE* = 0x00000003
|
||||
FO_RENAME* = 0x00000004
|
||||
FOF_MULTIDESTFILES* = 0x00000001
|
||||
FOF_CONFIRMMOUSE* = 0x00000002
|
||||
FOF_SILENT* = 0x00000004 # don't create progress/report
|
||||
FOF_RENAMEONCOLLISION* = 0x00000008
|
||||
FOF_NOCONFIRMATION* = 0x00000010 # Don't prompt the user.
|
||||
FOF_WANTMAPPINGHANDLE* = 0x00000020 # Fill in SHFILEOPSTRUCT.hNameMappings
|
||||
FOF_ALLOWUNDO* = 0x00000040 # Must be freed using SHFreeNameMappings
|
||||
FOF_FILESONLY* = 0x00000080 # on *.*, do only files
|
||||
FOF_SIMPLEPROGRESS* = 0x00000100 # means don't show names of files
|
||||
FOF_NOCONFIRMMKDIR* = 0x00000200 # don't confirm making any needed dirs
|
||||
FOF_NOERRORUI* = 0x00000400 # don't put up error UI
|
||||
FOF_NOCOPYSECURITYATTRIBS* = 0x00000800 # dont copy NT file Security Attributes
|
||||
FOF_NORECURSION* = 0x00001000 # don't recurse into directories.
|
||||
#if (_WIN32_IE >= 0x0500)
|
||||
FOF_NO_CONNECTED_ELEMENTS* = 0x00002000 # don't operate on connected elements.
|
||||
FOF_WANTNUKEWARNING* = 0x00004000 # during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
|
||||
#endif
|
||||
#if (_WIN32_WINNT >= 0x0501)
|
||||
FOF_NORECURSEREPARSE* = 0x00008000 # treat reparse points as objects, not containers
|
||||
#endif
|
||||
|
||||
type
|
||||
FILEOP_FLAGS* = int16
|
||||
|
||||
const
|
||||
PO_DELETE* = 0x00000013 # printer is being deleted
|
||||
PO_RENAME* = 0x00000014 # printer is being renamed
|
||||
PO_PORTCHANGE* = 0x00000020 # port this printer connected to is being changed
|
||||
# if this id is set, the strings received by
|
||||
# the copyhook are a doubly-null terminated
|
||||
# list of strings. The first is the printer
|
||||
# name and the second is the printer port.
|
||||
PO_REN_PORT* = 0x00000034 # PO_RENAME and PO_PORTCHANGE at same time.
|
||||
# no POF_ flags currently defined
|
||||
|
||||
type
|
||||
PRINTEROP_FLAGS* = int16 #endif}
|
||||
# FO_MOVE
|
||||
# implicit parameters are:
|
||||
# if pFrom or pTo are unqualified names the current directories are
|
||||
# taken from the global current drive/directory settings managed
|
||||
# by Get/SetCurrentDrive/Directory
|
||||
#
|
||||
# the global confirmation settings
|
||||
# only used if FOF_SIMPLEPROGRESS
|
||||
|
||||
type
|
||||
SHFILEOPSTRUCTA* {.final.} = object
|
||||
hwnd*: HWND
|
||||
wFunc*: uint32
|
||||
pFrom*: LPCSTR
|
||||
pTo*: LPCSTR
|
||||
fFlags*: FILEOP_FLAGS
|
||||
fAnyOperationsAborted*: bool
|
||||
hNameMappings*: LPVOID
|
||||
lpszProgressTitle*: LPCSTR # only used if FOF_SIMPLEPROGRESS
|
||||
|
||||
LPSHFILEOPSTRUCTA* = ptr SHFILEOPSTRUCTA
|
||||
SHFILEOPSTRUCTW* {.final.} = object
|
||||
hwnd*: HWND
|
||||
wFunc*: uint32
|
||||
pFrom*: LPCWSTR
|
||||
pTo*: LPCWSTR
|
||||
fFlags*: FILEOP_FLAGS
|
||||
fAnyOperationsAborted*: bool
|
||||
hNameMappings*: LPVOID
|
||||
lpszProgressTitle*: LPCWSTR
|
||||
|
||||
LPSHFILEOPSTRUCTW* = ptr SHFILEOPSTRUCTW
|
||||
{.deprecated: [TSHFILEOPSTRUCTA: SHFILEOPSTRUCTA,
|
||||
TSHFILEOPSTRUCTW: SHFILEOPSTRUCTW].}
|
||||
|
||||
when defined(UNICODE):
|
||||
type
|
||||
SHFILEOPSTRUCT* = SHFILEOPSTRUCTW
|
||||
LPSHFILEOPSTRUCT* = LPSHFILEOPSTRUCTW
|
||||
{.deprecated: [TSHFILEOPSTRUCT: SHFILEOPSTRUCTW].}
|
||||
else:
|
||||
type
|
||||
SHFILEOPSTRUCT* = SHFILEOPSTRUCTA
|
||||
LPSHFILEOPSTRUCT* = LPSHFILEOPSTRUCTA
|
||||
{.deprecated: [TSHFILEOPSTRUCT: SHFILEOPSTRUCTA].}
|
||||
|
||||
proc SHFileOperationA*(lpFileOp: LPSHFILEOPSTRUCTA): int32{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHFileOperationA".}
|
||||
proc SHFileOperationW*(lpFileOp: LPSHFILEOPSTRUCTW): int32{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHFileOperationW".}
|
||||
proc SHFileOperation*(lpFileOp: LPSHFILEOPSTRUCTA): int32{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHFileOperationA".}
|
||||
proc SHFileOperation*(lpFileOp: LPSHFILEOPSTRUCTW): int32{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHFileOperationW".}
|
||||
proc SHFreeNameMappings*(hNameMappings: Handle){.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHFreeNameMappings".}
|
||||
type
|
||||
SHNAMEMAPPINGA* {.final.} = object
|
||||
pszOldPath*: LPSTR
|
||||
pszNewPath*: LPSTR
|
||||
cchOldPath*: int32
|
||||
cchNewPath*: int32
|
||||
|
||||
LPSHNAMEMAPPINGA* = ptr SHNAMEMAPPINGA
|
||||
SHNAMEMAPPINGW* {.final.} = object
|
||||
pszOldPath*: LPWSTR
|
||||
pszNewPath*: LPWSTR
|
||||
cchOldPath*: int32
|
||||
cchNewPath*: int32
|
||||
|
||||
LPSHNAMEMAPPINGW* = ptr SHNAMEMAPPINGW
|
||||
{.deprecated: [TSHNAMEMAPPINGA: SHNAMEMAPPINGA,
|
||||
TSHNAMEMAPPINGW: SHNAMEMAPPINGW].}
|
||||
|
||||
when not(defined(UNICODE)):
|
||||
type
|
||||
SHNAMEMAPPING* = SHNAMEMAPPINGW
|
||||
LPSHNAMEMAPPING* = LPSHNAMEMAPPINGW
|
||||
{.deprecated: [TSHNAMEMAPPING: SHNAMEMAPPINGW].}
|
||||
else:
|
||||
type
|
||||
SHNAMEMAPPING* = SHNAMEMAPPINGA
|
||||
LPSHNAMEMAPPING* = LPSHNAMEMAPPINGA
|
||||
{.deprecated: [TSHNAMEMAPPING: SHNAMEMAPPINGA].}
|
||||
#
|
||||
# End Shell File Operations
|
||||
#
|
||||
#
|
||||
# Begin ShellExecuteEx and family
|
||||
#
|
||||
# ShellExecute() and ShellExecuteEx() error codes
|
||||
# regular WinExec() codes
|
||||
|
||||
const
|
||||
SE_ERR_FNF* = 2 # file not found
|
||||
SE_ERR_PNF* = 3 # path not found
|
||||
SE_ERR_ACCESSDENIED* = 5 # access denied
|
||||
SE_ERR_OOM* = 8 # out of memory
|
||||
SE_ERR_DLLNOTFOUND* = 32 # endif WINVER >= 0x0400
|
||||
# error values for ShellExecute() beyond the regular WinExec() codes
|
||||
SE_ERR_SHARE* = 26
|
||||
SE_ERR_ASSOCINCOMPLETE* = 27
|
||||
SE_ERR_DDETIMEOUT* = 28
|
||||
SE_ERR_DDEFAIL* = 29
|
||||
SE_ERR_DDEBUSY* = 30
|
||||
SE_ERR_NOASSOC* = 31 #if(WINVER >= 0x0400)}
|
||||
# Note CLASSKEY overrides CLASSNAME
|
||||
SEE_MASK_CLASSNAME* = 0x00000001
|
||||
SEE_MASK_CLASSKEY* = 0x00000003 # Note INVOKEIDLIST overrides IDLIST
|
||||
SEE_MASK_IDLIST* = 0x00000004
|
||||
SEE_MASK_INVOKEIDLIST* = 0x0000000C
|
||||
SEE_MASK_ICON* = 0x00000010
|
||||
SEE_MASK_HOTKEY* = 0x00000020
|
||||
SEE_MASK_NOCLOSEPROCESS* = 0x00000040
|
||||
SEE_MASK_CONNECTNETDRV* = 0x00000080
|
||||
SEE_MASK_FLAG_DDEWAIT* = 0x00000100
|
||||
SEE_MASK_DOENVSUBST* = 0x00000200
|
||||
SEE_MASK_FLAG_NO_UI* = 0x00000400
|
||||
SEE_MASK_UNICODE* = 0x00004000
|
||||
SEE_MASK_NO_CONSOLE* = 0x00008000
|
||||
SEE_MASK_ASYNCOK* = 0x00100000
|
||||
SEE_MASK_HMONITOR* = 0x00200000 #if (_WIN32_IE >= 0x0500)
|
||||
SEE_MASK_NOQUERYCLASSSTORE* = 0x01000000
|
||||
SEE_MASK_WAITFORINPUTIDLE* = 0x02000000 #endif (_WIN32_IE >= 0x500)
|
||||
#if (_WIN32_IE >= 0x0560)
|
||||
SEE_MASK_FLAG_LOG_USAGE* = 0x04000000 #endif
|
||||
# (_WIN32_IE >= 0x560)
|
||||
|
||||
type
|
||||
SHELLEXECUTEINFOA* {.final.} = object
|
||||
cbSize*: DWORD
|
||||
fMask*: ULONG
|
||||
hwnd*: HWND
|
||||
lpVerb*: LPCSTR
|
||||
lpFile*: LPCSTR
|
||||
lpParameters*: LPCSTR
|
||||
lpDirectory*: LPCSTR
|
||||
nShow*: int32
|
||||
hInstApp*: HINST
|
||||
lpIDList*: LPVOID
|
||||
lpClass*: LPCSTR
|
||||
hkeyClass*: HKEY
|
||||
dwHotKey*: DWORD
|
||||
hMonitor*: HANDLE # also: hIcon
|
||||
hProcess*: HANDLE
|
||||
|
||||
LPSHELLEXECUTEINFOA* = ptr SHELLEXECUTEINFOA
|
||||
SHELLEXECUTEINFOW* {.final.} = object
|
||||
cbSize*: DWORD
|
||||
fMask*: ULONG
|
||||
hwnd*: HWND
|
||||
lpVerb*: LPCWSTR
|
||||
lpFile*: LPCWSTR
|
||||
lpParameters*: LPCWSTR
|
||||
lpDirectory*: LPCWSTR
|
||||
nShow*: int32
|
||||
hInstApp*: HINST
|
||||
lpIDList*: LPVOID
|
||||
lpClass*: LPCWSTR
|
||||
hkeyClass*: HKEY
|
||||
dwHotKey*: DWORD
|
||||
hMonitor*: HANDLE # also: hIcon
|
||||
hProcess*: HANDLE
|
||||
|
||||
LPSHELLEXECUTEINFOW* = ptr SHELLEXECUTEINFOW
|
||||
{.deprecated: [TSHELLEXECUTEINFOA: SHELLEXECUTEINFOA,
|
||||
TSHELLEXECUTEINFOW: SHELLEXECUTEINFOW].}
|
||||
|
||||
when defined(UNICODE):
|
||||
type
|
||||
SHELLEXECUTEINFO* = SHELLEXECUTEINFOW
|
||||
LPSHELLEXECUTEINFO* = LPSHELLEXECUTEINFOW
|
||||
{.deprecated: [TSHELLEXECUTEINFO: SHELLEXECUTEINFOW].}
|
||||
else:
|
||||
type
|
||||
SHELLEXECUTEINFO* = SHELLEXECUTEINFOA
|
||||
LPSHELLEXECUTEINFO* = LPSHELLEXECUTEINFOA
|
||||
{.deprecated: [TSHELLEXECUTEINFO: SHELLEXECUTEINFOA].}
|
||||
|
||||
proc ShellExecuteExA*(lpExecInfo: LPSHELLEXECUTEINFOA): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "ShellExecuteExA".}
|
||||
proc ShellExecuteExW*(lpExecInfo: LPSHELLEXECUTEINFOW): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "ShellExecuteExW".}
|
||||
proc ShellExecuteEx*(lpExecInfo: LPSHELLEXECUTEINFOA): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "ShellExecuteExA".}
|
||||
proc ShellExecuteEx*(lpExecInfo: LPSHELLEXECUTEINFOW): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "ShellExecuteExW".}
|
||||
proc WinExecErrorA*(hwnd: HWND, error: int32, lpstrFileName: LPCSTR,
|
||||
lpstrTitle: LPCSTR){.stdcall, dynlib: "shell32.dll",
|
||||
importc: "WinExecErrorA".}
|
||||
proc WinExecErrorW*(hwnd: HWND, error: int32, lpstrFileName: LPCWSTR,
|
||||
lpstrTitle: LPCWSTR){.stdcall, dynlib: "shell32.dll",
|
||||
importc: "WinExecErrorW".}
|
||||
proc WinExecError*(hwnd: HWND, error: int32, lpstrFileName: LPCSTR,
|
||||
lpstrTitle: LPCSTR){.stdcall, dynlib: "shell32.dll",
|
||||
importc: "WinExecErrorA".}
|
||||
proc WinExecError*(hwnd: HWND, error: int32, lpstrFileName: LPCWSTR,
|
||||
lpstrTitle: LPCWSTR){.stdcall, dynlib: "shell32.dll",
|
||||
importc: "WinExecErrorW".}
|
||||
type
|
||||
SHCREATEPROCESSINFOW* {.final.} = object
|
||||
cbSize*: DWORD
|
||||
fMask*: ULONG
|
||||
hwnd*: HWND
|
||||
pszFile*: LPCWSTR
|
||||
pszParameters*: LPCWSTR
|
||||
pszCurrentDirectory*: LPCWSTR
|
||||
hUserToken*: HANDLE
|
||||
lpProcessAttributes*: LPSECURITY_ATTRIBUTES
|
||||
lpThreadAttributes*: LPSECURITY_ATTRIBUTES
|
||||
bInheritHandles*: bool
|
||||
dwCreationFlags*: DWORD
|
||||
lpStartupInfo*: LPSTARTUPINFOW
|
||||
lpProcessInformation*: LPPROCESS_INFORMATION
|
||||
|
||||
PSHCREATEPROCESSINFOW* = ptr SHCREATEPROCESSINFOW
|
||||
{.deprecated: [TSHCREATEPROCESSINFOW: SHCREATEPROCESSINFOW].}
|
||||
|
||||
proc SHCreateProcessAsUserW*(pscpi: PSHCREATEPROCESSINFOW): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHCreateProcessAsUserW".}
|
||||
#
|
||||
# End ShellExecuteEx and family }
|
||||
#
|
||||
#
|
||||
# RecycleBin
|
||||
#
|
||||
# struct for query recycle bin info
|
||||
type
|
||||
SHQUERYRBINFO* {.final.} = object
|
||||
cbSize*: DWORD
|
||||
i64Size*: int64
|
||||
i64NumItems*: int64
|
||||
|
||||
LPSHQUERYRBINFO* = ptr SHQUERYRBINFO # flags for SHEmptyRecycleBin
|
||||
{.deprecated: [TSHQUERYRBINFO: SHQUERYRBINFO].}
|
||||
|
||||
const
|
||||
SHERB_NOCONFIRMATION* = 0x00000001
|
||||
SHERB_NOPROGRESSUI* = 0x00000002
|
||||
SHERB_NOSOUND* = 0x00000004
|
||||
|
||||
proc SHQueryRecycleBinA*(pszRootPath: LPCSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinA".}
|
||||
proc SHQueryRecycleBinW*(pszRootPath: LPCWSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinW".}
|
||||
proc SHQueryRecycleBin*(pszRootPath: LPCSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinA".}
|
||||
proc SHQueryRecycleBin*(pszRootPath: LPCWSTR, pSHQueryRBInfo: LPSHQUERYRBINFO): HRESULT{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHQueryRecycleBinW".}
|
||||
proc SHEmptyRecycleBinA*(hwnd: HWND, pszRootPath: LPCSTR, dwFlags: DWORD): HRESULT{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinA".}
|
||||
proc SHEmptyRecycleBinW*(hwnd: HWND, pszRootPath: LPCWSTR, dwFlags: DWORD): HRESULT{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinW".}
|
||||
proc SHEmptyRecycleBin*(hwnd: HWND, pszRootPath: LPCSTR, dwFlags: DWORD): HRESULT{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinA".}
|
||||
proc SHEmptyRecycleBin*(hwnd: HWND, pszRootPath: LPCWSTR, dwFlags: DWORD): HRESULT{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHEmptyRecycleBinW".}
|
||||
#
|
||||
# end of RecycleBin
|
||||
#
|
||||
#
|
||||
# Tray notification definitions
|
||||
#
|
||||
type
|
||||
NOTIFYICONDATAA* {.final.} = object
|
||||
cbSize*: DWORD
|
||||
hWnd*: HWND
|
||||
uID*: uint32
|
||||
uFlags*: uint32
|
||||
uCallbackMessage*: uint32
|
||||
hIcon*: HICON
|
||||
szTip*: array[0..127, char]
|
||||
dwState*: DWORD
|
||||
dwStateMask*: DWORD
|
||||
szInfo*: array[0..255, char]
|
||||
uTimeout*: uint32 # also: uVersion
|
||||
szInfoTitle*: array[0..63, char]
|
||||
dwInfoFlags*: DWORD
|
||||
guidItem*: GUID
|
||||
|
||||
PNOTIFYICONDATAA* = ptr NOTIFYICONDATAA
|
||||
NOTIFYICONDATAW* {.final.} = object
|
||||
cbSize*: DWORD
|
||||
hWnd*: HWND
|
||||
uID*: uint32
|
||||
uFlags*: uint32
|
||||
uCallbackMessage*: uint32
|
||||
hIcon*: HICON
|
||||
szTip*: array[0..127, Wchar]
|
||||
dwState*: DWORD
|
||||
dwStateMask*: DWORD
|
||||
szInfo*: array[0..255, Wchar]
|
||||
uTimeout*: uint32 # also uVersion : UINT
|
||||
szInfoTitle*: array[0..63, char]
|
||||
dwInfoFlags*: DWORD
|
||||
guidItem*: GUID
|
||||
|
||||
PNOTIFYICONDATAW* = ptr NOTIFYICONDATAW
|
||||
{.deprecated: [TNOTIFYICONDATAA: NOTIFYICONDATAA,
|
||||
TNOTIFYICONDATAW: NOTIFYICONDATAW].}
|
||||
|
||||
when defined(UNICODE):
|
||||
type
|
||||
NOTIFYICONDATA* = NOTIFYICONDATAW
|
||||
PNOTIFYICONDATA* = PNOTIFYICONDATAW
|
||||
{.deprecated: [TNOTIFYICONDATA: NOTIFYICONDATAW].}
|
||||
else:
|
||||
type
|
||||
NOTIFYICONDATA* = NOTIFYICONDATAA
|
||||
PNOTIFYICONDATA* = PNOTIFYICONDATAA
|
||||
{.deprecated: [TNOTIFYICONDATA: NOTIFYICONDATAA].}
|
||||
const
|
||||
NIN_SELECT* = WM_USER + 0
|
||||
NINF_KEY* = 0x00000001
|
||||
NIN_KEYSELECT* = NIN_SELECT or NINF_KEY
|
||||
NIN_BALLOONSHOW* = WM_USER + 2
|
||||
NIN_BALLOONHIDE* = WM_USER + 3
|
||||
NIN_BALLOONTIMEOUT* = WM_USER + 4
|
||||
NIN_BALLOONUSERCLICK* = WM_USER + 5
|
||||
NIM_ADD* = 0x00000000
|
||||
NIM_MODIFY* = 0x00000001
|
||||
NIM_DELETE* = 0x00000002
|
||||
NIM_SETFOCUS* = 0x00000003
|
||||
NIM_SETVERSION* = 0x00000004
|
||||
NOTIFYICON_VERSION* = 3
|
||||
NIF_MESSAGE* = 0x00000001
|
||||
NIF_ICON* = 0x00000002
|
||||
NIF_TIP* = 0x00000004
|
||||
NIF_STATE* = 0x00000008
|
||||
NIF_INFO* = 0x00000010
|
||||
NIF_GUID* = 0x00000020
|
||||
NIS_HIDDEN* = 0x00000001
|
||||
NIS_SHAREDICON* = 0x00000002 # says this is the source of a shared icon
|
||||
# Notify Icon Infotip flags
|
||||
NIIF_NONE* = 0x00000000 # icon flags are mutually exclusive
|
||||
# and take only the lowest 2 bits
|
||||
NIIF_INFO* = 0x00000001
|
||||
NIIF_WARNING* = 0x00000002
|
||||
NIIF_ERROR* = 0x00000003
|
||||
NIIF_ICON_MASK* = 0x0000000F
|
||||
NIIF_NOSOUND* = 0x00000010
|
||||
|
||||
proc Shell_NotifyIconA*(dwMessage: Dword, lpData: PNOTIFYICONDATAA): bool{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconA".}
|
||||
proc Shell_NotifyIconW*(dwMessage: Dword, lpData: PNOTIFYICONDATAW): bool{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconW".}
|
||||
proc Shell_NotifyIcon*(dwMessage: Dword, lpData: PNOTIFYICONDATAA): bool{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconA".}
|
||||
proc Shell_NotifyIcon*(dwMessage: Dword, lpData: PNOTIFYICONDATAW): bool{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "Shell_NotifyIconW".}
|
||||
#
|
||||
# The SHGetFileInfo API provides an easy way to get attributes
|
||||
# for a file given a pathname.
|
||||
#
|
||||
# PARAMETERS
|
||||
#
|
||||
# pszPath file name to get info about
|
||||
# dwFileAttributes file attribs, only used with SHGFI_USEFILEATTRIBUTES
|
||||
# psfi place to return file info
|
||||
# cbFileInfo size of structure
|
||||
# uFlags flags
|
||||
#
|
||||
# RETURN
|
||||
# TRUE if things worked
|
||||
#
|
||||
# out: icon
|
||||
# out: icon index
|
||||
# out: SFGAO_ flags
|
||||
# out: display name (or path)
|
||||
# out: type name
|
||||
type
|
||||
SHFILEINFOA* {.final.} = object
|
||||
hIcon*: HICON # out: icon
|
||||
iIcon*: int32 # out: icon index
|
||||
dwAttributes*: DWORD # out: SFGAO_ flags
|
||||
szDisplayName*: array[0..(MAX_PATH) - 1, char] # out: display name (or path)
|
||||
szTypeName*: array[0..79, char] # out: type name
|
||||
|
||||
PSHFILEINFOA* = ptr SHFILEINFOA
|
||||
SHFILEINFOW* {.final.} = object
|
||||
hIcon*: HICON # out: icon
|
||||
iIcon*: int32 # out: icon index
|
||||
dwAttributes*: DWORD # out: SFGAO_ flags
|
||||
szDisplayName*: array[0..(MAX_PATH) - 1, Wchar] # out: display name (or path)
|
||||
szTypeName*: array[0..79, Wchar] # out: type name
|
||||
|
||||
PSHFILEINFOW* = ptr SHFILEINFOW
|
||||
{.deprecated: [TSHFILEINFOA: SHFILEINFOA, TSHFILEINFOW: SHFILEINFOW].}
|
||||
|
||||
when defined(UNICODE):
|
||||
type
|
||||
SHFILEINFO* = SHFILEINFOW
|
||||
pFILEINFO* = SHFILEINFOW
|
||||
{.deprecated: [TSHFILEINFO: SHFILEINFOW].}
|
||||
else:
|
||||
type
|
||||
SHFILEINFO* = SHFILEINFOA
|
||||
pFILEINFO* = SHFILEINFOA
|
||||
{.deprecated: [TSHFILEINFO: SHFILEINFOA].}
|
||||
# NOTE: This is also in shlwapi.h. Please keep in synch.
|
||||
|
||||
const
|
||||
SHGFI_ICON* = 0x00000100 # get Icon
|
||||
SHGFI_DISPLAYNAME* = 0x00000200 # get display name
|
||||
SHGFI_TYPENAME* = 0x00000400 # get type name
|
||||
SHGFI_ATTRIBUTES* = 0x00000800 # get attributes
|
||||
SHGFI_ICONLOCATION* = 0x00001000 # get icon location
|
||||
SHGFI_EXETYPE* = 0x00002000 # return exe type
|
||||
SHGFI_SYSICONINDEX* = 0x00004000 # get system icon index
|
||||
SHGFI_LINKOVERLAY* = 0x00008000 # put a link overlay on icon
|
||||
SHGFI_SELECTED* = 0x00010000 # show icon in selected state
|
||||
SHGFI_ATTR_SPECIFIED* = 0x00020000 # get only specified attributes
|
||||
SHGFI_LARGEICON* = 0x00000000 # get large icon
|
||||
SHGFI_SMALLICON* = 0x00000001 # get small icon
|
||||
SHGFI_OPENICON* = 0x00000002 # get open icon
|
||||
SHGFI_SHELLICONSIZE* = 0x00000004 # get shell size icon
|
||||
SHGFI_PIDL* = 0x00000008 # pszPath is a pidl
|
||||
SHGFI_USEFILEATTRIBUTES* = 0x00000010 # use passed dwFileAttribute
|
||||
SHGFI_ADDOVERLAYS* = 0x00000020 # apply the appropriate overlays
|
||||
SHGFI_OVERLAYINDEX* = 0x00000040 # Get the index of the overlay
|
||||
# in the upper 8 bits of the iIcon
|
||||
|
||||
proc SHGetFileInfoA*(pszPath: LPCSTR, dwFileAttributes: DWORD,
|
||||
psfi: PSHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
|
||||
proc SHGetFileInfoW*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
|
||||
psfi: PSHFILEINFOW, cbFileInfo, UFlags: uint32): DWORD{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
|
||||
proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD,
|
||||
psfi: PSHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
|
||||
proc SHGetFileInfoA*(pszPath: LPCSTR, dwFileAttributes: DWORD,
|
||||
psfi: var SHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
|
||||
proc SHGetFileInfoW*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
|
||||
psfi: var SHFILEINFOW, cbFileInfo, UFlags: uint32): DWORD{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
|
||||
proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD,
|
||||
psfi: var SHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".}
|
||||
proc SHGetFileInfo*(pszPath: LPCWSTR, dwFileAttributes: DWORD,
|
||||
psfi: var SHFILEINFOW, cbFileInfo, UFlags: uint32): DWORD{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".}
|
||||
proc SHGetDiskFreeSpaceExA*(pszDirectoryName: LPCSTR,
|
||||
pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
|
||||
pulTotalNumberOfBytes: PULARGE_INTEGER,
|
||||
pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
|
||||
proc SHGetDiskFreeSpaceExW*(pszDirectoryName: LPCWSTR,
|
||||
pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
|
||||
pulTotalNumberOfBytes: PULARGE_INTEGER,
|
||||
pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
|
||||
proc SHGetDiskFreeSpaceEx*(pszDirectoryName: LPCSTR,
|
||||
pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
|
||||
pulTotalNumberOfBytes: PULARGE_INTEGER,
|
||||
pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
|
||||
proc SHGetDiskFreeSpace*(pszDirectoryName: LPCSTR,
|
||||
pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
|
||||
pulTotalNumberOfBytes: PULARGE_INTEGER,
|
||||
pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExA".}
|
||||
proc SHGetDiskFreeSpaceEx*(pszDirectoryName: LPCWSTR,
|
||||
pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
|
||||
pulTotalNumberOfBytes: PULARGE_INTEGER,
|
||||
pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
|
||||
proc SHGetDiskFreeSpace*(pszDirectoryName: LPCWSTR,
|
||||
pulFreeBytesAvailableToCaller: PULARGE_INTEGER,
|
||||
pulTotalNumberOfBytes: PULARGE_INTEGER,
|
||||
pulTotalNumberOfFreeBytes: PULARGE_INTEGER): bool{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetDiskFreeSpaceExW".}
|
||||
proc SHGetNewLinkInfoA*(pszLinkTo: LPCSTR, pszDir: LPCSTR, pszName: LPSTR,
|
||||
pfMustCopy: PBool, uFlags: uint32): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHGetNewLinkInfoA".}
|
||||
proc SHGetNewLinkInfoW*(pszLinkTo: LPCWSTR, pszDir: LPCWSTR, pszName: LPWSTR,
|
||||
pfMustCopy: PBool, uFlags: uint32): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHGetNewLinkInfoW".}
|
||||
proc SHGetNewLinkInfo*(pszLinkTo: LPCSTR, pszDir: LPCSTR, pszName: LPSTR,
|
||||
pfMustCopy: PBool, uFlags: uint32): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHGetNewLinkInfoA".}
|
||||
proc SHGetNewLinkInfo*(pszLinkTo: LPCWSTR, pszDir: LPCWSTR, pszName: LPWSTR,
|
||||
pfMustCopy: PBool, uFlags: uint32): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHGetNewLinkInfoW".}
|
||||
const
|
||||
SHGNLI_PIDL* = 0x00000001 # pszLinkTo is a pidl
|
||||
SHGNLI_PREFIXNAME* = 0x00000002 # Make name "Shortcut to xxx"
|
||||
SHGNLI_NOUNIQUE* = 0x00000004 # don't do the unique name generation
|
||||
SHGNLI_NOLNK* = 0x00000008 # don't add ".lnk" extension
|
||||
PRINTACTION_OPEN* = 0
|
||||
PRINTACTION_PROPERTIES* = 1
|
||||
PRINTACTION_NETINSTALL* = 2
|
||||
PRINTACTION_NETINSTALLLINK* = 3
|
||||
PRINTACTION_TESTPAGE* = 4
|
||||
PRINTACTION_OPENNETPRN* = 5
|
||||
PRINTACTION_DOCUMENTDEFAULTS* = 6
|
||||
PRINTACTION_SERVERPROPERTIES* = 7
|
||||
|
||||
proc SHInvokePrinterCommandA*(hwnd: HWND, uAction: uint32, lpBuf1: LPCSTR,
|
||||
lpBuf2: LPCSTR, fModal: bool): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHInvokePrinterCommandA".}
|
||||
proc SHInvokePrinterCommandW*(hwnd: HWND, uAction: uint32, lpBuf1: LPCWSTR,
|
||||
lpBuf2: LPCWSTR, fModal: bool): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}
|
||||
proc SHInvokePrinterCommand*(hwnd: HWND, uAction: uint32, lpBuf1: LPCSTR,
|
||||
lpBuf2: LPCSTR, fModal: bool): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHInvokePrinterCommandA".}
|
||||
proc SHInvokePrinterCommand*(hwnd: HWND, uAction: uint32, lpBuf1: LPCWSTR,
|
||||
lpBuf2: LPCWSTR, fModal: bool): bool{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}
|
||||
proc SHLoadNonloadedIconOverlayIdentifiers*(): HResult{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHInvokePrinterCommandW".}
|
||||
proc SHIsFileAvailableOffline*(pwszPath: LPCWSTR, pdwStatus: LPDWORD): HRESULT{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHIsFileAvailableOffline".}
|
||||
const
|
||||
OFFLINE_STATUS_LOCAL* = 0x00000001 # If open, it's open locally
|
||||
OFFLINE_STATUS_REMOTE* = 0x00000002 # If open, it's open remotely
|
||||
OFFLINE_STATUS_INCOMPLETE* = 0x00000004 # The local copy is currently incomplete.
|
||||
# The file will not be available offline
|
||||
# until it has been synchronized.
|
||||
# sets the specified path to use the string resource
|
||||
# as the UI instead of the file system name
|
||||
|
||||
proc SHSetLocalizedName*(pszPath: LPWSTR, pszResModule: LPCWSTR, idsRes: int32): HRESULT{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHSetLocalizedName".}
|
||||
proc SHEnumerateUnreadMailAccountsA*(hKeyUser: HKEY, dwIndex: DWORD,
|
||||
pszMailAddress: LPSTR,
|
||||
cchMailAddress: int32): HRESULT{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHEnumerateUnreadMailAccountsA".}
|
||||
proc SHEnumerateUnreadMailAccountsW*(hKeyUser: HKEY, dwIndex: DWORD,
|
||||
pszMailAddress: LPWSTR,
|
||||
cchMailAddress: int32): HRESULT{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHEnumerateUnreadMailAccountsW".}
|
||||
proc SHEnumerateUnreadMailAccounts*(hKeyUser: HKEY, dwIndex: DWORD,
|
||||
pszMailAddress: LPWSTR,
|
||||
cchMailAddress: int32): HRESULT{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHEnumerateUnreadMailAccountsW".}
|
||||
proc SHGetUnreadMailCountA*(hKeyUser: HKEY, pszMailAddress: LPCSTR,
|
||||
pdwCount: PDWORD, pFileTime: PFILETIME,
|
||||
pszShellExecuteCommand: LPSTR,
|
||||
cchShellExecuteCommand: int32): HRESULT{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHGetUnreadMailCountA".}
|
||||
proc SHGetUnreadMailCountW*(hKeyUser: HKEY, pszMailAddress: LPCWSTR,
|
||||
pdwCount: PDWORD, pFileTime: PFILETIME,
|
||||
pszShellExecuteCommand: LPWSTR,
|
||||
cchShellExecuteCommand: int32): HRESULT{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHGetUnreadMailCountW".}
|
||||
proc SHGetUnreadMailCount*(hKeyUser: HKEY, pszMailAddress: LPCSTR,
|
||||
pdwCount: PDWORD, pFileTime: PFILETIME,
|
||||
pszShellExecuteCommand: LPSTR,
|
||||
cchShellExecuteCommand: int32): HRESULT{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHGetUnreadMailCountA".}
|
||||
proc SHGetUnreadMailCount*(hKeyUser: HKEY, pszMailAddress: LPCWSTR,
|
||||
pdwCount: PDWORD, pFileTime: PFILETIME,
|
||||
pszShellExecuteCommand: LPWSTR,
|
||||
cchShellExecuteCommand: int32): HRESULT{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHGetUnreadMailCountW".}
|
||||
proc SHSetUnreadMailCountA*(pszMailAddress: LPCSTR, dwCount: DWORD,
|
||||
pszShellExecuteCommand: LPCSTR): HRESULT{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHSetUnreadMailCountA".}
|
||||
proc SHSetUnreadMailCountW*(pszMailAddress: LPCWSTR, dwCount: DWORD,
|
||||
pszShellExecuteCommand: LPCWSTR): HRESULT{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHSetUnreadMailCountW".}
|
||||
proc SHSetUnreadMailCount*(pszMailAddress: LPCSTR, dwCount: DWORD,
|
||||
pszShellExecuteCommand: LPCSTR): HRESULT{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHSetUnreadMailCountA".}
|
||||
proc SHSetUnreadMailCount*(pszMailAddress: LPCWSTR, dwCount: DWORD,
|
||||
pszShellExecuteCommand: LPCWSTR): HRESULT{.stdcall,
|
||||
dynlib: "shell32.dll", importc: "SHSetUnreadMailCountW".}
|
||||
proc SHGetImageList*(iImageList: int32, riid: TIID, ppvObj: ptr pointer): HRESULT{.
|
||||
stdcall, dynlib: "shell32.dll", importc: "SHGetImageList".}
|
||||
const
|
||||
SHIL_LARGE* = 0 # normally 32x32
|
||||
SHIL_SMALL* = 1 # normally 16x16
|
||||
SHIL_EXTRALARGE* = 2
|
||||
SHIL_SYSSMALL* = 3 # like SHIL_SMALL, but tracks system small icon metric correctly
|
||||
SHIL_LAST* = SHIL_SYSSMALL
|
||||
|
||||
# implementation
|
||||
|
||||
proc EIRESID(x: int32): int32 =
|
||||
result = -x
|
||||
@@ -1,93 +0,0 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2006 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# shfolder.dll is distributed standard with IE5.5, so it should ship
|
||||
# with 2000/XP or higher but is likely to be installed on NT/95/98 or
|
||||
# ME as well. It works on all these systems.
|
||||
#
|
||||
# The info found here is also in the registry:
|
||||
# HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\
|
||||
# HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\
|
||||
#
|
||||
# Note that not all CSIDL_* constants are supported by shlfolder.dll,
|
||||
# they should be supported by the shell32.dll, though again not on all
|
||||
# systems.
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
import
|
||||
windows
|
||||
|
||||
const
|
||||
LibName* = "SHFolder.dll"
|
||||
|
||||
const
|
||||
CSIDL_PROGRAMS* = 0x00000002 # %SYSTEMDRIVE%\Program Files
|
||||
CSIDL_PERSONAL* = 0x00000005 # %USERPROFILE%\My Documents
|
||||
CSIDL_FAVORITES* = 0x00000006 # %USERPROFILE%\Favorites
|
||||
CSIDL_STARTUP* = 0x00000007 # %USERPROFILE%\Start menu\Programs\Startup
|
||||
CSIDL_RECENT* = 0x00000008 # %USERPROFILE%\Recent
|
||||
CSIDL_SENDTO* = 0x00000009 # %USERPROFILE%\Sendto
|
||||
CSIDL_STARTMENU* = 0x0000000B # %USERPROFILE%\Start menu
|
||||
CSIDL_MYMUSIC* = 0x0000000D # %USERPROFILE%\Documents\My Music
|
||||
CSIDL_MYVIDEO* = 0x0000000E # %USERPROFILE%\Documents\My Videos
|
||||
CSIDL_DESKTOPDIRECTORY* = 0x00000010 # %USERPROFILE%\Desktop
|
||||
CSIDL_NETHOOD* = 0x00000013 # %USERPROFILE%\NetHood
|
||||
CSIDL_TEMPLATES* = 0x00000015 # %USERPROFILE%\Templates
|
||||
CSIDL_COMMON_STARTMENU* = 0x00000016 # %PROFILEPATH%\All users\Start menu
|
||||
CSIDL_COMMON_PROGRAMS* = 0x00000017 # %PROFILEPATH%\All users\Start menu\Programs
|
||||
CSIDL_COMMON_STARTUP* = 0x00000018 # %PROFILEPATH%\All users\Start menu\Programs\Startup
|
||||
CSIDL_COMMON_DESKTOPDIRECTORY* = 0x00000019 # %PROFILEPATH%\All users\Desktop
|
||||
CSIDL_APPDATA* = 0x0000001A # %USERPROFILE%\Application Data (roaming)
|
||||
CSIDL_PRINTHOOD* = 0x0000001B # %USERPROFILE%\Printhood
|
||||
CSIDL_LOCAL_APPDATA* = 0x0000001C # %USERPROFILE%\Local Settings\Application Data (non roaming)
|
||||
CSIDL_COMMON_FAVORITES* = 0x0000001F # %PROFILEPATH%\All users\Favorites
|
||||
CSIDL_INTERNET_CACHE* = 0x00000020 # %USERPROFILE%\Local Settings\Temporary Internet Files
|
||||
CSIDL_COOKIES* = 0x00000021 # %USERPROFILE%\Cookies
|
||||
CSIDL_HISTORY* = 0x00000022 # %USERPROFILE%\Local settings\History
|
||||
CSIDL_COMMON_APPDATA* = 0x00000023 # %PROFILESPATH%\All Users\Application Data
|
||||
CSIDL_WINDOWS* = 0x00000024 # %SYSTEMROOT%
|
||||
CSIDL_SYSTEM* = 0x00000025 # %SYSTEMROOT%\SYSTEM32 (may be system on 95/98/ME)
|
||||
CSIDL_PROGRAM_FILES* = 0x00000026 # %SYSTEMDRIVE%\Program Files
|
||||
CSIDL_MYPICTURES* = 0x00000027 # %USERPROFILE%\My Documents\My Pictures
|
||||
CSIDL_PROFILE* = 0x00000028 # %USERPROFILE%
|
||||
CSIDL_PROGRAM_FILES_COMMON* = 0x0000002B # %SYSTEMDRIVE%\Program Files\Common
|
||||
CSIDL_COMMON_TEMPLATES* = 0x0000002D # %PROFILEPATH%\All Users\Templates
|
||||
CSIDL_COMMON_DOCUMENTS* = 0x0000002E # %PROFILEPATH%\All Users\Documents
|
||||
CSIDL_COMMON_ADMINTOOLS* = 0x0000002F # %PROFILEPATH%\All Users\Start Menu\Programs\Administrative Tools
|
||||
CSIDL_ADMINTOOLS* = 0x00000030 # %USERPROFILE%\Start Menu\Programs\Administrative Tools
|
||||
CSIDL_COMMON_MUSIC* = 0x00000035 # %PROFILEPATH%\All Users\Documents\my music
|
||||
CSIDL_COMMON_PICTURES* = 0x00000036 # %PROFILEPATH%\All Users\Documents\my pictures
|
||||
CSIDL_COMMON_VIDEO* = 0x00000037 # %PROFILEPATH%\All Users\Documents\my videos
|
||||
CSIDL_CDBURN_AREA* = 0x0000003B # %USERPROFILE%\Local Settings\Application Data\Microsoft\CD Burning
|
||||
CSIDL_PROFILES* = 0x0000003E # %PROFILEPATH%
|
||||
CSIDL_FLAG_CREATE* = 0x00008000 # (force creation of requested folder if it doesn't exist yet)
|
||||
# Original entry points
|
||||
|
||||
proc SHGetFolderPathA*(Ahwnd: HWND, Csidl: int, Token: Handle, Flags: DWord,
|
||||
Path: cstring): HRESULT{.stdcall, dynlib: LibName,
|
||||
importc: "SHGetFolderPathA".}
|
||||
proc SHGetFolderPathW*(Ahwnd: HWND, Csidl: int, Token: Handle, Flags: DWord,
|
||||
Path: cstring): HRESULT{.stdcall, dynlib: LibName,
|
||||
importc: "SHGetFolderPathW".}
|
||||
proc SHGetFolderPath*(Ahwnd: HWND, Csidl: int, Token: Handle, Flags: DWord,
|
||||
Path: cstring): HRESULT{.stdcall, dynlib: LibName,
|
||||
importc: "SHGetFolderPathA".}
|
||||
type
|
||||
PFNSHGetFolderPathA* = proc (Ahwnd: HWND, Csidl: int, Token: Handle,
|
||||
Flags: DWord, Path: cstring): HRESULT{.stdcall.}
|
||||
PFNSHGetFolderPathW* = proc (Ahwnd: HWND, Csidl: int, Token: Handle,
|
||||
Flags: DWord, Path: cstring): HRESULT{.stdcall.}
|
||||
PFNSHGetFolderPath* = PFNSHGetFolderPathA
|
||||
|
||||
{.deprecated: [TSHGetFolderPathA: PFNSHGetFolderPathA,
|
||||
TSHGetFolderPathW: PFNSHGetFolderPathW,
|
||||
TSHGetFolderPath: SHGetFolderPathA].}
|
||||
23662
lib/windows/windows.nim
23662
lib/windows/windows.nim
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,899 +0,0 @@
|
||||
# Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
# See the file COPYING for copying permission.
|
||||
#
|
||||
|
||||
when not defined(expatDll):
|
||||
when defined(windows):
|
||||
const
|
||||
expatDll = "expat.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
expatDll = "libexpat.dylib"
|
||||
else:
|
||||
const
|
||||
expatDll = "libexpat.so(.1|)"
|
||||
type
|
||||
ParserStruct{.pure, final.} = object
|
||||
|
||||
PParser* = ptr ParserStruct
|
||||
|
||||
# The XML_Status enum gives the possible return values for several
|
||||
# API functions. The preprocessor #defines are included so this
|
||||
# stanza can be added to code that still needs to support older
|
||||
# versions of Expat 1.95.x:
|
||||
#
|
||||
# #ifndef XML_STATUS_OK
|
||||
# #define XML_STATUS_OK 1
|
||||
# #define XML_STATUS_ERROR 0
|
||||
# #endif
|
||||
#
|
||||
# Otherwise, the #define hackery is quite ugly and would have been
|
||||
# dropped.
|
||||
#
|
||||
{.deprecated: [TParserStruct: ParserStruct].}
|
||||
|
||||
type
|
||||
Status*{.size: sizeof(cint).} = enum
|
||||
STATUS_ERROR = 0, STATUS_OK = 1, STATUS_SUSPENDED = 2
|
||||
Error*{.size: sizeof(cint).} = enum
|
||||
ERROR_NONE, ERROR_NO_MEMORY, ERROR_SYNTAX, ERROR_NO_ELEMENTS,
|
||||
ERROR_INVALID_TOKEN, ERROR_UNCLOSED_TOKEN, ERROR_PARTIAL_CHAR,
|
||||
ERROR_TAG_MISMATCH, ERROR_DUPLICATE_ATTRIBUTE,
|
||||
ERROR_JUNK_AFTER_DOC_ELEMENT,
|
||||
ERROR_PARAM_ENTITY_REF, ERROR_UNDEFINED_ENTITY, ERROR_RECURSIVE_ENTITY_REF,
|
||||
ERROR_ASYNC_ENTITY, ERROR_BAD_CHAR_REF, ERROR_BINARY_ENTITY_REF,
|
||||
ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, ERROR_MISPLACED_XML_PI,
|
||||
ERROR_UNKNOWN_ENCODING, ERROR_INCORRECT_ENCODING,
|
||||
ERROR_UNCLOSED_CDATA_SECTION, ERROR_EXTERNAL_ENTITY_HANDLING,
|
||||
ERROR_NOT_STANDALONE, ERROR_UNEXPECTED_STATE, ERROR_ENTITY_DECLARED_IN_PE,
|
||||
ERROR_FEATURE_REQUIRES_XML_DTD, ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
|
||||
ERROR_UNBOUND_PREFIX,
|
||||
ERROR_UNDECLARING_PREFIX, ERROR_INCOMPLETE_PE, ERROR_XML_DECL,
|
||||
ERROR_TEXT_DECL, ERROR_PUBLICID, ERROR_SUSPENDED, ERROR_NOT_SUSPENDED,
|
||||
ERROR_ABORTED, ERROR_FINISHED, ERROR_SUSPEND_PE,
|
||||
ERROR_RESERVED_PREFIX_XML, ERROR_RESERVED_PREFIX_XMLNS,
|
||||
ERROR_RESERVED_NAMESPACE_URI
|
||||
ContentType*{.size: sizeof(cint).} = enum
|
||||
CTYPE_EMPTY = 1, CTYPE_ANY, CTYPE_MIXED, CTYPE_NAME, CTYPE_CHOICE, CTYPE_SEQ
|
||||
ContentQuant*{.size: sizeof(cint).} = enum
|
||||
CQUANT_NONE, CQUANT_OPT, CQUANT_REP, CQUANT_PLUS
|
||||
{.deprecated: [TStatus: Status, TError: Error, TContent_Type: ContentType,
|
||||
TContent_Quant: ContentQuant].}
|
||||
|
||||
# If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
|
||||
# XML_CQUANT_NONE, and the other fields will be zero or NULL.
|
||||
# If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
|
||||
# numchildren will contain number of elements that may be mixed in
|
||||
# and children point to an array of XML_Content cells that will be
|
||||
# all of XML_CTYPE_NAME type with no quantification.
|
||||
#
|
||||
# If type == XML_CTYPE_NAME, then the name points to the name, and
|
||||
# the numchildren field will be zero and children will be NULL. The
|
||||
# quant fields indicates any quantifiers placed on the name.
|
||||
#
|
||||
# CHOICE and SEQ will have name NULL, the number of children in
|
||||
# numchildren and children will point, recursively, to an array
|
||||
# of XML_Content cells.
|
||||
#
|
||||
# The EMPTY, ANY, and MIXED types will only occur at top level.
|
||||
#
|
||||
|
||||
type
|
||||
Content*{.pure, final.} = object
|
||||
typ*: ContentType
|
||||
quant*: ContentQuant
|
||||
name*: cstring
|
||||
numchildren*: cint
|
||||
children*: ptr Content
|
||||
{.deprecated: [TContent: Content].}
|
||||
|
||||
# This is called for an element declaration. See above for
|
||||
# description of the model argument. It's the caller's responsibility
|
||||
# to free model when finished with it.
|
||||
#
|
||||
|
||||
type
|
||||
ElementDeclHandler* = proc (userData: pointer, name: cstring,
|
||||
model: ptr Content){.cdecl.}
|
||||
{.deprecated: [TElementDeclHandler: ElementDeclHandler].}
|
||||
|
||||
proc setElementDeclHandler*(parser: PParser, eldecl: ElementDeclHandler){.
|
||||
cdecl, importc: "XML_SetElementDeclHandler", dynlib: expatDll.}
|
||||
# The Attlist declaration handler is called for *each* attribute. So
|
||||
# a single Attlist declaration with multiple attributes declared will
|
||||
# generate multiple calls to this handler. The "default" parameter
|
||||
# may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
|
||||
# keyword. The "isrequired" parameter will be true and the default
|
||||
# value will be NULL in the case of "#REQUIRED". If "isrequired" is
|
||||
# true and default is non-NULL, then this is a "#FIXED" default.
|
||||
#
|
||||
|
||||
type
|
||||
AttlistDeclHandler* = proc (userData: pointer, elname: cstring,
|
||||
attname: cstring, attType: cstring,
|
||||
dflt: cstring, isrequired: cint){.cdecl.}
|
||||
{.deprecated: [TAttlistDeclHandler: AttlistDeclHandler].}
|
||||
|
||||
proc setAttlistDeclHandler*(parser: PParser, attdecl: AttlistDeclHandler){.
|
||||
cdecl, importc: "XML_SetAttlistDeclHandler", dynlib: expatDll.}
|
||||
# The XML declaration handler is called for *both* XML declarations
|
||||
# and text declarations. The way to distinguish is that the version
|
||||
# parameter will be NULL for text declarations. The encoding
|
||||
# parameter may be NULL for XML declarations. The standalone
|
||||
# parameter will be -1, 0, or 1 indicating respectively that there
|
||||
# was no standalone parameter in the declaration, that it was given
|
||||
# as no, or that it was given as yes.
|
||||
#
|
||||
|
||||
type
|
||||
XmlDeclHandler* = proc (userData: pointer, version: cstring,
|
||||
encoding: cstring, standalone: cint){.cdecl.}
|
||||
{.deprecated: [TXmlDeclHandler: XmlDeclHandler].}
|
||||
|
||||
proc setXmlDeclHandler*(parser: PParser, xmldecl: XmlDeclHandler){.cdecl,
|
||||
importc: "XML_SetXmlDeclHandler", dynlib: expatDll.}
|
||||
type
|
||||
Memory_Handling_Suite*{.pure, final.} = object
|
||||
mallocFcn*: proc (size: int): pointer{.cdecl.}
|
||||
reallocFcn*: proc (p: pointer, size: int): pointer{.cdecl.}
|
||||
freeFcn*: proc (p: pointer){.cdecl.}
|
||||
{.deprecated: [TMemory_Handling_Suite: MemoryHandlingSuite].}
|
||||
|
||||
# Constructs a new parser; encoding is the encoding specified by the
|
||||
# external protocol or NULL if there is none specified.
|
||||
#
|
||||
|
||||
proc parserCreate*(encoding: cstring): PParser{.cdecl,
|
||||
importc: "XML_ParserCreate", dynlib: expatDll.}
|
||||
# Constructs a new parser and namespace processor. Element type
|
||||
# names and attribute names that belong to a namespace will be
|
||||
# expanded; unprefixed attribute names are never expanded; unprefixed
|
||||
# element type names are expanded only if there is a default
|
||||
# namespace. The expanded name is the concatenation of the namespace
|
||||
# URI, the namespace separator character, and the local part of the
|
||||
# name. If the namespace separator is '\0' then the namespace URI
|
||||
# and the local part will be concatenated without any separator.
|
||||
# It is a programming error to use the separator '\0' with namespace
|
||||
# triplets (see XML_SetReturnNSTriplet).
|
||||
#
|
||||
|
||||
proc parserCreateNS*(encoding: cstring, namespaceSeparator: char): PParser{.
|
||||
cdecl, importc: "XML_ParserCreateNS", dynlib: expatDll.}
|
||||
# Constructs a new parser using the memory management suite referred to
|
||||
# by memsuite. If memsuite is NULL, then use the standard library memory
|
||||
# suite. If namespaceSeparator is non-NULL it creates a parser with
|
||||
# namespace processing as described above. The character pointed at
|
||||
# will serve as the namespace separator.
|
||||
#
|
||||
# All further memory operations used for the created parser will come from
|
||||
# the given suite.
|
||||
#
|
||||
|
||||
proc parserCreateMM*(encoding: cstring, memsuite: ptr TMemoryHandlingSuite,
|
||||
namespaceSeparator: cstring): PParser{.cdecl,
|
||||
importc: "XML_ParserCreate_MM", dynlib: expatDll.}
|
||||
# Prepare a parser object to be re-used. This is particularly
|
||||
# valuable when memory allocation overhead is disproportionatly high,
|
||||
# such as when a large number of small documnents need to be parsed.
|
||||
# All handlers are cleared from the parser, except for the
|
||||
# unknownEncodingHandler. The parser's external state is re-initialized
|
||||
# except for the values of ns and ns_triplets.
|
||||
#
|
||||
# Added in Expat 1.95.3.
|
||||
#
|
||||
|
||||
proc parserReset*(parser: PParser, encoding: cstring): bool{.cdecl,
|
||||
importc: "XML_ParserReset", dynlib: expatDll.}
|
||||
# atts is array of name/value pairs, terminated by 0;
|
||||
# names and values are 0 terminated.
|
||||
#
|
||||
|
||||
type
|
||||
StartElementHandler* = proc (userData: pointer, name: cstring,
|
||||
atts: cstringArray){.cdecl.}
|
||||
EndElementHandler* = proc (userData: pointer, name: cstring){.cdecl.}
|
||||
{.deprecated: [TStartElementHandler: StartElementHandler,
|
||||
TEndElementHandler: EndElementHandler].}
|
||||
# s is not 0 terminated.
|
||||
|
||||
type
|
||||
CharacterDataHandler* = proc (userData: pointer, s: cstring, len: cint){.
|
||||
cdecl.}
|
||||
{.deprecated: [TCharacterDataHandler: CharacterDataHandler].}
|
||||
# target and data are 0 terminated
|
||||
|
||||
type
|
||||
ProcessingInstructionHandler* = proc (userData: pointer, target: cstring,
|
||||
data: cstring){.cdecl.}
|
||||
{.deprecated: [TProcessingInstructionHandler: ProcessingInstructionHandler].}
|
||||
|
||||
# data is 0 terminated
|
||||
|
||||
type
|
||||
CommentHandler* = proc (userData: pointer, data: cstring){.cdecl.}
|
||||
StartCdataSectionHandler* = proc (userData: pointer){.cdecl.}
|
||||
EndCdataSectionHandler* = proc (userData: pointer){.cdecl.}
|
||||
{.deprecated: [TCommentHandler: CommentHandler,
|
||||
TStartCdataSectionHandler: StartCdataSectionHandler,
|
||||
TEndCdataSectionHandler: EndCdataSectionHandler].}
|
||||
# This is called for any characters in the XML document for which
|
||||
# there is no applicable handler. This includes both characters that
|
||||
# are part of markup which is of a kind that is not reported
|
||||
# (comments, markup declarations), or characters that are part of a
|
||||
# construct which could be reported but for which no handler has been
|
||||
# supplied. The characters are passed exactly as they were in the XML
|
||||
# document except that they will be encoded in UTF-8 or UTF-16.
|
||||
# Line boundaries are not normalized. Note that a byte order mark
|
||||
# character is not passed to the default handler. There are no
|
||||
# guarantees about how characters are divided between calls to the
|
||||
# default handler: for example, a comment might be split between
|
||||
# multiple calls.
|
||||
#
|
||||
|
||||
type
|
||||
DefaultHandler* = proc (userData: pointer, s: cstring, len: cint){.cdecl.}
|
||||
{.deprecated: [TDefaultHandler: DefaultHandler].}
|
||||
# This is called for the start of the DOCTYPE declaration, before
|
||||
# any DTD or internal subset is parsed.
|
||||
#
|
||||
|
||||
type
|
||||
StartDoctypeDeclHandler* = proc (userData: pointer, doctypeName: cstring,
|
||||
sysid: cstring, pubid: cstring,
|
||||
hasInternalSubset: cint){.cdecl.}
|
||||
{.deprecated: [TStartDoctypeDeclHandler: StartDoctypeDeclHandler].}
|
||||
|
||||
# This is called for the start of the DOCTYPE declaration when the
|
||||
# closing > is encountered, but after processing any external
|
||||
# subset.
|
||||
#
|
||||
|
||||
type
|
||||
EndDoctypeDeclHandler* = proc (userData: pointer){.cdecl.}
|
||||
{.deprecated: [TEndDoctypeDeclHandler: EndDoctypeDeclHandler].}
|
||||
|
||||
# This is called for entity declarations. The is_parameter_entity
|
||||
# argument will be non-zero if the entity is a parameter entity, zero
|
||||
# otherwise.
|
||||
#
|
||||
# For internal entities (<!ENTITY foo "bar">), value will
|
||||
# be non-NULL and systemId, publicID, and notationName will be NULL.
|
||||
# The value string is NOT nul-terminated; the length is provided in
|
||||
# the value_length argument. Since it is legal to have zero-length
|
||||
# values, do not use this argument to test for internal entities.
|
||||
#
|
||||
# For external entities, value will be NULL and systemId will be
|
||||
# non-NULL. The publicId argument will be NULL unless a public
|
||||
# identifier was provided. The notationName argument will have a
|
||||
# non-NULL value only for unparsed entity declarations.
|
||||
#
|
||||
# Note that is_parameter_entity can't be changed to XML_Bool, since
|
||||
# that would break binary compatibility.
|
||||
#
|
||||
|
||||
type
|
||||
EntityDeclHandler* = proc (userData: pointer, entityName: cstring,
|
||||
isParameterEntity: cint, value: cstring,
|
||||
valueLength: cint, base: cstring,
|
||||
systemId: cstring, publicId: cstring,
|
||||
notationName: cstring){.cdecl.}
|
||||
{.deprecated: [TEntityDeclHandler: EntityDeclHandler].}
|
||||
|
||||
proc setEntityDeclHandler*(parser: PParser, handler: EntityDeclHandler){.cdecl,
|
||||
importc: "XML_SetEntityDeclHandler", dynlib: expatDll.}
|
||||
# OBSOLETE -- OBSOLETE -- OBSOLETE
|
||||
# This handler has been superceded by the EntityDeclHandler above.
|
||||
# It is provided here for backward compatibility.
|
||||
#
|
||||
# This is called for a declaration of an unparsed (NDATA) entity.
|
||||
# The base argument is whatever was set by XML_SetBase. The
|
||||
# entityName, systemId and notationName arguments will never be
|
||||
# NULL. The other arguments may be.
|
||||
#
|
||||
|
||||
type
|
||||
UnparsedEntityDeclHandler* = proc (userData: pointer, entityName: cstring,
|
||||
base: cstring, systemId: cstring,
|
||||
publicId, notationName: cstring){.
|
||||
cdecl.}
|
||||
{.deprecated: [TUnparsedEntityDeclHandler: UnparsedEntityDeclHandler].}
|
||||
|
||||
# This is called for a declaration of notation. The base argument is
|
||||
# whatever was set by XML_SetBase. The notationName will never be
|
||||
# NULL. The other arguments can be.
|
||||
#
|
||||
|
||||
type
|
||||
NotationDeclHandler* = proc (userData: pointer, notationName: cstring,
|
||||
base: cstring, systemId: cstring,
|
||||
publicId: cstring){.cdecl.}
|
||||
{.deprecated: [TNotationDeclHandler: NotationDeclHandler].}
|
||||
|
||||
# When namespace processing is enabled, these are called once for
|
||||
# each namespace declaration. The call to the start and end element
|
||||
# handlers occur between the calls to the start and end namespace
|
||||
# declaration handlers. For an xmlns attribute, prefix will be
|
||||
# NULL. For an xmlns="" attribute, uri will be NULL.
|
||||
#
|
||||
|
||||
type
|
||||
StartNamespaceDeclHandler* = proc (userData: pointer, prefix: cstring,
|
||||
uri: cstring){.cdecl.}
|
||||
EndNamespaceDeclHandler* = proc (userData: pointer, prefix: cstring){.cdecl.}
|
||||
{.deprecated: [TStartNamespaceDeclHandler: StartNamespaceDeclHandler,
|
||||
TEndNamespaceDeclHandler: EndNamespaceDeclHandler].}
|
||||
# This is called if the document is not standalone, that is, it has an
|
||||
# external subset or a reference to a parameter entity, but does not
|
||||
# have standalone="yes". If this handler returns XML_STATUS_ERROR,
|
||||
# then processing will not continue, and the parser will return a
|
||||
# XML_ERROR_NOT_STANDALONE error.
|
||||
# If parameter entity parsing is enabled, then in addition to the
|
||||
# conditions above this handler will only be called if the referenced
|
||||
# entity was actually read.
|
||||
#
|
||||
|
||||
type
|
||||
NotStandaloneHandler* = proc (userData: pointer): cint{.cdecl.}
|
||||
{.deprecated: [TNotStandaloneHandler: NotStandaloneHandler].}
|
||||
|
||||
# This is called for a reference to an external parsed general
|
||||
# entity. The referenced entity is not automatically parsed. The
|
||||
# application can parse it immediately or later using
|
||||
# XML_ExternalEntityParserCreate.
|
||||
#
|
||||
# The parser argument is the parser parsing the entity containing the
|
||||
# reference; it can be passed as the parser argument to
|
||||
# XML_ExternalEntityParserCreate. The systemId argument is the
|
||||
# system identifier as specified in the entity declaration; it will
|
||||
# not be NULL.
|
||||
#
|
||||
# The base argument is the system identifier that should be used as
|
||||
# the base for resolving systemId if systemId was relative; this is
|
||||
# set by XML_SetBase; it may be NULL.
|
||||
#
|
||||
# The publicId argument is the public identifier as specified in the
|
||||
# entity declaration, or NULL if none was specified; the whitespace
|
||||
# in the public identifier will have been normalized as required by
|
||||
# the XML spec.
|
||||
#
|
||||
# The context argument specifies the parsing context in the format
|
||||
# expected by the context argument to XML_ExternalEntityParserCreate;
|
||||
# context is valid only until the handler returns, so if the
|
||||
# referenced entity is to be parsed later, it must be copied.
|
||||
# context is NULL only when the entity is a parameter entity.
|
||||
#
|
||||
# The handler should return XML_STATUS_ERROR if processing should not
|
||||
# continue because of a fatal error in the handling of the external
|
||||
# entity. In this case the calling parser will return an
|
||||
# XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
|
||||
#
|
||||
# Note that unlike other handlers the first argument is the parser,
|
||||
# not userData.
|
||||
#
|
||||
|
||||
type
|
||||
ExternalEntityRefHandler* = proc (parser: PParser, context: cstring,
|
||||
base: cstring, systemId: cstring,
|
||||
publicId: cstring): cint{.cdecl.}
|
||||
{.deprecated: [TExternalEntityRefHandler: ExternalEntityRefHandler].}
|
||||
# This is called in two situations:
|
||||
# 1) An entity reference is encountered for which no declaration
|
||||
# has been read *and* this is not an error.
|
||||
# 2) An internal entity reference is read, but not expanded, because
|
||||
# XML_SetDefaultHandler has been called.
|
||||
# Note: skipped parameter entities in declarations and skipped general
|
||||
# entities in attribute values cannot be reported, because
|
||||
# the event would be out of sync with the reporting of the
|
||||
# declarations or attribute values
|
||||
#
|
||||
|
||||
type
|
||||
SkippedEntityHandler* = proc (userData: pointer, entityName: cstring,
|
||||
isParameterEntity: cint){.cdecl.}
|
||||
{.deprecated: [TSkippedEntityHandler: SkippedEntityHandler].}
|
||||
|
||||
# This structure is filled in by the XML_UnknownEncodingHandler to
|
||||
# provide information to the parser about encodings that are unknown
|
||||
# to the parser.
|
||||
#
|
||||
# The map[b] member gives information about byte sequences whose
|
||||
# first byte is b.
|
||||
#
|
||||
# If map[b] is c where c is >= 0, then b by itself encodes the
|
||||
# Unicode scalar value c.
|
||||
#
|
||||
# If map[b] is -1, then the byte sequence is malformed.
|
||||
#
|
||||
# If map[b] is -n, where n >= 2, then b is the first byte of an
|
||||
# n-byte sequence that encodes a single Unicode scalar value.
|
||||
#
|
||||
# The data member will be passed as the first argument to the convert
|
||||
# function.
|
||||
#
|
||||
# The convert function is used to convert multibyte sequences; s will
|
||||
# point to a n-byte sequence where map[(unsigned char)*s] == -n. The
|
||||
# convert function must return the Unicode scalar value represented
|
||||
# by this byte sequence or -1 if the byte sequence is malformed.
|
||||
#
|
||||
# The convert function may be NULL if the encoding is a single-byte
|
||||
# encoding, that is if map[b] >= -1 for all bytes b.
|
||||
#
|
||||
# When the parser is finished with the encoding, then if release is
|
||||
# not NULL, it will call release passing it the data member; once
|
||||
# release has been called, the convert function will not be called
|
||||
# again.
|
||||
#
|
||||
# Expat places certain restrictions on the encodings that are supported
|
||||
# using this mechanism.
|
||||
#
|
||||
# 1. Every ASCII character that can appear in a well-formed XML document,
|
||||
# other than the characters
|
||||
#
|
||||
# $@\^`{}~
|
||||
#
|
||||
# must be represented by a single byte, and that byte must be the
|
||||
# same byte that represents that character in ASCII.
|
||||
#
|
||||
# 2. No character may require more than 4 bytes to encode.
|
||||
#
|
||||
# 3. All characters encoded must have Unicode scalar values <=
|
||||
# 0xFFFF, (i.e., characters that would be encoded by surrogates in
|
||||
# UTF-16 are not allowed). Note that this restriction doesn't
|
||||
# apply to the built-in support for UTF-8 and UTF-16.
|
||||
#
|
||||
# 4. No Unicode character may be encoded by more than one distinct
|
||||
# sequence of bytes.
|
||||
#
|
||||
|
||||
type
|
||||
Encoding*{.pure, final.} = object
|
||||
map*: array[0..256 - 1, cint]
|
||||
data*: pointer
|
||||
convert*: proc (data: pointer, s: cstring): cint{.cdecl.}
|
||||
release*: proc (data: pointer){.cdecl.}
|
||||
{.deprecated: [TEncoding: Encoding].}
|
||||
|
||||
|
||||
# This is called for an encoding that is unknown to the parser.
|
||||
#
|
||||
# The encodingHandlerData argument is that which was passed as the
|
||||
# second argument to XML_SetUnknownEncodingHandler.
|
||||
#
|
||||
# The name argument gives the name of the encoding as specified in
|
||||
# the encoding declaration.
|
||||
#
|
||||
# If the callback can provide information about the encoding, it must
|
||||
# fill in the XML_Encoding structure, and return XML_STATUS_OK.
|
||||
# Otherwise it must return XML_STATUS_ERROR.
|
||||
#
|
||||
# If info does not describe a suitable encoding, then the parser will
|
||||
# return an XML_UNKNOWN_ENCODING error.
|
||||
#
|
||||
|
||||
type
|
||||
UnknownEncodingHandler* = proc (encodingHandlerData: pointer, name: cstring,
|
||||
info: ptr Encoding): cint{.cdecl.}
|
||||
{.deprecated: [TUnknownEncodingHandler: UnknownEncodingHandler].}
|
||||
|
||||
proc setElementHandler*(parser: PParser, start: StartElementHandler,
|
||||
endHandler: EndElementHandler){.cdecl,
|
||||
importc: "XML_SetElementHandler", dynlib: expatDll.}
|
||||
proc setStartElementHandler*(parser: PParser, handler: StartElementHandler){.
|
||||
cdecl, importc: "XML_SetStartElementHandler", dynlib: expatDll.}
|
||||
proc setEndElementHandler*(parser: PParser, handler: EndElementHandler){.cdecl,
|
||||
importc: "XML_SetEndElementHandler", dynlib: expatDll.}
|
||||
proc setCharacterDataHandler*(parser: PParser, handler: CharacterDataHandler){.
|
||||
cdecl, importc: "XML_SetCharacterDataHandler", dynlib: expatDll.}
|
||||
proc setProcessingInstructionHandler*(parser: PParser,
|
||||
handler: ProcessingInstructionHandler){.
|
||||
cdecl, importc: "XML_SetProcessingInstructionHandler", dynlib: expatDll.}
|
||||
proc setCommentHandler*(parser: PParser, handler: CommentHandler){.cdecl,
|
||||
importc: "XML_SetCommentHandler", dynlib: expatDll.}
|
||||
proc setCdataSectionHandler*(parser: PParser, start: StartCdataSectionHandler,
|
||||
endHandler: EndCdataSectionHandler){.cdecl,
|
||||
importc: "XML_SetCdataSectionHandler", dynlib: expatDll.}
|
||||
proc setStartCdataSectionHandler*(parser: PParser,
|
||||
start: StartCdataSectionHandler){.cdecl,
|
||||
importc: "XML_SetStartCdataSectionHandler", dynlib: expatDll.}
|
||||
proc setEndCdataSectionHandler*(parser: PParser,
|
||||
endHandler: EndCdataSectionHandler){.cdecl,
|
||||
importc: "XML_SetEndCdataSectionHandler", dynlib: expatDll.}
|
||||
# This sets the default handler and also inhibits expansion of
|
||||
# internal entities. These entity references will be passed to the
|
||||
# default handler, or to the skipped entity handler, if one is set.
|
||||
#
|
||||
|
||||
proc setDefaultHandler*(parser: PParser, handler: DefaultHandler){.cdecl,
|
||||
importc: "XML_SetDefaultHandler", dynlib: expatDll.}
|
||||
# This sets the default handler but does not inhibit expansion of
|
||||
# internal entities. The entity reference will not be passed to the
|
||||
# default handler.
|
||||
#
|
||||
|
||||
proc setDefaultHandlerExpand*(parser: PParser, handler: DefaultHandler){.cdecl,
|
||||
importc: "XML_SetDefaultHandlerExpand", dynlib: expatDll.}
|
||||
proc setDoctypeDeclHandler*(parser: PParser, start: StartDoctypeDeclHandler,
|
||||
endHandler: EndDoctypeDeclHandler){.cdecl,
|
||||
importc: "XML_SetDoctypeDeclHandler", dynlib: expatDll.}
|
||||
proc setStartDoctypeDeclHandler*(parser: PParser,
|
||||
start: StartDoctypeDeclHandler){.cdecl,
|
||||
importc: "XML_SetStartDoctypeDeclHandler", dynlib: expatDll.}
|
||||
proc setEndDoctypeDeclHandler*(parser: PParser,
|
||||
endHandler: EndDoctypeDeclHandler){.cdecl,
|
||||
importc: "XML_SetEndDoctypeDeclHandler", dynlib: expatDll.}
|
||||
proc setUnparsedEntityDeclHandler*(parser: PParser,
|
||||
handler: UnparsedEntityDeclHandler){.cdecl,
|
||||
importc: "XML_SetUnparsedEntityDeclHandler", dynlib: expatDll.}
|
||||
proc setNotationDeclHandler*(parser: PParser, handler: NotationDeclHandler){.
|
||||
cdecl, importc: "XML_SetNotationDeclHandler", dynlib: expatDll.}
|
||||
proc setNamespaceDeclHandler*(parser: PParser,
|
||||
start: StartNamespaceDeclHandler,
|
||||
endHandler: EndNamespaceDeclHandler){.cdecl,
|
||||
importc: "XML_SetNamespaceDeclHandler", dynlib: expatDll.}
|
||||
proc setStartNamespaceDeclHandler*(parser: PParser,
|
||||
start: StartNamespaceDeclHandler){.cdecl,
|
||||
importc: "XML_SetStartNamespaceDeclHandler", dynlib: expatDll.}
|
||||
proc setEndNamespaceDeclHandler*(parser: PParser,
|
||||
endHandler: EndNamespaceDeclHandler){.cdecl,
|
||||
importc: "XML_SetEndNamespaceDeclHandler", dynlib: expatDll.}
|
||||
proc setNotStandaloneHandler*(parser: PParser, handler: NotStandaloneHandler){.
|
||||
cdecl, importc: "XML_SetNotStandaloneHandler", dynlib: expatDll.}
|
||||
proc setExternalEntityRefHandler*(parser: PParser,
|
||||
handler: ExternalEntityRefHandler){.cdecl,
|
||||
importc: "XML_SetExternalEntityRefHandler", dynlib: expatDll.}
|
||||
# If a non-NULL value for arg is specified here, then it will be
|
||||
# passed as the first argument to the external entity ref handler
|
||||
# instead of the parser object.
|
||||
#
|
||||
|
||||
proc setExternalEntityRefHandlerArg*(parser: PParser, arg: pointer){.cdecl,
|
||||
importc: "XML_SetExternalEntityRefHandlerArg", dynlib: expatDll.}
|
||||
proc setSkippedEntityHandler*(parser: PParser, handler: SkippedEntityHandler){.
|
||||
cdecl, importc: "XML_SetSkippedEntityHandler", dynlib: expatDll.}
|
||||
proc setUnknownEncodingHandler*(parser: PParser,
|
||||
handler: UnknownEncodingHandler,
|
||||
encodingHandlerData: pointer){.cdecl,
|
||||
importc: "XML_SetUnknownEncodingHandler", dynlib: expatDll.}
|
||||
# This can be called within a handler for a start element, end
|
||||
# element, processing instruction or character data. It causes the
|
||||
# corresponding markup to be passed to the default handler.
|
||||
#
|
||||
|
||||
proc defaultCurrent*(parser: PParser){.cdecl, importc: "XML_DefaultCurrent",
|
||||
dynlib: expatDll.}
|
||||
# If do_nst is non-zero, and namespace processing is in effect, and
|
||||
# a name has a prefix (i.e. an explicit namespace qualifier) then
|
||||
# that name is returned as a triplet in a single string separated by
|
||||
# the separator character specified when the parser was created: URI
|
||||
# + sep + local_name + sep + prefix.
|
||||
#
|
||||
# If do_nst is zero, then namespace information is returned in the
|
||||
# default manner (URI + sep + local_name) whether or not the name
|
||||
# has a prefix.
|
||||
#
|
||||
# Note: Calling XML_SetReturnNSTriplet after XML_Parse or
|
||||
# XML_ParseBuffer has no effect.
|
||||
#
|
||||
|
||||
proc setReturnNSTriplet*(parser: PParser, doNst: cint){.cdecl,
|
||||
importc: "XML_SetReturnNSTriplet", dynlib: expatDll.}
|
||||
# This value is passed as the userData argument to callbacks.
|
||||
|
||||
proc setUserData*(parser: PParser, userData: pointer){.cdecl,
|
||||
importc: "XML_SetUserData", dynlib: expatDll.}
|
||||
# Returns the last value set by XML_SetUserData or NULL.
|
||||
|
||||
template getUserData*(parser: expr): expr =
|
||||
(cast[ptr pointer]((parser))[] )
|
||||
|
||||
# This is equivalent to supplying an encoding argument to
|
||||
# XML_ParserCreate. On success XML_SetEncoding returns non-zero,
|
||||
# zero otherwise.
|
||||
# Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
|
||||
# has no effect and returns XML_STATUS_ERROR.
|
||||
#
|
||||
|
||||
proc setEncoding*(parser: PParser, encoding: cstring): Status{.cdecl,
|
||||
importc: "XML_SetEncoding", dynlib: expatDll.}
|
||||
# If this function is called, then the parser will be passed as the
|
||||
# first argument to callbacks instead of userData. The userData will
|
||||
# still be accessible using XML_GetUserData.
|
||||
#
|
||||
|
||||
proc useParserAsHandlerArg*(parser: PParser){.cdecl,
|
||||
importc: "XML_UseParserAsHandlerArg", dynlib: expatDll.}
|
||||
# If useDTD == XML_TRUE is passed to this function, then the parser
|
||||
# will assume that there is an external subset, even if none is
|
||||
# specified in the document. In such a case the parser will call the
|
||||
# externalEntityRefHandler with a value of NULL for the systemId
|
||||
# argument (the publicId and context arguments will be NULL as well).
|
||||
# Note: For the purpose of checking WFC: Entity Declared, passing
|
||||
# useDTD == XML_TRUE will make the parser behave as if the document
|
||||
# had a DTD with an external subset.
|
||||
# Note: If this function is called, then this must be done before
|
||||
# the first call to XML_Parse or XML_ParseBuffer, since it will
|
||||
# have no effect after that. Returns
|
||||
# XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
|
||||
# Note: If the document does not have a DOCTYPE declaration at all,
|
||||
# then startDoctypeDeclHandler and endDoctypeDeclHandler will not
|
||||
# be called, despite an external subset being parsed.
|
||||
# Note: If XML_DTD is not defined when Expat is compiled, returns
|
||||
# XML_ERROR_FEATURE_REQUIRES_XML_DTD.
|
||||
#
|
||||
|
||||
proc useForeignDTD*(parser: PParser, useDTD: bool): Error{.cdecl,
|
||||
importc: "XML_UseForeignDTD", dynlib: expatDll.}
|
||||
# Sets the base to be used for resolving relative URIs in system
|
||||
# identifiers in declarations. Resolving relative identifiers is
|
||||
# left to the application: this value will be passed through as the
|
||||
# base argument to the XML_ExternalEntityRefHandler,
|
||||
# XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
|
||||
# argument will be copied. Returns XML_STATUS_ERROR if out of memory,
|
||||
# XML_STATUS_OK otherwise.
|
||||
#
|
||||
|
||||
proc setBase*(parser: PParser, base: cstring): Status{.cdecl,
|
||||
importc: "XML_SetBase", dynlib: expatDll.}
|
||||
proc getBase*(parser: PParser): cstring{.cdecl, importc: "XML_GetBase",
|
||||
dynlib: expatDll.}
|
||||
# Returns the number of the attribute/value pairs passed in last call
|
||||
# to the XML_StartElementHandler that were specified in the start-tag
|
||||
# rather than defaulted. Each attribute/value pair counts as 2; thus
|
||||
# this correspondds to an index into the atts array passed to the
|
||||
# XML_StartElementHandler.
|
||||
#
|
||||
|
||||
proc getSpecifiedAttributeCount*(parser: PParser): cint{.cdecl,
|
||||
importc: "XML_GetSpecifiedAttributeCount", dynlib: expatDll.}
|
||||
# Returns the index of the ID attribute passed in the last call to
|
||||
# XML_StartElementHandler, or -1 if there is no ID attribute. Each
|
||||
# attribute/value pair counts as 2; thus this correspondds to an
|
||||
# index into the atts array passed to the XML_StartElementHandler.
|
||||
#
|
||||
|
||||
proc getIdAttributeIndex*(parser: PParser): cint{.cdecl,
|
||||
importc: "XML_GetIdAttributeIndex", dynlib: expatDll.}
|
||||
# Parses some input. Returns XML_STATUS_ERROR if a fatal error is
|
||||
# detected. The last call to XML_Parse must have isFinal true; len
|
||||
# may be zero for this call (or any other).
|
||||
#
|
||||
# Though the return values for these functions has always been
|
||||
# described as a Boolean value, the implementation, at least for the
|
||||
# 1.95.x series, has always returned exactly one of the XML_Status
|
||||
# values.
|
||||
#
|
||||
|
||||
proc parse*(parser: PParser, s: cstring, len: cint, isFinal: cint): Status{.
|
||||
cdecl, importc: "XML_Parse", dynlib: expatDll.}
|
||||
proc getBuffer*(parser: PParser, len: cint): pointer{.cdecl,
|
||||
importc: "XML_GetBuffer", dynlib: expatDll.}
|
||||
proc parseBuffer*(parser: PParser, len: cint, isFinal: cint): Status{.cdecl,
|
||||
importc: "XML_ParseBuffer", dynlib: expatDll.}
|
||||
# Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return.
|
||||
# Must be called from within a call-back handler, except when aborting
|
||||
# (resumable = 0) an already suspended parser. Some call-backs may
|
||||
# still follow because they would otherwise get lost. Examples:
|
||||
# - endElementHandler() for empty elements when stopped in
|
||||
# startElementHandler(),
|
||||
# - endNameSpaceDeclHandler() when stopped in endElementHandler(),
|
||||
# and possibly others.
|
||||
#
|
||||
# Can be called from most handlers, including DTD related call-backs,
|
||||
# except when parsing an external parameter entity and resumable != 0.
|
||||
# Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise.
|
||||
# Possible error codes:
|
||||
# - XML_ERROR_SUSPENDED: when suspending an already suspended parser.
|
||||
# - XML_ERROR_FINISHED: when the parser has already finished.
|
||||
# - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE.
|
||||
#
|
||||
# When resumable != 0 (true) then parsing is suspended, that is,
|
||||
# XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED.
|
||||
# Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer()
|
||||
# return XML_STATUS_ERROR with error code XML_ERROR_ABORTED.
|
||||
#
|
||||
# Note*:
|
||||
# This will be applied to the current parser instance only, that is, if
|
||||
# there is a parent parser then it will continue parsing when the
|
||||
# externalEntityRefHandler() returns. It is up to the implementation of
|
||||
# the externalEntityRefHandler() to call XML_StopParser() on the parent
|
||||
# parser (recursively), if one wants to stop parsing altogether.
|
||||
#
|
||||
# When suspended, parsing can be resumed by calling XML_ResumeParser().
|
||||
#
|
||||
|
||||
proc stopParser*(parser: PParser, resumable: bool): Status{.cdecl,
|
||||
importc: "XML_StopParser", dynlib: expatDll.}
|
||||
# Resumes parsing after it has been suspended with XML_StopParser().
|
||||
# Must not be called from within a handler call-back. Returns same
|
||||
# status codes as XML_Parse() or XML_ParseBuffer().
|
||||
# Additional error code XML_ERROR_NOT_SUSPENDED possible.
|
||||
#
|
||||
# Note*:
|
||||
# This must be called on the most deeply nested child parser instance
|
||||
# first, and on its parent parser only after the child parser has finished,
|
||||
# to be applied recursively until the document entity's parser is restarted.
|
||||
# That is, the parent parser will not resume by itself and it is up to the
|
||||
# application to call XML_ResumeParser() on it at the appropriate moment.
|
||||
#
|
||||
|
||||
proc resumeParser*(parser: PParser): Status{.cdecl,
|
||||
importc: "XML_ResumeParser", dynlib: expatDll.}
|
||||
type
|
||||
TParsing* = enum
|
||||
INITIALIZED, PARSING, FINISHED, SUSPENDED
|
||||
ParsingStatus*{.pure, final.} = object
|
||||
parsing*: TParsing
|
||||
finalBuffer*: bool
|
||||
{.deprecated: [#TParsing: Parsing, # Naming conflict if we drop the `T`
|
||||
TParsingStatus: ParsingStatus].}
|
||||
|
||||
# Returns status of parser with respect to being initialized, parsing,
|
||||
# finished, or suspended and processing the final buffer.
|
||||
# XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus,
|
||||
# XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED
|
||||
#
|
||||
|
||||
proc getParsingStatus*(parser: PParser, status: ptr ParsingStatus){.cdecl,
|
||||
importc: "XML_GetParsingStatus", dynlib: expatDll.}
|
||||
# Creates an XML_Parser object that can parse an external general
|
||||
# entity; context is a '\0'-terminated string specifying the parse
|
||||
# context; encoding is a '\0'-terminated string giving the name of
|
||||
# the externally specified encoding, or NULL if there is no
|
||||
# externally specified encoding. The context string consists of a
|
||||
# sequence of tokens separated by formfeeds (\f); a token consisting
|
||||
# of a name specifies that the general entity of the name is open; a
|
||||
# token of the form prefix=uri specifies the namespace for a
|
||||
# particular prefix; a token of the form =uri specifies the default
|
||||
# namespace. This can be called at any point after the first call to
|
||||
# an ExternalEntityRefHandler so longer as the parser has not yet
|
||||
# been freed. The new parser is completely independent and may
|
||||
# safely be used in a separate thread. The handlers and userData are
|
||||
# initialized from the parser argument. Returns NULL if out of memory.
|
||||
# Otherwise returns a new XML_Parser object.
|
||||
#
|
||||
|
||||
proc externalEntityParserCreate*(parser: PParser, context: cstring,
|
||||
encoding: cstring): PParser{.cdecl,
|
||||
importc: "XML_ExternalEntityParserCreate", dynlib: expatDll.}
|
||||
type
|
||||
ParamEntityParsing* = enum
|
||||
PARAM_ENTITY_PARSING_NEVER, PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
|
||||
PARAM_ENTITY_PARSING_ALWAYS
|
||||
{.deprecated: [TParamEntityParsing: ParamEntityParsing].}
|
||||
|
||||
# Controls parsing of parameter entities (including the external DTD
|
||||
# subset). If parsing of parameter entities is enabled, then
|
||||
# references to external parameter entities (including the external
|
||||
# DTD subset) will be passed to the handler set with
|
||||
# XML_SetExternalEntityRefHandler. The context passed will be 0.
|
||||
#
|
||||
# Unlike external general entities, external parameter entities can
|
||||
# only be parsed synchronously. If the external parameter entity is
|
||||
# to be parsed, it must be parsed during the call to the external
|
||||
# entity ref handler: the complete sequence of
|
||||
# XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
|
||||
# XML_ParserFree calls must be made during this call. After
|
||||
# XML_ExternalEntityParserCreate has been called to create the parser
|
||||
# for the external parameter entity (context must be 0 for this
|
||||
# call), it is illegal to make any calls on the old parser until
|
||||
# XML_ParserFree has been called on the newly created parser.
|
||||
# If the library has been compiled without support for parameter
|
||||
# entity parsing (ie without XML_DTD being defined), then
|
||||
# XML_SetParamEntityParsing will return 0 if parsing of parameter
|
||||
# entities is requested; otherwise it will return non-zero.
|
||||
# Note: If XML_SetParamEntityParsing is called after XML_Parse or
|
||||
# XML_ParseBuffer, then it has no effect and will always return 0.
|
||||
#
|
||||
|
||||
proc setParamEntityParsing*(parser: PParser, parsing: ParamEntityParsing): cint{.
|
||||
cdecl, importc: "XML_SetParamEntityParsing", dynlib: expatDll.}
|
||||
# If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
|
||||
# XML_GetErrorCode returns information about the error.
|
||||
#
|
||||
|
||||
proc getErrorCode*(parser: PParser): Error{.cdecl, importc: "XML_GetErrorCode",
|
||||
dynlib: expatDll.}
|
||||
# These functions return information about the current parse
|
||||
# location. They may be called from any callback called to report
|
||||
# some parse event; in this case the location is the location of the
|
||||
# first of the sequence of characters that generated the event. When
|
||||
# called from callbacks generated by declarations in the document
|
||||
# prologue, the location identified isn't as neatly defined, but will
|
||||
# be within the relevant markup. When called outside of the callback
|
||||
# functions, the position indicated will be just past the last parse
|
||||
# event (regardless of whether there was an associated callback).
|
||||
#
|
||||
# They may also be called after returning from a call to XML_Parse
|
||||
# or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then
|
||||
# the location is the location of the character at which the error
|
||||
# was detected; otherwise the location is the location of the last
|
||||
# parse event, as described above.
|
||||
#
|
||||
|
||||
proc getCurrentLineNumber*(parser: PParser): int{.cdecl,
|
||||
importc: "XML_GetCurrentLineNumber", dynlib: expatDll.}
|
||||
proc getCurrentColumnNumber*(parser: PParser): int{.cdecl,
|
||||
importc: "XML_GetCurrentColumnNumber", dynlib: expatDll.}
|
||||
proc getCurrentByteIndex*(parser: PParser): int{.cdecl,
|
||||
importc: "XML_GetCurrentByteIndex", dynlib: expatDll.}
|
||||
# Return the number of bytes in the current event.
|
||||
# Returns 0 if the event is in an internal entity.
|
||||
#
|
||||
|
||||
proc getCurrentByteCount*(parser: PParser): cint{.cdecl,
|
||||
importc: "XML_GetCurrentByteCount", dynlib: expatDll.}
|
||||
# If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
|
||||
# the integer pointed to by offset to the offset within this buffer
|
||||
# of the current parse position, and sets the integer pointed to by size
|
||||
# to the size of this buffer (the number of input bytes). Otherwise
|
||||
# returns a NULL pointer. Also returns a NULL pointer if a parse isn't
|
||||
# active.
|
||||
#
|
||||
# NOTE: The character pointer returned should not be used outside
|
||||
# the handler that makes the call.
|
||||
#
|
||||
|
||||
proc getInputContext*(parser: PParser, offset: ptr cint, size: ptr cint): cstring{.
|
||||
cdecl, importc: "XML_GetInputContext", dynlib: expatDll.}
|
||||
# Frees the content model passed to the element declaration handler
|
||||
|
||||
proc freeContentModel*(parser: PParser, model: ptr Content){.cdecl,
|
||||
importc: "XML_FreeContentModel", dynlib: expatDll.}
|
||||
# Exposing the memory handling functions used in Expat
|
||||
|
||||
proc memMalloc*(parser: PParser, size: int): pointer{.cdecl,
|
||||
importc: "XML_MemMalloc", dynlib: expatDll.}
|
||||
proc memRealloc*(parser: PParser, p: pointer, size: int): pointer{.cdecl,
|
||||
importc: "XML_MemRealloc", dynlib: expatDll.}
|
||||
proc memFree*(parser: PParser, p: pointer){.cdecl, importc: "XML_MemFree",
|
||||
dynlib: expatDll.}
|
||||
# Frees memory used by the parser.
|
||||
|
||||
proc parserFree*(parser: PParser){.cdecl, importc: "XML_ParserFree",
|
||||
dynlib: expatDll.}
|
||||
# Returns a string describing the error.
|
||||
|
||||
proc errorString*(code: Error): cstring{.cdecl, importc: "XML_ErrorString",
|
||||
dynlib: expatDll.}
|
||||
# Return a string containing the version number of this expat
|
||||
|
||||
proc expatVersion*(): cstring{.cdecl, importc: "XML_ExpatVersion",
|
||||
dynlib: expatDll.}
|
||||
type
|
||||
Expat_Version*{.pure, final.} = object
|
||||
major*: cint
|
||||
minor*: cint
|
||||
micro*: cint
|
||||
{.deprecated: [TExpat_Version: ExpatVersion].}
|
||||
|
||||
# Return an XML_Expat_Version structure containing numeric version
|
||||
# number information for this version of expat.
|
||||
#
|
||||
|
||||
proc expatVersionInfo*(): ExpatVersion{.cdecl,
|
||||
importc: "XML_ExpatVersionInfo", dynlib: expatDll.}
|
||||
# Added in Expat 1.95.5.
|
||||
|
||||
type
|
||||
FeatureEnum* = enum
|
||||
FEATURE_END = 0, FEATURE_UNICODE, FEATURE_UNICODE_WCHAR_T, FEATURE_DTD,
|
||||
FEATURE_CONTEXT_BYTES, FEATURE_MIN_SIZE, FEATURE_SIZEOF_XML_CHAR,
|
||||
FEATURE_SIZEOF_XML_LCHAR, FEATURE_NS, FEATURE_LARGE_SIZE # Additional features must be added to the end of this enum.
|
||||
Feature*{.pure, final.} = object
|
||||
feature*: FeatureEnum
|
||||
name*: cstring
|
||||
value*: int
|
||||
{.deprecated: [TFeatureEnum: FeatureEnum, TFeature: Feature].}
|
||||
|
||||
proc getFeatureList*(): ptr Feature{.cdecl, importc: "XML_GetFeatureList",
|
||||
dynlib: expatDll.}
|
||||
# Expat follows the GNU/Linux convention of odd number minor version for
|
||||
# beta/development releases and even number minor version for stable
|
||||
# releases. Micro is bumped with each release, and set to 0 with each
|
||||
# change to major or minor version.
|
||||
#
|
||||
|
||||
const
|
||||
MAJOR_VERSION* = 2
|
||||
MINOR_VERSION* = 0
|
||||
MICRO_VERSION* = 1
|
||||
@@ -1,6 +1,12 @@
|
||||
#
|
||||
# Binding for the IUP GUI toolkit
|
||||
# (c) 2012 Andreas Rumpf
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2012 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
# C header files translated by hand
|
||||
# Licence of IUP follows:
|
||||
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2015 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
type
|
||||
csize = int
|
||||
|
||||
|
||||
HttpDataProc* = proc (a2: ptr HttpParser, at: cstring, length: csize): cint {.cdecl.}
|
||||
HttpProc* = proc (a2: ptr HttpParser): cint {.cdecl.}
|
||||
|
||||
|
||||
@@ -1,512 +0,0 @@
|
||||
#
|
||||
# $Id: header,v 1.1 2000/07/13 06:33:45 michael Exp $
|
||||
# This file is part of the Free Pascal packages
|
||||
# Copyright (c) 1999-2000 by the Free Pascal development team
|
||||
#
|
||||
# See the file COPYING.FPC, included in this distribution,
|
||||
# for details about the copyright.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# **********************************************************************
|
||||
#
|
||||
# the curl library is governed by its own copyright, see the curl
|
||||
# website for this.
|
||||
#
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
import
|
||||
times
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
libname = "libcurl.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
libname = "libcurl-7.19.3.dylib"
|
||||
elif defined(unix):
|
||||
const
|
||||
libname = "libcurl.so.4"
|
||||
type
|
||||
Pcalloc_callback* = ptr Calloc_callback
|
||||
Pclosepolicy* = ptr Closepolicy
|
||||
Pforms* = ptr Forms
|
||||
Pftpauth* = ptr Ftpauth
|
||||
Pftpmethod* = ptr Ftpmethod
|
||||
Pftpssl* = ptr Ftpssl
|
||||
PHTTP_VERSION* = ptr HTTP_VERSION
|
||||
Phttppost* = ptr Httppost
|
||||
PPcurl_httppost* = ptr Phttppost
|
||||
Pinfotype* = ptr Infotype
|
||||
Plock_access* = ptr Lock_access
|
||||
Plock_data* = ptr Lock_data
|
||||
Pmalloc_callback* = ptr Malloc_callback
|
||||
PNETRC_OPTION* = ptr NETRC_OPTION
|
||||
Pproxytype* = ptr Proxytype
|
||||
Prealloc_callback* = ptr Realloc_callback
|
||||
Pslist* = ptr Slist
|
||||
Psocket* = ptr Socket
|
||||
PSSL_VERSION* = ptr SSL_VERSION
|
||||
Pstrdup_callback* = ptr Strdup_callback
|
||||
PTIMECOND* = ptr TIMECOND
|
||||
Pversion_info_data* = ptr Version_info_data
|
||||
Pcode* = ptr Code
|
||||
PFORMcode* = ptr FORMcode
|
||||
Pformoption* = ptr Formoption
|
||||
PINFO* = ptr INFO
|
||||
Piocmd* = ptr Iocmd
|
||||
Pioerr* = ptr Ioerr
|
||||
PM* = ptr M
|
||||
PMcode* = ptr Mcode
|
||||
PMoption* = ptr Moption
|
||||
PMSG* = ptr MSG
|
||||
Poption* = ptr Option
|
||||
PSH* = ptr SH
|
||||
PSHcode* = ptr SHcode
|
||||
PSHoption* = ptr SHoption
|
||||
Pversion* = ptr Version
|
||||
Pfd_set* = pointer
|
||||
PCurl* = ptr Curl
|
||||
Curl* = pointer
|
||||
Httppost*{.final, pure.} = object
|
||||
next*: Phttppost
|
||||
name*: cstring
|
||||
namelength*: int32
|
||||
contents*: cstring
|
||||
contentslength*: int32
|
||||
buffer*: cstring
|
||||
bufferlength*: int32
|
||||
contenttype*: cstring
|
||||
contentheader*: Pslist
|
||||
more*: Phttppost
|
||||
flags*: int32
|
||||
showfilename*: cstring
|
||||
|
||||
Progress_callback* = proc (clientp: pointer, dltotal: float64,
|
||||
dlnow: float64, ultotal: float64,
|
||||
ulnow: float64): int32 {.cdecl.}
|
||||
Write_callback* = proc (buffer: cstring, size: int, nitems: int,
|
||||
outstream: pointer): int{.cdecl.}
|
||||
Read_callback* = proc (buffer: cstring, size: int, nitems: int,
|
||||
instream: pointer): int{.cdecl.}
|
||||
Passwd_callback* = proc (clientp: pointer, prompt: cstring, buffer: cstring,
|
||||
buflen: int32): int32{.cdecl.}
|
||||
Ioerr* = enum
|
||||
IOE_OK, IOE_UNKNOWNCMD, IOE_FAILRESTART, IOE_LAST
|
||||
Iocmd* = enum
|
||||
IOCMD_NOP, IOCMD_RESTARTREAD, IOCMD_LAST
|
||||
Ioctl_callback* = proc (handle: PCurl, cmd: int32, clientp: pointer): Ioerr{.
|
||||
cdecl.}
|
||||
Malloc_callback* = proc (size: int): pointer{.cdecl.}
|
||||
Free_callback* = proc (p: pointer){.cdecl.}
|
||||
Realloc_callback* = proc (p: pointer, size: int): pointer{.cdecl.}
|
||||
Strdup_callback* = proc (str: cstring): cstring{.cdecl.}
|
||||
Calloc_callback* = proc (nmemb: int, size: int): pointer{.noconv.}
|
||||
Infotype* = enum
|
||||
INFO_TEXT = 0, INFO_HEADER_IN, INFO_HEADER_OUT, INFO_DATA_IN, INFO_DATA_OUT,
|
||||
INFO_SSL_DATA_IN, INFO_SSL_DATA_OUT, INFO_END
|
||||
Debug_callback* = proc (handle: PCurl, theType: Infotype, data: cstring,
|
||||
size: int, userptr: pointer): int32{.cdecl.}
|
||||
Code* = enum
|
||||
E_OK = 0, E_UNSUPPORTED_PROTOCOL, E_FAILED_INIT, E_URL_MALFORMAT,
|
||||
E_URL_MALFORMAT_USER, E_COULDNT_RESOLVE_PROXY, E_COULDNT_RESOLVE_HOST,
|
||||
E_COULDNT_CONNECT, E_FTP_WEIRD_SERVER_REPLY, E_FTP_ACCESS_DENIED,
|
||||
E_FTP_USER_PASSWORD_INCORRECT, E_FTP_WEIRD_PASS_REPLY,
|
||||
E_FTP_WEIRD_USER_REPLY, E_FTP_WEIRD_PASV_REPLY, E_FTP_WEIRD_227_FORMAT,
|
||||
E_FTP_CANT_GET_HOST, E_FTP_CANT_RECONNECT, E_FTP_COULDNT_SET_BINARY,
|
||||
E_PARTIAL_FILE, E_FTP_COULDNT_RETR_FILE, E_FTP_WRITE_ERROR,
|
||||
E_FTP_QUOTE_ERROR, E_HTTP_RETURNED_ERROR, E_WRITE_ERROR, E_MALFORMAT_USER,
|
||||
E_FTP_COULDNT_STOR_FILE, E_READ_ERROR, E_OUT_OF_MEMORY,
|
||||
E_OPERATION_TIMEOUTED, E_FTP_COULDNT_SET_ASCII, E_FTP_PORT_FAILED,
|
||||
E_FTP_COULDNT_USE_REST, E_FTP_COULDNT_GET_SIZE, E_HTTP_RANGE_ERROR,
|
||||
E_HTTP_POST_ERROR, E_SSL_CONNECT_ERROR, E_BAD_DOWNLOAD_RESUME,
|
||||
E_FILE_COULDNT_READ_FILE, E_LDAP_CANNOT_BIND, E_LDAP_SEARCH_FAILED,
|
||||
E_LIBRARY_NOT_FOUND, E_FUNCTION_NOT_FOUND, E_ABORTED_BY_CALLBACK,
|
||||
E_BAD_FUNCTION_ARGUMENT, E_BAD_CALLING_ORDER, E_INTERFACE_FAILED,
|
||||
E_BAD_PASSWORD_ENTERED, E_TOO_MANY_REDIRECTS, E_UNKNOWN_TELNET_OPTION,
|
||||
E_TELNET_OPTION_SYNTAX, E_OBSOLETE, E_SSL_PEER_CERTIFICATE, E_GOT_NOTHING,
|
||||
E_SSL_ENGINE_NOTFOUND, E_SSL_ENGINE_SETFAILED, E_SEND_ERROR, E_RECV_ERROR,
|
||||
E_SHARE_IN_USE, E_SSL_CERTPROBLEM, E_SSL_CIPHER, E_SSL_CACERT,
|
||||
E_BAD_CONTENT_ENCODING, E_LDAP_INVALID_URL, E_FILESIZE_EXCEEDED,
|
||||
E_FTP_SSL_FAILED, E_SEND_FAIL_REWIND, E_SSL_ENGINE_INITFAILED,
|
||||
E_LOGIN_DENIED, E_TFTP_NOTFOUND, E_TFTP_PERM, E_TFTP_DISKFULL,
|
||||
E_TFTP_ILLEGAL, E_TFTP_UNKNOWNID, E_TFTP_EXISTS, E_TFTP_NOSUCHUSER,
|
||||
E_CONV_FAILED, E_CONV_REQD, LAST
|
||||
Conv_callback* = proc (buffer: cstring, len: int): Code{.cdecl.}
|
||||
Ssl_ctx_callback* = proc (curl: PCurl, ssl_ctx, userptr: pointer): Code{.cdecl.}
|
||||
Proxytype* = enum
|
||||
PROXY_HTTP = 0, PROXY_SOCKS4 = 4, PROXY_SOCKS5 = 5
|
||||
Ftpssl* = enum
|
||||
FTPSSL_NONE, FTPSSL_TRY, FTPSSL_CONTROL, FTPSSL_ALL, FTPSSL_LAST
|
||||
Ftpauth* = enum
|
||||
FTPAUTH_DEFAULT, FTPAUTH_SSL, FTPAUTH_TLS, FTPAUTH_LAST
|
||||
Ftpmethod* = enum
|
||||
FTPMETHOD_DEFAULT, FTPMETHOD_MULTICWD, FTPMETHOD_NOCWD, FTPMETHOD_SINGLECWD,
|
||||
FTPMETHOD_LAST
|
||||
Option* = enum
|
||||
OPT_PORT = 0 + 3, OPT_TIMEOUT = 0 + 13, OPT_INFILESIZE = 0 + 14,
|
||||
OPT_LOW_SPEED_LIMIT = 0 + 19, OPT_LOW_SPEED_TIME = 0 + 20,
|
||||
OPT_RESUME_FROM = 0 + 21, OPT_CRLF = 0 + 27, OPT_SSLVERSION = 0 + 32,
|
||||
OPT_TIMECONDITION = 0 + 33, OPT_TIMEVALUE = 0 + 34, OPT_VERBOSE = 0 + 41,
|
||||
OPT_HEADER = 0 + 42, OPT_NOPROGRESS = 0 + 43, OPT_NOBODY = 0 + 44,
|
||||
OPT_FAILONERROR = 0 + 45, OPT_UPLOAD = 0 + 46, OPT_POST = 0 + 47,
|
||||
OPT_FTPLISTONLY = 0 + 48, OPT_FTPAPPEND = 0 + 50, OPT_NETRC = 0 + 51,
|
||||
OPT_FOLLOWLOCATION = 0 + 52, OPT_TRANSFERTEXT = 0 + 53, OPT_PUT = 0 + 54,
|
||||
OPT_AUTOREFERER = 0 + 58, OPT_PROXYPORT = 0 + 59,
|
||||
OPT_POSTFIELDSIZE = 0 + 60, OPT_HTTPPROXYTUNNEL = 0 + 61,
|
||||
OPT_SSL_VERIFYPEER = 0 + 64, OPT_MAXREDIRS = 0 + 68, OPT_FILETIME = 0 + 69,
|
||||
OPT_MAXCONNECTS = 0 + 71, OPT_CLOSEPOLICY = 0 + 72,
|
||||
OPT_FRESH_CONNECT = 0 + 74, OPT_FORBID_REUSE = 0 + 75,
|
||||
OPT_CONNECTTIMEOUT = 0 + 78, OPT_HTTPGET = 0 + 80,
|
||||
OPT_SSL_VERIFYHOST = 0 + 81, OPT_HTTP_VERSION = 0 + 84,
|
||||
OPT_FTP_USE_EPSV = 0 + 85, OPT_SSLENGINE_DEFAULT = 0 + 90,
|
||||
OPT_DNS_USE_GLOBAL_CACHE = 0 + 91, OPT_DNS_CACHE_TIMEOUT = 0 + 92,
|
||||
OPT_COOKIESESSION = 0 + 96, OPT_BUFFERSIZE = 0 + 98, OPT_NOSIGNAL = 0 + 99,
|
||||
OPT_PROXYTYPE = 0 + 101, OPT_UNRESTRICTED_AUTH = 0 + 105,
|
||||
OPT_FTP_USE_EPRT = 0 + 106, OPT_HTTPAUTH = 0 + 107,
|
||||
OPT_FTP_CREATE_MISSING_DIRS = 0 + 110, OPT_PROXYAUTH = 0 + 111,
|
||||
OPT_FTP_RESPONSE_TIMEOUT = 0 + 112, OPT_IPRESOLVE = 0 + 113,
|
||||
OPT_MAXFILESIZE = 0 + 114, OPT_FTP_SSL = 0 + 119, OPT_TCP_NODELAY = 0 + 121,
|
||||
OPT_FTPSSLAUTH = 0 + 129, OPT_IGNORE_CONTENT_LENGTH = 0 + 136,
|
||||
OPT_FTP_SKIP_PASV_IP = 0 + 137, OPT_FTP_FILEMETHOD = 0 + 138,
|
||||
OPT_LOCALPORT = 0 + 139, OPT_LOCALPORTRANGE = 0 + 140,
|
||||
OPT_CONNECT_ONLY = 0 + 141, OPT_FILE = 10000 + 1, OPT_URL = 10000 + 2,
|
||||
OPT_PROXY = 10000 + 4, OPT_USERPWD = 10000 + 5,
|
||||
OPT_PROXYUSERPWD = 10000 + 6, OPT_RANGE = 10000 + 7, OPT_INFILE = 10000 + 9,
|
||||
OPT_ERRORBUFFER = 10000 + 10, OPT_POSTFIELDS = 10000 + 15,
|
||||
OPT_REFERER = 10000 + 16, OPT_FTPPORT = 10000 + 17,
|
||||
OPT_USERAGENT = 10000 + 18, OPT_COOKIE = 10000 + 22,
|
||||
OPT_HTTPHEADER = 10000 + 23, OPT_HTTPPOST = 10000 + 24,
|
||||
OPT_SSLCERT = 10000 + 25, OPT_SSLCERTPASSWD = 10000 + 26,
|
||||
OPT_QUOTE = 10000 + 28, OPT_WRITEHEADER = 10000 + 29,
|
||||
OPT_COOKIEFILE = 10000 + 31, OPT_CUSTOMREQUEST = 10000 + 36,
|
||||
OPT_STDERR = 10000 + 37, OPT_POSTQUOTE = 10000 + 39,
|
||||
OPT_WRITEINFO = 10000 + 40, OPT_PROGRESSDATA = 10000 + 57,
|
||||
OPT_INTERFACE = 10000 + 62, OPT_KRB4LEVEL = 10000 + 63,
|
||||
OPT_CAINFO = 10000 + 65, OPT_TELNETOPTIONS = 10000 + 70,
|
||||
OPT_RANDOM_FILE = 10000 + 76, OPT_EGDSOCKET = 10000 + 77,
|
||||
OPT_COOKIEJAR = 10000 + 82, OPT_SSL_CIPHER_LIST = 10000 + 83,
|
||||
OPT_SSLCERTTYPE = 10000 + 86, OPT_SSLKEY = 10000 + 87,
|
||||
OPT_SSLKEYTYPE = 10000 + 88, OPT_SSLENGINE = 10000 + 89,
|
||||
OPT_PREQUOTE = 10000 + 93, OPT_DEBUGDATA = 10000 + 95,
|
||||
OPT_CAPATH = 10000 + 97, OPT_SHARE = 10000 + 100,
|
||||
OPT_ENCODING = 10000 + 102, OPT_PRIVATE = 10000 + 103,
|
||||
OPT_HTTP200ALIASES = 10000 + 104, OPT_SSL_CTX_DATA = 10000 + 109,
|
||||
OPT_NETRC_FILE = 10000 + 118, OPT_SOURCE_USERPWD = 10000 + 123,
|
||||
OPT_SOURCE_PREQUOTE = 10000 + 127, OPT_SOURCE_POSTQUOTE = 10000 + 128,
|
||||
OPT_IOCTLDATA = 10000 + 131, OPT_SOURCE_URL = 10000 + 132,
|
||||
OPT_SOURCE_QUOTE = 10000 + 133, OPT_FTP_ACCOUNT = 10000 + 134,
|
||||
OPT_COOKIELIST = 10000 + 135, OPT_FTP_ALTERNATIVE_TO_USER = 10000 + 147,
|
||||
OPT_LASTENTRY = 10000 + 148, OPT_WRITEFUNCTION = 20000 + 11,
|
||||
OPT_READFUNCTION = 20000 + 12, OPT_PROGRESSFUNCTION = 20000 + 56,
|
||||
OPT_HEADERFUNCTION = 20000 + 79, OPT_DEBUGFUNCTION = 20000 + 94,
|
||||
OPT_SSL_CTX_FUNCTION = 20000 + 108, OPT_IOCTLFUNCTION = 20000 + 130,
|
||||
OPT_CONV_FROM_NETWORK_FUNCTION = 20000 + 142,
|
||||
OPT_CONV_TO_NETWORK_FUNCTION = 20000 + 143,
|
||||
OPT_CONV_FROM_UTF8_FUNCTION = 20000 + 144,
|
||||
OPT_INFILESIZE_LARGE = 30000 + 115, OPT_RESUME_FROM_LARGE = 30000 + 116,
|
||||
OPT_MAXFILESIZE_LARGE = 30000 + 117, OPT_POSTFIELDSIZE_LARGE = 30000 + 120,
|
||||
OPT_MAX_SEND_SPEED_LARGE = 30000 + 145,
|
||||
OPT_MAX_RECV_SPEED_LARGE = 30000 + 146
|
||||
HTTP_VERSION* = enum
|
||||
HTTP_VERSION_NONE, HTTP_VERSION_1_0, HTTP_VERSION_1_1, HTTP_VERSION_LAST
|
||||
NETRC_OPTION* = enum
|
||||
NETRC_IGNORED, NETRC_OPTIONAL, NETRC_REQUIRED, NETRC_LAST
|
||||
SSL_VERSION* = enum
|
||||
SSLVERSION_DEFAULT, SSLVERSION_TLSv1, SSLVERSION_SSLv2, SSLVERSION_SSLv3,
|
||||
SSLVERSION_LAST
|
||||
TIMECOND* = enum
|
||||
TIMECOND_NONE, TIMECOND_IFMODSINCE, TIMECOND_IFUNMODSINCE, TIMECOND_LASTMOD,
|
||||
TIMECOND_LAST
|
||||
Formoption* = enum
|
||||
FORM_NOTHING, FORM_COPYNAME, FORM_PTRNAME, FORM_NAMELENGTH,
|
||||
FORM_COPYCONTENTS, FORM_PTRCONTENTS, FORM_CONTENTSLENGTH, FORM_FILECONTENT,
|
||||
FORM_ARRAY, FORM_OBSOLETE, FORM_FILE, FORM_BUFFER, FORM_BUFFERPTR,
|
||||
FORM_BUFFERLENGTH, FORM_CONTENTTYPE, FORM_CONTENTHEADER, FORM_FILENAME,
|
||||
FORM_END, FORM_OBSOLETE2, FORM_LASTENTRY
|
||||
Forms*{.pure, final.} = object
|
||||
option*: Formoption
|
||||
value*: cstring
|
||||
|
||||
FORMcode* = enum
|
||||
FORMADD_OK, FORMADD_MEMORY, FORMADD_OPTION_TWICE, FORMADD_NULL,
|
||||
FORMADD_UNKNOWN_OPTION, FORMADD_INCOMPLETE, FORMADD_ILLEGAL_ARRAY,
|
||||
FORMADD_DISABLED, FORMADD_LAST
|
||||
Formget_callback* = proc (arg: pointer, buf: cstring, length: int): int{.
|
||||
cdecl.}
|
||||
Slist*{.pure, final.} = object
|
||||
data*: cstring
|
||||
next*: Pslist
|
||||
|
||||
INFO* = enum
|
||||
INFO_NONE = 0, INFO_LASTONE = 30, INFO_EFFECTIVE_URL = 0x00100000 + 1,
|
||||
INFO_CONTENT_TYPE = 0x00100000 + 18, INFO_PRIVATE = 0x00100000 + 21,
|
||||
INFO_FTP_ENTRY_PATH = 0x00100000 + 30, INFO_RESPONSE_CODE = 0x00200000 + 2,
|
||||
INFO_HEADER_SIZE = 0x00200000 + 11, INFO_REQUEST_SIZE = 0x00200000 + 12,
|
||||
INFO_SSL_VERIFYRESULT = 0x00200000 + 13, INFO_FILETIME = 0x00200000 + 14,
|
||||
INFO_REDIRECT_COUNT = 0x00200000 + 20,
|
||||
INFO_HTTP_CONNECTCODE = 0x00200000 + 22,
|
||||
INFO_HTTPAUTH_AVAIL = 0x00200000 + 23,
|
||||
INFO_PROXYAUTH_AVAIL = 0x00200000 + 24, INFO_OS_ERRNO = 0x00200000 + 25,
|
||||
INFO_NUM_CONNECTS = 0x00200000 + 26, INFO_LASTSOCKET = 0x00200000 + 29,
|
||||
INFO_TOTAL_TIME = 0x00300000 + 3, INFO_NAMELOOKUP_TIME = 0x00300000 + 4,
|
||||
INFO_CONNECT_TIME = 0x00300000 + 5, INFO_PRETRANSFER_TIME = 0x00300000 + 6,
|
||||
INFO_SIZE_UPLOAD = 0x00300000 + 7, INFO_SIZE_DOWNLOAD = 0x00300000 + 8,
|
||||
INFO_SPEED_DOWNLOAD = 0x00300000 + 9, INFO_SPEED_UPLOAD = 0x00300000 + 10,
|
||||
INFO_CONTENT_LENGTH_DOWNLOAD = 0x00300000 + 15,
|
||||
INFO_CONTENT_LENGTH_UPLOAD = 0x00300000 + 16,
|
||||
INFO_STARTTRANSFER_TIME = 0x00300000 + 17,
|
||||
INFO_REDIRECT_TIME = 0x00300000 + 19, INFO_SSL_ENGINES = 0x00400000 + 27,
|
||||
INFO_COOKIELIST = 0x00400000 + 28
|
||||
Closepolicy* = enum
|
||||
CLOSEPOLICY_NONE, CLOSEPOLICY_OLDEST, CLOSEPOLICY_LEAST_RECENTLY_USED,
|
||||
CLOSEPOLICY_LEAST_TRAFFIC, CLOSEPOLICY_SLOWEST, CLOSEPOLICY_CALLBACK,
|
||||
CLOSEPOLICY_LAST
|
||||
Lock_data* = enum
|
||||
LOCK_DATA_NONE = 0, LOCK_DATA_SHARE, LOCK_DATA_COOKIE, LOCK_DATA_DNS,
|
||||
LOCK_DATA_SSL_SESSION, LOCK_DATA_CONNECT, LOCK_DATA_LAST
|
||||
Lock_access* = enum
|
||||
LOCK_ACCESS_NONE = 0, LOCK_ACCESS_SHARED = 1, LOCK_ACCESS_SINGLE = 2,
|
||||
LOCK_ACCESS_LAST
|
||||
Lock_function* = proc (handle: PCurl, data: Lock_data,
|
||||
locktype: Lock_access,
|
||||
userptr: pointer){.cdecl.}
|
||||
Unlock_function* = proc (handle: PCurl, data: Lock_data, userptr: pointer){.
|
||||
cdecl.}
|
||||
SH* = pointer
|
||||
SHcode* = enum
|
||||
SHE_OK, SHE_BAD_OPTION, SHE_IN_USE, SHE_INVALID, SHE_NOMEM, SHE_LAST
|
||||
SHoption* = enum
|
||||
SHOPT_NONE, SHOPT_SHARE, SHOPT_UNSHARE, SHOPT_LOCKFUNC, SHOPT_UNLOCKFUNC,
|
||||
SHOPT_USERDATA, SHOPT_LAST
|
||||
Version* = enum
|
||||
VERSION_FIRST, VERSION_SECOND, VERSION_THIRD, VERSION_LAST
|
||||
Version_info_data*{.pure, final.} = object
|
||||
age*: Version
|
||||
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
|
||||
|
||||
M* = pointer
|
||||
Socket* = int32
|
||||
Mcode* = enum
|
||||
M_CALL_MULTI_PERFORM = - 1, M_OK = 0, M_BAD_HANDLE, M_BAD_EASY_HANDLE,
|
||||
M_OUT_OF_MEMORY, M_INTERNAL_ERROR, M_BAD_SOCKET, M_UNKNOWN_OPTION, M_LAST
|
||||
MSGEnum* = enum
|
||||
MSG_NONE, MSG_DONE, MSG_LAST
|
||||
Msg*{.pure, final.} = object
|
||||
msg*: MSGEnum
|
||||
easy_handle*: PCurl
|
||||
whatever*: pointer #data : record
|
||||
# case longint of
|
||||
# 0 : ( whatever : pointer );
|
||||
# 1 : ( result : CURLcode );
|
||||
# end;
|
||||
|
||||
Socket_callback* = proc (easy: PCurl, s: Socket, what: int32,
|
||||
userp, socketp: pointer): int32{.cdecl.}
|
||||
Moption* = enum
|
||||
MOPT_SOCKETDATA = 10000 + 2, MOPT_LASTENTRY = 10000 + 3,
|
||||
MOPT_SOCKETFUNCTION = 20000 + 1
|
||||
{.deprecated: [TMsg: Msg, TCurl: Curl, Thttppost: Httppost,
|
||||
Tprogress_callback: Progress_callback, Twrite_callback: Write_callback,
|
||||
Tread_callback: Read_callback, Tpasswd_callback: Passwd_callback, Tioerr: Ioerr,
|
||||
Tiocmd: Iocmd, Tioctl_callback: Ioctl_callback, Tmalloc_callback: Malloc_callback,
|
||||
Tfree_callback: Free_callback, Trealloc_callback: Realloc_callback,
|
||||
Tstrdup_callback: Strdup_callback, Tcalloc_callback: Calloc_callback,
|
||||
Tinfotype: Infotype, Tdebug_callback: Debug_callback, Tcode: Code,
|
||||
Tconv_callback: Conv_callback, Tssl_ctx_callback: Ssl_ctx_callback,
|
||||
Tproxytype: Proxytype, Tftpssl: Ftpssl, Tftpauth: Ftpauth, Tftpmethod: Ftpmethod,
|
||||
Toption: Option, THTTP_VERSION: HTTP_VERSION, TNETRC_OPTION: NETRC_OPTION,
|
||||
TSSL_VERSION: SSL_VERSION, TTIMECOND: TIMECOND, Tformoption: Formoption,
|
||||
Tforms: Forms, TFORMcode: FORMcode, Tformget_callback: Formget_callback,
|
||||
Tslist: Slist, TINFO: INFO, Tclosepolicy: Closepolicy, Tlock_data: Lock_data,
|
||||
Tlock_access: Lock_access, Tlock_function: Lock_function,
|
||||
Tunlock_function: Unlock_function, TSH: Sh, TSHcode: SHcode, TSHoption: SHoption,
|
||||
Tversion: Version, Tversion_info_data: Version_info_data, TM: M, Tsocket: Socket,
|
||||
TMcode: Mcode, TMSGEnum: MsGEnum, Tsocket_callback: Socket_callback,
|
||||
TMoption: Moption].}
|
||||
|
||||
const
|
||||
OPT_SSLKEYPASSWD* = OPT_SSLCERTPASSWD
|
||||
AUTH_ANY* = not (0)
|
||||
AUTH_BASIC* = 1 shl 0
|
||||
AUTH_ANYSAFE* = not (AUTH_BASIC)
|
||||
AUTH_DIGEST* = 1 shl 1
|
||||
AUTH_GSSNEGOTIATE* = 1 shl 2
|
||||
AUTH_NONE* = 0
|
||||
AUTH_NTLM* = 1 shl 3
|
||||
E_ALREADY_COMPLETE* = 99999
|
||||
E_FTP_BAD_DOWNLOAD_RESUME* = E_BAD_DOWNLOAD_RESUME
|
||||
E_FTP_PARTIAL_FILE* = E_PARTIAL_FILE
|
||||
E_HTTP_NOT_FOUND* = E_HTTP_RETURNED_ERROR
|
||||
E_HTTP_PORT_FAILED* = E_INTERFACE_FAILED
|
||||
E_OPERATION_TIMEDOUT* = E_OPERATION_TIMEOUTED
|
||||
ERROR_SIZE* = 256
|
||||
FORMAT_OFF_T* = "%ld"
|
||||
GLOBAL_NOTHING* = 0
|
||||
GLOBAL_SSL* = 1 shl 0
|
||||
GLOBAL_WIN32* = 1 shl 1
|
||||
GLOBAL_ALL* = GLOBAL_SSL or GLOBAL_WIN32
|
||||
GLOBAL_DEFAULT* = GLOBAL_ALL
|
||||
INFO_DOUBLE* = 0x00300000
|
||||
INFO_HTTP_CODE* = INFO_RESPONSE_CODE
|
||||
INFO_LONG* = 0x00200000
|
||||
INFO_MASK* = 0x000FFFFF
|
||||
INFO_SLIST* = 0x00400000
|
||||
INFO_STRING* = 0x00100000
|
||||
INFO_TYPEMASK* = 0x00F00000
|
||||
IPRESOLVE_V4* = 1
|
||||
IPRESOLVE_V6* = 2
|
||||
IPRESOLVE_WHATEVER* = 0
|
||||
MAX_WRITE_SIZE* = 16384
|
||||
M_CALL_MULTI_SOCKET* = M_CALL_MULTI_PERFORM
|
||||
OPT_CLOSEFUNCTION* = - (5)
|
||||
OPT_FTPASCII* = OPT_TRANSFERTEXT
|
||||
OPT_HEADERDATA* = OPT_WRITEHEADER
|
||||
OPT_HTTPREQUEST* = - (1)
|
||||
OPT_MUTE* = - (2)
|
||||
OPT_PASSWDDATA* = - (4)
|
||||
OPT_PASSWDFUNCTION* = - (3)
|
||||
OPT_PASV_HOST* = - (9)
|
||||
OPT_READDATA* = OPT_INFILE
|
||||
OPT_SOURCE_HOST* = - (6)
|
||||
OPT_SOURCE_PATH* = - (7)
|
||||
OPT_SOURCE_PORT* = - (8)
|
||||
OPTTYPE_FUNCTIONPOINT* = 20000
|
||||
OPTTYPE_LONG* = 0
|
||||
OPTTYPE_OBJECTPOINT* = 10000
|
||||
OPTTYPE_OFF_T* = 30000
|
||||
OPT_WRITEDATA* = OPT_FILE
|
||||
POLL_IN* = 1
|
||||
POLL_INOUT* = 3
|
||||
POLL_NONE* = 0
|
||||
POLL_OUT* = 2
|
||||
POLL_REMOVE* = 4
|
||||
READFUNC_ABORT* = 0x10000000
|
||||
SOCKET_BAD* = - (1)
|
||||
SOCKET_TIMEOUT* = SOCKET_BAD
|
||||
VERSION_ASYNCHDNS* = 1 shl 7
|
||||
VERSION_CONV* = 1 shl 12
|
||||
VERSION_DEBUG* = 1 shl 6
|
||||
VERSION_GSSNEGOTIATE* = 1 shl 5
|
||||
VERSION_IDN* = 1 shl 10
|
||||
VERSION_IPV6* = 1 shl 0
|
||||
VERSION_KERBEROS4* = 1 shl 1
|
||||
VERSION_LARGEFILE* = 1 shl 9
|
||||
VERSION_LIBZ* = 1 shl 3
|
||||
VERSION_NOW* = VERSION_THIRD
|
||||
VERSION_NTLM* = 1 shl 4
|
||||
VERSION_SPNEGO* = 1 shl 8
|
||||
VERSION_SSL* = 1 shl 2
|
||||
VERSION_SSPI* = 1 shl 11
|
||||
FILE_OFFSET_BITS* = 0
|
||||
FILESIZEBITS* = 0
|
||||
FUNCTIONPOINT* = OPTTYPE_FUNCTIONPOINT
|
||||
HTTPPOST_BUFFER* = 1 shl 4
|
||||
HTTPPOST_FILENAME* = 1 shl 0
|
||||
HTTPPOST_PTRBUFFER* = 1 shl 5
|
||||
HTTPPOST_PTRCONTENTS* = 1 shl 3
|
||||
HTTPPOST_PTRNAME* = 1 shl 2
|
||||
HTTPPOST_READFILE* = 1 shl 1
|
||||
LIBCURL_VERSION* = "7.15.5"
|
||||
LIBCURL_VERSION_MAJOR* = 7
|
||||
LIBCURL_VERSION_MINOR* = 15
|
||||
LIBCURL_VERSION_NUM* = 0x00070F05
|
||||
LIBCURL_VERSION_PATCH* = 5
|
||||
|
||||
proc strequal*(s1, s2: cstring): int32{.cdecl, dynlib: libname,
|
||||
importc: "curl_strequal".}
|
||||
proc strnequal*(s1, s2: cstring, n: int): int32{.cdecl, dynlib: libname,
|
||||
importc: "curl_strnequal".}
|
||||
proc formadd*(httppost, last_post: PPcurl_httppost): FORMcode{.cdecl, varargs,
|
||||
dynlib: libname, importc: "curl_formadd".}
|
||||
proc formget*(form: Phttppost, arg: pointer, append: Formget_callback): int32{.
|
||||
cdecl, dynlib: libname, importc: "curl_formget".}
|
||||
proc formfree*(form: Phttppost){.cdecl, dynlib: libname,
|
||||
importc: "curl_formfree".}
|
||||
proc getenv*(variable: cstring): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_getenv".}
|
||||
proc version*(): cstring{.cdecl, dynlib: libname, importc: "curl_version".}
|
||||
proc easy_escape*(handle: PCurl, str: cstring, len: int32): cstring{.cdecl,
|
||||
dynlib: libname, importc: "curl_easy_escape".}
|
||||
proc escape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_escape".}
|
||||
proc easy_unescape*(handle: PCurl, str: cstring, len: int32, outlength: var int32): cstring{.
|
||||
cdecl, dynlib: libname, importc: "curl_easy_unescape".}
|
||||
proc unescape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_unescape".}
|
||||
proc free*(p: pointer){.cdecl, dynlib: libname, importc: "curl_free".}
|
||||
proc global_init*(flags: int32): Code{.cdecl, dynlib: libname,
|
||||
importc: "curl_global_init".}
|
||||
proc global_init_mem*(flags: int32, m: Malloc_callback, f: Free_callback,
|
||||
r: Realloc_callback, s: Strdup_callback,
|
||||
c: Calloc_callback): Code{.cdecl, dynlib: libname,
|
||||
importc: "curl_global_init_mem".}
|
||||
proc global_cleanup*(){.cdecl, dynlib: libname, importc: "curl_global_cleanup".}
|
||||
proc slist_append*(slist: Pslist, p: cstring): Pslist{.cdecl, dynlib: libname,
|
||||
importc: "curl_slist_append".}
|
||||
proc slist_free_all*(para1: Pslist){.cdecl, dynlib: libname,
|
||||
importc: "curl_slist_free_all".}
|
||||
proc getdate*(p: cstring, unused: ptr Time): Time{.cdecl, dynlib: libname,
|
||||
importc: "curl_getdate".}
|
||||
proc share_init*(): PSH{.cdecl, dynlib: libname, importc: "curl_share_init".}
|
||||
proc share_setopt*(para1: PSH, option: SHoption): SHcode{.cdecl, varargs,
|
||||
dynlib: libname, importc: "curl_share_setopt".}
|
||||
proc share_cleanup*(para1: PSH): SHcode{.cdecl, dynlib: libname,
|
||||
importc: "curl_share_cleanup".}
|
||||
proc version_info*(para1: Version): Pversion_info_data{.cdecl, dynlib: libname,
|
||||
importc: "curl_version_info".}
|
||||
proc easy_strerror*(para1: Code): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_easy_strerror".}
|
||||
proc share_strerror*(para1: SHcode): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_share_strerror".}
|
||||
proc easy_init*(): PCurl{.cdecl, dynlib: libname, importc: "curl_easy_init".}
|
||||
proc easy_setopt*(curl: PCurl, option: Option): Code{.cdecl, varargs, dynlib: libname,
|
||||
importc: "curl_easy_setopt".}
|
||||
proc easy_perform*(curl: PCurl): Code{.cdecl, dynlib: libname,
|
||||
importc: "curl_easy_perform".}
|
||||
proc easy_cleanup*(curl: PCurl){.cdecl, dynlib: libname, importc: "curl_easy_cleanup".}
|
||||
proc easy_getinfo*(curl: PCurl, info: INFO): Code{.cdecl, varargs, dynlib: libname,
|
||||
importc: "curl_easy_getinfo".}
|
||||
proc easy_duphandle*(curl: PCurl): PCurl{.cdecl, dynlib: libname,
|
||||
importc: "curl_easy_duphandle".}
|
||||
proc easy_reset*(curl: PCurl){.cdecl, dynlib: libname, importc: "curl_easy_reset".}
|
||||
proc multi_init*(): PM{.cdecl, dynlib: libname, importc: "curl_multi_init".}
|
||||
proc multi_add_handle*(multi_handle: PM, handle: PCurl): Mcode{.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_add_handle".}
|
||||
proc multi_remove_handle*(multi_handle: PM, handle: PCurl): Mcode{.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_remove_handle".}
|
||||
proc multi_fdset*(multi_handle: PM, read_fd_set: Pfd_set, write_fd_set: Pfd_set,
|
||||
exc_fd_set: Pfd_set, max_fd: var int32): Mcode{.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_fdset".}
|
||||
proc multi_perform*(multi_handle: PM, running_handles: var int32): Mcode{.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_perform".}
|
||||
proc multi_cleanup*(multi_handle: PM): Mcode{.cdecl, dynlib: libname,
|
||||
importc: "curl_multi_cleanup".}
|
||||
proc multi_info_read*(multi_handle: PM, msgs_in_queue: var int32): PMsg{.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_info_read".}
|
||||
proc multi_strerror*(para1: Mcode): cstring{.cdecl, dynlib: libname,
|
||||
importc: "curl_multi_strerror".}
|
||||
proc multi_socket*(multi_handle: PM, s: Socket, running_handles: var int32): Mcode{.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_socket".}
|
||||
proc multi_socket_all*(multi_handle: PM, running_handles: var int32): Mcode{.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_socket_all".}
|
||||
proc multi_timeout*(multi_handle: PM, milliseconds: var int32): Mcode{.cdecl,
|
||||
dynlib: libname, importc: "curl_multi_timeout".}
|
||||
proc multi_setopt*(multi_handle: PM, option: Moption): Mcode{.cdecl, varargs,
|
||||
dynlib: libname, importc: "curl_multi_setopt".}
|
||||
proc multi_assign*(multi_handle: PM, sockfd: Socket, sockp: pointer): Mcode{.
|
||||
cdecl, dynlib: libname, importc: "curl_multi_assign".}
|
||||
@@ -1,331 +0,0 @@
|
||||
/* -----------------------------------------------------------------*-C-*-
|
||||
libffi 2.00-beta - Copyright (c) 1996-2003 Red Hat, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
The basic API is described in the README file.
|
||||
|
||||
The raw API is designed to bypass some of the argument packing
|
||||
and unpacking on architectures for which it can be avoided.
|
||||
|
||||
The closure API allows interpreted functions to be packaged up
|
||||
inside a C function pointer, so that they can be called as C functions,
|
||||
with no understanding on the client side that they are interpreted.
|
||||
It can also be used in other cases in which it is necessary to package
|
||||
up a user specified parameter and a function pointer as a single
|
||||
function pointer.
|
||||
|
||||
The closure API must be implemented in order to get its functionality,
|
||||
e.g. for use by gij. Routines are provided to emulate the raw API
|
||||
if the underlying platform doesn't allow faster implementation.
|
||||
|
||||
More details on the raw and cloure API can be found in:
|
||||
|
||||
http://gcc.gnu.org/ml/java/1999-q3/msg00138.html
|
||||
|
||||
and
|
||||
|
||||
http://gcc.gnu.org/ml/java/1999-q3/msg00174.html
|
||||
-------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LIBFFI_H
|
||||
#define LIBFFI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Specify which architecture libffi is configured for. */
|
||||
//XXX #define X86
|
||||
|
||||
/* ---- System configuration information --------------------------------- */
|
||||
|
||||
#include <ffitarget.h>
|
||||
|
||||
#ifndef LIBFFI_ASM
|
||||
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).
|
||||
But we can find it either under the correct ANSI name, or under GNU
|
||||
C's internal name. */
|
||||
#ifdef LONG_LONG_MAX
|
||||
# define FFI_LONG_LONG_MAX LONG_LONG_MAX
|
||||
#else
|
||||
# ifdef LLONG_MAX
|
||||
# define FFI_LONG_LONG_MAX LLONG_MAX
|
||||
# else
|
||||
# ifdef __GNUC__
|
||||
# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
|
||||
# endif
|
||||
# ifdef _MSC_VER
|
||||
# define FFI_LONG_LONG_MAX _I64_MAX
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if SCHAR_MAX == 127
|
||||
# define ffi_type_uchar ffi_type_uint8
|
||||
# define ffi_type_schar ffi_type_sint8
|
||||
#else
|
||||
#error "char size not supported"
|
||||
#endif
|
||||
|
||||
#if SHRT_MAX == 32767
|
||||
# define ffi_type_ushort ffi_type_uint16
|
||||
# define ffi_type_sshort ffi_type_sint16
|
||||
#elif SHRT_MAX == 2147483647
|
||||
# define ffi_type_ushort ffi_type_uint32
|
||||
# define ffi_type_sshort ffi_type_sint32
|
||||
#else
|
||||
#error "short size not supported"
|
||||
#endif
|
||||
|
||||
#if INT_MAX == 32767
|
||||
# define ffi_type_uint ffi_type_uint16
|
||||
# define ffi_type_sint ffi_type_sint16
|
||||
#elif INT_MAX == 2147483647
|
||||
# define ffi_type_uint ffi_type_uint32
|
||||
# define ffi_type_sint ffi_type_sint32
|
||||
#elif INT_MAX == 9223372036854775807
|
||||
# define ffi_type_uint ffi_type_uint64
|
||||
# define ffi_type_sint ffi_type_sint64
|
||||
#else
|
||||
#error "int size not supported"
|
||||
#endif
|
||||
|
||||
#define ffi_type_ulong ffi_type_uint64
|
||||
#define ffi_type_slong ffi_type_sint64
|
||||
#if LONG_MAX == 2147483647
|
||||
# if FFI_LONG_LONG_MAX != 9223372036854775807
|
||||
#error "no 64-bit data type supported"
|
||||
# endif
|
||||
#elif LONG_MAX != 9223372036854775807
|
||||
#error "long size not supported"
|
||||
#endif
|
||||
|
||||
/* The closure code assumes that this works on pointers, i.e. a size_t */
|
||||
/* can hold a pointer. */
|
||||
|
||||
typedef struct _ffi_type
|
||||
{
|
||||
size_t size;
|
||||
unsigned short alignment;
|
||||
unsigned short type;
|
||||
/*@null@*/ struct _ffi_type **elements;
|
||||
} ffi_type;
|
||||
|
||||
/* These are defined in types.c */
|
||||
extern const ffi_type ffi_type_void;
|
||||
extern const ffi_type ffi_type_uint8;
|
||||
extern const ffi_type ffi_type_sint8;
|
||||
extern const ffi_type ffi_type_uint16;
|
||||
extern const ffi_type ffi_type_sint16;
|
||||
extern const ffi_type ffi_type_uint32;
|
||||
extern const ffi_type ffi_type_sint32;
|
||||
extern const ffi_type ffi_type_uint64;
|
||||
extern const ffi_type ffi_type_sint64;
|
||||
extern const ffi_type ffi_type_float;
|
||||
extern const ffi_type ffi_type_double;
|
||||
extern const ffi_type ffi_type_longdouble;
|
||||
extern const ffi_type ffi_type_pointer;
|
||||
|
||||
|
||||
typedef enum {
|
||||
FFI_OK = 0,
|
||||
FFI_BAD_TYPEDEF,
|
||||
FFI_BAD_ABI
|
||||
} ffi_status;
|
||||
|
||||
typedef unsigned FFI_TYPE;
|
||||
|
||||
typedef struct {
|
||||
ffi_abi abi;
|
||||
unsigned nargs;
|
||||
/*@dependent@*/ ffi_type **arg_types;
|
||||
/*@dependent@*/ ffi_type *rtype;
|
||||
unsigned bytes;
|
||||
unsigned flags;
|
||||
#ifdef FFI_EXTRA_CIF_FIELDS
|
||||
FFI_EXTRA_CIF_FIELDS;
|
||||
#endif
|
||||
} ffi_cif;
|
||||
|
||||
/* ---- Definitions for the raw API -------------------------------------- */
|
||||
|
||||
#ifdef _WIN64
|
||||
#define FFI_SIZEOF_ARG 8
|
||||
#else
|
||||
#define FFI_SIZEOF_ARG 4
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
ffi_sarg sint;
|
||||
ffi_arg uint;
|
||||
float flt;
|
||||
char data[FFI_SIZEOF_ARG];
|
||||
void* ptr;
|
||||
} ffi_raw;
|
||||
|
||||
void ffi_raw_call (/*@dependent@*/ ffi_cif *cif,
|
||||
void (*fn)(),
|
||||
/*@out@*/ void *rvalue,
|
||||
/*@dependent@*/ ffi_raw *avalue);
|
||||
|
||||
void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
|
||||
void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
|
||||
size_t ffi_raw_size (ffi_cif *cif);
|
||||
|
||||
/* This is analogous to the raw API, except it uses Java parameter */
|
||||
/* packing, even on 64-bit machines. I.e. on 64-bit machines */
|
||||
/* longs and doubles are followed by an empty 64-bit word. */
|
||||
|
||||
void ffi_java_raw_call (/*@dependent@*/ ffi_cif *cif,
|
||||
void (*fn)(),
|
||||
/*@out@*/ void *rvalue,
|
||||
/*@dependent@*/ ffi_raw *avalue);
|
||||
|
||||
void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
|
||||
void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
|
||||
size_t ffi_java_raw_size (ffi_cif *cif);
|
||||
|
||||
/* ---- Definitions for closures ----------------------------------------- */
|
||||
|
||||
#if FFI_CLOSURES
|
||||
|
||||
typedef struct {
|
||||
char tramp[FFI_TRAMPOLINE_SIZE];
|
||||
ffi_cif *cif;
|
||||
void (*fun)(ffi_cif*,void*,void**,void*);
|
||||
void *user_data;
|
||||
} ffi_closure;
|
||||
|
||||
void ffi_closure_free(void *);
|
||||
void *ffi_closure_alloc (size_t size, void **code);
|
||||
|
||||
ffi_status
|
||||
ffi_prep_closure_loc (ffi_closure*,
|
||||
ffi_cif *,
|
||||
void (*fun)(ffi_cif*,void*,void**,void*),
|
||||
void *user_data,
|
||||
void *codeloc);
|
||||
|
||||
typedef struct {
|
||||
char tramp[FFI_TRAMPOLINE_SIZE];
|
||||
|
||||
ffi_cif *cif;
|
||||
|
||||
#if !FFI_NATIVE_RAW_API
|
||||
|
||||
/* if this is enabled, then a raw closure has the same layout
|
||||
as a regular closure. We use this to install an intermediate
|
||||
handler to do the transaltion, void** -> ffi_raw*. */
|
||||
|
||||
void (*translate_args)(ffi_cif*,void*,void**,void*);
|
||||
void *this_closure;
|
||||
|
||||
#endif
|
||||
|
||||
void (*fun)(ffi_cif*,void*,ffi_raw*,void*);
|
||||
void *user_data;
|
||||
|
||||
} ffi_raw_closure;
|
||||
|
||||
ffi_status
|
||||
ffi_prep_raw_closure (ffi_raw_closure*,
|
||||
ffi_cif *cif,
|
||||
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
|
||||
void *user_data);
|
||||
|
||||
ffi_status
|
||||
ffi_prep_java_raw_closure (ffi_raw_closure*,
|
||||
ffi_cif *cif,
|
||||
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
|
||||
void *user_data);
|
||||
|
||||
#endif /* FFI_CLOSURES */
|
||||
|
||||
/* ---- Public interface definition -------------------------------------- */
|
||||
|
||||
ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif,
|
||||
ffi_abi abi,
|
||||
unsigned int nargs,
|
||||
/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype,
|
||||
/*@dependent@*/ ffi_type **atypes);
|
||||
|
||||
void
|
||||
ffi_call(/*@dependent@*/ ffi_cif *cif,
|
||||
void (*fn)(),
|
||||
/*@out@*/ void *rvalue,
|
||||
/*@dependent@*/ void **avalue);
|
||||
|
||||
/* Useful for eliminating compiler warnings */
|
||||
#define FFI_FN(f) ((void (*)())f)
|
||||
|
||||
/* ---- Definitions shared with assembly code ---------------------------- */
|
||||
|
||||
#endif
|
||||
|
||||
/* If these change, update src/mips/ffitarget.h. */
|
||||
#define FFI_TYPE_VOID 0
|
||||
#define FFI_TYPE_INT 1
|
||||
#define FFI_TYPE_FLOAT 2
|
||||
#define FFI_TYPE_DOUBLE 3
|
||||
#if 1
|
||||
#define FFI_TYPE_LONGDOUBLE 4
|
||||
#else
|
||||
#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
|
||||
#endif
|
||||
#define FFI_TYPE_UINT8 5
|
||||
#define FFI_TYPE_SINT8 6
|
||||
#define FFI_TYPE_UINT16 7
|
||||
#define FFI_TYPE_SINT16 8
|
||||
#define FFI_TYPE_UINT32 9
|
||||
#define FFI_TYPE_SINT32 10
|
||||
#define FFI_TYPE_UINT64 11
|
||||
#define FFI_TYPE_SINT64 12
|
||||
#define FFI_TYPE_STRUCT 13
|
||||
#define FFI_TYPE_POINTER 14
|
||||
|
||||
/* This should always refer to the last type code (for sanity checks) */
|
||||
#define FFI_TYPE_LAST FFI_TYPE_POINTER
|
||||
|
||||
#define FFI_HIDDEN /* no idea what the origial definition looks like ... */
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define LIKELY(x) __builtin_expect(x, 1)
|
||||
# define UNLIKELY(x) __builtin_expect(x, 0)
|
||||
#else
|
||||
# define LIKELY(x) (x)
|
||||
# define UNLIKELY(x) (x)
|
||||
#endif
|
||||
|
||||
#define MAYBE_UNUSED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
ffi_common.h - Copyright (c) 1996 Red Hat, Inc.
|
||||
|
||||
Common internal definitions and macros. Only necessary for building
|
||||
libffi.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef FFI_COMMON_H
|
||||
#define FFI_COMMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <fficonfig.h>
|
||||
#include <malloc.h>
|
||||
|
||||
/* Check for the existence of memcpy. */
|
||||
#if STDC_HEADERS
|
||||
# include <string.h>
|
||||
#else
|
||||
# ifndef HAVE_MEMCPY
|
||||
# define memcpy(d, s, n) bcopy ((s), (d), (n))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(FFI_DEBUG)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef FFI_DEBUG
|
||||
/*@exits@*/ void ffi_assert(/*@temp@*/ char *expr, /*@temp@*/ char *file, int line);
|
||||
void ffi_stop_here(void);
|
||||
void ffi_type_test(/*@temp@*/ /*@out@*/ ffi_type *a, /*@temp@*/ char *file, int line);
|
||||
|
||||
#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
|
||||
#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
|
||||
#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
|
||||
#else
|
||||
#define FFI_ASSERT(x)
|
||||
#define FFI_ASSERT_AT(x, f, l)
|
||||
#define FFI_ASSERT_VALID_TYPE(x)
|
||||
#endif
|
||||
|
||||
#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
|
||||
|
||||
/* Perform machine dependent cif processing */
|
||||
ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
|
||||
|
||||
/* Extended cif, used in callback from assembly routine */
|
||||
typedef struct
|
||||
{
|
||||
/*@dependent@*/ ffi_cif *cif;
|
||||
/*@dependent@*/ void *rvalue;
|
||||
/*@dependent@*/ void **avalue;
|
||||
} extended_cif;
|
||||
|
||||
/* Terse sized type definitions. */
|
||||
typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
|
||||
typedef signed int SINT8 __attribute__((__mode__(__QI__)));
|
||||
typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
|
||||
typedef signed int SINT16 __attribute__((__mode__(__HI__)));
|
||||
typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
|
||||
typedef signed int SINT32 __attribute__((__mode__(__SI__)));
|
||||
typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
|
||||
typedef signed int SINT64 __attribute__((__mode__(__DI__)));
|
||||
|
||||
typedef float FLOAT32;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
/* fficonfig.h. Originally created by configure, now hand_maintained for MSVC. */
|
||||
|
||||
/* fficonfig.h. Generated automatically by configure. */
|
||||
/* fficonfig.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define this for MSVC, but not for mingw32! */
|
||||
#ifdef _MSC_VER
|
||||
#define __attribute__(x) /* */
|
||||
#endif
|
||||
#define alloca _alloca
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
|
||||
/* Define if using alloca.c. */
|
||||
/* #undef C_ALLOCA */
|
||||
|
||||
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
|
||||
This function is required for alloca.c support on those systems. */
|
||||
/* #undef CRAY_STACKSEG_END */
|
||||
|
||||
/* Define if you have alloca, as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
/* #define HAVE_ALLOCA_H 1 */
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown
|
||||
*/
|
||||
/* #undef STACK_DIRECTION */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if you have the memcpy function. */
|
||||
#define HAVE_MEMCPY 1
|
||||
|
||||
/* Define if read-only mmap of a plain file works. */
|
||||
//#define HAVE_MMAP_FILE 1
|
||||
|
||||
/* Define if mmap of /dev/zero works. */
|
||||
//#define HAVE_MMAP_DEV_ZERO 1
|
||||
|
||||
/* Define if mmap with MAP_ANON(YMOUS) works. */
|
||||
//#define HAVE_MMAP_ANON 1
|
||||
|
||||
/* The number of bytes in type double */
|
||||
#define SIZEOF_DOUBLE 8
|
||||
|
||||
/* The number of bytes in type long double */
|
||||
#define SIZEOF_LONG_DOUBLE 12
|
||||
|
||||
/* Define if you have the long double type and it is bigger than a double */
|
||||
#define HAVE_LONG_DOUBLE 1
|
||||
|
||||
/* whether byteorder is bigendian */
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
/* Define if the host machine stores words of multi-word integers in
|
||||
big-endian order. */
|
||||
/* #undef HOST_WORDS_BIG_ENDIAN */
|
||||
|
||||
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
|
||||
#define BYTEORDER 1234
|
||||
|
||||
/* Define if your assembler and linker support unaligned PC relative relocs. */
|
||||
/* #undef HAVE_AS_SPARC_UA_PCREL */
|
||||
|
||||
/* Define if your assembler supports .register. */
|
||||
/* #undef HAVE_AS_REGISTER_PSEUDO_OP */
|
||||
|
||||
/* Define if .eh_frame sections should be read-only. */
|
||||
/* #undef HAVE_RO_EH_FRAME */
|
||||
|
||||
/* Define to the flags needed for the .section .eh_frame directive. */
|
||||
/* #define EH_FRAME_FLAGS "aw" */
|
||||
|
||||
/* Define to the flags needed for the .section .eh_frame directive. */
|
||||
/* #define EH_FRAME_FLAGS "aw" */
|
||||
|
||||
/* Define this if you want extra debugging. */
|
||||
/* #undef FFI_DEBUG */
|
||||
|
||||
/* Define this is you do not want support for aggregate types. */
|
||||
/* #undef FFI_NO_STRUCTS */
|
||||
|
||||
/* Define this is you do not want support for the raw API. */
|
||||
/* #undef FFI_NO_RAW_API */
|
||||
|
||||
/* Define this if you are using Purify and want to suppress spurious messages. */
|
||||
/* #undef USING_PURIFY */
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
/* -----------------------------------------------------------------*-C-*-
|
||||
ffitarget.h - Copyright (c) 2012 Anthony Green
|
||||
Copyright (c) 1996-2003, 2010 Red Hat, Inc.
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
|
||||
Target configuration macros for x86 and x86-64.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LIBFFI_TARGET_H
|
||||
#define LIBFFI_TARGET_H
|
||||
|
||||
#ifndef LIBFFI_H
|
||||
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
|
||||
#endif
|
||||
|
||||
/* ---- System specific configurations ----------------------------------- */
|
||||
|
||||
/* For code common to all platforms on x86 and x86_64. */
|
||||
#define X86_ANY
|
||||
|
||||
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
|
||||
# if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64)
|
||||
# define X86_64
|
||||
# define X86_WIN64
|
||||
# else
|
||||
# define X86_32
|
||||
# define X86_WIN32
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (X86_64) && defined (__i386__)
|
||||
#undef X86_64
|
||||
#define X86
|
||||
#endif
|
||||
|
||||
#ifdef X86_WIN64
|
||||
#define FFI_SIZEOF_ARG 8
|
||||
#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
|
||||
#endif
|
||||
|
||||
/* ---- Generic type definitions ----------------------------------------- */
|
||||
|
||||
#ifndef LIBFFI_ASM
|
||||
#ifdef X86_WIN64
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned __int64 ffi_arg;
|
||||
typedef __int64 ffi_sarg;
|
||||
#else
|
||||
typedef unsigned long long ffi_arg;
|
||||
typedef long long ffi_sarg;
|
||||
#endif
|
||||
#else
|
||||
#if defined __x86_64__ && defined __ILP32__
|
||||
#define FFI_SIZEOF_ARG 8
|
||||
#define FFI_SIZEOF_JAVA_RAW 4
|
||||
typedef unsigned long long ffi_arg;
|
||||
typedef long long ffi_sarg;
|
||||
#else
|
||||
typedef unsigned long ffi_arg;
|
||||
typedef signed long ffi_sarg;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef enum ffi_abi {
|
||||
FFI_FIRST_ABI = 0,
|
||||
|
||||
/* ---- Intel x86 Win32 ---------- */
|
||||
#ifdef X86_WIN32
|
||||
FFI_SYSV,
|
||||
FFI_STDCALL,
|
||||
FFI_THISCALL,
|
||||
FFI_FASTCALL,
|
||||
FFI_MS_CDECL,
|
||||
FFI_LAST_ABI,
|
||||
#ifdef _MSC_VER
|
||||
FFI_DEFAULT_ABI = FFI_MS_CDECL
|
||||
#else
|
||||
FFI_DEFAULT_ABI = FFI_SYSV
|
||||
#endif
|
||||
|
||||
#elif defined(X86_WIN64)
|
||||
FFI_WIN64,
|
||||
FFI_LAST_ABI,
|
||||
FFI_DEFAULT_ABI = FFI_WIN64
|
||||
|
||||
#else
|
||||
/* ---- Intel x86 and AMD x86-64 - */
|
||||
FFI_SYSV,
|
||||
FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */
|
||||
FFI_LAST_ABI,
|
||||
#if defined(__i386__) || defined(__i386)
|
||||
FFI_DEFAULT_ABI = FFI_SYSV
|
||||
#else
|
||||
FFI_DEFAULT_ABI = FFI_UNIX64
|
||||
#endif
|
||||
#endif
|
||||
} ffi_abi;
|
||||
#endif
|
||||
|
||||
/* ---- Definitions for closures ----------------------------------------- */
|
||||
|
||||
#define FFI_CLOSURES 1
|
||||
#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
|
||||
#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
|
||||
#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
|
||||
#define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4)
|
||||
|
||||
#if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
|
||||
#define FFI_TRAMPOLINE_SIZE 24
|
||||
#define FFI_NATIVE_RAW_API 0
|
||||
#else
|
||||
#ifdef X86_WIN32
|
||||
#define FFI_TRAMPOLINE_SIZE 52
|
||||
#else
|
||||
#ifdef X86_WIN64
|
||||
#define FFI_TRAMPOLINE_SIZE 29
|
||||
#define FFI_NATIVE_RAW_API 0
|
||||
#define FFI_NO_RAW_API 1
|
||||
#else
|
||||
#define FFI_TRAMPOLINE_SIZE 10
|
||||
#endif
|
||||
#endif
|
||||
#ifndef X86_WIN64
|
||||
#define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
#include <ffi.h>
|
||||
#ifdef MS_WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
|
||||
# define MAP_ANONYMOUS MAP_ANON
|
||||
# endif
|
||||
#endif
|
||||
#include "ctypes.h"
|
||||
|
||||
/* BLOCKSIZE can be adjusted. Larger blocksize will take a larger memory
|
||||
overhead, but allocate less blocks from the system. It may be that some
|
||||
systems have a limit of how many mmap'd blocks can be open.
|
||||
*/
|
||||
|
||||
#define BLOCKSIZE _pagesize
|
||||
|
||||
/* #define MALLOC_CLOSURE_DEBUG */ /* enable for some debugging output */
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
typedef union _tagITEM {
|
||||
ffi_closure closure;
|
||||
union _tagITEM *next;
|
||||
} ITEM;
|
||||
|
||||
static ITEM *free_list;
|
||||
static int _pagesize;
|
||||
|
||||
static void more_core(void)
|
||||
{
|
||||
ITEM *item;
|
||||
int count, i;
|
||||
|
||||
/* determine the pagesize */
|
||||
#ifdef MS_WIN32
|
||||
if (!_pagesize) {
|
||||
SYSTEM_INFO systeminfo;
|
||||
GetSystemInfo(&systeminfo);
|
||||
_pagesize = systeminfo.dwPageSize;
|
||||
}
|
||||
#else
|
||||
if (!_pagesize) {
|
||||
#ifdef _SC_PAGESIZE
|
||||
_pagesize = sysconf(_SC_PAGESIZE);
|
||||
#else
|
||||
_pagesize = getpagesize();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* calculate the number of nodes to allocate */
|
||||
count = BLOCKSIZE / sizeof(ITEM);
|
||||
|
||||
/* allocate a memory block */
|
||||
#ifdef MS_WIN32
|
||||
item = (ITEM *)VirtualAlloc(NULL,
|
||||
count * sizeof(ITEM),
|
||||
MEM_COMMIT,
|
||||
PAGE_EXECUTE_READWRITE);
|
||||
if (item == NULL)
|
||||
return;
|
||||
#else
|
||||
item = (ITEM *)mmap(NULL,
|
||||
count * sizeof(ITEM),
|
||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS,
|
||||
-1,
|
||||
0);
|
||||
if (item == (void *)MAP_FAILED)
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef MALLOC_CLOSURE_DEBUG
|
||||
printf("block at %p allocated (%d bytes), %d ITEMs\n",
|
||||
item, count * sizeof(ITEM), count);
|
||||
#endif
|
||||
/* put them into the free list */
|
||||
for (i = 0; i < count; ++i) {
|
||||
item->next = free_list;
|
||||
free_list = item;
|
||||
++item;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
/* put the item back into the free list */
|
||||
void ffi_closure_free(void *p)
|
||||
{
|
||||
ITEM *item = (ITEM *)p;
|
||||
item->next = free_list;
|
||||
free_list = item;
|
||||
}
|
||||
|
||||
/* return one item from the free list, allocating more if needed */
|
||||
void *ffi_closure_alloc(size_t ignored, void** codeloc)
|
||||
{
|
||||
ITEM *item;
|
||||
if (!free_list)
|
||||
more_core();
|
||||
if (!free_list)
|
||||
return NULL;
|
||||
item = free_list;
|
||||
free_list = item->next;
|
||||
*codeloc = (void *)item;
|
||||
return (void *)item;
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
raw_api.c - Copyright (c) 1999, 2008 Red Hat, Inc.
|
||||
|
||||
Author: Kresten Krab Thorup <krab@gnu.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
/* This file defines generic functions for use with the raw api. */
|
||||
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
|
||||
#if !FFI_NO_RAW_API
|
||||
|
||||
size_t
|
||||
ffi_raw_size (ffi_cif *cif)
|
||||
{
|
||||
size_t result = 0;
|
||||
int i;
|
||||
|
||||
ffi_type **at = cif->arg_types;
|
||||
|
||||
for (i = cif->nargs-1; i >= 0; i--, at++)
|
||||
{
|
||||
#if !FFI_NO_STRUCTS
|
||||
if ((*at)->type == FFI_TYPE_STRUCT)
|
||||
result += ALIGN (sizeof (void*), FFI_SIZEOF_ARG);
|
||||
else
|
||||
#endif
|
||||
result += ALIGN ((*at)->size, FFI_SIZEOF_ARG);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args)
|
||||
{
|
||||
unsigned i;
|
||||
ffi_type **tp = cif->arg_types;
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
|
||||
for (i = 0; i < cif->nargs; i++, tp++, args++)
|
||||
{
|
||||
switch ((*tp)->type)
|
||||
{
|
||||
case FFI_TYPE_UINT8:
|
||||
case FFI_TYPE_SINT8:
|
||||
*args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 1);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_UINT16:
|
||||
case FFI_TYPE_SINT16:
|
||||
*args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 2);
|
||||
break;
|
||||
|
||||
#if FFI_SIZEOF_ARG >= 4
|
||||
case FFI_TYPE_UINT32:
|
||||
case FFI_TYPE_SINT32:
|
||||
*args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 4);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !FFI_NO_STRUCTS
|
||||
case FFI_TYPE_STRUCT:
|
||||
*args = (raw++)->ptr;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case FFI_TYPE_POINTER:
|
||||
*args = (void*) &(raw++)->ptr;
|
||||
break;
|
||||
|
||||
default:
|
||||
*args = raw;
|
||||
raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* WORDS_BIGENDIAN */
|
||||
|
||||
#if !PDP
|
||||
|
||||
/* then assume little endian */
|
||||
for (i = 0; i < cif->nargs; i++, tp++, args++)
|
||||
{
|
||||
#if !FFI_NO_STRUCTS
|
||||
if ((*tp)->type == FFI_TYPE_STRUCT)
|
||||
{
|
||||
*args = (raw++)->ptr;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
*args = (void*) raw;
|
||||
raw += ALIGN ((*tp)->size, sizeof (void*)) / sizeof (void*);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#error "pdp endian not supported"
|
||||
#endif /* ! PDP */
|
||||
|
||||
#endif /* WORDS_BIGENDIAN */
|
||||
}
|
||||
|
||||
void
|
||||
ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw)
|
||||
{
|
||||
unsigned i;
|
||||
ffi_type **tp = cif->arg_types;
|
||||
|
||||
for (i = 0; i < cif->nargs; i++, tp++, args++)
|
||||
{
|
||||
switch ((*tp)->type)
|
||||
{
|
||||
case FFI_TYPE_UINT8:
|
||||
(raw++)->uint = *(UINT8*) (*args);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_SINT8:
|
||||
(raw++)->sint = *(SINT8*) (*args);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_UINT16:
|
||||
(raw++)->uint = *(UINT16*) (*args);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_SINT16:
|
||||
(raw++)->sint = *(SINT16*) (*args);
|
||||
break;
|
||||
|
||||
#if FFI_SIZEOF_ARG >= 4
|
||||
case FFI_TYPE_UINT32:
|
||||
(raw++)->uint = *(UINT32*) (*args);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_SINT32:
|
||||
(raw++)->sint = *(SINT32*) (*args);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !FFI_NO_STRUCTS
|
||||
case FFI_TYPE_STRUCT:
|
||||
(raw++)->ptr = *args;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case FFI_TYPE_POINTER:
|
||||
(raw++)->ptr = **(void***) args;
|
||||
break;
|
||||
|
||||
default:
|
||||
memcpy ((void*) raw->data, (void*)*args, (*tp)->size);
|
||||
raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !FFI_NATIVE_RAW_API
|
||||
|
||||
|
||||
/* This is a generic definition of ffi_raw_call, to be used if the
|
||||
* native system does not provide a machine-specific implementation.
|
||||
* Having this, allows code to be written for the raw API, without
|
||||
* the need for system-specific code to handle input in that format;
|
||||
* these following couple of functions will handle the translation forth
|
||||
* and back automatically. */
|
||||
|
||||
void ffi_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *raw)
|
||||
{
|
||||
void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
|
||||
ffi_raw_to_ptrarray (cif, raw, avalue);
|
||||
ffi_call (cif, fn, rvalue, avalue);
|
||||
}
|
||||
|
||||
#if FFI_CLOSURES /* base system provides closures */
|
||||
|
||||
static void
|
||||
ffi_translate_args (ffi_cif *cif, void *rvalue,
|
||||
void **avalue, void *user_data)
|
||||
{
|
||||
ffi_raw *raw = (ffi_raw*)alloca (ffi_raw_size (cif));
|
||||
ffi_raw_closure *cl = (ffi_raw_closure*)user_data;
|
||||
|
||||
ffi_ptrarray_to_raw (cif, avalue, raw);
|
||||
(*cl->fun) (cif, rvalue, raw, cl->user_data);
|
||||
}
|
||||
|
||||
ffi_status
|
||||
ffi_prep_raw_closure_loc (ffi_raw_closure* cl,
|
||||
ffi_cif *cif,
|
||||
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
|
||||
void *user_data,
|
||||
void *codeloc)
|
||||
{
|
||||
ffi_status status;
|
||||
|
||||
status = ffi_prep_closure_loc ((ffi_closure*) cl,
|
||||
cif,
|
||||
&ffi_translate_args,
|
||||
codeloc,
|
||||
codeloc);
|
||||
if (status == FFI_OK)
|
||||
{
|
||||
cl->fun = fun;
|
||||
cl->user_data = user_data;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* FFI_CLOSURES */
|
||||
#endif /* !FFI_NATIVE_RAW_API */
|
||||
|
||||
#if FFI_CLOSURES
|
||||
|
||||
/* Again, here is the generic version of ffi_prep_raw_closure, which
|
||||
* will install an intermediate "hub" for translation of arguments from
|
||||
* the pointer-array format, to the raw format */
|
||||
|
||||
ffi_status
|
||||
ffi_prep_raw_closure (ffi_raw_closure* cl,
|
||||
ffi_cif *cif,
|
||||
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
|
||||
void *user_data)
|
||||
{
|
||||
return ffi_prep_raw_closure_loc (cl, cif, fun, user_data, cl);
|
||||
}
|
||||
|
||||
#endif /* FFI_CLOSURES */
|
||||
|
||||
#endif /* !FFI_NO_RAW_API */
|
||||
@@ -1,627 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
closures.c - Copyright (c) 2007, 2009, 2010 Red Hat, Inc.
|
||||
Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc
|
||||
Copyright (c) 2011 Plausible Labs Cooperative, Inc.
|
||||
|
||||
Code to allocate and deallocate memory for closures.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#if defined __linux__ && !defined _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
|
||||
#if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE
|
||||
# if __gnu_linux__
|
||||
/* This macro indicates it may be forbidden to map anonymous memory
|
||||
with both write and execute permission. Code compiled when this
|
||||
option is defined will attempt to map such pages once, but if it
|
||||
fails, it falls back to creating a temporary file in a writable and
|
||||
executable filesystem and mapping pages from it into separate
|
||||
locations in the virtual memory space, one location writable and
|
||||
another executable. */
|
||||
# define FFI_MMAP_EXEC_WRIT 1
|
||||
# define HAVE_MNTENT 1
|
||||
# endif
|
||||
# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)
|
||||
/* Windows systems may have Data Execution Protection (DEP) enabled,
|
||||
which requires the use of VirtualMalloc/VirtualFree to alloc/free
|
||||
executable memory. */
|
||||
# define FFI_MMAP_EXEC_WRIT 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if FFI_MMAP_EXEC_WRIT && !defined FFI_MMAP_EXEC_SELINUX
|
||||
# ifdef __linux__
|
||||
/* When defined to 1 check for SELinux and if SELinux is active,
|
||||
don't attempt PROT_EXEC|PROT_WRITE mapping at all, as that
|
||||
might cause audit messages. */
|
||||
# define FFI_MMAP_EXEC_SELINUX 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if FFI_CLOSURES
|
||||
|
||||
# if FFI_EXEC_TRAMPOLINE_TABLE
|
||||
|
||||
// Per-target implementation; It's unclear what can reasonable be shared
|
||||
// between two OS/architecture implementations.
|
||||
|
||||
# elif FFI_MMAP_EXEC_WRIT /* !FFI_EXEC_TRAMPOLINE_TABLE */
|
||||
|
||||
#define USE_LOCKS 1
|
||||
#define USE_DL_PREFIX 1
|
||||
#ifdef __GNUC__
|
||||
#ifndef USE_BUILTIN_FFS
|
||||
#define USE_BUILTIN_FFS 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* We need to use mmap, not sbrk. */
|
||||
#define HAVE_MORECORE 0
|
||||
|
||||
/* We could, in theory, support mremap, but it wouldn't buy us anything. */
|
||||
#define HAVE_MREMAP 0
|
||||
|
||||
/* We have no use for this, so save some code and data. */
|
||||
#define NO_MALLINFO 1
|
||||
|
||||
/* We need all allocations to be in regular segments, otherwise we
|
||||
lose track of the corresponding code address. */
|
||||
#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T
|
||||
|
||||
/* Don't allocate more than a page unless needed. */
|
||||
#define DEFAULT_GRANULARITY ((size_t)malloc_getpagesize)
|
||||
|
||||
#if FFI_CLOSURE_TEST
|
||||
/* Don't release single pages, to avoid a worst-case scenario of
|
||||
continuously allocating and releasing single pages, but release
|
||||
pairs of pages, which should do just as well given that allocations
|
||||
are likely to be small. */
|
||||
#define DEFAULT_TRIM_THRESHOLD ((size_t)malloc_getpagesize)
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#if !defined(X86_WIN32) && !defined(X86_WIN64)
|
||||
#ifdef HAVE_MNTENT
|
||||
#include <mntent.h>
|
||||
#endif /* HAVE_MNTENT */
|
||||
#include <sys/param.h>
|
||||
#include <pthread.h>
|
||||
|
||||
/* We don't want sys/mman.h to be included after we redefine mmap and
|
||||
dlmunmap. */
|
||||
#include <sys/mman.h>
|
||||
#define LACKS_SYS_MMAN_H 1
|
||||
|
||||
#if FFI_MMAP_EXEC_SELINUX
|
||||
#include <sys/statfs.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int selinux_enabled = -1;
|
||||
|
||||
static int
|
||||
selinux_enabled_check (void)
|
||||
{
|
||||
struct statfs sfs;
|
||||
FILE *f;
|
||||
char *buf = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
if (statfs ("/selinux", &sfs) >= 0
|
||||
&& (unsigned int) sfs.f_type == 0xf97cff8cU)
|
||||
return 1;
|
||||
f = fopen ("/proc/mounts", "r");
|
||||
if (f == NULL)
|
||||
return 0;
|
||||
while (getline (&buf, &len, f) >= 0)
|
||||
{
|
||||
char *p = strchr (buf, ' ');
|
||||
if (p == NULL)
|
||||
break;
|
||||
p = strchr (p + 1, ' ');
|
||||
if (p == NULL)
|
||||
break;
|
||||
if (strncmp (p + 1, "selinuxfs ", 10) == 0)
|
||||
{
|
||||
free (buf);
|
||||
fclose (f);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
free (buf);
|
||||
fclose (f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define is_selinux_enabled() (selinux_enabled >= 0 ? selinux_enabled \
|
||||
: (selinux_enabled = selinux_enabled_check ()))
|
||||
|
||||
#else
|
||||
|
||||
#define is_selinux_enabled() 0
|
||||
|
||||
#endif /* !FFI_MMAP_EXEC_SELINUX */
|
||||
|
||||
/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */
|
||||
#ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX
|
||||
#include <stdlib.h>
|
||||
|
||||
static int emutramp_enabled = -1;
|
||||
|
||||
static int
|
||||
emutramp_enabled_check (void)
|
||||
{
|
||||
if (getenv ("FFI_DISABLE_EMUTRAMP") == NULL)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
|
||||
: (emutramp_enabled = emutramp_enabled_check ()))
|
||||
#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
|
||||
|
||||
#elif defined (__CYGWIN__) || defined(__INTERIX)
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
/* Cygwin is Linux-like, but not quite that Linux-like. */
|
||||
#define is_selinux_enabled() 0
|
||||
|
||||
#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
|
||||
|
||||
#ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX
|
||||
#define is_emutramp_enabled() 0
|
||||
#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
|
||||
|
||||
#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
|
||||
/* Use these for mmap and munmap within dlmalloc.c. */
|
||||
static void *dlmmap(void *, size_t, int, int, int, off_t);
|
||||
static int dlmunmap(void *, size_t);
|
||||
#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
|
||||
|
||||
#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
|
||||
|
||||
/* A mutex used to synchronize access to *exec* variables in this file. */
|
||||
static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
/* A file descriptor of a temporary file from which we'll map
|
||||
executable pages. */
|
||||
static int execfd = -1;
|
||||
|
||||
/* The amount of space already allocated from the temporary file. */
|
||||
static size_t execsize = 0;
|
||||
|
||||
/* Open a temporary file name, and immediately unlink it. */
|
||||
static int
|
||||
open_temp_exec_file_name (char *name)
|
||||
{
|
||||
int fd = mkstemp (name);
|
||||
|
||||
if (fd != -1)
|
||||
unlink (name);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* Open a temporary file in the named directory. */
|
||||
static int
|
||||
open_temp_exec_file_dir (const char *dir)
|
||||
{
|
||||
static const char suffix[] = "/ffiXXXXXX";
|
||||
int lendir = strlen (dir);
|
||||
char *tempname = __builtin_alloca (lendir + sizeof (suffix));
|
||||
|
||||
if (!tempname)
|
||||
return -1;
|
||||
|
||||
memcpy (tempname, dir, lendir);
|
||||
memcpy (tempname + lendir, suffix, sizeof (suffix));
|
||||
|
||||
return open_temp_exec_file_name (tempname);
|
||||
}
|
||||
|
||||
/* Open a temporary file in the directory in the named environment
|
||||
variable. */
|
||||
static int
|
||||
open_temp_exec_file_env (const char *envvar)
|
||||
{
|
||||
const char *value = getenv (envvar);
|
||||
|
||||
if (!value)
|
||||
return -1;
|
||||
|
||||
return open_temp_exec_file_dir (value);
|
||||
}
|
||||
|
||||
#ifdef HAVE_MNTENT
|
||||
/* Open a temporary file in an executable and writable mount point
|
||||
listed in the mounts file. Subsequent calls with the same mounts
|
||||
keep searching for mount points in the same file. Providing NULL
|
||||
as the mounts file closes the file. */
|
||||
static int
|
||||
open_temp_exec_file_mnt (const char *mounts)
|
||||
{
|
||||
static const char *last_mounts;
|
||||
static FILE *last_mntent;
|
||||
|
||||
if (mounts != last_mounts)
|
||||
{
|
||||
if (last_mntent)
|
||||
endmntent (last_mntent);
|
||||
|
||||
last_mounts = mounts;
|
||||
|
||||
if (mounts)
|
||||
last_mntent = setmntent (mounts, "r");
|
||||
else
|
||||
last_mntent = NULL;
|
||||
}
|
||||
|
||||
if (!last_mntent)
|
||||
return -1;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int fd;
|
||||
struct mntent mnt;
|
||||
char buf[MAXPATHLEN * 3];
|
||||
|
||||
if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf)) == NULL)
|
||||
return -1;
|
||||
|
||||
if (hasmntopt (&mnt, "ro")
|
||||
|| hasmntopt (&mnt, "noexec")
|
||||
|| access (mnt.mnt_dir, W_OK))
|
||||
continue;
|
||||
|
||||
fd = open_temp_exec_file_dir (mnt.mnt_dir);
|
||||
|
||||
if (fd != -1)
|
||||
return fd;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_MNTENT */
|
||||
|
||||
/* Instructions to look for a location to hold a temporary file that
|
||||
can be mapped in for execution. */
|
||||
static struct
|
||||
{
|
||||
int (*func)(const char *);
|
||||
const char *arg;
|
||||
int repeat;
|
||||
} open_temp_exec_file_opts[] = {
|
||||
{ open_temp_exec_file_env, "TMPDIR", 0 },
|
||||
{ open_temp_exec_file_dir, "/tmp", 0 },
|
||||
{ open_temp_exec_file_dir, "/var/tmp", 0 },
|
||||
{ open_temp_exec_file_dir, "/dev/shm", 0 },
|
||||
{ open_temp_exec_file_env, "HOME", 0 },
|
||||
#ifdef HAVE_MNTENT
|
||||
{ open_temp_exec_file_mnt, "/etc/mtab", 1 },
|
||||
{ open_temp_exec_file_mnt, "/proc/mounts", 1 },
|
||||
#endif /* HAVE_MNTENT */
|
||||
};
|
||||
|
||||
/* Current index into open_temp_exec_file_opts. */
|
||||
static int open_temp_exec_file_opts_idx = 0;
|
||||
|
||||
/* Reset a current multi-call func, then advances to the next entry.
|
||||
If we're at the last, go back to the first and return nonzero,
|
||||
otherwise return zero. */
|
||||
static int
|
||||
open_temp_exec_file_opts_next (void)
|
||||
{
|
||||
if (open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat)
|
||||
open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func (NULL);
|
||||
|
||||
open_temp_exec_file_opts_idx++;
|
||||
if (open_temp_exec_file_opts_idx
|
||||
== (sizeof (open_temp_exec_file_opts)
|
||||
/ sizeof (*open_temp_exec_file_opts)))
|
||||
{
|
||||
open_temp_exec_file_opts_idx = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return a file descriptor of a temporary zero-sized file in a
|
||||
writable and exexutable filesystem. */
|
||||
static int
|
||||
open_temp_exec_file (void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
do
|
||||
{
|
||||
fd = open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func
|
||||
(open_temp_exec_file_opts[open_temp_exec_file_opts_idx].arg);
|
||||
|
||||
if (!open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat
|
||||
|| fd == -1)
|
||||
{
|
||||
if (open_temp_exec_file_opts_next ())
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (fd == -1);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* Map in a chunk of memory from the temporary exec file into separate
|
||||
locations in the virtual memory address space, one writable and one
|
||||
executable. Returns the address of the writable portion, after
|
||||
storing an offset to the corresponding executable portion at the
|
||||
last word of the requested chunk. */
|
||||
static void *
|
||||
dlmmap_locked (void *start, size_t length, int prot, int flags, off_t offset)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if (execfd == -1)
|
||||
{
|
||||
open_temp_exec_file_opts_idx = 0;
|
||||
retry_open:
|
||||
execfd = open_temp_exec_file ();
|
||||
if (execfd == -1)
|
||||
return MFAIL;
|
||||
}
|
||||
|
||||
offset = execsize;
|
||||
|
||||
if (ftruncate (execfd, offset + length))
|
||||
return MFAIL;
|
||||
|
||||
flags &= ~(MAP_PRIVATE | MAP_ANONYMOUS);
|
||||
flags |= MAP_SHARED;
|
||||
|
||||
ptr = mmap (NULL, length, (prot & ~PROT_WRITE) | PROT_EXEC,
|
||||
flags, execfd, offset);
|
||||
if (ptr == MFAIL)
|
||||
{
|
||||
if (!offset)
|
||||
{
|
||||
close (execfd);
|
||||
goto retry_open;
|
||||
}
|
||||
ftruncate (execfd, offset);
|
||||
return MFAIL;
|
||||
}
|
||||
else if (!offset
|
||||
&& open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat)
|
||||
open_temp_exec_file_opts_next ();
|
||||
|
||||
start = mmap (start, length, prot, flags, execfd, offset);
|
||||
|
||||
if (start == MFAIL)
|
||||
{
|
||||
munmap (ptr, length);
|
||||
ftruncate (execfd, offset);
|
||||
return start;
|
||||
}
|
||||
|
||||
mmap_exec_offset ((char *)start, length) = (char*)ptr - (char*)start;
|
||||
|
||||
execsize += length;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
/* Map in a writable and executable chunk of memory if possible.
|
||||
Failing that, fall back to dlmmap_locked. */
|
||||
static void *
|
||||
dlmmap (void *start, size_t length, int prot,
|
||||
int flags, int fd, off_t offset)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
assert (start == NULL && length % malloc_getpagesize == 0
|
||||
&& prot == (PROT_READ | PROT_WRITE)
|
||||
&& flags == (MAP_PRIVATE | MAP_ANONYMOUS)
|
||||
&& fd == -1 && offset == 0);
|
||||
|
||||
#if FFI_CLOSURE_TEST
|
||||
printf ("mapping in %zi\n", length);
|
||||
#endif
|
||||
|
||||
if (execfd == -1 && is_emutramp_enabled ())
|
||||
{
|
||||
ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
if (execfd == -1 && !is_selinux_enabled ())
|
||||
{
|
||||
ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
|
||||
|
||||
if (ptr != MFAIL || (errno != EPERM && errno != EACCES))
|
||||
/* Cool, no need to mess with separate segments. */
|
||||
return ptr;
|
||||
|
||||
/* If MREMAP_DUP is ever introduced and implemented, try mmap
|
||||
with ((prot & ~PROT_WRITE) | PROT_EXEC) and mremap with
|
||||
MREMAP_DUP and prot at this point. */
|
||||
}
|
||||
|
||||
if (execsize == 0 || execfd == -1)
|
||||
{
|
||||
pthread_mutex_lock (&open_temp_exec_file_mutex);
|
||||
ptr = dlmmap_locked (start, length, prot, flags, offset);
|
||||
pthread_mutex_unlock (&open_temp_exec_file_mutex);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
return dlmmap_locked (start, length, prot, flags, offset);
|
||||
}
|
||||
|
||||
/* Release memory at the given address, as well as the corresponding
|
||||
executable page if it's separate. */
|
||||
static int
|
||||
dlmunmap (void *start, size_t length)
|
||||
{
|
||||
/* We don't bother decreasing execsize or truncating the file, since
|
||||
we can't quite tell whether we're unmapping the end of the file.
|
||||
We don't expect frequent deallocation anyway. If we did, we
|
||||
could locate pages in the file by writing to the pages being
|
||||
deallocated and checking that the file contents change.
|
||||
Yuck. */
|
||||
msegmentptr seg = segment_holding (gm, start);
|
||||
void *code;
|
||||
|
||||
#if FFI_CLOSURE_TEST
|
||||
printf ("unmapping %zi\n", length);
|
||||
#endif
|
||||
|
||||
if (seg && (code = add_segment_exec_offset (start, seg)) != start)
|
||||
{
|
||||
int ret = munmap (code, length);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return munmap (start, length);
|
||||
}
|
||||
|
||||
#if FFI_CLOSURE_FREE_CODE
|
||||
/* Return segment holding given code address. */
|
||||
static msegmentptr
|
||||
segment_holding_code (mstate m, char* addr)
|
||||
{
|
||||
msegmentptr sp = &m->seg;
|
||||
for (;;) {
|
||||
if (addr >= add_segment_exec_offset (sp->base, sp)
|
||||
&& addr < add_segment_exec_offset (sp->base, sp) + sp->size)
|
||||
return sp;
|
||||
if ((sp = sp->next) == 0)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
|
||||
|
||||
/* Allocate a chunk of memory with the given size. Returns a pointer
|
||||
to the writable address, and sets *CODE to the executable
|
||||
corresponding virtual address. */
|
||||
void *
|
||||
ffi_closure_alloc (size_t size, void **code)
|
||||
{
|
||||
*code = malloc(size);
|
||||
return *code;
|
||||
#if 0
|
||||
void *ptr;
|
||||
|
||||
if (!code)
|
||||
return NULL;
|
||||
|
||||
ptr = dlmalloc (size);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
msegmentptr seg = segment_holding (gm, ptr);
|
||||
|
||||
*code = add_segment_exec_offset (ptr, seg);
|
||||
}
|
||||
|
||||
return ptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Release a chunk of memory allocated with ffi_closure_alloc. If
|
||||
FFI_CLOSURE_FREE_CODE is nonzero, the given address can be the
|
||||
writable or the executable address given. Otherwise, only the
|
||||
writable address can be provided here. */
|
||||
void
|
||||
ffi_closure_free (void *ptr)
|
||||
{
|
||||
#if 0
|
||||
#if FFI_CLOSURE_FREE_CODE
|
||||
msegmentptr seg = segment_holding_code(gm, ptr);
|
||||
|
||||
if (seg)
|
||||
ptr = sub_segment_exec_offset(ptr, seg);
|
||||
#endif
|
||||
|
||||
dlfree(ptr);
|
||||
#endif
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
|
||||
#if FFI_CLOSURE_TEST
|
||||
/* Do some internal sanity testing to make sure allocation and
|
||||
deallocation of pages are working as intended. */
|
||||
int main ()
|
||||
{
|
||||
void *p[3];
|
||||
#define GET(idx, len) do { p[idx] = dlmalloc (len); printf ("allocated %zi for p[%i]\n", (len), (idx)); } while (0)
|
||||
#define PUT(idx) do { printf ("freeing p[%i]\n", (idx)); dlfree (p[idx]); } while (0)
|
||||
GET (0, malloc_getpagesize / 2);
|
||||
GET (1, 2 * malloc_getpagesize - 64 * sizeof (void*));
|
||||
PUT (1);
|
||||
GET (1, 2 * malloc_getpagesize);
|
||||
GET (2, malloc_getpagesize / 2);
|
||||
PUT (1);
|
||||
PUT (0);
|
||||
PUT (2);
|
||||
return 0;
|
||||
}
|
||||
#endif /* FFI_CLOSURE_TEST */
|
||||
# else /* ! FFI_MMAP_EXEC_WRIT */
|
||||
|
||||
/* On many systems, memory returned by malloc is writable and
|
||||
executable, so just use it. */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void *
|
||||
ffi_closure_alloc (size_t size, void **code)
|
||||
{
|
||||
if (!code)
|
||||
return NULL;
|
||||
|
||||
return *code = malloc (size);
|
||||
}
|
||||
|
||||
void
|
||||
ffi_closure_free (void *ptr)
|
||||
{
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
# endif /* ! FFI_MMAP_EXEC_WRIT */
|
||||
#endif /* FFI_CLOSURES */
|
||||
@@ -1,841 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
ffi.c - Copyright (c) 1996, 1998, 1999, 2001, 2007, 2008 Red Hat, Inc.
|
||||
Copyright (c) 2002 Ranjit Mathew
|
||||
Copyright (c) 2002 Bo Thorsen
|
||||
Copyright (c) 2002 Roger Sayle
|
||||
Copyright (C) 2008, 2010 Free Software Foundation, Inc.
|
||||
|
||||
x86 Foreign Function Interface
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#if !defined(__x86_64__) || defined(_WIN64)
|
||||
|
||||
#ifdef _WIN64
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* ffi_prep_args is called by the assembly routine once stack space
|
||||
has been allocated for the function's arguments */
|
||||
|
||||
void ffi_prep_args(char *stack, extended_cif *ecif)
|
||||
{
|
||||
register unsigned int i;
|
||||
register void **p_argv;
|
||||
register char *argp;
|
||||
register ffi_type **p_arg;
|
||||
#ifdef X86_WIN32
|
||||
size_t p_stack_args[2];
|
||||
void *p_stack_data[2];
|
||||
char *argp2 = stack;
|
||||
int stack_args_count = 0;
|
||||
int cabi = ecif->cif->abi;
|
||||
#endif
|
||||
|
||||
argp = stack;
|
||||
|
||||
if ((ecif->cif->flags == FFI_TYPE_STRUCT
|
||||
|| ecif->cif->flags == FFI_TYPE_MS_STRUCT)
|
||||
#ifdef X86_WIN64
|
||||
&& (ecif->cif->rtype->size != 1 && ecif->cif->rtype->size != 2
|
||||
&& ecif->cif->rtype->size != 4 && ecif->cif->rtype->size != 8)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
*(void **) argp = ecif->rvalue;
|
||||
#ifdef X86_WIN32
|
||||
/* For fastcall/thiscall this is first register-passed
|
||||
argument. */
|
||||
if (cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
|
||||
{
|
||||
p_stack_args[stack_args_count] = sizeof (void*);
|
||||
p_stack_data[stack_args_count] = argp;
|
||||
++stack_args_count;
|
||||
}
|
||||
#endif
|
||||
argp += sizeof(void*);
|
||||
}
|
||||
|
||||
p_argv = ecif->avalue;
|
||||
|
||||
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
|
||||
i != 0;
|
||||
i--, p_arg++)
|
||||
{
|
||||
size_t z;
|
||||
|
||||
/* Align if necessary */
|
||||
if ((sizeof(void*) - 1) & (size_t) argp)
|
||||
argp = (char *) ALIGN(argp, sizeof(void*));
|
||||
|
||||
z = (*p_arg)->size;
|
||||
#ifdef X86_WIN64
|
||||
if (z > sizeof(ffi_arg)
|
||||
|| ((*p_arg)->type == FFI_TYPE_STRUCT
|
||||
&& (z != 1 && z != 2 && z != 4 && z != 8))
|
||||
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
|
||||
|| ((*p_arg)->type == FFI_TYPE_LONGDOUBLE)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
z = sizeof(ffi_arg);
|
||||
*(void **)argp = *p_argv;
|
||||
}
|
||||
else if ((*p_arg)->type == FFI_TYPE_FLOAT)
|
||||
{
|
||||
memcpy(argp, *p_argv, z);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (z < sizeof(ffi_arg))
|
||||
{
|
||||
z = sizeof(ffi_arg);
|
||||
switch ((*p_arg)->type)
|
||||
{
|
||||
case FFI_TYPE_SINT8:
|
||||
*(ffi_sarg *) argp = (ffi_sarg)*(SINT8 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_UINT8:
|
||||
*(ffi_arg *) argp = (ffi_arg)*(UINT8 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_SINT16:
|
||||
*(ffi_sarg *) argp = (ffi_sarg)*(SINT16 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_UINT16:
|
||||
*(ffi_arg *) argp = (ffi_arg)*(UINT16 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_SINT32:
|
||||
*(ffi_sarg *) argp = (ffi_sarg)*(SINT32 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_UINT32:
|
||||
*(ffi_arg *) argp = (ffi_arg)*(UINT32 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_STRUCT:
|
||||
*(ffi_arg *) argp = *(ffi_arg *)(* p_argv);
|
||||
break;
|
||||
|
||||
default:
|
||||
FFI_ASSERT(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(argp, *p_argv, z);
|
||||
}
|
||||
|
||||
#ifdef X86_WIN32
|
||||
/* For thiscall/fastcall convention register-passed arguments
|
||||
are the first two none-floating-point arguments with a size
|
||||
smaller or equal to sizeof (void*). */
|
||||
if ((cabi == FFI_THISCALL && stack_args_count < 1)
|
||||
|| (cabi == FFI_FASTCALL && stack_args_count < 2))
|
||||
{
|
||||
if (z <= 4
|
||||
&& ((*p_arg)->type != FFI_TYPE_FLOAT
|
||||
&& (*p_arg)->type != FFI_TYPE_STRUCT))
|
||||
{
|
||||
p_stack_args[stack_args_count] = z;
|
||||
p_stack_data[stack_args_count] = argp;
|
||||
++stack_args_count;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
p_argv++;
|
||||
#ifdef X86_WIN64
|
||||
argp += (z + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
|
||||
#else
|
||||
argp += z;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef X86_WIN32
|
||||
/* We need to move the register-passed arguments for thiscall/fastcall
|
||||
on top of stack, so that those can be moved to registers ecx/edx by
|
||||
call-handler. */
|
||||
if (stack_args_count > 0)
|
||||
{
|
||||
size_t zz = (p_stack_args[0] + 3) & ~3;
|
||||
char *h;
|
||||
|
||||
/* Move first argument to top-stack position. */
|
||||
if (p_stack_data[0] != argp2)
|
||||
{
|
||||
h = alloca (zz + 1);
|
||||
memcpy (h, p_stack_data[0], zz);
|
||||
memmove (argp2 + zz, argp2,
|
||||
(size_t) ((char *) p_stack_data[0] - (char*)argp2));
|
||||
memcpy (argp2, h, zz);
|
||||
}
|
||||
|
||||
argp2 += zz;
|
||||
--stack_args_count;
|
||||
if (zz > 4)
|
||||
stack_args_count = 0;
|
||||
|
||||
/* If we have a second argument, then move it on top
|
||||
after the first one. */
|
||||
if (stack_args_count > 0 && p_stack_data[1] != argp2)
|
||||
{
|
||||
zz = p_stack_args[1];
|
||||
zz = (zz + 3) & ~3;
|
||||
h = alloca (zz + 1);
|
||||
h = alloca (zz + 1);
|
||||
memcpy (h, p_stack_data[1], zz);
|
||||
memmove (argp2 + zz, argp2, (size_t) ((char*) p_stack_data[1] - (char*)argp2));
|
||||
memcpy (argp2, h, zz);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/* Perform machine dependent cif processing */
|
||||
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
|
||||
{
|
||||
unsigned int i;
|
||||
ffi_type **ptr;
|
||||
|
||||
/* Set the return type flag */
|
||||
switch (cif->rtype->type)
|
||||
{
|
||||
case FFI_TYPE_VOID:
|
||||
case FFI_TYPE_UINT8:
|
||||
case FFI_TYPE_UINT16:
|
||||
case FFI_TYPE_SINT8:
|
||||
case FFI_TYPE_SINT16:
|
||||
#ifdef X86_WIN64
|
||||
case FFI_TYPE_UINT32:
|
||||
case FFI_TYPE_SINT32:
|
||||
#endif
|
||||
case FFI_TYPE_SINT64:
|
||||
case FFI_TYPE_FLOAT:
|
||||
case FFI_TYPE_DOUBLE:
|
||||
#ifndef X86_WIN64
|
||||
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
|
||||
case FFI_TYPE_LONGDOUBLE:
|
||||
#endif
|
||||
#endif
|
||||
cif->flags = (unsigned) cif->rtype->type;
|
||||
break;
|
||||
|
||||
case FFI_TYPE_UINT64:
|
||||
#ifdef X86_WIN64
|
||||
case FFI_TYPE_POINTER:
|
||||
#endif
|
||||
cif->flags = FFI_TYPE_SINT64;
|
||||
break;
|
||||
|
||||
case FFI_TYPE_STRUCT:
|
||||
#ifndef X86
|
||||
if (cif->rtype->size == 1)
|
||||
{
|
||||
cif->flags = FFI_TYPE_SMALL_STRUCT_1B; /* same as char size */
|
||||
}
|
||||
else if (cif->rtype->size == 2)
|
||||
{
|
||||
cif->flags = FFI_TYPE_SMALL_STRUCT_2B; /* same as short size */
|
||||
}
|
||||
else if (cif->rtype->size == 4)
|
||||
{
|
||||
#ifdef X86_WIN64
|
||||
cif->flags = FFI_TYPE_SMALL_STRUCT_4B;
|
||||
#else
|
||||
cif->flags = FFI_TYPE_INT; /* same as int type */
|
||||
#endif
|
||||
}
|
||||
else if (cif->rtype->size == 8)
|
||||
{
|
||||
cif->flags = FFI_TYPE_SINT64; /* same as int64 type */
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef X86_WIN32
|
||||
if (cif->abi == FFI_MS_CDECL)
|
||||
cif->flags = FFI_TYPE_MS_STRUCT;
|
||||
else
|
||||
#endif
|
||||
cif->flags = FFI_TYPE_STRUCT;
|
||||
/* allocate space for return value pointer */
|
||||
cif->bytes += ALIGN(sizeof(void*), FFI_SIZEOF_ARG);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
#ifdef X86_WIN64
|
||||
cif->flags = FFI_TYPE_SINT64;
|
||||
break;
|
||||
case FFI_TYPE_INT:
|
||||
cif->flags = FFI_TYPE_SINT32;
|
||||
#else
|
||||
cif->flags = FFI_TYPE_INT;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
|
||||
{
|
||||
if (((*ptr)->alignment - 1) & cif->bytes)
|
||||
cif->bytes = ALIGN(cif->bytes, (*ptr)->alignment);
|
||||
cif->bytes += ALIGN((*ptr)->size, FFI_SIZEOF_ARG);
|
||||
}
|
||||
|
||||
#ifdef X86_WIN64
|
||||
/* ensure space for storing four registers */
|
||||
cif->bytes += 4 * sizeof(ffi_arg);
|
||||
#endif
|
||||
|
||||
cif->bytes = (cif->bytes + 15) & ~0xF;
|
||||
|
||||
return FFI_OK;
|
||||
}
|
||||
|
||||
#ifdef X86_WIN64
|
||||
extern int
|
||||
ffi_call_win64(void (*)(char *, extended_cif *), extended_cif *,
|
||||
unsigned, unsigned, unsigned *, void (*fn)(void));
|
||||
#elif defined(X86_WIN32)
|
||||
extern void
|
||||
ffi_call_win32(void (*)(char *, extended_cif *), extended_cif *,
|
||||
unsigned, unsigned, unsigned, unsigned *, void (*fn)(void));
|
||||
#else
|
||||
extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
|
||||
unsigned, unsigned, unsigned *, void (*fn)(void));
|
||||
#endif
|
||||
|
||||
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
||||
{
|
||||
extended_cif ecif;
|
||||
|
||||
ecif.cif = cif;
|
||||
ecif.avalue = avalue;
|
||||
|
||||
/* If the return value is a struct and we don't have a return */
|
||||
/* value address then we need to make one */
|
||||
|
||||
#ifdef X86_WIN64
|
||||
if (rvalue == NULL
|
||||
&& cif->flags == FFI_TYPE_STRUCT
|
||||
&& cif->rtype->size != 1 && cif->rtype->size != 2
|
||||
&& cif->rtype->size != 4 && cif->rtype->size != 8)
|
||||
{
|
||||
ecif.rvalue = alloca((cif->rtype->size + 0xF) & ~0xF);
|
||||
}
|
||||
#else
|
||||
if (rvalue == NULL
|
||||
&& (cif->flags == FFI_TYPE_STRUCT
|
||||
|| cif->flags == FFI_TYPE_MS_STRUCT))
|
||||
{
|
||||
ecif.rvalue = alloca(cif->rtype->size);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
ecif.rvalue = rvalue;
|
||||
|
||||
|
||||
switch (cif->abi)
|
||||
{
|
||||
#ifdef X86_WIN64
|
||||
case FFI_WIN64:
|
||||
ffi_call_win64(ffi_prep_args, &ecif, cif->bytes,
|
||||
cif->flags, ecif.rvalue, fn);
|
||||
break;
|
||||
#elif defined(X86_WIN32)
|
||||
case FFI_SYSV:
|
||||
case FFI_STDCALL:
|
||||
case FFI_MS_CDECL:
|
||||
ffi_call_win32(ffi_prep_args, &ecif, cif->abi, cif->bytes, cif->flags,
|
||||
ecif.rvalue, fn);
|
||||
break;
|
||||
case FFI_THISCALL:
|
||||
case FFI_FASTCALL:
|
||||
{
|
||||
unsigned int abi = cif->abi;
|
||||
unsigned int i, passed_regs = 0;
|
||||
|
||||
if (cif->flags == FFI_TYPE_STRUCT)
|
||||
++passed_regs;
|
||||
|
||||
for (i=0; i < cif->nargs && passed_regs < 2;i++)
|
||||
{
|
||||
size_t sz;
|
||||
|
||||
if (cif->arg_types[i]->type == FFI_TYPE_FLOAT
|
||||
|| cif->arg_types[i]->type == FFI_TYPE_STRUCT)
|
||||
continue;
|
||||
sz = (cif->arg_types[i]->size + 3) & ~3;
|
||||
if (sz == 0 || sz > 4)
|
||||
continue;
|
||||
++passed_regs;
|
||||
}
|
||||
if (passed_regs < 2 && abi == FFI_FASTCALL)
|
||||
abi = FFI_THISCALL;
|
||||
if (passed_regs < 1 && abi == FFI_THISCALL)
|
||||
abi = FFI_STDCALL;
|
||||
ffi_call_win32(ffi_prep_args, &ecif, abi, cif->bytes, cif->flags,
|
||||
ecif.rvalue, fn);
|
||||
}
|
||||
break;
|
||||
#else
|
||||
case FFI_SYSV:
|
||||
ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue,
|
||||
fn);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
FFI_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** private members **/
|
||||
|
||||
/* The following __attribute__((regparm(1))) decorations will have no effect
|
||||
on MSVC or SUNPRO_C -- standard conventions apply. */
|
||||
static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
|
||||
void** args, ffi_cif* cif);
|
||||
void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *)
|
||||
__attribute__ ((regparm(1)));
|
||||
unsigned int FFI_HIDDEN ffi_closure_SYSV_inner (ffi_closure *, void **, void *)
|
||||
__attribute__ ((regparm(1)));
|
||||
void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *)
|
||||
__attribute__ ((regparm(1)));
|
||||
#ifdef X86_WIN32
|
||||
void FFI_HIDDEN ffi_closure_raw_THISCALL (ffi_raw_closure *)
|
||||
__attribute__ ((regparm(1)));
|
||||
void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *)
|
||||
__attribute__ ((regparm(1)));
|
||||
void FFI_HIDDEN ffi_closure_THISCALL (ffi_closure *)
|
||||
__attribute__ ((regparm(1)));
|
||||
#endif
|
||||
#ifdef X86_WIN64
|
||||
void FFI_HIDDEN ffi_closure_win64 (ffi_closure *);
|
||||
#endif
|
||||
|
||||
/* This function is jumped to by the trampoline */
|
||||
|
||||
#ifdef X86_WIN64
|
||||
void * FFI_HIDDEN
|
||||
ffi_closure_win64_inner (ffi_closure *closure, void *args) {
|
||||
ffi_cif *cif;
|
||||
void **arg_area;
|
||||
void *result;
|
||||
void *resp = &result;
|
||||
|
||||
cif = closure->cif;
|
||||
arg_area = (void**) alloca (cif->nargs * sizeof (void*));
|
||||
|
||||
/* this call will initialize ARG_AREA, such that each
|
||||
* element in that array points to the corresponding
|
||||
* value on the stack; and if the function returns
|
||||
* a structure, it will change RESP to point to the
|
||||
* structure return address. */
|
||||
|
||||
ffi_prep_incoming_args_SYSV(args, &resp, arg_area, cif);
|
||||
|
||||
(closure->fun) (cif, resp, arg_area, closure->user_data);
|
||||
|
||||
/* The result is returned in rax. This does the right thing for
|
||||
result types except for floats; we have to 'mov xmm0, rax' in the
|
||||
caller to correct this.
|
||||
TODO: structure sizes of 3 5 6 7 are returned by reference, too!!!
|
||||
*/
|
||||
return cif->rtype->size > sizeof(void *) ? resp : *(void **)resp;
|
||||
}
|
||||
|
||||
#else
|
||||
unsigned int FFI_HIDDEN __attribute__ ((regparm(1)))
|
||||
ffi_closure_SYSV_inner (ffi_closure *closure, void **respp, void *args)
|
||||
{
|
||||
/* our various things... */
|
||||
ffi_cif *cif;
|
||||
void **arg_area;
|
||||
|
||||
cif = closure->cif;
|
||||
arg_area = (void**) alloca (cif->nargs * sizeof (void*));
|
||||
|
||||
/* this call will initialize ARG_AREA, such that each
|
||||
* element in that array points to the corresponding
|
||||
* value on the stack; and if the function returns
|
||||
* a structure, it will change RESP to point to the
|
||||
* structure return address. */
|
||||
|
||||
ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif);
|
||||
|
||||
(closure->fun) (cif, *respp, arg_area, closure->user_data);
|
||||
|
||||
return cif->flags;
|
||||
}
|
||||
#endif /* !X86_WIN64 */
|
||||
|
||||
static void
|
||||
ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
|
||||
ffi_cif *cif)
|
||||
{
|
||||
register unsigned int i;
|
||||
register void **p_argv;
|
||||
register char *argp;
|
||||
register ffi_type **p_arg;
|
||||
|
||||
argp = stack;
|
||||
|
||||
#ifdef X86_WIN64
|
||||
if (cif->rtype->size > sizeof(ffi_arg)
|
||||
|| (cif->flags == FFI_TYPE_STRUCT
|
||||
&& (cif->rtype->size != 1 && cif->rtype->size != 2
|
||||
&& cif->rtype->size != 4 && cif->rtype->size != 8))) {
|
||||
*rvalue = *(void **) argp;
|
||||
argp += sizeof(void *);
|
||||
}
|
||||
#else
|
||||
if ( cif->flags == FFI_TYPE_STRUCT
|
||||
|| cif->flags == FFI_TYPE_MS_STRUCT ) {
|
||||
*rvalue = *(void **) argp;
|
||||
argp += sizeof(void *);
|
||||
}
|
||||
#endif
|
||||
|
||||
p_argv = avalue;
|
||||
|
||||
for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
|
||||
{
|
||||
size_t z;
|
||||
|
||||
/* Align if necessary */
|
||||
if ((sizeof(void*) - 1) & (size_t) argp) {
|
||||
argp = (char *) ALIGN(argp, sizeof(void*));
|
||||
}
|
||||
|
||||
#ifdef X86_WIN64
|
||||
if ((*p_arg)->size > sizeof(ffi_arg)
|
||||
|| ((*p_arg)->type == FFI_TYPE_STRUCT
|
||||
&& ((*p_arg)->size != 1 && (*p_arg)->size != 2
|
||||
&& (*p_arg)->size != 4 && (*p_arg)->size != 8)))
|
||||
{
|
||||
z = sizeof(void *);
|
||||
*p_argv = *(void **)argp;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
z = (*p_arg)->size;
|
||||
|
||||
/* because we're little endian, this is what it turns into. */
|
||||
|
||||
*p_argv = (void*) argp;
|
||||
}
|
||||
|
||||
p_argv++;
|
||||
#ifdef X86_WIN64
|
||||
argp += (z + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
|
||||
#else
|
||||
argp += z;
|
||||
#endif
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#define FFI_INIT_TRAMPOLINE_WIN64(TRAMP,FUN,CTX,MASK) \
|
||||
{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
|
||||
void* __fun = (void*)(FUN); \
|
||||
void* __ctx = (void*)(CTX); \
|
||||
*(unsigned char*) &__tramp[0] = 0x41; \
|
||||
*(unsigned char*) &__tramp[1] = 0xbb; \
|
||||
*(unsigned int*) &__tramp[2] = MASK; /* mov $mask, %r11 */ \
|
||||
*(unsigned char*) &__tramp[6] = 0x48; \
|
||||
*(unsigned char*) &__tramp[7] = 0xb8; \
|
||||
*(void**) &__tramp[8] = __ctx; /* mov __ctx, %rax */ \
|
||||
*(unsigned char *) &__tramp[16] = 0x49; \
|
||||
*(unsigned char *) &__tramp[17] = 0xba; \
|
||||
*(void**) &__tramp[18] = __fun; /* mov __fun, %r10 */ \
|
||||
*(unsigned char *) &__tramp[26] = 0x41; \
|
||||
*(unsigned char *) &__tramp[27] = 0xff; \
|
||||
*(unsigned char *) &__tramp[28] = 0xe2; /* jmp %r10 */ \
|
||||
}
|
||||
|
||||
/* How to make a trampoline. Derived from gcc/config/i386/i386.c. */
|
||||
|
||||
#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
|
||||
{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
|
||||
unsigned int __fun = (unsigned int)(FUN); \
|
||||
unsigned int __ctx = (unsigned int)(CTX); \
|
||||
unsigned int __dis = __fun - (__ctx + 10); \
|
||||
*(unsigned char*) &__tramp[0] = 0xb8; \
|
||||
*(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \
|
||||
*(unsigned char *) &__tramp[5] = 0xe9; \
|
||||
*(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \
|
||||
}
|
||||
|
||||
#define FFI_INIT_TRAMPOLINE_THISCALL(TRAMP,FUN,CTX,SIZE) \
|
||||
{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
|
||||
unsigned int __fun = (unsigned int)(FUN); \
|
||||
unsigned int __ctx = (unsigned int)(CTX); \
|
||||
unsigned int __dis = __fun - (__ctx + 49); \
|
||||
unsigned short __size = (unsigned short)(SIZE); \
|
||||
*(unsigned int *) &__tramp[0] = 0x8324048b; /* mov (%esp), %eax */ \
|
||||
*(unsigned int *) &__tramp[4] = 0x4c890cec; /* sub $12, %esp */ \
|
||||
*(unsigned int *) &__tramp[8] = 0x04890424; /* mov %ecx, 4(%esp) */ \
|
||||
*(unsigned char*) &__tramp[12] = 0x24; /* mov %eax, (%esp) */ \
|
||||
*(unsigned char*) &__tramp[13] = 0xb8; \
|
||||
*(unsigned int *) &__tramp[14] = __size; /* mov __size, %eax */ \
|
||||
*(unsigned int *) &__tramp[18] = 0x08244c8d; /* lea 8(%esp), %ecx */ \
|
||||
*(unsigned int *) &__tramp[22] = 0x4802e8c1; /* shr $2, %eax ; dec %eax */ \
|
||||
*(unsigned short*) &__tramp[26] = 0x0b74; /* jz 1f */ \
|
||||
*(unsigned int *) &__tramp[28] = 0x8908518b; /* 2b: mov 8(%ecx), %edx */ \
|
||||
*(unsigned int *) &__tramp[32] = 0x04c18311; /* mov %edx, (%ecx) ; add $4, %ecx */ \
|
||||
*(unsigned char*) &__tramp[36] = 0x48; /* dec %eax */ \
|
||||
*(unsigned short*) &__tramp[37] = 0xf575; /* jnz 2b ; 1f: */ \
|
||||
*(unsigned char*) &__tramp[39] = 0xb8; \
|
||||
*(unsigned int*) &__tramp[40] = __ctx; /* movl __ctx, %eax */ \
|
||||
*(unsigned char *) &__tramp[44] = 0xe8; \
|
||||
*(unsigned int*) &__tramp[45] = __dis; /* call __fun */ \
|
||||
*(unsigned char*) &__tramp[49] = 0xc2; /* ret */ \
|
||||
*(unsigned short*) &__tramp[50] = (__size + 8); /* ret (__size + 8) */ \
|
||||
}
|
||||
|
||||
#define FFI_INIT_TRAMPOLINE_STDCALL(TRAMP,FUN,CTX,SIZE) \
|
||||
{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
|
||||
unsigned int __fun = (unsigned int)(FUN); \
|
||||
unsigned int __ctx = (unsigned int)(CTX); \
|
||||
unsigned int __dis = __fun - (__ctx + 10); \
|
||||
unsigned short __size = (unsigned short)(SIZE); \
|
||||
*(unsigned char*) &__tramp[0] = 0xb8; \
|
||||
*(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \
|
||||
*(unsigned char *) &__tramp[5] = 0xe8; \
|
||||
*(unsigned int*) &__tramp[6] = __dis; /* call __fun */ \
|
||||
*(unsigned char *) &__tramp[10] = 0xc2; \
|
||||
*(unsigned short*) &__tramp[11] = __size; /* ret __size */ \
|
||||
}
|
||||
|
||||
/* the cif must already be prep'ed */
|
||||
|
||||
ffi_status
|
||||
ffi_prep_closure_loc (ffi_closure* closure,
|
||||
ffi_cif* cif,
|
||||
void (*fun)(ffi_cif*,void*,void**,void*),
|
||||
void *user_data,
|
||||
void *codeloc)
|
||||
{
|
||||
#ifdef X86_WIN64
|
||||
#define ISFLOAT(IDX) (cif->arg_types[IDX]->type == FFI_TYPE_FLOAT || cif->arg_types[IDX]->type == FFI_TYPE_DOUBLE)
|
||||
#define FLAG(IDX) (cif->nargs>(IDX)&&ISFLOAT(IDX)?(1<<(IDX)):0)
|
||||
if (cif->abi == FFI_WIN64)
|
||||
{
|
||||
int mask = FLAG(0)|FLAG(1)|FLAG(2)|FLAG(3);
|
||||
FFI_INIT_TRAMPOLINE_WIN64 (&closure->tramp[0],
|
||||
&ffi_closure_win64,
|
||||
codeloc, mask);
|
||||
/* make sure we can execute here */
|
||||
}
|
||||
#else
|
||||
if (cif->abi == FFI_SYSV)
|
||||
{
|
||||
FFI_INIT_TRAMPOLINE (&closure->tramp[0],
|
||||
&ffi_closure_SYSV,
|
||||
(void*)codeloc);
|
||||
}
|
||||
#ifdef X86_WIN32
|
||||
else if (cif->abi == FFI_THISCALL)
|
||||
{
|
||||
FFI_INIT_TRAMPOLINE_THISCALL (&closure->tramp[0],
|
||||
&ffi_closure_THISCALL,
|
||||
(void*)codeloc,
|
||||
cif->bytes);
|
||||
}
|
||||
else if (cif->abi == FFI_STDCALL)
|
||||
{
|
||||
FFI_INIT_TRAMPOLINE_STDCALL (&closure->tramp[0],
|
||||
&ffi_closure_STDCALL,
|
||||
(void*)codeloc, cif->bytes);
|
||||
}
|
||||
else if (cif->abi == FFI_MS_CDECL)
|
||||
{
|
||||
FFI_INIT_TRAMPOLINE (&closure->tramp[0],
|
||||
&ffi_closure_SYSV,
|
||||
(void*)codeloc);
|
||||
}
|
||||
#endif /* X86_WIN32 */
|
||||
#endif /* !X86_WIN64 */
|
||||
else
|
||||
{
|
||||
return FFI_BAD_ABI;
|
||||
}
|
||||
|
||||
closure->cif = cif;
|
||||
closure->user_data = user_data;
|
||||
closure->fun = fun;
|
||||
|
||||
return FFI_OK;
|
||||
}
|
||||
|
||||
/* ------- Native raw API support -------------------------------- */
|
||||
|
||||
#if !FFI_NO_RAW_API
|
||||
|
||||
ffi_status
|
||||
ffi_prep_raw_closure_loc (ffi_raw_closure* closure,
|
||||
ffi_cif* cif,
|
||||
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
|
||||
void *user_data,
|
||||
void *codeloc)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (cif->abi != FFI_SYSV) {
|
||||
#ifdef X86_WIN32
|
||||
if (cif->abi != FFI_THISCALL)
|
||||
#endif
|
||||
return FFI_BAD_ABI;
|
||||
}
|
||||
|
||||
/* we currently don't support certain kinds of arguments for raw
|
||||
closures. This should be implemented by a separate assembly
|
||||
language routine, since it would require argument processing,
|
||||
something we don't do now for performance. */
|
||||
|
||||
for (i = cif->nargs-1; i >= 0; i--)
|
||||
{
|
||||
FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_STRUCT);
|
||||
FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE);
|
||||
}
|
||||
|
||||
#ifdef X86_WIN32
|
||||
if (cif->abi == FFI_SYSV)
|
||||
{
|
||||
#endif
|
||||
FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV,
|
||||
codeloc);
|
||||
#ifdef X86_WIN32
|
||||
}
|
||||
else if (cif->abi == FFI_THISCALL)
|
||||
{
|
||||
FFI_INIT_TRAMPOLINE_THISCALL (&closure->tramp[0], &ffi_closure_raw_THISCALL,
|
||||
codeloc, cif->bytes);
|
||||
}
|
||||
#endif
|
||||
closure->cif = cif;
|
||||
closure->user_data = user_data;
|
||||
closure->fun = fun;
|
||||
|
||||
return FFI_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
ffi_prep_args_raw(char *stack, extended_cif *ecif)
|
||||
{
|
||||
memcpy (stack, ecif->avalue, ecif->cif->bytes);
|
||||
}
|
||||
|
||||
/* we borrow this routine from libffi (it must be changed, though, to
|
||||
* actually call the function passed in the first argument. as of
|
||||
* libffi-1.20, this is not the case.)
|
||||
*/
|
||||
|
||||
void
|
||||
ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
|
||||
{
|
||||
extended_cif ecif;
|
||||
void **avalue = (void **)fake_avalue;
|
||||
|
||||
ecif.cif = cif;
|
||||
ecif.avalue = avalue;
|
||||
|
||||
/* If the return value is a struct and we don't have a return */
|
||||
/* value address then we need to make one */
|
||||
|
||||
if (rvalue == NULL
|
||||
&& (cif->flags == FFI_TYPE_STRUCT
|
||||
|| cif->flags == FFI_TYPE_MS_STRUCT))
|
||||
{
|
||||
ecif.rvalue = alloca(cif->rtype->size);
|
||||
}
|
||||
else
|
||||
ecif.rvalue = rvalue;
|
||||
|
||||
|
||||
switch (cif->abi)
|
||||
{
|
||||
#ifdef X86_WIN32
|
||||
case FFI_SYSV:
|
||||
case FFI_STDCALL:
|
||||
case FFI_MS_CDECL:
|
||||
ffi_call_win32(ffi_prep_args_raw, &ecif, cif->abi, cif->bytes, cif->flags,
|
||||
ecif.rvalue, fn);
|
||||
break;
|
||||
case FFI_THISCALL:
|
||||
case FFI_FASTCALL:
|
||||
{
|
||||
unsigned int abi = cif->abi;
|
||||
unsigned int i, passed_regs = 0;
|
||||
|
||||
if (cif->flags == FFI_TYPE_STRUCT)
|
||||
++passed_regs;
|
||||
|
||||
for (i=0; i < cif->nargs && passed_regs < 2;i++)
|
||||
{
|
||||
size_t sz;
|
||||
|
||||
if (cif->arg_types[i]->type == FFI_TYPE_FLOAT
|
||||
|| cif->arg_types[i]->type == FFI_TYPE_STRUCT)
|
||||
continue;
|
||||
sz = (cif->arg_types[i]->size + 3) & ~3;
|
||||
if (sz == 0 || sz > 4)
|
||||
continue;
|
||||
++passed_regs;
|
||||
}
|
||||
if (passed_regs < 2 && abi == FFI_FASTCALL)
|
||||
cif->abi = abi = FFI_THISCALL;
|
||||
if (passed_regs < 1 && abi == FFI_THISCALL)
|
||||
cif->abi = abi = FFI_STDCALL;
|
||||
ffi_call_win32(ffi_prep_args_raw, &ecif, abi, cif->bytes, cif->flags,
|
||||
ecif.rvalue, fn);
|
||||
}
|
||||
break;
|
||||
#else
|
||||
case FFI_SYSV:
|
||||
ffi_call_SYSV(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
|
||||
ecif.rvalue, fn);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
FFI_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !__x86_64__ || X86_WIN64 */
|
||||
|
||||
@@ -1,673 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
ffi64.c - Copyright (c) 2013 The Written Word, Inc.
|
||||
Copyright (c) 2011 Anthony Green
|
||||
Copyright (c) 2008, 2010 Red Hat, Inc.
|
||||
Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de>
|
||||
|
||||
x86-64 Foreign Function Interface
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
#define MAX_GPR_REGS 6
|
||||
#define MAX_SSE_REGS 8
|
||||
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#define UINT128 __m128
|
||||
#else
|
||||
#if defined(__SUNPRO_C)
|
||||
#include <sunmedia_types.h>
|
||||
#define UINT128 __m128i
|
||||
#else
|
||||
#define UINT128 __int128_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
union big_int_union
|
||||
{
|
||||
UINT32 i32;
|
||||
UINT64 i64;
|
||||
UINT128 i128;
|
||||
};
|
||||
|
||||
struct register_args
|
||||
{
|
||||
/* Registers for argument passing. */
|
||||
UINT64 gpr[MAX_GPR_REGS];
|
||||
union big_int_union sse[MAX_SSE_REGS];
|
||||
};
|
||||
|
||||
extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
|
||||
void *raddr, void (*fnaddr)(void), unsigned ssecount);
|
||||
|
||||
/* All reference to register classes here is identical to the code in
|
||||
gcc/config/i386/i386.c. Do *not* change one without the other. */
|
||||
|
||||
/* Register class used for passing given 64bit part of the argument.
|
||||
These represent classes as documented by the PS ABI, with the
|
||||
exception of SSESF, SSEDF classes, that are basically SSE class,
|
||||
just gcc will use SF or DFmode move instead of DImode to avoid
|
||||
reformatting penalties.
|
||||
|
||||
Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves
|
||||
whenever possible (upper half does contain padding). */
|
||||
enum x86_64_reg_class
|
||||
{
|
||||
X86_64_NO_CLASS,
|
||||
X86_64_INTEGER_CLASS,
|
||||
X86_64_INTEGERSI_CLASS,
|
||||
X86_64_SSE_CLASS,
|
||||
X86_64_SSESF_CLASS,
|
||||
X86_64_SSEDF_CLASS,
|
||||
X86_64_SSEUP_CLASS,
|
||||
X86_64_X87_CLASS,
|
||||
X86_64_X87UP_CLASS,
|
||||
X86_64_COMPLEX_X87_CLASS,
|
||||
X86_64_MEMORY_CLASS
|
||||
};
|
||||
|
||||
#define MAX_CLASSES 4
|
||||
|
||||
#define SSE_CLASS_P(X) ((X) >= X86_64_SSE_CLASS && X <= X86_64_SSEUP_CLASS)
|
||||
|
||||
/* x86-64 register passing implementation. See x86-64 ABI for details. Goal
|
||||
of this code is to classify each 8bytes of incoming argument by the register
|
||||
class and assign registers accordingly. */
|
||||
|
||||
/* Return the union class of CLASS1 and CLASS2.
|
||||
See the x86-64 PS ABI for details. */
|
||||
|
||||
static enum x86_64_reg_class
|
||||
merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2)
|
||||
{
|
||||
/* Rule #1: If both classes are equal, this is the resulting class. */
|
||||
if (class1 == class2)
|
||||
return class1;
|
||||
|
||||
/* Rule #2: If one of the classes is NO_CLASS, the resulting class is
|
||||
the other class. */
|
||||
if (class1 == X86_64_NO_CLASS)
|
||||
return class2;
|
||||
if (class2 == X86_64_NO_CLASS)
|
||||
return class1;
|
||||
|
||||
/* Rule #3: If one of the classes is MEMORY, the result is MEMORY. */
|
||||
if (class1 == X86_64_MEMORY_CLASS || class2 == X86_64_MEMORY_CLASS)
|
||||
return X86_64_MEMORY_CLASS;
|
||||
|
||||
/* Rule #4: If one of the classes is INTEGER, the result is INTEGER. */
|
||||
if ((class1 == X86_64_INTEGERSI_CLASS && class2 == X86_64_SSESF_CLASS)
|
||||
|| (class2 == X86_64_INTEGERSI_CLASS && class1 == X86_64_SSESF_CLASS))
|
||||
return X86_64_INTEGERSI_CLASS;
|
||||
if (class1 == X86_64_INTEGER_CLASS || class1 == X86_64_INTEGERSI_CLASS
|
||||
|| class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS)
|
||||
return X86_64_INTEGER_CLASS;
|
||||
|
||||
/* Rule #5: If one of the classes is X87, X87UP, or COMPLEX_X87 class,
|
||||
MEMORY is used. */
|
||||
if (class1 == X86_64_X87_CLASS
|
||||
|| class1 == X86_64_X87UP_CLASS
|
||||
|| class1 == X86_64_COMPLEX_X87_CLASS
|
||||
|| class2 == X86_64_X87_CLASS
|
||||
|| class2 == X86_64_X87UP_CLASS
|
||||
|| class2 == X86_64_COMPLEX_X87_CLASS)
|
||||
return X86_64_MEMORY_CLASS;
|
||||
|
||||
/* Rule #6: Otherwise class SSE is used. */
|
||||
return X86_64_SSE_CLASS;
|
||||
}
|
||||
|
||||
/* Classify the argument of type TYPE and mode MODE.
|
||||
CLASSES will be filled by the register class used to pass each word
|
||||
of the operand. The number of words is returned. In case the parameter
|
||||
should be passed in memory, 0 is returned. As a special case for zero
|
||||
sized containers, classes[0] will be NO_CLASS and 1 is returned.
|
||||
|
||||
See the x86-64 PS ABI for details.
|
||||
*/
|
||||
static int
|
||||
classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
|
||||
size_t byte_offset)
|
||||
{
|
||||
switch (type->type)
|
||||
{
|
||||
case FFI_TYPE_UINT8:
|
||||
case FFI_TYPE_SINT8:
|
||||
case FFI_TYPE_UINT16:
|
||||
case FFI_TYPE_SINT16:
|
||||
case FFI_TYPE_UINT32:
|
||||
case FFI_TYPE_SINT32:
|
||||
case FFI_TYPE_UINT64:
|
||||
case FFI_TYPE_SINT64:
|
||||
case FFI_TYPE_POINTER:
|
||||
{
|
||||
int size = byte_offset + type->size;
|
||||
|
||||
if (size <= 4)
|
||||
{
|
||||
classes[0] = X86_64_INTEGERSI_CLASS;
|
||||
return 1;
|
||||
}
|
||||
else if (size <= 8)
|
||||
{
|
||||
classes[0] = X86_64_INTEGER_CLASS;
|
||||
return 1;
|
||||
}
|
||||
else if (size <= 12)
|
||||
{
|
||||
classes[0] = X86_64_INTEGER_CLASS;
|
||||
classes[1] = X86_64_INTEGERSI_CLASS;
|
||||
return 2;
|
||||
}
|
||||
else if (size <= 16)
|
||||
{
|
||||
classes[0] = classes[1] = X86_64_INTEGERSI_CLASS;
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
FFI_ASSERT (0);
|
||||
}
|
||||
case FFI_TYPE_FLOAT:
|
||||
if (!(byte_offset % 8))
|
||||
classes[0] = X86_64_SSESF_CLASS;
|
||||
else
|
||||
classes[0] = X86_64_SSE_CLASS;
|
||||
return 1;
|
||||
case FFI_TYPE_DOUBLE:
|
||||
classes[0] = X86_64_SSEDF_CLASS;
|
||||
return 1;
|
||||
case FFI_TYPE_LONGDOUBLE:
|
||||
classes[0] = X86_64_X87_CLASS;
|
||||
classes[1] = X86_64_X87UP_CLASS;
|
||||
return 2;
|
||||
case FFI_TYPE_STRUCT:
|
||||
{
|
||||
const int UNITS_PER_WORD = 8;
|
||||
int words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
|
||||
ffi_type **ptr;
|
||||
int i;
|
||||
enum x86_64_reg_class subclasses[MAX_CLASSES];
|
||||
|
||||
/* If the struct is larger than 32 bytes, pass it on the stack. */
|
||||
if (type->size > 32)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < words; i++)
|
||||
classes[i] = X86_64_NO_CLASS;
|
||||
|
||||
/* Zero sized arrays or structures are NO_CLASS. We return 0 to
|
||||
signalize memory class, so handle it as special case. */
|
||||
if (!words)
|
||||
{
|
||||
classes[0] = X86_64_NO_CLASS;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Merge the fields of structure. */
|
||||
for (ptr = type->elements; *ptr != NULL; ptr++)
|
||||
{
|
||||
int num;
|
||||
|
||||
byte_offset = ALIGN (byte_offset, (*ptr)->alignment);
|
||||
|
||||
num = classify_argument (*ptr, subclasses, byte_offset % 8);
|
||||
if (num == 0)
|
||||
return 0;
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
int pos = byte_offset / 8;
|
||||
classes[i + pos] =
|
||||
merge_classes (subclasses[i], classes[i + pos]);
|
||||
}
|
||||
|
||||
byte_offset += (*ptr)->size;
|
||||
}
|
||||
|
||||
if (words > 2)
|
||||
{
|
||||
/* When size > 16 bytes, if the first one isn't
|
||||
X86_64_SSE_CLASS or any other ones aren't
|
||||
X86_64_SSEUP_CLASS, everything should be passed in
|
||||
memory. */
|
||||
if (classes[0] != X86_64_SSE_CLASS)
|
||||
return 0;
|
||||
|
||||
for (i = 1; i < words; i++)
|
||||
if (classes[i] != X86_64_SSEUP_CLASS)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Final merger cleanup. */
|
||||
for (i = 0; i < words; i++)
|
||||
{
|
||||
/* If one class is MEMORY, everything should be passed in
|
||||
memory. */
|
||||
if (classes[i] == X86_64_MEMORY_CLASS)
|
||||
return 0;
|
||||
|
||||
/* The X86_64_SSEUP_CLASS should be always preceded by
|
||||
X86_64_SSE_CLASS or X86_64_SSEUP_CLASS. */
|
||||
if (classes[i] == X86_64_SSEUP_CLASS
|
||||
&& classes[i - 1] != X86_64_SSE_CLASS
|
||||
&& classes[i - 1] != X86_64_SSEUP_CLASS)
|
||||
{
|
||||
/* The first one should never be X86_64_SSEUP_CLASS. */
|
||||
FFI_ASSERT (i != 0);
|
||||
classes[i] = X86_64_SSE_CLASS;
|
||||
}
|
||||
|
||||
/* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
|
||||
everything should be passed in memory. */
|
||||
if (classes[i] == X86_64_X87UP_CLASS
|
||||
&& (classes[i - 1] != X86_64_X87_CLASS))
|
||||
{
|
||||
/* The first one should never be X86_64_X87UP_CLASS. */
|
||||
FFI_ASSERT (i != 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return words;
|
||||
}
|
||||
|
||||
default:
|
||||
FFI_ASSERT(0);
|
||||
}
|
||||
return 0; /* Never reached. */
|
||||
}
|
||||
|
||||
/* Examine the argument and return set number of register required in each
|
||||
class. Return zero iff parameter should be passed in memory, otherwise
|
||||
the number of registers. */
|
||||
|
||||
static int
|
||||
examine_argument (ffi_type *type, enum x86_64_reg_class classes[MAX_CLASSES],
|
||||
_Bool in_return, int *pngpr, int *pnsse)
|
||||
{
|
||||
int i, n, ngpr, nsse;
|
||||
|
||||
n = classify_argument (type, classes, 0);
|
||||
if (n == 0)
|
||||
return 0;
|
||||
|
||||
ngpr = nsse = 0;
|
||||
for (i = 0; i < n; ++i)
|
||||
switch (classes[i])
|
||||
{
|
||||
case X86_64_INTEGER_CLASS:
|
||||
case X86_64_INTEGERSI_CLASS:
|
||||
ngpr++;
|
||||
break;
|
||||
case X86_64_SSE_CLASS:
|
||||
case X86_64_SSESF_CLASS:
|
||||
case X86_64_SSEDF_CLASS:
|
||||
nsse++;
|
||||
break;
|
||||
case X86_64_NO_CLASS:
|
||||
case X86_64_SSEUP_CLASS:
|
||||
break;
|
||||
case X86_64_X87_CLASS:
|
||||
case X86_64_X87UP_CLASS:
|
||||
case X86_64_COMPLEX_X87_CLASS:
|
||||
return in_return != 0;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
*pngpr = ngpr;
|
||||
*pnsse = nsse;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* Perform machine dependent cif processing. */
|
||||
|
||||
ffi_status
|
||||
ffi_prep_cif_machdep (ffi_cif *cif)
|
||||
{
|
||||
int gprcount, ssecount, i, avn, n, ngpr, nsse, flags;
|
||||
enum x86_64_reg_class classes[MAX_CLASSES];
|
||||
size_t bytes;
|
||||
|
||||
gprcount = ssecount = 0;
|
||||
|
||||
flags = cif->rtype->type;
|
||||
if (flags != FFI_TYPE_VOID)
|
||||
{
|
||||
n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
|
||||
if (n == 0)
|
||||
{
|
||||
/* The return value is passed in memory. A pointer to that
|
||||
memory is the first argument. Allocate a register for it. */
|
||||
gprcount++;
|
||||
/* We don't have to do anything in asm for the return. */
|
||||
flags = FFI_TYPE_VOID;
|
||||
}
|
||||
else if (flags == FFI_TYPE_STRUCT)
|
||||
{
|
||||
/* Mark which registers the result appears in. */
|
||||
_Bool sse0 = SSE_CLASS_P (classes[0]);
|
||||
_Bool sse1 = n == 2 && SSE_CLASS_P (classes[1]);
|
||||
if (sse0 && !sse1)
|
||||
flags |= 1 << 8;
|
||||
else if (!sse0 && sse1)
|
||||
flags |= 1 << 9;
|
||||
else if (sse0 && sse1)
|
||||
flags |= 1 << 10;
|
||||
/* Mark the true size of the structure. */
|
||||
flags |= cif->rtype->size << 12;
|
||||
}
|
||||
}
|
||||
|
||||
/* Go over all arguments and determine the way they should be passed.
|
||||
If it's in a register and there is space for it, let that be so. If
|
||||
not, add it's size to the stack byte count. */
|
||||
for (bytes = 0, i = 0, avn = cif->nargs; i < avn; i++)
|
||||
{
|
||||
if (examine_argument (cif->arg_types[i], classes, 0, &ngpr, &nsse) == 0
|
||||
|| gprcount + ngpr > MAX_GPR_REGS
|
||||
|| ssecount + nsse > MAX_SSE_REGS)
|
||||
{
|
||||
long align = cif->arg_types[i]->alignment;
|
||||
|
||||
if (align < 8)
|
||||
align = 8;
|
||||
|
||||
bytes = ALIGN (bytes, align);
|
||||
bytes += cif->arg_types[i]->size;
|
||||
}
|
||||
else
|
||||
{
|
||||
gprcount += ngpr;
|
||||
ssecount += nsse;
|
||||
}
|
||||
}
|
||||
if (ssecount)
|
||||
flags |= 1 << 11;
|
||||
cif->flags = flags;
|
||||
cif->bytes = ALIGN (bytes, 8);
|
||||
|
||||
return FFI_OK;
|
||||
}
|
||||
|
||||
void
|
||||
ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
||||
{
|
||||
enum x86_64_reg_class classes[MAX_CLASSES];
|
||||
char *stack, *argp;
|
||||
ffi_type **arg_types;
|
||||
int gprcount, ssecount, ngpr, nsse, i, avn;
|
||||
_Bool ret_in_memory;
|
||||
struct register_args *reg_args;
|
||||
|
||||
/* Can't call 32-bit mode from 64-bit mode. */
|
||||
FFI_ASSERT (cif->abi == FFI_UNIX64);
|
||||
|
||||
/* If the return value is a struct and we don't have a return value
|
||||
address then we need to make one. Note the setting of flags to
|
||||
VOID above in ffi_prep_cif_machdep. */
|
||||
ret_in_memory = (cif->rtype->type == FFI_TYPE_STRUCT
|
||||
&& (cif->flags & 0xff) == FFI_TYPE_VOID);
|
||||
if (rvalue == NULL && ret_in_memory)
|
||||
rvalue = alloca (cif->rtype->size);
|
||||
|
||||
/* Allocate the space for the arguments, plus 4 words of temp space. */
|
||||
stack = alloca (sizeof (struct register_args) + cif->bytes + 4*8);
|
||||
reg_args = (struct register_args *) stack;
|
||||
argp = stack + sizeof (struct register_args);
|
||||
|
||||
gprcount = ssecount = 0;
|
||||
|
||||
/* If the return value is passed in memory, add the pointer as the
|
||||
first integer argument. */
|
||||
if (ret_in_memory)
|
||||
reg_args->gpr[gprcount++] = (unsigned long) rvalue;
|
||||
|
||||
avn = cif->nargs;
|
||||
arg_types = cif->arg_types;
|
||||
|
||||
for (i = 0; i < avn; ++i)
|
||||
{
|
||||
size_t size = arg_types[i]->size;
|
||||
int n;
|
||||
|
||||
n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
|
||||
if (n == 0
|
||||
|| gprcount + ngpr > MAX_GPR_REGS
|
||||
|| ssecount + nsse > MAX_SSE_REGS)
|
||||
{
|
||||
long align = arg_types[i]->alignment;
|
||||
|
||||
/* Stack arguments are *always* at least 8 byte aligned. */
|
||||
if (align < 8)
|
||||
align = 8;
|
||||
|
||||
/* Pass this argument in memory. */
|
||||
argp = (void *) ALIGN (argp, align);
|
||||
memcpy (argp, avalue[i], size);
|
||||
argp += size;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The argument is passed entirely in registers. */
|
||||
char *a = (char *) avalue[i];
|
||||
int j;
|
||||
|
||||
for (j = 0; j < n; j++, a += 8, size -= 8)
|
||||
{
|
||||
switch (classes[j])
|
||||
{
|
||||
case X86_64_INTEGER_CLASS:
|
||||
case X86_64_INTEGERSI_CLASS:
|
||||
/* Sign-extend integer arguments passed in general
|
||||
purpose registers, to cope with the fact that
|
||||
LLVM incorrectly assumes that this will be done
|
||||
(the x86-64 PS ABI does not specify this). */
|
||||
switch (arg_types[i]->type)
|
||||
{
|
||||
case FFI_TYPE_SINT8:
|
||||
*(SINT64 *)®_args->gpr[gprcount] = (SINT64) *((SINT8 *) a);
|
||||
break;
|
||||
case FFI_TYPE_SINT16:
|
||||
*(SINT64 *)®_args->gpr[gprcount] = (SINT64) *((SINT16 *) a);
|
||||
break;
|
||||
case FFI_TYPE_SINT32:
|
||||
*(SINT64 *)®_args->gpr[gprcount] = (SINT64) *((SINT32 *) a);
|
||||
break;
|
||||
default:
|
||||
reg_args->gpr[gprcount] = 0;
|
||||
memcpy (®_args->gpr[gprcount], a, size < 8 ? size : 8);
|
||||
}
|
||||
gprcount++;
|
||||
break;
|
||||
case X86_64_SSE_CLASS:
|
||||
case X86_64_SSEDF_CLASS:
|
||||
reg_args->sse[ssecount++].i64 = *(UINT64 *) a;
|
||||
break;
|
||||
case X86_64_SSESF_CLASS:
|
||||
reg_args->sse[ssecount++].i32 = *(UINT32 *) a;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ffi_call_unix64 (stack, cif->bytes + sizeof (struct register_args),
|
||||
cif->flags, rvalue, fn, ssecount);
|
||||
}
|
||||
|
||||
|
||||
extern void ffi_closure_unix64(void);
|
||||
|
||||
ffi_status
|
||||
ffi_prep_closure_loc (ffi_closure* closure,
|
||||
ffi_cif* cif,
|
||||
void (*fun)(ffi_cif*, void*, void**, void*),
|
||||
void *user_data,
|
||||
void *codeloc)
|
||||
{
|
||||
volatile unsigned short *tramp;
|
||||
|
||||
/* Sanity check on the cif ABI. */
|
||||
{
|
||||
int abi = cif->abi;
|
||||
if (UNLIKELY (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI)))
|
||||
return FFI_BAD_ABI;
|
||||
}
|
||||
|
||||
tramp = (volatile unsigned short *) &closure->tramp[0];
|
||||
|
||||
tramp[0] = 0xbb49; /* mov <code>, %r11 */
|
||||
*((unsigned long long * volatile) &tramp[1])
|
||||
= (unsigned long) ffi_closure_unix64;
|
||||
tramp[5] = 0xba49; /* mov <data>, %r10 */
|
||||
*((unsigned long long * volatile) &tramp[6])
|
||||
= (unsigned long) codeloc;
|
||||
|
||||
/* Set the carry bit iff the function uses any sse registers.
|
||||
This is clc or stc, together with the first byte of the jmp. */
|
||||
tramp[10] = cif->flags & (1 << 11) ? 0x49f9 : 0x49f8;
|
||||
|
||||
tramp[11] = 0xe3ff; /* jmp *%r11 */
|
||||
|
||||
closure->cif = cif;
|
||||
closure->fun = fun;
|
||||
closure->user_data = user_data;
|
||||
|
||||
return FFI_OK;
|
||||
}
|
||||
|
||||
int
|
||||
ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue,
|
||||
struct register_args *reg_args, char *argp)
|
||||
{
|
||||
ffi_cif *cif;
|
||||
void **avalue;
|
||||
ffi_type **arg_types;
|
||||
long i, avn;
|
||||
int gprcount, ssecount, ngpr, nsse;
|
||||
int ret;
|
||||
|
||||
cif = closure->cif;
|
||||
avalue = alloca(cif->nargs * sizeof(void *));
|
||||
gprcount = ssecount = 0;
|
||||
|
||||
ret = cif->rtype->type;
|
||||
if (ret != FFI_TYPE_VOID)
|
||||
{
|
||||
enum x86_64_reg_class classes[MAX_CLASSES];
|
||||
int n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
|
||||
if (n == 0)
|
||||
{
|
||||
/* The return value goes in memory. Arrange for the closure
|
||||
return value to go directly back to the original caller. */
|
||||
rvalue = (void *) (unsigned long) reg_args->gpr[gprcount++];
|
||||
/* We don't have to do anything in asm for the return. */
|
||||
ret = FFI_TYPE_VOID;
|
||||
}
|
||||
else if (ret == FFI_TYPE_STRUCT && n == 2)
|
||||
{
|
||||
/* Mark which register the second word of the structure goes in. */
|
||||
_Bool sse0 = SSE_CLASS_P (classes[0]);
|
||||
_Bool sse1 = SSE_CLASS_P (classes[1]);
|
||||
if (!sse0 && sse1)
|
||||
ret |= 1 << 8;
|
||||
else if (sse0 && !sse1)
|
||||
ret |= 1 << 9;
|
||||
}
|
||||
}
|
||||
|
||||
avn = cif->nargs;
|
||||
arg_types = cif->arg_types;
|
||||
|
||||
for (i = 0; i < avn; ++i)
|
||||
{
|
||||
enum x86_64_reg_class classes[MAX_CLASSES];
|
||||
int n;
|
||||
|
||||
n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
|
||||
if (n == 0
|
||||
|| gprcount + ngpr > MAX_GPR_REGS
|
||||
|| ssecount + nsse > MAX_SSE_REGS)
|
||||
{
|
||||
long align = arg_types[i]->alignment;
|
||||
|
||||
/* Stack arguments are *always* at least 8 byte aligned. */
|
||||
if (align < 8)
|
||||
align = 8;
|
||||
|
||||
/* Pass this argument in memory. */
|
||||
argp = (void *) ALIGN (argp, align);
|
||||
avalue[i] = argp;
|
||||
argp += arg_types[i]->size;
|
||||
}
|
||||
/* If the argument is in a single register, or two consecutive
|
||||
integer registers, then we can use that address directly. */
|
||||
else if (n == 1
|
||||
|| (n == 2 && !(SSE_CLASS_P (classes[0])
|
||||
|| SSE_CLASS_P (classes[1]))))
|
||||
{
|
||||
/* The argument is in a single register. */
|
||||
if (SSE_CLASS_P (classes[0]))
|
||||
{
|
||||
avalue[i] = ®_args->sse[ssecount];
|
||||
ssecount += n;
|
||||
}
|
||||
else
|
||||
{
|
||||
avalue[i] = ®_args->gpr[gprcount];
|
||||
gprcount += n;
|
||||
}
|
||||
}
|
||||
/* Otherwise, allocate space to make them consecutive. */
|
||||
else
|
||||
{
|
||||
char *a = alloca (16);
|
||||
int j;
|
||||
|
||||
avalue[i] = a;
|
||||
for (j = 0; j < n; j++, a += 8)
|
||||
{
|
||||
if (SSE_CLASS_P (classes[j]))
|
||||
memcpy (a, ®_args->sse[ssecount++], 8);
|
||||
else
|
||||
memcpy (a, ®_args->gpr[gprcount++], 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Invoke the closure. */
|
||||
closure->fun (cif, rvalue, avalue, closure->user_data);
|
||||
|
||||
/* Tell assembly how to perform return type promotions. */
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
@@ -1,237 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
prep_cif.c - Copyright (c) 2011, 2012 Anthony Green
|
||||
Copyright (c) 1996, 1998, 2007 Red Hat, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Round up to FFI_SIZEOF_ARG. */
|
||||
|
||||
#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
|
||||
|
||||
/* Perform machine independent initialization of aggregate type
|
||||
specifications. */
|
||||
|
||||
static ffi_status initialize_aggregate(ffi_type *arg)
|
||||
{
|
||||
ffi_type **ptr;
|
||||
|
||||
if (UNLIKELY(arg == NULL || arg->elements == NULL))
|
||||
return FFI_BAD_TYPEDEF;
|
||||
|
||||
arg->size = 0;
|
||||
arg->alignment = 0;
|
||||
|
||||
ptr = &(arg->elements[0]);
|
||||
|
||||
if (UNLIKELY(ptr == 0))
|
||||
return FFI_BAD_TYPEDEF;
|
||||
|
||||
while ((*ptr) != NULL)
|
||||
{
|
||||
if (UNLIKELY(((*ptr)->size == 0)
|
||||
&& (initialize_aggregate((*ptr)) != FFI_OK)))
|
||||
return FFI_BAD_TYPEDEF;
|
||||
|
||||
/* Perform a sanity check on the argument type */
|
||||
FFI_ASSERT_VALID_TYPE(*ptr);
|
||||
|
||||
arg->size = ALIGN(arg->size, (*ptr)->alignment);
|
||||
arg->size += (*ptr)->size;
|
||||
|
||||
arg->alignment = (arg->alignment > (*ptr)->alignment) ?
|
||||
arg->alignment : (*ptr)->alignment;
|
||||
|
||||
ptr++;
|
||||
}
|
||||
|
||||
/* Structure size includes tail padding. This is important for
|
||||
structures that fit in one register on ABIs like the PowerPC64
|
||||
Linux ABI that right justify small structs in a register.
|
||||
It's also needed for nested structure layout, for example
|
||||
struct A { long a; char b; }; struct B { struct A x; char y; };
|
||||
should find y at an offset of 2*sizeof(long) and result in a
|
||||
total size of 3*sizeof(long). */
|
||||
arg->size = ALIGN (arg->size, arg->alignment);
|
||||
|
||||
if (arg->size == 0)
|
||||
return FFI_BAD_TYPEDEF;
|
||||
else
|
||||
return FFI_OK;
|
||||
}
|
||||
|
||||
#ifndef __CRIS__
|
||||
/* The CRIS ABI specifies structure elements to have byte
|
||||
alignment only, so it completely overrides this functions,
|
||||
which assumes "natural" alignment and padding. */
|
||||
|
||||
/* Perform machine independent ffi_cif preparation, then call
|
||||
machine dependent routine. */
|
||||
|
||||
/* For non variadic functions isvariadic should be 0 and
|
||||
nfixedargs==ntotalargs.
|
||||
|
||||
For variadic calls, isvariadic should be 1 and nfixedargs
|
||||
and ntotalargs set as appropriate. nfixedargs must always be >=1 */
|
||||
|
||||
|
||||
ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi,
|
||||
unsigned int isvariadic,
|
||||
unsigned int nfixedargs,
|
||||
unsigned int ntotalargs,
|
||||
ffi_type *rtype, ffi_type **atypes)
|
||||
{
|
||||
unsigned bytes = 0;
|
||||
unsigned int i;
|
||||
ffi_type **ptr;
|
||||
|
||||
FFI_ASSERT(cif != NULL);
|
||||
FFI_ASSERT((!isvariadic) || (nfixedargs >= 1));
|
||||
FFI_ASSERT(nfixedargs <= ntotalargs);
|
||||
|
||||
#ifndef X86_WIN32
|
||||
if (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI))
|
||||
return FFI_BAD_ABI;
|
||||
#else
|
||||
if (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI || abi == FFI_THISCALL))
|
||||
return FFI_BAD_ABI;
|
||||
#endif
|
||||
|
||||
cif->abi = abi;
|
||||
cif->arg_types = atypes;
|
||||
cif->nargs = ntotalargs;
|
||||
cif->rtype = rtype;
|
||||
|
||||
cif->flags = 0;
|
||||
|
||||
/* Initialize the return type if necessary */
|
||||
if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
|
||||
return FFI_BAD_TYPEDEF;
|
||||
|
||||
/* Perform a sanity check on the return type */
|
||||
FFI_ASSERT_VALID_TYPE(cif->rtype);
|
||||
|
||||
/* x86, x86-64 and s390 stack space allocation is handled in prep_machdep. */
|
||||
#if !defined M68K && !defined X86_ANY && !defined S390 && !defined PA
|
||||
/* Make space for the return structure pointer */
|
||||
if (cif->rtype->type == FFI_TYPE_STRUCT
|
||||
#ifdef SPARC
|
||||
&& (cif->abi != FFI_V9 || cif->rtype->size > 32)
|
||||
#endif
|
||||
#ifdef TILE
|
||||
&& (cif->rtype->size > 10 * FFI_SIZEOF_ARG)
|
||||
#endif
|
||||
#ifdef XTENSA
|
||||
&& (cif->rtype->size > 16)
|
||||
#endif
|
||||
|
||||
)
|
||||
bytes = STACK_ARG_SIZE(sizeof(void*));
|
||||
#endif
|
||||
|
||||
for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
|
||||
{
|
||||
|
||||
/* Initialize any uninitialized aggregate type definitions */
|
||||
if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
|
||||
return FFI_BAD_TYPEDEF;
|
||||
|
||||
/* Perform a sanity check on the argument type, do this
|
||||
check after the initialization. */
|
||||
FFI_ASSERT_VALID_TYPE(*ptr);
|
||||
|
||||
#if !defined X86_ANY && !defined S390 && !defined PA
|
||||
#ifdef SPARC
|
||||
if (((*ptr)->type == FFI_TYPE_STRUCT
|
||||
&& ((*ptr)->size > 16 || cif->abi != FFI_V9))
|
||||
|| ((*ptr)->type == FFI_TYPE_LONGDOUBLE
|
||||
&& cif->abi != FFI_V9))
|
||||
bytes += sizeof(void*);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Add any padding if necessary */
|
||||
if (((*ptr)->alignment - 1) & bytes)
|
||||
bytes = ALIGN(bytes, (*ptr)->alignment);
|
||||
|
||||
#ifdef TILE
|
||||
if (bytes < 10 * FFI_SIZEOF_ARG &&
|
||||
bytes + STACK_ARG_SIZE((*ptr)->size) > 10 * FFI_SIZEOF_ARG)
|
||||
{
|
||||
/* An argument is never split between the 10 parameter
|
||||
registers and the stack. */
|
||||
bytes = 10 * FFI_SIZEOF_ARG;
|
||||
}
|
||||
#endif
|
||||
#ifdef XTENSA
|
||||
if (bytes <= 6*4 && bytes + STACK_ARG_SIZE((*ptr)->size) > 6*4)
|
||||
bytes = 6*4;
|
||||
#endif
|
||||
|
||||
bytes += STACK_ARG_SIZE((*ptr)->size);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
cif->bytes = bytes;
|
||||
|
||||
/* Perform machine dependent cif processing */
|
||||
#ifdef FFI_TARGET_SPECIFIC_VARIADIC
|
||||
if (isvariadic)
|
||||
return ffi_prep_cif_machdep_var(cif, nfixedargs, ntotalargs);
|
||||
#endif
|
||||
|
||||
return ffi_prep_cif_machdep(cif);
|
||||
}
|
||||
#endif /* not __CRIS__ */
|
||||
|
||||
ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs,
|
||||
ffi_type *rtype, ffi_type **atypes)
|
||||
{
|
||||
return ffi_prep_cif_core(cif, abi, 0, nargs, nargs, rtype, atypes);
|
||||
}
|
||||
|
||||
ffi_status ffi_prep_cif_var(ffi_cif *cif,
|
||||
ffi_abi abi,
|
||||
unsigned int nfixedargs,
|
||||
unsigned int ntotalargs,
|
||||
ffi_type *rtype,
|
||||
ffi_type **atypes)
|
||||
{
|
||||
return ffi_prep_cif_core(cif, abi, 1, nfixedargs, ntotalargs, rtype, atypes);
|
||||
}
|
||||
|
||||
#if FFI_CLOSURES
|
||||
|
||||
ffi_status
|
||||
ffi_prep_closure (ffi_closure* closure,
|
||||
ffi_cif* cif,
|
||||
void (*fun)(ffi_cif*,void*,void**,void*),
|
||||
void *user_data)
|
||||
{
|
||||
return ffi_prep_closure_loc (closure, cif, fun, user_data, closure);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,77 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
types.c - Copyright (c) 1996, 1998 Red Hat, Inc.
|
||||
|
||||
Predefined ffi_types needed by libffi.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
/* Hide the basic type definitions from the header file, so that we
|
||||
can redefine them here as "const". */
|
||||
#define LIBFFI_HIDE_BASIC_TYPES
|
||||
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
|
||||
/* Type definitions */
|
||||
|
||||
#define FFI_TYPEDEF(name, type, id) \
|
||||
struct struct_align_##name { \
|
||||
char c; \
|
||||
type x; \
|
||||
}; \
|
||||
const ffi_type ffi_type_##name = { \
|
||||
sizeof(type), \
|
||||
offsetof(struct struct_align_##name, x), \
|
||||
id, NULL \
|
||||
}
|
||||
|
||||
/* Size and alignment are fake here. They must not be 0. */
|
||||
const ffi_type ffi_type_void = {
|
||||
1, 1, FFI_TYPE_VOID, NULL
|
||||
};
|
||||
|
||||
FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8);
|
||||
FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8);
|
||||
FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16);
|
||||
FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16);
|
||||
FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32);
|
||||
FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32);
|
||||
FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64);
|
||||
FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64);
|
||||
|
||||
FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER);
|
||||
|
||||
FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT);
|
||||
FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE);
|
||||
|
||||
#ifdef __alpha__
|
||||
/* Even if we're not configured to default to 128-bit long double,
|
||||
maintain binary compatibility, as -mlong-double-128 can be used
|
||||
at any time. */
|
||||
/* Validate the hard-coded number below. */
|
||||
# if defined(__LONG_DOUBLE_128__) && FFI_TYPE_LONGDOUBLE != 4
|
||||
# error FFI_TYPE_LONGDOUBLE out of date
|
||||
# endif
|
||||
const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL };
|
||||
#elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
||||
FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);
|
||||
#endif
|
||||
@@ -1,759 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
win32.S - Copyright (c) 1996, 1998, 2001, 2002, 2009 Red Hat, Inc.
|
||||
Copyright (c) 2001 John Beniton
|
||||
Copyright (c) 2002 Ranjit Mathew
|
||||
Copyright (c) 2009 Daniel Witte
|
||||
|
||||
|
||||
X86 Foreign Function Interface
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define LIBFFI_ASM
|
||||
#include <fficonfig.h>
|
||||
#include <ffi.h>
|
||||
#include <ffitarget.h>
|
||||
|
||||
.text
|
||||
|
||||
// This assumes we are using gas.
|
||||
.balign 16
|
||||
.globl _ffi_call_win32
|
||||
#ifndef __OS2__
|
||||
.def _ffi_call_win32; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
_ffi_call_win32:
|
||||
.LFB1:
|
||||
pushl %ebp
|
||||
.LCFI0:
|
||||
movl %esp,%ebp
|
||||
.LCFI1:
|
||||
// Make room for all of the new args.
|
||||
movl 20(%ebp),%ecx
|
||||
subl %ecx,%esp
|
||||
|
||||
movl %esp,%eax
|
||||
|
||||
// Place all of the ffi_prep_args in position
|
||||
pushl 12(%ebp)
|
||||
pushl %eax
|
||||
call *8(%ebp)
|
||||
|
||||
// Return stack to previous state and call the function
|
||||
addl $8,%esp
|
||||
|
||||
// Handle fastcall and thiscall
|
||||
cmpl $3, 16(%ebp) // FFI_THISCALL
|
||||
jz .do_thiscall
|
||||
cmpl $4, 16(%ebp) // FFI_FASTCALL
|
||||
jnz .do_fncall
|
||||
movl (%esp), %ecx
|
||||
movl 4(%esp), %edx
|
||||
addl $8, %esp
|
||||
jmp .do_fncall
|
||||
.do_thiscall:
|
||||
movl (%esp), %ecx
|
||||
addl $4, %esp
|
||||
|
||||
.do_fncall:
|
||||
|
||||
// FIXME: Align the stack to a 128-bit boundary to avoid
|
||||
// potential performance hits.
|
||||
|
||||
call *32(%ebp)
|
||||
|
||||
// stdcall functions pop arguments off the stack themselves
|
||||
|
||||
// Load %ecx with the return type code
|
||||
movl 24(%ebp),%ecx
|
||||
|
||||
// If the return value pointer is NULL, assume no return value.
|
||||
cmpl $0,28(%ebp)
|
||||
jne 0f
|
||||
|
||||
// Even if there is no space for the return value, we are
|
||||
// obliged to handle floating-point values.
|
||||
cmpl $FFI_TYPE_FLOAT,%ecx
|
||||
jne .Lnoretval
|
||||
fstp %st(0)
|
||||
|
||||
jmp .Lepilogue
|
||||
|
||||
0:
|
||||
call 1f
|
||||
// Do not insert anything here between the call and the jump table.
|
||||
.Lstore_table:
|
||||
.long .Lnoretval /* FFI_TYPE_VOID */
|
||||
.long .Lretint /* FFI_TYPE_INT */
|
||||
.long .Lretfloat /* FFI_TYPE_FLOAT */
|
||||
.long .Lretdouble /* FFI_TYPE_DOUBLE */
|
||||
.long .Lretlongdouble /* FFI_TYPE_LONGDOUBLE */
|
||||
.long .Lretuint8 /* FFI_TYPE_UINT8 */
|
||||
.long .Lretsint8 /* FFI_TYPE_SINT8 */
|
||||
.long .Lretuint16 /* FFI_TYPE_UINT16 */
|
||||
.long .Lretsint16 /* FFI_TYPE_SINT16 */
|
||||
.long .Lretint /* FFI_TYPE_UINT32 */
|
||||
.long .Lretint /* FFI_TYPE_SINT32 */
|
||||
.long .Lretint64 /* FFI_TYPE_UINT64 */
|
||||
.long .Lretint64 /* FFI_TYPE_SINT64 */
|
||||
.long .Lretstruct /* FFI_TYPE_STRUCT */
|
||||
.long .Lretint /* FFI_TYPE_POINTER */
|
||||
.long .Lretstruct1b /* FFI_TYPE_SMALL_STRUCT_1B */
|
||||
.long .Lretstruct2b /* FFI_TYPE_SMALL_STRUCT_2B */
|
||||
.long .Lretstruct4b /* FFI_TYPE_SMALL_STRUCT_4B */
|
||||
.long .Lretstruct /* FFI_TYPE_MS_STRUCT */
|
||||
1:
|
||||
add %ecx, %ecx
|
||||
add %ecx, %ecx
|
||||
add (%esp),%ecx
|
||||
add $4, %esp
|
||||
jmp *(%ecx)
|
||||
|
||||
/* Sign/zero extend as appropriate. */
|
||||
.Lretsint8:
|
||||
movsbl %al, %eax
|
||||
jmp .Lretint
|
||||
|
||||
.Lretsint16:
|
||||
movswl %ax, %eax
|
||||
jmp .Lretint
|
||||
|
||||
.Lretuint8:
|
||||
movzbl %al, %eax
|
||||
jmp .Lretint
|
||||
|
||||
.Lretuint16:
|
||||
movzwl %ax, %eax
|
||||
jmp .Lretint
|
||||
|
||||
.Lretint:
|
||||
// Load %ecx with the pointer to storage for the return value
|
||||
movl 28(%ebp),%ecx
|
||||
movl %eax,0(%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretfloat:
|
||||
// Load %ecx with the pointer to storage for the return value
|
||||
movl 28(%ebp),%ecx
|
||||
fstps (%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretdouble:
|
||||
// Load %ecx with the pointer to storage for the return value
|
||||
movl 28(%ebp),%ecx
|
||||
fstpl (%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretlongdouble:
|
||||
// Load %ecx with the pointer to storage for the return value
|
||||
movl 28(%ebp),%ecx
|
||||
fstpt (%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretint64:
|
||||
// Load %ecx with the pointer to storage for the return value
|
||||
movl 28(%ebp),%ecx
|
||||
movl %eax,0(%ecx)
|
||||
movl %edx,4(%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretstruct1b:
|
||||
// Load %ecx with the pointer to storage for the return value
|
||||
movl 28(%ebp),%ecx
|
||||
movb %al,0(%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretstruct2b:
|
||||
// Load %ecx with the pointer to storage for the return value
|
||||
movl 28(%ebp),%ecx
|
||||
movw %ax,0(%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretstruct4b:
|
||||
// Load %ecx with the pointer to storage for the return value
|
||||
movl 28(%ebp),%ecx
|
||||
movl %eax,0(%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretstruct:
|
||||
// Nothing to do!
|
||||
|
||||
.Lnoretval:
|
||||
.Lepilogue:
|
||||
movl %ebp,%esp
|
||||
popl %ebp
|
||||
ret
|
||||
.ffi_call_win32_end:
|
||||
.balign 16
|
||||
.globl _ffi_closure_THISCALL
|
||||
#ifndef __OS2__
|
||||
.def _ffi_closure_THISCALL; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
_ffi_closure_THISCALL:
|
||||
pushl %ebp
|
||||
movl %esp, %ebp
|
||||
subl $40, %esp
|
||||
leal -24(%ebp), %edx
|
||||
movl %edx, -12(%ebp) /* resp */
|
||||
leal 12(%ebp), %edx /* account for stub return address on stack */
|
||||
jmp .stub
|
||||
.LFE1:
|
||||
|
||||
// This assumes we are using gas.
|
||||
.balign 16
|
||||
.globl _ffi_closure_SYSV
|
||||
#ifndef __OS2__
|
||||
.def _ffi_closure_SYSV; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
_ffi_closure_SYSV:
|
||||
.LFB3:
|
||||
pushl %ebp
|
||||
.LCFI4:
|
||||
movl %esp, %ebp
|
||||
.LCFI5:
|
||||
subl $40, %esp
|
||||
leal -24(%ebp), %edx
|
||||
movl %edx, -12(%ebp) /* resp */
|
||||
leal 8(%ebp), %edx
|
||||
.stub:
|
||||
movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
|
||||
leal -12(%ebp), %edx
|
||||
movl %edx, (%esp) /* &resp */
|
||||
call _ffi_closure_SYSV_inner
|
||||
movl -12(%ebp), %ecx
|
||||
|
||||
0:
|
||||
call 1f
|
||||
// Do not insert anything here between the call and the jump table.
|
||||
.Lcls_store_table:
|
||||
.long .Lcls_noretval /* FFI_TYPE_VOID */
|
||||
.long .Lcls_retint /* FFI_TYPE_INT */
|
||||
.long .Lcls_retfloat /* FFI_TYPE_FLOAT */
|
||||
.long .Lcls_retdouble /* FFI_TYPE_DOUBLE */
|
||||
.long .Lcls_retldouble /* FFI_TYPE_LONGDOUBLE */
|
||||
.long .Lcls_retuint8 /* FFI_TYPE_UINT8 */
|
||||
.long .Lcls_retsint8 /* FFI_TYPE_SINT8 */
|
||||
.long .Lcls_retuint16 /* FFI_TYPE_UINT16 */
|
||||
.long .Lcls_retsint16 /* FFI_TYPE_SINT16 */
|
||||
.long .Lcls_retint /* FFI_TYPE_UINT32 */
|
||||
.long .Lcls_retint /* FFI_TYPE_SINT32 */
|
||||
.long .Lcls_retllong /* FFI_TYPE_UINT64 */
|
||||
.long .Lcls_retllong /* FFI_TYPE_SINT64 */
|
||||
.long .Lcls_retstruct /* FFI_TYPE_STRUCT */
|
||||
.long .Lcls_retint /* FFI_TYPE_POINTER */
|
||||
.long .Lcls_retstruct1 /* FFI_TYPE_SMALL_STRUCT_1B */
|
||||
.long .Lcls_retstruct2 /* FFI_TYPE_SMALL_STRUCT_2B */
|
||||
.long .Lcls_retstruct4 /* FFI_TYPE_SMALL_STRUCT_4B */
|
||||
.long .Lcls_retmsstruct /* FFI_TYPE_MS_STRUCT */
|
||||
|
||||
1:
|
||||
add %eax, %eax
|
||||
add %eax, %eax
|
||||
add (%esp),%eax
|
||||
add $4, %esp
|
||||
jmp *(%eax)
|
||||
|
||||
/* Sign/zero extend as appropriate. */
|
||||
.Lcls_retsint8:
|
||||
movsbl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retsint16:
|
||||
movswl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retuint8:
|
||||
movzbl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retuint16:
|
||||
movzwl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retint:
|
||||
movl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retfloat:
|
||||
flds (%ecx)
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retdouble:
|
||||
fldl (%ecx)
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retldouble:
|
||||
fldt (%ecx)
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retllong:
|
||||
movl (%ecx), %eax
|
||||
movl 4(%ecx), %edx
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retstruct1:
|
||||
movsbl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retstruct2:
|
||||
movswl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retstruct4:
|
||||
movl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retstruct:
|
||||
// Caller expects us to pop struct return value pointer hidden arg.
|
||||
movl %ebp, %esp
|
||||
popl %ebp
|
||||
ret $0x4
|
||||
|
||||
.Lcls_retmsstruct:
|
||||
// Caller expects us to return a pointer to the real return value.
|
||||
mov %ecx, %eax
|
||||
// Caller doesn't expects us to pop struct return value pointer hidden arg.
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_noretval:
|
||||
.Lcls_epilogue:
|
||||
movl %ebp, %esp
|
||||
popl %ebp
|
||||
ret
|
||||
.ffi_closure_SYSV_end:
|
||||
.LFE3:
|
||||
|
||||
#if !FFI_NO_RAW_API
|
||||
|
||||
#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
|
||||
#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
|
||||
#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
|
||||
#define CIF_FLAGS_OFFSET 20
|
||||
.balign 16
|
||||
.globl _ffi_closure_raw_THISCALL
|
||||
#ifndef __OS2__
|
||||
.def _ffi_closure_raw_THISCALL; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
_ffi_closure_raw_THISCALL:
|
||||
pushl %ebp
|
||||
movl %esp, %ebp
|
||||
pushl %esi
|
||||
subl $36, %esp
|
||||
movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
|
||||
movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
|
||||
movl %edx, 12(%esp) /* user_data */
|
||||
leal 12(%ebp), %edx /* __builtin_dwarf_cfa () */
|
||||
jmp .stubraw
|
||||
// This assumes we are using gas.
|
||||
.balign 16
|
||||
.globl _ffi_closure_raw_SYSV
|
||||
#ifndef __OS2__
|
||||
.def _ffi_closure_raw_SYSV; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
_ffi_closure_raw_SYSV:
|
||||
.LFB4:
|
||||
pushl %ebp
|
||||
.LCFI6:
|
||||
movl %esp, %ebp
|
||||
.LCFI7:
|
||||
pushl %esi
|
||||
.LCFI8:
|
||||
subl $36, %esp
|
||||
movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
|
||||
movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
|
||||
movl %edx, 12(%esp) /* user_data */
|
||||
leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */
|
||||
.stubraw:
|
||||
movl %edx, 8(%esp) /* raw_args */
|
||||
leal -24(%ebp), %edx
|
||||
movl %edx, 4(%esp) /* &res */
|
||||
movl %esi, (%esp) /* cif */
|
||||
call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */
|
||||
movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */
|
||||
0:
|
||||
call 1f
|
||||
// Do not insert anything here between the call and the jump table.
|
||||
.Lrcls_store_table:
|
||||
.long .Lrcls_noretval /* FFI_TYPE_VOID */
|
||||
.long .Lrcls_retint /* FFI_TYPE_INT */
|
||||
.long .Lrcls_retfloat /* FFI_TYPE_FLOAT */
|
||||
.long .Lrcls_retdouble /* FFI_TYPE_DOUBLE */
|
||||
.long .Lrcls_retldouble /* FFI_TYPE_LONGDOUBLE */
|
||||
.long .Lrcls_retuint8 /* FFI_TYPE_UINT8 */
|
||||
.long .Lrcls_retsint8 /* FFI_TYPE_SINT8 */
|
||||
.long .Lrcls_retuint16 /* FFI_TYPE_UINT16 */
|
||||
.long .Lrcls_retsint16 /* FFI_TYPE_SINT16 */
|
||||
.long .Lrcls_retint /* FFI_TYPE_UINT32 */
|
||||
.long .Lrcls_retint /* FFI_TYPE_SINT32 */
|
||||
.long .Lrcls_retllong /* FFI_TYPE_UINT64 */
|
||||
.long .Lrcls_retllong /* FFI_TYPE_SINT64 */
|
||||
.long .Lrcls_retstruct /* FFI_TYPE_STRUCT */
|
||||
.long .Lrcls_retint /* FFI_TYPE_POINTER */
|
||||
.long .Lrcls_retstruct1 /* FFI_TYPE_SMALL_STRUCT_1B */
|
||||
.long .Lrcls_retstruct2 /* FFI_TYPE_SMALL_STRUCT_2B */
|
||||
.long .Lrcls_retstruct4 /* FFI_TYPE_SMALL_STRUCT_4B */
|
||||
.long .Lrcls_retstruct /* FFI_TYPE_MS_STRUCT */
|
||||
1:
|
||||
add %eax, %eax
|
||||
add %eax, %eax
|
||||
add (%esp),%eax
|
||||
add $4, %esp
|
||||
jmp *(%eax)
|
||||
|
||||
/* Sign/zero extend as appropriate. */
|
||||
.Lrcls_retsint8:
|
||||
movsbl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retsint16:
|
||||
movswl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retuint8:
|
||||
movzbl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retuint16:
|
||||
movzwl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retint:
|
||||
movl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retfloat:
|
||||
flds -24(%ebp)
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retdouble:
|
||||
fldl -24(%ebp)
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retldouble:
|
||||
fldt -24(%ebp)
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retllong:
|
||||
movl -24(%ebp), %eax
|
||||
movl -20(%ebp), %edx
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retstruct1:
|
||||
movsbl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retstruct2:
|
||||
movswl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retstruct4:
|
||||
movl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retstruct:
|
||||
// Nothing to do!
|
||||
|
||||
.Lrcls_noretval:
|
||||
.Lrcls_epilogue:
|
||||
addl $36, %esp
|
||||
popl %esi
|
||||
popl %ebp
|
||||
ret
|
||||
.ffi_closure_raw_SYSV_end:
|
||||
.LFE4:
|
||||
|
||||
#endif /* !FFI_NO_RAW_API */
|
||||
|
||||
// This assumes we are using gas.
|
||||
.balign 16
|
||||
.globl _ffi_closure_STDCALL
|
||||
#ifndef __OS2__
|
||||
.def _ffi_closure_STDCALL; .scl 2; .type 32; .endef
|
||||
#endif
|
||||
_ffi_closure_STDCALL:
|
||||
.LFB5:
|
||||
pushl %ebp
|
||||
.LCFI9:
|
||||
movl %esp, %ebp
|
||||
.LCFI10:
|
||||
subl $40, %esp
|
||||
leal -24(%ebp), %edx
|
||||
movl %edx, -12(%ebp) /* resp */
|
||||
leal 12(%ebp), %edx /* account for stub return address on stack */
|
||||
movl %edx, 4(%esp) /* args */
|
||||
leal -12(%ebp), %edx
|
||||
movl %edx, (%esp) /* &resp */
|
||||
call _ffi_closure_SYSV_inner
|
||||
movl -12(%ebp), %ecx
|
||||
0:
|
||||
call 1f
|
||||
// Do not insert anything here between the call and the jump table.
|
||||
.Lscls_store_table:
|
||||
.long .Lscls_noretval /* FFI_TYPE_VOID */
|
||||
.long .Lscls_retint /* FFI_TYPE_INT */
|
||||
.long .Lscls_retfloat /* FFI_TYPE_FLOAT */
|
||||
.long .Lscls_retdouble /* FFI_TYPE_DOUBLE */
|
||||
.long .Lscls_retldouble /* FFI_TYPE_LONGDOUBLE */
|
||||
.long .Lscls_retuint8 /* FFI_TYPE_UINT8 */
|
||||
.long .Lscls_retsint8 /* FFI_TYPE_SINT8 */
|
||||
.long .Lscls_retuint16 /* FFI_TYPE_UINT16 */
|
||||
.long .Lscls_retsint16 /* FFI_TYPE_SINT16 */
|
||||
.long .Lscls_retint /* FFI_TYPE_UINT32 */
|
||||
.long .Lscls_retint /* FFI_TYPE_SINT32 */
|
||||
.long .Lscls_retllong /* FFI_TYPE_UINT64 */
|
||||
.long .Lscls_retllong /* FFI_TYPE_SINT64 */
|
||||
.long .Lscls_retstruct /* FFI_TYPE_STRUCT */
|
||||
.long .Lscls_retint /* FFI_TYPE_POINTER */
|
||||
.long .Lscls_retstruct1 /* FFI_TYPE_SMALL_STRUCT_1B */
|
||||
.long .Lscls_retstruct2 /* FFI_TYPE_SMALL_STRUCT_2B */
|
||||
.long .Lscls_retstruct4 /* FFI_TYPE_SMALL_STRUCT_4B */
|
||||
1:
|
||||
add %eax, %eax
|
||||
add %eax, %eax
|
||||
add (%esp),%eax
|
||||
add $4, %esp
|
||||
jmp *(%eax)
|
||||
|
||||
/* Sign/zero extend as appropriate. */
|
||||
.Lscls_retsint8:
|
||||
movsbl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retsint16:
|
||||
movswl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retuint8:
|
||||
movzbl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retuint16:
|
||||
movzwl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retint:
|
||||
movl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retfloat:
|
||||
flds (%ecx)
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retdouble:
|
||||
fldl (%ecx)
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retldouble:
|
||||
fldt (%ecx)
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retllong:
|
||||
movl (%ecx), %eax
|
||||
movl 4(%ecx), %edx
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retstruct1:
|
||||
movsbl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retstruct2:
|
||||
movswl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retstruct4:
|
||||
movl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retstruct:
|
||||
// Nothing to do!
|
||||
|
||||
.Lscls_noretval:
|
||||
.Lscls_epilogue:
|
||||
movl %ebp, %esp
|
||||
popl %ebp
|
||||
ret
|
||||
.ffi_closure_STDCALL_end:
|
||||
.LFE5:
|
||||
|
||||
#ifndef __OS2__
|
||||
.section .eh_frame,"w"
|
||||
#endif
|
||||
.Lframe1:
|
||||
.LSCIE1:
|
||||
.long .LECIE1-.LASCIE1 /* Length of Common Information Entry */
|
||||
.LASCIE1:
|
||||
.long 0x0 /* CIE Identifier Tag */
|
||||
.byte 0x1 /* CIE Version */
|
||||
#ifdef __PIC__
|
||||
.ascii "zR\0" /* CIE Augmentation */
|
||||
#else
|
||||
.ascii "\0" /* CIE Augmentation */
|
||||
#endif
|
||||
.byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */
|
||||
.byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */
|
||||
.byte 0x8 /* CIE RA Column */
|
||||
#ifdef __PIC__
|
||||
.byte 0x1 /* .uleb128 0x1; Augmentation size */
|
||||
.byte 0x1b /* FDE Encoding (pcrel sdata4) */
|
||||
#endif
|
||||
.byte 0xc /* DW_CFA_def_cfa CFA = r4 + 4 = 4(%esp) */
|
||||
.byte 0x4 /* .uleb128 0x4 */
|
||||
.byte 0x4 /* .uleb128 0x4 */
|
||||
.byte 0x88 /* DW_CFA_offset, column 0x8 %eip at CFA + 1 * -4 */
|
||||
.byte 0x1 /* .uleb128 0x1 */
|
||||
.align 4
|
||||
.LECIE1:
|
||||
|
||||
.LSFDE1:
|
||||
.long .LEFDE1-.LASFDE1 /* FDE Length */
|
||||
.LASFDE1:
|
||||
.long .LASFDE1-.Lframe1 /* FDE CIE offset */
|
||||
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
|
||||
.long .LFB1-. /* FDE initial location */
|
||||
#else
|
||||
.long .LFB1
|
||||
#endif
|
||||
.long .LFE1-.LFB1 /* FDE address range */
|
||||
#ifdef __PIC__
|
||||
.byte 0x0 /* .uleb128 0x0; Augmentation size */
|
||||
#endif
|
||||
/* DW_CFA_xxx CFI instructions go here. */
|
||||
|
||||
.byte 0x4 /* DW_CFA_advance_loc4 */
|
||||
.long .LCFI0-.LFB1
|
||||
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
|
||||
.byte 0x8 /* .uleb128 0x8 */
|
||||
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
|
||||
.byte 0x2 /* .uleb128 0x2 */
|
||||
|
||||
.byte 0x4 /* DW_CFA_advance_loc4 */
|
||||
.long .LCFI1-.LCFI0
|
||||
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
|
||||
.byte 0x5 /* .uleb128 0x5 */
|
||||
|
||||
/* End of DW_CFA_xxx CFI instructions. */
|
||||
.align 4
|
||||
.LEFDE1:
|
||||
|
||||
|
||||
.LSFDE3:
|
||||
.long .LEFDE3-.LASFDE3 /* FDE Length */
|
||||
.LASFDE3:
|
||||
.long .LASFDE3-.Lframe1 /* FDE CIE offset */
|
||||
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
|
||||
.long .LFB3-. /* FDE initial location */
|
||||
#else
|
||||
.long .LFB3
|
||||
#endif
|
||||
.long .LFE3-.LFB3 /* FDE address range */
|
||||
#ifdef __PIC__
|
||||
.byte 0x0 /* .uleb128 0x0; Augmentation size */
|
||||
#endif
|
||||
/* DW_CFA_xxx CFI instructions go here. */
|
||||
|
||||
.byte 0x4 /* DW_CFA_advance_loc4 */
|
||||
.long .LCFI4-.LFB3
|
||||
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
|
||||
.byte 0x8 /* .uleb128 0x8 */
|
||||
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
|
||||
.byte 0x2 /* .uleb128 0x2 */
|
||||
|
||||
.byte 0x4 /* DW_CFA_advance_loc4 */
|
||||
.long .LCFI5-.LCFI4
|
||||
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
|
||||
.byte 0x5 /* .uleb128 0x5 */
|
||||
|
||||
/* End of DW_CFA_xxx CFI instructions. */
|
||||
.align 4
|
||||
.LEFDE3:
|
||||
|
||||
#if !FFI_NO_RAW_API
|
||||
|
||||
.LSFDE4:
|
||||
.long .LEFDE4-.LASFDE4 /* FDE Length */
|
||||
.LASFDE4:
|
||||
.long .LASFDE4-.Lframe1 /* FDE CIE offset */
|
||||
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
|
||||
.long .LFB4-. /* FDE initial location */
|
||||
#else
|
||||
.long .LFB4
|
||||
#endif
|
||||
.long .LFE4-.LFB4 /* FDE address range */
|
||||
#ifdef __PIC__
|
||||
.byte 0x0 /* .uleb128 0x0; Augmentation size */
|
||||
#endif
|
||||
/* DW_CFA_xxx CFI instructions go here. */
|
||||
|
||||
.byte 0x4 /* DW_CFA_advance_loc4 */
|
||||
.long .LCFI6-.LFB4
|
||||
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
|
||||
.byte 0x8 /* .uleb128 0x8 */
|
||||
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
|
||||
.byte 0x2 /* .uleb128 0x2 */
|
||||
|
||||
.byte 0x4 /* DW_CFA_advance_loc4 */
|
||||
.long .LCFI7-.LCFI6
|
||||
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
|
||||
.byte 0x5 /* .uleb128 0x5 */
|
||||
|
||||
.byte 0x4 /* DW_CFA_advance_loc4 */
|
||||
.long .LCFI8-.LCFI7
|
||||
.byte 0x86 /* DW_CFA_offset, column 0x6 %esi at CFA + 3 * -4 */
|
||||
.byte 0x3 /* .uleb128 0x3 */
|
||||
|
||||
/* End of DW_CFA_xxx CFI instructions. */
|
||||
.align 4
|
||||
.LEFDE4:
|
||||
|
||||
#endif /* !FFI_NO_RAW_API */
|
||||
|
||||
.LSFDE5:
|
||||
.long .LEFDE5-.LASFDE5 /* FDE Length */
|
||||
.LASFDE5:
|
||||
.long .LASFDE5-.Lframe1 /* FDE CIE offset */
|
||||
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
|
||||
.long .LFB5-. /* FDE initial location */
|
||||
#else
|
||||
.long .LFB5
|
||||
#endif
|
||||
.long .LFE5-.LFB5 /* FDE address range */
|
||||
#ifdef __PIC__
|
||||
.byte 0x0 /* .uleb128 0x0; Augmentation size */
|
||||
#endif
|
||||
/* DW_CFA_xxx CFI instructions go here. */
|
||||
|
||||
.byte 0x4 /* DW_CFA_advance_loc4 */
|
||||
.long .LCFI9-.LFB5
|
||||
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
|
||||
.byte 0x8 /* .uleb128 0x8 */
|
||||
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
|
||||
.byte 0x2 /* .uleb128 0x2 */
|
||||
|
||||
.byte 0x4 /* DW_CFA_advance_loc4 */
|
||||
.long .LCFI10-.LCFI9
|
||||
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
|
||||
.byte 0x5 /* .uleb128 0x5 */
|
||||
|
||||
/* End of DW_CFA_xxx CFI instructions. */
|
||||
.align 4
|
||||
.LEFDE5:
|
||||
@@ -1,736 +0,0 @@
|
||||
# 1 "gcc\\win32_asm.asm"
|
||||
# 1 "<command-line>"
|
||||
# 1 "gcc\\win32_asm.asm"
|
||||
# 33 "gcc\\win32_asm.asm"
|
||||
# 1 "common/fficonfig.h" 1
|
||||
# 34 "gcc\\win32_asm.asm" 2
|
||||
# 1 "common/ffi.h" 1
|
||||
# 63 "common/ffi.h"
|
||||
# 1 "common/ffitarget.h" 1
|
||||
# 64 "common/ffi.h" 2
|
||||
# 35 "gcc\\win32_asm.asm" 2
|
||||
|
||||
|
||||
.text
|
||||
|
||||
|
||||
.balign 16
|
||||
.globl _ffi_call_win32
|
||||
|
||||
.def _ffi_call_win32; .scl 2; .type 32; .endef
|
||||
|
||||
_ffi_call_win32:
|
||||
.LFB1:
|
||||
pushl %ebp
|
||||
.LCFI0:
|
||||
movl %esp,%ebp
|
||||
.LCFI1:
|
||||
|
||||
movl 20(%ebp),%ecx
|
||||
subl %ecx,%esp
|
||||
|
||||
movl %esp,%eax
|
||||
|
||||
|
||||
pushl 12(%ebp)
|
||||
pushl %eax
|
||||
call *8(%ebp)
|
||||
|
||||
|
||||
addl $8,%esp
|
||||
|
||||
|
||||
cmpl $3, 16(%ebp)
|
||||
jz .do_thiscall
|
||||
cmpl $4, 16(%ebp)
|
||||
jnz .do_fncall
|
||||
movl (%esp), %ecx
|
||||
movl 4(%esp), %edx
|
||||
addl $8, %esp
|
||||
jmp .do_fncall
|
||||
.do_thiscall:
|
||||
movl (%esp), %ecx
|
||||
addl $4, %esp
|
||||
|
||||
.do_fncall:
|
||||
|
||||
|
||||
|
||||
|
||||
call *32(%ebp)
|
||||
|
||||
|
||||
|
||||
|
||||
movl 24(%ebp),%ecx
|
||||
|
||||
|
||||
cmpl $0,28(%ebp)
|
||||
jne 0f
|
||||
|
||||
|
||||
|
||||
cmpl $2,%ecx
|
||||
jne .Lnoretval
|
||||
fstp %st(0)
|
||||
|
||||
jmp .Lepilogue
|
||||
|
||||
0:
|
||||
call 1f
|
||||
|
||||
.Lstore_table:
|
||||
.long .Lnoretval
|
||||
.long .Lretint
|
||||
.long .Lretfloat
|
||||
.long .Lretdouble
|
||||
.long .Lretlongdouble
|
||||
.long .Lretuint8
|
||||
.long .Lretsint8
|
||||
.long .Lretuint16
|
||||
.long .Lretsint16
|
||||
.long .Lretint
|
||||
.long .Lretint
|
||||
.long .Lretint64
|
||||
.long .Lretint64
|
||||
.long .Lretstruct
|
||||
.long .Lretint
|
||||
.long .Lretstruct1b
|
||||
.long .Lretstruct2b
|
||||
.long .Lretstruct4b
|
||||
.long .Lretstruct
|
||||
1:
|
||||
add %ecx, %ecx
|
||||
add %ecx, %ecx
|
||||
add (%esp),%ecx
|
||||
add $4, %esp
|
||||
jmp *(%ecx)
|
||||
|
||||
|
||||
.Lretsint8:
|
||||
movsbl %al, %eax
|
||||
jmp .Lretint
|
||||
|
||||
.Lretsint16:
|
||||
movswl %ax, %eax
|
||||
jmp .Lretint
|
||||
|
||||
.Lretuint8:
|
||||
movzbl %al, %eax
|
||||
jmp .Lretint
|
||||
|
||||
.Lretuint16:
|
||||
movzwl %ax, %eax
|
||||
jmp .Lretint
|
||||
|
||||
.Lretint:
|
||||
|
||||
movl 28(%ebp),%ecx
|
||||
movl %eax,0(%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretfloat:
|
||||
|
||||
movl 28(%ebp),%ecx
|
||||
fstps (%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretdouble:
|
||||
|
||||
movl 28(%ebp),%ecx
|
||||
fstpl (%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretlongdouble:
|
||||
|
||||
movl 28(%ebp),%ecx
|
||||
fstpt (%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretint64:
|
||||
|
||||
movl 28(%ebp),%ecx
|
||||
movl %eax,0(%ecx)
|
||||
movl %edx,4(%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretstruct1b:
|
||||
|
||||
movl 28(%ebp),%ecx
|
||||
movb %al,0(%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretstruct2b:
|
||||
|
||||
movl 28(%ebp),%ecx
|
||||
movw %ax,0(%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretstruct4b:
|
||||
|
||||
movl 28(%ebp),%ecx
|
||||
movl %eax,0(%ecx)
|
||||
jmp .Lepilogue
|
||||
|
||||
.Lretstruct:
|
||||
|
||||
|
||||
.Lnoretval:
|
||||
.Lepilogue:
|
||||
movl %ebp,%esp
|
||||
popl %ebp
|
||||
ret
|
||||
.ffi_call_win32_end:
|
||||
.balign 16
|
||||
.globl _ffi_closure_THISCALL
|
||||
|
||||
.def _ffi_closure_THISCALL; .scl 2; .type 32; .endef
|
||||
|
||||
_ffi_closure_THISCALL:
|
||||
pushl %ebp
|
||||
movl %esp, %ebp
|
||||
subl $40, %esp
|
||||
leal -24(%ebp), %edx
|
||||
movl %edx, -12(%ebp)
|
||||
leal 12(%ebp), %edx
|
||||
jmp .stub
|
||||
.LFE1:
|
||||
|
||||
|
||||
.balign 16
|
||||
.globl _ffi_closure_SYSV
|
||||
|
||||
.def _ffi_closure_SYSV; .scl 2; .type 32; .endef
|
||||
|
||||
_ffi_closure_SYSV:
|
||||
.LFB3:
|
||||
pushl %ebp
|
||||
.LCFI4:
|
||||
movl %esp, %ebp
|
||||
.LCFI5:
|
||||
subl $40, %esp
|
||||
leal -24(%ebp), %edx
|
||||
movl %edx, -12(%ebp)
|
||||
leal 8(%ebp), %edx
|
||||
.stub:
|
||||
movl %edx, 4(%esp)
|
||||
leal -12(%ebp), %edx
|
||||
movl %edx, (%esp)
|
||||
call _ffi_closure_SYSV_inner
|
||||
movl -12(%ebp), %ecx
|
||||
|
||||
0:
|
||||
call 1f
|
||||
|
||||
.Lcls_store_table:
|
||||
.long .Lcls_noretval
|
||||
.long .Lcls_retint
|
||||
.long .Lcls_retfloat
|
||||
.long .Lcls_retdouble
|
||||
.long .Lcls_retldouble
|
||||
.long .Lcls_retuint8
|
||||
.long .Lcls_retsint8
|
||||
.long .Lcls_retuint16
|
||||
.long .Lcls_retsint16
|
||||
.long .Lcls_retint
|
||||
.long .Lcls_retint
|
||||
.long .Lcls_retllong
|
||||
.long .Lcls_retllong
|
||||
.long .Lcls_retstruct
|
||||
.long .Lcls_retint
|
||||
.long .Lcls_retstruct1
|
||||
.long .Lcls_retstruct2
|
||||
.long .Lcls_retstruct4
|
||||
.long .Lcls_retmsstruct
|
||||
|
||||
1:
|
||||
add %eax, %eax
|
||||
add %eax, %eax
|
||||
add (%esp),%eax
|
||||
add $4, %esp
|
||||
jmp *(%eax)
|
||||
|
||||
|
||||
.Lcls_retsint8:
|
||||
movsbl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retsint16:
|
||||
movswl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retuint8:
|
||||
movzbl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retuint16:
|
||||
movzwl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retint:
|
||||
movl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retfloat:
|
||||
flds (%ecx)
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retdouble:
|
||||
fldl (%ecx)
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retldouble:
|
||||
fldt (%ecx)
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retllong:
|
||||
movl (%ecx), %eax
|
||||
movl 4(%ecx), %edx
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retstruct1:
|
||||
movsbl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retstruct2:
|
||||
movswl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retstruct4:
|
||||
movl (%ecx), %eax
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_retstruct:
|
||||
|
||||
movl %ebp, %esp
|
||||
popl %ebp
|
||||
ret $0x4
|
||||
|
||||
.Lcls_retmsstruct:
|
||||
|
||||
mov %ecx, %eax
|
||||
|
||||
jmp .Lcls_epilogue
|
||||
|
||||
.Lcls_noretval:
|
||||
.Lcls_epilogue:
|
||||
movl %ebp, %esp
|
||||
popl %ebp
|
||||
ret
|
||||
.ffi_closure_SYSV_end:
|
||||
.LFE3:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.balign 16
|
||||
.globl _ffi_closure_raw_THISCALL
|
||||
|
||||
.def _ffi_closure_raw_THISCALL; .scl 2; .type 32; .endef
|
||||
|
||||
_ffi_closure_raw_THISCALL:
|
||||
pushl %ebp
|
||||
movl %esp, %ebp
|
||||
pushl %esi
|
||||
subl $36, %esp
|
||||
movl ((52 + 3) & ~3)(%eax), %esi
|
||||
movl ((((52 + 3) & ~3) + 4) + 4)(%eax), %edx
|
||||
movl %edx, 12(%esp)
|
||||
leal 12(%ebp), %edx
|
||||
jmp .stubraw
|
||||
|
||||
.balign 16
|
||||
.globl _ffi_closure_raw_SYSV
|
||||
|
||||
.def _ffi_closure_raw_SYSV; .scl 2; .type 32; .endef
|
||||
|
||||
_ffi_closure_raw_SYSV:
|
||||
.LFB4:
|
||||
pushl %ebp
|
||||
.LCFI6:
|
||||
movl %esp, %ebp
|
||||
.LCFI7:
|
||||
pushl %esi
|
||||
.LCFI8:
|
||||
subl $36, %esp
|
||||
movl ((52 + 3) & ~3)(%eax), %esi
|
||||
movl ((((52 + 3) & ~3) + 4) + 4)(%eax), %edx
|
||||
movl %edx, 12(%esp)
|
||||
leal 8(%ebp), %edx
|
||||
.stubraw:
|
||||
movl %edx, 8(%esp)
|
||||
leal -24(%ebp), %edx
|
||||
movl %edx, 4(%esp)
|
||||
movl %esi, (%esp)
|
||||
call *(((52 + 3) & ~3) + 4)(%eax)
|
||||
movl 20(%esi), %eax
|
||||
0:
|
||||
call 1f
|
||||
|
||||
.Lrcls_store_table:
|
||||
.long .Lrcls_noretval
|
||||
.long .Lrcls_retint
|
||||
.long .Lrcls_retfloat
|
||||
.long .Lrcls_retdouble
|
||||
.long .Lrcls_retldouble
|
||||
.long .Lrcls_retuint8
|
||||
.long .Lrcls_retsint8
|
||||
.long .Lrcls_retuint16
|
||||
.long .Lrcls_retsint16
|
||||
.long .Lrcls_retint
|
||||
.long .Lrcls_retint
|
||||
.long .Lrcls_retllong
|
||||
.long .Lrcls_retllong
|
||||
.long .Lrcls_retstruct
|
||||
.long .Lrcls_retint
|
||||
.long .Lrcls_retstruct1
|
||||
.long .Lrcls_retstruct2
|
||||
.long .Lrcls_retstruct4
|
||||
.long .Lrcls_retstruct
|
||||
1:
|
||||
add %eax, %eax
|
||||
add %eax, %eax
|
||||
add (%esp),%eax
|
||||
add $4, %esp
|
||||
jmp *(%eax)
|
||||
|
||||
|
||||
.Lrcls_retsint8:
|
||||
movsbl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retsint16:
|
||||
movswl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retuint8:
|
||||
movzbl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retuint16:
|
||||
movzwl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retint:
|
||||
movl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retfloat:
|
||||
flds -24(%ebp)
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retdouble:
|
||||
fldl -24(%ebp)
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retldouble:
|
||||
fldt -24(%ebp)
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retllong:
|
||||
movl -24(%ebp), %eax
|
||||
movl -20(%ebp), %edx
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retstruct1:
|
||||
movsbl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retstruct2:
|
||||
movswl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retstruct4:
|
||||
movl -24(%ebp), %eax
|
||||
jmp .Lrcls_epilogue
|
||||
|
||||
.Lrcls_retstruct:
|
||||
|
||||
|
||||
.Lrcls_noretval:
|
||||
.Lrcls_epilogue:
|
||||
addl $36, %esp
|
||||
popl %esi
|
||||
popl %ebp
|
||||
ret
|
||||
.ffi_closure_raw_SYSV_end:
|
||||
.LFE4:
|
||||
|
||||
|
||||
|
||||
|
||||
.balign 16
|
||||
.globl _ffi_closure_STDCALL
|
||||
|
||||
.def _ffi_closure_STDCALL; .scl 2; .type 32; .endef
|
||||
|
||||
_ffi_closure_STDCALL:
|
||||
.LFB5:
|
||||
pushl %ebp
|
||||
.LCFI9:
|
||||
movl %esp, %ebp
|
||||
.LCFI10:
|
||||
subl $40, %esp
|
||||
leal -24(%ebp), %edx
|
||||
movl %edx, -12(%ebp)
|
||||
leal 12(%ebp), %edx
|
||||
movl %edx, 4(%esp)
|
||||
leal -12(%ebp), %edx
|
||||
movl %edx, (%esp)
|
||||
call _ffi_closure_SYSV_inner
|
||||
movl -12(%ebp), %ecx
|
||||
0:
|
||||
call 1f
|
||||
|
||||
.Lscls_store_table:
|
||||
.long .Lscls_noretval
|
||||
.long .Lscls_retint
|
||||
.long .Lscls_retfloat
|
||||
.long .Lscls_retdouble
|
||||
.long .Lscls_retldouble
|
||||
.long .Lscls_retuint8
|
||||
.long .Lscls_retsint8
|
||||
.long .Lscls_retuint16
|
||||
.long .Lscls_retsint16
|
||||
.long .Lscls_retint
|
||||
.long .Lscls_retint
|
||||
.long .Lscls_retllong
|
||||
.long .Lscls_retllong
|
||||
.long .Lscls_retstruct
|
||||
.long .Lscls_retint
|
||||
.long .Lscls_retstruct1
|
||||
.long .Lscls_retstruct2
|
||||
.long .Lscls_retstruct4
|
||||
1:
|
||||
add %eax, %eax
|
||||
add %eax, %eax
|
||||
add (%esp),%eax
|
||||
add $4, %esp
|
||||
jmp *(%eax)
|
||||
|
||||
|
||||
.Lscls_retsint8:
|
||||
movsbl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retsint16:
|
||||
movswl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retuint8:
|
||||
movzbl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retuint16:
|
||||
movzwl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retint:
|
||||
movl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retfloat:
|
||||
flds (%ecx)
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retdouble:
|
||||
fldl (%ecx)
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retldouble:
|
||||
fldt (%ecx)
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retllong:
|
||||
movl (%ecx), %eax
|
||||
movl 4(%ecx), %edx
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retstruct1:
|
||||
movsbl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retstruct2:
|
||||
movswl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retstruct4:
|
||||
movl (%ecx), %eax
|
||||
jmp .Lscls_epilogue
|
||||
|
||||
.Lscls_retstruct:
|
||||
|
||||
|
||||
.Lscls_noretval:
|
||||
.Lscls_epilogue:
|
||||
movl %ebp, %esp
|
||||
popl %ebp
|
||||
ret
|
||||
.ffi_closure_STDCALL_end:
|
||||
.LFE5:
|
||||
|
||||
|
||||
.section .eh_frame,"w"
|
||||
|
||||
.Lframe1:
|
||||
.LSCIE1:
|
||||
.long .LECIE1-.LASCIE1
|
||||
.LASCIE1:
|
||||
.long 0x0
|
||||
.byte 0x1
|
||||
|
||||
|
||||
|
||||
.ascii "\0"
|
||||
|
||||
.byte 0x1
|
||||
.byte 0x7c
|
||||
.byte 0x8
|
||||
|
||||
|
||||
|
||||
|
||||
.byte 0xc
|
||||
.byte 0x4
|
||||
.byte 0x4
|
||||
.byte 0x88
|
||||
.byte 0x1
|
||||
.align 4
|
||||
.LECIE1:
|
||||
|
||||
.LSFDE1:
|
||||
.long .LEFDE1-.LASFDE1
|
||||
.LASFDE1:
|
||||
.long .LASFDE1-.Lframe1
|
||||
|
||||
|
||||
|
||||
.long .LFB1
|
||||
|
||||
.long .LFE1-.LFB1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.byte 0x4
|
||||
.long .LCFI0-.LFB1
|
||||
.byte 0xe
|
||||
.byte 0x8
|
||||
.byte 0x85
|
||||
.byte 0x2
|
||||
|
||||
.byte 0x4
|
||||
.long .LCFI1-.LCFI0
|
||||
.byte 0xd
|
||||
.byte 0x5
|
||||
|
||||
|
||||
.align 4
|
||||
.LEFDE1:
|
||||
|
||||
|
||||
.LSFDE3:
|
||||
.long .LEFDE3-.LASFDE3
|
||||
.LASFDE3:
|
||||
.long .LASFDE3-.Lframe1
|
||||
|
||||
|
||||
|
||||
.long .LFB3
|
||||
|
||||
.long .LFE3-.LFB3
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.byte 0x4
|
||||
.long .LCFI4-.LFB3
|
||||
.byte 0xe
|
||||
.byte 0x8
|
||||
.byte 0x85
|
||||
.byte 0x2
|
||||
|
||||
.byte 0x4
|
||||
.long .LCFI5-.LCFI4
|
||||
.byte 0xd
|
||||
.byte 0x5
|
||||
|
||||
|
||||
.align 4
|
||||
.LEFDE3:
|
||||
|
||||
|
||||
|
||||
.LSFDE4:
|
||||
.long .LEFDE4-.LASFDE4
|
||||
.LASFDE4:
|
||||
.long .LASFDE4-.Lframe1
|
||||
|
||||
|
||||
|
||||
.long .LFB4
|
||||
|
||||
.long .LFE4-.LFB4
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.byte 0x4
|
||||
.long .LCFI6-.LFB4
|
||||
.byte 0xe
|
||||
.byte 0x8
|
||||
.byte 0x85
|
||||
.byte 0x2
|
||||
|
||||
.byte 0x4
|
||||
.long .LCFI7-.LCFI6
|
||||
.byte 0xd
|
||||
.byte 0x5
|
||||
|
||||
.byte 0x4
|
||||
.long .LCFI8-.LCFI7
|
||||
.byte 0x86
|
||||
.byte 0x3
|
||||
|
||||
|
||||
.align 4
|
||||
.LEFDE4:
|
||||
|
||||
|
||||
|
||||
.LSFDE5:
|
||||
.long .LEFDE5-.LASFDE5
|
||||
.LASFDE5:
|
||||
.long .LASFDE5-.Lframe1
|
||||
|
||||
|
||||
|
||||
.long .LFB5
|
||||
|
||||
.long .LFE5-.LFB5
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.byte 0x4
|
||||
.long .LCFI9-.LFB5
|
||||
.byte 0xe
|
||||
.byte 0x8
|
||||
.byte 0x85
|
||||
.byte 0x2
|
||||
|
||||
.byte 0x4
|
||||
.long .LCFI10-.LCFI9
|
||||
.byte 0xd
|
||||
.byte 0x5
|
||||
|
||||
|
||||
.align 4
|
||||
.LEFDE5:
|
||||
@@ -1,467 +0,0 @@
|
||||
#define LIBFFI_ASM
|
||||
#include <fficonfig.h>
|
||||
#include <ffi.h>
|
||||
|
||||
/* Constants for ffi_call_win64 */
|
||||
#define STACK 0
|
||||
#define PREP_ARGS_FN 32
|
||||
#define ECIF 40
|
||||
#define CIF_BYTES 48
|
||||
#define CIF_FLAGS 56
|
||||
#define RVALUE 64
|
||||
#define FN 72
|
||||
|
||||
/* ffi_call_win64 (void (*prep_args_fn)(char *, extended_cif *),
|
||||
extended_cif *ecif, unsigned bytes, unsigned flags,
|
||||
unsigned *rvalue, void (*fn)());
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
PUBLIC ffi_call_win64
|
||||
|
||||
EXTRN __chkstk:NEAR
|
||||
EXTRN ffi_closure_win64_inner:NEAR
|
||||
|
||||
_TEXT SEGMENT
|
||||
|
||||
;;; ffi_closure_win64 will be called with these registers set:
|
||||
;;; rax points to 'closure'
|
||||
;;; r11 contains a bit mask that specifies which of the
|
||||
;;; first four parameters are float or double
|
||||
;;;
|
||||
;;; It must move the parameters passed in registers to their stack location,
|
||||
;;; call ffi_closure_win64_inner for the actual work, then return the result.
|
||||
;;;
|
||||
ffi_closure_win64 PROC FRAME
|
||||
;; copy register arguments onto stack
|
||||
test r11, 1
|
||||
jne first_is_float
|
||||
mov QWORD PTR [rsp+8], rcx
|
||||
jmp second
|
||||
first_is_float:
|
||||
movlpd QWORD PTR [rsp+8], xmm0
|
||||
|
||||
second:
|
||||
test r11, 2
|
||||
jne second_is_float
|
||||
mov QWORD PTR [rsp+16], rdx
|
||||
jmp third
|
||||
second_is_float:
|
||||
movlpd QWORD PTR [rsp+16], xmm1
|
||||
|
||||
third:
|
||||
test r11, 4
|
||||
jne third_is_float
|
||||
mov QWORD PTR [rsp+24], r8
|
||||
jmp fourth
|
||||
third_is_float:
|
||||
movlpd QWORD PTR [rsp+24], xmm2
|
||||
|
||||
fourth:
|
||||
test r11, 8
|
||||
jne fourth_is_float
|
||||
mov QWORD PTR [rsp+32], r9
|
||||
jmp done
|
||||
fourth_is_float:
|
||||
movlpd QWORD PTR [rsp+32], xmm3
|
||||
|
||||
done:
|
||||
.ALLOCSTACK 40
|
||||
sub rsp, 40
|
||||
.ENDPROLOG
|
||||
mov rcx, rax ; context is first parameter
|
||||
mov rdx, rsp ; stack is second parameter
|
||||
add rdx, 48 ; point to start of arguments
|
||||
mov rax, ffi_closure_win64_inner
|
||||
call rax ; call the real closure function
|
||||
add rsp, 40
|
||||
movd xmm0, rax ; If the closure returned a float,
|
||||
; ffi_closure_win64_inner wrote it to rax
|
||||
ret 0
|
||||
ffi_closure_win64 ENDP
|
||||
|
||||
ffi_call_win64 PROC FRAME
|
||||
;; copy registers onto stack
|
||||
mov QWORD PTR [rsp+32], r9
|
||||
mov QWORD PTR [rsp+24], r8
|
||||
mov QWORD PTR [rsp+16], rdx
|
||||
mov QWORD PTR [rsp+8], rcx
|
||||
.PUSHREG rbp
|
||||
push rbp
|
||||
.ALLOCSTACK 48
|
||||
sub rsp, 48 ; 00000030H
|
||||
.SETFRAME rbp, 32
|
||||
lea rbp, QWORD PTR [rsp+32]
|
||||
.ENDPROLOG
|
||||
|
||||
mov eax, DWORD PTR CIF_BYTES[rbp]
|
||||
add rax, 15
|
||||
and rax, -16
|
||||
call __chkstk
|
||||
sub rsp, rax
|
||||
lea rax, QWORD PTR [rsp+32]
|
||||
mov QWORD PTR STACK[rbp], rax
|
||||
|
||||
mov rdx, QWORD PTR ECIF[rbp]
|
||||
mov rcx, QWORD PTR STACK[rbp]
|
||||
call QWORD PTR PREP_ARGS_FN[rbp]
|
||||
|
||||
mov rsp, QWORD PTR STACK[rbp]
|
||||
|
||||
movlpd xmm3, QWORD PTR [rsp+24]
|
||||
movd r9, xmm3
|
||||
|
||||
movlpd xmm2, QWORD PTR [rsp+16]
|
||||
movd r8, xmm2
|
||||
|
||||
movlpd xmm1, QWORD PTR [rsp+8]
|
||||
movd rdx, xmm1
|
||||
|
||||
movlpd xmm0, QWORD PTR [rsp]
|
||||
movd rcx, xmm0
|
||||
|
||||
call QWORD PTR FN[rbp]
|
||||
ret_struct4b$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_4B
|
||||
jne ret_struct2b$
|
||||
|
||||
mov rcx, QWORD PTR RVALUE[rbp]
|
||||
mov DWORD PTR [rcx], eax
|
||||
jmp ret_void$
|
||||
|
||||
ret_struct2b$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_2B
|
||||
jne ret_struct1b$
|
||||
|
||||
mov rcx, QWORD PTR RVALUE[rbp]
|
||||
mov WORD PTR [rcx], ax
|
||||
jmp ret_void$
|
||||
|
||||
ret_struct1b$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_1B
|
||||
jne ret_uint8$
|
||||
|
||||
mov rcx, QWORD PTR RVALUE[rbp]
|
||||
mov BYTE PTR [rcx], al
|
||||
jmp ret_void$
|
||||
|
||||
ret_uint8$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT8
|
||||
jne ret_sint8$
|
||||
|
||||
mov rcx, QWORD PTR RVALUE[rbp]
|
||||
movzx rax, al
|
||||
mov QWORD PTR [rcx], rax
|
||||
jmp ret_void$
|
||||
|
||||
ret_sint8$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT8
|
||||
jne ret_uint16$
|
||||
|
||||
mov rcx, QWORD PTR RVALUE[rbp]
|
||||
movsx rax, al
|
||||
mov QWORD PTR [rcx], rax
|
||||
jmp ret_void$
|
||||
|
||||
ret_uint16$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT16
|
||||
jne ret_sint16$
|
||||
|
||||
mov rcx, QWORD PTR RVALUE[rbp]
|
||||
movzx rax, ax
|
||||
mov QWORD PTR [rcx], rax
|
||||
jmp SHORT ret_void$
|
||||
|
||||
ret_sint16$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT16
|
||||
jne ret_uint32$
|
||||
|
||||
mov rcx, QWORD PTR RVALUE[rbp]
|
||||
movsx rax, ax
|
||||
mov QWORD PTR [rcx], rax
|
||||
jmp SHORT ret_void$
|
||||
|
||||
ret_uint32$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT32
|
||||
jne ret_sint32$
|
||||
|
||||
mov rcx, QWORD PTR RVALUE[rbp]
|
||||
mov eax, eax
|
||||
mov QWORD PTR [rcx], rax
|
||||
jmp SHORT ret_void$
|
||||
|
||||
ret_sint32$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT32
|
||||
jne ret_float$
|
||||
|
||||
mov rcx, QWORD PTR RVALUE[rbp]
|
||||
cdqe
|
||||
mov QWORD PTR [rcx], rax
|
||||
jmp SHORT ret_void$
|
||||
|
||||
ret_float$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_FLOAT
|
||||
jne SHORT ret_double$
|
||||
|
||||
mov rax, QWORD PTR RVALUE[rbp]
|
||||
movss DWORD PTR [rax], xmm0
|
||||
jmp SHORT ret_void$
|
||||
|
||||
ret_double$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_DOUBLE
|
||||
jne SHORT ret_sint64$
|
||||
|
||||
mov rax, QWORD PTR RVALUE[rbp]
|
||||
movlpd QWORD PTR [rax], xmm0
|
||||
jmp SHORT ret_void$
|
||||
|
||||
ret_sint64$:
|
||||
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT64
|
||||
jne ret_void$
|
||||
|
||||
mov rcx, QWORD PTR RVALUE[rbp]
|
||||
mov QWORD PTR [rcx], rax
|
||||
jmp SHORT ret_void$
|
||||
|
||||
ret_void$:
|
||||
xor rax, rax
|
||||
|
||||
lea rsp, QWORD PTR [rbp+16]
|
||||
pop rbp
|
||||
ret 0
|
||||
ffi_call_win64 ENDP
|
||||
_TEXT ENDS
|
||||
END
|
||||
|
||||
#else
|
||||
|
||||
#ifdef SYMBOL_UNDERSCORE
|
||||
#define SYMBOL_NAME(name) _##name
|
||||
#else
|
||||
#define SYMBOL_NAME(name) name
|
||||
#endif
|
||||
|
||||
.text
|
||||
|
||||
.extern SYMBOL_NAME(ffi_closure_win64_inner)
|
||||
|
||||
// ffi_closure_win64 will be called with these registers set:
|
||||
// rax points to 'closure'
|
||||
// r11 contains a bit mask that specifies which of the
|
||||
// first four parameters are float or double
|
||||
// // It must move the parameters passed in registers to their stack location,
|
||||
// call ffi_closure_win64_inner for the actual work, then return the result.
|
||||
//
|
||||
.balign 16
|
||||
.globl SYMBOL_NAME(ffi_closure_win64)
|
||||
SYMBOL_NAME(ffi_closure_win64):
|
||||
// copy register arguments onto stack
|
||||
test $1,%r11
|
||||
jne .Lfirst_is_float
|
||||
mov %rcx, 8(%rsp)
|
||||
jmp .Lsecond
|
||||
.Lfirst_is_float:
|
||||
movlpd %xmm0, 8(%rsp)
|
||||
|
||||
.Lsecond:
|
||||
test $2, %r11
|
||||
jne .Lsecond_is_float
|
||||
mov %rdx, 16(%rsp)
|
||||
jmp .Lthird
|
||||
.Lsecond_is_float:
|
||||
movlpd %xmm1, 16(%rsp)
|
||||
|
||||
.Lthird:
|
||||
test $4, %r11
|
||||
jne .Lthird_is_float
|
||||
mov %r8,24(%rsp)
|
||||
jmp .Lfourth
|
||||
.Lthird_is_float:
|
||||
movlpd %xmm2, 24(%rsp)
|
||||
|
||||
.Lfourth:
|
||||
test $8, %r11
|
||||
jne .Lfourth_is_float
|
||||
mov %r9, 32(%rsp)
|
||||
jmp .Ldone
|
||||
.Lfourth_is_float:
|
||||
movlpd %xmm3, 32(%rsp)
|
||||
|
||||
.Ldone:
|
||||
// ALLOCSTACK 40
|
||||
sub $40, %rsp
|
||||
// ENDPROLOG
|
||||
mov %rax, %rcx // context is first parameter
|
||||
mov %rsp, %rdx // stack is second parameter
|
||||
add $48, %rdx // point to start of arguments
|
||||
mov $SYMBOL_NAME(ffi_closure_win64_inner), %rax
|
||||
callq *%rax // call the real closure function
|
||||
add $40, %rsp
|
||||
movq %rax, %xmm0 // If the closure returned a float,
|
||||
// ffi_closure_win64_inner wrote it to rax
|
||||
retq
|
||||
.ffi_closure_win64_end:
|
||||
|
||||
.balign 16
|
||||
.globl SYMBOL_NAME(ffi_call_win64)
|
||||
SYMBOL_NAME(ffi_call_win64):
|
||||
// copy registers onto stack
|
||||
mov %r9,32(%rsp)
|
||||
mov %r8,24(%rsp)
|
||||
mov %rdx,16(%rsp)
|
||||
mov %rcx,8(%rsp)
|
||||
// PUSHREG rbp
|
||||
push %rbp
|
||||
// ALLOCSTACK 48
|
||||
sub $48,%rsp
|
||||
// SETFRAME rbp, 32
|
||||
lea 32(%rsp),%rbp
|
||||
// ENDPROLOG
|
||||
|
||||
mov CIF_BYTES(%rbp),%eax
|
||||
add $15, %rax
|
||||
and $-16, %rax
|
||||
cmpq $0x1000, %rax
|
||||
jb Lch_done
|
||||
Lch_probe:
|
||||
subq $0x1000,%rsp
|
||||
orl $0x0, (%rsp)
|
||||
subq $0x1000,%rax
|
||||
cmpq $0x1000,%rax
|
||||
ja Lch_probe
|
||||
Lch_done:
|
||||
subq %rax, %rsp
|
||||
orl $0x0, (%rsp)
|
||||
lea 32(%rsp), %rax
|
||||
mov %rax, STACK(%rbp)
|
||||
|
||||
mov ECIF(%rbp), %rdx
|
||||
mov STACK(%rbp), %rcx
|
||||
callq *PREP_ARGS_FN(%rbp)
|
||||
|
||||
mov STACK(%rbp), %rsp
|
||||
|
||||
movlpd 24(%rsp), %xmm3
|
||||
movd %xmm3, %r9
|
||||
|
||||
movlpd 16(%rsp), %xmm2
|
||||
movd %xmm2, %r8
|
||||
|
||||
movlpd 8(%rsp), %xmm1
|
||||
movd %xmm1, %rdx
|
||||
|
||||
movlpd (%rsp), %xmm0
|
||||
movd %xmm0, %rcx
|
||||
|
||||
callq *FN(%rbp)
|
||||
.Lret_struct4b:
|
||||
cmpl $FFI_TYPE_SMALL_STRUCT_4B, CIF_FLAGS(%rbp)
|
||||
jne .Lret_struct2b
|
||||
|
||||
mov RVALUE(%rbp), %rcx
|
||||
mov %eax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_struct2b:
|
||||
cmpl $FFI_TYPE_SMALL_STRUCT_2B, CIF_FLAGS(%rbp)
|
||||
jne .Lret_struct1b
|
||||
|
||||
mov RVALUE(%rbp), %rcx
|
||||
mov %ax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_struct1b:
|
||||
cmpl $FFI_TYPE_SMALL_STRUCT_1B, CIF_FLAGS(%rbp)
|
||||
jne .Lret_uint8
|
||||
|
||||
mov RVALUE(%rbp), %rcx
|
||||
mov %al, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_uint8:
|
||||
cmpl $FFI_TYPE_UINT8, CIF_FLAGS(%rbp)
|
||||
jne .Lret_sint8
|
||||
|
||||
mov RVALUE(%rbp), %rcx
|
||||
movzbq %al, %rax
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_sint8:
|
||||
cmpl $FFI_TYPE_SINT8, CIF_FLAGS(%rbp)
|
||||
jne .Lret_uint16
|
||||
|
||||
mov RVALUE(%rbp), %rcx
|
||||
movsbq %al, %rax
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_uint16:
|
||||
cmpl $FFI_TYPE_UINT16, CIF_FLAGS(%rbp)
|
||||
jne .Lret_sint16
|
||||
|
||||
mov RVALUE(%rbp), %rcx
|
||||
movzwq %ax, %rax
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_sint16:
|
||||
cmpl $FFI_TYPE_SINT16, CIF_FLAGS(%rbp)
|
||||
jne .Lret_uint32
|
||||
|
||||
mov RVALUE(%rbp), %rcx
|
||||
movswq %ax, %rax
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_uint32:
|
||||
cmpl $FFI_TYPE_UINT32, CIF_FLAGS(%rbp)
|
||||
jne .Lret_sint32
|
||||
|
||||
mov RVALUE(%rbp), %rcx
|
||||
movl %eax, %eax
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_sint32:
|
||||
cmpl $FFI_TYPE_SINT32, CIF_FLAGS(%rbp)
|
||||
jne .Lret_float
|
||||
|
||||
mov RVALUE(%rbp), %rcx
|
||||
cltq
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_float:
|
||||
cmpl $FFI_TYPE_FLOAT, CIF_FLAGS(%rbp)
|
||||
jne .Lret_double
|
||||
|
||||
mov RVALUE(%rbp), %rax
|
||||
movss %xmm0, (%rax)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_double:
|
||||
cmpl $FFI_TYPE_DOUBLE, CIF_FLAGS(%rbp)
|
||||
jne .Lret_sint64
|
||||
|
||||
mov RVALUE(%rbp), %rax
|
||||
movlpd %xmm0, (%rax)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_sint64:
|
||||
cmpl $FFI_TYPE_SINT64, CIF_FLAGS(%rbp)
|
||||
jne .Lret_void
|
||||
|
||||
mov RVALUE(%rbp), %rcx
|
||||
mov %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_void:
|
||||
xor %rax, %rax
|
||||
|
||||
lea 16(%rbp), %rsp
|
||||
pop %rbp
|
||||
retq
|
||||
.ffi_call_win64_end:
|
||||
#endif /* !_MSC_VER */
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
# 1 "gcc\\win64_asm.asm"
|
||||
# 1 "<command-line>"
|
||||
# 1 "gcc\\win64_asm.asm"
|
||||
|
||||
# 1 "common/fficonfig.h" 1
|
||||
# 3 "gcc\\win64_asm.asm" 2
|
||||
# 1 "common/ffi.h" 1
|
||||
# 63 "common/ffi.h"
|
||||
# 1 "common/ffitarget.h" 1
|
||||
# 64 "common/ffi.h" 2
|
||||
# 4 "gcc\\win64_asm.asm" 2
|
||||
# 244 "gcc\\win64_asm.asm"
|
||||
.text
|
||||
|
||||
.extern ffi_closure_win64_inner
|
||||
# 255 "gcc\\win64_asm.asm"
|
||||
.balign 16
|
||||
.globl ffi_closure_win64
|
||||
ffi_closure_win64:
|
||||
|
||||
test $1,%r11
|
||||
jne .Lfirst_is_float
|
||||
mov %rcx, 8(%rsp)
|
||||
jmp .Lsecond
|
||||
.Lfirst_is_float:
|
||||
movlpd %xmm0, 8(%rsp)
|
||||
|
||||
.Lsecond:
|
||||
test $2, %r11
|
||||
jne .Lsecond_is_float
|
||||
mov %rdx, 16(%rsp)
|
||||
jmp .Lthird
|
||||
.Lsecond_is_float:
|
||||
movlpd %xmm1, 16(%rsp)
|
||||
|
||||
.Lthird:
|
||||
test $4, %r11
|
||||
jne .Lthird_is_float
|
||||
mov %r8,24(%rsp)
|
||||
jmp .Lfourth
|
||||
.Lthird_is_float:
|
||||
movlpd %xmm2, 24(%rsp)
|
||||
|
||||
.Lfourth:
|
||||
test $8, %r11
|
||||
jne .Lfourth_is_float
|
||||
mov %r9, 32(%rsp)
|
||||
jmp .Ldone
|
||||
.Lfourth_is_float:
|
||||
movlpd %xmm3, 32(%rsp)
|
||||
|
||||
.Ldone:
|
||||
|
||||
sub $40, %rsp
|
||||
|
||||
mov %rax, %rcx
|
||||
mov %rsp, %rdx
|
||||
add $48, %rdx
|
||||
mov $SYMBOL_NAME(ffi_closure_win64_inner), %rax
|
||||
callq *%rax
|
||||
add $40, %rsp
|
||||
movq %rax, %xmm0
|
||||
|
||||
retq
|
||||
.ffi_closure_win64_end:
|
||||
|
||||
.balign 16
|
||||
.globl ffi_call_win64
|
||||
ffi_call_win64:
|
||||
|
||||
mov %r9,32(%rsp)
|
||||
mov %r8,24(%rsp)
|
||||
mov %rdx,16(%rsp)
|
||||
mov %rcx,8(%rsp)
|
||||
|
||||
push %rbp
|
||||
|
||||
sub $48,%rsp
|
||||
|
||||
lea 32(%rsp),%rbp
|
||||
|
||||
|
||||
mov 48(%rbp),%eax
|
||||
add $15, %rax
|
||||
and $-16, %rax
|
||||
cmpq $0x1000, %rax
|
||||
jb Lch_done
|
||||
Lch_probe:
|
||||
subq $0x1000,%rsp
|
||||
orl $0x0, (%rsp)
|
||||
subq $0x1000,%rax
|
||||
cmpq $0x1000,%rax
|
||||
ja Lch_probe
|
||||
Lch_done:
|
||||
subq %rax, %rsp
|
||||
orl $0x0, (%rsp)
|
||||
lea 32(%rsp), %rax
|
||||
mov %rax, 0(%rbp)
|
||||
|
||||
mov 40(%rbp), %rdx
|
||||
mov 0(%rbp), %rcx
|
||||
callq *32(%rbp)
|
||||
|
||||
mov 0(%rbp), %rsp
|
||||
|
||||
movlpd 24(%rsp), %xmm3
|
||||
movd %xmm3, %r9
|
||||
|
||||
movlpd 16(%rsp), %xmm2
|
||||
movd %xmm2, %r8
|
||||
|
||||
movlpd 8(%rsp), %xmm1
|
||||
movd %xmm1, %rdx
|
||||
|
||||
movlpd (%rsp), %xmm0
|
||||
movd %xmm0, %rcx
|
||||
|
||||
callq *72(%rbp)
|
||||
.Lret_struct4b:
|
||||
cmpl $FFI_TYPE_SMALL_STRUCT_4B, 56(%rbp)
|
||||
jne .Lret_struct2b
|
||||
|
||||
mov 64(%rbp), %rcx
|
||||
mov %eax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_struct2b:
|
||||
cmpl $FFI_TYPE_SMALL_STRUCT_2B, 56(%rbp)
|
||||
jne .Lret_struct1b
|
||||
|
||||
mov 64(%rbp), %rcx
|
||||
mov %ax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_struct1b:
|
||||
cmpl $FFI_TYPE_SMALL_STRUCT_1B, 56(%rbp)
|
||||
jne .Lret_uint8
|
||||
|
||||
mov 64(%rbp), %rcx
|
||||
mov %al, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_uint8:
|
||||
cmpl $FFI_TYPE_UINT8, 56(%rbp)
|
||||
jne .Lret_sint8
|
||||
|
||||
mov 64(%rbp), %rcx
|
||||
movzbq %al, %rax
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_sint8:
|
||||
cmpl $FFI_TYPE_SINT8, 56(%rbp)
|
||||
jne .Lret_uint16
|
||||
|
||||
mov 64(%rbp), %rcx
|
||||
movsbq %al, %rax
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_uint16:
|
||||
cmpl $FFI_TYPE_UINT16, 56(%rbp)
|
||||
jne .Lret_sint16
|
||||
|
||||
mov 64(%rbp), %rcx
|
||||
movzwq %ax, %rax
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_sint16:
|
||||
cmpl $FFI_TYPE_SINT16, 56(%rbp)
|
||||
jne .Lret_uint32
|
||||
|
||||
mov 64(%rbp), %rcx
|
||||
movswq %ax, %rax
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_uint32:
|
||||
cmpl $9, 56(%rbp)
|
||||
jne .Lret_sint32
|
||||
|
||||
mov 64(%rbp), %rcx
|
||||
movl %eax, %eax
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_sint32:
|
||||
cmpl $10, 56(%rbp)
|
||||
jne .Lret_float
|
||||
|
||||
mov 64(%rbp), %rcx
|
||||
cltq
|
||||
movq %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_float:
|
||||
cmpl $2, 56(%rbp)
|
||||
jne .Lret_double
|
||||
|
||||
mov 64(%rbp), %rax
|
||||
movss %xmm0, (%rax)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_double:
|
||||
cmpl $3, 56(%rbp)
|
||||
jne .Lret_sint64
|
||||
|
||||
mov 64(%rbp), %rax
|
||||
movlpd %xmm0, (%rax)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_sint64:
|
||||
cmpl $12, 56(%rbp)
|
||||
jne .Lret_void
|
||||
|
||||
mov 64(%rbp), %rcx
|
||||
mov %rax, (%rcx)
|
||||
jmp .Lret_void
|
||||
|
||||
.Lret_void:
|
||||
xor %rax, %rax
|
||||
|
||||
lea 16(%rbp), %rsp
|
||||
pop %rbp
|
||||
retq
|
||||
.ffi_call_win64_end:
|
||||
@@ -1,176 +0,0 @@
|
||||
# -----------------------------------------------------------------*-C-*-
|
||||
# libffi 3.0.10 - Copyright (c) 2011 Anthony Green
|
||||
# - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation
|
||||
# files (the ``Software''), to deal in the Software without
|
||||
# restriction, including without limitation the rights to use, copy,
|
||||
# modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
# of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
when defined(windows):
|
||||
# on Windows we don't use a DLL but instead embed libffi directly:
|
||||
{.pragma: mylib, header: r"ffi.h".}
|
||||
|
||||
#{.compile: r"common\malloc_closure.c".}
|
||||
{.compile: r"common\raw_api.c".}
|
||||
when defined(vcc):
|
||||
{.compile: r"msvc\ffi.c".}
|
||||
{.compile: r"msvc\prep_cif.c".}
|
||||
{.compile: r"msvc\win32.c".}
|
||||
{.compile: r"msvc\types.c".}
|
||||
when defined(cpu64):
|
||||
{.compile: r"msvc\win64_asm.asm".}
|
||||
else:
|
||||
{.compile: r"msvc\win32_asm.asm".}
|
||||
else:
|
||||
{.compile: r"gcc\ffi.c".}
|
||||
{.compile: r"gcc\prep_cif.c".}
|
||||
{.compile: r"gcc\types.c".}
|
||||
{.compile: r"gcc\closures.c".}
|
||||
when defined(cpu64):
|
||||
{.compile: r"gcc\ffi64.c".}
|
||||
{.compile: r"gcc\win64_asm.S".}
|
||||
else:
|
||||
{.compile: r"gcc\win32_asm.S".}
|
||||
|
||||
elif defined(macosx):
|
||||
{.pragma: mylib, dynlib: "libffi.dylib".}
|
||||
else:
|
||||
{.pragma: mylib, dynlib: "libffi.so".}
|
||||
|
||||
type
|
||||
Arg* = int
|
||||
SArg* = int
|
||||
{.deprecated: [TArg: Arg, TSArg: SArg].}
|
||||
|
||||
when defined(windows) and defined(x86):
|
||||
type
|
||||
TABI* {.size: sizeof(cint).} = enum
|
||||
FIRST_ABI, SYSV, STDCALL
|
||||
|
||||
const DEFAULT_ABI* = SYSV
|
||||
elif defined(amd64) and defined(windows):
|
||||
type
|
||||
TABI* {.size: sizeof(cint).} = enum
|
||||
FIRST_ABI, WIN64
|
||||
const DEFAULT_ABI* = WIN64
|
||||
else:
|
||||
type
|
||||
TABI* {.size: sizeof(cint).} = enum
|
||||
FIRST_ABI, SYSV, UNIX64
|
||||
|
||||
when defined(i386):
|
||||
const DEFAULT_ABI* = SYSV
|
||||
else:
|
||||
const DEFAULT_ABI* = UNIX64
|
||||
|
||||
const
|
||||
tkVOID* = 0
|
||||
tkINT* = 1
|
||||
tkFLOAT* = 2
|
||||
tkDOUBLE* = 3
|
||||
tkLONGDOUBLE* = 4
|
||||
tkUINT8* = 5
|
||||
tkSINT8* = 6
|
||||
tkUINT16* = 7
|
||||
tkSINT16* = 8
|
||||
tkUINT32* = 9
|
||||
tkSINT32* = 10
|
||||
tkUINT64* = 11
|
||||
tkSINT64* = 12
|
||||
tkSTRUCT* = 13
|
||||
tkPOINTER* = 14
|
||||
|
||||
tkLAST = tkPOINTER
|
||||
tkSMALL_STRUCT_1B* = (tkLAST + 1)
|
||||
tkSMALL_STRUCT_2B* = (tkLAST + 2)
|
||||
tkSMALL_STRUCT_4B* = (tkLAST + 3)
|
||||
|
||||
type
|
||||
Type* = object
|
||||
size*: int
|
||||
alignment*: uint16
|
||||
typ*: uint16
|
||||
elements*: ptr ptr Type
|
||||
{.deprecated: [TType: Type].}
|
||||
|
||||
var
|
||||
type_void* {.importc: "ffi_type_void", mylib.}: Type
|
||||
type_uint8* {.importc: "ffi_type_uint8", mylib.}: Type
|
||||
type_sint8* {.importc: "ffi_type_sint8", mylib.}: Type
|
||||
type_uint16* {.importc: "ffi_type_uint16", mylib.}: Type
|
||||
type_sint16* {.importc: "ffi_type_sint16", mylib.}: Type
|
||||
type_uint32* {.importc: "ffi_type_uint32", mylib.}: Type
|
||||
type_sint32* {.importc: "ffi_type_sint32", mylib.}: Type
|
||||
type_uint64* {.importc: "ffi_type_uint64", mylib.}: Type
|
||||
type_sint64* {.importc: "ffi_type_sint64", mylib.}: Type
|
||||
type_float* {.importc: "ffi_type_float", mylib.}: Type
|
||||
type_double* {.importc: "ffi_type_double", mylib.}: Type
|
||||
type_pointer* {.importc: "ffi_type_pointer", mylib.}: Type
|
||||
type_longdouble* {.importc: "ffi_type_longdouble", mylib.}: Type
|
||||
|
||||
type
|
||||
Status* {.size: sizeof(cint).} = enum
|
||||
OK, BAD_TYPEDEF, BAD_ABI
|
||||
TypeKind* = cuint
|
||||
TCif* {.pure, final.} = object
|
||||
abi*: TABI
|
||||
nargs*: cuint
|
||||
arg_types*: ptr ptr Type
|
||||
rtype*: ptr Type
|
||||
bytes*: cuint
|
||||
flags*: cuint
|
||||
{.deprecated: [Tstatus: Status].}
|
||||
|
||||
type
|
||||
Raw* = object
|
||||
sint*: SArg
|
||||
{.deprecated: [TRaw: Raw].}
|
||||
|
||||
proc raw_call*(cif: var Tcif; fn: proc () {.cdecl.}; rvalue: pointer;
|
||||
avalue: ptr Raw) {.cdecl, importc: "ffi_raw_call", mylib.}
|
||||
proc ptrarray_to_raw*(cif: var Tcif; args: ptr pointer; raw: ptr Raw) {.cdecl,
|
||||
importc: "ffi_ptrarray_to_raw", mylib.}
|
||||
proc raw_to_ptrarray*(cif: var Tcif; raw: ptr Raw; args: ptr pointer) {.cdecl,
|
||||
importc: "ffi_raw_to_ptrarray", mylib.}
|
||||
proc raw_size*(cif: var Tcif): int {.cdecl, importc: "ffi_raw_size", mylib.}
|
||||
|
||||
proc prep_cif*(cif: var Tcif; abi: TABI; nargs: cuint; rtype: ptr Type;
|
||||
atypes: ptr ptr Type): Status {.cdecl, importc: "ffi_prep_cif",
|
||||
mylib.}
|
||||
proc call*(cif: var Tcif; fn: proc () {.cdecl.}; rvalue: pointer;
|
||||
avalue: ptr pointer) {.cdecl, importc: "ffi_call", mylib.}
|
||||
|
||||
# the same with an easier interface:
|
||||
type
|
||||
ParamList* = array[0..100, ptr Type]
|
||||
ArgList* = array[0..100, pointer]
|
||||
{.deprecated: [TParamList: ParamList, TArgList: ArgList].}
|
||||
|
||||
proc prep_cif*(cif: var Tcif; abi: TABI; nargs: cuint; rtype: ptr Type;
|
||||
atypes: ParamList): Status {.cdecl, importc: "ffi_prep_cif",
|
||||
mylib.}
|
||||
proc call*(cif: var Tcif; fn, rvalue: pointer;
|
||||
avalue: ArgList) {.cdecl, importc: "ffi_call", mylib.}
|
||||
|
||||
# Useful for eliminating compiler warnings
|
||||
##define FFI_FN(f) ((void (*)(void))f)
|
||||
@@ -1,457 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
ffi.c - Copyright (c) 1996, 1998, 1999, 2001 Red Hat, Inc.
|
||||
Copyright (c) 2002 Ranjit Mathew
|
||||
Copyright (c) 2002 Bo Thorsen
|
||||
Copyright (c) 2002 Roger Sayle
|
||||
|
||||
x86 Foreign Function Interface
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* ffi_prep_args is called by the assembly routine once stack space
|
||||
has been allocated for the function's arguments */
|
||||
|
||||
extern void Py_FatalError(const char *msg);
|
||||
|
||||
/*@-exportheader@*/
|
||||
void ffi_prep_args(char *stack, extended_cif *ecif)
|
||||
/*@=exportheader@*/
|
||||
{
|
||||
register unsigned int i;
|
||||
register void **p_argv;
|
||||
register char *argp;
|
||||
register ffi_type **p_arg;
|
||||
|
||||
argp = stack;
|
||||
if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
|
||||
{
|
||||
*(void **) argp = ecif->rvalue;
|
||||
argp += sizeof(void *);
|
||||
}
|
||||
|
||||
p_argv = ecif->avalue;
|
||||
|
||||
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
|
||||
i != 0;
|
||||
i--, p_arg++)
|
||||
{
|
||||
size_t z;
|
||||
|
||||
/* Align if necessary */
|
||||
if ((sizeof(void *) - 1) & (size_t) argp)
|
||||
argp = (char *) ALIGN(argp, sizeof(void *));
|
||||
|
||||
z = (*p_arg)->size;
|
||||
if (z < sizeof(int))
|
||||
{
|
||||
z = sizeof(int);
|
||||
switch ((*p_arg)->type)
|
||||
{
|
||||
case FFI_TYPE_SINT8:
|
||||
*(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_UINT8:
|
||||
*(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_SINT16:
|
||||
*(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_UINT16:
|
||||
*(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_SINT32:
|
||||
*(signed int *) argp = (signed int)*(SINT32 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_UINT32:
|
||||
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
|
||||
break;
|
||||
|
||||
case FFI_TYPE_STRUCT:
|
||||
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
|
||||
break;
|
||||
|
||||
default:
|
||||
FFI_ASSERT(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(argp, *p_argv, z);
|
||||
}
|
||||
p_argv++;
|
||||
argp += z;
|
||||
}
|
||||
|
||||
if (argp >= stack && (unsigned)(argp - stack) > ecif->cif->bytes)
|
||||
{
|
||||
Py_FatalError("FFI BUG: not enough stack space for arguments");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Perform machine dependent cif processing */
|
||||
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
|
||||
{
|
||||
/* Set the return type flag */
|
||||
switch (cif->rtype->type)
|
||||
{
|
||||
case FFI_TYPE_VOID:
|
||||
case FFI_TYPE_STRUCT:
|
||||
case FFI_TYPE_SINT64:
|
||||
case FFI_TYPE_FLOAT:
|
||||
case FFI_TYPE_DOUBLE:
|
||||
case FFI_TYPE_LONGDOUBLE:
|
||||
cif->flags = (unsigned) cif->rtype->type;
|
||||
break;
|
||||
|
||||
case FFI_TYPE_UINT64:
|
||||
#ifdef _WIN64
|
||||
case FFI_TYPE_POINTER:
|
||||
#endif
|
||||
cif->flags = FFI_TYPE_SINT64;
|
||||
break;
|
||||
|
||||
default:
|
||||
cif->flags = FFI_TYPE_INT;
|
||||
break;
|
||||
}
|
||||
|
||||
return FFI_OK;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
extern int
|
||||
ffi_call_x86(void (*)(char *, extended_cif *),
|
||||
/*@out@*/ extended_cif *,
|
||||
unsigned, unsigned,
|
||||
/*@out@*/ unsigned *,
|
||||
void (*fn)());
|
||||
#endif
|
||||
|
||||
#ifdef _WIN64
|
||||
extern int
|
||||
ffi_call_AMD64(void (*)(char *, extended_cif *),
|
||||
/*@out@*/ extended_cif *,
|
||||
unsigned, unsigned,
|
||||
/*@out@*/ unsigned *,
|
||||
void (*fn)());
|
||||
#endif
|
||||
|
||||
int
|
||||
ffi_call(/*@dependent@*/ ffi_cif *cif,
|
||||
void (*fn)(),
|
||||
/*@out@*/ void *rvalue,
|
||||
/*@dependent@*/ void **avalue)
|
||||
{
|
||||
extended_cif ecif;
|
||||
|
||||
ecif.cif = cif;
|
||||
ecif.avalue = avalue;
|
||||
|
||||
/* If the return value is a struct and we don't have a return */
|
||||
/* value address then we need to make one */
|
||||
|
||||
if ((rvalue == NULL) &&
|
||||
(cif->rtype->type == FFI_TYPE_STRUCT))
|
||||
{
|
||||
/*@-sysunrecog@*/
|
||||
ecif.rvalue = alloca(cif->rtype->size);
|
||||
/*@=sysunrecog@*/
|
||||
}
|
||||
else
|
||||
ecif.rvalue = rvalue;
|
||||
|
||||
|
||||
switch (cif->abi)
|
||||
{
|
||||
#if !defined(_WIN64)
|
||||
case FFI_SYSV:
|
||||
case FFI_STDCALL:
|
||||
return ffi_call_x86(ffi_prep_args, &ecif, cif->bytes,
|
||||
cif->flags, ecif.rvalue, fn);
|
||||
break;
|
||||
#else
|
||||
case FFI_SYSV:
|
||||
/*@-usedef@*/
|
||||
/* Function call needs at least 40 bytes stack size, on win64 AMD64 */
|
||||
return ffi_call_AMD64(ffi_prep_args, &ecif, cif->bytes ? cif->bytes : 40,
|
||||
cif->flags, ecif.rvalue, fn);
|
||||
/*@=usedef@*/
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
FFI_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
return -1; /* theller: Hrm. */
|
||||
}
|
||||
|
||||
|
||||
/** private members **/
|
||||
|
||||
static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
|
||||
void** args, ffi_cif* cif);
|
||||
/* This function is jumped to by the trampoline */
|
||||
|
||||
#ifdef _WIN64
|
||||
void *
|
||||
#else
|
||||
static void __fastcall
|
||||
#endif
|
||||
ffi_closure_SYSV (ffi_closure *closure, int *argp)
|
||||
{
|
||||
// this is our return value storage
|
||||
long double res;
|
||||
|
||||
// our various things...
|
||||
ffi_cif *cif;
|
||||
void **arg_area;
|
||||
unsigned short rtype;
|
||||
void *resp = (void*)&res;
|
||||
void *args = &argp[1];
|
||||
|
||||
cif = closure->cif;
|
||||
arg_area = (void**) alloca (cif->nargs * sizeof (void*));
|
||||
|
||||
/* this call will initialize ARG_AREA, such that each
|
||||
* element in that array points to the corresponding
|
||||
* value on the stack; and if the function returns
|
||||
* a structure, it will re-set RESP to point to the
|
||||
* structure return address. */
|
||||
|
||||
ffi_prep_incoming_args_SYSV(args, (void**)&resp, arg_area, cif);
|
||||
|
||||
(closure->fun) (cif, resp, arg_area, closure->user_data);
|
||||
|
||||
rtype = cif->flags;
|
||||
|
||||
#if defined(_WIN32) && !defined(_WIN64)
|
||||
#ifdef _MSC_VER
|
||||
/* now, do a generic return based on the value of rtype */
|
||||
if (rtype == FFI_TYPE_INT)
|
||||
{
|
||||
_asm mov eax, resp ;
|
||||
_asm mov eax, [eax] ;
|
||||
}
|
||||
else if (rtype == FFI_TYPE_FLOAT)
|
||||
{
|
||||
_asm mov eax, resp ;
|
||||
_asm fld DWORD PTR [eax] ;
|
||||
// asm ("flds (%0)" : : "r" (resp) : "st" );
|
||||
}
|
||||
else if (rtype == FFI_TYPE_DOUBLE)
|
||||
{
|
||||
_asm mov eax, resp ;
|
||||
_asm fld QWORD PTR [eax] ;
|
||||
// asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" );
|
||||
}
|
||||
else if (rtype == FFI_TYPE_LONGDOUBLE)
|
||||
{
|
||||
// asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" );
|
||||
}
|
||||
else if (rtype == FFI_TYPE_SINT64)
|
||||
{
|
||||
_asm mov edx, resp ;
|
||||
_asm mov eax, [edx] ;
|
||||
_asm mov edx, [edx + 4] ;
|
||||
// asm ("movl 0(%0),%%eax;"
|
||||
// "movl 4(%0),%%edx"
|
||||
// : : "r"(resp)
|
||||
// : "eax", "edx");
|
||||
}
|
||||
#else
|
||||
/* now, do a generic return based on the value of rtype */
|
||||
if (rtype == FFI_TYPE_INT)
|
||||
{
|
||||
asm ("movl (%0),%%eax" : : "r" (resp) : "eax");
|
||||
}
|
||||
else if (rtype == FFI_TYPE_FLOAT)
|
||||
{
|
||||
asm ("flds (%0)" : : "r" (resp) : "st" );
|
||||
}
|
||||
else if (rtype == FFI_TYPE_DOUBLE)
|
||||
{
|
||||
asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" );
|
||||
}
|
||||
else if (rtype == FFI_TYPE_LONGDOUBLE)
|
||||
{
|
||||
asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" );
|
||||
}
|
||||
else if (rtype == FFI_TYPE_SINT64)
|
||||
{
|
||||
asm ("movl 0(%0),%%eax;"
|
||||
"movl 4(%0),%%edx"
|
||||
: : "r"(resp)
|
||||
: "eax", "edx");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN64
|
||||
/* The result is returned in rax. This does the right thing for
|
||||
result types except for floats; we have to 'mov xmm0, rax' in the
|
||||
caller to correct this.
|
||||
*/
|
||||
return *(void **)resp;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*@-exportheader@*/
|
||||
static void
|
||||
ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
|
||||
void **avalue, ffi_cif *cif)
|
||||
/*@=exportheader@*/
|
||||
{
|
||||
register unsigned int i;
|
||||
register void **p_argv;
|
||||
register char *argp;
|
||||
register ffi_type **p_arg;
|
||||
|
||||
argp = stack;
|
||||
|
||||
if ( cif->rtype->type == FFI_TYPE_STRUCT ) {
|
||||
*rvalue = *(void **) argp;
|
||||
argp += 4;
|
||||
}
|
||||
|
||||
p_argv = avalue;
|
||||
|
||||
for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
|
||||
{
|
||||
size_t z;
|
||||
|
||||
/* Align if necessary */
|
||||
if ((sizeof(char *) - 1) & (size_t) argp) {
|
||||
argp = (char *) ALIGN(argp, sizeof(char*));
|
||||
}
|
||||
|
||||
z = (*p_arg)->size;
|
||||
|
||||
/* because we're little endian, this is what it turns into. */
|
||||
|
||||
*p_argv = (void*) argp;
|
||||
|
||||
p_argv++;
|
||||
argp += z;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* the cif must already be prep'ed */
|
||||
extern void ffi_closure_OUTER();
|
||||
|
||||
ffi_status
|
||||
ffi_prep_closure_loc (ffi_closure* closure,
|
||||
ffi_cif* cif,
|
||||
void (*fun)(ffi_cif*,void*,void**,void*),
|
||||
void *user_data,
|
||||
void *codeloc)
|
||||
{
|
||||
short bytes;
|
||||
char *tramp;
|
||||
#ifdef _WIN64
|
||||
int mask = 0;
|
||||
#endif
|
||||
FFI_ASSERT (cif->abi == FFI_SYSV);
|
||||
|
||||
if (cif->abi == FFI_SYSV)
|
||||
bytes = 0;
|
||||
#if !defined(_WIN64)
|
||||
else if (cif->abi == FFI_STDCALL)
|
||||
bytes = cif->bytes;
|
||||
#endif
|
||||
else
|
||||
return FFI_BAD_ABI;
|
||||
|
||||
tramp = &closure->tramp[0];
|
||||
|
||||
#define BYTES(text) memcpy(tramp, text, sizeof(text)), tramp += sizeof(text)-1
|
||||
#define POINTER(x) *(void**)tramp = (void*)(x), tramp += sizeof(void*)
|
||||
#define SHORT(x) *(short*)tramp = x, tramp += sizeof(short)
|
||||
#define INT(x) *(int*)tramp = x, tramp += sizeof(int)
|
||||
|
||||
#ifdef _WIN64
|
||||
if (cif->nargs >= 1 &&
|
||||
(cif->arg_types[0]->type == FFI_TYPE_FLOAT
|
||||
|| cif->arg_types[0]->type == FFI_TYPE_DOUBLE))
|
||||
mask |= 1;
|
||||
if (cif->nargs >= 2 &&
|
||||
(cif->arg_types[1]->type == FFI_TYPE_FLOAT
|
||||
|| cif->arg_types[1]->type == FFI_TYPE_DOUBLE))
|
||||
mask |= 2;
|
||||
if (cif->nargs >= 3 &&
|
||||
(cif->arg_types[2]->type == FFI_TYPE_FLOAT
|
||||
|| cif->arg_types[2]->type == FFI_TYPE_DOUBLE))
|
||||
mask |= 4;
|
||||
if (cif->nargs >= 4 &&
|
||||
(cif->arg_types[3]->type == FFI_TYPE_FLOAT
|
||||
|| cif->arg_types[3]->type == FFI_TYPE_DOUBLE))
|
||||
mask |= 8;
|
||||
|
||||
/* 41 BB ---- mov r11d,mask */
|
||||
BYTES("\x41\xBB"); INT(mask);
|
||||
|
||||
/* 48 B8 -------- mov rax, closure */
|
||||
BYTES("\x48\xB8"); POINTER(closure);
|
||||
|
||||
/* 49 BA -------- mov r10, ffi_closure_OUTER */
|
||||
BYTES("\x49\xBA"); POINTER(ffi_closure_OUTER);
|
||||
|
||||
/* 41 FF E2 jmp r10 */
|
||||
BYTES("\x41\xFF\xE2");
|
||||
|
||||
#else
|
||||
|
||||
/* mov ecx, closure */
|
||||
BYTES("\xb9"); POINTER(closure);
|
||||
|
||||
/* mov edx, esp */
|
||||
BYTES("\x8b\xd4");
|
||||
|
||||
/* call ffi_closure_SYSV */
|
||||
BYTES("\xe8"); POINTER((char*)&ffi_closure_SYSV - (tramp + 4));
|
||||
|
||||
/* ret bytes */
|
||||
BYTES("\xc2");
|
||||
SHORT(bytes);
|
||||
|
||||
#endif
|
||||
|
||||
if (tramp - &closure->tramp[0] > FFI_TRAMPOLINE_SIZE)
|
||||
Py_FatalError("FFI_TRAMPOLINE_SIZE too small in " __FILE__);
|
||||
|
||||
closure->cif = cif;
|
||||
closure->user_data = user_data;
|
||||
closure->fun = fun;
|
||||
return FFI_OK;
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
prep_cif.c - Copyright (c) 1996, 1998 Red Hat, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/* Round up to FFI_SIZEOF_ARG. */
|
||||
|
||||
#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
|
||||
|
||||
/* Perform machine independent initialization of aggregate type
|
||||
specifications. */
|
||||
|
||||
static ffi_status initialize_aggregate(/*@out@*/ ffi_type *arg)
|
||||
{
|
||||
ffi_type **ptr;
|
||||
|
||||
FFI_ASSERT(arg != NULL);
|
||||
|
||||
/*@-usedef@*/
|
||||
|
||||
FFI_ASSERT(arg->elements != NULL);
|
||||
FFI_ASSERT(arg->size == 0);
|
||||
FFI_ASSERT(arg->alignment == 0);
|
||||
|
||||
ptr = &(arg->elements[0]);
|
||||
|
||||
while ((*ptr) != NULL)
|
||||
{
|
||||
if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
|
||||
return FFI_BAD_TYPEDEF;
|
||||
|
||||
/* Perform a sanity check on the argument type */
|
||||
FFI_ASSERT_VALID_TYPE(*ptr);
|
||||
|
||||
arg->size = ALIGN(arg->size, (*ptr)->alignment);
|
||||
arg->size += (*ptr)->size;
|
||||
|
||||
arg->alignment = (arg->alignment > (*ptr)->alignment) ?
|
||||
arg->alignment : (*ptr)->alignment;
|
||||
|
||||
ptr++;
|
||||
}
|
||||
|
||||
/* Structure size includes tail padding. This is important for
|
||||
structures that fit in one register on ABIs like the PowerPC64
|
||||
Linux ABI that right justify small structs in a register.
|
||||
It's also needed for nested structure layout, for example
|
||||
struct A { long a; char b; }; struct B { struct A x; char y; };
|
||||
should find y at an offset of 2*sizeof(long) and result in a
|
||||
total size of 3*sizeof(long). */
|
||||
arg->size = ALIGN (arg->size, arg->alignment);
|
||||
|
||||
if (arg->size == 0)
|
||||
return FFI_BAD_TYPEDEF;
|
||||
else
|
||||
return FFI_OK;
|
||||
|
||||
/*@=usedef@*/
|
||||
}
|
||||
|
||||
/* Perform machine independent ffi_cif preparation, then call
|
||||
machine dependent routine. */
|
||||
|
||||
ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif,
|
||||
ffi_abi abi, unsigned int nargs,
|
||||
/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype,
|
||||
/*@dependent@*/ ffi_type **atypes)
|
||||
{
|
||||
unsigned bytes = 0;
|
||||
unsigned int i;
|
||||
ffi_type **ptr;
|
||||
|
||||
FFI_ASSERT(cif != NULL);
|
||||
FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI));
|
||||
|
||||
cif->abi = abi;
|
||||
cif->arg_types = atypes;
|
||||
cif->nargs = nargs;
|
||||
cif->rtype = rtype;
|
||||
|
||||
cif->flags = 0;
|
||||
|
||||
/* Initialize the return type if necessary */
|
||||
/*@-usedef@*/
|
||||
if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
|
||||
return FFI_BAD_TYPEDEF;
|
||||
/*@=usedef@*/
|
||||
|
||||
/* Perform a sanity check on the return type */
|
||||
FFI_ASSERT_VALID_TYPE(cif->rtype);
|
||||
|
||||
/* x86-64 and s390 stack space allocation is handled in prep_machdep. */
|
||||
#if !defined M68K && !defined __x86_64__ && !defined S390
|
||||
/* Make space for the return structure pointer */
|
||||
if (cif->rtype->type == FFI_TYPE_STRUCT
|
||||
/* MSVC returns small structures in registers. But we have a different
|
||||
workaround: pretend int32 or int64 return type, and converting to
|
||||
structure afterwards. */
|
||||
#ifdef SPARC
|
||||
&& (cif->abi != FFI_V9 || cif->rtype->size > 32)
|
||||
#endif
|
||||
)
|
||||
bytes = STACK_ARG_SIZE(sizeof(void*));
|
||||
#endif
|
||||
|
||||
for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
|
||||
{
|
||||
|
||||
/* Initialize any uninitialized aggregate type definitions */
|
||||
if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
|
||||
return FFI_BAD_TYPEDEF;
|
||||
|
||||
/* Perform a sanity check on the argument type, do this
|
||||
check after the initialization. */
|
||||
FFI_ASSERT_VALID_TYPE(*ptr);
|
||||
|
||||
#if !defined __x86_64__ && !defined S390
|
||||
#ifdef SPARC
|
||||
if (((*ptr)->type == FFI_TYPE_STRUCT
|
||||
&& ((*ptr)->size > 16 || cif->abi != FFI_V9))
|
||||
|| ((*ptr)->type == FFI_TYPE_LONGDOUBLE
|
||||
&& cif->abi != FFI_V9))
|
||||
bytes += sizeof(void*);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
/* Don't know if this is a libffi bug or not. At least on
|
||||
Windows with MSVC, function call parameters are *not*
|
||||
aligned in the same way as structure fields are, they are
|
||||
only aligned in integer boundaries.
|
||||
|
||||
This doesn't do any harm for cdecl functions and closures,
|
||||
since the caller cleans up the stack, but it is wrong for
|
||||
stdcall functions where the callee cleans.
|
||||
*/
|
||||
|
||||
/* Add any padding if necessary */
|
||||
if (((*ptr)->alignment - 1) & bytes)
|
||||
bytes = ALIGN(bytes, (*ptr)->alignment);
|
||||
|
||||
#endif
|
||||
bytes += STACK_ARG_SIZE((*ptr)->size);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
cif->bytes = bytes;
|
||||
|
||||
/* Perform machine dependent cif processing */
|
||||
return ffi_prep_cif_machdep(cif);
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
types.c - Copyright (c) 1996, 1998 Red Hat, Inc.
|
||||
|
||||
Predefined ffi_types needed by libffi.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
|
||||
/* Type definitions */
|
||||
|
||||
#define FFI_INTEGRAL_TYPEDEF(n, s, a, t) ffi_type ffi_type_##n = { s, a, t, NULL }
|
||||
#define FFI_AGGREGATE_TYPEDEF(n, e) ffi_type ffi_type_##n = { 0, 0, FFI_TYPE_STRUCT, e }
|
||||
|
||||
/* Size and alignment are fake here. They must not be 0. */
|
||||
FFI_INTEGRAL_TYPEDEF(void, 1, 1, FFI_TYPE_VOID);
|
||||
|
||||
FFI_INTEGRAL_TYPEDEF(uint8, 1, 1, FFI_TYPE_UINT8);
|
||||
FFI_INTEGRAL_TYPEDEF(sint8, 1, 1, FFI_TYPE_SINT8);
|
||||
FFI_INTEGRAL_TYPEDEF(uint16, 2, 2, FFI_TYPE_UINT16);
|
||||
FFI_INTEGRAL_TYPEDEF(sint16, 2, 2, FFI_TYPE_SINT16);
|
||||
FFI_INTEGRAL_TYPEDEF(uint32, 4, 4, FFI_TYPE_UINT32);
|
||||
FFI_INTEGRAL_TYPEDEF(sint32, 4, 4, FFI_TYPE_SINT32);
|
||||
FFI_INTEGRAL_TYPEDEF(float, 4, 4, FFI_TYPE_FLOAT);
|
||||
|
||||
#if defined ALPHA || defined SPARC64 || defined X86_64 || defined S390X \
|
||||
|| defined IA64
|
||||
|
||||
FFI_INTEGRAL_TYPEDEF(pointer, 8, 8, FFI_TYPE_POINTER);
|
||||
|
||||
#else
|
||||
|
||||
FFI_INTEGRAL_TYPEDEF(pointer, 4, 4, FFI_TYPE_POINTER);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined X86 || defined X86_WIN32 || defined ARM || defined M68K
|
||||
|
||||
FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
|
||||
FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
|
||||
|
||||
#elif defined SH
|
||||
|
||||
FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
|
||||
FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
|
||||
|
||||
#else
|
||||
|
||||
FFI_INTEGRAL_TYPEDEF(uint64, 8, 8, FFI_TYPE_UINT64);
|
||||
FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined X86 || defined X86_WIN32 || defined M68K
|
||||
|
||||
FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
|
||||
FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
|
||||
|
||||
#elif defined ARM || defined SH || defined POWERPC_AIX || defined POWERPC_DARWIN
|
||||
|
||||
FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
|
||||
FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
|
||||
|
||||
#elif defined SPARC
|
||||
|
||||
FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
|
||||
#ifdef SPARC64
|
||||
FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
|
||||
#else
|
||||
FFI_INTEGRAL_TYPEDEF(longdouble, 16, 8, FFI_TYPE_LONGDOUBLE);
|
||||
#endif
|
||||
|
||||
#elif defined X86_64
|
||||
|
||||
FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
|
||||
FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
|
||||
|
||||
#else
|
||||
|
||||
FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
|
||||
FFI_INTEGRAL_TYPEDEF(longdouble, 8, 8, FFI_TYPE_LONGDOUBLE);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
win32.S - Copyright (c) 1996, 1998, 2001, 2002 Red Hat, Inc.
|
||||
Copyright (c) 2001 John Beniton
|
||||
Copyright (c) 2002 Ranjit Mathew
|
||||
|
||||
|
||||
X86 Foreign Function Interface
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
/* theller: almost verbatim translation from gas syntax to MSVC inline
|
||||
assembler code. */
|
||||
|
||||
/* theller: ffi_call_x86 now returns an integer - the difference of the stack
|
||||
pointer before and after the function call. If everything is ok, zero is
|
||||
returned. If stdcall functions are passed the wrong number of arguments,
|
||||
the difference will be nonzero. */
|
||||
|
||||
#include <ffi.h>
|
||||
#include <ffi_common.h>
|
||||
|
||||
__declspec(naked) int
|
||||
ffi_call_x86(void (* prepfunc)(char *, extended_cif *), /* 8 */
|
||||
extended_cif *ecif, /* 12 */
|
||||
unsigned bytes, /* 16 */
|
||||
unsigned flags, /* 20 */
|
||||
unsigned *rvalue, /* 24 */
|
||||
void (*fn)()) /* 28 */
|
||||
{
|
||||
_asm {
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
push esi // NEW: this register must be preserved across function calls
|
||||
// XXX SAVE ESP NOW!
|
||||
mov esi, esp // save stack pointer before the call
|
||||
|
||||
// Make room for all of the new args.
|
||||
mov ecx, [ebp+16]
|
||||
sub esp, ecx // sub esp, bytes
|
||||
|
||||
mov eax, esp
|
||||
|
||||
// Place all of the ffi_prep_args in position
|
||||
push [ebp + 12] // ecif
|
||||
push eax
|
||||
call [ebp + 8] // prepfunc
|
||||
|
||||
// Return stack to previous state and call the function
|
||||
add esp, 8
|
||||
// FIXME: Align the stack to a 128-bit boundary to avoid
|
||||
// potential performance hits.
|
||||
call [ebp + 28]
|
||||
|
||||
// Load ecif->cif->abi
|
||||
mov ecx, [ebp + 12]
|
||||
mov ecx, [ecx]ecif.cif
|
||||
mov ecx, [ecx]ecif.cif.abi
|
||||
|
||||
cmp ecx, FFI_STDCALL
|
||||
je noclean
|
||||
// STDCALL: Remove the space we pushed for the args
|
||||
mov ecx, [ebp + 16]
|
||||
add esp, ecx
|
||||
// CDECL: Caller has already cleaned the stack
|
||||
noclean:
|
||||
// Check that esp has the same value as before!
|
||||
sub esi, esp
|
||||
|
||||
// Load %ecx with the return type code
|
||||
mov ecx, [ebp + 20]
|
||||
|
||||
// If the return value pointer is NULL, assume no return value.
|
||||
/*
|
||||
Intel asm is weird. We have to explicitly specify 'DWORD PTR' in the nexr instruction,
|
||||
otherwise only one BYTE will be compared (instead of a DWORD)!
|
||||
*/
|
||||
cmp DWORD PTR [ebp + 24], 0
|
||||
jne sc_retint
|
||||
|
||||
// Even if there is no space for the return value, we are
|
||||
// obliged to handle floating-point values.
|
||||
cmp ecx, FFI_TYPE_FLOAT
|
||||
jne sc_noretval
|
||||
// fstp %st(0)
|
||||
fstp st(0)
|
||||
|
||||
jmp sc_epilogue
|
||||
|
||||
sc_retint:
|
||||
cmp ecx, FFI_TYPE_INT
|
||||
jne sc_retfloat
|
||||
// # Load %ecx with the pointer to storage for the return value
|
||||
mov ecx, [ebp + 24]
|
||||
mov [ecx + 0], eax
|
||||
jmp sc_epilogue
|
||||
|
||||
sc_retfloat:
|
||||
cmp ecx, FFI_TYPE_FLOAT
|
||||
jne sc_retdouble
|
||||
// Load %ecx with the pointer to storage for the return value
|
||||
mov ecx, [ebp+24]
|
||||
// fstps (%ecx)
|
||||
fstp DWORD PTR [ecx]
|
||||
jmp sc_epilogue
|
||||
|
||||
sc_retdouble:
|
||||
cmp ecx, FFI_TYPE_DOUBLE
|
||||
jne sc_retlongdouble
|
||||
// movl 24(%ebp),%ecx
|
||||
mov ecx, [ebp+24]
|
||||
fstp QWORD PTR [ecx]
|
||||
jmp sc_epilogue
|
||||
|
||||
jmp sc_retlongdouble // avoid warning about unused label
|
||||
sc_retlongdouble:
|
||||
cmp ecx, FFI_TYPE_LONGDOUBLE
|
||||
jne sc_retint64
|
||||
// Load %ecx with the pointer to storage for the return value
|
||||
mov ecx, [ebp+24]
|
||||
// fstpt (%ecx)
|
||||
fstp QWORD PTR [ecx] /* XXX ??? */
|
||||
jmp sc_epilogue
|
||||
|
||||
sc_retint64:
|
||||
cmp ecx, FFI_TYPE_SINT64
|
||||
jne sc_retstruct
|
||||
// Load %ecx with the pointer to storage for the return value
|
||||
mov ecx, [ebp+24]
|
||||
mov [ecx+0], eax
|
||||
mov [ecx+4], edx
|
||||
|
||||
sc_retstruct:
|
||||
// Nothing to do!
|
||||
|
||||
sc_noretval:
|
||||
sc_epilogue:
|
||||
mov eax, esi
|
||||
pop esi // NEW restore: must be preserved across function calls
|
||||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
||||
}
|
||||
}
|
||||
@@ -1,470 +0,0 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
win32.S - Copyright (c) 1996, 1998, 2001, 2002, 2009 Red Hat, Inc.
|
||||
Copyright (c) 2001 John Beniton
|
||||
Copyright (c) 2002 Ranjit Mathew
|
||||
Copyright (c) 2009 Daniel Witte
|
||||
|
||||
|
||||
X86 Foreign Function Interface
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
``Software''), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define LIBFFI_ASM
|
||||
#include <fficonfig.h>
|
||||
#include <ffi.h>
|
||||
|
||||
.386
|
||||
.MODEL FLAT, C
|
||||
|
||||
EXTRN ffi_closure_SYSV_inner:NEAR
|
||||
|
||||
_TEXT SEGMENT
|
||||
|
||||
ffi_call_win32 PROC NEAR,
|
||||
ffi_prep_args : NEAR PTR DWORD,
|
||||
ecif : NEAR PTR DWORD,
|
||||
cif_abi : DWORD,
|
||||
cif_bytes : DWORD,
|
||||
cif_flags : DWORD,
|
||||
rvalue : NEAR PTR DWORD,
|
||||
fn : NEAR PTR DWORD
|
||||
|
||||
;; Make room for all of the new args.
|
||||
mov ecx, cif_bytes
|
||||
sub esp, ecx
|
||||
|
||||
mov eax, esp
|
||||
|
||||
;; Place all of the ffi_prep_args in position
|
||||
push ecif
|
||||
push eax
|
||||
call ffi_prep_args
|
||||
|
||||
;; Return stack to previous state and call the function
|
||||
add esp, 8
|
||||
|
||||
;; Handle thiscall and fastcall
|
||||
cmp cif_abi, 3 ;; FFI_THISCALL
|
||||
jz do_thiscall
|
||||
cmp cif_abi, 4 ;; FFI_FASTCALL
|
||||
jnz do_stdcall
|
||||
mov ecx, DWORD PTR [esp]
|
||||
mov edx, DWORD PTR [esp+4]
|
||||
add esp, 8
|
||||
jmp do_stdcall
|
||||
do_thiscall:
|
||||
mov ecx, DWORD PTR [esp]
|
||||
add esp, 4
|
||||
do_stdcall:
|
||||
call fn
|
||||
|
||||
;; cdecl: we restore esp in the epilogue, so there's no need to
|
||||
;; remove the space we pushed for the args.
|
||||
;; stdcall: the callee has already cleaned the stack.
|
||||
|
||||
;; Load ecx with the return type code
|
||||
mov ecx, cif_flags
|
||||
|
||||
;; If the return value pointer is NULL, assume no return value.
|
||||
cmp rvalue, 0
|
||||
jne ca_jumptable
|
||||
|
||||
;; Even if there is no space for the return value, we are
|
||||
;; obliged to handle floating-point values.
|
||||
cmp ecx, FFI_TYPE_FLOAT
|
||||
jne ca_epilogue
|
||||
fstp st(0)
|
||||
|
||||
jmp ca_epilogue
|
||||
|
||||
ca_jumptable:
|
||||
jmp [ca_jumpdata + 4 * ecx]
|
||||
ca_jumpdata:
|
||||
;; Do not insert anything here between label and jump table.
|
||||
dd offset ca_epilogue ;; FFI_TYPE_VOID
|
||||
dd offset ca_retint ;; FFI_TYPE_INT
|
||||
dd offset ca_retfloat ;; FFI_TYPE_FLOAT
|
||||
dd offset ca_retdouble ;; FFI_TYPE_DOUBLE
|
||||
dd offset ca_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
||||
dd offset ca_retuint8 ;; FFI_TYPE_UINT8
|
||||
dd offset ca_retsint8 ;; FFI_TYPE_SINT8
|
||||
dd offset ca_retuint16 ;; FFI_TYPE_UINT16
|
||||
dd offset ca_retsint16 ;; FFI_TYPE_SINT16
|
||||
dd offset ca_retint ;; FFI_TYPE_UINT32
|
||||
dd offset ca_retint ;; FFI_TYPE_SINT32
|
||||
dd offset ca_retint64 ;; FFI_TYPE_UINT64
|
||||
dd offset ca_retint64 ;; FFI_TYPE_SINT64
|
||||
dd offset ca_epilogue ;; FFI_TYPE_STRUCT
|
||||
dd offset ca_retint ;; FFI_TYPE_POINTER
|
||||
dd offset ca_retstruct1b ;; FFI_TYPE_SMALL_STRUCT_1B
|
||||
dd offset ca_retstruct2b ;; FFI_TYPE_SMALL_STRUCT_2B
|
||||
dd offset ca_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
||||
dd offset ca_epilogue ;; FFI_TYPE_MS_STRUCT
|
||||
|
||||
/* Sign/zero extend as appropriate. */
|
||||
ca_retuint8:
|
||||
movzx eax, al
|
||||
jmp ca_retint
|
||||
|
||||
ca_retsint8:
|
||||
movsx eax, al
|
||||
jmp ca_retint
|
||||
|
||||
ca_retuint16:
|
||||
movzx eax, ax
|
||||
jmp ca_retint
|
||||
|
||||
ca_retsint16:
|
||||
movsx eax, ax
|
||||
jmp ca_retint
|
||||
|
||||
ca_retint:
|
||||
;; Load %ecx with the pointer to storage for the return value
|
||||
mov ecx, rvalue
|
||||
mov [ecx + 0], eax
|
||||
jmp ca_epilogue
|
||||
|
||||
ca_retint64:
|
||||
;; Load %ecx with the pointer to storage for the return value
|
||||
mov ecx, rvalue
|
||||
mov [ecx + 0], eax
|
||||
mov [ecx + 4], edx
|
||||
jmp ca_epilogue
|
||||
|
||||
ca_retfloat:
|
||||
;; Load %ecx with the pointer to storage for the return value
|
||||
mov ecx, rvalue
|
||||
fstp DWORD PTR [ecx]
|
||||
jmp ca_epilogue
|
||||
|
||||
ca_retdouble:
|
||||
;; Load %ecx with the pointer to storage for the return value
|
||||
mov ecx, rvalue
|
||||
fstp QWORD PTR [ecx]
|
||||
jmp ca_epilogue
|
||||
|
||||
ca_retlongdouble:
|
||||
;; Load %ecx with the pointer to storage for the return value
|
||||
mov ecx, rvalue
|
||||
fstp TBYTE PTR [ecx]
|
||||
jmp ca_epilogue
|
||||
|
||||
ca_retstruct1b:
|
||||
;; Load %ecx with the pointer to storage for the return value
|
||||
mov ecx, rvalue
|
||||
mov [ecx + 0], al
|
||||
jmp ca_epilogue
|
||||
|
||||
ca_retstruct2b:
|
||||
;; Load %ecx with the pointer to storage for the return value
|
||||
mov ecx, rvalue
|
||||
mov [ecx + 0], ax
|
||||
jmp ca_epilogue
|
||||
|
||||
ca_epilogue:
|
||||
;; Epilogue code is autogenerated.
|
||||
ret
|
||||
ffi_call_win32 ENDP
|
||||
|
||||
ffi_closure_THISCALL PROC NEAR FORCEFRAME
|
||||
sub esp, 40
|
||||
lea edx, [ebp -24]
|
||||
mov [ebp - 12], edx /* resp */
|
||||
lea edx, [ebp + 12] /* account for stub return address on stack */
|
||||
jmp stub
|
||||
ffi_closure_THISCALL ENDP
|
||||
|
||||
ffi_closure_SYSV PROC NEAR FORCEFRAME
|
||||
;; the ffi_closure ctx is passed in eax by the trampoline.
|
||||
|
||||
sub esp, 40
|
||||
lea edx, [ebp - 24]
|
||||
mov [ebp - 12], edx ;; resp
|
||||
lea edx, [ebp + 8]
|
||||
stub::
|
||||
mov [esp + 8], edx ;; args
|
||||
lea edx, [ebp - 12]
|
||||
mov [esp + 4], edx ;; &resp
|
||||
mov [esp], eax ;; closure
|
||||
call ffi_closure_SYSV_inner
|
||||
mov ecx, [ebp - 12]
|
||||
|
||||
cs_jumptable:
|
||||
jmp [cs_jumpdata + 4 * eax]
|
||||
cs_jumpdata:
|
||||
;; Do not insert anything here between the label and jump table.
|
||||
dd offset cs_epilogue ;; FFI_TYPE_VOID
|
||||
dd offset cs_retint ;; FFI_TYPE_INT
|
||||
dd offset cs_retfloat ;; FFI_TYPE_FLOAT
|
||||
dd offset cs_retdouble ;; FFI_TYPE_DOUBLE
|
||||
dd offset cs_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
||||
dd offset cs_retuint8 ;; FFI_TYPE_UINT8
|
||||
dd offset cs_retsint8 ;; FFI_TYPE_SINT8
|
||||
dd offset cs_retuint16 ;; FFI_TYPE_UINT16
|
||||
dd offset cs_retsint16 ;; FFI_TYPE_SINT16
|
||||
dd offset cs_retint ;; FFI_TYPE_UINT32
|
||||
dd offset cs_retint ;; FFI_TYPE_SINT32
|
||||
dd offset cs_retint64 ;; FFI_TYPE_UINT64
|
||||
dd offset cs_retint64 ;; FFI_TYPE_SINT64
|
||||
dd offset cs_retstruct ;; FFI_TYPE_STRUCT
|
||||
dd offset cs_retint ;; FFI_TYPE_POINTER
|
||||
dd offset cs_retsint8 ;; FFI_TYPE_SMALL_STRUCT_1B
|
||||
dd offset cs_retsint16 ;; FFI_TYPE_SMALL_STRUCT_2B
|
||||
dd offset cs_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
||||
dd offset cs_retmsstruct ;; FFI_TYPE_MS_STRUCT
|
||||
|
||||
cs_retuint8:
|
||||
movzx eax, BYTE PTR [ecx]
|
||||
jmp cs_epilogue
|
||||
|
||||
cs_retsint8:
|
||||
movsx eax, BYTE PTR [ecx]
|
||||
jmp cs_epilogue
|
||||
|
||||
cs_retuint16:
|
||||
movzx eax, WORD PTR [ecx]
|
||||
jmp cs_epilogue
|
||||
|
||||
cs_retsint16:
|
||||
movsx eax, WORD PTR [ecx]
|
||||
jmp cs_epilogue
|
||||
|
||||
cs_retint:
|
||||
mov eax, [ecx]
|
||||
jmp cs_epilogue
|
||||
|
||||
cs_retint64:
|
||||
mov eax, [ecx + 0]
|
||||
mov edx, [ecx + 4]
|
||||
jmp cs_epilogue
|
||||
|
||||
cs_retfloat:
|
||||
fld DWORD PTR [ecx]
|
||||
jmp cs_epilogue
|
||||
|
||||
cs_retdouble:
|
||||
fld QWORD PTR [ecx]
|
||||
jmp cs_epilogue
|
||||
|
||||
cs_retlongdouble:
|
||||
fld TBYTE PTR [ecx]
|
||||
jmp cs_epilogue
|
||||
|
||||
cs_retstruct:
|
||||
;; Caller expects us to pop struct return value pointer hidden arg.
|
||||
;; Epilogue code is autogenerated.
|
||||
ret 4
|
||||
|
||||
cs_retmsstruct:
|
||||
;; Caller expects us to return a pointer to the real return value.
|
||||
mov eax, ecx
|
||||
;; Caller doesn't expects us to pop struct return value pointer hidden arg.
|
||||
jmp cs_epilogue
|
||||
|
||||
cs_epilogue:
|
||||
;; Epilogue code is autogenerated.
|
||||
ret
|
||||
ffi_closure_SYSV ENDP
|
||||
|
||||
#if !FFI_NO_RAW_API
|
||||
|
||||
#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) AND NOT 3)
|
||||
#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
|
||||
#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
|
||||
#define CIF_FLAGS_OFFSET 20
|
||||
|
||||
ffi_closure_raw_THISCALL PROC NEAR USES esi FORCEFRAME
|
||||
sub esp, 36
|
||||
mov esi, [eax + RAW_CLOSURE_CIF_OFFSET] ;; closure->cif
|
||||
mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data
|
||||
mov [esp + 12], edx
|
||||
lea edx, [ebp + 12]
|
||||
jmp stubraw
|
||||
ffi_closure_raw_THISCALL ENDP
|
||||
|
||||
ffi_closure_raw_SYSV PROC NEAR USES esi FORCEFRAME
|
||||
;; the ffi_closure ctx is passed in eax by the trampoline.
|
||||
|
||||
sub esp, 40
|
||||
mov esi, [eax + RAW_CLOSURE_CIF_OFFSET] ;; closure->cif
|
||||
mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data
|
||||
mov [esp + 12], edx ;; user_data
|
||||
lea edx, [ebp + 8]
|
||||
stubraw::
|
||||
mov [esp + 8], edx ;; raw_args
|
||||
lea edx, [ebp - 24]
|
||||
mov [esp + 4], edx ;; &res
|
||||
mov [esp], esi ;; cif
|
||||
call DWORD PTR [eax + RAW_CLOSURE_FUN_OFFSET] ;; closure->fun
|
||||
mov eax, [esi + CIF_FLAGS_OFFSET] ;; cif->flags
|
||||
lea ecx, [ebp - 24]
|
||||
|
||||
cr_jumptable:
|
||||
jmp [cr_jumpdata + 4 * eax]
|
||||
cr_jumpdata:
|
||||
;; Do not insert anything here between the label and jump table.
|
||||
dd offset cr_epilogue ;; FFI_TYPE_VOID
|
||||
dd offset cr_retint ;; FFI_TYPE_INT
|
||||
dd offset cr_retfloat ;; FFI_TYPE_FLOAT
|
||||
dd offset cr_retdouble ;; FFI_TYPE_DOUBLE
|
||||
dd offset cr_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
||||
dd offset cr_retuint8 ;; FFI_TYPE_UINT8
|
||||
dd offset cr_retsint8 ;; FFI_TYPE_SINT8
|
||||
dd offset cr_retuint16 ;; FFI_TYPE_UINT16
|
||||
dd offset cr_retsint16 ;; FFI_TYPE_SINT16
|
||||
dd offset cr_retint ;; FFI_TYPE_UINT32
|
||||
dd offset cr_retint ;; FFI_TYPE_SINT32
|
||||
dd offset cr_retint64 ;; FFI_TYPE_UINT64
|
||||
dd offset cr_retint64 ;; FFI_TYPE_SINT64
|
||||
dd offset cr_epilogue ;; FFI_TYPE_STRUCT
|
||||
dd offset cr_retint ;; FFI_TYPE_POINTER
|
||||
dd offset cr_retsint8 ;; FFI_TYPE_SMALL_STRUCT_1B
|
||||
dd offset cr_retsint16 ;; FFI_TYPE_SMALL_STRUCT_2B
|
||||
dd offset cr_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
||||
dd offset cr_epilogue ;; FFI_TYPE_MS_STRUCT
|
||||
|
||||
cr_retuint8:
|
||||
movzx eax, BYTE PTR [ecx]
|
||||
jmp cr_epilogue
|
||||
|
||||
cr_retsint8:
|
||||
movsx eax, BYTE PTR [ecx]
|
||||
jmp cr_epilogue
|
||||
|
||||
cr_retuint16:
|
||||
movzx eax, WORD PTR [ecx]
|
||||
jmp cr_epilogue
|
||||
|
||||
cr_retsint16:
|
||||
movsx eax, WORD PTR [ecx]
|
||||
jmp cr_epilogue
|
||||
|
||||
cr_retint:
|
||||
mov eax, [ecx]
|
||||
jmp cr_epilogue
|
||||
|
||||
cr_retint64:
|
||||
mov eax, [ecx + 0]
|
||||
mov edx, [ecx + 4]
|
||||
jmp cr_epilogue
|
||||
|
||||
cr_retfloat:
|
||||
fld DWORD PTR [ecx]
|
||||
jmp cr_epilogue
|
||||
|
||||
cr_retdouble:
|
||||
fld QWORD PTR [ecx]
|
||||
jmp cr_epilogue
|
||||
|
||||
cr_retlongdouble:
|
||||
fld TBYTE PTR [ecx]
|
||||
jmp cr_epilogue
|
||||
|
||||
cr_epilogue:
|
||||
;; Epilogue code is autogenerated.
|
||||
ret
|
||||
ffi_closure_raw_SYSV ENDP
|
||||
|
||||
#endif /* !FFI_NO_RAW_API */
|
||||
|
||||
ffi_closure_STDCALL PROC NEAR FORCEFRAME
|
||||
;; the ffi_closure ctx is passed in eax by the trampoline.
|
||||
|
||||
sub esp, 40
|
||||
lea edx, [ebp - 24]
|
||||
mov [ebp - 12], edx ;; resp
|
||||
lea edx, [ebp + 12] ;; account for stub return address on stack
|
||||
mov [esp + 8], edx ;; args
|
||||
lea edx, [ebp - 12]
|
||||
mov [esp + 4], edx ;; &resp
|
||||
mov [esp], eax ;; closure
|
||||
call ffi_closure_SYSV_inner
|
||||
mov ecx, [ebp - 12]
|
||||
|
||||
cd_jumptable:
|
||||
jmp [cd_jumpdata + 4 * eax]
|
||||
cd_jumpdata:
|
||||
;; Do not insert anything here between the label and jump table.
|
||||
dd offset cd_epilogue ;; FFI_TYPE_VOID
|
||||
dd offset cd_retint ;; FFI_TYPE_INT
|
||||
dd offset cd_retfloat ;; FFI_TYPE_FLOAT
|
||||
dd offset cd_retdouble ;; FFI_TYPE_DOUBLE
|
||||
dd offset cd_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
||||
dd offset cd_retuint8 ;; FFI_TYPE_UINT8
|
||||
dd offset cd_retsint8 ;; FFI_TYPE_SINT8
|
||||
dd offset cd_retuint16 ;; FFI_TYPE_UINT16
|
||||
dd offset cd_retsint16 ;; FFI_TYPE_SINT16
|
||||
dd offset cd_retint ;; FFI_TYPE_UINT32
|
||||
dd offset cd_retint ;; FFI_TYPE_SINT32
|
||||
dd offset cd_retint64 ;; FFI_TYPE_UINT64
|
||||
dd offset cd_retint64 ;; FFI_TYPE_SINT64
|
||||
dd offset cd_epilogue ;; FFI_TYPE_STRUCT
|
||||
dd offset cd_retint ;; FFI_TYPE_POINTER
|
||||
dd offset cd_retsint8 ;; FFI_TYPE_SMALL_STRUCT_1B
|
||||
dd offset cd_retsint16 ;; FFI_TYPE_SMALL_STRUCT_2B
|
||||
dd offset cd_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
||||
|
||||
cd_retuint8:
|
||||
movzx eax, BYTE PTR [ecx]
|
||||
jmp cd_epilogue
|
||||
|
||||
cd_retsint8:
|
||||
movsx eax, BYTE PTR [ecx]
|
||||
jmp cd_epilogue
|
||||
|
||||
cd_retuint16:
|
||||
movzx eax, WORD PTR [ecx]
|
||||
jmp cd_epilogue
|
||||
|
||||
cd_retsint16:
|
||||
movsx eax, WORD PTR [ecx]
|
||||
jmp cd_epilogue
|
||||
|
||||
cd_retint:
|
||||
mov eax, [ecx]
|
||||
jmp cd_epilogue
|
||||
|
||||
cd_retint64:
|
||||
mov eax, [ecx + 0]
|
||||
mov edx, [ecx + 4]
|
||||
jmp cd_epilogue
|
||||
|
||||
cd_retfloat:
|
||||
fld DWORD PTR [ecx]
|
||||
jmp cd_epilogue
|
||||
|
||||
cd_retdouble:
|
||||
fld QWORD PTR [ecx]
|
||||
jmp cd_epilogue
|
||||
|
||||
cd_retlongdouble:
|
||||
fld TBYTE PTR [ecx]
|
||||
jmp cd_epilogue
|
||||
|
||||
cd_epilogue:
|
||||
;; Epilogue code is autogenerated.
|
||||
ret
|
||||
ffi_closure_STDCALL ENDP
|
||||
|
||||
_TEXT ENDS
|
||||
END
|
||||
@@ -1,156 +0,0 @@
|
||||
PUBLIC ffi_call_AMD64
|
||||
|
||||
EXTRN __chkstk:NEAR
|
||||
EXTRN ffi_closure_SYSV:NEAR
|
||||
|
||||
_TEXT SEGMENT
|
||||
|
||||
;;; ffi_closure_OUTER will be called with these registers set:
|
||||
;;; rax points to 'closure'
|
||||
;;; r11 contains a bit mask that specifies which of the
|
||||
;;; first four parameters are float or double
|
||||
;;;
|
||||
;;; It must move the parameters passed in registers to their stack location,
|
||||
;;; call ffi_closure_SYSV for the actual work, then return the result.
|
||||
;;;
|
||||
ffi_closure_OUTER PROC FRAME
|
||||
;; save actual arguments to their stack space.
|
||||
test r11, 1
|
||||
jne first_is_float
|
||||
mov QWORD PTR [rsp+8], rcx
|
||||
jmp second
|
||||
first_is_float:
|
||||
movlpd QWORD PTR [rsp+8], xmm0
|
||||
|
||||
second:
|
||||
test r11, 2
|
||||
jne second_is_float
|
||||
mov QWORD PTR [rsp+16], rdx
|
||||
jmp third
|
||||
second_is_float:
|
||||
movlpd QWORD PTR [rsp+16], xmm1
|
||||
|
||||
third:
|
||||
test r11, 4
|
||||
jne third_is_float
|
||||
mov QWORD PTR [rsp+24], r8
|
||||
jmp forth
|
||||
third_is_float:
|
||||
movlpd QWORD PTR [rsp+24], xmm2
|
||||
|
||||
forth:
|
||||
test r11, 8
|
||||
jne forth_is_float
|
||||
mov QWORD PTR [rsp+32], r9
|
||||
jmp done
|
||||
forth_is_float:
|
||||
movlpd QWORD PTR [rsp+32], xmm3
|
||||
|
||||
done:
|
||||
.ALLOCSTACK 40
|
||||
sub rsp, 40
|
||||
.ENDPROLOG
|
||||
mov rcx, rax ; context is first parameter
|
||||
mov rdx, rsp ; stack is second parameter
|
||||
add rdx, 40 ; correct our own area
|
||||
mov rax, ffi_closure_SYSV
|
||||
call rax ; call the real closure function
|
||||
;; Here, code is missing that handles float return values
|
||||
add rsp, 40
|
||||
movd xmm0, rax ; In case the closure returned a float.
|
||||
ret 0
|
||||
ffi_closure_OUTER ENDP
|
||||
|
||||
|
||||
;;; ffi_call_AMD64
|
||||
|
||||
stack$ = 0
|
||||
prepfunc$ = 32
|
||||
ecif$ = 40
|
||||
bytes$ = 48
|
||||
flags$ = 56
|
||||
rvalue$ = 64
|
||||
fn$ = 72
|
||||
|
||||
ffi_call_AMD64 PROC FRAME
|
||||
|
||||
mov QWORD PTR [rsp+32], r9
|
||||
mov QWORD PTR [rsp+24], r8
|
||||
mov QWORD PTR [rsp+16], rdx
|
||||
mov QWORD PTR [rsp+8], rcx
|
||||
.PUSHREG rbp
|
||||
push rbp
|
||||
.ALLOCSTACK 48
|
||||
sub rsp, 48 ; 00000030H
|
||||
.SETFRAME rbp, 32
|
||||
lea rbp, QWORD PTR [rsp+32]
|
||||
.ENDPROLOG
|
||||
|
||||
mov eax, DWORD PTR bytes$[rbp]
|
||||
add rax, 15
|
||||
and rax, -16
|
||||
call __chkstk
|
||||
sub rsp, rax
|
||||
lea rax, QWORD PTR [rsp+32]
|
||||
mov QWORD PTR stack$[rbp], rax
|
||||
|
||||
mov rdx, QWORD PTR ecif$[rbp]
|
||||
mov rcx, QWORD PTR stack$[rbp]
|
||||
call QWORD PTR prepfunc$[rbp]
|
||||
|
||||
mov rsp, QWORD PTR stack$[rbp]
|
||||
|
||||
movlpd xmm3, QWORD PTR [rsp+24]
|
||||
movd r9, xmm3
|
||||
|
||||
movlpd xmm2, QWORD PTR [rsp+16]
|
||||
movd r8, xmm2
|
||||
|
||||
movlpd xmm1, QWORD PTR [rsp+8]
|
||||
movd rdx, xmm1
|
||||
|
||||
movlpd xmm0, QWORD PTR [rsp]
|
||||
movd rcx, xmm0
|
||||
|
||||
call QWORD PTR fn$[rbp]
|
||||
ret_int$:
|
||||
cmp DWORD PTR flags$[rbp], 1 ; FFI_TYPE_INT
|
||||
jne ret_float$
|
||||
|
||||
mov rcx, QWORD PTR rvalue$[rbp]
|
||||
mov DWORD PTR [rcx], eax
|
||||
jmp SHORT ret_nothing$
|
||||
|
||||
ret_float$:
|
||||
cmp DWORD PTR flags$[rbp], 2 ; FFI_TYPE_FLOAT
|
||||
jne SHORT ret_double$
|
||||
|
||||
mov rax, QWORD PTR rvalue$[rbp]
|
||||
movlpd QWORD PTR [rax], xmm0
|
||||
jmp SHORT ret_nothing$
|
||||
|
||||
ret_double$:
|
||||
cmp DWORD PTR flags$[rbp], 3 ; FFI_TYPE_DOUBLE
|
||||
jne SHORT ret_int64$
|
||||
|
||||
mov rax, QWORD PTR rvalue$[rbp]
|
||||
movlpd QWORD PTR [rax], xmm0
|
||||
jmp SHORT ret_nothing$
|
||||
|
||||
ret_int64$:
|
||||
cmp DWORD PTR flags$[rbp], 12 ; FFI_TYPE_SINT64
|
||||
jne ret_nothing$
|
||||
|
||||
mov rcx, QWORD PTR rvalue$[rbp]
|
||||
mov QWORD PTR [rcx], rax
|
||||
jmp SHORT ret_nothing$
|
||||
|
||||
ret_nothing$:
|
||||
xor eax, eax
|
||||
|
||||
lea rsp, QWORD PTR [rbp+16]
|
||||
pop rbp
|
||||
ret 0
|
||||
ffi_call_AMD64 ENDP
|
||||
_TEXT ENDS
|
||||
END
|
||||
@@ -1,3 +1,12 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2015 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## libuv is still fast moving target
|
||||
## This file was last updated against a development HEAD revision of https://github.com/joyent/libuv/
|
||||
|
||||
@@ -136,7 +145,7 @@ type
|
||||
fs_event_init* {.importc: "fs_event_init".}: uint64
|
||||
|
||||
Loop* {.pure, final, importc: "uv_loop_t", header: "uv.h".} = object
|
||||
# ares_handles_* {.importc: "uv_ares_handles_".}: pointer # XXX: This seems to be a private field?
|
||||
# ares_handles_* {.importc: "uv_ares_handles_".}: pointer # XXX: This seems to be a private field?
|
||||
eio_want_poll_notifier* {.importc: "uv_eio_want_poll_notifier".}: TAsync
|
||||
eio_done_poll_notifier* {.importc: "uv_eio_done_poll_notifier".}: TAsync
|
||||
eio_poller* {.importc: "uv_eio_poller".}: TIdle
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2015 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
@@ -27,7 +35,7 @@ else:
|
||||
# ftMemo SQL_BINARY // SQL_VARCHAR
|
||||
#
|
||||
|
||||
type
|
||||
type
|
||||
TSqlChar* = char
|
||||
TSqlSmallInt* = int16
|
||||
SqlUSmallInt* = int16
|
||||
@@ -64,7 +72,7 @@ type
|
||||
# TSqlFloat: TSqlFloat, # Name conflict if we drop `T`
|
||||
TSqlHWND: SqlHWND].}
|
||||
|
||||
const # SQL data type codes
|
||||
const # SQL data type codes
|
||||
SQL_UNKNOWN_TYPE* = 0
|
||||
SQL_LONGVARCHAR* = (- 1)
|
||||
SQL_BINARY* = (- 2)
|
||||
@@ -95,8 +103,8 @@ const # SQL data type codes
|
||||
SQL_INTERVAL* = 10
|
||||
SQL_GUID* = - 11 # interval codes
|
||||
|
||||
when ODBCVER >= 0x0300:
|
||||
const
|
||||
when ODBCVER >= 0x0300:
|
||||
const
|
||||
SQL_CODE_YEAR* = 1
|
||||
SQL_CODE_MONTH* = 2
|
||||
SQL_CODE_DAY* = 3
|
||||
@@ -123,8 +131,8 @@ when ODBCVER >= 0x0300:
|
||||
SQL_INTERVAL_HOUR_TO_MINUTE* = 100 + SQL_CODE_HOUR_TO_MINUTE
|
||||
SQL_INTERVAL_HOUR_TO_SECOND* = 100 + SQL_CODE_HOUR_TO_SECOND
|
||||
SQL_INTERVAL_MINUTE_TO_SECOND* = 100 + SQL_CODE_MINUTE_TO_SECOND
|
||||
else:
|
||||
const
|
||||
else:
|
||||
const
|
||||
SQL_INTERVAL_YEAR* = - 80
|
||||
SQL_INTERVAL_MONTH* = - 81
|
||||
SQL_INTERVAL_YEAR_TO_MONTH* = - 82
|
||||
@@ -140,20 +148,20 @@ else:
|
||||
SQL_INTERVAL_MINUTE_TO_SECOND* = - 92
|
||||
|
||||
|
||||
when ODBCVER < 0x0300:
|
||||
const
|
||||
when ODBCVER < 0x0300:
|
||||
const
|
||||
SQL_UNICODE* = - 95
|
||||
SQL_UNICODE_VARCHAR* = - 96
|
||||
SQL_UNICODE_LONGVARCHAR* = - 97
|
||||
SQL_UNICODE_CHAR* = SQL_UNICODE
|
||||
else:
|
||||
# The previous definitions for SQL_UNICODE_ are historical and obsolete
|
||||
const
|
||||
else:
|
||||
# The previous definitions for SQL_UNICODE_ are historical and obsolete
|
||||
const
|
||||
SQL_UNICODE* = SQL_WCHAR
|
||||
SQL_UNICODE_VARCHAR* = SQL_WVARCHAR
|
||||
SQL_UNICODE_LONGVARCHAR* = SQL_WLONGVARCHAR
|
||||
SQL_UNICODE_CHAR* = SQL_WCHAR
|
||||
const # C datatype to SQL datatype mapping
|
||||
const # C datatype to SQL datatype mapping
|
||||
SQL_C_CHAR* = SQL_CHAR
|
||||
SQL_C_LONG* = SQL_INTEGER
|
||||
SQL_C_SHORT* = SQL_SMALLINT
|
||||
@@ -197,30 +205,30 @@ const # C datatype to SQL datatype mapping
|
||||
SQL_C_GUID* = SQL_GUID
|
||||
SQL_TYPE_NULL* = 0
|
||||
|
||||
when ODBCVER < 0x0300:
|
||||
const
|
||||
when ODBCVER < 0x0300:
|
||||
const
|
||||
SQL_TYPE_MIN* = SQL_BIT
|
||||
SQL_TYPE_MAX* = SQL_VARCHAR
|
||||
|
||||
const
|
||||
const
|
||||
SQL_C_VARBOOKMARK* = SQL_C_BINARY
|
||||
SQL_API_SQLDESCRIBEPARAM* = 58
|
||||
SQL_NO_TOTAL* = - 4
|
||||
|
||||
type
|
||||
SQL_DATE_STRUCT* {.final, pure.} = object
|
||||
type
|
||||
SQL_DATE_STRUCT* {.final, pure.} = object
|
||||
Year*: TSqlSmallInt
|
||||
Month*: SqlUSmallInt
|
||||
Day*: SqlUSmallInt
|
||||
|
||||
PSQL_DATE_STRUCT* = ptr SQL_DATE_STRUCT
|
||||
SQL_TIME_STRUCT* {.final, pure.} = object
|
||||
SQL_TIME_STRUCT* {.final, pure.} = object
|
||||
Hour*: SqlUSmallInt
|
||||
Minute*: SqlUSmallInt
|
||||
Second*: SqlUSmallInt
|
||||
|
||||
PSQL_TIME_STRUCT* = ptr SQL_TIME_STRUCT
|
||||
SQL_TIMESTAMP_STRUCT* {.final, pure.} = object
|
||||
SQL_TIMESTAMP_STRUCT* {.final, pure.} = object
|
||||
Year*: SqlUSmallInt
|
||||
Month*: SqlUSmallInt
|
||||
Day*: SqlUSmallInt
|
||||
@@ -231,34 +239,34 @@ type
|
||||
|
||||
PSQL_TIMESTAMP_STRUCT* = ptr SQL_TIMESTAMP_STRUCT
|
||||
|
||||
const
|
||||
const
|
||||
SQL_NAME_LEN* = 128
|
||||
SQL_OV_ODBC3* = 3
|
||||
SQL_OV_ODBC2* = 2
|
||||
SQL_ATTR_ODBC_VERSION* = 200 # Options for SQLDriverConnect
|
||||
SQL_ATTR_ODBC_VERSION* = 200 # Options for SQLDriverConnect
|
||||
SQL_DRIVER_NOPROMPT* = 0
|
||||
SQL_DRIVER_COMPLETE* = 1
|
||||
SQL_DRIVER_PROMPT* = 2
|
||||
SQL_DRIVER_COMPLETE_REQUIRED* = 3
|
||||
SQL_IS_POINTER* = (- 4) # whether an attribute is a pointer or not
|
||||
SQL_DRIVER_COMPLETE_REQUIRED* = 3
|
||||
SQL_IS_POINTER* = (- 4) # whether an attribute is a pointer or not
|
||||
SQL_IS_UINTEGER* = (- 5)
|
||||
SQL_IS_INTEGER* = (- 6)
|
||||
SQL_IS_USMALLINT* = (- 7)
|
||||
SQL_IS_SMALLINT* = (- 8) # SQLExtendedFetch "fFetchType" values
|
||||
SQL_IS_SMALLINT* = (- 8) # SQLExtendedFetch "fFetchType" values
|
||||
SQL_FETCH_BOOKMARK* = 8
|
||||
SQL_SCROLL_OPTIONS* = 44 # SQL_USE_BOOKMARKS options
|
||||
SQL_SCROLL_OPTIONS* = 44 # SQL_USE_BOOKMARKS options
|
||||
SQL_UB_OFF* = 0
|
||||
SQL_UB_ON* = 1
|
||||
SQL_UB_DEFAULT* = SQL_UB_OFF
|
||||
SQL_UB_FIXED* = SQL_UB_ON
|
||||
SQL_UB_VARIABLE* = 2 # SQL_SCROLL_OPTIONS masks
|
||||
SQL_UB_VARIABLE* = 2 # SQL_SCROLL_OPTIONS masks
|
||||
SQL_SO_FORWARD_ONLY* = 0x00000001
|
||||
SQL_SO_KEYSET_DRIVEN* = 0x00000002
|
||||
SQL_SO_DYNAMIC* = 0x00000004
|
||||
SQL_SO_MIXED* = 0x00000008
|
||||
SQL_SO_STATIC* = 0x00000010
|
||||
SQL_BOOKMARK_PERSISTENCE* = 82
|
||||
SQL_STATIC_SENSITIVITY* = 83 # SQL_BOOKMARK_PERSISTENCE values
|
||||
SQL_STATIC_SENSITIVITY* = 83 # SQL_BOOKMARK_PERSISTENCE values
|
||||
SQL_BP_CLOSE* = 0x00000001
|
||||
SQL_BP_DELETE* = 0x00000002
|
||||
SQL_BP_DROP* = 0x00000004
|
||||
@@ -275,32 +283,32 @@ const
|
||||
SQL_KEYSET_CURSOR_ATTRIBUTES1* = 150
|
||||
SQL_KEYSET_CURSOR_ATTRIBUTES2* = 151
|
||||
SQL_STATIC_CURSOR_ATTRIBUTES1* = 167
|
||||
SQL_STATIC_CURSOR_ATTRIBUTES2* = 168 # supported SQLFetchScroll FetchOrientation's
|
||||
SQL_STATIC_CURSOR_ATTRIBUTES2* = 168 # supported SQLFetchScroll FetchOrientation's
|
||||
SQL_CA1_NEXT* = 1
|
||||
SQL_CA1_ABSOLUTE* = 2
|
||||
SQL_CA1_RELATIVE* = 4
|
||||
SQL_CA1_BOOKMARK* = 8 # supported SQLSetPos LockType's
|
||||
SQL_CA1_BOOKMARK* = 8 # supported SQLSetPos LockType's
|
||||
SQL_CA1_LOCK_NO_CHANGE* = 0x00000040
|
||||
SQL_CA1_LOCK_EXCLUSIVE* = 0x00000080
|
||||
SQL_CA1_LOCK_UNLOCK* = 0x00000100 # supported SQLSetPos Operations
|
||||
SQL_CA1_LOCK_UNLOCK* = 0x00000100 # supported SQLSetPos Operations
|
||||
SQL_CA1_POS_POSITION* = 0x00000200
|
||||
SQL_CA1_POS_UPDATE* = 0x00000400
|
||||
SQL_CA1_POS_DELETE* = 0x00000800
|
||||
SQL_CA1_POS_REFRESH* = 0x00001000 # positioned updates and deletes
|
||||
SQL_CA1_POS_REFRESH* = 0x00001000 # positioned updates and deletes
|
||||
SQL_CA1_POSITIONED_UPDATE* = 0x00002000
|
||||
SQL_CA1_POSITIONED_DELETE* = 0x00004000
|
||||
SQL_CA1_SELECT_FOR_UPDATE* = 0x00008000 # supported SQLBulkOperations operations
|
||||
SQL_CA1_SELECT_FOR_UPDATE* = 0x00008000 # supported SQLBulkOperations operations
|
||||
SQL_CA1_BULK_ADD* = 0x00010000
|
||||
SQL_CA1_BULK_UPDATE_BY_BOOKMARK* = 0x00020000
|
||||
SQL_CA1_BULK_DELETE_BY_BOOKMARK* = 0x00040000
|
||||
SQL_CA1_BULK_FETCH_BY_BOOKMARK* = 0x00080000 # supported values for SQL_ATTR_SCROLL_CONCURRENCY
|
||||
SQL_CA1_BULK_FETCH_BY_BOOKMARK* = 0x00080000 # supported values for SQL_ATTR_SCROLL_CONCURRENCY
|
||||
SQL_CA2_READ_ONLY_CONCURRENCY* = 1
|
||||
SQL_CA2_LOCK_CONCURRENCY* = 2
|
||||
SQL_CA2_OPT_ROWVER_CONCURRENCY* = 4
|
||||
SQL_CA2_OPT_VALUES_CONCURRENCY* = 8 # sensitivity of the cursor to its own inserts, deletes, and updates
|
||||
SQL_CA2_OPT_VALUES_CONCURRENCY* = 8 # sensitivity of the cursor to its own inserts, deletes, and updates
|
||||
SQL_CA2_SENSITIVITY_ADDITIONS* = 0x00000010
|
||||
SQL_CA2_SENSITIVITY_DELETIONS* = 0x00000020
|
||||
SQL_CA2_SENSITIVITY_UPDATES* = 0x00000040 # semantics of SQL_ATTR_MAX_ROWS
|
||||
SQL_CA2_SENSITIVITY_UPDATES* = 0x00000040 # semantics of SQL_ATTR_MAX_ROWS
|
||||
SQL_CA2_MAX_ROWS_SELECT* = 0x00000080
|
||||
SQL_CA2_MAX_ROWS_INSERT* = 0x00000100
|
||||
SQL_CA2_MAX_ROWS_DELETE* = 0x00000200
|
||||
@@ -308,25 +316,25 @@ const
|
||||
SQL_CA2_MAX_ROWS_CATALOG* = 0x00000800
|
||||
SQL_CA2_MAX_ROWS_AFFECTS_ALL* = (SQL_CA2_MAX_ROWS_SELECT or
|
||||
SQL_CA2_MAX_ROWS_INSERT or SQL_CA2_MAX_ROWS_DELETE or
|
||||
SQL_CA2_MAX_ROWS_UPDATE or SQL_CA2_MAX_ROWS_CATALOG) # semantics of
|
||||
# SQL_DIAG_CURSOR_ROW_COUNT
|
||||
SQL_CA2_MAX_ROWS_UPDATE or SQL_CA2_MAX_ROWS_CATALOG) # semantics of
|
||||
# SQL_DIAG_CURSOR_ROW_COUNT
|
||||
SQL_CA2_CRC_EXACT* = 0x00001000
|
||||
SQL_CA2_CRC_APPROXIMATE* = 0x00002000 # the kinds of positioned statements that can be simulated
|
||||
SQL_CA2_CRC_APPROXIMATE* = 0x00002000 # the kinds of positioned statements that can be simulated
|
||||
SQL_CA2_SIMULATE_NON_UNIQUE* = 0x00004000
|
||||
SQL_CA2_SIMULATE_TRY_UNIQUE* = 0x00008000
|
||||
SQL_CA2_SIMULATE_UNIQUE* = 0x00010000 # Operations in SQLBulkOperations
|
||||
SQL_CA2_SIMULATE_UNIQUE* = 0x00010000 # Operations in SQLBulkOperations
|
||||
SQL_ADD* = 4
|
||||
SQL_SETPOS_MAX_OPTION_VALUE* = SQL_ADD
|
||||
SQL_UPDATE_BY_BOOKMARK* = 5
|
||||
SQL_DELETE_BY_BOOKMARK* = 6
|
||||
SQL_FETCH_BY_BOOKMARK* = 7 # Operations in SQLSetPos
|
||||
SQL_FETCH_BY_BOOKMARK* = 7 # Operations in SQLSetPos
|
||||
SQL_POSITION* = 0
|
||||
SQL_REFRESH* = 1
|
||||
SQL_UPDATE* = 2
|
||||
SQL_DELETE* = 3 # Lock options in SQLSetPos
|
||||
SQL_DELETE* = 3 # Lock options in SQLSetPos
|
||||
SQL_LOCK_NO_CHANGE* = 0
|
||||
SQL_LOCK_EXCLUSIVE* = 1
|
||||
SQL_LOCK_UNLOCK* = 2 # SQLExtendedFetch "rgfRowStatus" element values
|
||||
SQL_LOCK_UNLOCK* = 2 # SQLExtendedFetch "rgfRowStatus" element values
|
||||
SQL_ROW_SUCCESS* = 0
|
||||
SQL_ROW_DELETED* = 1
|
||||
SQL_ROW_UPDATED* = 2
|
||||
@@ -336,10 +344,10 @@ const
|
||||
SQL_ROW_SUCCESS_WITH_INFO* = 6
|
||||
SQL_ROW_PROCEED* = 0
|
||||
SQL_ROW_IGNORE* = 1
|
||||
SQL_MAX_DSN_LENGTH* = 32 # maximum data source name size
|
||||
SQL_MAX_DSN_LENGTH* = 32 # maximum data source name size
|
||||
SQL_MAX_OPTION_STRING_LENGTH* = 256
|
||||
SQL_ODBC_CURSORS* = 110
|
||||
SQL_ATTR_ODBC_CURSORS* = SQL_ODBC_CURSORS # SQL_ODBC_CURSORS options
|
||||
SQL_ATTR_ODBC_CURSORS* = SQL_ODBC_CURSORS # SQL_ODBC_CURSORS options
|
||||
SQL_CUR_USE_IF_NEEDED* = 0
|
||||
SQL_CUR_USE_ODBC* = 1
|
||||
SQL_CUR_USE_DRIVER* = 2
|
||||
@@ -349,7 +357,7 @@ const
|
||||
SQL_PARAM_INPUT_OUTPUT* = 2
|
||||
SQL_RESULT_COL* = 3
|
||||
SQL_PARAM_OUTPUT* = 4
|
||||
SQL_RETURN_VALUE* = 5 # special length/indicator values
|
||||
SQL_RETURN_VALUE* = 5 # special length/indicator values
|
||||
SQL_NULL_DATA* = (- 1)
|
||||
SQL_DATA_AT_EXEC* = (- 2)
|
||||
SQL_SUCCESS* = 0
|
||||
@@ -358,20 +366,20 @@ const
|
||||
SQL_ERROR* = (- 1)
|
||||
SQL_INVALID_HANDLE* = (- 2)
|
||||
SQL_STILL_EXECUTING* = 2
|
||||
SQL_NEED_DATA* = 99 # flags for null-terminated string
|
||||
SQL_NTS* = (- 3) # maximum message length
|
||||
SQL_MAX_MESSAGE_LENGTH* = 512 # date/time length constants
|
||||
SQL_NEED_DATA* = 99 # flags for null-terminated string
|
||||
SQL_NTS* = (- 3) # maximum message length
|
||||
SQL_MAX_MESSAGE_LENGTH* = 512 # date/time length constants
|
||||
SQL_DATE_LEN* = 10
|
||||
SQL_TIME_LEN* = 8 # add P+1 if precision is nonzero
|
||||
SQL_TIMESTAMP_LEN* = 19 # add P+1 if precision is nonzero
|
||||
# handle type identifiers
|
||||
SQL_TIME_LEN* = 8 # add P+1 if precision is nonzero
|
||||
SQL_TIMESTAMP_LEN* = 19 # add P+1 if precision is nonzero
|
||||
# handle type identifiers
|
||||
SQL_HANDLE_ENV* = 1
|
||||
SQL_HANDLE_DBC* = 2
|
||||
SQL_HANDLE_STMT* = 3
|
||||
SQL_HANDLE_DESC* = 4 # environment attribute
|
||||
SQL_ATTR_OUTPUT_NTS* = 10001 # connection attributes
|
||||
SQL_HANDLE_DESC* = 4 # environment attribute
|
||||
SQL_ATTR_OUTPUT_NTS* = 10001 # connection attributes
|
||||
SQL_ATTR_AUTO_IPD* = 10001
|
||||
SQL_ATTR_METADATA_ID* = 10014 # statement attributes
|
||||
SQL_ATTR_METADATA_ID* = 10014 # statement attributes
|
||||
SQL_ATTR_APP_ROW_DESC* = 10010
|
||||
SQL_ATTR_APP_PARAM_DESC* = 10011
|
||||
SQL_ATTR_IMP_ROW_DESC* = 10012
|
||||
@@ -434,21 +442,21 @@ const
|
||||
SQL_MODE_DEFAULT* = SQL_MODE_READ_WRITE #* SQL_AUTOCOMMIT options */
|
||||
SQL_AUTOCOMMIT_OFF* = 0
|
||||
SQL_AUTOCOMMIT_ON* = 1
|
||||
SQL_AUTOCOMMIT_DEFAULT* = SQL_AUTOCOMMIT_ON # SQL_ATTR_CURSOR_SCROLLABLE values
|
||||
SQL_AUTOCOMMIT_DEFAULT* = SQL_AUTOCOMMIT_ON # SQL_ATTR_CURSOR_SCROLLABLE values
|
||||
SQL_NONSCROLLABLE* = 0
|
||||
SQL_SCROLLABLE* = 1 # SQL_CURSOR_TYPE options
|
||||
SQL_SCROLLABLE* = 1 # SQL_CURSOR_TYPE options
|
||||
SQL_CURSOR_FORWARD_ONLY* = 0
|
||||
SQL_CURSOR_KEYSET_DRIVEN* = 1
|
||||
SQL_CURSOR_DYNAMIC* = 2
|
||||
SQL_CURSOR_STATIC* = 3
|
||||
SQL_CURSOR_TYPE_DEFAULT* = SQL_CURSOR_FORWARD_ONLY # Default value
|
||||
# SQL_CONCURRENCY options
|
||||
SQL_CURSOR_TYPE_DEFAULT* = SQL_CURSOR_FORWARD_ONLY # Default value
|
||||
# SQL_CONCURRENCY options
|
||||
SQL_CONCUR_READ_ONLY* = 1
|
||||
SQL_CONCUR_LOCK* = 2
|
||||
SQL_CONCUR_ROWVER* = 3
|
||||
SQL_CONCUR_VALUES* = 4
|
||||
SQL_CONCUR_DEFAULT* = SQL_CONCUR_READ_ONLY # Default value
|
||||
# identifiers of fields in the SQL descriptor
|
||||
SQL_CONCUR_DEFAULT* = SQL_CONCUR_READ_ONLY # Default value
|
||||
# identifiers of fields in the SQL descriptor
|
||||
SQL_DESC_COUNT* = 1001
|
||||
SQL_DESC_TYPE* = 1002
|
||||
SQL_DESC_LENGTH* = 1003
|
||||
@@ -462,7 +470,7 @@ const
|
||||
SQL_DESC_NAME* = 1011
|
||||
SQL_DESC_UNNAMED* = 1012
|
||||
SQL_DESC_OCTET_LENGTH* = 1013
|
||||
SQL_DESC_ALLOC_TYPE* = 1099 # identifiers of fields in the diagnostics area
|
||||
SQL_DESC_ALLOC_TYPE* = 1099 # identifiers of fields in the diagnostics area
|
||||
SQL_DIAG_RETURNCODE* = 1
|
||||
SQL_DIAG_NUMBER* = 2
|
||||
SQL_DIAG_ROW_COUNT* = 3
|
||||
@@ -474,7 +482,7 @@ const
|
||||
SQL_DIAG_SUBCLASS_ORIGIN* = 9
|
||||
SQL_DIAG_CONNECTION_NAME* = 10
|
||||
SQL_DIAG_SERVER_NAME* = 11
|
||||
SQL_DIAG_DYNAMIC_FUNCTION_CODE* = 12 # dynamic function codes
|
||||
SQL_DIAG_DYNAMIC_FUNCTION_CODE* = 12 # dynamic function codes
|
||||
SQL_DIAG_ALTER_TABLE* = 4
|
||||
SQL_DIAG_CREATE_INDEX* = (- 1)
|
||||
SQL_DIAG_CREATE_TABLE* = 77
|
||||
@@ -490,36 +498,36 @@ const
|
||||
SQL_DIAG_REVOKE* = 59
|
||||
SQL_DIAG_SELECT_CURSOR* = 85
|
||||
SQL_DIAG_UNKNOWN_STATEMENT* = 0
|
||||
SQL_DIAG_UPDATE_WHERE* = 82 # Statement attribute values for cursor sensitivity
|
||||
SQL_DIAG_UPDATE_WHERE* = 82 # Statement attribute values for cursor sensitivity
|
||||
SQL_UNSPECIFIED* = 0
|
||||
SQL_INSENSITIVE* = 1
|
||||
SQL_SENSITIVE* = 2 # GetTypeInfo() request for all data types
|
||||
SQL_ALL_TYPES* = 0 # Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData()
|
||||
SQL_SENSITIVE* = 2 # GetTypeInfo() request for all data types
|
||||
SQL_ALL_TYPES* = 0 # Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData()
|
||||
SQL_DEFAULT* = 99 # SQLGetData() code indicating that the application row descriptor
|
||||
# specifies the data type
|
||||
SQL_ARD_TYPE* = (- 99) # SQL date/time type subcodes
|
||||
# specifies the data type
|
||||
SQL_ARD_TYPE* = (- 99) # SQL date/time type subcodes
|
||||
SQL_CODE_DATE* = 1
|
||||
SQL_CODE_TIME* = 2
|
||||
SQL_CODE_TIMESTAMP* = 3 # CLI option values
|
||||
SQL_CODE_TIMESTAMP* = 3 # CLI option values
|
||||
SQL_FALSE* = 0
|
||||
SQL_TRUE* = 1 # values of NULLABLE field in descriptor
|
||||
SQL_TRUE* = 1 # values of NULLABLE field in descriptor
|
||||
SQL_NO_NULLS* = 0
|
||||
SQL_NULLABLE* = 1 # Value returned by SQLGetTypeInfo() to denote that it is
|
||||
# not known whether or not a data type supports null values.
|
||||
SQL_NULLABLE_UNKNOWN* = 2
|
||||
# not known whether or not a data type supports null values.
|
||||
SQL_NULLABLE_UNKNOWN* = 2
|
||||
SQL_CLOSE* = 0
|
||||
SQL_DROP* = 1
|
||||
SQL_UNBIND* = 2
|
||||
SQL_RESET_PARAMS* = 3 # Codes used for FetchOrientation in SQLFetchScroll(),
|
||||
# and in SQLDataSources()
|
||||
# and in SQLDataSources()
|
||||
SQL_FETCH_NEXT* = 1
|
||||
SQL_FETCH_FIRST* = 2
|
||||
SQL_FETCH_FIRST_USER* = 31
|
||||
SQL_FETCH_FIRST_SYSTEM* = 32 # Other codes used for FetchOrientation in SQLFetchScroll()
|
||||
SQL_FETCH_FIRST_SYSTEM* = 32 # Other codes used for FetchOrientation in SQLFetchScroll()
|
||||
SQL_FETCH_LAST* = 3
|
||||
SQL_FETCH_PRIOR* = 4
|
||||
SQL_FETCH_ABSOLUTE* = 5
|
||||
SQL_FETCH_RELATIVE* = 6
|
||||
SQL_FETCH_RELATIVE* = 6
|
||||
SQL_NULL_HENV* = SqlHEnv(nil)
|
||||
SQL_NULL_HDBC* = SqlHDBC(nil)
|
||||
SQL_NULL_HSTMT* = SqlHStmt(nil)
|
||||
@@ -529,7 +537,7 @@ const
|
||||
SQL_SCOPE_TRANSACTION* = 1
|
||||
SQL_SCOPE_SESSION* = 2 #* Column types and scopes in SQLSpecialColumns. */
|
||||
SQL_BEST_ROWID* = 1
|
||||
SQL_ROWVER* = 2
|
||||
SQL_ROWVER* = 2
|
||||
SQL_ROW_IDENTIFIER* = 1 #* Reserved values for UNIQUE argument of SQLStatistics() */
|
||||
SQL_INDEX_UNIQUE* = 0
|
||||
SQL_INDEX_ALL* = 1 #* Reserved values for RESERVED argument of SQLStatistics() */
|
||||
@@ -538,13 +546,13 @@ const
|
||||
SQL_TABLE_STAT* = 0
|
||||
SQL_INDEX_CLUSTERED* = 1
|
||||
SQL_INDEX_HASHED* = 2
|
||||
SQL_INDEX_OTHER* = 3
|
||||
SQL_INDEX_OTHER* = 3
|
||||
SQL_SCROLL_CONCURRENCY* = 43
|
||||
SQL_TXN_CAPABLE* = 46
|
||||
SQL_TRANSACTION_CAPABLE* = SQL_TXN_CAPABLE
|
||||
SQL_USER_NAME* = 47
|
||||
SQL_TXN_ISOLATION_OPTION* = 72
|
||||
SQL_TRANSACTION_ISOLATION_OPTION* = SQL_TXN_ISOLATION_OPTION
|
||||
SQL_TRANSACTION_ISOLATION_OPTION* = SQL_TXN_ISOLATION_OPTION
|
||||
SQL_OJ_CAPABILITIES* = 115
|
||||
SQL_OUTER_JOIN_CAPABILITIES* = SQL_OJ_CAPABILITIES
|
||||
SQL_XOPEN_CLI_YEAR* = 10000
|
||||
@@ -570,10 +578,10 @@ const
|
||||
SQL_TXN_REPEATABLE_READ* = 4
|
||||
SQL_TRANSACTION_REPEATABLE_READ* = SQL_TXN_REPEATABLE_READ
|
||||
SQL_TXN_SERIALIZABLE* = 8
|
||||
SQL_TRANSACTION_SERIALIZABLE* = SQL_TXN_SERIALIZABLE
|
||||
SQL_TRANSACTION_SERIALIZABLE* = SQL_TXN_SERIALIZABLE
|
||||
SQL_SS_ADDITIONS* = 1
|
||||
SQL_SS_DELETIONS* = 2
|
||||
SQL_SS_UPDATES* = 4 # SQLColAttributes defines
|
||||
SQL_SS_UPDATES* = 4 # SQLColAttributes defines
|
||||
SQL_COLUMN_COUNT* = 0
|
||||
SQL_COLUMN_NAME* = 1
|
||||
SQL_COLUMN_TYPE* = 2
|
||||
@@ -633,166 +641,166 @@ const
|
||||
ODBC_CONFIG_SYS_DSN* = 5
|
||||
ODBC_REMOVE_SYS_DSN* = 6
|
||||
|
||||
proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: SqlHandle,
|
||||
proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: SqlHandle,
|
||||
OutputHandlePtr: var SqlHandle): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger,
|
||||
proc SQLSetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger,
|
||||
Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLGetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger,
|
||||
Value: SqlPointer, BufferLength: TSqlInteger,
|
||||
StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLGetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger,
|
||||
Value: SqlPointer, BufferLength: TSqlInteger,
|
||||
StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLFreeHandle*(HandleType: TSqlSmallInt, Handle: SqlHandle): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: SqlHandle,
|
||||
RecNumber: TSqlSmallInt, Sqlstate: PSQLCHAR,
|
||||
NativeError: var TSqlInteger, MessageText: PSQLCHAR,
|
||||
proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: SqlHandle,
|
||||
RecNumber: TSqlSmallInt, Sqlstate: PSQLCHAR,
|
||||
NativeError: var TSqlInteger, MessageText: PSQLCHAR,
|
||||
BufferLength: TSqlSmallInt, TextLength: var TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLGetDiagField*(HandleType: TSqlSmallInt, Handle: SqlHandle,
|
||||
RecNumber: TSqlSmallInt, DiagIdentifier: TSqlSmallInt,
|
||||
DiagInfoPtr: SqlPointer, BufferLength: TSqlSmallInt,
|
||||
proc SQLGetDiagField*(HandleType: TSqlSmallInt, Handle: SqlHandle,
|
||||
RecNumber: TSqlSmallInt, DiagIdentifier: TSqlSmallInt,
|
||||
DiagInfoPtr: SqlPointer, BufferLength: TSqlSmallInt,
|
||||
StringLengthPtr: var TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLConnect*(ConnectionHandle: SqlHDBC, ServerName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, UserName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, Authentication: PSQLCHAR,
|
||||
proc SQLConnect*(ConnectionHandle: SqlHDBC, ServerName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, UserName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, Authentication: PSQLCHAR,
|
||||
NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLDisconnect*(ConnectionHandle: SqlHDBC): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLDisconnect*(ConnectionHandle: SqlHDBC): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLDriverConnect*(hdbc: SqlHDBC, hwnd: SqlHWND, szCsin: cstring,
|
||||
szCLen: TSqlSmallInt, szCsout: cstring,
|
||||
cbCSMax: TSqlSmallInt, cbCsOut: var TSqlSmallInt,
|
||||
proc SQLDriverConnect*(hdbc: SqlHDBC, hwnd: SqlHWND, szCsin: cstring,
|
||||
szCLen: TSqlSmallInt, szCsout: cstring,
|
||||
cbCSMax: TSqlSmallInt, cbCsOut: var TSqlSmallInt,
|
||||
f: SqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLBrowseConnect*(hdbc: SqlHDBC, szConnStrIn: PSQLCHAR,
|
||||
cbConnStrIn: TSqlSmallInt, szConnStrOut: PSQLCHAR,
|
||||
cbConnStrOutMax: TSqlSmallInt,
|
||||
proc SQLBrowseConnect*(hdbc: SqlHDBC, szConnStrIn: PSQLCHAR,
|
||||
cbConnStrIn: TSqlSmallInt, szConnStrOut: PSQLCHAR,
|
||||
cbConnStrOutMax: TSqlSmallInt,
|
||||
cbConnStrOut: var TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLExecDirect*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR,
|
||||
proc SQLExecDirect*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR,
|
||||
TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLPrepare*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR,
|
||||
proc SQLPrepare*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR,
|
||||
TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLCloseCursor*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLCloseCursor*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLExecute*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLFetch*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLNumResultCols*(StatementHandle: SqlHStmt, ColumnCount: var TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLDescribeCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt,
|
||||
NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt,
|
||||
ColumnSize: var SqlUInteger,
|
||||
proc SQLDescribeCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt,
|
||||
NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt,
|
||||
ColumnSize: var SqlUInteger,
|
||||
DecimalDigits: var TSqlSmallInt, Nullable: var TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLFetchScroll*(StatementHandle: SqlHStmt, FetchOrientation: TSqlSmallInt,
|
||||
FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLFetchScroll*(StatementHandle: SqlHStmt, FetchOrientation: TSqlSmallInt,
|
||||
FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLExtendedFetch*(hstmt: SqlHStmt, fFetchType: SqlUSmallInt,
|
||||
irow: TSqlInteger, pcrow: PSQLUINTEGER,
|
||||
rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLExtendedFetch*(hstmt: SqlHStmt, fFetchType: SqlUSmallInt,
|
||||
irow: TSqlInteger, pcrow: PSQLUINTEGER,
|
||||
rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLGetData*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
TargetType: TSqlSmallInt, TargetValue: SqlPointer,
|
||||
proc SQLGetData*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
TargetType: TSqlSmallInt, TargetValue: SqlPointer,
|
||||
BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger,
|
||||
proc SQLSetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger,
|
||||
Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLGetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger,
|
||||
Value: SqlPointer, BufferLength: TSqlInteger,
|
||||
StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLGetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger,
|
||||
Value: SqlPointer, BufferLength: TSqlInteger,
|
||||
StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLGetInfo*(ConnectionHandle: SqlHDBC, InfoType: SqlUSmallInt,
|
||||
InfoValue: SqlPointer, BufferLength: TSqlSmallInt,
|
||||
StringLength: PSQLSMALLINT): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLGetInfo*(ConnectionHandle: SqlHDBC, InfoType: SqlUSmallInt,
|
||||
InfoValue: SqlPointer, BufferLength: TSqlSmallInt,
|
||||
StringLength: PSQLSMALLINT): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLBulkOperations*(StatementHandle: SqlHStmt, Operation: TSqlSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLPutData*(StatementHandle: SqlHStmt, Data: SqlPointer,
|
||||
proc SQLPutData*(StatementHandle: SqlHStmt, Data: SqlPointer,
|
||||
StrLen_or_Ind: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLBindCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
TargetType: TSqlSmallInt, TargetValue: SqlPointer,
|
||||
proc SQLBindCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
TargetType: TSqlSmallInt, TargetValue: SqlPointer,
|
||||
BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetPos*(hstmt: SqlHStmt, irow: SqlUSmallInt, fOption: SqlUSmallInt,
|
||||
proc SQLSetPos*(hstmt: SqlHStmt, irow: SqlUSmallInt, fOption: SqlUSmallInt,
|
||||
fLock: SqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLDataSources*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt,
|
||||
ServerName: PSQLCHAR, BufferLength1: TSqlSmallInt,
|
||||
NameLength1: PSQLSMALLINT, Description: PSQLCHAR,
|
||||
proc SQLDataSources*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt,
|
||||
ServerName: PSQLCHAR, BufferLength1: TSqlSmallInt,
|
||||
NameLength1: PSQLSMALLINT, Description: PSQLCHAR,
|
||||
BufferLength2: TSqlSmallInt, NameLength2: PSQLSMALLINT): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLDrivers*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt,
|
||||
DriverDescription: PSQLCHAR, BufferLength1: TSqlSmallInt,
|
||||
DescriptionLength1: PSQLSMALLINT, DriverAttributes: PSQLCHAR,
|
||||
proc SQLDrivers*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt,
|
||||
DriverDescription: PSQLCHAR, BufferLength1: TSqlSmallInt,
|
||||
DescriptionLength1: PSQLSMALLINT, DriverAttributes: PSQLCHAR,
|
||||
BufferLength2: TSqlSmallInt, AttributesLength2: PSQLSMALLINT): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetConnectAttr*(ConnectionHandle: SqlHDBC, Attribute: TSqlInteger,
|
||||
proc SQLSetConnectAttr*(ConnectionHandle: SqlHDBC, Attribute: TSqlInteger,
|
||||
Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLGetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR,
|
||||
proc SQLGetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR,
|
||||
BufferLength: TSqlSmallInt, NameLength: PSQLSMALLINT): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLSetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR,
|
||||
NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLSetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR,
|
||||
NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLRowCount*(StatementHandle: SqlHStmt, RowCount: var TSqlInteger): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLBindParameter*(hstmt: SqlHStmt, ipar: SqlUSmallInt,
|
||||
fParamType: TSqlSmallInt, fCType: TSqlSmallInt,
|
||||
fSqlType: TSqlSmallInt, cbColDef: SqlUInteger,
|
||||
ibScale: TSqlSmallInt, rgbValue: SqlPointer,
|
||||
proc SQLBindParameter*(hstmt: SqlHStmt, ipar: SqlUSmallInt,
|
||||
fParamType: TSqlSmallInt, fCType: TSqlSmallInt,
|
||||
fSqlType: TSqlSmallInt, cbColDef: SqlUInteger,
|
||||
ibScale: TSqlSmallInt, rgbValue: SqlPointer,
|
||||
cbValueMax: TSqlInteger, pcbValue: PSQLINTEGER): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLFreeStmt*(StatementHandle: SqlHStmt, Option: SqlUSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLColAttribute*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
FieldIdentifier: SqlUSmallInt,
|
||||
CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt,
|
||||
StringLength: PSQLSMALLINT,
|
||||
proc SQLColAttribute*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
|
||||
FieldIdentifier: SqlUSmallInt,
|
||||
CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt,
|
||||
StringLength: PSQLSMALLINT,
|
||||
NumericAttribute: SqlPointer): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: SqlHandle,
|
||||
CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: SqlHandle,
|
||||
CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLTables*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
|
||||
cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
|
||||
cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
|
||||
cbTableName: TSqlSmallInt, szTableType: PSQLCHAR,
|
||||
proc SQLTables*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
|
||||
cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
|
||||
cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
|
||||
cbTableName: TSqlSmallInt, szTableType: PSQLCHAR,
|
||||
cbTableType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLColumns*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
|
||||
cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
|
||||
cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
|
||||
cbTableName: TSqlSmallInt, szColumnName: PSQLCHAR,
|
||||
proc SQLColumns*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
|
||||
cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
|
||||
cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
|
||||
cbTableName: TSqlSmallInt, szColumnName: PSQLCHAR,
|
||||
cbColumnName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
|
||||
proc SQLSpecialColumns*(StatementHandle: SqlHStmt, IdentifierType: SqlUSmallInt,
|
||||
CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt,
|
||||
SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt,
|
||||
TableName: PSQLCHAR, NameLength3: TSqlSmallInt,
|
||||
Scope: SqlUSmallInt,
|
||||
proc SQLSpecialColumns*(StatementHandle: SqlHStmt, IdentifierType: SqlUSmallInt,
|
||||
CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt,
|
||||
SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt,
|
||||
TableName: PSQLCHAR, NameLength3: TSqlSmallInt,
|
||||
Scope: SqlUSmallInt,
|
||||
Nullable: SqlUSmallInt): TSqlSmallInt{.
|
||||
dynlib: odbclib, importc.}
|
||||
proc SQLProcedures*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
|
||||
cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
|
||||
cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
|
||||
cbTableName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLProcedures*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
|
||||
cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
|
||||
cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
|
||||
cbTableName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLPrimaryKeys*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, TableName: PSQLCHAR,
|
||||
NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLPrimaryKeys*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, TableName: PSQLCHAR,
|
||||
NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLProcedureColumns*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, ProcName: PSQLCHAR,
|
||||
NameLength3: TSqlSmallInt, ColumnName: PSQLCHAR,
|
||||
NameLength4: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
proc SQLProcedureColumns*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, ProcName: PSQLCHAR,
|
||||
NameLength3: TSqlSmallInt, ColumnName: PSQLCHAR,
|
||||
NameLength4: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
|
||||
importc.}
|
||||
proc SQLStatistics*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, TableName: PSQLCHAR,
|
||||
NameLength3: TSqlSmallInt, Unique: SqlUSmallInt,
|
||||
proc SQLStatistics*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
|
||||
NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
|
||||
NameLength2: TSqlSmallInt, TableName: PSQLCHAR,
|
||||
NameLength3: TSqlSmallInt, Unique: SqlUSmallInt,
|
||||
Reserved: SqlUSmallInt): TSqlSmallInt {.
|
||||
dynlib: odbclib, importc.}
|
||||
|
||||
|
||||
@@ -1,41 +1,11 @@
|
||||
#==============================================================================#
|
||||
# Project: Ararat Synapse | 003.004.001 #
|
||||
#==============================================================================#
|
||||
# Content: SSL support by OpenSSL #
|
||||
#==============================================================================#
|
||||
# Copyright (c)1999-2005, Lukas Gebauer #
|
||||
# All rights reserved. #
|
||||
# #
|
||||
# Redistribution and use in source and binary forms, with or without #
|
||||
# modification, are permitted provided that the following conditions are met: #
|
||||
# #
|
||||
# Redistributions of source code must retain the above copyright notice, this #
|
||||
# list of conditions and the following disclaimer. #
|
||||
# #
|
||||
# Redistributions in binary form must reproduce the above copyright notice, #
|
||||
# this list of conditions and the following disclaimer in the documentation #
|
||||
# and/or other materials provided with the distribution. #
|
||||
# #
|
||||
# Neither the name of Lukas Gebauer nor the names of its contributors may #
|
||||
# be used to endorse or promote products derived from this software without #
|
||||
# specific prior written permission. #
|
||||
# #
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" #
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE #
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE #
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR #
|
||||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL #
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR #
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER #
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT #
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY #
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH #
|
||||
# DAMAGE. #
|
||||
#==============================================================================#
|
||||
# The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).#
|
||||
# Portions created by Lukas Gebauer are Copyright (c)2002-2005. #
|
||||
# All Rights Reserved. #
|
||||
#==============================================================================#
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2015 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## OpenSSL support
|
||||
|
||||
@@ -43,8 +13,8 @@
|
||||
|
||||
const useWinVersion = defined(Windows) or defined(nimdoc)
|
||||
|
||||
when useWinVersion:
|
||||
const
|
||||
when useWinVersion:
|
||||
const
|
||||
DLLSSLName = "(ssleay32|libssl32).dll"
|
||||
DLLUtilName = "libeay32.dll"
|
||||
from winlean import SocketHandle
|
||||
@@ -56,12 +26,12 @@ else:
|
||||
DLLSSLName = "libssl" & versions & ".dylib"
|
||||
DLLUtilName = "libcrypto" & versions & ".dylib"
|
||||
else:
|
||||
const
|
||||
const
|
||||
DLLSSLName = "libssl.so" & versions
|
||||
DLLUtilName = "libcrypto.so" & versions
|
||||
from posix import SocketHandle
|
||||
|
||||
type
|
||||
type
|
||||
SslStruct {.final, pure.} = object
|
||||
SslPtr* = ptr SslStruct
|
||||
PSslPtr* = ptr SslPtr
|
||||
@@ -80,7 +50,7 @@ type
|
||||
PFunction* = proc () {.cdecl.}
|
||||
DES_cblock* = array[0..7, int8]
|
||||
PDES_cblock* = ptr DES_cblock
|
||||
des_ks_struct*{.final.} = object
|
||||
des_ks_struct*{.final.} = object
|
||||
ks*: DES_cblock
|
||||
weak_key*: cInt
|
||||
|
||||
@@ -88,7 +58,7 @@ type
|
||||
|
||||
{.deprecated: [PSSL: SslPtr, PSSL_CTX: SslCtx, PBIO: BIO].}
|
||||
|
||||
const
|
||||
const
|
||||
SSL_SENT_SHUTDOWN* = 1
|
||||
SSL_RECEIVED_SHUTDOWN* = 2
|
||||
EVP_MAX_MD_SIZE* = 16 + 20
|
||||
@@ -116,8 +86,8 @@ const
|
||||
SSL_CTRL_GET_FLAGS* = 13
|
||||
SSL_CTRL_EXTRA_CHAIN_CERT* = 14
|
||||
SSL_CTRL_SET_MSG_CALLBACK* = 15
|
||||
SSL_CTRL_SET_MSG_CALLBACK_ARG* = 16 # only applies to datagram connections
|
||||
SSL_CTRL_SET_MTU* = 17 # Stats
|
||||
SSL_CTRL_SET_MSG_CALLBACK_ARG* = 16 # only applies to datagram connections
|
||||
SSL_CTRL_SET_MTU* = 17 # Stats
|
||||
SSL_CTRL_SESS_NUMBER* = 20
|
||||
SSL_CTRL_SESS_CONNECT* = 21
|
||||
SSL_CTRL_SESS_CONNECT_GOOD* = 22
|
||||
@@ -204,7 +174,7 @@ const
|
||||
SSL_FILETYPE_ASN1* = 2
|
||||
SSL_FILETYPE_PEM* = 1
|
||||
EVP_PKEY_RSA* = 6 # libssl.dll
|
||||
|
||||
|
||||
BIO_C_SET_CONNECT = 100
|
||||
BIO_C_DO_STATE_MACHINE = 101
|
||||
BIO_C_GET_SSL = 110
|
||||
@@ -237,7 +207,7 @@ proc SSL_CTX_use_certificate_chain_file*(ctx: SslCtx, filename: cstring): cInt{.
|
||||
stdcall, dynlib: DLLSSLName, importc.}
|
||||
proc SSL_CTX_use_PrivateKey_file*(ctx: SslCtx,
|
||||
filename: cstring, typ: cInt): cInt{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SSL_CTX_check_private_key*(ctx: SslCtx): cInt{.cdecl, dynlib: DLLSSLName,
|
||||
proc SSL_CTX_check_private_key*(ctx: SslCtx): cInt{.cdecl, dynlib: DLLSSLName,
|
||||
importc.}
|
||||
|
||||
proc SSL_set_fd*(ssl: SslPtr, fd: SocketHandle): cint{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
@@ -256,7 +226,7 @@ proc BIO_new_ssl_connect*(ctx: SslCtx): BIO{.cdecl,
|
||||
dynlib: DLLSSLName, importc.}
|
||||
proc BIO_ctrl*(bio: BIO, cmd: cint, larg: int, arg: cstring): int{.cdecl,
|
||||
dynlib: DLLSSLName, importc.}
|
||||
proc BIO_get_ssl*(bio: BIO, ssl: ptr SslPtr): int =
|
||||
proc BIO_get_ssl*(bio: BIO, ssl: ptr SslPtr): int =
|
||||
return BIO_ctrl(bio, BIO_C_GET_SSL, 0, cast[cstring](ssl))
|
||||
proc BIO_set_conn_hostname*(bio: BIO, name: cstring): int =
|
||||
return BIO_ctrl(bio, BIO_C_SET_CONNECT, 0, name)
|
||||
@@ -266,16 +236,16 @@ proc BIO_do_connect*(bio: BIO): int =
|
||||
return BIO_do_handshake(bio)
|
||||
|
||||
when not defined(nimfix):
|
||||
proc BIO_read*(b: BIO, data: cstring, length: cInt): cInt{.cdecl,
|
||||
proc BIO_read*(b: BIO, data: cstring, length: cInt): cInt{.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc BIO_write*(b: BIO, data: cstring, length: cInt): cInt{.cdecl,
|
||||
proc BIO_write*(b: BIO, data: cstring, length: cInt): cInt{.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
|
||||
proc BIO_free*(b: BIO): cInt{.cdecl, dynlib: DLLUtilName, importc.}
|
||||
|
||||
proc ERR_print_errors_fp*(fp: File){.cdecl, dynlib: DLLSSLName, importc.}
|
||||
|
||||
proc ERR_error_string*(e: cInt, buf: cstring): cstring{.cdecl,
|
||||
proc ERR_error_string*(e: cInt, buf: cstring): cstring{.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc ERR_get_error*(): cInt{.cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc ERR_peek_last_error*(): cInt{.cdecl, dynlib: DLLUtilName, importc.}
|
||||
@@ -285,7 +255,7 @@ proc OpenSSL_add_all_algorithms*(){.cdecl, dynlib: DLLUtilName, importc: "OPENSS
|
||||
proc OPENSSL_config*(configName: cstring){.cdecl, dynlib: DLLSSLName, importc.}
|
||||
|
||||
when not useWinVersion:
|
||||
proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl,
|
||||
proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
|
||||
proc allocWrapper(size: int): pointer {.cdecl.} = alloc(size)
|
||||
@@ -375,7 +345,7 @@ proc ErrRemoveState*(pid: cInt){.cdecl, dynlib: DLLUtilName, importc: "ERR_remov
|
||||
when true:
|
||||
discard
|
||||
else:
|
||||
proc SslCtxSetCipherList*(arg0: PSSL_CTX, str: cstring): cInt{.cdecl,
|
||||
proc SslCtxSetCipherList*(arg0: PSSL_CTX, str: cstring): cInt{.cdecl,
|
||||
dynlib: DLLSSLName, importc.}
|
||||
proc SslCtxNew*(meth: PSSL_METHOD): PSSL_CTX{.cdecl,
|
||||
dynlib: DLLSSLName, importc.}
|
||||
@@ -391,12 +361,12 @@ else:
|
||||
proc SslMethodV3*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SslMethodTLSV1*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SslMethodV23*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SslCtxUsePrivateKey*(ctx: PSSL_CTX, pkey: SslPtr): cInt{.cdecl,
|
||||
proc SslCtxUsePrivateKey*(ctx: PSSL_CTX, pkey: SslPtr): cInt{.cdecl,
|
||||
dynlib: DLLSSLName, importc.}
|
||||
proc SslCtxUsePrivateKeyASN1*(pk: cInt, ctx: PSSL_CTX,
|
||||
d: cstring, length: int): cInt{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
|
||||
proc SslCtxUseCertificate*(ctx: PSSL_CTX, x: SslPtr): cInt{.cdecl,
|
||||
proc SslCtxUseCertificate*(ctx: PSSL_CTX, x: SslPtr): cInt{.cdecl,
|
||||
dynlib: DLLSSLName, importc.}
|
||||
proc SslCtxUseCertificateASN1*(ctx: PSSL_CTX, length: int, d: cstring): cInt{.
|
||||
cdecl, dynlib: DLLSSLName, importc.}
|
||||
@@ -404,9 +374,9 @@ else:
|
||||
# function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const filename: PChar):cInt;
|
||||
proc SslCtxUseCertificateChainFile*(ctx: PSSL_CTX, filename: cstring): cInt{.
|
||||
cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SslCtxSetDefaultPasswdCb*(ctx: PSSL_CTX, cb: PPasswdCb){.cdecl,
|
||||
proc SslCtxSetDefaultPasswdCb*(ctx: PSSL_CTX, cb: PPasswdCb){.cdecl,
|
||||
dynlib: DLLSSLName, importc.}
|
||||
proc SslCtxSetDefaultPasswdCbUserdata*(ctx: PSSL_CTX, u: SslPtr){.cdecl,
|
||||
proc SslCtxSetDefaultPasswdCbUserdata*(ctx: PSSL_CTX, u: SslPtr){.cdecl,
|
||||
dynlib: DLLSSLName, importc.}
|
||||
# function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):cInt;
|
||||
proc SslCtxLoadVerifyLocations*(ctx: PSSL_CTX, CAfile: cstring, CApath: cstring): cInt{.
|
||||
@@ -416,15 +386,15 @@ else:
|
||||
|
||||
proc SslConnect*(ssl: PSSL): cInt{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
|
||||
|
||||
|
||||
proc SslGetVersion*(ssl: PSSL): cstring{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SslGetPeerCertificate*(ssl: PSSL): PX509{.cdecl, dynlib: DLLSSLName,
|
||||
proc SslGetPeerCertificate*(ssl: PSSL): PX509{.cdecl, dynlib: DLLSSLName,
|
||||
importc.}
|
||||
proc SslCtxSetVerify*(ctx: PSSL_CTX, mode: cInt, arg2: PFunction){.cdecl,
|
||||
proc SslCtxSetVerify*(ctx: PSSL_CTX, mode: cInt, arg2: PFunction){.cdecl,
|
||||
dynlib: DLLSSLName, importc.}
|
||||
proc SSLGetCurrentCipher*(s: PSSL): SslPtr{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SSLCipherGetName*(c: SslPtr): cstring{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
proc SSLCipherGetBits*(c: SslPtr, alg_bits: var cInt): cInt{.cdecl,
|
||||
proc SSLCipherGetBits*(c: SslPtr, alg_bits: var cInt): cInt{.cdecl,
|
||||
dynlib: DLLSSLName, importc.}
|
||||
proc SSLGetVerifyResult*(ssl: PSSL): int{.cdecl, dynlib: DLLSSLName, importc.}
|
||||
# libeay.dll
|
||||
@@ -432,39 +402,39 @@ else:
|
||||
proc X509Free*(x: PX509){.cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc X509NameOneline*(a: PX509_NAME, buf: cstring, size: cInt): cstring{.
|
||||
cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc X509GetSubjectName*(a: PX509): PX509_NAME{.cdecl, dynlib: DLLUtilName,
|
||||
proc X509GetSubjectName*(a: PX509): PX509_NAME{.cdecl, dynlib: DLLUtilName,
|
||||
importc.}
|
||||
proc X509GetIssuerName*(a: PX509): PX509_NAME{.cdecl, dynlib: DLLUtilName,
|
||||
proc X509GetIssuerName*(a: PX509): PX509_NAME{.cdecl, dynlib: DLLUtilName,
|
||||
importc.}
|
||||
proc X509NameHash*(x: PX509_NAME): int{.cdecl, dynlib: DLLUtilName, importc.}
|
||||
# function SslX509Digest(data: PX509; typ: PEVP_MD; md: PChar; len: PcInt):cInt;
|
||||
proc X509Digest*(data: PX509, typ: PEVP_MD, md: cstring, length: var cInt): cInt{.
|
||||
cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc X509print*(b: PBIO, a: PX509): cInt{.cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc X509SetVersion*(x: PX509, version: cInt): cInt{.cdecl, dynlib: DLLUtilName,
|
||||
proc X509SetVersion*(x: PX509, version: cInt): cInt{.cdecl, dynlib: DLLUtilName,
|
||||
importc.}
|
||||
proc X509SetPubkey*(x: PX509, pkey: EVP_PKEY): cInt{.cdecl, dynlib: DLLUtilName,
|
||||
proc X509SetPubkey*(x: PX509, pkey: EVP_PKEY): cInt{.cdecl, dynlib: DLLUtilName,
|
||||
importc.}
|
||||
proc X509SetIssuerName*(x: PX509, name: PX509_NAME): cInt{.cdecl,
|
||||
proc X509SetIssuerName*(x: PX509, name: PX509_NAME): cInt{.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc X509NameAddEntryByTxt*(name: PX509_NAME, field: cstring, typ: cInt,
|
||||
proc X509NameAddEntryByTxt*(name: PX509_NAME, field: cstring, typ: cInt,
|
||||
bytes: cstring, length, loc, theSet: cInt): cInt{.
|
||||
cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc X509Sign*(x: PX509, pkey: EVP_PKEY, md: PEVP_MD): cInt{.cdecl,
|
||||
proc X509Sign*(x: PX509, pkey: EVP_PKEY, md: PEVP_MD): cInt{.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc X509GmtimeAdj*(s: PASN1_UTCTIME, adj: cInt): PASN1_UTCTIME{.cdecl,
|
||||
proc X509GmtimeAdj*(s: PASN1_UTCTIME, adj: cInt): PASN1_UTCTIME{.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc X509SetNotBefore*(x: PX509, tm: PASN1_UTCTIME): cInt{.cdecl,
|
||||
proc X509SetNotBefore*(x: PX509, tm: PASN1_UTCTIME): cInt{.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc X509SetNotAfter*(x: PX509, tm: PASN1_UTCTIME): cInt{.cdecl,
|
||||
proc X509SetNotAfter*(x: PX509, tm: PASN1_UTCTIME): cInt{.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc X509GetSerialNumber*(x: PX509): PASN1_cInt{.cdecl, dynlib: DLLUtilName,
|
||||
proc X509GetSerialNumber*(x: PX509): PASN1_cInt{.cdecl, dynlib: DLLUtilName,
|
||||
importc.}
|
||||
proc EvpPkeyNew*(): EVP_PKEY{.cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc EvpPkeyFree*(pk: EVP_PKEY){.cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc EvpPkeyAssign*(pkey: EVP_PKEY, typ: cInt, key: Prsa): cInt{.cdecl,
|
||||
proc EvpPkeyAssign*(pkey: EVP_PKEY, typ: cInt, key: Prsa): cInt{.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
proc EvpGetDigestByName*(Name: cstring): PEVP_MD{.cdecl, dynlib: DLLUtilName,
|
||||
proc EvpGetDigestByName*(Name: cstring): PEVP_MD{.cdecl, dynlib: DLLUtilName,
|
||||
importc.}
|
||||
proc EVPcleanup*(){.cdecl, dynlib: DLLUtilName, importc.}
|
||||
# function ErrErrorString(e: cInt; buf: PChar): PChar;
|
||||
@@ -475,7 +445,7 @@ else:
|
||||
proc CRYPTOcleanupAllExData*(){.cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc RandScreen*(){.cdecl, dynlib: DLLUtilName, importc.}
|
||||
|
||||
proc d2iPKCS12bio*(b: PBIO, Pkcs12: SslPtr): SslPtr{.cdecl, dynlib: DLLUtilName,
|
||||
proc d2iPKCS12bio*(b: PBIO, Pkcs12: SslPtr): SslPtr{.cdecl, dynlib: DLLUtilName,
|
||||
importc.}
|
||||
proc PKCS12parse*(p12: SslPtr, pass: cstring, pkey, cert, ca: var SslPtr): cint{.
|
||||
dynlib: DLLUtilName, importc, cdecl.}
|
||||
@@ -485,37 +455,37 @@ else:
|
||||
cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc Asn1UtctimeNew*(): PASN1_UTCTIME{.cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc Asn1UtctimeFree*(a: PASN1_UTCTIME){.cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc Asn1cIntSet*(a: PASN1_cInt, v: cInt): cInt{.cdecl, dynlib: DLLUtilName,
|
||||
proc Asn1cIntSet*(a: PASN1_cInt, v: cInt): cInt{.cdecl, dynlib: DLLUtilName,
|
||||
importc.}
|
||||
proc i2dX509bio*(b: PBIO, x: PX509): cInt{.cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc i2dPrivateKeyBio*(b: PBIO, pkey: EVP_PKEY): cInt{.cdecl,
|
||||
proc i2dPrivateKeyBio*(b: PBIO, pkey: EVP_PKEY): cInt{.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
# 3DES functions
|
||||
proc DESsetoddparity*(Key: des_cblock){.cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc DESsetkeychecked*(key: des_cblock, schedule: des_key_schedule): cInt{.
|
||||
cdecl, dynlib: DLLUtilName, importc.}
|
||||
proc DESecbencrypt*(Input: des_cblock, output: des_cblock, ks: des_key_schedule,
|
||||
proc DESecbencrypt*(Input: des_cblock, output: des_cblock, ks: des_key_schedule,
|
||||
enc: cInt){.cdecl, dynlib: DLLUtilName, importc.}
|
||||
# implementation
|
||||
|
||||
proc SSLSetMode(s: PSSL, mode: int): int =
|
||||
proc SSLSetMode(s: PSSL, mode: int): int =
|
||||
result = SSLctrl(s, SSL_CTRL_MODE, mode, nil)
|
||||
|
||||
proc SSLCTXGetMode(ctx: PSSL_CTX): int =
|
||||
proc SSLCTXGetMode(ctx: PSSL_CTX): int =
|
||||
result = SSLCTXctrl(ctx, SSL_CTRL_MODE, 0, nil)
|
||||
|
||||
proc SSLGetMode(s: PSSL): int =
|
||||
proc SSLGetMode(s: PSSL): int =
|
||||
result = SSLctrl(s, SSL_CTRL_MODE, 0, nil)
|
||||
|
||||
# <openssl/md5.h>
|
||||
type
|
||||
type
|
||||
MD5_LONG* = cuint
|
||||
const
|
||||
const
|
||||
MD5_CBLOCK* = 64
|
||||
MD5_LBLOCK* = int(MD5_CBLOCK div 4)
|
||||
MD5_DIGEST_LENGTH* = 16
|
||||
type
|
||||
MD5_CTX* = object
|
||||
type
|
||||
MD5_CTX* = object
|
||||
A,B,C,D,Nl,Nh: MD5_LONG
|
||||
data: array[MD5_LBLOCK, MD5_LONG]
|
||||
num: cuint
|
||||
@@ -532,7 +502,7 @@ proc md5_Transform*(c: var MD5_CTX; b: ptr cuchar){.ic.}
|
||||
from strutils import toHex,toLower
|
||||
|
||||
proc hexStr (buf:cstring): string =
|
||||
# turn md5s output into a nice hex str
|
||||
# turn md5s output into a nice hex str
|
||||
result = newStringOfCap(32)
|
||||
for i in 0 .. <16:
|
||||
result.add toHex(buf[i].ord, 2).toLower
|
||||
@@ -554,13 +524,13 @@ proc md5_File* (file: string): string {.raises: [IOError,Exception].} =
|
||||
|
||||
discard md5_final( buf[0].addr, ctx )
|
||||
f.close
|
||||
|
||||
|
||||
result = hexStr(buf)
|
||||
|
||||
proc md5_Str* (str:string): string {.raises:[IOError].} =
|
||||
##Generate MD5 hash for a string. Result is a 32 character
|
||||
#hex string with lowercase characters
|
||||
var
|
||||
var
|
||||
ctx: MD5_CTX
|
||||
res: array[MD5_DIGEST_LENGTH,char]
|
||||
input = str.cstring
|
||||
|
||||
@@ -1,38 +1,11 @@
|
||||
#************************************************
|
||||
# Perl-Compatible Regular Expressions *
|
||||
#************************************************
|
||||
# This is the public header file for the PCRE library, to be #included by
|
||||
# applications that call the PCRE functions.
|
||||
#
|
||||
# Copyright (c) 1997-2014 University of Cambridge
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2015 Andreas Rumpf
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# * Neither the name of the University of Cambridge nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
@@ -77,9 +50,9 @@ const
|
||||
# C4 Affects compile, exec, dfa_exec, study
|
||||
# C5 Affects compile, exec, study
|
||||
#
|
||||
# Options that can be set for pcre_exec() and/or pcre_dfa_exec() are flagged
|
||||
# with E and D, respectively. They take precedence over C3, C4, and C5 settings
|
||||
# passed from pcre_compile(). Those that are compatible with JIT execution are
|
||||
# Options that can be set for pcre_exec() and/or pcre_dfa_exec() are flagged
|
||||
# with E and D, respectively. They take precedence over C3, C4, and C5 settings
|
||||
# passed from pcre_compile(). Those that are compatible with JIT execution are
|
||||
# flagged with J.
|
||||
|
||||
const
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,12 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2015 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
# This module contains the definitions for structures and externs for
|
||||
# functions used by frontend postgres applications. It is based on
|
||||
# Postgresql's libpq-fe.h.
|
||||
@@ -8,43 +17,43 @@
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
when defined(windows):
|
||||
const
|
||||
dllName = "libpq.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
elif defined(macosx):
|
||||
const
|
||||
dllName = "libpq.dylib"
|
||||
else:
|
||||
const
|
||||
else:
|
||||
const
|
||||
dllName = "libpq.so(.5|)"
|
||||
type
|
||||
type
|
||||
POid* = ptr Oid
|
||||
Oid* = int32
|
||||
|
||||
const
|
||||
const
|
||||
ERROR_MSG_LENGTH* = 4096
|
||||
CMDSTATUS_LEN* = 40
|
||||
|
||||
type
|
||||
type
|
||||
SockAddr* = array[1..112, int8]
|
||||
PGresAttDesc*{.pure, final.} = object
|
||||
PGresAttDesc*{.pure, final.} = object
|
||||
name*: cstring
|
||||
adtid*: Oid
|
||||
adtsize*: int
|
||||
|
||||
PPGresAttDesc* = ptr PGresAttDesc
|
||||
PPPGresAttDesc* = ptr PPGresAttDesc
|
||||
PGresAttValue*{.pure, final.} = object
|
||||
PGresAttValue*{.pure, final.} = object
|
||||
length*: int32
|
||||
value*: cstring
|
||||
|
||||
PPGresAttValue* = ptr PGresAttValue
|
||||
PPPGresAttValue* = ptr PPGresAttValue
|
||||
PExecStatusType* = ptr ExecStatusType
|
||||
ExecStatusType* = enum
|
||||
PGRES_EMPTY_QUERY = 0, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PGRES_COPY_OUT,
|
||||
ExecStatusType* = enum
|
||||
PGRES_EMPTY_QUERY = 0, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PGRES_COPY_OUT,
|
||||
PGRES_COPY_IN, PGRES_BAD_RESPONSE, PGRES_NONFATAL_ERROR, PGRES_FATAL_ERROR
|
||||
PGlobjfuncs*{.pure, final.} = object
|
||||
PGlobjfuncs*{.pure, final.} = object
|
||||
fn_lo_open*: Oid
|
||||
fn_lo_close*: Oid
|
||||
fn_lo_creat*: Oid
|
||||
@@ -56,11 +65,11 @@ type
|
||||
|
||||
PPGlobjfuncs* = ptr PGlobjfuncs
|
||||
PConnStatusType* = ptr ConnStatusType
|
||||
ConnStatusType* = enum
|
||||
CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE,
|
||||
CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV,
|
||||
ConnStatusType* = enum
|
||||
CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE,
|
||||
CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV,
|
||||
CONNECTION_SSL_STARTUP, CONNECTION_NEEDED
|
||||
PGconn*{.pure, final.} = object
|
||||
PGconn*{.pure, final.} = object
|
||||
pghost*: cstring
|
||||
pgtty*: cstring
|
||||
pgport*: cstring
|
||||
@@ -82,7 +91,7 @@ type
|
||||
lobjfuncs*: PPGlobjfuncs
|
||||
|
||||
PPGconn* = ptr PGconn
|
||||
PGresult*{.pure, final.} = object
|
||||
PGresult*{.pure, final.} = object
|
||||
ntups*: int32
|
||||
numAttributes*: int32
|
||||
attDescs*: PPGresAttDesc
|
||||
@@ -95,18 +104,18 @@ type
|
||||
|
||||
PPGresult* = ptr PGresult
|
||||
PPostgresPollingStatusType* = ptr PostgresPollingStatusType
|
||||
PostgresPollingStatusType* = enum
|
||||
PGRES_POLLING_FAILED = 0, PGRES_POLLING_READING, PGRES_POLLING_WRITING,
|
||||
PostgresPollingStatusType* = enum
|
||||
PGRES_POLLING_FAILED = 0, PGRES_POLLING_READING, PGRES_POLLING_WRITING,
|
||||
PGRES_POLLING_OK, PGRES_POLLING_ACTIVE
|
||||
PPGTransactionStatusType* = ptr PGTransactionStatusType
|
||||
PGTransactionStatusType* = enum
|
||||
PQTRANS_IDLE, PQTRANS_ACTIVE, PQTRANS_INTRANS, PQTRANS_INERROR,
|
||||
PGTransactionStatusType* = enum
|
||||
PQTRANS_IDLE, PQTRANS_ACTIVE, PQTRANS_INTRANS, PQTRANS_INERROR,
|
||||
PQTRANS_UNKNOWN
|
||||
PPGVerbosity* = ptr PGVerbosity
|
||||
PGVerbosity* = enum
|
||||
PGVerbosity* = enum
|
||||
PQERRORS_TERSE, PQERRORS_DEFAULT, PQERRORS_VERBOSE
|
||||
PpgNotify* = ptr pgNotify
|
||||
pgNotify*{.pure, final.} = object
|
||||
pgNotify*{.pure, final.} = object
|
||||
relname*: cstring
|
||||
be_pid*: int32
|
||||
extra*: cstring
|
||||
@@ -116,7 +125,7 @@ type
|
||||
Ppqbool* = ptr pqbool
|
||||
pqbool* = char
|
||||
P_PQprintOpt* = ptr PQprintOpt
|
||||
PQprintOpt*{.pure, final.} = object
|
||||
PQprintOpt*{.pure, final.} = object
|
||||
header*: pqbool
|
||||
align*: pqbool
|
||||
standard*: pqbool
|
||||
@@ -129,7 +138,7 @@ type
|
||||
fieldName*: ptr cstring
|
||||
|
||||
P_PQconninfoOption* = ptr PQconninfoOption
|
||||
PQconninfoOption*{.pure, final.} = object
|
||||
PQconninfoOption*{.pure, final.} = object
|
||||
keyword*: cstring
|
||||
envvar*: cstring
|
||||
compiled*: cstring
|
||||
@@ -139,7 +148,7 @@ type
|
||||
dispsize*: int32
|
||||
|
||||
PPQArgBlock* = ptr PQArgBlock
|
||||
PQArgBlock*{.pure, final.} = object
|
||||
PQArgBlock*{.pure, final.} = object
|
||||
length*: int32
|
||||
isint*: int32
|
||||
p*: pointer
|
||||
@@ -148,27 +157,27 @@ type
|
||||
TPGlobjfuncs: Pglobjfuncs, TConnStatusType: ConnStatusType, TPGconn: Pgconn,
|
||||
TPGresult: PGresult].}
|
||||
|
||||
proc pqconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
|
||||
proc pqconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
|
||||
importc: "PQconnectStart".}
|
||||
proc pqconnectPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
|
||||
proc pqconnectPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
|
||||
dynlib: dllName, importc: "PQconnectPoll".}
|
||||
proc pqconnectdb*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
|
||||
proc pqconnectdb*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
|
||||
importc: "PQconnectdb".}
|
||||
proc pqsetdbLogin*(pghost: cstring, pgport: cstring, pgoptions: cstring,
|
||||
proc pqsetdbLogin*(pghost: cstring, pgport: cstring, pgoptions: cstring,
|
||||
pgtty: cstring, dbName: cstring, login: cstring, pwd: cstring): PPGconn{.
|
||||
cdecl, dynlib: dllName, importc: "PQsetdbLogin".}
|
||||
proc pqsetdb*(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): Ppgconn
|
||||
proc pqfinish*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQfinish".}
|
||||
proc pqconndefaults*(): PPQconninfoOption{.cdecl, dynlib: dllName,
|
||||
proc pqconndefaults*(): PPQconninfoOption{.cdecl, dynlib: dllName,
|
||||
importc: "PQconndefaults".}
|
||||
proc pqconninfoFree*(connOptions: PPQconninfoOption){.cdecl, dynlib: dllName,
|
||||
proc pqconninfoFree*(connOptions: PPQconninfoOption){.cdecl, dynlib: dllName,
|
||||
importc: "PQconninfoFree".}
|
||||
proc pqresetStart*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqresetStart*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQresetStart".}
|
||||
proc pqresetPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
|
||||
proc pqresetPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
|
||||
dynlib: dllName, importc: "PQresetPoll".}
|
||||
proc pqreset*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQreset".}
|
||||
proc pqrequestCancel*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqrequestCancel*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQrequestCancel".}
|
||||
proc pqdb*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQdb".}
|
||||
proc pquser*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQuser".}
|
||||
@@ -176,44 +185,44 @@ proc pqpass*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQpass".
|
||||
proc pqhost*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQhost".}
|
||||
proc pqport*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQport".}
|
||||
proc pqtty*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQtty".}
|
||||
proc pqoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQoptions".}
|
||||
proc pqstatus*(conn: PPGconn): ConnStatusType{.cdecl, dynlib: dllName,
|
||||
proc pqstatus*(conn: PPGconn): ConnStatusType{.cdecl, dynlib: dllName,
|
||||
importc: "PQstatus".}
|
||||
proc pqtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl,
|
||||
proc pqtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl,
|
||||
dynlib: dllName, importc: "PQtransactionStatus".}
|
||||
proc pqparameterStatus*(conn: PPGconn, paramName: cstring): cstring{.cdecl,
|
||||
proc pqparameterStatus*(conn: PPGconn, paramName: cstring): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "PQparameterStatus".}
|
||||
proc pqprotocolVersion*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqprotocolVersion*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQprotocolVersion".}
|
||||
proc pqerrorMessage*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqerrorMessage*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQerrorMessage".}
|
||||
proc pqsocket*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqsocket*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsocket".}
|
||||
proc pqbackendPID*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqbackendPID*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQbackendPID".}
|
||||
proc pqclientEncoding*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqclientEncoding*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQclientEncoding".}
|
||||
proc pqsetClientEncoding*(conn: PPGconn, encoding: cstring): int32{.cdecl,
|
||||
proc pqsetClientEncoding*(conn: PPGconn, encoding: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQsetClientEncoding".}
|
||||
when defined(USE_SSL):
|
||||
# Get the SSL structure associated with a connection
|
||||
proc pqgetssl*(conn: PPGconn): PSSL{.cdecl, dynlib: dllName,
|
||||
when defined(USE_SSL):
|
||||
# Get the SSL structure associated with a connection
|
||||
proc pqgetssl*(conn: PPGconn): PSSL{.cdecl, dynlib: dllName,
|
||||
importc: "PQgetssl".}
|
||||
proc pqsetErrorVerbosity*(conn: PPGconn, verbosity: PGVerbosity): PGVerbosity{.
|
||||
cdecl, dynlib: dllName, importc: "PQsetErrorVerbosity".}
|
||||
proc pqtrace*(conn: PPGconn, debug_port: File){.cdecl, dynlib: dllName,
|
||||
proc pqtrace*(conn: PPGconn, debug_port: File){.cdecl, dynlib: dllName,
|
||||
importc: "PQtrace".}
|
||||
proc pquntrace*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQuntrace".}
|
||||
proc pqsetNoticeReceiver*(conn: PPGconn, theProc: PQnoticeReceiver, arg: pointer): PQnoticeReceiver{.
|
||||
cdecl, dynlib: dllName, importc: "PQsetNoticeReceiver".}
|
||||
proc pqsetNoticeProcessor*(conn: PPGconn, theProc: PQnoticeProcessor,
|
||||
arg: pointer): PQnoticeProcessor{.cdecl,
|
||||
proc pqsetNoticeProcessor*(conn: PPGconn, theProc: PQnoticeProcessor,
|
||||
arg: pointer): PQnoticeProcessor{.cdecl,
|
||||
dynlib: dllName, importc: "PQsetNoticeProcessor".}
|
||||
proc pqexec*(conn: PPGconn, query: cstring): PPGresult{.cdecl, dynlib: dllName,
|
||||
proc pqexec*(conn: PPGconn, query: cstring): PPGresult{.cdecl, dynlib: dllName,
|
||||
importc: "PQexec".}
|
||||
proc pqexecParams*(conn: PPGconn, command: cstring, nParams: int32,
|
||||
paramTypes: POid, paramValues: cstringArray,
|
||||
proc pqexecParams*(conn: PPGconn, command: cstring, nParams: int32,
|
||||
paramTypes: POid, paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQexecParams".}
|
||||
proc pqprepare*(conn: PPGconn, stmtName, query: cstring, nParams: int32,
|
||||
@@ -222,87 +231,87 @@ proc pqexecPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
|
||||
paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQexecPrepared".}
|
||||
proc pqsendQuery*(conn: PPGconn, query: cstring): int32{.cdecl, dynlib: dllName,
|
||||
proc pqsendQuery*(conn: PPGconn, query: cstring): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsendQuery".}
|
||||
proc pqsendQueryParams*(conn: PPGconn, command: cstring, nParams: int32,
|
||||
paramTypes: POid, paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32,
|
||||
resultFormat: int32): int32{.cdecl, dynlib: dllName,
|
||||
proc pqsendQueryParams*(conn: PPGconn, command: cstring, nParams: int32,
|
||||
paramTypes: POid, paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32,
|
||||
resultFormat: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsendQueryParams".}
|
||||
proc pqsendQueryPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
|
||||
paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32,
|
||||
resultFormat: int32): int32{.cdecl, dynlib: dllName,
|
||||
proc pqsendQueryPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
|
||||
paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32,
|
||||
resultFormat: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsendQueryPrepared".}
|
||||
proc pqgetResult*(conn: PPGconn): PPGresult{.cdecl, dynlib: dllName,
|
||||
proc pqgetResult*(conn: PPGconn): PPGresult{.cdecl, dynlib: dllName,
|
||||
importc: "PQgetResult".}
|
||||
proc pqisBusy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqisBusy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQisBusy".}
|
||||
proc pqconsumeInput*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqconsumeInput*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQconsumeInput".}
|
||||
proc pqnotifies*(conn: PPGconn): PPGnotify{.cdecl, dynlib: dllName,
|
||||
proc pqnotifies*(conn: PPGconn): PPGnotify{.cdecl, dynlib: dllName,
|
||||
importc: "PQnotifies".}
|
||||
proc pqputCopyData*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQputCopyData".}
|
||||
proc pqputCopyEnd*(conn: PPGconn, errormsg: cstring): int32{.cdecl,
|
||||
proc pqputCopyEnd*(conn: PPGconn, errormsg: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQputCopyEnd".}
|
||||
proc pqgetCopyData*(conn: PPGconn, buffer: cstringArray, async: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetCopyData".}
|
||||
proc pqgetline*(conn: PPGconn, str: cstring, len: int32): int32{.cdecl,
|
||||
proc pqgetline*(conn: PPGconn, str: cstring, len: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQgetline".}
|
||||
proc pqputline*(conn: PPGconn, str: cstring): int32{.cdecl, dynlib: dllName,
|
||||
proc pqputline*(conn: PPGconn, str: cstring): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQputline".}
|
||||
proc pqgetlineAsync*(conn: PPGconn, buffer: cstring, bufsize: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetlineAsync".}
|
||||
proc pqputnbytes*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.cdecl,
|
||||
proc pqputnbytes*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQputnbytes".}
|
||||
proc pqendcopy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqendcopy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQendcopy".}
|
||||
proc pqsetnonblocking*(conn: PPGconn, arg: int32): int32{.cdecl,
|
||||
proc pqsetnonblocking*(conn: PPGconn, arg: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQsetnonblocking".}
|
||||
proc pqisnonblocking*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqisnonblocking*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQisnonblocking".}
|
||||
proc pqflush*(conn: PPGconn): int32{.cdecl, dynlib: dllName, importc: "PQflush".}
|
||||
proc pqfn*(conn: PPGconn, fnid: int32, result_buf, result_len: ptr int32,
|
||||
proc pqfn*(conn: PPGconn, fnid: int32, result_buf, result_len: ptr int32,
|
||||
result_is_int: int32, args: PPQArgBlock, nargs: int32): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQfn".}
|
||||
proc pqresultStatus*(res: PPGresult): ExecStatusType{.cdecl, dynlib: dllName,
|
||||
proc pqresultStatus*(res: PPGresult): ExecStatusType{.cdecl, dynlib: dllName,
|
||||
importc: "PQresultStatus".}
|
||||
proc pqresStatus*(status: ExecStatusType): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqresStatus*(status: ExecStatusType): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQresStatus".}
|
||||
proc pqresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQresultErrorMessage".}
|
||||
proc pqresultErrorField*(res: PPGresult, fieldcode: int32): cstring{.cdecl,
|
||||
proc pqresultErrorField*(res: PPGresult, fieldcode: int32): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "PQresultErrorField".}
|
||||
proc pqntuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
proc pqntuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQntuples".}
|
||||
proc pqnfields*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
proc pqnfields*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQnfields".}
|
||||
proc pqbinaryTuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
proc pqbinaryTuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQbinaryTuples".}
|
||||
proc pqfname*(res: PPGresult, field_num: int32): cstring{.cdecl,
|
||||
proc pqfname*(res: PPGresult, field_num: int32): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "PQfname".}
|
||||
proc pqfnumber*(res: PPGresult, field_name: cstring): int32{.cdecl,
|
||||
proc pqfnumber*(res: PPGresult, field_name: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQfnumber".}
|
||||
proc pqftable*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
|
||||
proc pqftable*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "PQftable".}
|
||||
proc pqftablecol*(res: PPGresult, field_num: int32): int32{.cdecl,
|
||||
proc pqftablecol*(res: PPGresult, field_num: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQftablecol".}
|
||||
proc pqfformat*(res: PPGresult, field_num: int32): int32{.cdecl,
|
||||
proc pqfformat*(res: PPGresult, field_num: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQfformat".}
|
||||
proc pqftype*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
|
||||
proc pqftype*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "PQftype".}
|
||||
proc pqfsize*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
|
||||
proc pqfsize*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQfsize".}
|
||||
proc pqfmod*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
|
||||
proc pqfmod*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQfmod".}
|
||||
proc pqcmdStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqcmdStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQcmdStatus".}
|
||||
proc pqoidStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqoidStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQoidStatus".}
|
||||
proc pqoidValue*(res: PPGresult): Oid{.cdecl, dynlib: dllName,
|
||||
proc pqoidValue*(res: PPGresult): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "PQoidValue".}
|
||||
proc pqcmdTuples*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqcmdTuples*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQcmdTuples".}
|
||||
proc pqgetvalue*(res: PPGresult, tup_num: int32, field_num: int32): cstring{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetvalue".}
|
||||
@@ -314,23 +323,23 @@ proc pqclear*(res: PPGresult){.cdecl, dynlib: dllName, importc: "PQclear".}
|
||||
proc pqfreemem*(p: pointer){.cdecl, dynlib: dllName, importc: "PQfreemem".}
|
||||
proc pqmakeEmptyPGresult*(conn: PPGconn, status: ExecStatusType): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQmakeEmptyPGresult".}
|
||||
proc pqescapeString*(till, `from`: cstring, len: int): int{.cdecl,
|
||||
proc pqescapeString*(till, `from`: cstring, len: int): int{.cdecl,
|
||||
dynlib: dllName, importc: "PQescapeString".}
|
||||
proc pqescapeBytea*(bintext: cstring, binlen: int, bytealen: var int): cstring{.
|
||||
cdecl, dynlib: dllName, importc: "PQescapeBytea".}
|
||||
proc pqunescapeBytea*(strtext: cstring, retbuflen: var int): cstring{.cdecl,
|
||||
proc pqunescapeBytea*(strtext: cstring, retbuflen: var int): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "PQunescapeBytea".}
|
||||
proc pqprint*(fout: File, res: PPGresult, ps: PPQprintOpt){.cdecl,
|
||||
proc pqprint*(fout: File, res: PPGresult, ps: PPQprintOpt){.cdecl,
|
||||
dynlib: dllName, importc: "PQprint".}
|
||||
proc pqdisplayTuples*(res: PPGresult, fp: File, fillAlign: int32,
|
||||
proc pqdisplayTuples*(res: PPGresult, fp: File, fillAlign: int32,
|
||||
fieldSep: cstring, printHeader: int32, quiet: int32){.
|
||||
cdecl, dynlib: dllName, importc: "PQdisplayTuples".}
|
||||
proc pqprintTuples*(res: PPGresult, fout: File, printAttName: int32,
|
||||
terseOutput: int32, width: int32){.cdecl, dynlib: dllName,
|
||||
proc pqprintTuples*(res: PPGresult, fout: File, printAttName: int32,
|
||||
terseOutput: int32, width: int32){.cdecl, dynlib: dllName,
|
||||
importc: "PQprintTuples".}
|
||||
proc lo_open*(conn: PPGconn, lobjId: Oid, mode: int32): int32{.cdecl,
|
||||
proc lo_open*(conn: PPGconn, lobjId: Oid, mode: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "lo_open".}
|
||||
proc lo_close*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName,
|
||||
proc lo_close*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "lo_close".}
|
||||
proc lo_read*(conn: PPGconn, fd: int32, buf: cstring, length: int): int32{.
|
||||
cdecl, dynlib: dllName, importc: "lo_read".}
|
||||
@@ -338,18 +347,18 @@ proc lo_write*(conn: PPGconn, fd: int32, buf: cstring, length: int): int32{.
|
||||
cdecl, dynlib: dllName, importc: "lo_write".}
|
||||
proc lo_lseek*(conn: PPGconn, fd: int32, offset: int32, whence: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "lo_lseek".}
|
||||
proc lo_creat*(conn: PPGconn, mode: int32): Oid{.cdecl, dynlib: dllName,
|
||||
proc lo_creat*(conn: PPGconn, mode: int32): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "lo_creat".}
|
||||
proc lo_tell*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName,
|
||||
proc lo_tell*(conn: PPGconn, fd: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "lo_tell".}
|
||||
proc lo_unlink*(conn: PPGconn, lobjId: Oid): int32{.cdecl, dynlib: dllName,
|
||||
proc lo_unlink*(conn: PPGconn, lobjId: Oid): int32{.cdecl, dynlib: dllName,
|
||||
importc: "lo_unlink".}
|
||||
proc lo_import*(conn: PPGconn, filename: cstring): Oid{.cdecl, dynlib: dllName,
|
||||
proc lo_import*(conn: PPGconn, filename: cstring): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "lo_import".}
|
||||
proc lo_export*(conn: PPGconn, lobjId: Oid, filename: cstring): int32{.cdecl,
|
||||
proc lo_export*(conn: PPGconn, lobjId: Oid, filename: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "lo_export".}
|
||||
proc pqmblen*(s: cstring, encoding: int32): int32{.cdecl, dynlib: dllName,
|
||||
proc pqmblen*(s: cstring, encoding: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQmblen".}
|
||||
proc pqenv2encoding*(): int32{.cdecl, dynlib: dllName, importc: "PQenv2encoding".}
|
||||
proc pqsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): PPgConn =
|
||||
proc pqsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): PPgConn =
|
||||
result = pqSetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, "", "")
|
||||
|
||||
@@ -1,279 +0,0 @@
|
||||
# history.h -- the names of functions that you can call in history.
|
||||
# Copyright (C) 1989-2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file contains the GNU History Library (History), a set of
|
||||
# routines for managing the text of previously typed lines.
|
||||
#
|
||||
# History is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# History 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. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with History. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
import readline
|
||||
|
||||
const
|
||||
historyDll = readlineDll
|
||||
|
||||
import times, rltypedefs
|
||||
|
||||
type
|
||||
Histdata* = pointer
|
||||
{.deprecated: [Thistdata: Histdata].}
|
||||
|
||||
# The structure used to store a history entry.
|
||||
|
||||
type
|
||||
HIST_ENTRY*{.pure, final.} = object
|
||||
line*: cstring
|
||||
timestamp*: cstring # char * rather than time_t for read/write
|
||||
data*: Histdata
|
||||
{.deprecated: [THIST_ENTRY: HIST_ENTRY].}
|
||||
|
||||
# Size of the history-library-managed space in history entry HS.
|
||||
|
||||
template HISTENT_BYTES*(hs: expr): expr =
|
||||
(strlen(hs.line) + strlen(hs.timestamp))
|
||||
|
||||
# A structure used to pass the current state of the history stuff around.
|
||||
|
||||
type
|
||||
HISTORY_STATE*{.pure, final.} = object
|
||||
entries*: ptr ptr HIST_ENTRY # Pointer to the entries themselves.
|
||||
offset*: cint # The location pointer within this array.
|
||||
length*: cint # Number of elements within this array.
|
||||
size*: cint # Number of slots allocated to this array.
|
||||
flags*: cint
|
||||
{.deprecated: [THISTORY_STATE: HISTORY_STATE].}
|
||||
|
||||
|
||||
# Flag values for the `flags' member of HISTORY_STATE.
|
||||
|
||||
const
|
||||
HS_STIFLED* = 0x00000001
|
||||
|
||||
# Initialization and state management.
|
||||
# Begin a session in which the history functions might be used. This
|
||||
# just initializes the interactive variables.
|
||||
|
||||
proc using_history*(){.cdecl, importc: "using_history", dynlib: historyDll.}
|
||||
# Return the current HISTORY_STATE of the history.
|
||||
|
||||
proc history_get_history_state*(): ptr HISTORY_STATE{.cdecl,
|
||||
importc: "history_get_history_state", dynlib: historyDll.}
|
||||
# Set the state of the current history array to STATE.
|
||||
|
||||
proc history_set_history_state*(a2: ptr HISTORY_STATE){.cdecl,
|
||||
importc: "history_set_history_state", dynlib: historyDll.}
|
||||
# Manage the history list.
|
||||
# Place STRING at the end of the history list.
|
||||
# The associated data field (if any) is set to NULL.
|
||||
|
||||
proc add_history*(a2: cstring){.cdecl, importc: "add_history",
|
||||
dynlib: historyDll.}
|
||||
# Change the timestamp associated with the most recent history entry to
|
||||
# STRING.
|
||||
|
||||
proc add_history_time*(a2: cstring){.cdecl, importc: "add_history_time",
|
||||
dynlib: historyDll.}
|
||||
# A reasonably useless function, only here for completeness. WHICH
|
||||
# is the magic number that tells us which element to delete. The
|
||||
# elements are numbered from 0.
|
||||
|
||||
proc remove_history*(a2: cint): ptr HIST_ENTRY{.cdecl,
|
||||
importc: "remove_history", dynlib: historyDll.}
|
||||
# Free the history entry H and return any application-specific data
|
||||
# associated with it.
|
||||
|
||||
proc free_history_entry*(a2: ptr HIST_ENTRY): Histdata{.cdecl,
|
||||
importc: "free_history_entry", dynlib: historyDll.}
|
||||
# Make the history entry at WHICH have LINE and DATA. This returns
|
||||
# the old entry so you can dispose of the data. In the case of an
|
||||
# invalid WHICH, a NULL pointer is returned.
|
||||
|
||||
proc replace_history_entry*(a2: cint, a3: cstring, a4: Histdata): ptr HIST_ENTRY{.
|
||||
cdecl, importc: "replace_history_entry", dynlib: historyDll.}
|
||||
# Clear the history list and start over.
|
||||
|
||||
proc clear_history*(){.cdecl, importc: "clear_history", dynlib: historyDll.}
|
||||
# Stifle the history list, remembering only MAX number of entries.
|
||||
|
||||
proc stifle_history*(a2: cint){.cdecl, importc: "stifle_history",
|
||||
dynlib: historyDll.}
|
||||
# Stop stifling the history. This returns the previous amount the
|
||||
# history was stifled by. The value is positive if the history was
|
||||
# stifled, negative if it wasn't.
|
||||
|
||||
proc unstifle_history*(): cint{.cdecl, importc: "unstifle_history",
|
||||
dynlib: historyDll.}
|
||||
# Return 1 if the history is stifled, 0 if it is not.
|
||||
|
||||
proc history_is_stifled*(): cint{.cdecl, importc: "history_is_stifled",
|
||||
dynlib: historyDll.}
|
||||
# Information about the history list.
|
||||
# Return a NULL terminated array of HIST_ENTRY which is the current input
|
||||
# history. Element 0 of this list is the beginning of time. If there
|
||||
# is no history, return NULL.
|
||||
|
||||
proc history_list*(): ptr ptr HIST_ENTRY{.cdecl, importc: "history_list",
|
||||
dynlib: historyDll.}
|
||||
# Returns the number which says what history element we are now
|
||||
# looking at.
|
||||
|
||||
proc where_history*(): cint{.cdecl, importc: "where_history", dynlib: historyDll.}
|
||||
# Return the history entry at the current position, as determined by
|
||||
# history_offset. If there is no entry there, return a NULL pointer.
|
||||
|
||||
proc current_history*(): ptr HIST_ENTRY{.cdecl, importc: "current_history",
|
||||
dynlib: historyDll.}
|
||||
# Return the history entry which is logically at OFFSET in the history
|
||||
# array. OFFSET is relative to history_base.
|
||||
|
||||
proc history_get*(a2: cint): ptr HIST_ENTRY{.cdecl, importc: "history_get",
|
||||
dynlib: historyDll.}
|
||||
# Return the timestamp associated with the HIST_ENTRY * passed as an
|
||||
# argument
|
||||
|
||||
proc history_get_time*(a2: ptr HIST_ENTRY): Time{.cdecl,
|
||||
importc: "history_get_time", dynlib: historyDll.}
|
||||
# Return the number of bytes that the primary history entries are using.
|
||||
# This just adds up the lengths of the_history->lines.
|
||||
|
||||
proc history_total_bytes*(): cint{.cdecl, importc: "history_total_bytes",
|
||||
dynlib: historyDll.}
|
||||
# Moving around the history list.
|
||||
# Set the position in the history list to POS.
|
||||
|
||||
proc history_set_pos*(a2: cint): cint{.cdecl, importc: "history_set_pos",
|
||||
dynlib: historyDll.}
|
||||
# Back up history_offset to the previous history entry, and return
|
||||
# a pointer to that entry. If there is no previous entry, return
|
||||
# a NULL pointer.
|
||||
|
||||
proc previous_history*(): ptr HIST_ENTRY{.cdecl, importc: "previous_history",
|
||||
dynlib: historyDll.}
|
||||
# Move history_offset forward to the next item in the input_history,
|
||||
# and return the a pointer to that entry. If there is no next entry,
|
||||
# return a NULL pointer.
|
||||
|
||||
proc next_history*(): ptr HIST_ENTRY{.cdecl, importc: "next_history",
|
||||
dynlib: historyDll.}
|
||||
# Searching the history list.
|
||||
# Search the history for STRING, starting at history_offset.
|
||||
# If DIRECTION < 0, then the search is through previous entries,
|
||||
# else through subsequent. If the string is found, then
|
||||
# current_history () is the history entry, and the value of this function
|
||||
# is the offset in the line of that history entry that the string was
|
||||
# found in. Otherwise, nothing is changed, and a -1 is returned.
|
||||
|
||||
proc history_search*(a2: cstring, a3: cint): cint{.cdecl,
|
||||
importc: "history_search", dynlib: historyDll.}
|
||||
# Search the history for STRING, starting at history_offset.
|
||||
# The search is anchored: matching lines must begin with string.
|
||||
# DIRECTION is as in history_search().
|
||||
|
||||
proc history_search_prefix*(a2: cstring, a3: cint): cint{.cdecl,
|
||||
importc: "history_search_prefix", dynlib: historyDll.}
|
||||
# Search for STRING in the history list, starting at POS, an
|
||||
# absolute index into the list. DIR, if negative, says to search
|
||||
# backwards from POS, else forwards.
|
||||
# Returns the absolute index of the history element where STRING
|
||||
# was found, or -1 otherwise.
|
||||
|
||||
proc history_search_pos*(a2: cstring, a3: cint, a4: cint): cint{.cdecl,
|
||||
importc: "history_search_pos", dynlib: historyDll.}
|
||||
# Managing the history file.
|
||||
# Add the contents of FILENAME to the history list, a line at a time.
|
||||
# If FILENAME is NULL, then read from ~/.history. Returns 0 if
|
||||
# successful, or errno if not.
|
||||
|
||||
proc read_history*(a2: cstring): cint{.cdecl, importc: "read_history",
|
||||
dynlib: historyDll.}
|
||||
# Read a range of lines from FILENAME, adding them to the history list.
|
||||
# Start reading at the FROM'th line and end at the TO'th. If FROM
|
||||
# is zero, start at the beginning. If TO is less than FROM, read
|
||||
# until the end of the file. If FILENAME is NULL, then read from
|
||||
# ~/.history. Returns 0 if successful, or errno if not.
|
||||
|
||||
proc read_history_range*(a2: cstring, a3: cint, a4: cint): cint{.cdecl,
|
||||
importc: "read_history_range", dynlib: historyDll.}
|
||||
# Write the current history to FILENAME. If FILENAME is NULL,
|
||||
# then write the history list to ~/.history. Values returned
|
||||
# are as in read_history ().
|
||||
|
||||
proc write_history*(a2: cstring): cint{.cdecl, importc: "write_history",
|
||||
dynlib: historyDll.}
|
||||
# Append NELEMENT entries to FILENAME. The entries appended are from
|
||||
# the end of the list minus NELEMENTs up to the end of the list.
|
||||
|
||||
proc append_history*(a2: cint, a3: cstring): cint{.cdecl,
|
||||
importc: "append_history", dynlib: historyDll.}
|
||||
# Truncate the history file, leaving only the last NLINES lines.
|
||||
|
||||
proc history_truncate_file*(a2: cstring, a3: cint): cint{.cdecl,
|
||||
importc: "history_truncate_file", dynlib: historyDll.}
|
||||
# History expansion.
|
||||
# Expand the string STRING, placing the result into OUTPUT, a pointer
|
||||
# to a string. Returns:
|
||||
#
|
||||
# 0) If no expansions took place (or, if the only change in
|
||||
# the text was the de-slashifying of the history expansion
|
||||
# character)
|
||||
# 1) If expansions did take place
|
||||
# -1) If there was an error in expansion.
|
||||
# 2) If the returned line should just be printed.
|
||||
#
|
||||
# If an error occurred in expansion, then OUTPUT contains a descriptive
|
||||
# error message.
|
||||
|
||||
proc history_expand*(a2: cstring, a3: cstringArray): cint{.cdecl,
|
||||
importc: "history_expand", dynlib: historyDll.}
|
||||
# Extract a string segment consisting of the FIRST through LAST
|
||||
# arguments present in STRING. Arguments are broken up as in
|
||||
# the shell.
|
||||
|
||||
proc history_arg_extract*(a2: cint, a3: cint, a4: cstring): cstring{.cdecl,
|
||||
importc: "history_arg_extract", dynlib: historyDll.}
|
||||
# Return the text of the history event beginning at the current
|
||||
# offset into STRING. Pass STRING with *INDEX equal to the
|
||||
# history_expansion_char that begins this specification.
|
||||
# DELIMITING_QUOTE is a character that is allowed to end the string
|
||||
# specification for what to search for in addition to the normal
|
||||
# characters `:', ` ', `\t', `\n', and sometimes `?'.
|
||||
|
||||
proc get_history_event*(a2: cstring, a3: ptr cint, a4: cint): cstring{.cdecl,
|
||||
importc: "get_history_event", dynlib: historyDll.}
|
||||
# Return an array of tokens, much as the shell might. The tokens are
|
||||
# parsed out of STRING.
|
||||
|
||||
proc history_tokenize*(a2: cstring): cstringArray{.cdecl,
|
||||
importc: "history_tokenize", dynlib: historyDll.}
|
||||
when false:
|
||||
# Exported history variables.
|
||||
var history_base*{.importc: "history_base", dynlib: historyDll.}: cint
|
||||
var history_length*{.importc: "history_length", dynlib: historyDll.}: cint
|
||||
var history_max_entries*{.importc: "history_max_entries", dynlib: historyDll.}: cint
|
||||
var history_expansion_char*{.importc: "history_expansion_char",
|
||||
dynlib: historyDll.}: char
|
||||
var history_subst_char*{.importc: "history_subst_char", dynlib: historyDll.}: char
|
||||
var history_word_delimiters*{.importc: "history_word_delimiters",
|
||||
dynlib: historyDll.}: cstring
|
||||
var history_comment_char*{.importc: "history_comment_char", dynlib: historyDll.}: char
|
||||
var history_no_expand_chars*{.importc: "history_no_expand_chars",
|
||||
dynlib: historyDll.}: cstring
|
||||
var history_search_delimiter_chars*{.importc: "history_search_delimiter_chars",
|
||||
dynlib: historyDll.}: cstring
|
||||
var history_quotes_inhibit_expansion*{.
|
||||
importc: "history_quotes_inhibit_expansion", dynlib: historyDll.}: cint
|
||||
var history_write_timestamps*{.importc: "history_write_timestamps",
|
||||
dynlib: historyDll.}: cint
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,79 +0,0 @@
|
||||
# rltypedefs.h -- Type declarations for readline functions.
|
||||
# Copyright (C) 2000-2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of the GNU Readline Library (Readline), a library
|
||||
# for reading lines of text with interactive input and history editing.
|
||||
#
|
||||
# Readline is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Readline 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. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
type
|
||||
Function* = proc (): cint{.cdecl.}
|
||||
VFunction* = proc (){.cdecl.}
|
||||
CPFunction* = proc (): cstring{.cdecl.}
|
||||
CPPFunction* = proc (): cstringArray{.cdecl.}
|
||||
{.deprecated: [TFunction: Function, TVFunction: VFunction,
|
||||
TCPFunction: CPFunction, TCPPFunction: CPPFunction].}
|
||||
|
||||
# Bindable functions
|
||||
|
||||
type
|
||||
Command_func* = proc (a2: cint, a3: cint): cint{.cdecl.}
|
||||
{.deprecated: [Tcommand_func: Command_func].}
|
||||
|
||||
# Typedefs for the completion system
|
||||
|
||||
type
|
||||
Compentry_func* = proc (a2: cstring, a3: cint): cstring{.cdecl.}
|
||||
Completion_func* = proc (a2: cstring, a3: cint, a4: cint): cstringArray{.
|
||||
cdecl.}
|
||||
Quote_func* = proc (a2: cstring, a3: cint, a4: cstring): cstring{.cdecl.}
|
||||
Dequote_func* = proc (a2: cstring, a3: cint): cstring{.cdecl.}
|
||||
Compignore_func* = proc (a2: cstringArray): cint{.cdecl.}
|
||||
Compdisp_func* = proc (a2: cstringArray, a3: cint, a4: cint){.cdecl.}
|
||||
{.deprecated: [Tcompentry_func: Compentry_func,Tcompletion_func: Completion_func,
|
||||
Tquote_func: Quote_func, Tdequote_func: Dequote_func,
|
||||
Tcompignore_func: Compignore_func, Tcompdisp_func: Compdisp_func].}
|
||||
# Type for input and pre-read hook functions like rl_event_hook
|
||||
|
||||
type
|
||||
Thook_func* = proc (): cint{.cdecl.}
|
||||
|
||||
# Input function type
|
||||
|
||||
type
|
||||
Tgetc_func* = proc (a2: File): cint{.cdecl.}
|
||||
|
||||
# Generic function that takes a character buffer (which could be the readline
|
||||
# line buffer) and an index into it (which could be rl_point) and returns
|
||||
# an int.
|
||||
|
||||
type
|
||||
Tlinebuf_func* = proc (a2: cstring, a3: cint): cint{.cdecl.}
|
||||
|
||||
# `Generic' function pointer typedefs
|
||||
|
||||
type
|
||||
Tintfunc* = proc (a2: cint): cint{.cdecl.}
|
||||
Tivoidfunc* = proc (): cint{.cdecl.}
|
||||
Ticpfunc* = proc (a2: cstring): cint{.cdecl.}
|
||||
Ticppfunc* = proc (a2: cstringArray): cint{.cdecl.}
|
||||
Tvoidfunc* = proc (){.cdecl.}
|
||||
Tvintfunc* = proc (a2: cint){.cdecl.}
|
||||
Tvcpfunc* = proc (a2: cstring){.cdecl.}
|
||||
Tvcppfunc* = proc (a2: cstringArray){.cdecl.}
|
||||
Tcpvfunc* = proc (): cstring{.cdecl.}
|
||||
Tcpifunc* = proc (a2: cint): cstring{.cdecl.}
|
||||
Tcpcpfunc* = proc (a2: cstring): cstring{.cdecl.}
|
||||
Tcpcppfunc* = proc (a2: cstringArray): cstring{.cdecl.}
|
||||
@@ -1,257 +0,0 @@
|
||||
/* history.h -- the names of functions that you can call in history. */
|
||||
|
||||
/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (History), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
||||
History is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
History 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. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with History. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef C2NIM
|
||||
# private historyDll
|
||||
# dynlib historyDll
|
||||
# cdecl
|
||||
# if defined(windows)
|
||||
# define historyDll "history.dll"
|
||||
# elif defined(macosx)
|
||||
# define historyDll "libhistory.dynlib"
|
||||
# else
|
||||
# define historyDll "libhistory.so.6(|.0)"
|
||||
# endif
|
||||
# prefix rl_
|
||||
# prefix RL_
|
||||
# suffix _t
|
||||
# typeprefixes
|
||||
# def PARAMS(x) x
|
||||
# def time_t TTime
|
||||
#endif
|
||||
|
||||
# include "times"
|
||||
# include "rltypedefs.h"
|
||||
|
||||
typedef void *histdata_t;
|
||||
|
||||
/* The structure used to store a history entry. */
|
||||
typedef struct _hist_entry {
|
||||
char *line;
|
||||
char *timestamp; /* char * rather than time_t for read/write */
|
||||
histdata_t data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
/* Size of the history-library-managed space in history entry HS. */
|
||||
#define HISTENT_BYTES(hs) (strlen(hs.line) + strlen(hs.timestamp))
|
||||
|
||||
/* A structure used to pass the current state of the history stuff around. */
|
||||
typedef struct _hist_state {
|
||||
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
|
||||
int offset; /* The location pointer within this array. */
|
||||
int length; /* Number of elements within this array. */
|
||||
int size; /* Number of slots allocated to this array. */
|
||||
int flags;
|
||||
} HISTORY_STATE;
|
||||
|
||||
/* Flag values for the `flags' member of HISTORY_STATE. */
|
||||
#define HS_STIFLED 0x01
|
||||
|
||||
/* Initialization and state management. */
|
||||
|
||||
/* Begin a session in which the history functions might be used. This
|
||||
just initializes the interactive variables. */
|
||||
extern void using_history PARAMS((void));
|
||||
|
||||
/* Return the current HISTORY_STATE of the history. */
|
||||
extern HISTORY_STATE *history_get_history_state PARAMS((void));
|
||||
|
||||
/* Set the state of the current history array to STATE. */
|
||||
extern void history_set_history_state PARAMS((HISTORY_STATE *));
|
||||
|
||||
/* Manage the history list. */
|
||||
|
||||
/* Place STRING at the end of the history list.
|
||||
The associated data field (if any) is set to NULL. */
|
||||
extern void add_history PARAMS((const char *));
|
||||
|
||||
/* Change the timestamp associated with the most recent history entry to
|
||||
STRING. */
|
||||
extern void add_history_time PARAMS((const char *));
|
||||
|
||||
/* A reasonably useless function, only here for completeness. WHICH
|
||||
is the magic number that tells us which element to delete. The
|
||||
elements are numbered from 0. */
|
||||
extern HIST_ENTRY *remove_history PARAMS((int));
|
||||
|
||||
/* Free the history entry H and return any application-specific data
|
||||
associated with it. */
|
||||
extern histdata_t free_history_entry PARAMS((HIST_ENTRY *));
|
||||
|
||||
/* Make the history entry at WHICH have LINE and DATA. This returns
|
||||
the old entry so you can dispose of the data. In the case of an
|
||||
invalid WHICH, a NULL pointer is returned. */
|
||||
extern HIST_ENTRY *replace_history_entry PARAMS((int, const char *, histdata_t));
|
||||
|
||||
/* Clear the history list and start over. */
|
||||
extern void clear_history PARAMS((void));
|
||||
|
||||
/* Stifle the history list, remembering only MAX number of entries. */
|
||||
extern void stifle_history PARAMS((int));
|
||||
|
||||
/* Stop stifling the history. This returns the previous amount the
|
||||
history was stifled by. The value is positive if the history was
|
||||
stifled, negative if it wasn't. */
|
||||
extern int unstifle_history PARAMS((void));
|
||||
|
||||
/* Return 1 if the history is stifled, 0 if it is not. */
|
||||
extern int history_is_stifled PARAMS((void));
|
||||
|
||||
/* Information about the history list. */
|
||||
|
||||
/* Return a NULL terminated array of HIST_ENTRY which is the current input
|
||||
history. Element 0 of this list is the beginning of time. If there
|
||||
is no history, return NULL. */
|
||||
extern HIST_ENTRY **history_list PARAMS((void));
|
||||
|
||||
/* Returns the number which says what history element we are now
|
||||
looking at. */
|
||||
extern int where_history PARAMS((void));
|
||||
|
||||
/* Return the history entry at the current position, as determined by
|
||||
history_offset. If there is no entry there, return a NULL pointer. */
|
||||
extern HIST_ENTRY *current_history PARAMS((void));
|
||||
|
||||
/* Return the history entry which is logically at OFFSET in the history
|
||||
array. OFFSET is relative to history_base. */
|
||||
extern HIST_ENTRY *history_get PARAMS((int));
|
||||
|
||||
/* Return the timestamp associated with the HIST_ENTRY * passed as an
|
||||
argument */
|
||||
extern time_t history_get_time PARAMS((HIST_ENTRY *));
|
||||
|
||||
/* Return the number of bytes that the primary history entries are using.
|
||||
This just adds up the lengths of the_history->lines. */
|
||||
extern int history_total_bytes PARAMS((void));
|
||||
|
||||
/* Moving around the history list. */
|
||||
|
||||
/* Set the position in the history list to POS. */
|
||||
extern int history_set_pos PARAMS((int));
|
||||
|
||||
/* Back up history_offset to the previous history entry, and return
|
||||
a pointer to that entry. If there is no previous entry, return
|
||||
a NULL pointer. */
|
||||
extern HIST_ENTRY *previous_history PARAMS((void));
|
||||
|
||||
/* Move history_offset forward to the next item in the input_history,
|
||||
and return the a pointer to that entry. If there is no next entry,
|
||||
return a NULL pointer. */
|
||||
extern HIST_ENTRY *next_history PARAMS((void));
|
||||
|
||||
/* Searching the history list. */
|
||||
|
||||
/* Search the history for STRING, starting at history_offset.
|
||||
If DIRECTION < 0, then the search is through previous entries,
|
||||
else through subsequent. If the string is found, then
|
||||
current_history () is the history entry, and the value of this function
|
||||
is the offset in the line of that history entry that the string was
|
||||
found in. Otherwise, nothing is changed, and a -1 is returned. */
|
||||
extern int history_search PARAMS((const char *, int));
|
||||
|
||||
/* Search the history for STRING, starting at history_offset.
|
||||
The search is anchored: matching lines must begin with string.
|
||||
DIRECTION is as in history_search(). */
|
||||
extern int history_search_prefix PARAMS((const char *, int));
|
||||
|
||||
/* Search for STRING in the history list, starting at POS, an
|
||||
absolute index into the list. DIR, if negative, says to search
|
||||
backwards from POS, else forwards.
|
||||
Returns the absolute index of the history element where STRING
|
||||
was found, or -1 otherwise. */
|
||||
extern int history_search_pos PARAMS((const char *, int, int));
|
||||
|
||||
/* Managing the history file. */
|
||||
|
||||
/* Add the contents of FILENAME to the history list, a line at a time.
|
||||
If FILENAME is NULL, then read from ~/.history. Returns 0 if
|
||||
successful, or errno if not. */
|
||||
extern int read_history PARAMS((const char *));
|
||||
|
||||
/* Read a range of lines from FILENAME, adding them to the history list.
|
||||
Start reading at the FROM'th line and end at the TO'th. If FROM
|
||||
is zero, start at the beginning. If TO is less than FROM, read
|
||||
until the end of the file. If FILENAME is NULL, then read from
|
||||
~/.history. Returns 0 if successful, or errno if not. */
|
||||
extern int read_history_range PARAMS((const char *, int, int));
|
||||
|
||||
/* Write the current history to FILENAME. If FILENAME is NULL,
|
||||
then write the history list to ~/.history. Values returned
|
||||
are as in read_history (). */
|
||||
extern int write_history PARAMS((const char *));
|
||||
|
||||
/* Append NELEMENT entries to FILENAME. The entries appended are from
|
||||
the end of the list minus NELEMENTs up to the end of the list. */
|
||||
extern int append_history PARAMS((int, const char *));
|
||||
|
||||
/* Truncate the history file, leaving only the last NLINES lines. */
|
||||
extern int history_truncate_file PARAMS((const char *, int));
|
||||
|
||||
/* History expansion. */
|
||||
|
||||
/* Expand the string STRING, placing the result into OUTPUT, a pointer
|
||||
to a string. Returns:
|
||||
|
||||
0) If no expansions took place (or, if the only change in
|
||||
the text was the de-slashifying of the history expansion
|
||||
character)
|
||||
1) If expansions did take place
|
||||
-1) If there was an error in expansion.
|
||||
2) If the returned line should just be printed.
|
||||
|
||||
If an error occurred in expansion, then OUTPUT contains a descriptive
|
||||
error message. */
|
||||
extern int history_expand PARAMS((char *, char **));
|
||||
|
||||
/* Extract a string segment consisting of the FIRST through LAST
|
||||
arguments present in STRING. Arguments are broken up as in
|
||||
the shell. */
|
||||
extern char *history_arg_extract PARAMS((int, int, const char *));
|
||||
|
||||
/* Return the text of the history event beginning at the current
|
||||
offset into STRING. Pass STRING with *INDEX equal to the
|
||||
history_expansion_char that begins this specification.
|
||||
DELIMITING_QUOTE is a character that is allowed to end the string
|
||||
specification for what to search for in addition to the normal
|
||||
characters `:', ` ', `\t', `\n', and sometimes `?'. */
|
||||
extern char *get_history_event PARAMS((const char *, int *, int));
|
||||
|
||||
/* Return an array of tokens, much as the shell might. The tokens are
|
||||
parsed out of STRING. */
|
||||
extern char **history_tokenize PARAMS((const char *));
|
||||
|
||||
#if false
|
||||
/* Exported history variables. */
|
||||
extern int history_base;
|
||||
extern int history_length;
|
||||
extern int history_max_entries;
|
||||
extern char history_expansion_char;
|
||||
extern char history_subst_char;
|
||||
extern char *history_word_delimiters;
|
||||
extern char history_comment_char;
|
||||
extern char *history_no_expand_chars;
|
||||
extern char *history_search_delimiter_chars;
|
||||
extern int history_quotes_inhibit_expansion;
|
||||
|
||||
extern int history_write_timestamps;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,956 +0,0 @@
|
||||
/* Readline.h -- the names of functions callable from within readline. */
|
||||
|
||||
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Readline 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. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef C2NIM
|
||||
# private readlineDll
|
||||
# dynlib readlineDll
|
||||
# cdecl
|
||||
# if defined(windows)
|
||||
# define readlineDll "readline.dll"
|
||||
# elif defined(macosx)
|
||||
# define readlineDll "libreadline.dynlib"
|
||||
# else
|
||||
# define readlineDll "libreadline.so.6(|.0)"
|
||||
# endif
|
||||
# prefix rl_
|
||||
# prefix RL_
|
||||
# suffix _t
|
||||
# typeprefixes
|
||||
# def PARAMS(x) x
|
||||
# mangle end theEnd
|
||||
# mangle type typ
|
||||
# mangle macro theMacro
|
||||
/*# mangle "'command_func'" TCommandFunc
|
||||
# mangle vcpfunc TvcpFunc*/
|
||||
#endif
|
||||
|
||||
# include "rltypedefs.h"
|
||||
|
||||
|
||||
/* Some character stuff. */
|
||||
#define control_character_threshold 0x020 /* Smaller than this is control. */
|
||||
#define control_character_mask 0x1f /* 0x20 - 1 */
|
||||
#define meta_character_threshold 0x07f /* Larger than this is Meta. */
|
||||
#define control_character_bit 0x40 /* 0x000000, must be off. */
|
||||
#define meta_character_bit 0x080 /* x0000000, must be on. */
|
||||
#define largest_char 255 /* Largest character value. */
|
||||
|
||||
#define CTRL_CHAR(c) (c < control_character_threshold && ((c & 0x80) == 0))
|
||||
#define META_CHAR(c) (c > meta_character_threshold && c <= largest_char)
|
||||
|
||||
#define CTRL(c) (c & control_character_mask)
|
||||
#define META(c) (c | meta_character_bit)
|
||||
|
||||
#define UNMETA(c) (c & ~meta_character_bit)
|
||||
#define UNCTRL(c) (c|32|control_character_bit)
|
||||
|
||||
/* Beware: these only work with single-byte ASCII characters. */
|
||||
|
||||
#define RETURN_CHAR CTRL('M'.ord)
|
||||
#define RUBOUT_CHAR 0x7f
|
||||
#define ABORT_CHAR CTRL('G'.ord)
|
||||
#define PAGE_CHAR CTRL('L'.ord)
|
||||
#define ESC_CHAR CTRL('['.ord)
|
||||
|
||||
/* A keymap contains one entry for each key in the ASCII set.
|
||||
Each entry consists of a type and a pointer.
|
||||
FUNCTION is the address of a function to run, or the
|
||||
address of a keymap to indirect through.
|
||||
TYPE says which kind of thing FUNCTION is. */
|
||||
typedef struct _keymap_entry {
|
||||
char type;
|
||||
rl_command_func_t *function;
|
||||
} KEYMAP_ENTRY;
|
||||
|
||||
/* This must be large enough to hold bindings for all of the characters
|
||||
in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
|
||||
and so on) plus one for subsequence matching. */
|
||||
#define KEYMAP_SIZE 257
|
||||
#define ANYOTHERKEY KEYMAP_SIZE-1
|
||||
|
||||
/* I wanted to make the above structure contain a union of:
|
||||
union { rl_command_func_t *function; struct _keymap_entry *keymap; } value;
|
||||
but this made it impossible for me to create a static array.
|
||||
Maybe I need C lessons. */
|
||||
|
||||
typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
|
||||
typedef KEYMAP_ENTRY *Keymap;
|
||||
|
||||
/* The values that TYPE can have in a keymap entry. */
|
||||
#define ISFUNC 0
|
||||
#define ISKMAP 1
|
||||
#define ISMACR 2
|
||||
|
||||
#if false
|
||||
extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap;
|
||||
extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
|
||||
#endif
|
||||
|
||||
/* Return a new, empty keymap.
|
||||
Free it with free() when you are done. */
|
||||
extern Keymap rl_make_bare_keymap PARAMS((void));
|
||||
|
||||
/* Return a new keymap which is a copy of MAP. */
|
||||
extern Keymap rl_copy_keymap PARAMS((Keymap));
|
||||
|
||||
/* Return a new keymap with the printing characters bound to rl_insert,
|
||||
the lowercase Meta characters bound to run their equivalents, and
|
||||
the Meta digits bound to produce numeric arguments. */
|
||||
extern Keymap rl_make_keymap PARAMS((void));
|
||||
|
||||
/* Free the storage associated with a keymap. */
|
||||
extern void rl_discard_keymap PARAMS((Keymap));
|
||||
|
||||
/* These functions actually appear in bind.c */
|
||||
|
||||
/* Return the keymap corresponding to a given name. Names look like
|
||||
`emacs' or `emacs-meta' or `vi-insert'. */
|
||||
extern Keymap rl_get_keymap_by_name PARAMS((const char *));
|
||||
|
||||
/* Return the current keymap. */
|
||||
extern Keymap rl_get_keymap PARAMS((void));
|
||||
|
||||
/* Set the current keymap to MAP. */
|
||||
extern void rl_set_keymap PARAMS((Keymap));
|
||||
|
||||
# include "tilde.h"
|
||||
|
||||
/* Hex-encoded Readline version number. */
|
||||
#define RL_READLINE_VERSION 0x0600 /* Readline 6.0 */
|
||||
#define RL_VERSION_MAJOR 6
|
||||
#define RL_VERSION_MINOR 0
|
||||
|
||||
/* Readline data structures. */
|
||||
|
||||
/* Maintaining the state of undo. We remember individual deletes and inserts
|
||||
on a chain of things to do. */
|
||||
|
||||
/* The actions that undo knows how to undo. Notice that UNDO_DELETE means
|
||||
to insert some text, and UNDO_INSERT means to delete some text. I.e.,
|
||||
the code tells undo what to undo, not how to undo it. */
|
||||
enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
|
||||
|
||||
/* What an element of THE_UNDO_LIST looks like. */
|
||||
typedef struct undo_list {
|
||||
struct undo_list *next;
|
||||
int start, end; /* Where the change took place. */
|
||||
char *text; /* The text to insert, if undoing a delete. */
|
||||
enum undo_code what; /* Delete, Insert, Begin, End. */
|
||||
} UNDO_LIST;
|
||||
|
||||
/* The current undo list for RL_LINE_BUFFER. */
|
||||
extern UNDO_LIST *rl_undo_list;
|
||||
|
||||
/* The data structure for mapping textual names to code addresses. */
|
||||
typedef struct _funmap {
|
||||
const char *name;
|
||||
rl_command_func_t *function;
|
||||
} FUNMAP;
|
||||
|
||||
extern FUNMAP **funmap;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Functions available to bind to key sequences */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Bindable commands for numeric arguments. */
|
||||
extern int rl_digit_argument PARAMS((int, int));
|
||||
extern int rl_universal_argument PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for moving the cursor. */
|
||||
extern int rl_forward_byte PARAMS((int, int));
|
||||
extern int rl_forward_char PARAMS((int, int));
|
||||
extern int rl_forward PARAMS((int, int));
|
||||
extern int rl_backward_byte PARAMS((int, int));
|
||||
extern int rl_backward_char PARAMS((int, int));
|
||||
extern int rl_backward PARAMS((int, int));
|
||||
extern int rl_beg_of_line PARAMS((int, int));
|
||||
extern int rl_end_of_line PARAMS((int, int));
|
||||
extern int rl_forward_word PARAMS((int, int));
|
||||
extern int rl_backward_word PARAMS((int, int));
|
||||
extern int rl_refresh_line PARAMS((int, int));
|
||||
extern int rl_clear_screen PARAMS((int, int));
|
||||
extern int rl_skip_csi_sequence PARAMS((int, int));
|
||||
extern int rl_arrow_keys PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for inserting and deleting text. */
|
||||
extern int rl_insert PARAMS((int, int));
|
||||
extern int rl_quoted_insert PARAMS((int, int));
|
||||
extern int rl_tab_insert PARAMS((int, int));
|
||||
extern int rl_newline PARAMS((int, int));
|
||||
extern int rl_do_lowercase_version PARAMS((int, int));
|
||||
extern int rl_rubout PARAMS((int, int));
|
||||
extern int rl_delete PARAMS((int, int));
|
||||
extern int rl_rubout_or_delete PARAMS((int, int));
|
||||
extern int rl_delete_horizontal_space PARAMS((int, int));
|
||||
extern int rl_delete_or_show_completions PARAMS((int, int));
|
||||
extern int rl_insert_comment PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for changing case. */
|
||||
extern int rl_upcase_word PARAMS((int, int));
|
||||
extern int rl_downcase_word PARAMS((int, int));
|
||||
extern int rl_capitalize_word PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for transposing characters and words. */
|
||||
extern int rl_transpose_words PARAMS((int, int));
|
||||
extern int rl_transpose_chars PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for searching within a line. */
|
||||
extern int rl_char_search PARAMS((int, int));
|
||||
extern int rl_backward_char_search PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for readline's interface to the command history. */
|
||||
extern int rl_beginning_of_history PARAMS((int, int));
|
||||
extern int rl_end_of_history PARAMS((int, int));
|
||||
extern int rl_get_next_history PARAMS((int, int));
|
||||
extern int rl_get_previous_history PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for managing the mark and region. */
|
||||
extern int rl_set_mark PARAMS((int, int));
|
||||
extern int rl_exchange_point_and_mark PARAMS((int, int));
|
||||
|
||||
/* Bindable commands to set the editing mode (emacs or vi). */
|
||||
extern int rl_vi_editing_mode PARAMS((int, int));
|
||||
extern int rl_emacs_editing_mode PARAMS((int, int));
|
||||
|
||||
/* Bindable commands to change the insert mode (insert or overwrite) */
|
||||
extern int rl_overwrite_mode PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for managing key bindings. */
|
||||
extern int rl_re_read_init_file PARAMS((int, int));
|
||||
extern int rl_dump_functions PARAMS((int, int));
|
||||
extern int rl_dump_macros PARAMS((int, int));
|
||||
extern int rl_dump_variables PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for word completion. */
|
||||
extern int rl_complete PARAMS((int, int));
|
||||
extern int rl_possible_completions PARAMS((int, int));
|
||||
extern int rl_insert_completions PARAMS((int, int));
|
||||
extern int rl_old_menu_complete PARAMS((int, int));
|
||||
extern int rl_menu_complete PARAMS((int, int));
|
||||
extern int rl_backward_menu_complete PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for killing and yanking text, and managing the kill ring. */
|
||||
extern int rl_kill_word PARAMS((int, int));
|
||||
extern int rl_backward_kill_word PARAMS((int, int));
|
||||
extern int rl_kill_line PARAMS((int, int));
|
||||
extern int rl_backward_kill_line PARAMS((int, int));
|
||||
extern int rl_kill_full_line PARAMS((int, int));
|
||||
extern int rl_unix_word_rubout PARAMS((int, int));
|
||||
extern int rl_unix_filename_rubout PARAMS((int, int));
|
||||
extern int rl_unix_line_discard PARAMS((int, int));
|
||||
extern int rl_copy_region_to_kill PARAMS((int, int));
|
||||
extern int rl_kill_region PARAMS((int, int));
|
||||
extern int rl_copy_forward_word PARAMS((int, int));
|
||||
extern int rl_copy_backward_word PARAMS((int, int));
|
||||
extern int rl_yank PARAMS((int, int));
|
||||
extern int rl_yank_pop PARAMS((int, int));
|
||||
extern int rl_yank_nth_arg PARAMS((int, int));
|
||||
extern int rl_yank_last_arg PARAMS((int, int));
|
||||
|
||||
#ifdef Windows
|
||||
extern int rl_paste_from_clipboard PARAMS((int, int));
|
||||
#endif
|
||||
|
||||
/* Bindable commands for incremental searching. */
|
||||
extern int rl_reverse_search_history PARAMS((int, int));
|
||||
extern int rl_forward_search_history PARAMS((int, int));
|
||||
|
||||
/* Bindable keyboard macro commands. */
|
||||
extern int rl_start_kbd_macro PARAMS((int, int));
|
||||
extern int rl_end_kbd_macro PARAMS((int, int));
|
||||
extern int rl_call_last_kbd_macro PARAMS((int, int));
|
||||
|
||||
/* Bindable undo commands. */
|
||||
extern int rl_revert_line PARAMS((int, int));
|
||||
extern int rl_undo_command PARAMS((int, int));
|
||||
|
||||
/* Bindable tilde expansion commands. */
|
||||
extern int rl_tilde_expand PARAMS((int, int));
|
||||
|
||||
/* Bindable terminal control commands. */
|
||||
extern int rl_restart_output PARAMS((int, int));
|
||||
extern int rl_stop_output PARAMS((int, int));
|
||||
|
||||
/* Miscellaneous bindable commands. */
|
||||
extern int rl_abort PARAMS((int, int));
|
||||
extern int rl_tty_status PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for incremental and non-incremental history searching. */
|
||||
extern int rl_history_search_forward PARAMS((int, int));
|
||||
extern int rl_history_search_backward PARAMS((int, int));
|
||||
extern int rl_noninc_forward_search PARAMS((int, int));
|
||||
extern int rl_noninc_reverse_search PARAMS((int, int));
|
||||
extern int rl_noninc_forward_search_again PARAMS((int, int));
|
||||
extern int rl_noninc_reverse_search_again PARAMS((int, int));
|
||||
|
||||
/* Bindable command used when inserting a matching close character. */
|
||||
extern int rl_insert_close PARAMS((int, int));
|
||||
|
||||
/* Not available unless READLINE_CALLBACKS is defined. */
|
||||
extern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *));
|
||||
extern void rl_callback_read_char PARAMS((void));
|
||||
extern void rl_callback_handler_remove PARAMS((void));
|
||||
|
||||
/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
|
||||
/* VI-mode bindable commands. */
|
||||
extern int rl_vi_redo PARAMS((int, int));
|
||||
extern int rl_vi_undo PARAMS((int, int));
|
||||
extern int rl_vi_yank_arg PARAMS((int, int));
|
||||
extern int rl_vi_fetch_history PARAMS((int, int));
|
||||
extern int rl_vi_search_again PARAMS((int, int));
|
||||
extern int rl_vi_search PARAMS((int, int));
|
||||
extern int rl_vi_complete PARAMS((int, int));
|
||||
extern int rl_vi_tilde_expand PARAMS((int, int));
|
||||
extern int rl_vi_prev_word PARAMS((int, int));
|
||||
extern int rl_vi_next_word PARAMS((int, int));
|
||||
extern int rl_vi_end_word PARAMS((int, int));
|
||||
extern int rl_vi_insert_beg PARAMS((int, int));
|
||||
extern int rl_vi_append_mode PARAMS((int, int));
|
||||
extern int rl_vi_append_eol PARAMS((int, int));
|
||||
extern int rl_vi_eof_maybe PARAMS((int, int));
|
||||
extern int rl_vi_insertion_mode PARAMS((int, int));
|
||||
extern int rl_vi_insert_mode PARAMS((int, int));
|
||||
extern int rl_vi_movement_mode PARAMS((int, int));
|
||||
extern int rl_vi_arg_digit PARAMS((int, int));
|
||||
extern int rl_vi_change_case PARAMS((int, int));
|
||||
extern int rl_vi_put PARAMS((int, int));
|
||||
extern int rl_vi_column PARAMS((int, int));
|
||||
extern int rl_vi_delete_to PARAMS((int, int));
|
||||
extern int rl_vi_change_to PARAMS((int, int));
|
||||
extern int rl_vi_yank_to PARAMS((int, int));
|
||||
extern int rl_vi_rubout PARAMS((int, int));
|
||||
extern int rl_vi_delete PARAMS((int, int));
|
||||
extern int rl_vi_back_to_indent PARAMS((int, int));
|
||||
extern int rl_vi_first_print PARAMS((int, int));
|
||||
extern int rl_vi_char_search PARAMS((int, int));
|
||||
extern int rl_vi_match PARAMS((int, int));
|
||||
extern int rl_vi_change_char PARAMS((int, int));
|
||||
extern int rl_vi_subst PARAMS((int, int));
|
||||
extern int rl_vi_overstrike PARAMS((int, int));
|
||||
extern int rl_vi_overstrike_delete PARAMS((int, int));
|
||||
extern int rl_vi_replace PARAMS((int, int));
|
||||
extern int rl_vi_set_mark PARAMS((int, int));
|
||||
extern int rl_vi_goto_mark PARAMS((int, int));
|
||||
|
||||
/* VI-mode utility functions. */
|
||||
extern int rl_vi_check PARAMS((void));
|
||||
extern int rl_vi_domove PARAMS((int, int *));
|
||||
extern int rl_vi_bracktype PARAMS((int));
|
||||
|
||||
extern void rl_vi_start_inserting PARAMS((int, int, int));
|
||||
|
||||
/* VI-mode pseudo-bindable commands, used as utility functions. */
|
||||
extern int rl_vi_fWord PARAMS((int, int));
|
||||
extern int rl_vi_bWord PARAMS((int, int));
|
||||
extern int rl_vi_eWord PARAMS((int, int));
|
||||
extern int rl_vi_fword PARAMS((int, int));
|
||||
extern int rl_vi_bword PARAMS((int, int));
|
||||
extern int rl_vi_eword PARAMS((int, int));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Well Published Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Readline functions. */
|
||||
/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
|
||||
extern char *readline PARAMS((const char *));
|
||||
|
||||
extern int rl_set_prompt PARAMS((const char *));
|
||||
extern int rl_expand_prompt PARAMS((char *));
|
||||
|
||||
extern int rl_initialize PARAMS((void));
|
||||
|
||||
/* Undocumented; unused by readline */
|
||||
extern int rl_discard_argument PARAMS((void));
|
||||
|
||||
/* Utility functions to bind keys to readline commands. */
|
||||
extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
|
||||
extern int rl_bind_key PARAMS((int, rl_command_func_t *));
|
||||
extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
|
||||
extern int rl_unbind_key PARAMS((int));
|
||||
extern int rl_unbind_key_in_map PARAMS((int, Keymap));
|
||||
extern int rl_bind_key_if_unbound PARAMS((int, rl_command_func_t *));
|
||||
extern int rl_bind_key_if_unbound_in_map PARAMS((int, rl_command_func_t *, Keymap));
|
||||
extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
|
||||
extern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
|
||||
extern int rl_bind_keyseq PARAMS((const char *, rl_command_func_t *));
|
||||
extern int rl_bind_keyseq_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
|
||||
extern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *));
|
||||
extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
|
||||
extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
|
||||
|
||||
extern char *rl_variable_value PARAMS((const char *));
|
||||
extern int rl_variable_bind PARAMS((const char *, const char *));
|
||||
|
||||
/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
|
||||
extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
|
||||
|
||||
/* Backwards compatibility, use rl_generic_bind instead. */
|
||||
extern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
|
||||
|
||||
/* Undocumented in the texinfo manual; not really useful to programs. */
|
||||
extern int rl_translate_keyseq PARAMS((const char *, char *, int *));
|
||||
extern char *rl_untranslate_keyseq PARAMS((int));
|
||||
|
||||
extern rl_command_func_t *rl_named_function PARAMS((const char *));
|
||||
extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *));
|
||||
|
||||
extern void rl_list_funmap_names PARAMS((void));
|
||||
extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
|
||||
extern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *));
|
||||
|
||||
extern void rl_function_dumper PARAMS((int));
|
||||
extern void rl_macro_dumper PARAMS((int));
|
||||
extern void rl_variable_dumper PARAMS((int));
|
||||
|
||||
extern int rl_read_init_file PARAMS((const char *));
|
||||
extern int rl_parse_and_bind PARAMS((char *));
|
||||
|
||||
/* Functions for manipulating keymaps. */
|
||||
extern Keymap rl_make_bare_keymap PARAMS((void));
|
||||
extern Keymap rl_copy_keymap PARAMS((Keymap));
|
||||
extern Keymap rl_make_keymap PARAMS((void));
|
||||
extern void rl_discard_keymap PARAMS((Keymap));
|
||||
|
||||
extern Keymap rl_get_keymap_by_name PARAMS((const char *));
|
||||
extern char *rl_get_keymap_name PARAMS((Keymap));
|
||||
extern void rl_set_keymap PARAMS((Keymap));
|
||||
extern Keymap rl_get_keymap PARAMS((void));
|
||||
/* Undocumented; used internally only. */
|
||||
extern void rl_set_keymap_from_edit_mode PARAMS((void));
|
||||
extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
|
||||
|
||||
/* Functions for manipulating the funmap, which maps command names to functions. */
|
||||
extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
|
||||
extern const char **rl_funmap_names PARAMS((void));
|
||||
/* Undocumented, only used internally -- there is only one funmap, and this
|
||||
function may be called only once. */
|
||||
extern void rl_initialize_funmap PARAMS((void));
|
||||
|
||||
/* Utility functions for managing keyboard macros. */
|
||||
extern void rl_push_macro_input PARAMS((char *));
|
||||
|
||||
/* Functions for undoing, from undo.c */
|
||||
extern void rl_add_undo PARAMS((enum undo_code, int, int, char *));
|
||||
extern void rl_free_undo_list PARAMS((void));
|
||||
extern int rl_do_undo PARAMS((void));
|
||||
extern int rl_begin_undo_group PARAMS((void));
|
||||
extern int rl_end_undo_group PARAMS((void));
|
||||
extern int rl_modifying PARAMS((int, int));
|
||||
|
||||
/* Functions for redisplay. */
|
||||
extern void rl_redisplay PARAMS((void));
|
||||
extern int rl_on_new_line PARAMS((void));
|
||||
extern int rl_on_new_line_with_prompt PARAMS((void));
|
||||
extern int rl_forced_update_display PARAMS((void));
|
||||
extern int rl_clear_message PARAMS((void));
|
||||
extern int rl_reset_line_state PARAMS((void));
|
||||
extern int rl_crlf PARAMS((void));
|
||||
|
||||
extern int rl_message (const char *, ...);
|
||||
|
||||
extern int rl_show_char PARAMS((int));
|
||||
|
||||
/* Undocumented in texinfo manual. */
|
||||
extern int rl_character_len PARAMS((int, int));
|
||||
|
||||
/* Save and restore internal prompt redisplay information. */
|
||||
extern void rl_save_prompt PARAMS((void));
|
||||
extern void rl_restore_prompt PARAMS((void));
|
||||
|
||||
/* Modifying text. */
|
||||
extern void rl_replace_line PARAMS((const char *, int));
|
||||
extern int rl_insert_text PARAMS((const char *));
|
||||
extern int rl_delete_text PARAMS((int, int));
|
||||
extern int rl_kill_text PARAMS((int, int));
|
||||
extern char *rl_copy_text PARAMS((int, int));
|
||||
|
||||
/* Terminal and tty mode management. */
|
||||
extern void rl_prep_terminal PARAMS((int));
|
||||
extern void rl_deprep_terminal PARAMS((void));
|
||||
extern void rl_tty_set_default_bindings PARAMS((Keymap));
|
||||
extern void rl_tty_unset_default_bindings PARAMS((Keymap));
|
||||
|
||||
extern int rl_reset_terminal PARAMS((const char *));
|
||||
extern void rl_resize_terminal PARAMS((void));
|
||||
extern void rl_set_screen_size PARAMS((int, int));
|
||||
extern void rl_get_screen_size PARAMS((int *, int *));
|
||||
extern void rl_reset_screen_size PARAMS((void));
|
||||
|
||||
extern char *rl_get_termcap PARAMS((const char *));
|
||||
|
||||
/* Functions for character input. */
|
||||
extern int rl_stuff_char PARAMS((int));
|
||||
extern int rl_execute_next PARAMS((int));
|
||||
extern int rl_clear_pending_input PARAMS((void));
|
||||
extern int rl_read_key PARAMS((void));
|
||||
extern int rl_getc PARAMS((TFile));
|
||||
extern int rl_set_keyboard_input_timeout PARAMS((int));
|
||||
|
||||
/* `Public' utility functions . */
|
||||
extern void rl_extend_line_buffer PARAMS((int));
|
||||
extern int rl_ding PARAMS((void));
|
||||
extern int rl_alphabetic PARAMS((int));
|
||||
extern void rl_free PARAMS((void *));
|
||||
|
||||
/* Readline signal handling, from signals.c */
|
||||
extern int rl_set_signals PARAMS((void));
|
||||
extern int rl_clear_signals PARAMS((void));
|
||||
extern void rl_cleanup_after_signal PARAMS((void));
|
||||
extern void rl_reset_after_signal PARAMS((void));
|
||||
extern void rl_free_line_state PARAMS((void));
|
||||
|
||||
extern void rl_echo_signal_char PARAMS((int));
|
||||
|
||||
extern int rl_set_paren_blink_timeout PARAMS((int));
|
||||
|
||||
/* Undocumented. */
|
||||
extern int rl_maybe_save_line PARAMS((void));
|
||||
extern int rl_maybe_unsave_line PARAMS((void));
|
||||
extern int rl_maybe_replace_line PARAMS((void));
|
||||
|
||||
/* Completion functions. */
|
||||
extern int rl_complete_internal PARAMS((int));
|
||||
extern void rl_display_match_list PARAMS((char **, int, int));
|
||||
|
||||
extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
|
||||
extern char *rl_username_completion_function PARAMS((const char *, int));
|
||||
extern char *rl_filename_completion_function PARAMS((const char *, int));
|
||||
|
||||
extern int rl_completion_mode PARAMS((rl_command_func_t *));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Well Published Variables */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if false
|
||||
|
||||
/* The version of this incarnation of the readline library. */
|
||||
extern const char *rl_library_version; /* e.g., "4.2" */
|
||||
extern int rl_readline_version; /* e.g., 0x0402 */
|
||||
|
||||
/* True if this is real GNU readline. */
|
||||
extern int rl_gnu_readline_p;
|
||||
|
||||
/* Flags word encapsulating the current readline state. */
|
||||
extern int rl_readline_state;
|
||||
|
||||
/* Says which editing mode readline is currently using. 1 means emacs mode;
|
||||
0 means vi mode. */
|
||||
extern int rl_editing_mode;
|
||||
|
||||
/* Insert or overwrite mode for emacs mode. 1 means insert mode; 0 means
|
||||
overwrite mode. Reset to insert mode on each input line. */
|
||||
extern int rl_insert_mode;
|
||||
|
||||
/* The name of the calling program. You should initialize this to
|
||||
whatever was in argv[0]. It is used when parsing conditionals. */
|
||||
extern const char *rl_readline_name;
|
||||
|
||||
/* The prompt readline uses. This is set from the argument to
|
||||
readline (), and should not be assigned to directly. */
|
||||
extern char *rl_prompt;
|
||||
|
||||
/* The prompt string that is actually displayed by rl_redisplay. Public so
|
||||
applications can more easily supply their own redisplay functions. */
|
||||
extern char *rl_display_prompt;
|
||||
|
||||
/* The line buffer that is in use. */
|
||||
extern char *rl_line_buffer;
|
||||
|
||||
/* The location of point, and end. */
|
||||
extern int rl_point;
|
||||
extern int rl_end;
|
||||
|
||||
/* The mark, or saved cursor position. */
|
||||
extern int rl_mark;
|
||||
|
||||
/* Flag to indicate that readline has finished with the current input
|
||||
line and should return it. */
|
||||
extern int rl_done;
|
||||
|
||||
/* If set to a character value, that will be the next keystroke read. */
|
||||
extern int rl_pending_input;
|
||||
|
||||
/* Non-zero if we called this function from _rl_dispatch(). It's present
|
||||
so functions can find out whether they were called from a key binding
|
||||
or directly from an application. */
|
||||
extern int rl_dispatching;
|
||||
|
||||
/* Non-zero if the user typed a numeric argument before executing the
|
||||
current function. */
|
||||
extern int rl_explicit_arg;
|
||||
|
||||
/* The current value of the numeric argument specified by the user. */
|
||||
extern int rl_numeric_arg;
|
||||
|
||||
/* The address of the last command function Readline executed. */
|
||||
extern rl_command_func_t *rl_last_func;
|
||||
|
||||
/* The name of the terminal to use. */
|
||||
extern const char *rl_terminal_name;
|
||||
|
||||
/* The input and output streams. */
|
||||
extern FILE *rl_instream;
|
||||
extern FILE *rl_outstream;
|
||||
|
||||
/* If non-zero, Readline gives values of LINES and COLUMNS from the environment
|
||||
greater precedence than values fetched from the kernel when computing the
|
||||
screen dimensions. */
|
||||
extern int rl_prefer_env_winsize;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call just
|
||||
before readline_internal () prints the first prompt. */
|
||||
extern rl_hook_func_t *rl_startup_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function to call just before
|
||||
readline_internal_setup () returns and readline_internal starts
|
||||
reading input characters. */
|
||||
extern rl_hook_func_t *rl_pre_input_hook;
|
||||
|
||||
/* The address of a function to call periodically while Readline is
|
||||
awaiting character input, or NULL, for no event handling. */
|
||||
extern rl_hook_func_t *rl_event_hook;
|
||||
|
||||
/* The address of the function to call to fetch a character from the current
|
||||
Readline input stream */
|
||||
extern rl_getc_func_t *rl_getc_function;
|
||||
|
||||
extern rl_voidfunc_t *rl_redisplay_function;
|
||||
|
||||
extern rl_vintfunc_t *rl_prep_term_function;
|
||||
extern rl_voidfunc_t *rl_deprep_term_function;
|
||||
|
||||
/* Dispatch variables. */
|
||||
extern Keymap rl_executing_keymap;
|
||||
extern Keymap rl_binding_keymap;
|
||||
|
||||
/* Display variables. */
|
||||
/* If non-zero, readline will erase the entire line, including any prompt,
|
||||
if the only thing typed on an otherwise-blank line is something bound to
|
||||
rl_newline. */
|
||||
extern int rl_erase_empty_line;
|
||||
|
||||
/* If non-zero, the application has already printed the prompt (rl_prompt)
|
||||
before calling readline, so readline should not output it the first time
|
||||
redisplay is done. */
|
||||
extern int rl_already_prompted;
|
||||
|
||||
/* A non-zero value means to read only this many characters rather than
|
||||
up to a character bound to accept-line. */
|
||||
extern int rl_num_chars_to_read;
|
||||
|
||||
/* The text of a currently-executing keyboard macro. */
|
||||
extern char *rl_executing_macro;
|
||||
|
||||
/* Variables to control readline signal handling. */
|
||||
/* If non-zero, readline will install its own signal handlers for
|
||||
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
|
||||
extern int rl_catch_signals;
|
||||
|
||||
/* If non-zero, readline will install a signal handler for SIGWINCH
|
||||
that also attempts to call any calling application's SIGWINCH signal
|
||||
handler. Note that the terminal is not cleaned up before the
|
||||
application's signal handler is called; use rl_cleanup_after_signal()
|
||||
to do that. */
|
||||
extern int rl_catch_sigwinch;
|
||||
|
||||
/* Completion variables. */
|
||||
/* Pointer to the generator function for completion_matches ().
|
||||
NULL means to use rl_filename_completion_function (), the default
|
||||
filename completer. */
|
||||
extern rl_compentry_func_t *rl_completion_entry_function;
|
||||
|
||||
/* Optional generator for menu completion. Default is
|
||||
rl_completion_entry_function (rl_filename_completion_function). */
|
||||
extern rl_compentry_func_t *rl_menu_completion_entry_function;
|
||||
|
||||
/* If rl_ignore_some_completions_function is non-NULL it is the address
|
||||
of a function to call after all of the possible matches have been
|
||||
generated, but before the actual completion is done to the input line.
|
||||
The function is called with one argument; a NULL terminated array
|
||||
of (char *). If your function removes any of the elements, they
|
||||
must be free()'ed. */
|
||||
extern rl_compignore_func_t *rl_ignore_some_completions_function;
|
||||
|
||||
/* Pointer to alternative function to create matches.
|
||||
Function is called with TEXT, START, and END.
|
||||
START and END are indices in RL_LINE_BUFFER saying what the boundaries
|
||||
of TEXT are.
|
||||
If this function exists and returns NULL then call the value of
|
||||
rl_completion_entry_function to try to match, otherwise use the
|
||||
array of strings returned. */
|
||||
extern rl_completion_func_t *rl_attempted_completion_function;
|
||||
|
||||
/* The basic list of characters that signal a break between words for the
|
||||
completer routine. The initial contents of this variable is what
|
||||
breaks words in the shell, i.e. "n\"\\'`@$>". */
|
||||
extern const char *rl_basic_word_break_characters;
|
||||
|
||||
/* The list of characters that signal a break between words for
|
||||
rl_complete_internal. The default list is the contents of
|
||||
rl_basic_word_break_characters. */
|
||||
extern /*const*/ char *rl_completer_word_break_characters;
|
||||
|
||||
/* Hook function to allow an application to set the completion word
|
||||
break characters before readline breaks up the line. Allows
|
||||
position-dependent word break characters. */
|
||||
extern rl_cpvfunc_t *rl_completion_word_break_hook;
|
||||
|
||||
/* List of characters which can be used to quote a substring of the line.
|
||||
Completion occurs on the entire substring, and within the substring
|
||||
rl_completer_word_break_characters are treated as any other character,
|
||||
unless they also appear within this list. */
|
||||
extern const char *rl_completer_quote_characters;
|
||||
|
||||
/* List of quote characters which cause a word break. */
|
||||
extern const char *rl_basic_quote_characters;
|
||||
|
||||
/* List of characters that need to be quoted in filenames by the completer. */
|
||||
extern const char *rl_filename_quote_characters;
|
||||
|
||||
/* List of characters that are word break characters, but should be left
|
||||
in TEXT when it is passed to the completion function. The shell uses
|
||||
this to help determine what kind of completing to do. */
|
||||
extern const char *rl_special_prefixes;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing on a directory name. The function is called with
|
||||
the address of a string (the current directory name) as an arg. It
|
||||
changes what is displayed when the possible completions are printed
|
||||
or inserted. */
|
||||
extern rl_icppfunc_t *rl_directory_completion_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function to call when completing
|
||||
a directory name. This function takes the address of the directory name
|
||||
to be modified as an argument. Unlike rl_directory_completion_hook, it
|
||||
only modifies the directory name used in opendir(2), not what is displayed
|
||||
when the possible completions are printed or inserted. It is called
|
||||
before rl_directory_completion_hook. I'm not happy with how this works
|
||||
yet, so it's undocumented. */
|
||||
extern rl_icppfunc_t *rl_directory_rewrite_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function to call when reading
|
||||
directory entries from the filesystem for completion and comparing
|
||||
them to the partial word to be completed. The function should
|
||||
either return its first argument (if no conversion takes place) or
|
||||
newly-allocated memory. This can, for instance, convert filenames
|
||||
between character sets for comparison against what's typed at the
|
||||
keyboard. The returned value is what is added to the list of
|
||||
matches. The second argument is the length of the filename to be
|
||||
converted. */
|
||||
extern rl_dequote_func_t *rl_filename_rewrite_hook;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing a word would normally display the list of possible matches.
|
||||
This function is called instead of actually doing the display.
|
||||
It takes three arguments: (char **matches, int num_matches, int max_length)
|
||||
where MATCHES is the array of strings that matched, NUM_MATCHES is the
|
||||
number of strings in that array, and MAX_LENGTH is the length of the
|
||||
longest string in that array. */
|
||||
extern rl_compdisp_func_t *rl_completion_display_matches_hook;
|
||||
|
||||
/* Non-zero means that the results of the matches are to be treated
|
||||
as filenames. This is ALWAYS zero on entry, and can only be changed
|
||||
within a completion entry finder function. */
|
||||
extern int rl_filename_completion_desired;
|
||||
|
||||
/* Non-zero means that the results of the matches are to be quoted using
|
||||
double quotes (or an application-specific quoting mechanism) if the
|
||||
filename contains any characters in rl_word_break_chars. This is
|
||||
ALWAYS non-zero on entry, and can only be changed within a completion
|
||||
entry finder function. */
|
||||
extern int rl_filename_quoting_desired;
|
||||
|
||||
/* Set to a function to quote a filename in an application-specific fashion.
|
||||
Called with the text to quote, the type of match found (single or multiple)
|
||||
and a pointer to the quoting character to be used, which the function can
|
||||
reset if desired. */
|
||||
extern rl_quote_func_t *rl_filename_quoting_function;
|
||||
|
||||
/* Function to call to remove quoting characters from a filename. Called
|
||||
before completion is attempted, so the embedded quotes do not interfere
|
||||
with matching names in the file system. */
|
||||
extern rl_dequote_func_t *rl_filename_dequoting_function;
|
||||
|
||||
/* Function to call to decide whether or not a word break character is
|
||||
quoted. If a character is quoted, it does not break words for the
|
||||
completer. */
|
||||
extern rl_linebuf_func_t *rl_char_is_quoted_p;
|
||||
|
||||
/* Non-zero means to suppress normal filename completion after the
|
||||
user-specified completion function has been called. */
|
||||
extern int rl_attempted_completion_over;
|
||||
|
||||
/* Set to a character describing the type of completion being attempted by
|
||||
rl_complete_internal; available for use by application completion
|
||||
functions. */
|
||||
extern int rl_completion_type;
|
||||
|
||||
/* Set to the last key used to invoke one of the completion functions */
|
||||
extern int rl_completion_invoking_key;
|
||||
|
||||
/* Up to this many items will be displayed in response to a
|
||||
possible-completions call. After that, we ask the user if she
|
||||
is sure she wants to see them all. The default value is 100. */
|
||||
extern int rl_completion_query_items;
|
||||
|
||||
/* Character appended to completed words when at the end of the line. The
|
||||
default is a space. Nothing is added if this is '\0'. */
|
||||
extern int rl_completion_append_character;
|
||||
|
||||
/* If set to non-zero by an application completion function,
|
||||
rl_completion_append_character will not be appended. */
|
||||
extern int rl_completion_suppress_append;
|
||||
|
||||
/* Set to any quote character readline thinks it finds before any application
|
||||
completion function is called. */
|
||||
extern int rl_completion_quote_character;
|
||||
|
||||
/* Set to a non-zero value if readline found quoting anywhere in the word to
|
||||
be completed; set before any application completion function is called. */
|
||||
extern int rl_completion_found_quote;
|
||||
|
||||
/* If non-zero, the completion functions don't append any closing quote.
|
||||
This is set to 0 by rl_complete_internal and may be changed by an
|
||||
application-specific completion function. */
|
||||
extern int rl_completion_suppress_quote;
|
||||
|
||||
/* If non-zero, readline will sort the completion matches. On by default. */
|
||||
extern int rl_sort_completion_matches;
|
||||
|
||||
/* If non-zero, a slash will be appended to completed filenames that are
|
||||
symbolic links to directory names, subject to the value of the
|
||||
mark-directories variable (which is user-settable). This exists so
|
||||
that application completion functions can override the user's preference
|
||||
(set via the mark-symlinked-directories variable) if appropriate.
|
||||
It's set to the value of _rl_complete_mark_symlink_dirs in
|
||||
rl_complete_internal before any application-specific completion
|
||||
function is called, so without that function doing anything, the user's
|
||||
preferences are honored. */
|
||||
extern int rl_completion_mark_symlink_dirs;
|
||||
|
||||
/* If non-zero, then disallow duplicates in the matches. */
|
||||
extern int rl_ignore_completion_duplicates;
|
||||
|
||||
/* If this is non-zero, completion is (temporarily) inhibited, and the
|
||||
completion character will be inserted as any other. */
|
||||
extern int rl_inhibit_completion;
|
||||
|
||||
#endif
|
||||
|
||||
/* Input error; can be returned by (*rl_getc_function) if readline is reading
|
||||
a top-level command (RL_ISSTATE (RL_STATE_READCMD)). */
|
||||
#define READERR (-2)
|
||||
|
||||
/* Definitions available for use by readline clients. */
|
||||
#define RL_PROMPT_START_IGNORE '\001'
|
||||
#define RL_PROMPT_END_IGNORE '\002'
|
||||
|
||||
/* Possible values for do_replace argument to rl_filename_quoting_function,
|
||||
called by rl_complete_internal. */
|
||||
#define NO_MATCH 0
|
||||
#define SINGLE_MATCH 1
|
||||
#define MULT_MATCH 2
|
||||
|
||||
/* Possible state values for rl_readline_state */
|
||||
#define RL_STATE_NONE 0x000000 /* no state; before first call */
|
||||
|
||||
#define RL_STATE_INITIALIZING 0x000001 /* initializing */
|
||||
#define RL_STATE_INITIALIZED 0x000002 /* initialization done */
|
||||
#define RL_STATE_TERMPREPPED 0x000004 /* terminal is prepped */
|
||||
#define RL_STATE_READCMD 0x000008 /* reading a command key */
|
||||
#define RL_STATE_METANEXT 0x000010 /* reading input after ESC */
|
||||
#define RL_STATE_DISPATCHING 0x000020 /* dispatching to a command */
|
||||
#define RL_STATE_MOREINPUT 0x000040 /* reading more input in a command function */
|
||||
#define RL_STATE_ISEARCH 0x000080 /* doing incremental search */
|
||||
#define RL_STATE_NSEARCH 0x000100 /* doing non-inc search */
|
||||
#define RL_STATE_SEARCH 0x000200 /* doing a history search */
|
||||
#define RL_STATE_NUMERICARG 0x000400 /* reading numeric argument */
|
||||
#define RL_STATE_MACROINPUT 0x000800 /* getting input from a macro */
|
||||
#define RL_STATE_MACRODEF 0x001000 /* defining keyboard macro */
|
||||
#define RL_STATE_OVERWRITE 0x002000 /* overwrite mode */
|
||||
#define RL_STATE_COMPLETING 0x004000 /* doing completion */
|
||||
#define RL_STATE_SIGHANDLER 0x008000 /* in readline sighandler */
|
||||
#define RL_STATE_UNDOING 0x010000 /* doing an undo */
|
||||
#define RL_STATE_INPUTPENDING 0x020000 /* rl_execute_next called */
|
||||
#define RL_STATE_TTYCSAVED 0x040000 /* tty special chars saved */
|
||||
#define RL_STATE_CALLBACK 0x080000 /* using the callback interface */
|
||||
#define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */
|
||||
#define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */
|
||||
#define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at least once */
|
||||
#define RL_STATE_REDISPLAYING 0x800000 /* updating terminal display */
|
||||
|
||||
#define RL_STATE_DONE 0x1000000 /* done; accepted line */
|
||||
|
||||
#define RL_SETSTATE(x) (rl_readline_state |= (x))
|
||||
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
|
||||
#define RL_ISSTATE(x) (rl_readline_state & (x))
|
||||
|
||||
struct readline_state {
|
||||
/* line state */
|
||||
int point;
|
||||
int end;
|
||||
int mark;
|
||||
char *buffer;
|
||||
int buflen;
|
||||
UNDO_LIST *ul;
|
||||
char *prompt;
|
||||
|
||||
/* global state */
|
||||
int rlstate;
|
||||
int done;
|
||||
Keymap kmap;
|
||||
|
||||
/* input state */
|
||||
rl_command_func_t *lastfunc;
|
||||
int insmode;
|
||||
int edmode;
|
||||
int kseqlen;
|
||||
FILE *inf;
|
||||
FILE *outf;
|
||||
int pendingin;
|
||||
char *macro;
|
||||
|
||||
/* signal state */
|
||||
int catchsigs;
|
||||
int catchsigwinch;
|
||||
|
||||
/* search state */
|
||||
|
||||
/* completion state */
|
||||
|
||||
/* options state */
|
||||
|
||||
/* reserved for future expansion, so the struct size doesn't change */
|
||||
char reserved[64];
|
||||
};
|
||||
|
||||
extern int rl_save_state PARAMS((struct readline_state *));
|
||||
extern int rl_restore_state PARAMS((struct readline_state *));
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/* rltypedefs.h -- Type declarations for readline functions. */
|
||||
|
||||
/* Copyright (C) 2000-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Readline 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. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef C2NIM
|
||||
# cdecl
|
||||
# prefix rl_
|
||||
# prefix RL_
|
||||
# suffix _t
|
||||
# typeprefixes
|
||||
# def PARAMS(x) x
|
||||
#endif
|
||||
|
||||
typedef int (*Function) ();
|
||||
typedef void VFunction ();
|
||||
typedef char *CPFunction ();
|
||||
typedef char **CPPFunction ();
|
||||
|
||||
/* Bindable functions */
|
||||
typedef int rl_command_func_t PARAMS((int, int));
|
||||
|
||||
/* Typedefs for the completion system */
|
||||
typedef char *rl_compentry_func_t PARAMS((const char *, int));
|
||||
typedef char **rl_completion_func_t PARAMS((const char *, int, int));
|
||||
|
||||
typedef char *rl_quote_func_t PARAMS((char *, int, char *));
|
||||
typedef char *rl_dequote_func_t PARAMS((char *, int));
|
||||
|
||||
typedef int rl_compignore_func_t PARAMS((char **));
|
||||
|
||||
typedef void rl_compdisp_func_t PARAMS((char **, int, int));
|
||||
|
||||
/* Type for input and pre-read hook functions like rl_event_hook */
|
||||
typedef int rl_hook_func_t PARAMS((void));
|
||||
|
||||
/* Input function type */
|
||||
typedef int rl_getc_func_t PARAMS((TFile));
|
||||
|
||||
/* Generic function that takes a character buffer (which could be the readline
|
||||
line buffer) and an index into it (which could be rl_point) and returns
|
||||
an int. */
|
||||
typedef int rl_linebuf_func_t PARAMS((char *, int));
|
||||
|
||||
/* `Generic' function pointer typedefs */
|
||||
typedef int rl_intfunc_t PARAMS((int));
|
||||
typedef int rl_ivoidfunc_t PARAMS((void));
|
||||
|
||||
typedef int rl_icpfunc_t PARAMS((char *));
|
||||
typedef int rl_icppfunc_t PARAMS((char **));
|
||||
|
||||
typedef void rl_voidfunc_t PARAMS((void));
|
||||
typedef void rl_vintfunc_t PARAMS((int));
|
||||
typedef void rl_vcpfunc_t PARAMS((char *));
|
||||
typedef void rl_vcppfunc_t PARAMS((char **));
|
||||
|
||||
typedef char *rl_cpvfunc_t PARAMS((void));
|
||||
typedef char *rl_cpifunc_t PARAMS((int));
|
||||
typedef char *rl_cpcpfunc_t PARAMS((char *));
|
||||
typedef char *rl_cpcppfunc_t PARAMS((char **));
|
||||
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/* tilde.h: Externally available variables and function in libtilde.a. */
|
||||
|
||||
/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the Readline Library (Readline), a set of
|
||||
routines for providing Emacs style line input to programs that ask
|
||||
for it.
|
||||
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Readline 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. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef C2NIM
|
||||
# private tildeDll
|
||||
# dynlib tildeDll
|
||||
# cdecl
|
||||
# if defined(windows)
|
||||
# define tildeDll "tilde.dll"
|
||||
# elif defined(macosx)
|
||||
# define tildeDll "libtilde.dynlib"
|
||||
# else
|
||||
# define tildeDll "libtilde.so.6(|.0)"
|
||||
# endif
|
||||
# prefix tilde_
|
||||
# suffix _t
|
||||
# typeprefixes
|
||||
# def PARAMS(x) x
|
||||
#endif
|
||||
|
||||
typedef char *tilde_hook_func_t PARAMS((char *));
|
||||
|
||||
#if false
|
||||
|
||||
/* If non-null, this contains the address of a function that the application
|
||||
wants called before trying the standard tilde expansions. The function
|
||||
is called with the text sans tilde, and returns a malloc()'ed string
|
||||
which is the expansion, or a NULL pointer if the expansion fails. */
|
||||
extern tilde_hook_func_t *tilde_expansion_preexpansion_hook;
|
||||
|
||||
/* If non-null, this contains the address of a function to call if the
|
||||
standard meaning for expanding a tilde fails. The function is called
|
||||
with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
|
||||
which is the expansion, or a NULL pointer if there is no expansion. */
|
||||
extern tilde_hook_func_t *tilde_expansion_failure_hook;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which
|
||||
are duplicates for a tilde prefix. Bash uses this to expand
|
||||
`=~' and `:~'. */
|
||||
extern char **tilde_additional_prefixes;
|
||||
|
||||
/* When non-null, this is a NULL terminated array of strings which match
|
||||
the end of a username, instead of just "/". Bash sets this to
|
||||
`:' and `=~'. */
|
||||
extern char **tilde_additional_suffixes;
|
||||
|
||||
/* Return a new string which is the result of tilde expanding STRING. */
|
||||
extern char *tilde_expand PARAMS((const char *));
|
||||
|
||||
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
|
||||
tilde. If there is no expansion, call tilde_expansion_failure_hook. */
|
||||
extern char *tilde_expand_word PARAMS((const char *));
|
||||
|
||||
/* Find the portion of the string beginning with ~ that should be expanded. */
|
||||
extern char *tilde_find_word PARAMS((const char *, int, int *));
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,452 +0,0 @@
|
||||
#
|
||||
# $Id: sdl_gfx.pas,v 1.3 2007/05/29 21:31:04 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# $Log: sdl_gfx.pas,v $
|
||||
# Revision 1.3 2007/05/29 21:31:04 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.2 2007/05/20 20:30:18 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.1 2005/01/03 19:08:32 savage
|
||||
# Header for the SDL_Gfx library.
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
import
|
||||
sdl
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
gfxLibName = "SDL_gfx.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
gfxLibName = "libSDL_gfx.dylib"
|
||||
else:
|
||||
const
|
||||
gfxLibName = "libSDL_gfx.so"
|
||||
const # Some rates in Hz
|
||||
FPS_UPPER_LIMIT* = 200
|
||||
FPS_LOWER_LIMIT* = 1
|
||||
FPS_DEFAULT* = 30 # ---- Defines
|
||||
SMOOTHING_OFF* = 0
|
||||
SMOOTHING_ON* = 1
|
||||
|
||||
type
|
||||
PFPSmanager* = ptr FPSmanager
|
||||
FPSmanager*{.final.} = object # ---- Structures
|
||||
framecount*: uint32
|
||||
rateticks*: float32
|
||||
lastticks*: uint32
|
||||
rate*: uint32
|
||||
|
||||
PColorRGBA* = ptr ColorRGBA
|
||||
ColorRGBA*{.final.} = object
|
||||
r*: byte
|
||||
g*: byte
|
||||
b*: byte
|
||||
a*: byte
|
||||
|
||||
PColorY* = ptr ColorY
|
||||
ColorY*{.final.} = object #
|
||||
#
|
||||
# SDL_framerate: framerate manager
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
y*: byte
|
||||
{.deprecated: [TFPSmanager: FPSmanager, TColorRGBA: ColorRGBA, TColorY: ColorY].}
|
||||
|
||||
proc initFramerate*(manager: PFPSmanager){.cdecl, importc: "SDL_initFramerate",
|
||||
dynlib: gfxLibName.}
|
||||
proc setFramerate*(manager: PFPSmanager, rate: cint): cint{.cdecl,
|
||||
importc: "SDL_setFramerate", dynlib: gfxLibName.}
|
||||
proc getFramerate*(manager: PFPSmanager): cint{.cdecl,
|
||||
importc: "SDL_getFramerate", dynlib: gfxLibName.}
|
||||
proc framerateDelay*(manager: PFPSmanager){.cdecl,
|
||||
importc: "SDL_framerateDelay", dynlib: gfxLibName.}
|
||||
#
|
||||
#
|
||||
# SDL_gfxPrimitives: graphics primitives for SDL
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
# Note: all ___Color routines expect the color to be in format 0xRRGGBBAA
|
||||
# Pixel
|
||||
proc pixelColor*(dst: PSurface, x: int16, y: int16, color: uint32): cint{.
|
||||
cdecl, importc: "pixelColor", dynlib: gfxLibName.}
|
||||
proc pixelRGBA*(dst: PSurface, x: int16, y: int16, r: byte, g: byte,
|
||||
b: byte, a: byte): cint{.cdecl, importc: "pixelRGBA",
|
||||
dynlib: gfxLibName.}
|
||||
# Horizontal line
|
||||
proc hlineColor*(dst: PSurface, x1: int16, x2: int16, y: int16, color: uint32): cint{.
|
||||
cdecl, importc: "hlineColor", dynlib: gfxLibName.}
|
||||
proc hlineRGBA*(dst: PSurface, x1: int16, x2: int16, y: int16, r: byte,
|
||||
g: byte, b: byte, a: byte): cint{.cdecl, importc: "hlineRGBA",
|
||||
dynlib: gfxLibName.}
|
||||
# Vertical line
|
||||
proc vlineColor*(dst: PSurface, x: int16, y1: int16, y2: int16, color: uint32): cint{.
|
||||
cdecl, importc: "vlineColor", dynlib: gfxLibName.}
|
||||
proc vlineRGBA*(dst: PSurface, x: int16, y1: int16, y2: int16, r: byte,
|
||||
g: byte, b: byte, a: byte): cint{.cdecl, importc: "vlineRGBA",
|
||||
dynlib: gfxLibName.}
|
||||
# Rectangle
|
||||
proc rectangleColor*(dst: PSurface, x1: int16, y1: int16, x2: int16,
|
||||
y2: int16, color: uint32): cint{.cdecl,
|
||||
importc: "rectangleColor", dynlib: gfxLibName.}
|
||||
proc rectangleRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16,
|
||||
y2: int16, r: byte, g: byte, b: byte, a: byte): cint{.
|
||||
cdecl, importc: "rectangleRGBA", dynlib: gfxLibName.}
|
||||
# Filled rectangle (Box)
|
||||
proc boxColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16,
|
||||
color: uint32): cint{.cdecl, importc: "boxColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc boxRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16,
|
||||
r: byte, g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "boxRGBA", dynlib: gfxLibName.}
|
||||
# Line
|
||||
proc lineColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16,
|
||||
color: uint32): cint{.cdecl, importc: "lineColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc lineRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16,
|
||||
r: byte, g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "lineRGBA", dynlib: gfxLibName.}
|
||||
# AA Line
|
||||
proc aalineColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16,
|
||||
color: uint32): cint{.cdecl, importc: "aalineColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc aalineRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16,
|
||||
r: byte, g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "aalineRGBA", dynlib: gfxLibName.}
|
||||
# Circle
|
||||
proc circleColor*(dst: PSurface, x: int16, y: int16, r: int16, color: uint32): cint{.
|
||||
cdecl, importc: "circleColor", dynlib: gfxLibName.}
|
||||
proc circleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, r: byte,
|
||||
g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "circleRGBA", dynlib: gfxLibName.}
|
||||
# AA Circle
|
||||
proc aacircleColor*(dst: PSurface, x: int16, y: int16, r: int16,
|
||||
color: uint32): cint{.cdecl, importc: "aacircleColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc aacircleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, r: byte,
|
||||
g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "aacircleRGBA", dynlib: gfxLibName.}
|
||||
# Filled Circle
|
||||
proc filledCircleColor*(dst: PSurface, x: int16, y: int16, r: int16,
|
||||
color: uint32): cint{.cdecl,
|
||||
importc: "filledCircleColor", dynlib: gfxLibName.}
|
||||
proc filledCircleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16,
|
||||
r: byte, g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "filledCircleRGBA", dynlib: gfxLibName.}
|
||||
# Ellipse
|
||||
proc ellipseColor*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16,
|
||||
color: uint32): cint{.cdecl, importc: "ellipseColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc ellipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16,
|
||||
r: byte, g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "ellipseRGBA", dynlib: gfxLibName.}
|
||||
# AA Ellipse
|
||||
proc aaellipseColor*(dst: PSurface, xc: int16, yc: int16, rx: int16,
|
||||
ry: int16, color: uint32): cint{.cdecl,
|
||||
importc: "aaellipseColor", dynlib: gfxLibName.}
|
||||
proc aaellipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16,
|
||||
r: byte, g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "aaellipseRGBA", dynlib: gfxLibName.}
|
||||
# Filled Ellipse
|
||||
proc filledEllipseColor*(dst: PSurface, x: int16, y: int16, rx: int16,
|
||||
ry: int16, color: uint32): cint{.cdecl,
|
||||
importc: "filledEllipseColor", dynlib: gfxLibName.}
|
||||
proc filledEllipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16,
|
||||
ry: int16, r: byte, g: byte, b: byte, a: byte): cint{.
|
||||
cdecl, importc: "filledEllipseRGBA", dynlib: gfxLibName.}
|
||||
# Pie
|
||||
proc pieColor*(dst: PSurface, x: int16, y: int16, rad: int16, start: int16,
|
||||
finish: int16, color: uint32): cint{.cdecl, importc: "pieColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc pieRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, start: int16,
|
||||
finish: int16, r: byte, g: byte, b: byte, a: byte): cint{.
|
||||
cdecl, importc: "pieRGBA", dynlib: gfxLibName.}
|
||||
# Filled Pie
|
||||
proc filledPieColor*(dst: PSurface, x: int16, y: int16, rad: int16,
|
||||
start: int16, finish: int16, color: uint32): cint{.cdecl,
|
||||
importc: "filledPieColor", dynlib: gfxLibName.}
|
||||
proc filledPieRGBA*(dst: PSurface, x: int16, y: int16, rad: int16,
|
||||
start: int16, finish: int16, r: byte, g: byte, b: byte,
|
||||
a: byte): cint{.cdecl, importc: "filledPieRGBA",
|
||||
dynlib: gfxLibName.}
|
||||
# Trigon
|
||||
proc trigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16,
|
||||
x3: int16, y3: int16, color: uint32): cint{.cdecl,
|
||||
importc: "trigonColor", dynlib: gfxLibName.}
|
||||
proc trigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16,
|
||||
x3: int16, y3: int16, r: byte, g: byte, b: byte, a: byte): cint{.
|
||||
cdecl, importc: "trigonRGBA", dynlib: gfxLibName.}
|
||||
# AA-Trigon
|
||||
proc aatrigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16,
|
||||
y2: int16, x3: int16, y3: int16, color: uint32): cint{.
|
||||
cdecl, importc: "aatrigonColor", dynlib: gfxLibName.}
|
||||
proc aatrigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16,
|
||||
y2: int16, x3: int16, y3: int16, r: byte, g: byte,
|
||||
b: byte, a: byte): cint{.cdecl, importc: "aatrigonRGBA",
|
||||
dynlib: gfxLibName.}
|
||||
# Filled Trigon
|
||||
proc filledTrigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16,
|
||||
y2: int16, x3: int16, y3: int16, color: uint32): cint{.
|
||||
cdecl, importc: "filledTrigonColor", dynlib: gfxLibName.}
|
||||
proc filledTrigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16,
|
||||
y2: int16, x3: int16, y3: int16, r: byte, g: byte,
|
||||
b: byte, a: byte): cint{.cdecl,
|
||||
importc: "filledTrigonRGBA", dynlib: gfxLibName.}
|
||||
# Polygon
|
||||
proc polygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint,
|
||||
color: uint32): cint{.cdecl, importc: "polygonColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc polygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, r: byte,
|
||||
g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "polygonRGBA", dynlib: gfxLibName.}
|
||||
# AA-Polygon
|
||||
proc aapolygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint,
|
||||
color: uint32): cint{.cdecl, importc: "aapolygonColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc aapolygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, r: byte,
|
||||
g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "aapolygonRGBA", dynlib: gfxLibName.}
|
||||
# Filled Polygon
|
||||
proc filledPolygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint,
|
||||
color: uint32): cint{.cdecl,
|
||||
importc: "filledPolygonColor", dynlib: gfxLibName.}
|
||||
proc filledPolygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint,
|
||||
r: byte, g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "filledPolygonRGBA", dynlib: gfxLibName.}
|
||||
# Bezier
|
||||
# s = number of steps
|
||||
proc bezierColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, s: cint,
|
||||
color: uint32): cint{.cdecl, importc: "bezierColor",
|
||||
dynlib: gfxLibName.}
|
||||
proc bezierRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, s: cint,
|
||||
r: byte, g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "bezierRGBA", dynlib: gfxLibName.}
|
||||
# Characters/Strings
|
||||
proc characterColor*(dst: PSurface, x: int16, y: int16, c: char, color: uint32): cint{.
|
||||
cdecl, importc: "characterColor", dynlib: gfxLibName.}
|
||||
proc characterRGBA*(dst: PSurface, x: int16, y: int16, c: char, r: byte,
|
||||
g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "characterRGBA", dynlib: gfxLibName.}
|
||||
proc stringColor*(dst: PSurface, x: int16, y: int16, c: cstring, color: uint32): cint{.
|
||||
cdecl, importc: "stringColor", dynlib: gfxLibName.}
|
||||
proc stringRGBA*(dst: PSurface, x: int16, y: int16, c: cstring, r: byte,
|
||||
g: byte, b: byte, a: byte): cint{.cdecl,
|
||||
importc: "stringRGBA", dynlib: gfxLibName.}
|
||||
proc gfxPrimitivesSetFont*(fontdata: pointer, cw: cint, ch: cint){.cdecl,
|
||||
importc: "gfxPrimitivesSetFont", dynlib: gfxLibName.}
|
||||
#
|
||||
#
|
||||
# SDL_imageFilter - bytes-image "filter" routines
|
||||
# (uses inline x86 MMX optimizations if available)
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
# Comments:
|
||||
# 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary.
|
||||
# 2.) Data that is not within an 8 byte boundary is processed using the C routine.
|
||||
# 3.) Convolution routines do not have C routines at this time.
|
||||
# Detect MMX capability in CPU
|
||||
proc imageFilterMMXdetect*(): cint{.cdecl, importc: "SDL_imageFilterMMXdetect",
|
||||
dynlib: gfxLibName.}
|
||||
# Force use of MMX off (or turn possible use back on)
|
||||
proc imageFilterMMXoff*(){.cdecl, importc: "SDL_imageFilterMMXoff",
|
||||
dynlib: gfxLibName.}
|
||||
proc imageFilterMMXon*(){.cdecl, importc: "SDL_imageFilterMMXon",
|
||||
dynlib: gfxLibName.}
|
||||
#
|
||||
# All routines return:
|
||||
# 0 OK
|
||||
# -1 Error (internal error, parameter error)
|
||||
#
|
||||
# SDL_imageFilterAdd: D = saturation255(S1 + S2)
|
||||
proc imageFilterAdd*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterAdd", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMean: D = S1/2 + S2/2
|
||||
proc imageFilterMean*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterMean", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterSub: D = saturation0(S1 - S2)
|
||||
proc imageFilterSub*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterSub", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterAbsDiff: D = | S1 - S2 |
|
||||
proc imageFilterAbsDiff*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterAbsDiff", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMult: D = saturation(S1 * S2)
|
||||
proc imageFilterMult*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterMult", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMultNor: D = S1 * S2 (non-MMX)
|
||||
proc imageFilterMultNor*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterMultNor", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
|
||||
proc imageFilterMultDivby2*(src1: cstring, src2: cstring, dest: cstring,
|
||||
len: cint): cint{.cdecl,
|
||||
importc: "SDL_imageFilterMultDivby2", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
|
||||
proc imageFilterMultDivby4*(src1: cstring, src2: cstring, dest: cstring,
|
||||
len: cint): cint{.cdecl,
|
||||
importc: "SDL_imageFilterMultDivby4", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterBitAnd: D = S1 & S2
|
||||
proc imageFilterBitAnd*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterBitAnd", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterBitOr: D = S1 | S2
|
||||
proc imageFilterBitOr*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterBitOr", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterDiv: D = S1 / S2 (non-MMX)
|
||||
proc imageFilterDiv*(src1: cstring, src2: cstring, dest: cstring, len: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterDiv", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterBitNegation: D = !S
|
||||
proc imageFilterBitNegation*(src1: cstring, dest: cstring, len: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterBitNegation", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterAddByte: D = saturation255(S + C)
|
||||
proc imageFilterAddByte*(src1: cstring, dest: cstring, len: cint, c: char): cint{.
|
||||
cdecl, importc: "SDL_imageFilterAddByte", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
|
||||
proc imageFilterAddUint*(src1: cstring, dest: cstring, len: cint, c: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterAddUint", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
|
||||
proc imageFilterAddByteToHalf*(src1: cstring, dest: cstring, len: cint, c: char): cint{.
|
||||
cdecl, importc: "SDL_imageFilterAddByteToHalf", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterSubByte: D = saturation0(S - C)
|
||||
proc imageFilterSubByte*(src1: cstring, dest: cstring, len: cint, c: char): cint{.
|
||||
cdecl, importc: "SDL_imageFilterSubByte", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
|
||||
proc imageFilterSubUint*(src1: cstring, dest: cstring, len: cint, c: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterSubUint", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftRight: D = saturation0(S >> N)
|
||||
proc imageFilterShiftRight*(src1: cstring, dest: cstring, len: cint, n: char): cint{.
|
||||
cdecl, importc: "SDL_imageFilterShiftRight", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
|
||||
proc imageFilterShiftRightUint*(src1: cstring, dest: cstring, len: cint, n: char): cint{.
|
||||
cdecl, importc: "SDL_imageFilterShiftRightUint", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterMultByByte: D = saturation255(S * C)
|
||||
proc imageFilterMultByByte*(src1: cstring, dest: cstring, len: cint, c: char): cint{.
|
||||
cdecl, importc: "SDL_imageFilterMultByByte", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
|
||||
proc imageFilterShiftRightAndMultByByte*(src1: cstring, dest: cstring, len: cint,
|
||||
n: char, c: char): cint{.cdecl,
|
||||
importc: "SDL_imageFilterShiftRightAndMultByByte",
|
||||
dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftLeftByte: D = (S << N)
|
||||
proc imageFilterShiftLeftByte*(src1: cstring, dest: cstring, len: cint, n: char): cint{.
|
||||
cdecl, importc: "SDL_imageFilterShiftLeftByte", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
|
||||
proc imageFilterShiftLeftUint*(src1: cstring, dest: cstring, len: cint, n: char): cint{.
|
||||
cdecl, importc: "SDL_imageFilterShiftLeftUint", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterShiftLeft: D = saturation255(S << N)
|
||||
proc imageFilterShiftLeft*(src1: cstring, dest: cstring, len: cint, n: char): cint{.
|
||||
cdecl, importc: "SDL_imageFilterShiftLeft", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
|
||||
proc imageFilterBinarizeUsingThreshold*(src1: cstring, dest: cstring, len: cint,
|
||||
t: char): cint{.cdecl,
|
||||
importc: "SDL_imageFilterBinarizeUsingThreshold", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
|
||||
proc imageFilterClipToRange*(src1: cstring, dest: cstring, len: cint, tmin: int8,
|
||||
tmax: int8): cint{.cdecl,
|
||||
importc: "SDL_imageFilterClipToRange", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
|
||||
proc imageFilterNormalizeLinear*(src1: cstring, dest: cstring, len: cint,
|
||||
cmin: cint, cmax: cint, nmin: cint, nmax: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterNormalizeLinear", dynlib: gfxLibName.}
|
||||
# !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!!
|
||||
# SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel3x3Divide*(src: cstring, dest: cstring, rows: cint,
|
||||
columns: cint, kernel: pointer, divisor: int8): cint{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel3x3Divide", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel5x5Divide*(src: cstring, dest: cstring, rows: cint,
|
||||
columns: cint, kernel: pointer, divisor: int8): cint{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel5x5Divide", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel7x7Divide*(src: cstring, dest: cstring, rows: cint,
|
||||
columns: cint, kernel: pointer, divisor: int8): cint{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel7x7Divide", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel9x9Divide*(src: cstring, dest: cstring, rows: cint,
|
||||
columns: cint, kernel: pointer, divisor: int8): cint{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel9x9Divide", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel3x3ShiftRight*(src: cstring, dest: cstring,
|
||||
rows: cint, columns: cint, kernel: pointer, nRightShift: char): cint{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel3x3ShiftRight", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel5x5ShiftRight*(src: cstring, dest: cstring,
|
||||
rows: cint, columns: cint, kernel: pointer, nRightShift: char): cint{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel5x5ShiftRight", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel7x7ShiftRight*(src: cstring, dest: cstring,
|
||||
rows: cint, columns: cint, kernel: pointer, nRightShift: char): cint{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel7x7ShiftRight", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
|
||||
proc imageFilterConvolveKernel9x9ShiftRight*(src: cstring, dest: cstring,
|
||||
rows: cint, columns: cint, kernel: pointer, nRightShift: char): cint{.cdecl,
|
||||
importc: "SDL_imageFilterConvolveKernel9x9ShiftRight", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterSobelX: Dij = saturation255( ... )
|
||||
proc imageFilterSobelX*(src: cstring, dest: cstring, rows: cint, columns: cint): cint{.
|
||||
cdecl, importc: "SDL_imageFilterSobelX", dynlib: gfxLibName.}
|
||||
# SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
|
||||
proc imageFilterSobelXShiftRight*(src: cstring, dest: cstring, rows: cint,
|
||||
columns: cint, nRightShift: char): cint{.cdecl,
|
||||
importc: "SDL_imageFilterSobelXShiftRight", dynlib: gfxLibName.}
|
||||
# Align/restore stack to 32 byte boundary -- Functionality untested! --
|
||||
proc imageFilterAlignStack*(){.cdecl, importc: "SDL_imageFilterAlignStack",
|
||||
dynlib: gfxLibName.}
|
||||
proc imageFilterRestoreStack*(){.cdecl, importc: "SDL_imageFilterRestoreStack",
|
||||
dynlib: gfxLibName.}
|
||||
#
|
||||
#
|
||||
# SDL_rotozoom - rotozoomer
|
||||
#
|
||||
# LGPL (c) A. Schiffler
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# rotozoomSurface()
|
||||
#
|
||||
# Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
|
||||
# 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1
|
||||
# then the destination 32bit surface is anti-aliased. If the surface is not 8bit
|
||||
# or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
|
||||
#
|
||||
#
|
||||
proc rotozoomSurface*(src: PSurface, angle: float64, zoom: float64, smooth: cint): PSurface{.
|
||||
cdecl, importc: "rotozoomSurface", dynlib: gfxLibName.}
|
||||
proc rotozoomSurfaceXY*(src: PSurface, angle: float64, zoomx: float64,
|
||||
zoomy: float64, smooth: cint): PSurface{.cdecl,
|
||||
importc: "rotozoomSurfaceXY", dynlib: gfxLibName.}
|
||||
# Returns the size of the target surface for a rotozoomSurface() call
|
||||
proc rotozoomSurfaceSize*(width: cint, height: cint, angle: float64,
|
||||
zoom: float64, dstwidth: var cint, dstheight: var cint){.
|
||||
cdecl, importc: "rotozoomSurfaceSize", dynlib: gfxLibName.}
|
||||
proc rotozoomSurfaceSizeXY*(width: cint, height: cint, angle: float64,
|
||||
zoomx: float64, zoomy: float64, dstwidth: var cint,
|
||||
dstheight: var cint){.cdecl,
|
||||
importc: "rotozoomSurfaceSizeXY", dynlib: gfxLibName.}
|
||||
#
|
||||
#
|
||||
# zoomSurface()
|
||||
#
|
||||
# Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
|
||||
# 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1
|
||||
# then the destination 32bit surface is anti-aliased. If the surface is not 8bit
|
||||
# or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
|
||||
#
|
||||
#
|
||||
proc zoomSurface*(src: PSurface, zoomx: float64, zoomy: float64, smooth: cint): PSurface{.
|
||||
cdecl, importc: "zoomSurface", dynlib: gfxLibName.}
|
||||
# Returns the size of the target surface for a zoomSurface() call
|
||||
proc zoomSurfaceSize*(width: cint, height: cint, zoomx: float64, zoomy: float64,
|
||||
dstwidth: var cint, dstheight: var cint){.cdecl,
|
||||
importc: "zoomSurfaceSize", dynlib: gfxLibName.}
|
||||
# implementation
|
||||
@@ -1,243 +0,0 @@
|
||||
#
|
||||
# $Id: sdl_image.pas,v 1.14 2007/05/29 21:31:13 savage Exp $
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
#
|
||||
# Borland Delphi SDL_Image - An example image loading library for use
|
||||
# with SDL
|
||||
# Conversion of the Simple DirectMedia Layer Image Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_image.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Portions created by Matthias Thoma are
|
||||
# Copyright (C) 2000 - 2001 Matthias Thoma.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Dominique Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
# A simple library to load images of various formats as SDL surfaces
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# SDL.pas in your search path.
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
# See the Aliens Demo on how to make use of this libaray
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# April 02 2001 - MT : Initial Translation
|
||||
#
|
||||
# May 08 2001 - DL : Added ExternalSym derectives and copyright header
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_image.pas,v $
|
||||
# Revision 1.14 2007/05/29 21:31:13 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.13 2007/05/20 20:30:54 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.12 2006/12/02 00:14:40 savage
|
||||
# Updated to latest version
|
||||
#
|
||||
# Revision 1.11 2005/04/10 18:22:59 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.10 2005/04/10 11:48:33 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.9 2005/01/05 01:47:07 savage
|
||||
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
|
||||
#
|
||||
# Revision 1.8 2005/01/04 23:14:44 savage
|
||||
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
|
||||
#
|
||||
# Revision 1.7 2005/01/01 02:03:12 savage
|
||||
# Updated to v1.2.4
|
||||
#
|
||||
# Revision 1.6 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.5 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.4 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.3 2004/04/01 20:53:23 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/14 23:35:42 savage
|
||||
# version 1 of sdl_image, sdl_mixer and smpeg.
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
sdl
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
ImageLibName = "SDL_Image.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
ImageLibName = "libSDL_image-1.2.0.dylib"
|
||||
else:
|
||||
const
|
||||
ImageLibName = "libSDL_image(.so|-1.2.so.0)"
|
||||
const
|
||||
IMAGE_MAJOR_VERSION* = 1
|
||||
IMAGE_MINOR_VERSION* = 2
|
||||
IMAGE_PATCHLEVEL* = 5
|
||||
|
||||
# This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_image library.
|
||||
|
||||
proc imageVersion*(x: var Version)
|
||||
# This function gets the version of the dynamically linked SDL_image library.
|
||||
# it should NOT be used to fill a version structure, instead you should
|
||||
# use the SDL_IMAGE_VERSION() macro.
|
||||
#
|
||||
proc imgLinkedVersion*(): Pversion{.importc: "IMG_Linked_Version",
|
||||
dynlib: ImageLibName.}
|
||||
# Load an image from an SDL data source.
|
||||
# The 'type' may be one of: "BMP", "GIF", "PNG", etc.
|
||||
#
|
||||
# If the image format supports a transparent pixel, SDL will set the
|
||||
# colorkey for the surface. You can enable RLE acceleration on the
|
||||
# surface afterwards by calling:
|
||||
# SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey);
|
||||
#
|
||||
|
||||
const
|
||||
IMG_INIT_JPG* = 0x00000001
|
||||
IMG_INIT_PNG* = 0x00000002
|
||||
IMG_INIT_TIF* = 0x00000004
|
||||
IMG_INIT_WEBP* = 0x00000008
|
||||
|
||||
proc imgInit*(flags: cint): int {.cdecl, importc: "IMG_Init",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgQuit*() {.cdecl, importc: "IMG_Quit",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadTypedRW*(src: PRWops, freesrc: cint, theType: cstring): PSurface{.
|
||||
cdecl, importc: "IMG_LoadTyped_RW", dynlib: ImageLibName.}
|
||||
# Convenience functions
|
||||
proc imgLoad*(theFile: cstring): PSurface{.cdecl, importc: "IMG_Load",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadRW*(src: PRWops, freesrc: cint): PSurface{.cdecl,
|
||||
importc: "IMG_Load_RW", dynlib: ImageLibName.}
|
||||
# Invert the alpha of a surface for use with OpenGL
|
||||
# This function is now a no-op, and only provided for backwards compatibility.
|
||||
proc imgInvertAlpha*(theOn: cint): cint{.cdecl, importc: "IMG_InvertAlpha",
|
||||
dynlib: ImageLibName.}
|
||||
# Functions to detect a file type, given a seekable source
|
||||
proc imgIsBMP*(src: PRWops): cint{.cdecl, importc: "IMG_isBMP",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgIsGIF*(src: PRWops): cint{.cdecl, importc: "IMG_isGIF",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgIsJPG*(src: PRWops): cint{.cdecl, importc: "IMG_isJPG",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgIsLBM*(src: PRWops): cint{.cdecl, importc: "IMG_isLBM",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgIsPCX*(src: PRWops): cint{.cdecl, importc: "IMG_isPCX",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgIsPNG*(src: PRWops): cint{.cdecl, importc: "IMG_isPNG",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgIsPNM*(src: PRWops): cint{.cdecl, importc: "IMG_isPNM",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgIsTIF*(src: PRWops): cint{.cdecl, importc: "IMG_isTIF",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgIsXCF*(src: PRWops): cint{.cdecl, importc: "IMG_isXCF",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgIsXPM*(src: PRWops): cint{.cdecl, importc: "IMG_isXPM",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgIsXV*(src: PRWops): cint{.cdecl, importc: "IMG_isXV",
|
||||
dynlib: ImageLibName.}
|
||||
# Individual loading functions
|
||||
proc imgLoadBMP_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadBMP_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadGIF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadGIF_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadJPG_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadJPG_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadLBM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadLBM_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadPCX_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPCX_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadPNM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPNM_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadPNG_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadPNG_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadTGA_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadTGA_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadTIF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadTIF_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadXCF_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXCF_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadXPM_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXPM_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgLoadXV_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXV_RW",
|
||||
dynlib: ImageLibName.}
|
||||
proc imgReadXPMFromArray*(xpm: cstringArray): PSurface{.cdecl,
|
||||
importc: "IMG_ReadXPMFromArray", dynlib: ImageLibName.}
|
||||
|
||||
proc imageVersion(x: var Version) =
|
||||
x.major = IMAGE_MAJOR_VERSION
|
||||
x.minor = IMAGE_MINOR_VERSION
|
||||
x.patch = IMAGE_PATCHLEVEL
|
||||
|
||||
@@ -1,489 +0,0 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# $Id: sdl_mixer.pas,v 1.18 2007/05/29 21:31:44 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# Borland Delphi SDL_Mixer - Simple DirectMedia Layer Mixer Library
|
||||
# Conversion of the Simple DirectMedia Layer Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_mixer.h
|
||||
# music_cmd.h
|
||||
# wavestream.h
|
||||
# timidity.h
|
||||
# playmidi.h
|
||||
# music_ogg.h
|
||||
# mikmod.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Portions created by Dominqiue Louis are
|
||||
# Copyright (C) 2000 - 2001 Dominqiue Louis.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# SDL.pas & SMPEG.pas somewhere within your search path.
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
# See the Aliens Demo to see how this library is used
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# April 02 2001 - DL : Initial Translation
|
||||
#
|
||||
# February 02 2002 - DL : Update to version 1.2.1
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_mixer.pas,v $
|
||||
# Revision 1.18 2007/05/29 21:31:44 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.17 2007/05/20 20:31:17 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.16 2006/12/02 00:16:17 savage
|
||||
# Updated to latest version
|
||||
#
|
||||
# Revision 1.15 2005/04/10 11:48:33 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.14 2005/02/24 20:20:07 savage
|
||||
# Changed definition of MusicType and added GetMusicType function
|
||||
#
|
||||
# Revision 1.13 2005/01/05 01:47:09 savage
|
||||
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
|
||||
#
|
||||
# Revision 1.12 2005/01/04 23:14:56 savage
|
||||
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
|
||||
#
|
||||
# Revision 1.11 2005/01/01 02:05:19 savage
|
||||
# Updated to v1.2.6
|
||||
#
|
||||
# Revision 1.10 2004/09/12 21:45:17 savage
|
||||
# Robert Reed spotted that Mix_SetMusicPosition was missing from the conversion, so this has now been added.
|
||||
#
|
||||
# Revision 1.9 2004/08/27 21:48:24 savage
|
||||
# IFDEFed out Smpeg support on MacOS X
|
||||
#
|
||||
# Revision 1.8 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.7 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.6 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.5 2004/04/01 20:53:23 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.4 2004/03/31 22:20:02 savage
|
||||
# Windows unit not used in this file, so it was removed to keep the code tidy.
|
||||
#
|
||||
# Revision 1.3 2004/03/31 10:05:08 savage
|
||||
# Better defines for Endianness under FreePascal and Borland compilers.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/14 23:35:42 savage
|
||||
# version 1 of sdl_image, sdl_mixer and smpeg.
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
sdl, smpeg
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
MixerLibName = "SDL_mixer.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
MixerLibName = "libSDL_mixer-1.2.0.dylib"
|
||||
else:
|
||||
const
|
||||
MixerLibName = "libSDL_mixer.so"
|
||||
const
|
||||
MAJOR_VERSION* = 1
|
||||
MINOR_VERSION* = 2
|
||||
PATCHLEVEL* = 7 # Backwards compatibility
|
||||
|
||||
CHANNELS* = 8 # Good default values for a PC soundcard
|
||||
DEFAULT_FREQUENCY* = 22050
|
||||
|
||||
when defined(IA32):
|
||||
const
|
||||
DEFAULT_FORMAT* = AUDIO_S16LSB
|
||||
else:
|
||||
const
|
||||
DEFAULT_FORMAT* = AUDIO_S16MSB
|
||||
const
|
||||
DEFAULT_CHANNELS* = 2
|
||||
MAX_VOLUME* = 128 # Volume of a chunk
|
||||
PATH_MAX* = 255 # mikmod.h constants
|
||||
#*
|
||||
# * Library version
|
||||
# *
|
||||
LIBMIKMOD_VERSION_MAJOR* = 3
|
||||
LIBMIKMOD_VERSION_MINOR* = 1
|
||||
LIBMIKMOD_REVISION* = 8
|
||||
LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
|
||||
(LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
|
||||
|
||||
type #music_cmd.h types
|
||||
PMusicCMD* = ptr MusicCMD
|
||||
MusicCMD*{.final.} = object #wavestream.h types
|
||||
filename*: array[0..PATH_MAX - 1, char]
|
||||
cmd*: array[0..PATH_MAX - 1, char]
|
||||
pid*: TSYS_ThreadHandle
|
||||
|
||||
PWAVStream* = ptr WAVStream
|
||||
WAVStream*{.final.} = object #playmidi.h types
|
||||
wavefp*: pointer
|
||||
start*: int32
|
||||
stop*: int32
|
||||
cvt*: TAudioCVT
|
||||
|
||||
PMidiEvent* = ptr MidiEvent
|
||||
MidiEvent*{.final.} = object
|
||||
time*: int32
|
||||
channel*: byte
|
||||
typ*: byte
|
||||
a*: byte
|
||||
b*: byte
|
||||
|
||||
PMidiSong* = ptr MidiSong
|
||||
MidiSong*{.final.} = object #music_ogg.h types
|
||||
samples*: int32
|
||||
events*: PMidiEvent
|
||||
|
||||
POGG_Music* = ptr OGG_Music
|
||||
OGG_Music*{.final.} = object # mikmod.h types
|
||||
#*
|
||||
# * Error codes
|
||||
# *
|
||||
playing*: int32
|
||||
volume*: int32 #vf: OggVorbis_File;
|
||||
section*: int32
|
||||
cvt*: TAudioCVT
|
||||
lenAvailable*: int32
|
||||
sndAvailable*: pointer
|
||||
|
||||
ErrorEnum* = enum
|
||||
MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING,
|
||||
MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE,
|
||||
MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER,
|
||||
MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM,
|
||||
MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE,
|
||||
MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO,
|
||||
MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW,
|
||||
MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT,
|
||||
MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS,
|
||||
MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED,
|
||||
MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC,
|
||||
MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE,
|
||||
MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT,
|
||||
MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT,
|
||||
MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD,
|
||||
MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY,
|
||||
MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE,
|
||||
MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT,
|
||||
MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
|
||||
PMODULE* = ptr MODULE
|
||||
MODULE*{.final.} = object
|
||||
PUNIMOD* = ptr UNIMOD
|
||||
UNIMOD* = MODULE #SDL_mixer.h types
|
||||
# The internal format for an audio chunk
|
||||
PChunk* = ptr Chunk
|
||||
Chunk*{.final.} = object
|
||||
allocated*: cint
|
||||
abuf*: pointer
|
||||
alen*: uint32
|
||||
volume*: byte # Per-sample volume, 0-128
|
||||
|
||||
Fading* = enum
|
||||
MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
|
||||
MusicType* = enum
|
||||
MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3
|
||||
PMusic* = ptr Music
|
||||
Music*{.final.} = object # The internal format for a music chunk interpreted via mikmod
|
||||
mixtype*: MusicType # other fields are not aviable
|
||||
# data : MusicUnion;
|
||||
# fading : TMix_Fading;
|
||||
# fade_volume : integer;
|
||||
# fade_step : integer;
|
||||
# fade_steps : integer;
|
||||
# error : integer;
|
||||
|
||||
MixFunction* = proc (udata, stream: pointer, length: cint): pointer{.
|
||||
cdecl.} # This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_mixer library.
|
||||
{.deprecated: [TMusicCMD: MusicCMD, TWAVStream: WAVStream, TMidiEvent: MidiEvent,
|
||||
TMidiSong: MidiSong, TOGG_Music: OGG_Music, TErrorEnum: ErrorEnum,
|
||||
TMODULE: MODULE, TUNIMOD: UNIMOD, TChunk: Chunk, TFading: Fading,
|
||||
TMusicType: MusicType, TMusic: Music, TMixFunction: MixFunction].}
|
||||
|
||||
proc version*(x: var sdl.Version)
|
||||
# This function gets the version of the dynamically linked SDL_mixer library.
|
||||
# It should NOT be used to fill a version structure, instead you should use the
|
||||
# SDL_MIXER_VERSION() macro.
|
||||
proc linkedVersion*(): sdl.Pversion{.cdecl, importc: "Mix_Linked_Version",
|
||||
dynlib: MixerLibName.}
|
||||
# Open the mixer with a certain audio format
|
||||
proc openAudio*(frequency: cint, format: uint16, channels: cint,
|
||||
chunksize: cint): cint{.cdecl, importc: "Mix_OpenAudio",
|
||||
dynlib: MixerLibName.}
|
||||
# Dynamically change the number of channels managed by the mixer.
|
||||
# If decreasing the number of channels, the upper channels are
|
||||
# stopped.
|
||||
# This function returns the new number of allocated channels.
|
||||
#
|
||||
proc allocateChannels*(numchannels: cint): cint{.cdecl,
|
||||
importc: "Mix_AllocateChannels", dynlib: MixerLibName.}
|
||||
# Find out what the actual audio device parameters are.
|
||||
# This function returns 1 if the audio has been opened, 0 otherwise.
|
||||
#
|
||||
proc querySpec*(frequency: var cint, format: var uint16, channels: var cint): cint{.
|
||||
cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.}
|
||||
# Load a wave file or a music (.mod .s3m .it .xm) file
|
||||
proc loadWAV_RW*(src: PRWops, freesrc: cint): PChunk{.cdecl,
|
||||
importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.}
|
||||
proc loadWAV*(filename: cstring): PChunk
|
||||
proc loadMUS*(filename: cstring): PMusic{.cdecl, importc: "Mix_LoadMUS",
|
||||
dynlib: MixerLibName.}
|
||||
# Load a wave file of the mixer format from a memory buffer
|
||||
proc quickLoadWAV*(mem: pointer): PChunk{.cdecl,
|
||||
importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.}
|
||||
# Free an audio chunk previously loaded
|
||||
proc freeChunk*(chunk: PChunk){.cdecl, importc: "Mix_FreeChunk",
|
||||
dynlib: MixerLibName.}
|
||||
proc freeMusic*(music: PMusic){.cdecl, importc: "Mix_FreeMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Find out the music format of a mixer music, or the currently playing
|
||||
# music, if 'music' is NULL.
|
||||
proc getMusicType*(music: PMusic): MusicType{.cdecl,
|
||||
importc: "Mix_GetMusicType", dynlib: MixerLibName.}
|
||||
# Set a function that is called after all mixing is performed.
|
||||
# This can be used to provide real-time visual display of the audio stream
|
||||
# or add a custom mixer filter for the stream data.
|
||||
#
|
||||
proc setPostMix*(mixFunc: MixFunction, arg: pointer){.cdecl,
|
||||
importc: "Mix_SetPostMix", dynlib: MixerLibName.}
|
||||
# Add your own music player or additional mixer function.
|
||||
# If 'mix_func' is NULL, the default music player is re-enabled.
|
||||
#
|
||||
proc hookMusic*(mixFunc: MixFunction, arg: pointer){.cdecl,
|
||||
importc: "Mix_HookMusic", dynlib: MixerLibName.}
|
||||
# Add your own callback when the music has finished playing.
|
||||
#
|
||||
proc hookMusicFinished*(musicFinished: pointer){.cdecl,
|
||||
importc: "Mix_HookMusicFinished", dynlib: MixerLibName.}
|
||||
# Get a pointer to the user data for the current music hook
|
||||
proc getMusicHookData*(): pointer{.cdecl, importc: "Mix_GetMusicHookData",
|
||||
dynlib: MixerLibName.}
|
||||
#* Add your own callback when a channel has finished playing. NULL
|
||||
# * to disable callback.*
|
||||
type
|
||||
ChannelFinished* = proc (channel: cint){.cdecl.}
|
||||
{.deprecated: [TChannelFinished: ChannelFinished].}
|
||||
|
||||
proc channelFinished*(channelFinished: ChannelFinished){.cdecl,
|
||||
importc: "Mix_ChannelFinished", dynlib: MixerLibName.}
|
||||
const
|
||||
CHANNEL_POST* = - 2
|
||||
|
||||
type
|
||||
TEffectFunc* = proc (chan: cint, stream: pointer, length: cint,
|
||||
udata: pointer): pointer{.cdecl.}
|
||||
TEffectDone* = proc (chan: cint, udata: pointer): pointer{.cdecl.}
|
||||
proc registerEffect*(chan: cint, f: TEffectFunc, d: TEffectDone,
|
||||
arg: pointer): cint{.cdecl,
|
||||
importc: "Mix_RegisterEffect", dynlib: MixerLibName.}
|
||||
|
||||
proc unregisterEffect*(channel: cint, f: TEffectFunc): cint{.cdecl,
|
||||
importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}
|
||||
|
||||
proc unregisterAllEffects*(channel: cint): cint{.cdecl,
|
||||
importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}
|
||||
const
|
||||
EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"
|
||||
|
||||
proc setPanning*(channel: cint, left: byte, right: byte): cint{.cdecl,
|
||||
importc: "Mix_SetPanning", dynlib: MixerLibName.}
|
||||
|
||||
proc setPosition*(channel: cint, angle: int16, distance: byte): cint{.cdecl,
|
||||
importc: "Mix_SetPosition", dynlib: MixerLibName.}
|
||||
|
||||
proc setDistance*(channel: cint, distance: byte): cint{.cdecl,
|
||||
importc: "Mix_SetDistance", dynlib: MixerLibName.}
|
||||
|
||||
proc setReverseStereo*(channel: cint, flip: cint): cint{.cdecl,
|
||||
importc: "Mix_SetReverseStereo", dynlib: MixerLibName.}
|
||||
|
||||
proc reserveChannels*(num: cint): cint{.cdecl, importc: "Mix_ReserveChannels",
|
||||
dynlib: MixerLibName.}
|
||||
|
||||
proc groupChannel*(which: cint, tag: cint): cint{.cdecl,
|
||||
importc: "Mix_GroupChannel", dynlib: MixerLibName.}
|
||||
proc groupChannels*(`from`: cint, `to`: cint, tag: cint): cint{.cdecl,
|
||||
importc: "Mix_GroupChannels", dynlib: MixerLibName.}
|
||||
proc groupAvailable*(tag: cint): cint{.cdecl, importc: "Mix_GroupAvailable",
|
||||
dynlib: MixerLibName.}
|
||||
proc groupCount*(tag: cint): cint{.cdecl, importc: "Mix_GroupCount",
|
||||
dynlib: MixerLibName.}
|
||||
proc groupOldest*(tag: cint): cint{.cdecl, importc: "Mix_GroupOldest",
|
||||
dynlib: MixerLibName.}
|
||||
proc groupNewer*(tag: cint): cint{.cdecl, importc: "Mix_GroupNewer",
|
||||
dynlib: MixerLibName.}
|
||||
proc playChannelTimed*(channel: cint, chunk: PChunk, loops: cint,
|
||||
ticks: cint): cint{.cdecl,
|
||||
importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.}
|
||||
proc playChannel*(channel: cint, chunk: PChunk, loops: cint): cint
|
||||
proc playMusic*(music: PMusic, loops: cint): cint{.cdecl,
|
||||
importc: "Mix_PlayMusic", dynlib: MixerLibName.}
|
||||
proc fadeInMusic*(music: PMusic, loops: cint, ms: cint): cint{.cdecl,
|
||||
importc: "Mix_FadeInMusic", dynlib: MixerLibName.}
|
||||
proc fadeInChannelTimed*(channel: cint, chunk: PChunk, loops: cint,
|
||||
ms: cint, ticks: cint): cint{.cdecl,
|
||||
importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.}
|
||||
proc fadeInChannel*(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint
|
||||
|
||||
proc volume*(channel: cint, volume: cint): cint{.cdecl, importc: "Mix_Volume",
|
||||
dynlib: MixerLibName.}
|
||||
proc volumeChunk*(chunk: PChunk, volume: cint): cint{.cdecl,
|
||||
importc: "Mix_VolumeChunk", dynlib: MixerLibName.}
|
||||
proc volumeMusic*(volume: cint): cint{.cdecl, importc: "Mix_VolumeMusic",
|
||||
dynlib: MixerLibName.}
|
||||
|
||||
proc haltChannel*(channel: cint): cint{.cdecl, importc: "Mix_HaltChannel",
|
||||
dynlib: MixerLibName.}
|
||||
proc haltGroup*(tag: cint): cint{.cdecl, importc: "Mix_HaltGroup",
|
||||
dynlib: MixerLibName.}
|
||||
proc haltMusic*(): cint{.cdecl, importc: "Mix_HaltMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Change the expiration delay for a particular channel.
|
||||
# The sample will stop playing after the 'ticks' milliseconds have elapsed,
|
||||
# or remove the expiration if 'ticks' is -1
|
||||
#
|
||||
proc expireChannel*(channel: cint, ticks: cint): cint{.cdecl,
|
||||
importc: "Mix_ExpireChannel", dynlib: MixerLibName.}
|
||||
# Halt a channel, fading it out progressively till it's silent
|
||||
# The ms parameter indicates the number of milliseconds the fading
|
||||
# will take.
|
||||
#
|
||||
proc fadeOutChannel*(which: cint, ms: cint): cint{.cdecl,
|
||||
importc: "Mix_FadeOutChannel", dynlib: MixerLibName.}
|
||||
proc fadeOutGroup*(tag: cint, ms: cint): cint{.cdecl,
|
||||
importc: "Mix_FadeOutGroup", dynlib: MixerLibName.}
|
||||
proc fadeOutMusic*(ms: cint): cint{.cdecl, importc: "Mix_FadeOutMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Query the fading status of a channel
|
||||
proc fadingMusic*(): Fading{.cdecl, importc: "Mix_FadingMusic",
|
||||
dynlib: MixerLibName.}
|
||||
proc fadingChannel*(which: cint): Fading{.cdecl,
|
||||
importc: "Mix_FadingChannel", dynlib: MixerLibName.}
|
||||
|
||||
proc pause*(channel: cint){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.}
|
||||
proc resume*(channel: cint){.cdecl, importc: "Mix_Resume",
|
||||
dynlib: MixerLibName.}
|
||||
proc paused*(channel: cint): cint{.cdecl, importc: "Mix_Paused",
|
||||
dynlib: MixerLibName.}
|
||||
|
||||
proc pauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.}
|
||||
proc resumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.}
|
||||
proc rewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.}
|
||||
proc pausedMusic*(): cint{.cdecl, importc: "Mix_PausedMusic",
|
||||
dynlib: MixerLibName.}
|
||||
|
||||
proc setMusicPosition*(position: float64): cint{.cdecl,
|
||||
importc: "Mix_SetMusicPosition", dynlib: MixerLibName.}
|
||||
|
||||
proc playing*(channel: cint): cint{.cdecl, importc: "Mix_Playing",
|
||||
dynlib: MixerLibName.}
|
||||
proc playingMusic*(): cint{.cdecl, importc: "Mix_PlayingMusic",
|
||||
dynlib: MixerLibName.}
|
||||
|
||||
proc setMusicCMD*(command: cstring): cint{.cdecl, importc: "Mix_SetMusicCMD",
|
||||
dynlib: MixerLibName.}
|
||||
|
||||
proc setSynchroValue*(value: cint): cint{.cdecl,
|
||||
importc: "Mix_SetSynchroValue", dynlib: MixerLibName.}
|
||||
proc getSynchroValue*(): cint{.cdecl, importc: "Mix_GetSynchroValue",
|
||||
dynlib: MixerLibName.}
|
||||
|
||||
proc getChunk*(channel: cint): PChunk{.cdecl, importc: "Mix_GetChunk",
|
||||
dynlib: MixerLibName.}
|
||||
|
||||
proc closeAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}
|
||||
|
||||
proc version(x: var sdl.Version) =
|
||||
x.major = MAJOR_VERSION
|
||||
x.minor = MINOR_VERSION
|
||||
x.patch = PATCHLEVEL
|
||||
|
||||
proc loadWAV(filename: cstring): PChunk =
|
||||
result = loadWAV_RW(rWFromFile(filename, "rb"), 1)
|
||||
|
||||
proc playChannel(channel: cint, chunk: PChunk, loops: cint): cint =
|
||||
result = playChannelTimed(channel, chunk, loops, - 1)
|
||||
|
||||
proc fadeInChannel(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint =
|
||||
result = fadeInChannelTimed(channel, chunk, loops, ms, - 1)
|
||||
|
||||
@@ -1,357 +0,0 @@
|
||||
#******************************************************************************
|
||||
# Copy of SDL_Mixer without smpeg dependency and mp3 support
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
sdl
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
MixerLibName = "SDL_mixer.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
MixerLibName = "libSDL_mixer-1.2.0.dylib"
|
||||
else:
|
||||
const
|
||||
MixerLibName = "libSDL_mixer.so"
|
||||
const
|
||||
MAJOR_VERSION* = 1
|
||||
MINOR_VERSION* = 2
|
||||
PATCHLEVEL* = 7 # Backwards compatibility
|
||||
|
||||
CHANNELS* = 8 # Good default values for a PC soundcard
|
||||
DEFAULT_FREQUENCY* = 22050
|
||||
|
||||
when defined(IA32):
|
||||
const
|
||||
DEFAULT_FORMAT* = AUDIO_S16LSB
|
||||
else:
|
||||
const
|
||||
DEFAULT_FORMAT* = AUDIO_S16MSB
|
||||
const
|
||||
DEFAULT_CHANNELS* = 2
|
||||
MAX_VOLUME* = 128 # Volume of a chunk
|
||||
PATH_MAX* = 255
|
||||
|
||||
LIBMIKMOD_VERSION_MAJOR* = 3
|
||||
LIBMIKMOD_VERSION_MINOR* = 1
|
||||
LIBMIKMOD_REVISION* = 8
|
||||
LIBMIKMOD_VERSION* = ((LIBMIKMOD_VERSION_MAJOR shl 16) or
|
||||
(LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION))
|
||||
|
||||
type #music_cmd.h types
|
||||
PMusicCMD* = ptr MusicCMD
|
||||
MusicCMD*{.final.} = object #wavestream.h types
|
||||
filename*: array[0..PATH_MAX - 1, char]
|
||||
cmd*: array[0..PATH_MAX - 1, char]
|
||||
pid*: TSYS_ThreadHandle
|
||||
|
||||
PWAVStream* = ptr WAVStream
|
||||
WAVStream*{.final.} = object #playmidi.h types
|
||||
wavefp*: pointer
|
||||
start*: int32
|
||||
stop*: int32
|
||||
cvt*: TAudioCVT
|
||||
|
||||
PMidiEvent* = ptr MidiEvent
|
||||
MidiEvent*{.final.} = object
|
||||
time*: int32
|
||||
channel*: byte
|
||||
typ*: byte
|
||||
a*: byte
|
||||
b*: byte
|
||||
|
||||
PMidiSong* = ptr MidiSong
|
||||
MidiSong*{.final.} = object #music_ogg.h types
|
||||
samples*: int32
|
||||
events*: PMidiEvent
|
||||
|
||||
POGG_Music* = ptr OGG_Music
|
||||
OGG_Music*{.final.} = object # mikmod.h types
|
||||
#*
|
||||
# * Error codes
|
||||
# *
|
||||
playing*: cint
|
||||
volume*: cint #vf: OggVorbis_File;
|
||||
section*: cint
|
||||
cvt*: TAudioCVT
|
||||
lenAvailable*: cint
|
||||
sndAvailable*: pointer
|
||||
|
||||
ErrorEnum* = enum
|
||||
MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING,
|
||||
MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE,
|
||||
MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER,
|
||||
MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM,
|
||||
MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE,
|
||||
MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO,
|
||||
MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW,
|
||||
MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT,
|
||||
MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS,
|
||||
MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED,
|
||||
MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC,
|
||||
MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE,
|
||||
MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT,
|
||||
MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT,
|
||||
MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD,
|
||||
MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY,
|
||||
MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE,
|
||||
MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT,
|
||||
MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX
|
||||
PMODULE* = ptr MODULE
|
||||
MODULE*{.final.} = object
|
||||
PUNIMOD* = ptr UNIMOD
|
||||
UNIMOD* = MODULE #SDL_mixer.h types
|
||||
# The internal format for an audio chunk
|
||||
PChunk* = ptr Chunk
|
||||
Chunk*{.final.} = object
|
||||
allocated*: cint
|
||||
abuf*: pointer
|
||||
alen*: uint32
|
||||
volume*: byte # Per-sample volume, 0-128
|
||||
|
||||
Fading* = enum
|
||||
MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
|
||||
MusicType* = enum
|
||||
MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG
|
||||
PMusic* = ptr Music
|
||||
Music*{.final.} = object
|
||||
typ*: MusicType
|
||||
|
||||
MixFunction* = proc (udata, stream: pointer, length: cint): pointer{.
|
||||
cdecl.} # This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_mixer library.
|
||||
{.deprecated: [TMusicCMD: MusicCMD, TWAVStream: WAVStream, TMidiEvent: MidiEvent,
|
||||
TMidiSong: MidiSong, TOGG_Music: OGG_Music, TErrorEnum: ErrorEnum,
|
||||
TMODULE: MODULE, TUNIMOD: UNIMOD, TChunk: Chunk, TFading: Fading,
|
||||
TMusicType: MusicType, TMusic: Music, TMixFunction: MixFunction].}
|
||||
|
||||
|
||||
proc version*(x: var sdl.Version)
|
||||
# This function gets the version of the dynamically linked SDL_mixer library.
|
||||
# It should NOT be used to fill a version structure, instead you should use the
|
||||
# SDL_MIXER_VERSION() macro.
|
||||
proc linkedVersion*(): sdl.Pversion{.cdecl, importc: "Mix_Linked_Version",
|
||||
dynlib: MixerLibName.}
|
||||
# Open the mixer with a certain audio format
|
||||
proc openAudio*(frequency: cint, format: uint16, channels: cint,
|
||||
chunksize: cint): cint{.cdecl, importc: "Mix_OpenAudio",
|
||||
dynlib: MixerLibName.}
|
||||
# Dynamically change the number of channels managed by the mixer.
|
||||
# If decreasing the number of channels, the upper channels are
|
||||
# stopped.
|
||||
# This function returns the new number of allocated channels.
|
||||
#
|
||||
proc allocateChannels*(numchannels: cint): cint{.cdecl,
|
||||
importc: "Mix_AllocateChannels", dynlib: MixerLibName.}
|
||||
# Find out what the actual audio device parameters are.
|
||||
# This function returns 1 if the audio has been opened, 0 otherwise.
|
||||
#
|
||||
proc querySpec*(frequency: var cint, format: var uint16, channels: var cint): cint{.
|
||||
cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.}
|
||||
# Load a wave file or a music (.mod .s3m .it .xm) file
|
||||
proc LoadWAV_RW*(src: PRWops, freesrc: cint): PChunk{.cdecl,
|
||||
importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.}
|
||||
proc loadWAV*(filename: cstring): PChunk
|
||||
proc loadMUS*(filename: cstring): PMusic{.cdecl, importc: "Mix_LoadMUS",
|
||||
dynlib: MixerLibName.}
|
||||
# Load a wave file of the mixer format from a memory buffer
|
||||
proc quickLoadWAV*(mem: pointer): PChunk{.cdecl,
|
||||
importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.}
|
||||
# Free an audio chunk previously loaded
|
||||
proc freeChunk*(chunk: PChunk){.cdecl, importc: "Mix_FreeChunk",
|
||||
dynlib: MixerLibName.}
|
||||
proc freeMusic*(music: PMusic){.cdecl, importc: "Mix_FreeMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Find out the music format of a mixer music, or the currently playing
|
||||
# music, if 'music' is NULL.
|
||||
proc getMusicType*(music: PMusic): MusicType{.cdecl,
|
||||
importc: "Mix_GetMusicType", dynlib: MixerLibName.}
|
||||
# Set a function that is called after all mixing is performed.
|
||||
# This can be used to provide real-time visual display of the audio stream
|
||||
# or add a custom mixer filter for the stream data.
|
||||
#
|
||||
proc setPostMix*(mixfunc: MixFunction, arg: pointer){.cdecl,
|
||||
importc: "Mix_SetPostMix", dynlib: MixerLibName.}
|
||||
# Add your own music player or additional mixer function.
|
||||
# If 'mix_func' is NULL, the default music player is re-enabled.
|
||||
#
|
||||
proc hookMusic*(mixFunc: MixFunction, arg: pointer){.cdecl,
|
||||
importc: "Mix_HookMusic", dynlib: MixerLibName.}
|
||||
# Add your own callback when the music has finished playing.
|
||||
#
|
||||
proc hookMusicFinished*(musicFinished: pointer){.cdecl,
|
||||
importc: "Mix_HookMusicFinished", dynlib: MixerLibName.}
|
||||
# Get a pointer to the user data for the current music hook
|
||||
proc getMusicHookData*(): pointer{.cdecl, importc: "Mix_GetMusicHookData",
|
||||
dynlib: MixerLibName.}
|
||||
#* Add your own callback when a channel has finished playing. NULL
|
||||
# * to disable callback.*
|
||||
type
|
||||
ChannelFinished* = proc (channel: cint){.cdecl.}
|
||||
{.deprecated: [TChannelFinished: ChannelFinished].}
|
||||
|
||||
proc channelFinished*(channelFinished: ChannelFinished){.cdecl,
|
||||
importc: "Mix_ChannelFinished", dynlib: MixerLibName.}
|
||||
const
|
||||
CHANNEL_POST* = - 2
|
||||
|
||||
type
|
||||
TEffectFunc* = proc (chan: cint, stream: pointer, length: cint,
|
||||
udata: pointer): pointer{.cdecl.}
|
||||
TEffectDone* = proc (chan: cint, udata: pointer): pointer{.cdecl.}
|
||||
|
||||
proc registerEffect*(chan: cint, f: TEffectFunc, d: TEffectDone,
|
||||
arg: pointer): cint{.cdecl,
|
||||
importc: "Mix_RegisterEffect", dynlib: MixerLibName.}
|
||||
|
||||
proc unregisterEffect*(channel: cint, f: TEffectFunc): cint{.cdecl,
|
||||
importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}
|
||||
|
||||
proc unregisterAllEffects*(channel: cint): cint{.cdecl,
|
||||
importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}
|
||||
|
||||
const
|
||||
EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"
|
||||
|
||||
proc setPanning*(channel: cint, left: byte, right: byte): cint{.cdecl,
|
||||
importc: "Mix_SetPanning", dynlib: MixerLibName.}
|
||||
|
||||
proc setPosition*(channel: cint, angle: int16, distance: byte): cint{.cdecl,
|
||||
importc: "Mix_SetPosition", dynlib: MixerLibName.}
|
||||
|
||||
proc setDistance*(channel: cint, distance: byte): cint{.cdecl,
|
||||
importc: "Mix_SetDistance", dynlib: MixerLibName.}
|
||||
|
||||
proc setReverseStereo*(channel: cint, flip: cint): cint{.cdecl,
|
||||
importc: "Mix_SetReverseStereo", dynlib: MixerLibName.}
|
||||
|
||||
proc reserveChannels*(num: cint): cint{.cdecl, importc: "Mix_ReserveChannels",
|
||||
dynlib: MixerLibName.}
|
||||
|
||||
proc groupChannel*(which: cint, tag: cint): cint{.cdecl,
|
||||
importc: "Mix_GroupChannel", dynlib: MixerLibName.}
|
||||
# Assign several consecutive channels to a group
|
||||
proc groupChannels*(`from`: cint, `to`: cint, tag: cint): cint{.cdecl,
|
||||
importc: "Mix_GroupChannels", dynlib: MixerLibName.}
|
||||
# Finds the first available channel in a group of channels
|
||||
proc groupAvailable*(tag: cint): cint{.cdecl, importc: "Mix_GroupAvailable",
|
||||
dynlib: MixerLibName.}
|
||||
# Returns the number of channels in a group. This is also a subtle
|
||||
# way to get the total number of channels when 'tag' is -1
|
||||
#
|
||||
proc groupCount*(tag: cint): cint{.cdecl, importc: "Mix_GroupCount",
|
||||
dynlib: MixerLibName.}
|
||||
# Finds the "oldest" sample playing in a group of channels
|
||||
proc groupOldest*(tag: cint): cint{.cdecl, importc: "Mix_GroupOldest",
|
||||
dynlib: MixerLibName.}
|
||||
# Finds the "most recent" (i.e. last) sample playing in a group of channels
|
||||
proc groupNewer*(tag: cint): cint{.cdecl, importc: "Mix_GroupNewer",
|
||||
dynlib: MixerLibName.}
|
||||
# The same as above, but the sound is played at most 'ticks' milliseconds
|
||||
proc playChannelTimed*(channel: cint, chunk: PChunk, loops: cint,
|
||||
ticks: cint): cint{.cdecl,
|
||||
importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.}
|
||||
|
||||
proc playChannel*(channel: cint, chunk: PChunk, loops: cint): cint
|
||||
proc playMusic*(music: PMusic, loops: cint): cint{.cdecl,
|
||||
importc: "Mix_PlayMusic", dynlib: MixerLibName.}
|
||||
# Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions
|
||||
proc fadeInMusic*(music: PMusic, loops: cint, ms: cint): cint{.cdecl,
|
||||
importc: "Mix_FadeInMusic", dynlib: MixerLibName.}
|
||||
proc fadeInChannelTimed*(channel: cint, chunk: PChunk, loops: cint,
|
||||
ms: cint, ticks: cint): cint{.cdecl,
|
||||
importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.}
|
||||
proc fadeInChannel*(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint
|
||||
# Set the volume in the range of 0-128 of a specific channel or chunk.
|
||||
# If the specified channel is -1, set volume for all channels.
|
||||
# Returns the original volume.
|
||||
# If the specified volume is -1, just return the current volume.
|
||||
#
|
||||
proc volume*(channel: cint, volume: cint): cint{.cdecl, importc: "Mix_Volume",
|
||||
dynlib: MixerLibName.}
|
||||
proc volumeChunk*(chunk: PChunk, volume: cint): cint{.cdecl,
|
||||
importc: "Mix_VolumeChunk", dynlib: MixerLibName.}
|
||||
proc volumeMusic*(volume: cint): cint{.cdecl, importc: "Mix_VolumeMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Halt playing of a particular channel
|
||||
proc haltChannel*(channel: cint): cint{.cdecl, importc: "Mix_HaltChannel",
|
||||
dynlib: MixerLibName.}
|
||||
proc haltGroup*(tag: cint): cint{.cdecl, importc: "Mix_HaltGroup",
|
||||
dynlib: MixerLibName.}
|
||||
proc haltMusic*(): cint{.cdecl, importc: "Mix_HaltMusic",
|
||||
dynlib: MixerLibName.}
|
||||
|
||||
proc expireChannel*(channel: cint, ticks: cint): cint{.cdecl,
|
||||
importc: "Mix_ExpireChannel", dynlib: MixerLibName.}
|
||||
|
||||
proc fadeOutChannel*(which: cint, ms: cint): cint{.cdecl,
|
||||
importc: "Mix_FadeOutChannel", dynlib: MixerLibName.}
|
||||
proc fadeOutGroup*(tag: cint, ms: cint): cint{.cdecl,
|
||||
importc: "Mix_FadeOutGroup", dynlib: MixerLibName.}
|
||||
proc fadeOutMusic*(ms: cint): cint{.cdecl, importc: "Mix_FadeOutMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Query the fading status of a channel
|
||||
proc fadingMusic*(): Fading{.cdecl, importc: "Mix_FadingMusic",
|
||||
dynlib: MixerLibName.}
|
||||
proc fadingChannel*(which: cint): Fading{.cdecl,
|
||||
importc: "Mix_FadingChannel", dynlib: MixerLibName.}
|
||||
# Pause/Resume a particular channel
|
||||
proc pause*(channel: cint){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.}
|
||||
proc resume*(channel: cint){.cdecl, importc: "Mix_Resume",
|
||||
dynlib: MixerLibName.}
|
||||
proc paused*(channel: cint): cint{.cdecl, importc: "Mix_Paused",
|
||||
dynlib: MixerLibName.}
|
||||
# Pause/Resume the music stream
|
||||
proc pauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.}
|
||||
proc resumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.}
|
||||
proc rewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.}
|
||||
proc pausedMusic*(): cint{.cdecl, importc: "Mix_PausedMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Set the current position in the music stream.
|
||||
# This returns 0 if successful, or -1 if it failed or isn't implemented.
|
||||
# This function is only implemented for MOD music formats (set pattern
|
||||
# order number) and for OGG music (set position in seconds), at the
|
||||
# moment.
|
||||
#
|
||||
proc setMusicPosition*(position: float64): cint{.cdecl,
|
||||
importc: "Mix_SetMusicPosition", dynlib: MixerLibName.}
|
||||
# Check the status of a specific channel.
|
||||
# If the specified channel is -1, check all channels.
|
||||
#
|
||||
proc playing*(channel: cint): cint{.cdecl, importc: "Mix_Playing",
|
||||
dynlib: MixerLibName.}
|
||||
proc playingMusic*(): cint{.cdecl, importc: "Mix_PlayingMusic",
|
||||
dynlib: MixerLibName.}
|
||||
# Stop music and set external music playback command
|
||||
proc setMusicCMD*(command: cstring): cint{.cdecl, importc: "Mix_SetMusicCMD",
|
||||
dynlib: MixerLibName.}
|
||||
# Synchro value is set by MikMod from modules while playing
|
||||
proc setSynchroValue*(value: cint): cint{.cdecl,
|
||||
importc: "Mix_SetSynchroValue", dynlib: MixerLibName.}
|
||||
proc getSynchroValue*(): cint{.cdecl, importc: "Mix_GetSynchroValue",
|
||||
dynlib: MixerLibName.}
|
||||
#
|
||||
# Get the Mix_Chunk currently associated with a mixer channel
|
||||
# Returns nil if it's an invalid channel, or there's no chunk associated.
|
||||
#
|
||||
proc getChunk*(channel: cint): PChunk{.cdecl, importc: "Mix_GetChunk",
|
||||
dynlib: MixerLibName.}
|
||||
# Close the mixer, halting all playing audio
|
||||
proc closeAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}
|
||||
# We'll use SDL for reporting errors
|
||||
|
||||
proc version(x: var Version) =
|
||||
x.major = MAJOR_VERSION
|
||||
x.minor = MINOR_VERSION
|
||||
x.patch = PATCHLEVEL
|
||||
|
||||
proc loadWAV(filename: cstring): PChunk =
|
||||
result = LoadWAV_RW(rWFromFile(filename, "rb"), 1)
|
||||
|
||||
proc playChannel(channel: cint, chunk: PChunk, loops: cint): cint =
|
||||
result = playChannelTimed(channel, chunk, loops, - 1)
|
||||
|
||||
proc fadeInChannel(channel: cint, chunk: PChunk, loops: cint, ms: cint): cint =
|
||||
result = fadeInChannelTimed(channel, chunk, loops, ms, - 1)
|
||||
|
||||
@@ -1,428 +0,0 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# $Id: sdl_net.pas,v 1.7 2005/01/01 02:14:21 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# Borland Delphi SDL_Net - A x-platform network library for use with SDL.
|
||||
# Conversion of the Simple DirectMedia Layer Network Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_net.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Portions created by Dominqiue Louis are
|
||||
# Copyright (C) 2000 - 2001 Dominqiue Louis.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# SDL.pas somehere in your search path
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# April 09 2001 - DL : Initial Translation
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_net.pas,v $
|
||||
# Revision 1.7 2005/01/01 02:14:21 savage
|
||||
# Updated to v1.2.5
|
||||
#
|
||||
# Revision 1.6 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.5 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.4 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.3 2004/04/01 20:53:23 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/16 22:16:40 savage
|
||||
# v1.0 changes
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
sdl
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
NetLibName = "SDL_net.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
NetLibName = "libSDL_net.dylib"
|
||||
else:
|
||||
const
|
||||
NetLibName = "libSDL_net.so"
|
||||
const #* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *
|
||||
MAJOR_VERSION* = 1
|
||||
MINOR_VERSION* = 2
|
||||
PATCHLEVEL* = 5 # SDL_Net.h constants
|
||||
#* Resolve a host name and port to an IP address in network form.
|
||||
# If the function succeeds, it will return 0.
|
||||
# If the host couldn't be resolved, the host portion of the returned
|
||||
# address will be INADDR_NONE, and the function will return -1.
|
||||
# If 'host' is NULL, the resolved host will be set to INADDR_ANY.
|
||||
# *
|
||||
INADDR_ANY* = 0x00000000
|
||||
INADDR_NONE* = 0xFFFFFFFF #***********************************************************************
|
||||
#* UDP network API *
|
||||
#***********************************************************************
|
||||
#* The maximum channels on a a UDP socket *
|
||||
MAX_UDPCHANNELS* = 32 #* The maximum addresses bound to a single UDP socket channel *
|
||||
MAX_UDPADDRESSES* = 4
|
||||
|
||||
type # SDL_net.h types
|
||||
#***********************************************************************
|
||||
#* IPv4 hostname resolution API *
|
||||
#***********************************************************************
|
||||
PIPAddress* = ptr IPAddress
|
||||
IPAddress*{.final.} = object #* TCP network API
|
||||
host*: uint32 # 32-bit IPv4 host address */
|
||||
port*: uint16 # 16-bit protocol port */
|
||||
|
||||
PTCPSocket* = ptr TCPSocket
|
||||
TCPSocket*{.final.} = object # UDP network API
|
||||
ready*: int
|
||||
channel*: int
|
||||
remoteAddress*: IPAddress
|
||||
localAddress*: IPAddress
|
||||
sflag*: int
|
||||
|
||||
PUDP_Channel* = ptr UDP_Channel
|
||||
UDP_Channel*{.final.} = object
|
||||
numbound*: int
|
||||
address*: array[0..MAX_UDPADDRESSES - 1, IPAddress]
|
||||
|
||||
PUDPSocket* = ptr UDPSocket
|
||||
UDPSocket*{.final.} = object
|
||||
ready*: int
|
||||
channel*: int
|
||||
address*: IPAddress
|
||||
binding*: array[0..MAX_UDPCHANNELS - 1, UDP_Channel]
|
||||
|
||||
PUDPpacket* = ptr UDPpacket
|
||||
PPUDPpacket* = ptr PUDPpacket
|
||||
UDPpacket*{.final.} = object #***********************************************************************
|
||||
#* Hooks for checking sockets for available data *
|
||||
#***********************************************************************
|
||||
channel*: int #* The src/dst channel of the packet *
|
||||
data*: pointer #* The packet data *
|
||||
length*: int #* The length of the packet data *
|
||||
maxlen*: int #* The size of the data buffer *
|
||||
status*: int #* packet status after sending *
|
||||
address*: IPAddress #* The source/dest address of an incoming/outgoing packet *
|
||||
|
||||
PSocket* = ptr Socket
|
||||
Socket*{.final.} = object
|
||||
ready*: int
|
||||
channel*: int
|
||||
|
||||
PSocketSet* = ptr SocketSet
|
||||
SocketSet*{.final.} = object # Any network socket can be safely cast to this socket type *
|
||||
numsockets*: int
|
||||
maxsockets*: int
|
||||
sockets*: PSocket
|
||||
|
||||
PGenericSocket* = ptr GenericSocket
|
||||
GenericSocket*{.final.} = object
|
||||
ready*: int
|
||||
{.deprecated: [TSocket: Socket, TSocketSet: SocketSet, TIPAddress: IpAddress,
|
||||
TTCPSocket: TCPSocket, TUDP_Channel: UDP_Channel, TUDPSocket: UDPSocket,
|
||||
TUDPpacket: UDPpacket, TGenericSocket: GenericSocket].}
|
||||
|
||||
proc version*(x: var Version)
|
||||
#* Initialize/Cleanup the network API
|
||||
# SDL must be initialized before calls to functions in this library,
|
||||
# because this library uses utility functions from the SDL library.
|
||||
#*
|
||||
proc init*(): int{.cdecl, importc: "SDLNet_Init", dynlib: NetLibName.}
|
||||
proc quit*(){.cdecl, importc: "SDLNet_Quit", dynlib: NetLibName.}
|
||||
#* Resolve a host name and port to an IP address in network form.
|
||||
# If the function succeeds, it will return 0.
|
||||
# If the host couldn't be resolved, the host portion of the returned
|
||||
# address will be INADDR_NONE, and the function will return -1.
|
||||
# If 'host' is NULL, the resolved host will be set to INADDR_ANY.
|
||||
# *
|
||||
proc resolveHost*(address: var IPAddress, host: cstring, port: uint16): int{.
|
||||
cdecl, importc: "SDLNet_ResolveHost", dynlib: NetLibName.}
|
||||
#* Resolve an ip address to a host name in canonical form.
|
||||
# If the ip couldn't be resolved, this function returns NULL,
|
||||
# otherwise a pointer to a static buffer containing the hostname
|
||||
# is returned. Note that this function is not thread-safe.
|
||||
#*
|
||||
proc resolveIP*(ip: var IPAddress): cstring{.cdecl,
|
||||
importc: "SDLNet_ResolveIP", dynlib: NetLibName.}
|
||||
#***********************************************************************
|
||||
#* TCP network API *
|
||||
#***********************************************************************
|
||||
#* Open a TCP network socket
|
||||
# If ip.host is INADDR_NONE, this creates a local server socket on the
|
||||
# given port, otherwise a TCP connection to the remote host and port is
|
||||
# attempted. The address passed in should already be swapped to network
|
||||
# byte order (addresses returned from SDLNet_ResolveHost() are already
|
||||
# in the correct form).
|
||||
# The newly created socket is returned, or NULL if there was an error.
|
||||
#*
|
||||
proc tcpOpen*(ip: var IPAddress): PTCPSocket{.cdecl,
|
||||
importc: "SDLNet_TCP_Open", dynlib: NetLibName.}
|
||||
#* Accept an incoming connection on the given server socket.
|
||||
# The newly created socket is returned, or NULL if there was an error.
|
||||
#*
|
||||
proc tcpAccept*(server: PTCPSocket): PTCPSocket{.cdecl,
|
||||
importc: "SDLNet_TCP_Accept", dynlib: NetLibName.}
|
||||
#* Get the IP address of the remote system associated with the socket.
|
||||
# If the socket is a server socket, this function returns NULL.
|
||||
#*
|
||||
proc tcpGetPeerAddress*(sock: PTCPSocket): PIPAddress{.cdecl,
|
||||
importc: "SDLNet_TCP_GetPeerAddress", dynlib: NetLibName.}
|
||||
#* Send 'len' bytes of 'data' over the non-server socket 'sock'
|
||||
# This function returns the actual amount of data sent. If the return value
|
||||
# is less than the amount of data sent, then either the remote connection was
|
||||
# closed, or an unknown socket error occurred.
|
||||
#*
|
||||
proc tcpSend*(sock: PTCPSocket, data: pointer, length: int): int{.cdecl,
|
||||
importc: "SDLNet_TCP_Send", dynlib: NetLibName.}
|
||||
#* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
|
||||
# and store them in the buffer pointed to by 'data'.
|
||||
# This function returns the actual amount of data received. If the return
|
||||
# value is less than or equal to zero, then either the remote connection was
|
||||
# closed, or an unknown socket error occurred.
|
||||
#*
|
||||
proc tcpRecv*(sock: PTCPSocket, data: pointer, maxlen: int): int{.cdecl,
|
||||
importc: "SDLNet_TCP_Recv", dynlib: NetLibName.}
|
||||
#* Close a TCP network socket *
|
||||
proc tcpClose*(sock: PTCPSocket){.cdecl, importc: "SDLNet_TCP_Close",
|
||||
dynlib: NetLibName.}
|
||||
#***********************************************************************
|
||||
#* UDP network API *
|
||||
#***********************************************************************
|
||||
#* Allocate/resize/free a single UDP packet 'size' bytes long.
|
||||
# The new packet is returned, or NULL if the function ran out of memory.
|
||||
# *
|
||||
proc allocPacket*(size: int): PUDPpacket{.cdecl,
|
||||
importc: "SDLNet_AllocPacket", dynlib: NetLibName.}
|
||||
proc resizePacket*(packet: PUDPpacket, newsize: int): int{.cdecl,
|
||||
importc: "SDLNet_ResizePacket", dynlib: NetLibName.}
|
||||
proc freePacket*(packet: PUDPpacket){.cdecl, importc: "SDLNet_FreePacket",
|
||||
dynlib: NetLibName.}
|
||||
#* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets,
|
||||
# each 'size' bytes long.
|
||||
# A pointer to the first packet in the array is returned, or NULL if the
|
||||
# function ran out of memory.
|
||||
# *
|
||||
proc allocPacketV*(howmany: int, size: int): PUDPpacket{.cdecl,
|
||||
importc: "SDLNet_AllocPacketV", dynlib: NetLibName.}
|
||||
proc freePacketV*(packetV: PUDPpacket){.cdecl,
|
||||
importc: "SDLNet_FreePacketV", dynlib: NetLibName.}
|
||||
#* Open a UDP network socket
|
||||
# If 'port' is non-zero, the UDP socket is bound to a local port.
|
||||
# This allows other systems to send to this socket via a known port.
|
||||
#*
|
||||
proc udpOpen*(port: uint16): PUDPSocket{.cdecl, importc: "SDLNet_UDP_Open",
|
||||
dynlib: NetLibName.}
|
||||
#* Bind the address 'address' to the requested channel on the UDP socket.
|
||||
# If the channel is -1, then the first unbound channel will be bound with
|
||||
# the given address as it's primary address.
|
||||
# If the channel is already bound, this new address will be added to the
|
||||
# list of valid source addresses for packets arriving on the channel.
|
||||
# If the channel is not already bound, then the address becomes the primary
|
||||
# address, to which all outbound packets on the channel are sent.
|
||||
# This function returns the channel which was bound, or -1 on error.
|
||||
#*
|
||||
proc udpBind*(sock: PUDPSocket, channel: int, address: var IPAddress): int{.
|
||||
cdecl, importc: "SDLNet_UDP_Bind", dynlib: NetLibName.}
|
||||
#* Unbind all addresses from the given channel *
|
||||
proc udpUnbind*(sock: PUDPSocket, channel: int){.cdecl,
|
||||
importc: "SDLNet_UDP_Unbind", dynlib: NetLibName.}
|
||||
#* Get the primary IP address of the remote system associated with the
|
||||
# socket and channel. If the channel is -1, then the primary IP port
|
||||
# of the UDP socket is returned -- this is only meaningful for sockets
|
||||
# opened with a specific port.
|
||||
# If the channel is not bound and not -1, this function returns NULL.
|
||||
# *
|
||||
proc udpGetPeerAddress*(sock: PUDPSocket, channel: int): PIPAddress{.cdecl,
|
||||
importc: "SDLNet_UDP_GetPeerAddress", dynlib: NetLibName.}
|
||||
#* Send a vector of packets to the the channels specified within the packet.
|
||||
# If the channel specified in the packet is -1, the packet will be sent to
|
||||
# the address in the 'src' member of the packet.
|
||||
# Each packet will be updated with the status of the packet after it has
|
||||
# been sent, -1 if the packet send failed.
|
||||
# This function returns the number of packets sent.
|
||||
#*
|
||||
proc udpSendV*(sock: PUDPSocket, packets: PPUDPpacket, npackets: int): int{.
|
||||
cdecl, importc: "SDLNet_UDP_SendV", dynlib: NetLibName.}
|
||||
#* Send a single packet to the specified channel.
|
||||
# If the channel specified in the packet is -1, the packet will be sent to
|
||||
# the address in the 'src' member of the packet.
|
||||
# The packet will be updated with the status of the packet after it has
|
||||
# been sent.
|
||||
# This function returns 1 if the packet was sent, or 0 on error.
|
||||
#*
|
||||
proc udpSend*(sock: PUDPSocket, channel: int, packet: PUDPpacket): int{.
|
||||
cdecl, importc: "SDLNet_UDP_Send", dynlib: NetLibName.}
|
||||
#* Receive a vector of pending packets from the UDP socket.
|
||||
# The returned packets contain the source address and the channel they arrived
|
||||
# on. If they did not arrive on a bound channel, the the channel will be set
|
||||
# to -1.
|
||||
# The channels are checked in highest to lowest order, so if an address is
|
||||
# bound to multiple channels, the highest channel with the source address
|
||||
# bound will be returned.
|
||||
# This function returns the number of packets read from the network, or -1
|
||||
# on error. This function does not block, so can return 0 packets pending.
|
||||
#*
|
||||
proc udpRecvV*(sock: PUDPSocket, packets: PPUDPpacket): int{.cdecl,
|
||||
importc: "SDLNet_UDP_RecvV", dynlib: NetLibName.}
|
||||
#* Receive a single packet from the UDP socket.
|
||||
# The returned packet contains the source address and the channel it arrived
|
||||
# on. If it did not arrive on a bound channel, the the channel will be set
|
||||
# to -1.
|
||||
# The channels are checked in highest to lowest order, so if an address is
|
||||
# bound to multiple channels, the highest channel with the source address
|
||||
# bound will be returned.
|
||||
# This function returns the number of packets read from the network, or -1
|
||||
# on error. This function does not block, so can return 0 packets pending.
|
||||
#*
|
||||
proc udpRecv*(sock: PUDPSocket, packet: PUDPpacket): int{.cdecl,
|
||||
importc: "SDLNet_UDP_Recv", dynlib: NetLibName.}
|
||||
#* Close a UDP network socket *
|
||||
proc udpClose*(sock: PUDPSocket){.cdecl, importc: "SDLNet_UDP_Close",
|
||||
dynlib: NetLibName.}
|
||||
#***********************************************************************
|
||||
#* Hooks for checking sockets for available data *
|
||||
#***********************************************************************
|
||||
#* Allocate a socket set for use with SDLNet_CheckSockets()
|
||||
# This returns a socket set for up to 'maxsockets' sockets, or NULL if
|
||||
# the function ran out of memory.
|
||||
# *
|
||||
proc allocSocketSet*(maxsockets: int): PSocketSet{.cdecl,
|
||||
importc: "SDLNet_AllocSocketSet", dynlib: NetLibName.}
|
||||
#* Add a socket to a set of sockets to be checked for available data *
|
||||
proc addSocket*(theSet: PSocketSet, sock: PGenericSocket): int{.
|
||||
cdecl, importc: "SDLNet_AddSocket", dynlib: NetLibName.}
|
||||
proc tcpAddSocket*(theSet: PSocketSet, sock: PTCPSocket): int
|
||||
proc udpAddSocket*(theSet: PSocketSet, sock: PUDPSocket): int
|
||||
#* Remove a socket from a set of sockets to be checked for available data *
|
||||
proc delSocket*(theSet: PSocketSet, sock: PGenericSocket): int{.
|
||||
cdecl, importc: "SDLNet_DelSocket", dynlib: NetLibName.}
|
||||
proc tcpDelSocket*(theSet: PSocketSet, sock: PTCPSocket): int
|
||||
# SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
|
||||
proc udpDelSocket*(theSet: PSocketSet, sock: PUDPSocket): int
|
||||
#SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
|
||||
#* This function checks to see if data is available for reading on the
|
||||
# given set of sockets. If 'timeout' is 0, it performs a quick poll,
|
||||
# otherwise the function returns when either data is available for
|
||||
# reading, or the timeout in milliseconds has elapsed, which ever occurs
|
||||
# first. This function returns the number of sockets ready for reading,
|
||||
# or -1 if there was an error with the select() system call.
|
||||
#*
|
||||
proc checkSockets*(theSet: PSocketSet, timeout: int32): int{.cdecl,
|
||||
importc: "SDLNet_CheckSockets", dynlib: NetLibName.}
|
||||
#* After calling SDLNet_CheckSockets(), you can use this function on a
|
||||
# socket that was in the socket set, to find out if data is available
|
||||
# for reading.
|
||||
#*
|
||||
proc socketReady*(sock: PGenericSocket): bool
|
||||
#* Free a set of sockets allocated by SDL_NetAllocSocketSet() *
|
||||
proc freeSocketSet*(theSet: PSocketSet){.cdecl,
|
||||
importc: "SDLNet_FreeSocketSet", dynlib: NetLibName.}
|
||||
#***********************************************************************
|
||||
#* Platform-independent data conversion functions *
|
||||
#***********************************************************************
|
||||
#* Write a 16/32 bit value to network packet buffer *
|
||||
proc write16*(value: uint16, area: pointer){.cdecl,
|
||||
importc: "SDLNet_Write16", dynlib: NetLibName.}
|
||||
proc write32*(value: uint32, area: pointer){.cdecl,
|
||||
importc: "SDLNet_Write32", dynlib: NetLibName.}
|
||||
#* Read a 16/32 bit value from network packet buffer *
|
||||
proc read16*(area: pointer): uint16{.cdecl, importc: "SDLNet_Read16",
|
||||
dynlib: NetLibName.}
|
||||
proc read32*(area: pointer): uint32{.cdecl, importc: "SDLNet_Read32",
|
||||
dynlib: NetLibName.}
|
||||
|
||||
proc version(x: var Version) =
|
||||
x.major = MAJOR_VERSION
|
||||
x.minor = MINOR_VERSION
|
||||
x.patch = PATCHLEVEL
|
||||
|
||||
proc tcpAddSocket(theSet: PSocketSet, sock: PTCPSocket): int =
|
||||
result = addSocket(theSet, cast[PGenericSocket](sock))
|
||||
|
||||
proc udpAddSocket(theSet: PSocketSet, sock: PUDPSocket): int =
|
||||
result = addSocket(theSet, cast[PGenericSocket](sock))
|
||||
|
||||
proc tcpDelSocket(theSet: PSocketSet, sock: PTCPSocket): int =
|
||||
result = delSocket(theSet, cast[PGenericSocket](sock))
|
||||
|
||||
proc udpDelSocket(theSet: PSocketSet, sock: PUDPSocket): int =
|
||||
result = delSocket(theSet, cast[PGenericSocket](sock))
|
||||
|
||||
proc socketReady(sock: PGenericSocket): bool =
|
||||
result = sock != nil and sock.ready == 1
|
||||
@@ -1,338 +0,0 @@
|
||||
#
|
||||
# $Id: sdl_ttf.pas,v 1.18 2007/06/01 11:16:33 savage Exp $
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
#
|
||||
# JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer
|
||||
# Conversion of the Simple DirectMedia Layer Headers
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : SDL_ttf.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Dominqiue Louis <Dominique@SavageSoftware.com.au>
|
||||
#
|
||||
# Portions created by Dominqiue Louis are
|
||||
# Copyright (C) 2000 - 2001 Dominqiue Louis.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so
|
||||
# They are available from...
|
||||
# http://www.libsdl.org .
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# December 08 2002 - DL : Fixed definition of TTF_RenderUnicode_Solid
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: sdl_ttf.pas,v $
|
||||
# Revision 1.18 2007/06/01 11:16:33 savage
|
||||
# Added IFDEF UNIX for Workaround.
|
||||
#
|
||||
# Revision 1.17 2007/06/01 08:38:21 savage
|
||||
# Added TTF_RenderText_Solid workaround as suggested by Michalis Kamburelis
|
||||
#
|
||||
# Revision 1.16 2007/05/29 21:32:14 savage
|
||||
# Changes as suggested by Almindor for 64bit compatibility.
|
||||
#
|
||||
# Revision 1.15 2007/05/20 20:32:45 savage
|
||||
# Initial Changes to Handle 64 Bits
|
||||
#
|
||||
# Revision 1.14 2006/12/02 00:19:01 savage
|
||||
# Updated to latest version
|
||||
#
|
||||
# Revision 1.13 2005/04/10 11:48:33 savage
|
||||
# Changes as suggested by Michalis, thanks.
|
||||
#
|
||||
# Revision 1.12 2005/01/05 01:47:14 savage
|
||||
# Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
|
||||
#
|
||||
# Revision 1.11 2005/01/04 23:14:57 savage
|
||||
# Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
|
||||
#
|
||||
# Revision 1.10 2005/01/02 19:07:32 savage
|
||||
# Slight bug fix to use LongInt instead of Long ( Thanks Michalis Kamburelis )
|
||||
#
|
||||
# Revision 1.9 2005/01/01 02:15:20 savage
|
||||
# Updated to v2.0.7
|
||||
#
|
||||
# Revision 1.8 2004/10/07 21:02:32 savage
|
||||
# Fix for FPC
|
||||
#
|
||||
# Revision 1.7 2004/09/30 22:39:50 savage
|
||||
# Added a true type font class which contains a wrap text function.
|
||||
# Changed the sdl_ttf.pas header to reflect the future of jedi-sdl.
|
||||
#
|
||||
# Revision 1.6 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.5 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.4 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.3 2004/04/01 20:53:24 savage
|
||||
# Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/16 22:16:40 savage
|
||||
# v1.0 changes
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
#
|
||||
# Define this to workaround a known bug in some freetype versions.
|
||||
# The error manifests as TTF_RenderGlyph_Solid returning nil (error)
|
||||
# and error message (in SDL_Error) is
|
||||
# "Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable"
|
||||
# See [http://lists.libsdl.org/pipermail/sdl-libsdl.org/2007-March/060459.html]
|
||||
#
|
||||
|
||||
import
|
||||
sdl
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
ttfLibName = "SDL_ttf.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
ttfLibName = "libSDL_ttf-2.0.0.dylib"
|
||||
else:
|
||||
const
|
||||
ttfLibName = "libSDL_ttf(|-2.0).so(|.1|.0)"
|
||||
const
|
||||
MAJOR_VERSION* = 2
|
||||
MINOR_VERSION* = 0
|
||||
PATCHLEVEL* = 8 # Backwards compatibility
|
||||
|
||||
STYLE_NORMAL* = 0x00000000
|
||||
STYLE_BOLD* = 0x00000001
|
||||
STYLE_ITALIC* = 0x00000002
|
||||
STYLE_UNDERLINE* = 0x00000004 # ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark)
|
||||
UNICODE_BOM_NATIVE* = 0x0000FEFF
|
||||
UNICODE_BOM_SWAPPED* = 0x0000FFFE
|
||||
|
||||
type
|
||||
PFont* = ptr Font
|
||||
Font = object
|
||||
{.deprecated: [TFont: Font].}
|
||||
|
||||
|
||||
# This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_ttf library.
|
||||
|
||||
proc linkedVersion*(): sdl.Pversion{.cdecl, importc: "TTF_Linked_Version",
|
||||
dynlib: ttfLibName.}
|
||||
# This function tells the library whether UNICODE text is generally
|
||||
# byteswapped. A UNICODE BOM character in a string will override
|
||||
# this setting for the remainder of that string.
|
||||
#
|
||||
proc byteSwappedUNICODE*(swapped: cint){.cdecl,
|
||||
importc: "TTF_ByteSwappedUNICODE", dynlib: ttfLibName.}
|
||||
#returns 0 on succes, -1 if error occurs
|
||||
proc init*(): cint{.cdecl, importc: "TTF_Init", dynlib: ttfLibName.}
|
||||
#
|
||||
# Open a font file and create a font of the specified point size.
|
||||
# Some .fon fonts will have several sizes embedded in the file, so the
|
||||
# point size becomes the index of choosing which size. If the value
|
||||
# is too high, the last indexed size will be the default.
|
||||
#
|
||||
proc openFont*(filename: cstring, ptsize: cint): PFont{.cdecl,
|
||||
importc: "TTF_OpenFont", dynlib: ttfLibName.}
|
||||
proc openFontIndex*(filename: cstring, ptsize: cint, index: int32): PFont{.
|
||||
cdecl, importc: "TTF_OpenFontIndex", dynlib: ttfLibName.}
|
||||
proc openFontRW*(src: PRWops, freesrc: cint, ptsize: cint): PFont{.cdecl,
|
||||
importc: "TTF_OpenFontRW", dynlib: ttfLibName.}
|
||||
proc openFontIndexRW*(src: PRWops, freesrc: cint, ptsize: cint, index: int32): PFont{.
|
||||
cdecl, importc: "TTF_OpenFontIndexRW", dynlib: ttfLibName.}
|
||||
proc getFontStyle*(font: PFont): cint{.cdecl,
|
||||
importc: "TTF_GetFontStyle", dynlib: ttfLibName.}
|
||||
proc setFontStyle*(font: PFont, style: cint){.cdecl,
|
||||
importc: "TTF_SetFontStyle", dynlib: ttfLibName.}
|
||||
# Get the total height of the font - usually equal to point size
|
||||
proc fontHeight*(font: PFont): cint{.cdecl, importc: "TTF_FontHeight",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the offset from the baseline to the top of the font
|
||||
# This is a positive value, relative to the baseline.
|
||||
#
|
||||
proc fontAscent*(font: PFont): cint{.cdecl, importc: "TTF_FontAscent",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the offset from the baseline to the bottom of the font
|
||||
# This is a negative value, relative to the baseline.
|
||||
#
|
||||
proc fontDescent*(font: PFont): cint{.cdecl, importc: "TTF_FontDescent",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the recommended spacing between lines of text for this font
|
||||
proc fontLineSkip*(font: PFont): cint{.cdecl,
|
||||
importc: "TTF_FontLineSkip", dynlib: ttfLibName.}
|
||||
# Get the number of faces of the font
|
||||
proc fontFaces*(font: PFont): int32{.cdecl, importc: "TTF_FontFaces",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the font face attributes, if any
|
||||
proc fontFaceIsFixedWidth*(font: PFont): cint{.cdecl,
|
||||
importc: "TTF_FontFaceIsFixedWidth", dynlib: ttfLibName.}
|
||||
proc fontFaceFamilyName*(font: PFont): cstring{.cdecl,
|
||||
importc: "TTF_FontFaceFamilyName", dynlib: ttfLibName.}
|
||||
proc fontFaceStyleName*(font: PFont): cstring{.cdecl,
|
||||
importc: "TTF_FontFaceStyleName", dynlib: ttfLibName.}
|
||||
# Get the metrics (dimensions) of a glyph
|
||||
proc glyphMetrics*(font: PFont, ch: uint16, minx: var cint,
|
||||
maxx: var cint, miny: var cint, maxy: var cint,
|
||||
advance: var cint): cint{.cdecl,
|
||||
importc: "TTF_GlyphMetrics", dynlib: ttfLibName.}
|
||||
# Get the dimensions of a rendered string of text
|
||||
proc sizeText*(font: PFont, text: cstring, w: var cint, y: var cint): cint{.
|
||||
cdecl, importc: "TTF_SizeText", dynlib: ttfLibName.}
|
||||
proc sizeUTF8*(font: PFont, text: cstring, w: var cint, y: var cint): cint{.
|
||||
cdecl, importc: "TTF_SizeUTF8", dynlib: ttfLibName.}
|
||||
proc sizeUNICODE*(font: PFont, text: PUInt16, w: var cint, y: var cint): cint{.
|
||||
cdecl, importc: "TTF_SizeUNICODE", dynlib: ttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given text at
|
||||
# fast quality with the given font and color. The 0 pixel is the
|
||||
# colorkey, giving a transparent background, and the 1 pixel is set
|
||||
# to the text color.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc renderUTF8Solid*(font: PFont, text: cstring, fg: Color): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUTF8_Solid", dynlib: ttfLibName.}
|
||||
proc renderUNICODE_Solid*(font: PFont, text: PUInt16, fg: Color): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUNICODE_Solid", dynlib: ttfLibName.}
|
||||
#
|
||||
#Create an 8-bit palettized surface and render the given glyph at
|
||||
# fast quality with the given font and color. The 0 pixel is the
|
||||
# colorkey, giving a transparent background, and the 1 pixel is set
|
||||
# to the text color. The glyph is rendered without any padding or
|
||||
# centering in the X direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc renderGlyphSolid*(font: PFont, ch: uint16, fg: Color): PSurface{.
|
||||
cdecl, importc: "TTF_RenderGlyph_Solid", dynlib: ttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given text at
|
||||
# high quality with the given font and colors. The 0 pixel is background,
|
||||
# while other pixels have varying degrees of the foreground color.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc renderTextShaded*(font: PFont, text: cstring, fg: Color,
|
||||
bg: Color): PSurface{.cdecl,
|
||||
importc: "TTF_RenderText_Shaded", dynlib: ttfLibName.}
|
||||
proc renderUTF8Shaded*(font: PFont, text: cstring, fg: Color,
|
||||
bg: Color): PSurface{.cdecl,
|
||||
importc: "TTF_RenderUTF8_Shaded", dynlib: ttfLibName.}
|
||||
proc renderUNICODE_Shaded*(font: PFont, text: PUInt16, fg: Color,
|
||||
bg: Color): PSurface{.cdecl,
|
||||
importc: "TTF_RenderUNICODE_Shaded", dynlib: ttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given glyph at
|
||||
# high quality with the given font and colors. The 0 pixel is background,
|
||||
# while other pixels have varying degrees of the foreground color.
|
||||
# The glyph is rendered without any padding or centering in the X
|
||||
# direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc renderGlyphShaded*(font: PFont, ch: uint16, fg: Color, bg: Color): PSurface{.
|
||||
cdecl, importc: "TTF_RenderGlyph_Shaded", dynlib: ttfLibName.}
|
||||
# Create a 32-bit ARGB surface and render the given text at high quality,
|
||||
# using alpha blending to dither the font with the given color.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc renderTextBlended*(font: PFont, text: cstring, fg: Color): PSurface{.
|
||||
cdecl, importc: "TTF_RenderText_Blended", dynlib: ttfLibName.}
|
||||
proc renderUTF8Blended*(font: PFont, text: cstring, fg: Color): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUTF8_Blended", dynlib: ttfLibName.}
|
||||
proc RenderUNICODE_Blended*(font: PFont, text: PUInt16, fg: Color): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUNICODE_Blended", dynlib: ttfLibName.}
|
||||
# Create a 32-bit ARGB surface and render the given glyph at high quality,
|
||||
# using alpha blending to dither the font with the given color.
|
||||
# The glyph is rendered without any padding or centering in the X
|
||||
# direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc renderGlyphBlended*(font: PFont, ch: uint16, fg: Color): PSurface{.
|
||||
cdecl, importc: "TTF_RenderGlyph_Blended", dynlib: ttfLibName.}
|
||||
# For compatibility with previous versions, here are the old functions
|
||||
# #define TTF_RenderText(font, text, fg, bg)
|
||||
# TTF_RenderText_Shaded(font, text, fg, bg)
|
||||
# #define TTF_RenderUTF8(font, text, fg, bg)
|
||||
# TTF_RenderUTF8_Shaded(font, text, fg, bg)
|
||||
# #define TTF_RenderUNICODE(font, text, fg, bg)
|
||||
# TTF_RenderUNICODE_Shaded(font, text, fg, bg)
|
||||
# Close an opened font file
|
||||
proc closeFont*(font: PFont){.cdecl, importc: "TTF_CloseFont",
|
||||
dynlib: ttfLibName.}
|
||||
# De-initialize TTF engine
|
||||
proc quit*(){.cdecl, importc: "TTF_Quit", dynlib: ttfLibName.}
|
||||
# Check if the TTF engine is initialized
|
||||
proc wasInit*(): cint{.cdecl, importc: "TTF_WasInit", dynlib: ttfLibName.}
|
||||
|
||||
|
||||
proc version*(x: var sdl.Version) =
|
||||
x.major = MAJOR_VERSION
|
||||
x.minor = MINOR_VERSION
|
||||
x.patch = PATCHLEVEL
|
||||
|
||||
|
||||
proc renderTextSolid*(font: PFont, text: cstring, fg: Color): PSurface{.
|
||||
cdecl, importc: "TTF_RenderText_Solid", dynlib: ttfLibName.}
|
||||
@@ -1,335 +0,0 @@
|
||||
#******************************************************************************
|
||||
#
|
||||
# $Id: smpeg.pas,v 1.7 2004/08/14 22:54:30 savage Exp $
|
||||
#
|
||||
#
|
||||
#
|
||||
# Borland Delphi SMPEG - SDL MPEG Player Library
|
||||
# Conversion of the SMPEG - SDL MPEG Player Library
|
||||
#
|
||||
# Portions created by Sam Lantinga <slouken@devolution.com> are
|
||||
# Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
# 5635-34 Springhouse Dr.
|
||||
# Pleasanton, CA 94588 (USA)
|
||||
#
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# The original files are : smpeg.h
|
||||
#
|
||||
# The initial developer of this Pascal code was :
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Portions created by Matthias Thoma are
|
||||
# Copyright (C) 2000 - 2001 Matthias Thoma.
|
||||
#
|
||||
#
|
||||
# Contributor(s)
|
||||
# --------------
|
||||
# Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion
|
||||
# Matthias Thoma <ma.thoma@gmx.de>
|
||||
#
|
||||
# Obtained through:
|
||||
# Joint Endeavour of Delphi Innovators ( Project JEDI )
|
||||
#
|
||||
# You may retrieve the latest version of this file at the Project
|
||||
# JEDI home page, located at http://delphi-jedi.org
|
||||
#
|
||||
# The contents of this file are used with permission, subject to
|
||||
# the Mozilla Public License Version 1.1 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may
|
||||
# obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
#
|
||||
# Software distributed under the License is distributed on an
|
||||
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Requires
|
||||
# --------
|
||||
# The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL-1.2.so.0
|
||||
# They are available from...
|
||||
# http://www.libsdl.org .
|
||||
#
|
||||
# Programming Notes
|
||||
# -----------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# Revision History
|
||||
# ----------------
|
||||
# May 08 2001 - MT : Initial conversion
|
||||
#
|
||||
# October 12 2001 - DA : Various changes as suggested by David Acklam
|
||||
#
|
||||
# April 03 2003 - DL : Added jedi-sdl.inc include file to support more
|
||||
# Pascal compilers. Initial support is now included
|
||||
# for GnuPascal, VirtualPascal, TMT and obviously
|
||||
# continue support for Delphi Kylix and FreePascal.
|
||||
#
|
||||
# April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support
|
||||
# Fixed all invalid calls to DLL.
|
||||
# Changed constant names to:
|
||||
# const
|
||||
# STATUS_SMPEG_ERROR = -1;
|
||||
# STATUS_SMPEG_STOPPED = 0;
|
||||
# STATUS_SMPEG_PLAYING = 1;
|
||||
# because SMPEG_ERROR is a function (_SMPEG_error
|
||||
# isn't correct), and cannot be two elements with the
|
||||
# same name
|
||||
#
|
||||
# April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added
|
||||
# better TMT Pascal support and under instruction
|
||||
# from Prof. Abimbola Olowofoyeku (The African Chief),
|
||||
# I have added better Gnu Pascal support
|
||||
#
|
||||
# April 30 2003 - DL : under instruction from David Mears AKA
|
||||
# Jason Siletto, I have added FPC Linux support.
|
||||
# This was compiled with fpc 1.1, so remember to set
|
||||
# include file path. ie. -Fi/usr/share/fpcsrc/rtl/*
|
||||
#
|
||||
#
|
||||
# $Log: smpeg.pas,v $
|
||||
# Revision 1.7 2004/08/14 22:54:30 savage
|
||||
# Updated so that Library name defines are correctly defined for MacOS X.
|
||||
#
|
||||
# Revision 1.6 2004/05/10 14:10:04 savage
|
||||
# Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
|
||||
#
|
||||
# Revision 1.5 2004/04/13 09:32:08 savage
|
||||
# Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
|
||||
#
|
||||
# Revision 1.4 2004/04/02 10:40:55 savage
|
||||
# Changed Linux Shared Object name so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
|
||||
#
|
||||
# Revision 1.3 2004/03/31 22:20:02 savage
|
||||
# Windows unit not used in this file, so it was removed to keep the code tidy.
|
||||
#
|
||||
# Revision 1.2 2004/03/30 20:23:28 savage
|
||||
# Tidied up use of UNIX compiler directive.
|
||||
#
|
||||
# Revision 1.1 2004/02/14 23:35:42 savage
|
||||
# version 1 of sdl_image, sdl_mixer and smpeg.
|
||||
#
|
||||
#
|
||||
#
|
||||
#******************************************************************************
|
||||
|
||||
import
|
||||
sdl
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
SmpegLibName = "smpeg.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
SmpegLibName = "libsmpeg.dylib"
|
||||
else:
|
||||
const
|
||||
SmpegLibName = "libsmpeg.so"
|
||||
const
|
||||
FILTER_INFO_MB_ERROR* = 1
|
||||
FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG
|
||||
|
||||
type
|
||||
FilterInfo*{.final.} = object
|
||||
yuvMbSquareError*: PUInt16
|
||||
yuvPixelSquareError*: PUInt16
|
||||
|
||||
PFilterInfo* = ptr FilterInfo # MPEG filter definition
|
||||
PFilter* = ptr Filter # Callback functions for the filter
|
||||
FilterCallback* = proc (dest, source: POverlay, region: PRect,
|
||||
filterInfo: PFilterInfo, data: pointer): pointer{.
|
||||
cdecl.}
|
||||
FilterDestroy* = proc (filter: PFilter): pointer{.cdecl.} # The filter definition itself
|
||||
Filter*{.final.} = object # The null filter (default). It simply copies the source rectangle to the video overlay.
|
||||
flags*: uint32
|
||||
data*: pointer
|
||||
callback*: FilterCallback
|
||||
destroy*: FilterDestroy
|
||||
{.deprecated: [TFilterInfo: FilterInfo, TFilterCallback: FilterCallback,
|
||||
TFilterDestroy: FilterDestroy, TFilter: Filter].}
|
||||
|
||||
proc filterNull*(): PFilter{.cdecl, importc: "SMPEGfilter_null",
|
||||
dynlib: SmpegLibName.}
|
||||
# The bilinear filter. A basic low-pass filter that will produce a smoother image.
|
||||
proc filterBilinear*(): PFilter{.cdecl,
|
||||
importc: "SMPEGfilter_bilinear", dynlib: SmpegLibName.}
|
||||
# The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness
|
||||
proc filterDeblocking*(): PFilter{.cdecl,
|
||||
importc: "SMPEGfilter_deblocking", dynlib: SmpegLibName.}
|
||||
#------------------------------------------------------------------------------
|
||||
# SMPEG.h
|
||||
#------------------------------------------------------------------------------
|
||||
const
|
||||
MAJOR_VERSION* = 0
|
||||
MINOR_VERSION* = 4
|
||||
PATCHLEVEL* = 2
|
||||
|
||||
type
|
||||
TVersion* = object
|
||||
major*: byte
|
||||
minor*: byte
|
||||
patch*: byte
|
||||
|
||||
Pversion* = ptr TVersion # This is the actual SMPEG object
|
||||
TSMPEG* = object
|
||||
PSMPEG* = ptr TSMPEG # Used to get information about the SMPEG object
|
||||
Info* = object
|
||||
hasAudio*: int32
|
||||
hasVideo*: int32
|
||||
width*: int32
|
||||
height*: int32
|
||||
currentFrame*: int32
|
||||
currentFps*: float64
|
||||
audioString*: array[0..79, char]
|
||||
audioCurrentFrame*: int32
|
||||
currentOffset*: uint32
|
||||
totalSize*: uint32
|
||||
currentTime*: float64
|
||||
totalTime*: float64
|
||||
|
||||
PInfo* = ptr Info # Possible MPEG status codes
|
||||
{.deprecated: [TInfo: Info].}
|
||||
|
||||
const
|
||||
STATUS_ERROR* = - 1
|
||||
STATUS_STOPPED* = 0
|
||||
STATUS_PLAYING* = 1
|
||||
|
||||
type
|
||||
Status* = int32
|
||||
Pstatus* = ptr int32 # Matches the declaration of SDL_UpdateRect()
|
||||
TDisplayCallback* = proc (dst: PSurface, x, y: int, w, h: int): pointer{.
|
||||
cdecl.} # Create a new SMPEG object from an MPEG file.
|
||||
# On return, if 'info' is not NULL, it will be filled with information
|
||||
# about the MPEG object.
|
||||
# This function returns a new SMPEG object. Use error() to find out
|
||||
# whether or not there was a problem building the MPEG stream.
|
||||
# The sdl_audio parameter indicates if SMPEG should initialize the SDL audio
|
||||
# subsystem. If not, you will have to use the playaudio() function below
|
||||
# to extract the decoded data.
|
||||
{.deprecated: [Tstatus: Status].}
|
||||
|
||||
proc new*(theFile: cstring, info: PInfo, audio: int): PSMPEG{.cdecl,
|
||||
importc: "SMPEG_new", dynlib: SmpegLibName.}
|
||||
# The same as above for a file descriptor
|
||||
proc newDescr*(theFile: int, info: PInfo, audio: int): PSMPEG{.
|
||||
cdecl, importc: "SMPEG_new_descr", dynlib: SmpegLibName.}
|
||||
# The same as above but for a raw chunk of data. SMPEG makes a copy of the
|
||||
# data, so the application is free to delete after a successful call to this
|
||||
# function.
|
||||
proc newData*(data: pointer, size: int, info: PInfo, audio: int): PSMPEG{.
|
||||
cdecl, importc: "SMPEG_new_data", dynlib: SmpegLibName.}
|
||||
# Get current information about an SMPEG object
|
||||
proc getinfo*(mpeg: PSMPEG, info: PInfo){.cdecl,
|
||||
importc: "SMPEG_getinfo", dynlib: SmpegLibName.}
|
||||
#procedure getinfo(mpeg: PSMPEG; info: Pointer);
|
||||
#cdecl; external SmpegLibName;
|
||||
# Enable or disable audio playback in MPEG stream
|
||||
proc enableaudio*(mpeg: PSMPEG, enable: int){.cdecl,
|
||||
importc: "SMPEG_enableaudio", dynlib: SmpegLibName.}
|
||||
# Enable or disable video playback in MPEG stream
|
||||
proc enablevideo*(mpeg: PSMPEG, enable: int){.cdecl,
|
||||
importc: "SMPEG_enablevideo", dynlib: SmpegLibName.}
|
||||
# Delete an SMPEG object
|
||||
proc delete*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_delete",
|
||||
dynlib: SmpegLibName.}
|
||||
# Get the current status of an SMPEG object
|
||||
proc status*(mpeg: PSMPEG): Status{.cdecl, importc: "SMPEG_status",
|
||||
dynlib: SmpegLibName.}
|
||||
# status
|
||||
# Set the audio volume of an MPEG stream, in the range 0-100
|
||||
proc setVolume*(mpeg: PSMPEG, volume: int){.cdecl,
|
||||
importc: "SMPEG_setvolume", dynlib: SmpegLibName.}
|
||||
# Set the destination surface for MPEG video playback
|
||||
# 'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL.
|
||||
# 'callback' is a function called when an area of 'dst' needs to be updated.
|
||||
# If 'callback' is NULL, the default function (SDL_UpdateRect) will be used.
|
||||
proc setDisplay*(mpeg: PSMPEG, dst: PSurface, surfLock: PMutex,
|
||||
callback: TDisplayCallback){.cdecl,
|
||||
importc: "SMPEG_setdisplay", dynlib: SmpegLibName.}
|
||||
# Set or clear looping play on an SMPEG object
|
||||
proc loop*(mpeg: PSMPEG, repeat: int){.cdecl, importc: "SMPEG_loop",
|
||||
dynlib: SmpegLibName.}
|
||||
# Scale pixel display on an SMPEG object
|
||||
proc scaleXY*(mpeg: PSMPEG, width, height: int){.cdecl,
|
||||
importc: "SMPEG_scaleXY", dynlib: SmpegLibName.}
|
||||
proc scale*(mpeg: PSMPEG, scale: int){.cdecl, importc: "SMPEG_scale",
|
||||
dynlib: SmpegLibName.}
|
||||
proc double*(mpeg: PSMPEG, doubleit: bool)
|
||||
# Move the video display area within the destination surface
|
||||
proc move*(mpeg: PSMPEG, x, y: int){.cdecl, importc: "SMPEG_move",
|
||||
dynlib: SmpegLibName.}
|
||||
# Set the region of the video to be shown
|
||||
proc setDisplayRegion*(mpeg: PSMPEG, x, y, w, h: int){.cdecl,
|
||||
importc: "SMPEG_setdisplayregion", dynlib: SmpegLibName.}
|
||||
# Play an SMPEG object
|
||||
proc play*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_play",
|
||||
dynlib: SmpegLibName.}
|
||||
# Pause/Resume playback of an SMPEG object
|
||||
proc pause*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_pause",
|
||||
dynlib: SmpegLibName.}
|
||||
# Stop playback of an SMPEG object
|
||||
proc stop*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_stop",
|
||||
dynlib: SmpegLibName.}
|
||||
# Rewind the play position of an SMPEG object to the beginning of the MPEG
|
||||
proc rewind*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_rewind",
|
||||
dynlib: SmpegLibName.}
|
||||
# Seek 'bytes' bytes in the MPEG stream
|
||||
proc seek*(mpeg: PSMPEG, bytes: int){.cdecl, importc: "SMPEG_seek",
|
||||
dynlib: SmpegLibName.}
|
||||
# Skip 'seconds' seconds in the MPEG stream
|
||||
proc skip*(mpeg: PSMPEG, seconds: float32){.cdecl, importc: "SMPEG_skip",
|
||||
dynlib: SmpegLibName.}
|
||||
# Render a particular frame in the MPEG video
|
||||
# API CHANGE: This function no longer takes a target surface and position.
|
||||
# Use setdisplay() and move() to set this information.
|
||||
proc renderFrame*(mpeg: PSMPEG, framenum: int){.cdecl,
|
||||
importc: "SMPEG_renderFrame", dynlib: SmpegLibName.}
|
||||
# Render the last frame of an MPEG video
|
||||
proc renderFinal*(mpeg: PSMPEG, dst: PSurface, x, y: int){.cdecl,
|
||||
importc: "SMPEG_renderFinal", dynlib: SmpegLibName.}
|
||||
# Set video filter
|
||||
proc filter*(mpeg: PSMPEG, filter: PFilter): PFilter{.cdecl,
|
||||
importc: "SMPEG_filter", dynlib: SmpegLibName.}
|
||||
# Return NULL if there is no error in the MPEG stream, or an error message
|
||||
# if there was a fatal error in the MPEG stream for the SMPEG object.
|
||||
proc error*(mpeg: PSMPEG): cstring{.cdecl, importc: "SMPEG_error",
|
||||
dynlib: SmpegLibName.}
|
||||
# Exported callback function for audio playback.
|
||||
# The function takes a buffer and the amount of data to fill, and returns
|
||||
# the amount of data in bytes that was actually written. This will be the
|
||||
# amount requested unless the MPEG audio has finished.
|
||||
#
|
||||
proc playAudio*(mpeg: PSMPEG, stream: pointer, length: int): int{.cdecl,
|
||||
importc: "SMPEG_playAudio", dynlib: SmpegLibName.}
|
||||
# Wrapper for playAudio() that can be passed to SDL and SDL_mixer
|
||||
proc playAudioSDL*(mpeg: pointer, stream: pointer, length: int){.cdecl,
|
||||
importc: "SMPEG_playAudioSDL", dynlib: SmpegLibName.}
|
||||
# Get the best SDL audio spec for the audio stream
|
||||
proc wantedSpec*(mpeg: PSMPEG, wanted: PAudioSpec): int{.cdecl,
|
||||
importc: "SMPEG_wantedSpec", dynlib: SmpegLibName.}
|
||||
# Inform SMPEG of the actual SDL audio spec used for sound playback
|
||||
proc actualSpec*(mpeg: PSMPEG, spec: PAudioSpec){.cdecl,
|
||||
importc: "SMPEG_actualSpec", dynlib: SmpegLibName.}
|
||||
# This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL library.
|
||||
proc getversion*(x: var TVersion) =
|
||||
x.major = MAJOR_VERSION
|
||||
x.minor = MINOR_VERSION
|
||||
x.patch = PATCHLEVEL
|
||||
|
||||
proc double(mpeg: PSMPEG, doubleit: bool) =
|
||||
if doubleit: scale(mpeg, 2)
|
||||
else: scale(mpeg, 1)
|
||||
@@ -1,263 +0,0 @@
|
||||
#
|
||||
# $Id: sphinxclient.h 2654 2011-01-31 01:20:58Z kevg $
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2001-2011, Andrew Aksyonoff
|
||||
# Copyright (c) 2008-2011, Sphinx Technologies Inc
|
||||
# All rights reserved
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Library General Public License. You should
|
||||
# have received a copy of the LGPL license along with this program; if you
|
||||
# did not, you can find it at http://www.gnu.org/
|
||||
#
|
||||
|
||||
## Nim wrapper for ``sphinx``.
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
when defined(windows):
|
||||
const
|
||||
sphinxDll* = "spinx.dll"
|
||||
elif defined(macosx):
|
||||
const
|
||||
sphinxDll* = "libspinx.dylib"
|
||||
else:
|
||||
const
|
||||
sphinxDll* = "libspinxclient.so"
|
||||
|
||||
#/ known searchd status codes:
|
||||
const
|
||||
SEARCHD_OK* = 0
|
||||
SEARCHD_ERROR* = 1
|
||||
SEARCHD_RETRY* = 2
|
||||
SEARCHD_WARNING* = 3
|
||||
|
||||
#/ known match modes
|
||||
|
||||
const
|
||||
SPH_MATCH_ALL* = 0
|
||||
SPH_MATCH_ANY* = 1
|
||||
SPH_MATCH_PHRASE* = 2
|
||||
SPH_MATCH_BOOLEAN* = 3
|
||||
SPH_MATCH_EXTENDED* = 4
|
||||
SPH_MATCH_FULLSCAN* = 5
|
||||
SPH_MATCH_EXTENDED2* = 6
|
||||
|
||||
#/ known ranking modes (ext2 only)
|
||||
|
||||
const
|
||||
SPH_RANK_PROXIMITY_BM25* = 0
|
||||
SPH_RANK_BM25* = 1
|
||||
SPH_RANK_NONE* = 2
|
||||
SPH_RANK_WORDCOUNT* = 3
|
||||
SPH_RANK_PROXIMITY* = 4
|
||||
SPH_RANK_MATCHANY* = 5
|
||||
SPH_RANK_FIELDMASK* = 6
|
||||
SPH_RANK_SPH04* = 7
|
||||
SPH_RANK_DEFAULT* = SPH_RANK_PROXIMITY_BM25
|
||||
|
||||
#/ known sort modes
|
||||
|
||||
const
|
||||
SPH_SORT_RELEVANCE* = 0
|
||||
SPH_SORT_ATTR_DESC* = 1
|
||||
SPH_SORT_ATTR_ASC* = 2
|
||||
SPH_SORT_TIME_SEGMENTS* = 3
|
||||
SPH_SORT_EXTENDED* = 4
|
||||
SPH_SORT_EXPR* = 5
|
||||
|
||||
#/ known filter types
|
||||
|
||||
const
|
||||
SPH_FILTER_VALUES* = 0
|
||||
SPH_FILTER_RANGE* = 1
|
||||
SPH_FILTER_FLOATRANGE* = 2
|
||||
|
||||
#/ known attribute types
|
||||
|
||||
const
|
||||
SPH_ATTR_INTEGER* = 1
|
||||
SPH_ATTR_TIMESTAMP* = 2
|
||||
SPH_ATTR_ORDINAL* = 3
|
||||
SPH_ATTR_BOOL* = 4
|
||||
SPH_ATTR_FLOAT* = 5
|
||||
SPH_ATTR_BIGINT* = 6
|
||||
SPH_ATTR_STRING* = 7
|
||||
SPH_ATTR_MULTI* = 0x40000000
|
||||
|
||||
#/ known grouping functions
|
||||
|
||||
const
|
||||
SPH_GROUPBY_DAY* = 0
|
||||
SPH_GROUPBY_WEEK* = 1
|
||||
SPH_GROUPBY_MONTH* = 2
|
||||
SPH_GROUPBY_YEAR* = 3
|
||||
SPH_GROUPBY_ATTR* = 4
|
||||
SPH_GROUPBY_ATTRPAIR* = 5
|
||||
|
||||
type
|
||||
SphinxBool* {.size: sizeof(cint).} = enum
|
||||
SPH_FALSE = 0,
|
||||
SPH_TRUE = 1
|
||||
|
||||
Client {.pure, final.} = object
|
||||
PClient* = ptr Client
|
||||
Wordinfo*{.pure, final.} = object
|
||||
word*: cstring
|
||||
docs*: cint
|
||||
hits*: cint
|
||||
|
||||
Result*{.pure, final.} = object
|
||||
error*: cstring
|
||||
warning*: cstring
|
||||
status*: cint
|
||||
num_fields*: cint
|
||||
fields*: cstringArray
|
||||
num_attrs*: cint
|
||||
attr_names*: cstringArray
|
||||
attr_types*: ptr array [0..100_000, cint]
|
||||
num_matches*: cint
|
||||
values_pool*: pointer
|
||||
total*: cint
|
||||
total_found*: cint
|
||||
time_msec*: cint
|
||||
num_words*: cint
|
||||
words*: ptr array [0..100_000, Wordinfo]
|
||||
|
||||
Excerpt_options*{.pure, final.} = object
|
||||
before_match*: cstring
|
||||
after_match*: cstring
|
||||
chunk_separator*: cstring
|
||||
html_strip_mode*: cstring
|
||||
passage_boundary*: cstring
|
||||
limit*: cint
|
||||
limit_passages*: cint
|
||||
limit_words*: cint
|
||||
around*: cint
|
||||
start_passage_id*: cint
|
||||
exact_phrase*: SphinxBool
|
||||
single_passage*: SphinxBool
|
||||
use_boundaries*: SphinxBool
|
||||
weight_order*: SphinxBool
|
||||
query_mode*: SphinxBool
|
||||
force_all_words*: SphinxBool
|
||||
load_files*: SphinxBool
|
||||
allow_empty*: SphinxBool
|
||||
emit_zones*: SphinxBool
|
||||
|
||||
Keyword_info*{.pure, final.} = object
|
||||
tokenized*: cstring
|
||||
normalized*: cstring
|
||||
num_docs*: cint
|
||||
num_hits*: cint
|
||||
{.deprecated: [TSphinxBool: SphinxBool,
|
||||
Tclient: Client, Twordinfo: Wordinfo, Tresult: Result,
|
||||
Texcerpt_options: Excerpt_options, Tkeyword_info: Keyword_info].}
|
||||
|
||||
proc create*(copy_args: SphinxBool): PClient{.cdecl, importc: "sphinx_create",
|
||||
dynlib: sphinxDll.}
|
||||
proc cleanup*(client: PClient){.cdecl, importc: "sphinx_cleanup",
|
||||
dynlib: sphinxDll.}
|
||||
proc destroy*(client: PClient){.cdecl, importc: "sphinx_destroy",
|
||||
dynlib: sphinxDll.}
|
||||
proc error*(client: PClient): cstring{.cdecl, importc: "sphinx_error",
|
||||
dynlib: sphinxDll.}
|
||||
proc warning*(client: PClient): cstring{.cdecl, importc: "sphinx_warning",
|
||||
dynlib: sphinxDll.}
|
||||
proc set_server*(client: PClient, host: cstring, port: cint): SphinxBool{.cdecl,
|
||||
importc: "sphinx_set_server", dynlib: sphinxDll.}
|
||||
proc set_connect_timeout*(client: PClient, seconds: float32): SphinxBool{.cdecl,
|
||||
importc: "sphinx_set_connect_timeout", dynlib: sphinxDll.}
|
||||
proc open*(client: PClient): SphinxBool{.cdecl, importc: "sphinx_open",
|
||||
dynlib: sphinxDll.}
|
||||
proc close*(client: PClient): SphinxBool{.cdecl, importc: "sphinx_close",
|
||||
dynlib: sphinxDll.}
|
||||
proc set_limits*(client: PClient, offset: cint, limit: cint,
|
||||
max_matches: cint, cutoff: cint): SphinxBool{.cdecl,
|
||||
importc: "sphinx_set_limits", dynlib: sphinxDll.}
|
||||
proc set_max_query_time*(client: PClient, max_query_time: cint): SphinxBool{.
|
||||
cdecl, importc: "sphinx_set_max_query_time", dynlib: sphinxDll.}
|
||||
proc set_match_mode*(client: PClient, mode: cint): SphinxBool{.cdecl,
|
||||
importc: "sphinx_set_match_mode", dynlib: sphinxDll.}
|
||||
proc set_ranking_mode*(client: PClient, ranker: cint): SphinxBool{.cdecl,
|
||||
importc: "sphinx_set_ranking_mode", dynlib: sphinxDll.}
|
||||
proc set_sort_mode*(client: PClient, mode: cint, sortby: cstring): SphinxBool{.
|
||||
cdecl, importc: "sphinx_set_sort_mode", dynlib: sphinxDll.}
|
||||
proc set_field_weights*(client: PClient, num_weights: cint,
|
||||
field_names: cstringArray, field_weights: ptr cint): SphinxBool{.
|
||||
cdecl, importc: "sphinx_set_field_weights", dynlib: sphinxDll.}
|
||||
proc set_index_weights*(client: PClient, num_weights: cint,
|
||||
index_names: cstringArray, index_weights: ptr cint): SphinxBool{.
|
||||
cdecl, importc: "sphinx_set_index_weights", dynlib: sphinxDll.}
|
||||
proc set_id_range*(client: PClient, minid: int64, maxid: int64): SphinxBool{.
|
||||
cdecl, importc: "sphinx_set_id_range", dynlib: sphinxDll.}
|
||||
proc add_filter*(client: PClient, attr: cstring, num_values: cint,
|
||||
values: ptr int64, exclude: SphinxBool): SphinxBool{.cdecl,
|
||||
importc: "sphinx_add_filter", dynlib: sphinxDll.}
|
||||
proc add_filter_range*(client: PClient, attr: cstring, umin: int64,
|
||||
umax: int64, exclude: SphinxBool): SphinxBool{.cdecl,
|
||||
importc: "sphinx_add_filter_range", dynlib: sphinxDll.}
|
||||
proc add_filter_float_range*(client: PClient, attr: cstring, fmin: float32,
|
||||
fmax: float32, exclude: SphinxBool): SphinxBool{.cdecl,
|
||||
importc: "sphinx_add_filter_float_range", dynlib: sphinxDll.}
|
||||
proc set_geoanchor*(client: PClient, attr_latitude: cstring,
|
||||
attr_longitude: cstring, latitude: float32, longitude: float32): SphinxBool{.
|
||||
cdecl, importc: "sphinx_set_geoanchor", dynlib: sphinxDll.}
|
||||
proc set_groupby*(client: PClient, attr: cstring, groupby_func: cint,
|
||||
group_sort: cstring): SphinxBool{.cdecl,
|
||||
importc: "sphinx_set_groupby", dynlib: sphinxDll.}
|
||||
proc set_groupby_distinct*(client: PClient, attr: cstring): SphinxBool{.cdecl,
|
||||
importc: "sphinx_set_groupby_distinct", dynlib: sphinxDll.}
|
||||
proc set_retries*(client: PClient, count: cint, delay: cint): SphinxBool{.cdecl,
|
||||
importc: "sphinx_set_retries", dynlib: sphinxDll.}
|
||||
proc add_override*(client: PClient, attr: cstring, docids: ptr int64,
|
||||
num_values: cint, values: ptr cint): SphinxBool{.cdecl,
|
||||
importc: "sphinx_add_override", dynlib: sphinxDll.}
|
||||
proc set_select*(client: PClient, select_list: cstring): SphinxBool{.cdecl,
|
||||
importc: "sphinx_set_select", dynlib: sphinxDll.}
|
||||
proc reset_filters*(client: PClient){.cdecl,
|
||||
importc: "sphinx_reset_filters", dynlib: sphinxDll.}
|
||||
proc reset_groupby*(client: PClient){.cdecl,
|
||||
importc: "sphinx_reset_groupby", dynlib: sphinxDll.}
|
||||
proc query*(client: PClient, query: cstring, index_list: cstring,
|
||||
comment: cstring): ptr Result{.cdecl, importc: "sphinx_query",
|
||||
dynlib: sphinxDll.}
|
||||
proc add_query*(client: PClient, query: cstring, index_list: cstring,
|
||||
comment: cstring): cint{.cdecl, importc: "sphinx_add_query",
|
||||
dynlib: sphinxDll.}
|
||||
proc run_queries*(client: PClient): ptr Result{.cdecl,
|
||||
importc: "sphinx_run_queries", dynlib: sphinxDll.}
|
||||
proc get_num_results*(client: PClient): cint{.cdecl,
|
||||
importc: "sphinx_get_num_results", dynlib: sphinxDll.}
|
||||
proc get_id*(result: ptr Result, match: cint): int64{.cdecl,
|
||||
importc: "sphinx_get_id", dynlib: sphinxDll.}
|
||||
proc get_weight*(result: ptr Result, match: cint): cint{.cdecl,
|
||||
importc: "sphinx_get_weight", dynlib: sphinxDll.}
|
||||
proc get_int*(result: ptr Result, match: cint, attr: cint): int64{.cdecl,
|
||||
importc: "sphinx_get_int", dynlib: sphinxDll.}
|
||||
proc get_float*(result: ptr Result, match: cint, attr: cint): float32{.cdecl,
|
||||
importc: "sphinx_get_float", dynlib: sphinxDll.}
|
||||
proc get_mva*(result: ptr Result, match: cint, attr: cint): ptr cint{.
|
||||
cdecl, importc: "sphinx_get_mva", dynlib: sphinxDll.}
|
||||
proc get_string*(result: ptr Result, match: cint, attr: cint): cstring{.cdecl,
|
||||
importc: "sphinx_get_string", dynlib: sphinxDll.}
|
||||
proc init_excerpt_options*(opts: ptr Excerpt_options){.cdecl,
|
||||
importc: "sphinx_init_excerpt_options", dynlib: sphinxDll.}
|
||||
proc build_excerpts*(client: PClient, num_docs: cint, docs: cstringArray,
|
||||
index: cstring, words: cstring, opts: ptr Excerpt_options): cstringArray{.
|
||||
cdecl, importc: "sphinx_build_excerpts", dynlib: sphinxDll.}
|
||||
proc update_attributes*(client: PClient, index: cstring, num_attrs: cint,
|
||||
attrs: cstringArray, num_docs: cint,
|
||||
docids: ptr int64, values: ptr int64): cint{.
|
||||
cdecl, importc: "sphinx_update_attributes", dynlib: sphinxDll.}
|
||||
proc update_attributes_mva*(client: PClient, index: cstring, attr: cstring,
|
||||
docid: int64, num_values: cint,
|
||||
values: ptr cint): cint{.cdecl,
|
||||
importc: "sphinx_update_attributes_mva", dynlib: sphinxDll.}
|
||||
proc build_keywords*(client: PClient, query: cstring, index: cstring,
|
||||
hits: SphinxBool, out_num_keywords: ptr cint): ptr Keyword_info{.
|
||||
cdecl, importc: "sphinx_build_keywords", dynlib: sphinxDll.}
|
||||
proc status*(client: PClient, num_rows: ptr cint, num_cols: ptr cint): cstringArray{.
|
||||
cdecl, importc: "sphinx_status", dynlib: sphinxDll.}
|
||||
proc status_destroy*(status: cstringArray, num_rows: cint, num_cols: cint){.
|
||||
cdecl, importc: "sphinx_status_destroy", dynlib: sphinxDll.}
|
||||
@@ -1,188 +0,0 @@
|
||||
#
|
||||
# tre.h - TRE public API definitions
|
||||
#
|
||||
# This software is released under a BSD-style license.
|
||||
# See the file LICENSE for details and copyright.
|
||||
#
|
||||
#
|
||||
|
||||
when not defined(treDll):
|
||||
when hostOS == "windows":
|
||||
const treDll = "tre.dll"
|
||||
elif hostOS == "macosx":
|
||||
const treDll = "libtre.dylib"
|
||||
else:
|
||||
const treDll = "libtre.so(.5|)"
|
||||
|
||||
const
|
||||
APPROX* = 1 ## approximate matching functionality
|
||||
MULTIBYTE* = 1 ## multibyte character set support.
|
||||
VERSION* = "0.8.0" ## TRE version string.
|
||||
VERSION_1* = 0 ## TRE version level 1.
|
||||
VERSION_2* = 8 ## TRE version level 2.
|
||||
VERSION_3* = 0 ## TRE version level 3.
|
||||
|
||||
|
||||
# If the we're not using system regex.h, we need to define the
|
||||
# structs and enums ourselves.
|
||||
|
||||
type
|
||||
Regoff* = cint
|
||||
Regex*{.pure, final.} = object
|
||||
re_nsub*: int ## Number of parenthesized subexpressions.
|
||||
value*: pointer ## For internal use only.
|
||||
|
||||
Regmatch*{.pure, final.} = object
|
||||
rm_so*: Regoff
|
||||
rm_eo*: Regoff
|
||||
|
||||
Reg_errcode*{.size: 4.} = enum ## POSIX tre_regcomp() return error codes.
|
||||
## (In the order listed in the standard.)
|
||||
REG_OK = 0, ## No error.
|
||||
REG_NOMATCH, ## No match.
|
||||
REG_BADPAT, ## Invalid regexp.
|
||||
REG_ECOLLATE, ## Unknown collating element.
|
||||
REG_ECTYPE, ## Unknown character class name.
|
||||
REG_EESCAPE, ## Trailing backslash.
|
||||
REG_ESUBREG, ## Invalid back reference.
|
||||
REG_EBRACK, ## "[]" imbalance
|
||||
REG_EPAREN, ## "\(\)" or "()" imbalance
|
||||
REG_EBRACE, ## "\{\}" or "{}" imbalance
|
||||
REG_BADBR, ## Invalid content of {}
|
||||
REG_ERANGE, ## Invalid use of range operator
|
||||
REG_ESPACE, ## Out of memory.
|
||||
REG_BADRPT ## Invalid use of repetition operators.
|
||||
{.deprecated: [TRegoff: Regoff, TRegex: Regex, TRegmatch: Regmatch,
|
||||
TReg_errcode: Reg_errcode].}
|
||||
|
||||
# POSIX tre_regcomp() flags.
|
||||
|
||||
const
|
||||
REG_EXTENDED* = 1
|
||||
REG_ICASE* = (REG_EXTENDED shl 1)
|
||||
REG_NEWLINE* = (REG_ICASE shl 1)
|
||||
REG_NOSUB* = (REG_NEWLINE shl 1)
|
||||
|
||||
# Extra tre_regcomp() flags.
|
||||
|
||||
const
|
||||
REG_BASIC* = 0
|
||||
REG_LITERAL* = (REG_NOSUB shl 1)
|
||||
REG_RIGHT_ASSOC* = (REG_LITERAL shl 1)
|
||||
REG_UNGREEDY* = (REG_RIGHT_ASSOC shl 1)
|
||||
|
||||
# POSIX tre_regexec() flags.
|
||||
|
||||
const
|
||||
REG_NOTBOL* = 1
|
||||
REG_NOTEOL* = (REG_NOTBOL shl 1)
|
||||
|
||||
# Extra tre_regexec() flags.
|
||||
|
||||
const
|
||||
REG_APPROX_MATCHER* = (REG_NOTEOL shl 1)
|
||||
REG_BACKTRACKING_MATCHER* = (REG_APPROX_MATCHER shl 1)
|
||||
|
||||
# The maximum number of iterations in a bound expression.
|
||||
|
||||
const
|
||||
RE_DUP_MAX* = 255
|
||||
|
||||
# The POSIX.2 regexp functions
|
||||
|
||||
proc regcomp*(preg: var Regex, regex: cstring, cflags: cint): cint{.cdecl,
|
||||
importc: "tre_regcomp", dynlib: treDll.}
|
||||
proc regexec*(preg: var Regex, string: cstring, nmatch: int,
|
||||
pmatch: ptr Regmatch, eflags: cint): cint{.cdecl,
|
||||
importc: "tre_regexec", dynlib: treDll.}
|
||||
proc regerror*(errcode: cint, preg: var Regex, errbuf: cstring,
|
||||
errbuf_size: int): int{.cdecl, importc: "tre_regerror",
|
||||
dynlib: treDll.}
|
||||
proc regfree*(preg: var Regex){.cdecl, importc: "tre_regfree", dynlib: treDll.}
|
||||
# Versions with a maximum length argument and therefore the capability to
|
||||
# handle null characters in the middle of the strings (not in POSIX.2).
|
||||
|
||||
proc regncomp*(preg: var Regex, regex: cstring, len: int, cflags: cint): cint{.
|
||||
cdecl, importc: "tre_regncomp", dynlib: treDll.}
|
||||
proc regnexec*(preg: var Regex, string: cstring, len: int, nmatch: int,
|
||||
pmatch: ptr Regmatch, eflags: cint): cint{.cdecl,
|
||||
importc: "tre_regnexec", dynlib: treDll.}
|
||||
# Approximate matching parameter struct.
|
||||
|
||||
type
|
||||
TRegaparams*{.pure, final.} = object
|
||||
cost_ins*: cint ## Default cost of an inserted character.
|
||||
cost_del*: cint ## Default cost of a deleted character.
|
||||
cost_subst*: cint ## Default cost of a substituted character.
|
||||
max_cost*: cint ## Maximum allowed cost of a match.
|
||||
max_ins*: cint ## Maximum allowed number of inserts.
|
||||
max_del*: cint ## Maximum allowed number of deletes.
|
||||
max_subst*: cint ## Maximum allowed number of substitutes.
|
||||
max_err*: cint ## Maximum allowed number of errors total.
|
||||
|
||||
|
||||
# Approximate matching result struct.
|
||||
|
||||
type
|
||||
TRegamatch*{.pure, final.} = object
|
||||
nmatch*: int ## Length of pmatch[] array.
|
||||
pmatch*: ptr Regmatch ## Submatch data.
|
||||
cost*: cint ## Cost of the match.
|
||||
num_ins*: cint ## Number of inserts in the match.
|
||||
num_del*: cint ## Number of deletes in the match.
|
||||
num_subst*: cint ## Number of substitutes in the match.
|
||||
|
||||
|
||||
# Approximate matching functions.
|
||||
|
||||
proc regaexec*(preg: var Regex, string: cstring, match: ptr TRegamatch,
|
||||
params: TRegaparams, eflags: cint): cint{.cdecl,
|
||||
importc: "tre_regaexec", dynlib: treDll.}
|
||||
proc reganexec*(preg: var Regex, string: cstring, len: int,
|
||||
match: ptr TRegamatch, params: TRegaparams,
|
||||
eflags: cint): cint{.
|
||||
cdecl, importc: "tre_reganexec", dynlib: treDll.}
|
||||
# Sets the parameters to default values.
|
||||
|
||||
proc regaparams_default*(params: ptr TRegaparams){.cdecl,
|
||||
importc: "tre_regaparams_default", dynlib: treDll.}
|
||||
|
||||
type
|
||||
TStrSource*{.pure, final.} = object
|
||||
get_next_char*: proc (c: cstring, pos_add: ptr cint,
|
||||
context: pointer): cint{.cdecl.}
|
||||
rewind*: proc (pos: int, context: pointer){.cdecl.}
|
||||
compare*: proc (pos1: int, pos2: int, len: int, context: pointer): cint{.
|
||||
cdecl.}
|
||||
context*: pointer
|
||||
|
||||
|
||||
proc reguexec*(preg: var Regex, string: ptr TStrSource, nmatch: int,
|
||||
pmatch: ptr Regmatch, eflags: cint): cint{.cdecl,
|
||||
importc: "tre_reguexec", dynlib: treDll.}
|
||||
|
||||
proc runtimeVersion*(): cstring{.cdecl, importc: "tre_version", dynlib: treDll.}
|
||||
# Returns the version string. The returned string is static.
|
||||
|
||||
proc config*(query: cint, result: pointer): cint{.cdecl, importc: "tre_config",
|
||||
dynlib: treDll.}
|
||||
# Returns the value for a config parameter. The type to which `result`
|
||||
# must point to depends of the value of `query`, see documentation for
|
||||
# more details.
|
||||
|
||||
const
|
||||
CONFIG_APPROX* = 0
|
||||
CONFIG_WCHAR* = 1
|
||||
CONFIG_MULTIBYTE* = 2
|
||||
CONFIG_SYSTEM_ABI* = 3
|
||||
CONFIG_VERSION* = 4
|
||||
|
||||
# Returns 1 if the compiled pattern has back references, 0 if not.
|
||||
|
||||
proc have_backrefs*(preg: var Regex): cint{.cdecl,
|
||||
importc: "tre_have_backrefs", dynlib: treDll.}
|
||||
# Returns 1 if the compiled pattern uses approximate matching features,
|
||||
# 0 if not.
|
||||
|
||||
proc have_approx*(preg: var Regex): cint{.cdecl, importc: "tre_have_approx",
|
||||
dynlib: treDll.}
|
||||
@@ -1,251 +0,0 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2013 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## Interface to the `libzip <http://www.nih.at/libzip/index.html>`_ library by
|
||||
## Dieter Baron and Thomas Klausner. This version links
|
||||
## against ``libzip2.so.2`` unless you define the symbol ``useLibzipSrc``; then
|
||||
## it is compiled against some old ``libizp_all.c`` file.
|
||||
|
||||
#
|
||||
# zip.h -- exported declarations.
|
||||
# Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
|
||||
#
|
||||
# This file is part of libzip, a library to manipulate ZIP archives.
|
||||
# The authors can be contacted at <libzip@nih.at>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. The names of the authors may not be used to endorse or promote
|
||||
# products derived from this software without specific prior
|
||||
# written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import times
|
||||
|
||||
when defined(unix) and not defined(useLibzipSrc):
|
||||
when defined(macosx):
|
||||
{.pragma: mydll, dynlib: "libzip2.dylib".}
|
||||
else:
|
||||
{.pragma: mydll, dynlib: "libzip(|2).so(|.2|.1|.0)".}
|
||||
else:
|
||||
when defined(unix):
|
||||
{.passl: "-lz".}
|
||||
{.compile: "libzip_all.c".}
|
||||
{.pragma: mydll.}
|
||||
|
||||
type
|
||||
ZipSourceCmd* = int32
|
||||
|
||||
ZipSourceCallback* = proc (state: pointer, data: pointer, length: int,
|
||||
cmd: ZipSourceCmd): int {.cdecl.}
|
||||
PZipStat* = ptr ZipStat
|
||||
ZipStat* = object ## the 'zip_stat' struct
|
||||
name*: cstring ## name of the file
|
||||
index*: int32 ## index within archive
|
||||
crc*: int32 ## crc of file data
|
||||
mtime*: Time ## modification time
|
||||
size*: int ## size of file (uncompressed)
|
||||
compSize*: int ## size of file (compressed)
|
||||
compMethod*: int16 ## compression method used
|
||||
encryptionMethod*: int16 ## encryption method used
|
||||
|
||||
Zip = object
|
||||
ZipSource = object
|
||||
ZipFile = object
|
||||
|
||||
PZip* = ptr Zip ## represents a zip archive
|
||||
PZipFile* = ptr ZipFile ## represents a file within an archive
|
||||
PZipSource* = ptr ZipSource ## represents a source for an archive
|
||||
{.deprecated: [TZipSourceCmd: ZipSourceCmd, TZipStat: ZipStat, TZip: Zip,
|
||||
TZipSourceCallback: ZipSourceCallback, TZipSource: ZipSource,
|
||||
TZipFile: ZipFile].}
|
||||
|
||||
# flags for zip_name_locate, zip_fopen, zip_stat, ...
|
||||
const
|
||||
ZIP_CREATE* = 1'i32
|
||||
ZIP_EXCL* = 2'i32
|
||||
ZIP_CHECKCONS* = 4'i32
|
||||
ZIP_FL_NOCASE* = 1'i32 ## ignore case on name lookup
|
||||
ZIP_FL_NODIR* = 2'i32 ## ignore directory component
|
||||
ZIP_FL_COMPRESSED* = 4'i32 ## read compressed data
|
||||
ZIP_FL_UNCHANGED* = 8'i32 ## use original data, ignoring changes
|
||||
ZIP_FL_RECOMPRESS* = 16'i32 ## force recompression of data
|
||||
|
||||
const # archive global flags flags
|
||||
ZIP_AFL_TORRENT* = 1'i32 ## torrent zipped
|
||||
|
||||
const # libzip error codes
|
||||
ZIP_ER_OK* = 0'i32 ## N No error
|
||||
ZIP_ER_MULTIDISK* = 1'i32 ## N Multi-disk zip archives not supported
|
||||
ZIP_ER_RENAME* = 2'i32 ## S Renaming temporary file failed
|
||||
ZIP_ER_CLOSE* = 3'i32 ## S Closing zip archive failed
|
||||
ZIP_ER_SEEK* = 4'i32 ## S Seek error
|
||||
ZIP_ER_READ* = 5'i32 ## S Read error
|
||||
ZIP_ER_WRITE* = 6'i32 ## S Write error
|
||||
ZIP_ER_CRC* = 7'i32 ## N CRC error
|
||||
ZIP_ER_ZIPCLOSED* = 8'i32 ## N Containing zip archive was closed
|
||||
ZIP_ER_NOENT* = 9'i32 ## N No such file
|
||||
ZIP_ER_EXISTS* = 10'i32 ## N File already exists
|
||||
ZIP_ER_OPEN* = 11'i32 ## S Can't open file
|
||||
ZIP_ER_TMPOPEN* = 12'i32 ## S Failure to create temporary file
|
||||
ZIP_ER_ZLIB* = 13'i32 ## Z Zlib error
|
||||
ZIP_ER_MEMORY* = 14'i32 ## N Malloc failure
|
||||
ZIP_ER_CHANGED* = 15'i32 ## N Entry has been changed
|
||||
ZIP_ER_COMPNOTSUPP* = 16'i32 ## N Compression method not supported
|
||||
ZIP_ER_EOF* = 17'i32 ## N Premature EOF
|
||||
ZIP_ER_INVAL* = 18'i32 ## N Invalid argument
|
||||
ZIP_ER_NOZIP* = 19'i32 ## N Not a zip archive
|
||||
ZIP_ER_INTERNAL* = 20'i32 ## N Internal error
|
||||
ZIP_ER_INCONS* = 21'i32 ## N Zip archive inconsistent
|
||||
ZIP_ER_REMOVE* = 22'i32 ## S Can't remove file
|
||||
ZIP_ER_DELETED* = 23'i32 ## N Entry has been deleted
|
||||
|
||||
const # type of system error value
|
||||
ZIP_ET_NONE* = 0'i32 ## sys_err unused
|
||||
ZIP_ET_SYS* = 1'i32 ## sys_err is errno
|
||||
ZIP_ET_ZLIB* = 2'i32 ## sys_err is zlib error code
|
||||
|
||||
const # compression methods
|
||||
ZIP_CM_DEFAULT* = -1'i32 ## better of deflate or store
|
||||
ZIP_CM_STORE* = 0'i32 ## stored (uncompressed)
|
||||
ZIP_CM_SHRINK* = 1'i32 ## shrunk
|
||||
ZIP_CM_REDUCE_1* = 2'i32 ## reduced with factor 1
|
||||
ZIP_CM_REDUCE_2* = 3'i32 ## reduced with factor 2
|
||||
ZIP_CM_REDUCE_3* = 4'i32 ## reduced with factor 3
|
||||
ZIP_CM_REDUCE_4* = 5'i32 ## reduced with factor 4
|
||||
ZIP_CM_IMPLODE* = 6'i32 ## imploded
|
||||
## 7 - Reserved for Tokenizing compression algorithm
|
||||
ZIP_CM_DEFLATE* = 8'i32 ## deflated
|
||||
ZIP_CM_DEFLATE64* = 9'i32 ## deflate64
|
||||
ZIP_CM_PKWARE_IMPLODE* = 10'i32 ## PKWARE imploding
|
||||
## 11 - Reserved by PKWARE
|
||||
ZIP_CM_BZIP2* = 12'i32 ## compressed using BZIP2 algorithm
|
||||
## 13 - Reserved by PKWARE
|
||||
ZIP_CM_LZMA* = 14'i32 ## LZMA (EFS)
|
||||
## 15-17 - Reserved by PKWARE
|
||||
ZIP_CM_TERSE* = 18'i32 ## compressed using IBM TERSE (new)
|
||||
ZIP_CM_LZ77* = 19'i32 ## IBM LZ77 z Architecture (PFS)
|
||||
ZIP_CM_WAVPACK* = 97'i32 ## WavPack compressed data
|
||||
ZIP_CM_PPMD* = 98'i32 ## PPMd version I, Rev 1
|
||||
|
||||
const # encryption methods
|
||||
ZIP_EM_NONE* = 0'i32 ## not encrypted
|
||||
ZIP_EM_TRAD_PKWARE* = 1'i32 ## traditional PKWARE encryption
|
||||
|
||||
const
|
||||
ZIP_EM_UNKNOWN* = 0x0000FFFF'i32 ## unknown algorithm
|
||||
|
||||
const
|
||||
ZIP_SOURCE_OPEN* = 0'i32 ## prepare for reading
|
||||
ZIP_SOURCE_READ* = 1'i32 ## read data
|
||||
ZIP_SOURCE_CLOSE* = 2'i32 ## reading is done
|
||||
ZIP_SOURCE_STAT* = 3'i32 ## get meta information
|
||||
ZIP_SOURCE_ERROR* = 4'i32 ## get error information
|
||||
constZIP_SOURCE_FREE* = 5'i32 ## cleanup and free resources
|
||||
|
||||
proc zip_add*(para1: PZip, para2: cstring, para3: PZipSource): int32 {.cdecl,
|
||||
importc: "zip_add", mydll.}
|
||||
proc zip_add_dir*(para1: PZip, para2: cstring): int32 {.cdecl,
|
||||
importc: "zip_add_dir", mydll.}
|
||||
proc zip_close*(para1: PZip) {.cdecl, importc: "zip_close", mydll.}
|
||||
proc zip_delete*(para1: PZip, para2: int32): int32 {.cdecl, mydll,
|
||||
importc: "zip_delete".}
|
||||
proc zip_error_clear*(para1: PZip) {.cdecl, importc: "zip_error_clear", mydll.}
|
||||
proc zip_error_get*(para1: PZip, para2: ptr int32, para3: ptr int32) {.cdecl,
|
||||
importc: "zip_error_get", mydll.}
|
||||
proc zip_error_get_sys_type*(para1: int32): int32 {.cdecl, mydll,
|
||||
importc: "zip_error_get_sys_type".}
|
||||
proc zip_error_to_str*(para1: cstring, para2: int, para3: int32,
|
||||
para4: int32): int32 {.cdecl, mydll,
|
||||
importc: "zip_error_to_str".}
|
||||
proc zip_fclose*(para1: PZipFile) {.cdecl, mydll,
|
||||
importc: "zip_fclose".}
|
||||
proc zip_file_error_clear*(para1: PZipFile) {.cdecl, mydll,
|
||||
importc: "zip_file_error_clear".}
|
||||
proc zip_file_error_get*(para1: PZipFile, para2: ptr int32, para3: ptr int32) {.
|
||||
cdecl, mydll, importc: "zip_file_error_get".}
|
||||
proc zip_file_strerror*(para1: PZipFile): cstring {.cdecl, mydll,
|
||||
importc: "zip_file_strerror".}
|
||||
proc zip_fopen*(para1: PZip, para2: cstring, para3: int32): PZipFile {.cdecl,
|
||||
mydll, importc: "zip_fopen".}
|
||||
proc zip_fopen_index*(para1: PZip, para2: int32, para3: int32): PZipFile {.
|
||||
cdecl, mydll, importc: "zip_fopen_index".}
|
||||
proc zip_fread*(para1: PZipFile, para2: pointer, para3: int): int {.
|
||||
cdecl, mydll, importc: "zip_fread".}
|
||||
proc zip_get_archive_comment*(para1: PZip, para2: ptr int32, para3: int32): cstring {.
|
||||
cdecl, mydll, importc: "zip_get_archive_comment".}
|
||||
proc zip_get_archive_flag*(para1: PZip, para2: int32, para3: int32): int32 {.
|
||||
cdecl, mydll, importc: "zip_get_archive_flag".}
|
||||
proc zip_get_file_comment*(para1: PZip, para2: int32, para3: ptr int32,
|
||||
para4: int32): cstring {.cdecl, mydll,
|
||||
importc: "zip_get_file_comment".}
|
||||
proc zip_get_name*(para1: PZip, para2: int32, para3: int32): cstring {.cdecl,
|
||||
mydll, importc: "zip_get_name".}
|
||||
proc zip_get_num_files*(para1: PZip): int32 {.cdecl,
|
||||
mydll, importc: "zip_get_num_files".}
|
||||
proc zip_name_locate*(para1: PZip, para2: cstring, para3: int32): int32 {.cdecl,
|
||||
mydll, importc: "zip_name_locate".}
|
||||
proc zip_open*(para1: cstring, para2: int32, para3: ptr int32): PZip {.cdecl,
|
||||
mydll, importc: "zip_open".}
|
||||
proc zip_rename*(para1: PZip, para2: int32, para3: cstring): int32 {.cdecl,
|
||||
mydll, importc: "zip_rename".}
|
||||
proc zip_replace*(para1: PZip, para2: int32, para3: PZipSource): int32 {.cdecl,
|
||||
mydll, importc: "zip_replace".}
|
||||
proc zip_set_archive_comment*(para1: PZip, para2: cstring, para3: int32): int32 {.
|
||||
cdecl, mydll, importc: "zip_set_archive_comment".}
|
||||
proc zip_set_archive_flag*(para1: PZip, para2: int32, para3: int32): int32 {.
|
||||
cdecl, mydll, importc: "zip_set_archive_flag".}
|
||||
proc zip_set_file_comment*(para1: PZip, para2: int32, para3: cstring,
|
||||
para4: int32): int32 {.cdecl, mydll,
|
||||
importc: "zip_set_file_comment".}
|
||||
proc zip_source_buffer*(para1: PZip, para2: pointer, para3: int, para4: int32): PZipSource {.
|
||||
cdecl, mydll, importc: "zip_source_buffer".}
|
||||
proc zip_source_file*(para1: PZip, para2: cstring, para3: int, para4: int): PZipSource {.
|
||||
cdecl, mydll, importc: "zip_source_file".}
|
||||
proc zip_source_filep*(para1: PZip, para2: File, para3: int, para4: int): PZipSource {.
|
||||
cdecl, mydll, importc: "zip_source_filep".}
|
||||
proc zip_source_free*(para1: PZipSource) {.cdecl, mydll,
|
||||
importc: "zip_source_free".}
|
||||
proc zip_source_function*(para1: PZip, para2: ZipSourceCallback,
|
||||
para3: pointer): PZipSource {.cdecl, mydll,
|
||||
importc: "zip_source_function".}
|
||||
proc zip_source_zip*(para1: PZip, para2: PZip, para3: int32, para4: int32,
|
||||
para5: int, para6: int): PZipSource {.cdecl, mydll,
|
||||
importc: "zip_source_zip".}
|
||||
proc zip_stat*(para1: PZip, para2: cstring, para3: int32, para4: PZipStat): int32 {.
|
||||
cdecl, mydll, importc: "zip_stat".}
|
||||
proc zip_stat_index*(para1: PZip, para2: int32, para3: int32, para4: PZipStat): int32 {.
|
||||
cdecl, mydll, importc: "zip_stat_index".}
|
||||
proc zip_stat_init*(para1: PZipStat) {.cdecl, mydll, importc: "zip_stat_init".}
|
||||
proc zip_strerror*(para1: PZip): cstring {.cdecl, mydll, importc: "zip_strerror".}
|
||||
proc zip_unchange*(para1: PZip, para2: int32): int32 {.cdecl, mydll,
|
||||
importc: "zip_unchange".}
|
||||
proc zip_unchange_all*(para1: PZip): int32 {.cdecl, mydll,
|
||||
importc: "zip_unchange_all".}
|
||||
proc zip_unchange_archive*(para1: PZip): int32 {.cdecl, mydll,
|
||||
importc: "zip_unchange_archive".}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,312 +0,0 @@
|
||||
# Converted from Pascal
|
||||
|
||||
## Interface to the zlib http://www.zlib.net/ compression library.
|
||||
|
||||
when defined(windows):
|
||||
const libz = "zlib1.dll"
|
||||
elif defined(macosx):
|
||||
const libz = "libz.dylib"
|
||||
else:
|
||||
const libz = "libz.so.1"
|
||||
|
||||
type
|
||||
Uint* = int32
|
||||
Ulong* = int
|
||||
Ulongf* = int
|
||||
Pulongf* = ptr Ulongf
|
||||
ZOffT* = int32
|
||||
Pbyte* = cstring
|
||||
Pbytef* = cstring
|
||||
Allocfunc* = proc (p: pointer, items: Uint, size: Uint): pointer{.cdecl.}
|
||||
FreeFunc* = proc (p: pointer, address: pointer){.cdecl.}
|
||||
InternalState*{.final, pure.} = object
|
||||
PInternalState* = ptr InternalState
|
||||
ZStream*{.final, pure.} = object
|
||||
nextIn*: Pbytef
|
||||
availIn*: Uint
|
||||
totalIn*: Ulong
|
||||
nextOut*: Pbytef
|
||||
availOut*: Uint
|
||||
totalOut*: Ulong
|
||||
msg*: Pbytef
|
||||
state*: PInternalState
|
||||
zalloc*: Allocfunc
|
||||
zfree*: FreeFunc
|
||||
opaque*: pointer
|
||||
dataType*: int32
|
||||
adler*: Ulong
|
||||
reserved*: Ulong
|
||||
|
||||
ZStreamRec* = ZStream
|
||||
PZstream* = ptr ZStream
|
||||
GzFile* = pointer
|
||||
{.deprecated: [TInternalState: InternalState, TAllocfunc: Allocfunc,
|
||||
TFreeFunc: FreeFunc, TZStream: ZStream, TZStreamRec: ZStreamRec].}
|
||||
|
||||
const
|
||||
Z_NO_FLUSH* = 0
|
||||
Z_PARTIAL_FLUSH* = 1
|
||||
Z_SYNC_FLUSH* = 2
|
||||
Z_FULL_FLUSH* = 3
|
||||
Z_FINISH* = 4
|
||||
Z_OK* = 0
|
||||
Z_STREAM_END* = 1
|
||||
Z_NEED_DICT* = 2
|
||||
Z_ERRNO* = -1
|
||||
Z_STREAM_ERROR* = -2
|
||||
Z_DATA_ERROR* = -3
|
||||
Z_MEM_ERROR* = -4
|
||||
Z_BUF_ERROR* = -5
|
||||
Z_VERSION_ERROR* = -6
|
||||
Z_NO_COMPRESSION* = 0
|
||||
Z_BEST_SPEED* = 1
|
||||
Z_BEST_COMPRESSION* = 9
|
||||
Z_DEFAULT_COMPRESSION* = -1
|
||||
Z_FILTERED* = 1
|
||||
Z_HUFFMAN_ONLY* = 2
|
||||
Z_DEFAULT_STRATEGY* = 0
|
||||
Z_BINARY* = 0
|
||||
Z_ASCII* = 1
|
||||
Z_UNKNOWN* = 2
|
||||
Z_DEFLATED* = 8
|
||||
Z_NULL* = 0
|
||||
|
||||
proc zlibVersion*(): cstring{.cdecl, dynlib: libz, importc: "zlibVersion".}
|
||||
proc deflate*(strm: var ZStream, flush: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflate".}
|
||||
proc deflateEnd*(strm: var ZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateEnd".}
|
||||
proc inflate*(strm: var ZStream, flush: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflate".}
|
||||
proc inflateEnd*(strm: var ZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateEnd".}
|
||||
proc deflateSetDictionary*(strm: var ZStream, dictionary: Pbytef,
|
||||
dictLength: Uint): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateSetDictionary".}
|
||||
proc deflateCopy*(dest, source: var ZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateCopy".}
|
||||
proc deflateReset*(strm: var ZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateReset".}
|
||||
proc deflateParams*(strm: var ZStream, level: int32, strategy: int32): int32{.
|
||||
cdecl, dynlib: libz, importc: "deflateParams".}
|
||||
proc inflateSetDictionary*(strm: var ZStream, dictionary: Pbytef,
|
||||
dictLength: Uint): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateSetDictionary".}
|
||||
proc inflateSync*(strm: var ZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateSync".}
|
||||
proc inflateReset*(strm: var ZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateReset".}
|
||||
proc compress*(dest: Pbytef, destLen: Pulongf, source: Pbytef, sourceLen: Ulong): cint{.
|
||||
cdecl, dynlib: libz, importc: "compress".}
|
||||
proc compress2*(dest: Pbytef, destLen: Pulongf, source: Pbytef,
|
||||
sourceLen: Ulong, level: cint): cint{.cdecl, dynlib: libz,
|
||||
importc: "compress2".}
|
||||
proc uncompress*(dest: Pbytef, destLen: Pulongf, source: Pbytef,
|
||||
sourceLen: Ulong): cint{.cdecl, dynlib: libz,
|
||||
importc: "uncompress".}
|
||||
proc compressBound*(sourceLen: Ulong): Ulong {.cdecl, dynlib: libz, importc.}
|
||||
proc gzopen*(path: cstring, mode: cstring): GzFile{.cdecl, dynlib: libz,
|
||||
importc: "gzopen".}
|
||||
proc gzdopen*(fd: int32, mode: cstring): GzFile{.cdecl, dynlib: libz,
|
||||
importc: "gzdopen".}
|
||||
proc gzsetparams*(thefile: GzFile, level: int32, strategy: int32): int32{.cdecl,
|
||||
dynlib: libz, importc: "gzsetparams".}
|
||||
proc gzread*(thefile: GzFile, buf: pointer, length: int): int32{.cdecl,
|
||||
dynlib: libz, importc: "gzread".}
|
||||
proc gzwrite*(thefile: GzFile, buf: pointer, length: int): int32{.cdecl,
|
||||
dynlib: libz, importc: "gzwrite".}
|
||||
proc gzprintf*(thefile: GzFile, format: Pbytef): int32{.varargs, cdecl,
|
||||
dynlib: libz, importc: "gzprintf".}
|
||||
proc gzputs*(thefile: GzFile, s: Pbytef): int32{.cdecl, dynlib: libz,
|
||||
importc: "gzputs".}
|
||||
proc gzgets*(thefile: GzFile, buf: Pbytef, length: int32): Pbytef{.cdecl,
|
||||
dynlib: libz, importc: "gzgets".}
|
||||
proc gzputc*(thefile: GzFile, c: char): char{.cdecl, dynlib: libz,
|
||||
importc: "gzputc".}
|
||||
proc gzgetc*(thefile: GzFile): char{.cdecl, dynlib: libz, importc: "gzgetc".}
|
||||
proc gzflush*(thefile: GzFile, flush: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "gzflush".}
|
||||
proc gzseek*(thefile: GzFile, offset: ZOffT, whence: int32): ZOffT{.cdecl,
|
||||
dynlib: libz, importc: "gzseek".}
|
||||
proc gzrewind*(thefile: GzFile): int32{.cdecl, dynlib: libz, importc: "gzrewind".}
|
||||
proc gztell*(thefile: GzFile): ZOffT{.cdecl, dynlib: libz, importc: "gztell".}
|
||||
proc gzeof*(thefile: GzFile): int {.cdecl, dynlib: libz, importc: "gzeof".}
|
||||
proc gzclose*(thefile: GzFile): int32{.cdecl, dynlib: libz, importc: "gzclose".}
|
||||
proc gzerror*(thefile: GzFile, errnum: var int32): Pbytef{.cdecl, dynlib: libz,
|
||||
importc: "gzerror".}
|
||||
proc adler32*(adler: Ulong, buf: Pbytef, length: Uint): Ulong{.cdecl,
|
||||
dynlib: libz, importc: "adler32".}
|
||||
## **Warning**: Adler-32 requires at least a few hundred bytes to get rolling.
|
||||
proc crc32*(crc: Ulong, buf: Pbytef, length: Uint): Ulong{.cdecl, dynlib: libz,
|
||||
importc: "crc32".}
|
||||
proc deflateInitu*(strm: var ZStream, level: int32, version: cstring,
|
||||
streamSize: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateInit_".}
|
||||
proc inflateInitu*(strm: var ZStream, version: cstring,
|
||||
streamSize: int32): int32 {.
|
||||
cdecl, dynlib: libz, importc: "inflateInit_".}
|
||||
proc deflateInit*(strm: var ZStream, level: int32): int32
|
||||
proc inflateInit*(strm: var ZStream): int32
|
||||
proc deflateInit2u*(strm: var ZStream, level: int32, `method`: int32,
|
||||
windowBits: int32, memLevel: int32, strategy: int32,
|
||||
version: cstring, streamSize: int32): int32 {.cdecl,
|
||||
dynlib: libz, importc: "deflateInit2_".}
|
||||
proc inflateInit2u*(strm: var ZStream, windowBits: int32, version: cstring,
|
||||
streamSize: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateInit2_".}
|
||||
proc deflateInit2*(strm: var ZStream,
|
||||
level, `method`, windowBits, memLevel,
|
||||
strategy: int32): int32
|
||||
proc inflateInit2*(strm: var ZStream, windowBits: int32): int32
|
||||
proc zError*(err: int32): cstring{.cdecl, dynlib: libz, importc: "zError".}
|
||||
proc inflateSyncPoint*(z: PZstream): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateSyncPoint".}
|
||||
proc getCrcTable*(): pointer{.cdecl, dynlib: libz, importc: "get_crc_table".}
|
||||
|
||||
proc deflateInit(strm: var ZStream, level: int32): int32 =
|
||||
result = deflateInitu(strm, level, zlibVersion(), sizeof(ZStream).cint)
|
||||
|
||||
proc inflateInit(strm: var ZStream): int32 =
|
||||
result = inflateInitu(strm, zlibVersion(), sizeof(ZStream).cint)
|
||||
|
||||
proc deflateInit2(strm: var ZStream,
|
||||
level, `method`, windowBits, memLevel,
|
||||
strategy: int32): int32 =
|
||||
result = deflateInit2u(strm, level, `method`, windowBits, memLevel,
|
||||
strategy, zlibVersion(), sizeof(ZStream).cint)
|
||||
|
||||
proc inflateInit2(strm: var ZStream, windowBits: int32): int32 =
|
||||
result = inflateInit2u(strm, windowBits, zlibVersion(),
|
||||
sizeof(ZStream).cint)
|
||||
|
||||
proc zlibAllocMem*(appData: pointer, items, size: int): pointer {.cdecl.} =
|
||||
result = alloc(items * size)
|
||||
|
||||
proc zlibFreeMem*(appData, `block`: pointer) {.cdecl.} =
|
||||
dealloc(`block`)
|
||||
|
||||
proc uncompress*(sourceBuf: cstring, sourceLen: int): string =
|
||||
## Given a deflated cstring returns its inflated version.
|
||||
##
|
||||
## Passing a nil cstring will crash this proc in release mode and assert in
|
||||
## debug mode.
|
||||
##
|
||||
## Returns nil on problems. Failure is a very loose concept, it could be you
|
||||
## passing a non deflated string, or it could mean not having enough memory
|
||||
## for the inflated version.
|
||||
##
|
||||
## The uncompression algorithm is based on
|
||||
## http://stackoverflow.com/questions/17820664 but does ignore some of the
|
||||
## original signed/unsigned checks, so may fail with big chunks of data
|
||||
## exceeding the positive size of an int32. The algorithm can deal with
|
||||
## concatenated deflated values properly.
|
||||
assert (not sourceBuf.isNil)
|
||||
|
||||
var z: ZStream
|
||||
# Initialize input.
|
||||
z.nextIn = sourceBuf
|
||||
|
||||
# Input left to decompress.
|
||||
var left = zlib.Uint(sourceLen)
|
||||
if left < 1:
|
||||
# Incomplete gzip stream, or overflow?
|
||||
return
|
||||
|
||||
# Create starting space for output (guess double the input size, will grow if
|
||||
# needed -- in an extreme case, could end up needing more than 1000 times the
|
||||
# input size)
|
||||
var space = zlib.Uint(left shl 1)
|
||||
if space < left:
|
||||
space = left
|
||||
|
||||
var decompressed = newStringOfCap(space)
|
||||
|
||||
# Initialize output.
|
||||
z.nextOut = addr(decompressed[0])
|
||||
# Output generated so far.
|
||||
var have = 0
|
||||
|
||||
# Set up for gzip decoding.
|
||||
z.availIn = 0;
|
||||
var status = inflateInit2(z, (15+16))
|
||||
if status != Z_OK:
|
||||
# Out of memory.
|
||||
return
|
||||
|
||||
# Make sure memory allocated by inflateInit2() is freed eventually.
|
||||
defer: discard inflateEnd(z)
|
||||
|
||||
# Decompress all of self.
|
||||
while true:
|
||||
# Allow for concatenated gzip streams (per RFC 1952).
|
||||
if status == Z_STREAM_END:
|
||||
discard inflateReset(z)
|
||||
|
||||
# Provide input for inflate.
|
||||
if z.availIn == 0:
|
||||
# This only makes sense in the C version using unsigned values.
|
||||
z.availIn = left
|
||||
left -= z.availIn
|
||||
|
||||
# Decompress the available input.
|
||||
while true:
|
||||
# Allocate more output space if none left.
|
||||
if space == have:
|
||||
# Double space, handle overflow.
|
||||
space = space shl 1
|
||||
if space < have:
|
||||
# Space was likely already maxed out.
|
||||
discard inflateEnd(z)
|
||||
return
|
||||
|
||||
# Increase space.
|
||||
decompressed.setLen(space)
|
||||
# Update output pointer (might have moved).
|
||||
z.nextOut = addr(decompressed[have])
|
||||
|
||||
# Provide output space for inflate.
|
||||
z.availOut = zlib.Uint(space - have)
|
||||
have += z.availOut;
|
||||
|
||||
# Inflate and update the decompressed size.
|
||||
status = inflate(z, Z_SYNC_FLUSH);
|
||||
have -= z.availOut;
|
||||
|
||||
# Bail out if any errors.
|
||||
if status != Z_OK and status != Z_BUF_ERROR and status != Z_STREAM_END:
|
||||
# Invalid gzip stream.
|
||||
discard inflateEnd(z)
|
||||
return
|
||||
|
||||
# Repeat until all output is generated from provided input (note
|
||||
# that even if z.avail_in is zero, there may still be pending
|
||||
# output -- we're not done until the output buffer isn't filled)
|
||||
if z.availOut != 0:
|
||||
break
|
||||
# Continue until all input consumed.
|
||||
if left == 0 and z.availIn == 0:
|
||||
break
|
||||
|
||||
# Verify that the input is a valid gzip stream.
|
||||
if status != Z_STREAM_END:
|
||||
# Incomplete gzip stream.
|
||||
return
|
||||
|
||||
decompressed.setLen(have)
|
||||
swap(result, decompressed)
|
||||
|
||||
|
||||
proc inflate*(buffer: var string): bool {.discardable.} =
|
||||
## Convenience proc which inflates a string containing compressed data.
|
||||
##
|
||||
## Passing a nil string will crash this proc in release mode and assert in
|
||||
## debug mode. It is ok to pass a buffer which doesn't contain deflated data,
|
||||
## in this case the proc won't modify the buffer.
|
||||
##
|
||||
## Returns true if `buffer` was successfully inflated.
|
||||
assert (not buffer.isNil)
|
||||
if buffer.len < 1: return
|
||||
var temp = uncompress(addr(buffer[0]), buffer.len)
|
||||
if not temp.isNil:
|
||||
swap(buffer, temp)
|
||||
result = true
|
||||
@@ -1,176 +0,0 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2008 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module is an interface to the zzip library.
|
||||
|
||||
# Author:
|
||||
# Guido Draheim <guidod@gmx.de>
|
||||
# Tomi Ollila <Tomi.Ollila@iki.fi>
|
||||
# Copyright (c) 1999,2000,2001,2002,2003,2004 Guido Draheim
|
||||
# All rights reserved,
|
||||
# usage allowed under the restrictions of the
|
||||
# Lesser GNU General Public License
|
||||
# or alternatively the restrictions
|
||||
# of the Mozilla Public License 1.1
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
dllname = "zzip.dll"
|
||||
else:
|
||||
const
|
||||
dllname = "libzzip.so"
|
||||
|
||||
type
|
||||
TZZipError* = int32 # Name conflict if we drop the `T`
|
||||
|
||||
const
|
||||
ZZIP_ERROR* = -4096'i32
|
||||
ZZIP_NO_ERROR* = 0'i32 # no error, may be used if user sets it.
|
||||
ZZIP_OUTOFMEM* = ZZIP_ERROR - 20'i32 # out of memory
|
||||
ZZIP_DIR_OPEN* = ZZIP_ERROR - 21'i32 # failed to open zipfile, see errno for details
|
||||
ZZIP_DIR_STAT* = ZZIP_ERROR - 22'i32 # failed to fstat zipfile, see errno for details
|
||||
ZZIP_DIR_SEEK* = ZZIP_ERROR - 23'i32 # failed to lseek zipfile, see errno for details
|
||||
ZZIP_DIR_READ* = ZZIP_ERROR - 24'i32 # failed to read zipfile, see errno for details
|
||||
ZZIP_DIR_TOO_SHORT* = ZZIP_ERROR - 25'i32
|
||||
ZZIP_DIR_EDH_MISSING* = ZZIP_ERROR - 26'i32
|
||||
ZZIP_DIRSIZE* = ZZIP_ERROR - 27'i32
|
||||
ZZIP_ENOENT* = ZZIP_ERROR - 28'i32
|
||||
ZZIP_UNSUPP_COMPR* = ZZIP_ERROR - 29'i32
|
||||
ZZIP_CORRUPTED* = ZZIP_ERROR - 31'i32
|
||||
ZZIP_UNDEF* = ZZIP_ERROR - 32'i32
|
||||
ZZIP_DIR_LARGEFILE* = ZZIP_ERROR - 33'i32
|
||||
|
||||
ZZIP_CASELESS* = 1'i32 shl 12'i32
|
||||
ZZIP_NOPATHS* = 1'i32 shl 13'i32
|
||||
ZZIP_PREFERZIP* = 1'i32 shl 14'i32
|
||||
ZZIP_ONLYZIP* = 1'i32 shl 16'i32
|
||||
ZZIP_FACTORY* = 1'i32 shl 17'i32
|
||||
ZZIP_ALLOWREAL* = 1'i32 shl 18'i32
|
||||
ZZIP_THREADED* = 1'i32 shl 19'i32
|
||||
|
||||
type
|
||||
ZZipDir* {.final, pure.} = object
|
||||
ZZipFile* {.final, pure.} = object
|
||||
ZZipPluginIO* {.final, pure.} = object
|
||||
|
||||
ZZipDirent* {.final, pure.} = object
|
||||
d_compr*: int32 ## compression method
|
||||
d_csize*: int32 ## compressed size
|
||||
st_size*: int32 ## file size / decompressed size
|
||||
d_name*: cstring ## file name / strdupped name
|
||||
|
||||
ZZipStat* = ZZipDirent
|
||||
{.deprecated: [TZZipDir: ZzipDir, TZZipFile: ZzipFile,
|
||||
TZZipPluginIO: ZzipPluginIO, TZZipDirent: ZzipDirent,
|
||||
TZZipStat: ZZipStat].}
|
||||
|
||||
proc zzip_strerror*(errcode: int32): cstring {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_strerror".}
|
||||
proc zzip_strerror_of*(dir: ptr ZZipDir): cstring {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_strerror_of".}
|
||||
proc zzip_errno*(errcode: int32): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_errno".}
|
||||
|
||||
proc zzip_geterror*(dir: ptr ZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_error".}
|
||||
proc zzip_seterror*(dir: ptr ZZipDir, errcode: int32) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_seterror".}
|
||||
proc zzip_compr_str*(compr: int32): cstring {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_compr_str".}
|
||||
proc zzip_dirhandle*(fp: ptr ZZipFile): ptr ZZipDir {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dirhandle".}
|
||||
proc zzip_dirfd*(dir: ptr ZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dirfd".}
|
||||
proc zzip_dir_real*(dir: ptr ZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_real".}
|
||||
proc zzip_file_real*(fp: ptr ZZipFile): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_file_real".}
|
||||
proc zzip_realdir*(dir: ptr ZZipDir): pointer {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_realdir".}
|
||||
proc zzip_realfd*(fp: ptr ZZipFile): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_realfd".}
|
||||
|
||||
proc zzip_dir_alloc*(fileext: cstringArray): ptr ZZipDir {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_dir_alloc".}
|
||||
proc zzip_dir_free*(para1: ptr ZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_free".}
|
||||
|
||||
proc zzip_dir_fdopen*(fd: int32, errcode_p: ptr TZZipError): ptr ZZipDir {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_dir_fdopen".}
|
||||
proc zzip_dir_open*(filename: cstring, errcode_p: ptr TZZipError): ptr ZZipDir {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_dir_open".}
|
||||
proc zzip_dir_close*(dir: ptr ZZipDir) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_close".}
|
||||
proc zzip_dir_read*(dir: ptr ZZipDir, dirent: ptr ZZipDirent): int32 {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_dir_read".}
|
||||
|
||||
proc zzip_opendir*(filename: cstring): ptr ZZipDir {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_opendir".}
|
||||
proc zzip_closedir*(dir: ptr ZZipDir) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_closedir".}
|
||||
proc zzip_readdir*(dir: ptr ZZipDir): ptr ZZipDirent {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_readdir".}
|
||||
proc zzip_rewinddir*(dir: ptr ZZipDir) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_rewinddir".}
|
||||
proc zzip_telldir*(dir: ptr ZZipDir): int {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_telldir".}
|
||||
proc zzip_seekdir*(dir: ptr ZZipDir, offset: int) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_seekdir".}
|
||||
|
||||
proc zzip_file_open*(dir: ptr ZZipDir, name: cstring, flags: int32): ptr ZZipFile {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_file_open".}
|
||||
proc zzip_file_close*(fp: ptr ZZipFile) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_file_close".}
|
||||
proc zzip_file_read*(fp: ptr ZZipFile, buf: pointer, length: int): int {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_file_read".}
|
||||
proc zzip_open*(name: cstring, flags: int32): ptr ZZipFile {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_open".}
|
||||
proc zzip_close*(fp: ptr ZZipFile) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_close".}
|
||||
proc zzip_read*(fp: ptr ZZipFile, buf: pointer, length: int): int {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_read".}
|
||||
|
||||
proc zzip_freopen*(name: cstring, mode: cstring, para3: ptr ZZipFile): ptr ZZipFile {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_freopen".}
|
||||
proc zzip_fopen*(name: cstring, mode: cstring): ptr ZZipFile {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_fopen".}
|
||||
proc zzip_fread*(p: pointer, size: int, nmemb: int,
|
||||
file: ptr ZZipFile): int {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_fread".}
|
||||
proc zzip_fclose*(fp: ptr ZZipFile) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_fclose".}
|
||||
|
||||
proc zzip_rewind*(fp: ptr ZZipFile): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_rewind".}
|
||||
proc zzip_seek*(fp: ptr ZZipFile, offset: int, whence: int32): int {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_seek".}
|
||||
proc zzip_tell*(fp: ptr ZZipFile): int {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_tell".}
|
||||
|
||||
proc zzip_dir_stat*(dir: ptr ZZipDir, name: cstring, zs: ptr ZZipStat,
|
||||
flags: int32): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_stat".}
|
||||
proc zzip_file_stat*(fp: ptr ZZipFile, zs: ptr ZZipStat): int32 {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_file_stat".}
|
||||
proc zzip_fstat*(fp: ptr ZZipFile, zs: ptr ZZipStat): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_fstat".}
|
||||
|
||||
proc zzip_open_shared_io*(stream: ptr ZZipFile, name: cstring,
|
||||
o_flags: int32, o_modes: int32, ext: cstringArray,
|
||||
io: ptr ZZipPluginIO): ptr ZZipFile {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_open_shared_io".}
|
||||
proc zzip_open_ext_io*(name: cstring, o_flags: int32, o_modes: int32,
|
||||
ext: cstringArray, io: ptr ZZipPluginIO): ptr ZZipFile {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_open_ext_io".}
|
||||
proc zzip_opendir_ext_io*(name: cstring, o_modes: int32,
|
||||
ext: cstringArray, io: ptr ZZipPluginIO): ptr ZZipDir {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_opendir_ext_io".}
|
||||
proc zzip_dir_open_ext_io*(filename: cstring, errcode_p: ptr TZZipError,
|
||||
ext: cstringArray, io: ptr ZZipPluginIO): ptr ZZipDir {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_dir_open_ext_io".}
|
||||
@@ -2,10 +2,9 @@
|
||||
## can_alias_generic Nim Module
|
||||
##
|
||||
## Created by Eric Doughty-Papassideris on 2011-02-16.
|
||||
## Copyright (c) 2011 FWA. All rights reserved.
|
||||
|
||||
type
|
||||
TGen[T] = object
|
||||
TGen2[T] = TGen[T]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,12 +6,11 @@ discard """
|
||||
## can_alias_specialised_generic Nim Module
|
||||
##
|
||||
## Created by Eric Doughty-Papassideris on 2011-02-16.
|
||||
## Copyright (c) 2011 FWA. All rights reserved.
|
||||
|
||||
type
|
||||
TGen[T] = object
|
||||
TSpef = TGen[string]
|
||||
|
||||
|
||||
var
|
||||
s: TSpef
|
||||
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
## can_inherit_generic Nim Module
|
||||
##
|
||||
## Created by Eric Doughty-Papassideris on 2011-02-16.
|
||||
## Copyright (c) 2011 FWA. All rights reserved.
|
||||
|
||||
type
|
||||
TGen[T] = object of TObject
|
||||
x, y: T
|
||||
|
||||
|
||||
TSpef[T] = object of TGen[T]
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
## can_specialise_generic Nim Module
|
||||
##
|
||||
## Created by Eric Doughty-Papassideris on 2011-02-16.
|
||||
## Copyright (c) 2011 FWA. All rights reserved.
|
||||
|
||||
type
|
||||
TGen[T] = object {.inheritable.}
|
||||
TSpef = object of TGen[string]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
## specialised_is_equivalent Nim Module
|
||||
##
|
||||
## Created by Eric Doughty-Papassideris on 2011-02-16.
|
||||
## Copyright (c) 2011 FWA. All rights reserved.
|
||||
|
||||
type
|
||||
TGen[T] = tuple[a: T]
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#
|
||||
|
||||
const
|
||||
haveZipLib = defined(unix)
|
||||
haveZipLib = false # zip not in stdlib anymore
|
||||
|
||||
when haveZipLib:
|
||||
import zipfiles
|
||||
|
||||
@@ -43,13 +43,12 @@ srcdoc2: "pure/complex;pure/times;pure/osproc;pure/pegs;pure/dynlib"
|
||||
srcdoc2: "pure/parseopt;pure/parseopt2;pure/hashes;pure/strtabs;pure/lexbase"
|
||||
srcdoc2: "pure/parsecfg;pure/parsexml;pure/parsecsv;pure/parsesql"
|
||||
srcdoc2: "pure/streams;pure/terminal;pure/cgi;pure/unicode"
|
||||
srcdoc2: "impure/zipfiles;pure/htmlgen;pure/parseutils;pure/browsers"
|
||||
srcdoc2: "pure/htmlgen;pure/parseutils;pure/browsers"
|
||||
srcdoc2: "impure/db_postgres;impure/db_mysql;impure/db_sqlite"
|
||||
srcdoc2: "pure/httpserver;pure/httpclient;pure/smtp;impure/ssl;pure/fsmonitor"
|
||||
srcdoc2: "pure/ropes;pure/unidecode/unidecode;pure/xmldom;pure/xmldomparser"
|
||||
srcdoc2: "pure/xmlparser;pure/htmlparser;pure/xmltree;pure/colors;pure/mimetypes"
|
||||
srcdoc2: "pure/json;pure/base64;pure/scgi;pure/redis;impure/graphics"
|
||||
srcdoc2: "impure/rdstdin;impure/dialogs"
|
||||
srcdoc2: "pure/json;pure/base64;pure/scgi"
|
||||
srcdoc2: "pure/collections/tables;pure/collections/sets;pure/collections/lists"
|
||||
srcdoc2: "pure/collections/intsets;pure/collections/queues;pure/encodings"
|
||||
srcdoc2: "pure/events;pure/collections/sequtils;pure/cookies"
|
||||
@@ -68,17 +67,13 @@ srcdoc2: "pure/basic2d;pure/basic3d"
|
||||
; Note: everything under 'webdoc' doesn't get listed in the index, so wrappers
|
||||
; should live here
|
||||
|
||||
webdoc: "wrappers/mysql;wrappers/iup;wrappers/sphinx"
|
||||
webdoc: "wrappers/mysql;wrappers/iup"
|
||||
webdoc: "wrappers/sqlite3;wrappers/postgres;wrappers/tinyc;wrappers/odbcsql"
|
||||
webdoc: "wrappers/expat;wrappers/pcre"
|
||||
webdoc: "wrappers/tre;wrappers/openssl"
|
||||
webdoc: "wrappers/pcre"
|
||||
webdoc: "wrappers/openssl"
|
||||
webdoc: "wrappers/libuv;wrappers/joyent_http_parser"
|
||||
|
||||
webdoc: "posix/posix;wrappers/odbcsql"
|
||||
webdoc: "wrappers/zip/zlib;wrappers/zip/libzip"
|
||||
webdoc: "wrappers/libsvm.nim"
|
||||
webdoc: "windows"
|
||||
webdoc: "wrappers/readline/readline;wrappers/readline/history"
|
||||
webdoc: "wrappers/readline/rltypedefs"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user