examples/lib use the new wrappers
This commit is contained in:
parent
ddb7185482
commit
b559285b78
133 changed files with 17038 additions and 151734 deletions
|
|
@ -1,241 +0,0 @@
|
|||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2008 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. However, this does not need any external
|
||||
## library (DLL, lib*.so), as the source for this library is included and
|
||||
## compiled with this interface.
|
||||
|
||||
#
|
||||
# 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
|
||||
|
||||
{.compile: "libzip_all.c".}
|
||||
when defined(unix):
|
||||
{.passl: "-lz".}
|
||||
|
||||
type
|
||||
Tzip_source_cmd* = int32
|
||||
|
||||
Tzip_source_callback* = proc (state: pointer, data: pointer, length: int,
|
||||
cmd: Tzip_source_cmd): int {.cdecl.}
|
||||
Pzip_stat* = ptr Tzip_stat
|
||||
Tzip_stat* {.final, pure.} = object
|
||||
name*: cstring ## name of the file
|
||||
index*: int32 ## index within archive
|
||||
crc*: int32 ## crc of file data
|
||||
mtime*: TTime ## modification time
|
||||
size*: int ## size of file (uncompressed)
|
||||
comp_size*: int ## size of file (compressed)
|
||||
comp_method*: int16 ## compression method used
|
||||
encryption_method*: int16 ## encryption method used
|
||||
|
||||
Tzip {.final, pure.} = object
|
||||
Tzip_source {.final, pure.} = object
|
||||
Tzip_file {.final, pure.} = object
|
||||
|
||||
Pzip* = ptr Tzip ## represents a zip archive
|
||||
Pzip_file* = ptr Tzip_file ## represents a file within an archive
|
||||
Pzip_source* = ptr Tzip_source ## represents a source for an archive
|
||||
|
||||
|
||||
# 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: Pzip_source): int32 {.cdecl,
|
||||
importc: "zip_add".}
|
||||
proc zip_add_dir*(para1: Pzip, para2: cstring): int32 {.cdecl,
|
||||
importc: "zip_add_dir".}
|
||||
proc zip_close*(para1: Pzip) {.cdecl, importc: "zip_close".}
|
||||
proc zip_delete*(para1: Pzip, para2: int32): int32 {.cdecl,
|
||||
importc: "zip_delete".}
|
||||
proc zip_error_clear*(para1: Pzip) {.cdecl, importc: "zip_error_clear".}
|
||||
proc zip_error_get*(para1: Pzip, para2: ptr int32, para3: ptr int32) {.cdecl,
|
||||
importc: "zip_error_get".}
|
||||
proc zip_error_get_sys_type*(para1: int32): int32 {.cdecl,
|
||||
importc: "zip_error_get_sys_type".}
|
||||
proc zip_error_to_str*(para1: cstring, para2: int, para3: int32,
|
||||
para4: int32): int32 {.cdecl,
|
||||
importc: "zip_error_to_str".}
|
||||
proc zip_fclose*(para1: Pzip_file) {.cdecl,
|
||||
importc: "zip_fclose".}
|
||||
proc zip_file_error_clear*(para1: Pzip_file) {.cdecl,
|
||||
importc: "zip_file_error_clear".}
|
||||
proc zip_file_error_get*(para1: Pzip_file, para2: ptr int32, para3: ptr int32) {.
|
||||
cdecl, importc: "zip_file_error_get".}
|
||||
proc zip_file_strerror*(para1: Pzip_file): cstring {.cdecl,
|
||||
importc: "zip_file_strerror".}
|
||||
proc zip_fopen*(para1: Pzip, para2: cstring, para3: int32): Pzip_file {.cdecl,
|
||||
importc: "zip_fopen".}
|
||||
proc zip_fopen_index*(para1: Pzip, para2: int32, para3: int32): Pzip_file {.
|
||||
cdecl, importc: "zip_fopen_index".}
|
||||
proc zip_fread*(para1: Pzip_file, para2: pointer, para3: int): int {.
|
||||
cdecl, importc: "zip_fread".}
|
||||
proc zip_get_archive_comment*(para1: Pzip, para2: ptr int32, para3: int32): cstring {.
|
||||
cdecl, importc: "zip_get_archive_comment".}
|
||||
proc zip_get_archive_flag*(para1: Pzip, para2: int32, para3: int32): int32 {.
|
||||
cdecl, importc: "zip_get_archive_flag".}
|
||||
proc zip_get_file_comment*(para1: Pzip, para2: int32, para3: ptr int32,
|
||||
para4: int32): cstring {.cdecl,
|
||||
importc: "zip_get_file_comment".}
|
||||
proc zip_get_name*(para1: Pzip, para2: int32, para3: int32): cstring {.cdecl,
|
||||
importc: "zip_get_name".}
|
||||
proc zip_get_num_files*(para1: Pzip): int32 {.cdecl,
|
||||
importc: "zip_get_num_files".}
|
||||
proc zip_name_locate*(para1: Pzip, para2: cstring, para3: int32): int32 {.cdecl,
|
||||
importc: "zip_name_locate".}
|
||||
proc zip_open*(para1: cstring, para2: int32, para3: ptr int32): Pzip {.cdecl,
|
||||
importc: "zip_open".}
|
||||
proc zip_rename*(para1: Pzip, para2: int32, para3: cstring): int32 {.cdecl,
|
||||
importc: "zip_rename".}
|
||||
proc zip_replace*(para1: Pzip, para2: int32, para3: Pzip_source): int32 {.cdecl,
|
||||
importc: "zip_replace".}
|
||||
proc zip_set_archive_comment*(para1: Pzip, para2: cstring, para3: int32): int32 {.
|
||||
cdecl, importc: "zip_set_archive_comment".}
|
||||
proc zip_set_archive_flag*(para1: Pzip, para2: int32, para3: int32): int32 {.
|
||||
cdecl, importc: "zip_set_archive_flag".}
|
||||
proc zip_set_file_comment*(para1: Pzip, para2: int32, para3: cstring,
|
||||
para4: int32): int32 {.cdecl,
|
||||
importc: "zip_set_file_comment".}
|
||||
proc zip_source_buffer*(para1: Pzip, para2: pointer, para3: int, para4: int32): Pzip_source {.
|
||||
cdecl, importc: "zip_source_buffer".}
|
||||
proc zip_source_file*(para1: Pzip, para2: cstring, para3: int, para4: int): Pzip_source {.
|
||||
cdecl, importc: "zip_source_file".}
|
||||
proc zip_source_filep*(para1: Pzip, para2: TFile, para3: int, para4: int): Pzip_source {.
|
||||
cdecl, importc: "zip_source_filep".}
|
||||
proc zip_source_free*(para1: Pzip_source) {.cdecl,
|
||||
importc: "zip_source_free".}
|
||||
proc zip_source_function*(para1: Pzip, para2: Tzip_source_callback,
|
||||
para3: pointer): Pzip_source {.cdecl,
|
||||
importc: "zip_source_function".}
|
||||
proc zip_source_zip*(para1: Pzip, para2: Pzip, para3: int32, para4: int32,
|
||||
para5: int, para6: int): Pzip_source {.cdecl,
|
||||
importc: "zip_source_zip".}
|
||||
proc zip_stat*(para1: Pzip, para2: cstring, para3: int32, para4: Pzip_stat): int32 {.
|
||||
cdecl, importc: "zip_stat".}
|
||||
proc zip_stat_index*(para1: Pzip, para2: int32, para3: int32, para4: Pzip_stat): int32 {.
|
||||
cdecl, importc: "zip_stat_index".}
|
||||
proc zip_stat_init*(para1: Pzip_stat) {.cdecl, importc: "zip_stat_init".}
|
||||
proc zip_strerror*(para1: Pzip): cstring {.cdecl, importc: "zip_strerror".}
|
||||
proc zip_unchange*(para1: Pzip, para2: int32): int32 {.cdecl,
|
||||
importc: "zip_unchange".}
|
||||
proc zip_unchange_all*(para1: Pzip): int32 {.cdecl, importc: "zip_unchange_all".}
|
||||
proc zip_unchange_archive*(para1: Pzip): int32 {.cdecl,
|
||||
importc: "zip_unchange_archive".}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,181 +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"
|
||||
|
||||
type
|
||||
Uint* = int32
|
||||
Ulong* = int
|
||||
Ulongf* = int
|
||||
Pulongf* = ptr Ulongf
|
||||
z_off_t* = int32
|
||||
pbyte* = cstring
|
||||
pbytef* = cstring
|
||||
TAllocfunc* = proc (p: pointer, items: uInt, size: uInt): pointer{.cdecl.}
|
||||
TFreeFunc* = proc (p: pointer, address: pointer){.cdecl.}
|
||||
TInternalState*{.final, pure.} = object
|
||||
PInternalState* = ptr TInternalstate
|
||||
TZStream*{.final, pure.} = object
|
||||
next_in*: pbytef
|
||||
avail_in*: uInt
|
||||
total_in*: uLong
|
||||
next_out*: pbytef
|
||||
avail_out*: uInt
|
||||
total_out*: uLong
|
||||
msg*: pbytef
|
||||
state*: PInternalState
|
||||
zalloc*: TAllocFunc
|
||||
zfree*: TFreeFunc
|
||||
opaque*: pointer
|
||||
data_type*: int32
|
||||
adler*: uLong
|
||||
reserved*: uLong
|
||||
|
||||
TZStreamRec* = TZStream
|
||||
PZstream* = ptr TZStream
|
||||
gzFile* = pointer
|
||||
|
||||
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 TZStream, flush: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflate".}
|
||||
proc deflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateEnd".}
|
||||
proc inflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflate".}
|
||||
proc inflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateEnd".}
|
||||
proc deflateSetDictionary*(strm: var TZStream, dictionary: pbytef,
|
||||
dictLength: uInt): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateSetDictionary".}
|
||||
proc deflateCopy*(dest, source: var TZstream): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateCopy".}
|
||||
proc deflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateReset".}
|
||||
proc deflateParams*(strm: var TZStream, level: int32, strategy: int32): int32{.
|
||||
cdecl, dynlib: libz, importc: "deflateParams".}
|
||||
proc inflateSetDictionary*(strm: var TZStream, dictionary: pbytef,
|
||||
dictLength: uInt): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateSetDictionary".}
|
||||
proc inflateSync*(strm: var TZStream): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateSync".}
|
||||
proc inflateReset*(strm: var TZStream): 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 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: z_off_t, whence: int32): z_off_t{.cdecl,
|
||||
dynlib: libz, importc: "gzseek".}
|
||||
proc gzrewind*(thefile: gzFile): int32{.cdecl, dynlib: libz, importc: "gzrewind".}
|
||||
proc gztell*(thefile: gzFile): z_off_t{.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".}
|
||||
proc crc32*(crc: uLong, buf: pbytef, length: uInt): uLong{.cdecl, dynlib: libz,
|
||||
importc: "crc32".}
|
||||
proc deflateInitu*(strm: var TZStream, level: int32, version: cstring,
|
||||
stream_size: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "deflateInit_".}
|
||||
proc inflateInitu*(strm: var TZStream, version: cstring,
|
||||
stream_size: int32): int32 {.
|
||||
cdecl, dynlib: libz, importc: "inflateInit_".}
|
||||
proc deflateInit*(strm: var TZStream, level: int32): int32
|
||||
proc inflateInit*(strm: var TZStream): int32
|
||||
proc deflateInit2u*(strm: var TZStream, level: int32, `method`: int32,
|
||||
windowBits: int32, memLevel: int32, strategy: int32,
|
||||
version: cstring, stream_size: int32): int32 {.cdecl,
|
||||
dynlib: libz, importc: "deflateInit2_".}
|
||||
proc inflateInit2u*(strm: var TZStream, windowBits: int32, version: cstring,
|
||||
stream_size: int32): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateInit2_".}
|
||||
proc deflateInit2*(strm: var TZStream,
|
||||
level, `method`, windowBits, memLevel,
|
||||
strategy: int32): int32
|
||||
proc inflateInit2*(strm: var TZStream, windowBits: int32): int32
|
||||
proc zError*(err: int32): cstring{.cdecl, dynlib: libz, importc: "zError".}
|
||||
proc inflateSyncPoint*(z: PZstream): int32{.cdecl, dynlib: libz,
|
||||
importc: "inflateSyncPoint".}
|
||||
proc get_crc_table*(): pointer{.cdecl, dynlib: libz, importc: "get_crc_table".}
|
||||
|
||||
proc deflateInit(strm: var TZStream, level: int32): int32 =
|
||||
result = deflateInitu(strm, level, ZLIB_VERSION(), sizeof(TZStream))
|
||||
|
||||
proc inflateInit(strm: var TZStream): int32 =
|
||||
result = inflateInitu(strm, ZLIB_VERSION(), sizeof(TZStream))
|
||||
|
||||
proc deflateInit2(strm: var TZStream,
|
||||
level, `method`, windowBits, memLevel,
|
||||
strategy: int32): int32 =
|
||||
result = deflateInit2u(strm, level, `method`, windowBits, memLevel,
|
||||
strategy, ZLIB_VERSION(), sizeof(TZStream))
|
||||
|
||||
proc inflateInit2(strm: var TZStream, windowBits: int32): int32 =
|
||||
result = inflateInit2u(strm, windowBits, ZLIB_VERSION(), sizeof(TZStream))
|
||||
|
||||
proc zlibAllocMem*(AppData: Pointer, Items, Size: int): Pointer {.cdecl.} =
|
||||
result = Alloc(Items * Size)
|
||||
|
||||
proc zlibFreeMem*(AppData, `Block`: Pointer) {.cdecl.} =
|
||||
dealloc(`Block`)
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
#
|
||||
#
|
||||
# Nimrod'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
|
||||
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
|
||||
TZZipDir* {.final, pure.} = object
|
||||
TZZipFile* {.final, pure.} = object
|
||||
TZZipPluginIO* {.final, pure.} = object
|
||||
|
||||
TZZipDirent* {.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
|
||||
|
||||
TZZipStat* = TZZipDirent
|
||||
|
||||
proc zzip_strerror*(errcode: int32): cstring {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_strerror".}
|
||||
proc zzip_strerror_of*(dir: ptr TZZipDir): 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 TZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_error".}
|
||||
proc zzip_seterror*(dir: ptr TZZipDir, 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 TZZipFile): ptr TZZipDir {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dirhandle".}
|
||||
proc zzip_dirfd*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dirfd".}
|
||||
proc zzip_dir_real*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_real".}
|
||||
proc zzip_file_real*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_file_real".}
|
||||
proc zzip_realdir*(dir: ptr TZZipDir): pointer {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_realdir".}
|
||||
proc zzip_realfd*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_realfd".}
|
||||
|
||||
proc zzip_dir_alloc*(fileext: cstringArray): ptr TZZipDir {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_dir_alloc".}
|
||||
proc zzip_dir_free*(para1: ptr TZZipDir): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_free".}
|
||||
|
||||
proc zzip_dir_fdopen*(fd: int32, errcode_p: ptr TZZipError): ptr TZZipDir {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_dir_fdopen".}
|
||||
proc zzip_dir_open*(filename: cstring, errcode_p: ptr TZZipError): ptr TZZipDir {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_dir_open".}
|
||||
proc zzip_dir_close*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_close".}
|
||||
proc zzip_dir_read*(dir: ptr TZZipDir, dirent: ptr TZZipDirent): int32 {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_dir_read".}
|
||||
|
||||
proc zzip_opendir*(filename: cstring): ptr TZZipDir {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_opendir".}
|
||||
proc zzip_closedir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_closedir".}
|
||||
proc zzip_readdir*(dir: ptr TZZipDir): ptr TZZipDirent {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_readdir".}
|
||||
proc zzip_rewinddir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_rewinddir".}
|
||||
proc zzip_telldir*(dir: ptr TZZipDir): int {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_telldir".}
|
||||
proc zzip_seekdir*(dir: ptr TZZipDir, offset: int) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_seekdir".}
|
||||
|
||||
proc zzip_file_open*(dir: ptr TZZipDir, name: cstring, flags: int32): ptr TZZipFile {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_file_open".}
|
||||
proc zzip_file_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_file_close".}
|
||||
proc zzip_file_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_file_read".}
|
||||
proc zzip_open*(name: cstring, flags: int32): ptr TZZipFile {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_open".}
|
||||
proc zzip_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_close".}
|
||||
proc zzip_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_read".}
|
||||
|
||||
proc zzip_freopen*(name: cstring, mode: cstring, para3: ptr TZZipFile): ptr TZZipFile {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_freopen".}
|
||||
proc zzip_fopen*(name: cstring, mode: cstring): ptr TZZipFile {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_fopen".}
|
||||
proc zzip_fread*(p: pointer, size: int, nmemb: int,
|
||||
file: ptr TZZipFile): int {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_fread".}
|
||||
proc zzip_fclose*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_fclose".}
|
||||
|
||||
proc zzip_rewind*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_rewind".}
|
||||
proc zzip_seek*(fp: ptr TZZipFile, offset: int, whence: int32): int {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_seek".}
|
||||
proc zzip_tell*(fp: ptr TZZipFile): int {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_tell".}
|
||||
|
||||
proc zzip_dir_stat*(dir: ptr TZZipDir, name: cstring, zs: ptr TZZipStat,
|
||||
flags: int32): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_dir_stat".}
|
||||
proc zzip_file_stat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl,
|
||||
dynlib: dllname, importc: "zzip_file_stat".}
|
||||
proc zzip_fstat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, dynlib: dllname,
|
||||
importc: "zzip_fstat".}
|
||||
|
||||
proc zzip_open_shared_io*(stream: ptr TZZipFile, name: cstring,
|
||||
o_flags: int32, o_modes: int32, ext: cstringArray,
|
||||
io: ptr TZZipPluginIO): ptr TZZipFile {.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 TZZipPluginIO): ptr TZZipFile {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_open_ext_io".}
|
||||
proc zzip_opendir_ext_io*(name: cstring, o_modes: int32,
|
||||
ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_opendir_ext_io".}
|
||||
proc zzip_dir_open_ext_io*(filename: cstring, errcode_p: ptr TZZipError,
|
||||
ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {.
|
||||
cdecl, dynlib: dllname, importc: "zzip_dir_open_ext_io".}
|
||||
Loading…
Add table
Add a link
Reference in a new issue