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