]> gitweb.factorcode.org Git - factor.git/blob - basis/compression/zlib/ffi/ffi.factor
a2c4eb555e3c496bfa0574ab555654bcfb419146
[factor.git] / basis / compression / zlib / ffi / ffi.factor
1 ! Copyright (C) 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien alien.c-types alien.libraries alien.syntax
4 classes.struct combinators system ;
5 IN: compression.zlib.ffi
6
7 << "zlib" {
8     { [ os windows? ] [ "zlib1.dll" ] }
9     { [ os macosx? ] [ "libz.dylib" ] }
10     { [ os unix? ] [ "libz.so" ] }
11 } cond cdecl add-library >>
12
13 LIBRARY: zlib
14
15 TYPEDEF: void Bytef
16 TYPEDEF: ulong uLongf
17 TYPEDEF: ulong uLong
18 TYPEDEF: uint uInt
19
20 STRUCT: z_stream
21     { next_in uchar* }
22     { avail_in uint }
23     { total_in ulong }
24
25     { next_out uchar* }
26     { avail_out uint }
27     { total_out ulong }
28
29     { msg char* }
30     { state void* }
31
32     { zalloc void* }
33     { zfree void* }
34     { opaque void* }
35
36     { data_type int }
37     { adler ulong }
38     { reserved ulong } ;
39
40 TYPEDEF: z_stream* z_streamp
41
42 STRUCT: gz_header
43     { text int }
44     { time ulong }
45     { xflags int }
46     { os int }
47     { extra uchar* }
48     { extra_len uint }
49     { extra_max uint }
50     { name uchar* }
51     { name_max uint }
52     { comment uchar* }
53     { comm_max uint }
54     { hcrc int }
55     { done int } ;
56
57 TYPEDEF: gz_header* gz_headerp
58 CONSTANT: Z_NO_FLUSH      0
59 CONSTANT: Z_PARTIAL_FLUSH 1
60 CONSTANT: Z_SYNC_FLUSH    2
61 CONSTANT: Z_FULL_FLUSH    3
62 CONSTANT: Z_FINISH        4
63 CONSTANT: Z_BLOCK         5
64 CONSTANT: Z_TREES         6
65
66 CONSTANT: Z_OK             0
67 CONSTANT: Z_STREAM_END     1
68 CONSTANT: Z_NEED_DICT      2
69 CONSTANT: Z_ERRNO         -1
70 CONSTANT: Z_STREAM_ERROR  -2
71 CONSTANT: Z_DATA_ERROR    -3
72 CONSTANT: Z_MEM_ERROR     -4
73 CONSTANT: Z_BUF_ERROR     -5
74 CONSTANT: Z_VERSION_ERROR -6
75
76 CONSTANT: Z_NO_COMPRESSION       0
77 CONSTANT: Z_BEST_SPEED           1
78 CONSTANT: Z_BEST_COMPRESSION     9
79 CONSTANT: Z_DEFAULT_COMPRESSION -1
80
81 CONSTANT: Z_FILTERED         1
82 CONSTANT: Z_HUFFMAN_ONLY     2
83 CONSTANT: Z_RLE              3
84 CONSTANT: Z_FIXED            4
85 CONSTANT: Z_DEFAULT_STRATEGY 0
86
87 CONSTANT: Z_BINARY 0
88 CONSTANT: Z_TEXT 1
89 CONSTANT: Z_UNKNOWN 2
90
91 CONSTANT: Z_DEFLATED 8
92
93 CONSTANT: ZLIB_VERSION "1.2.5"
94
95 FUNCTION: c-string zlibVersion ( )
96
97 FUNCTION: int deflate ( z_streamp strm, int flush )
98 FUNCTION: int deflateEnd ( z_streamp strm )
99
100 FUNCTION: int inflate ( z_streamp strm, int flush )
101 FUNCTION: int inflateEnd ( z_streamp strm )
102
103 FUNCTION: int deflateSetDictionary ( z_streamp strm, Bytef* dictionary, uInt dictLength )
104 FUNCTION: int deflateCopy ( z_streamp dest, z_streamp source )
105 FUNCTION: int deflateReset ( z_streamp strm )
106 FUNCTION: int deflateParams ( z_streamp strm, int level, int strategy )
107 FUNCTION: int deflateTune ( z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain )
108 FUNCTION: uLong deflateBound ( z_streamp strm, uLong sourceLen )
109 FUNCTION: int deflatePrime ( z_streamp strm, int bits, int value )
110 FUNCTION: int deflateSetHeader ( z_streamp strm, gz_headerp head )
111
112 FUNCTION: int inflateSetDictionary ( z_streamp strm, Bytef* dictionary, uInt dictLength )
113 FUNCTION: int inflateSync ( z_streamp strm )
114 FUNCTION: int inflateCopy ( z_streamp dest, z_streamp source )
115 FUNCTION: int inflateReset ( z_streamp strm )
116 FUNCTION: int inflateReset2 ( z_streamp strm, int windowBits )
117 FUNCTION: int inflatePrime ( z_streamp strm, int bits, int value )
118 FUNCTION: long inflateMark ( z_streamp strm )
119 FUNCTION: int inflateGetHeader ( z_streamp strm, gz_headerp head )
120
121 FUNCTION: uLong zlibCompileFlags ( )
122
123 FUNCTION: int compress ( Bytef* dest, uLongf* destLen, Bytef* source, uLong sourceLen )
124 FUNCTION: int compress2 ( Bytef* dest, uLongf* destLen, Bytef* source, uLong sourceLen, int level )
125 FUNCTION: uLong compressBound ( uLong sourceLen )
126
127 FUNCTION: int uncompress ( Bytef* dest, uLongf* destLen, Bytef* source, uLong sourceLen )
128
129 TYPEDEF: void* gzFile
130
131 FUNCTION: gzFile gzdopen ( int fd, c-string mode )
132 FUNCTION: int gzbuffer ( gzFile file, uint size )
133 FUNCTION: int gzsetparams ( gzFile file, int level, int strategy )
134 FUNCTION: int gzread ( gzFile file, void* buf, uint len )
135 FUNCTION: int gzwrite ( gzFile file, void* buf, uint len )
136 FUNCTION: int gzputs ( gzFile file, char* s )
137 FUNCTION: c-string gzgets ( gzFile file, char* buf, int len )
138 FUNCTION: int gzputc ( gzFile file, int c )
139 FUNCTION: int gzgetc ( gzFile file )
140 FUNCTION: int gzungetc ( int c, gzFile file )
141 FUNCTION: int gzflush ( gzFile file, int flush )
142 FUNCTION: int gzrewind ( gzFile file )
143 FUNCTION: int gzeof ( gzFile file )
144 FUNCTION: int gzdirect ( gzFile file )
145 FUNCTION: int gzclose ( gzFile file )
146 FUNCTION: int gzclose_r ( gzFile file )
147 FUNCTION: int gzclose_w ( gzFile file )
148 FUNCTION: c-string gzerror ( gzFile file, int* errnum )
149 FUNCTION: void gzclearerr ( gzFile file )
150
151 FUNCTION: uLong adler32 ( uLong adler, Bytef* buf, uInt len )
152 FUNCTION: uLong crc32 ( uLong crc Bytef* buf, uInt len )
153
154 FUNCTION: int deflateInit_ ( z_streamp strm, int level, c-string version, int stream_size )
155 FUNCTION: int inflateInit_ ( z_streamp strm, c-string version, int stream_size )
156
157 FUNCTION: int deflateInit2_ ( z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, c-string version, int stream_size )
158 FUNCTION: int inflateInit2_ ( z_streamp strm, int windowBits, c-string version, int stream_size )