@@ -10,32 +10,32 @@ when ODIN_OS == .Windows {
1010 foreign import zlib " system:z"
1111}
1212
13- VERSION :: " 1.3.1"
14- VERNUM :: 0x1310
15- VER_MAJOR :: 1
16- VER_MINOR :: 3
17- VER_REVISION :: 1
13+ VERSION :: " 1.3.1"
14+ VERNUM :: 0x1310
15+ VER_MAJOR :: 1
16+ VER_MINOR :: 3
17+ VER_REVISION :: 1
1818VER_SUBREVISION :: 0
1919
20- voidp :: rawptr
21- voidpf :: rawptr
22- voidpc :: rawptr
23- Byte :: c.uchar
24- Bytef :: c.uchar
25- uInt :: c.uint
26- uIntf :: c.uint
27- uLong :: c.ulong
28- uLongf :: c.ulong
29- size_t :: c.size_t
30- off_t :: c.long
31- off64_t :: i64
32- crc_t :: u32
20+ voidp :: rawptr
21+ voidpf :: rawptr
22+ voidpc :: rawptr
23+ Byte :: c.uchar
24+ Bytef :: c.uchar
25+ uInt :: c.uint
26+ uIntf :: c.uint
27+ uLong :: c.ulong
28+ uLongf :: c.ulong
29+ size_t :: c.size_t
30+ off_t :: c.long
31+ off64_t :: i64
32+ crc_t :: u32
3333
34- alloc_func :: proc " c" (opaque: voidp, items: uInt, size: uInt) -> voidpf
35- free_func :: proc " c" (opaque: voidp, address: voidpf)
34+ alloc_func :: proc " c" (opaque: voidp, items: uInt, size: uInt) -> voidpf
35+ free_func :: proc " c" (opaque: voidp, address: voidpf)
3636
37- in_func :: proc " c" (_: rawptr , _: [^][^]c.uchar) -> c.uint
38- out_func :: proc " c" (_: rawptr , _: [^]c.uchar, _: c.uint ) -> c.int
37+ in_func :: proc " c" (rawptr , [^][^]c.uchar) -> c.uint
38+ out_func :: proc " c" (rawptr , [^]c.uchar, c.uint ) -> c.int
3939
4040gzFile_s :: struct {
4141 have: c.uint ,
@@ -52,7 +52,7 @@ z_stream_s :: struct {
5252 next_out: ^Bytef,
5353 avail_out: uInt,
5454 total_out: uLong,
55- msg: [^]c.char, // TODO: check if cstring might work
55+ msg: [^]c.char,
5656 state: rawptr ,
5757 zalloc: alloc_func,
5858 zfree: free_func,
@@ -62,7 +62,7 @@ z_stream_s :: struct {
6262 reserved: uLong,
6363}
6464
65- z_stream :: z_stream_s
65+ z_stream :: z_stream_s
6666z_streamp :: ^z_stream
6767
6868gz_header_s :: struct {
@@ -81,190 +81,173 @@ gz_header_s :: struct {
8181 done: c.int ,
8282}
8383
84- gz_header :: gz_header_s
84+ gz_header :: gz_header_s
8585gz_headerp :: ^gz_header
8686
8787// Allowed flush values; see deflate() and inflate() below for details
88- NO_FLUSH :: 0
89- PARTIAL_FLUSH :: 1
90- SYNC_FLUSH :: 2
91- FULL_FLUSH :: 3
92- FINISH :: 4
93- BLOCK :: 5
94- TREES :: 6
88+ NO_FLUSH :: 0
89+ PARTIAL_FLUSH :: 1
90+ SYNC_FLUSH :: 2
91+ FULL_FLUSH :: 3
92+ FINISH :: 4
93+ BLOCK :: 5
94+ TREES :: 6
9595
9696// Return codes for the compression/decompression functions. Negative values are
9797// errors, positive values are used for special but normal events.
98- OK :: 0
99- STREAM_END :: 1
100- NEED_DICT :: 2
101- ERRNO :: -1
102- STREAM_ERROR :: -2
103- DATA_ERROR :: -3
104- MEM_ERROR :: -4
105- BUF_ERROR :: -5
106- VERSION_ERROR :: -6
98+ OK :: 0
99+ STREAM_END :: 1
100+ NEED_DICT :: 2
101+ ERRNO :: -1
102+ STREAM_ERROR :: -2
103+ DATA_ERROR :: -3
104+ MEM_ERROR :: -4
105+ BUF_ERROR :: -5
106+ VERSION_ERROR :: -6
107107
108108// compression levels
109- NO_COMPRESSION :: 0
110- BEST_SPEED :: 1
111- BEST_COMPRESSION :: 9
112- DEFAULT_COMPRESSION :: -1
109+ NO_COMPRESSION :: 0
110+ BEST_SPEED :: 1
111+ BEST_COMPRESSION :: 9
112+ DEFAULT_COMPRESSION :: -1
113113
114114// compression strategy; see deflateInit2() below for details
115- FILTERED :: 1
116- HUFFMAN_ONLY :: 2
117- RLE :: 3
118- FIXED :: 4
119- DEFAULT_STRATEGY :: 0
115+ FILTERED :: 1
116+ HUFFMAN_ONLY :: 2
117+ RLE :: 3
118+ FIXED :: 4
119+ DEFAULT_STRATEGY :: 0
120120
121121// Possible values of the data_type field for deflate()
122- BINARY :: 0
123- TEXT :: 1
124- ASCII :: TEXT // for compatibility with 1.2.2 and earlier
125- UNKNOWN :: 2
122+ BINARY :: 0
123+ TEXT :: 1
124+ ASCII :: TEXT // for compatibility with 1.2.2 and earlier
125+ UNKNOWN :: 2
126126
127127// The deflate compression method (the only one supported in this version)
128- DEFLATED :: 8
128+ DEFLATED :: 8
129129
130+ NULL :: 0 // for initializing zalloc, zfree, opaque
130131
131- NULL :: 0 // Don't use this for initializing the zalloc, zfree, opaque function pointers! Use nil instead.
132+ version :: Version // for compatibility with versions < 1.0.2
132133
133- version :: Version // for compatibility with versions < 1.0.2
134-
135- @ (default_calling_convention = " c" )
134+ @ (default_calling_convention=" c" )
136135foreign zlib {
137136 // becase zlib.zlibVersion would be silly to write
138- @ (link_prefix = " zlib" )
139- Version :: proc () -> cstring ---
137+ @ (link_prefix= " zlib" )
138+ Version :: proc () -> cstring ---
140139
141- deflate :: proc (strm: z_streamp, flush: c.int ) -> c.int ---
142- deflateEnd :: proc (strm: z_streamp) -> c.int ---
143- inflate :: proc (strm: z_streamp, flush: c.int ) -> c.int ---
144- inflateEnd :: proc (strm: z_streamp) -> c.int ---
140+ deflate :: proc (strm: z_streamp, flush: c.int ) -> c.int ---
141+ deflateEnd :: proc (strm: z_streamp) -> c.int ---
142+ inflate :: proc (strm: z_streamp, flush: c.int ) -> c.int ---
143+ inflateEnd :: proc (strm: z_streamp) -> c.int ---
145144 deflateSetDictionary :: proc (strm: z_streamp, dictionary: [^]Bytef, dictLength: uInt) -> c.int ---
146145 deflateGetDictionary :: proc (strm: z_streamp, dictionary: [^]Bytef, dictLength: ^uInt) -> c.int ---
147- deflateCopy :: proc (dest, source: z_streamp) -> c.int ---
148- deflateReset :: proc (strm: z_streamp) -> c.int ---
149- deflateParams :: proc (strm: z_streamp, level, strategy: c.int ) -> c.int ---
150- deflateTune :: proc (strm: z_streamp, good_length, max_lazy, nice_length, max_chain: c.int ) -> c.int ---
151- deflateBound :: proc (strm: z_streamp, sourceLen: uLong) -> uLong ---
152- deflatePending :: proc (strm: z_streamp, pending: [^]c.uint , bits: [^]c.int ) -> c.int ---
153- deflatePrime :: proc (strm: z_streamp, bits, value: c.int ) -> c.int ---
154- deflateSetHeader :: proc (strm: z_streamp, head: gz_headerp) -> c.int ---
146+ deflateCopy :: proc (dest, source: z_streamp) -> c.int ---
147+ deflateReset :: proc (strm: z_streamp) -> c.int ---
148+ deflateParams :: proc (strm: z_streamp, level, strategy: c.int ) -> c.int ---
149+ deflateTune :: proc (strm: z_streamp, good_length, max_lazy, nice_length, max_chain: c.int ) -> c.int ---
150+ deflateBound :: proc (strm: z_streamp, sourceLen: uLong) -> uLong ---
151+ deflatePending :: proc (strm: z_streamp, pending: [^]c.uint , bits: [^]c.int ) -> c.int ---
152+ deflatePrime :: proc (strm: z_streamp, bits, value: c.int ) -> c.int ---
153+ deflateSetHeader :: proc (strm: z_streamp, head: gz_headerp) -> c.int ---
155154 inflateSetDictionary :: proc (strm: z_streamp, dictionary: [^]Bytef, dictLength: uInt) -> c.int ---
156155 inflateGetDictionary :: proc (strm: z_streamp, dictionary: [^]Bytef, dictLength: ^uInt) -> c.int ---
157- inflateSync :: proc (strm: z_streamp) -> c.int ---
158- inflateCopy :: proc (dest, source: z_streamp) -> c.int ---
159- inflateReset :: proc (strm: z_streamp) -> c.int ---
160- inflateReset2 :: proc (strm: z_streamp, windowBits: c.int ) -> c.int ---
161- inflatePrime :: proc (strm: z_streamp, bits, value: c.int ) -> c.int ---
162- inflateMark :: proc (strm: z_streamp) -> c.long ---
163- inflateGetHeader :: proc (strm: z_streamp, head: gz_headerp) -> c.int ---
164- inflateBack :: proc (strm: z_streamp, _in: in_func, in_desc: rawptr , out: out_func, out_desc: rawptr ) -> c.int ---
165- inflateBackEnd :: proc (strm: z_streamp) -> c.int ---
166- zlibCompileFlags :: proc () -> uLong ---
167- compress :: proc (dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong) -> c.int ---
168- compress2 :: proc (dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong, level: c.int ) -> c.int ---
169- compressBound :: proc (sourceLen: uLong) -> uLong ---
170- uncompress :: proc (dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong) -> c.int ---
171- uncompress2 :: proc (dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: ^uLong) -> c.int ---
172- gzdopen :: proc (fd: c.int , mode: cstring ) -> gzFile ---
173- gzbuffer :: proc (file: gzFile, size: c.uint ) -> c.int ---
174- gzsetparams :: proc (file: gzFile, level, strategy: c.int ) -> c.int ---
175- gzread :: proc (file: gzFile, buf: voidp, len: c.uint ) -> c.int ---
176- gzfread :: proc (buf: voidp, size, nitems: size_t, file: gzFile) -> size_t ---
177- gzwrite :: proc (file: gzFile, buf: voidpc, len: c.uint ) -> c.int ---
178- gzfwrite :: proc (buf: voidpc, size, nitems: size_t, file: gzFile) -> size_t ---
179- gzprintf :: proc (file: gzFile, format: cstring , #c_vararg args: ..any ) -> c.int ---
180- gzputs :: proc (file: gzFile, s: cstring ) -> c.int ---
181- gzgets :: proc (file: gzFile, buf: [^]c.char, len: c.int ) -> [^]c.char ---
182- gzputc :: proc (file: gzFile, ch: c.int ) -> c.int ---
183- gzgetc_ :: proc (file: gzFile) -> c.int --- // backwards compat, not the same as gzget
184- gzungetc :: proc (ch: c.int , file: gzFile) -> c.int ---
185- gzflush :: proc (file: gzFile, flush: c.int ) -> c.int ---
186- gzrewind :: proc (file: gzFile) -> c.int ---
187- gzeof :: proc (file: gzFile) -> c.int ---
188- gzdirect :: proc (file: gzFile) -> c.int ---
189- gzclose :: proc (file: gzFile) -> c.int ---
190- gzclose_r :: proc (file: gzFile) -> c.int ---
191- gzclose_w :: proc (file: gzFile) -> c.int ---
192- gzerror :: proc (file: gzFile, errnum: ^c.int ) -> cstring ---
193- gzclearerr :: proc (file: gzFile) ---
194- adler32 :: proc (adler: uLong, buf: [^]Bytef, len: uInt) -> uLong ---
195- adler32_z :: proc (adler: uLong, buf: [^]Bytef, len: size_t) -> uLong ---
196- crc32 :: proc (crc: uLong, buf: [^]Bytef, len: uInt) -> uLong ---
197- crc32_z :: proc (crc: uLong, buf: [^]Bytef, len: size_t) -> uLong ---
198- crc32_combine_op :: proc (crc1, crc2, op: uLong) -> uLong ---
199- gzopen64 :: proc (_: cstring , _: cstring ) -> gzFile ---
200- gzseek64 :: proc (_: gzFile, _: off64_t, _: c.int ) -> off64_t ---
201- gztell64 :: proc (_: gzFile) -> off64_t ---
202- gzoffset64 :: proc (_: gzFile) -> off64_t ---
203- adler32_combine64 :: proc (_: uLong, _: uLong, _: off64_t) -> uLong ---
204- crc32_combine64 :: proc (_: uLong, _: uLong, _: off64_t) -> uLong ---
205- crc32_combine_gen64 :: proc (_: off64_t) -> uLong ---
206- adler32_combine :: proc (_: uLong, _: uLong, _: off_t) -> uLong ---
207- crc32_combine :: proc (_: uLong, _: uLong, _: off_t) -> uLong ---
208- crc32_combine_gen :: proc (_: off_t) -> uLong ---
209- zError :: proc (_: c.int ) -> cstring ---
210- inflateSyncPoint :: proc (_: z_streamp) -> c.int ---
211- get_crc_table :: proc () -> [^]crc_t ---
212- inflateUndermine :: proc (_: z_streamp, _: c.int ) -> c.int ---
213- inflateValidate :: proc (_: z_streamp, _: c.int ) -> c.int ---
214- inflateCodesUsed :: proc (_: z_streamp) -> c.ulong ---
215- inflateResetKeep :: proc (_: z_streamp) -> c.int ---
216- deflateResetKeep :: proc (_: z_streamp) -> c.int ---
156+ inflateSync :: proc (strm: z_streamp) -> c.int ---
157+ inflateCopy :: proc (dest, source: z_streamp) -> c.int ---
158+ inflateReset :: proc (strm: z_streamp) -> c.int ---
159+ inflateReset2 :: proc (strm: z_streamp, windowBits: c.int ) -> c.int ---
160+ inflatePrime :: proc (strm: z_streamp, bits, value: c.int ) -> c.int ---
161+ inflateMark :: proc (strm: z_streamp) -> c.long ---
162+ inflateGetHeader :: proc (strm: z_streamp, head: gz_headerp) -> c.int ---
163+ inflateBack :: proc (strm: z_streamp, _in: in_func, in_desc: rawptr , out: out_func, out_desc: rawptr ) -> c.int ---
164+ inflateBackEnd :: proc (strm: z_streamp) -> c.int ---
165+ zlibCompileFlags :: proc () -> uLong ---
166+ compress :: proc (dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong) -> c.int ---
167+ compress2 :: proc (dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong, level: c.int ) -> c.int ---
168+ compressBound :: proc (sourceLen: uLong) -> uLong ---
169+ uncompress :: proc (dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: uLong) -> c.int ---
170+ uncompress2 :: proc (dest: [^]Bytef, destLen: ^uLongf, source: [^]Bytef, sourceLen: ^uLong) -> c.int ---
171+ gzdopen :: proc (fd: c.int , mode: cstring ) -> gzFile ---
172+ gzbuffer :: proc (file: gzFile, size: c.uint ) -> c.int ---
173+ gzsetparams :: proc (file: gzFile, level, strategy: c.int ) -> c.int ---
174+ gzread :: proc (file: gzFile, buf: voidp, len: c.uint ) -> c.int ---
175+ gzfread :: proc (buf: voidp, size, nitems: size_t, file: gzFile) -> size_t ---
176+ gzwrite :: proc (file: gzFile, buf: voidpc, len: c.uint ) -> c.int ---
177+ gzfwrite :: proc (buf: voidpc, size, nitems: size_t, file: gzFile) -> size_t ---
178+ gzprintf :: proc (file: gzFile, format: cstring , #c_vararg args: ..any ) -> c.int ---
179+ gzputs :: proc (file: gzFile, s: cstring ) -> c.int ---
180+ gzgets :: proc (file: gzFile, buf: [^]c.char, len: c.int ) -> [^]c.char ---
181+ gzputc :: proc (file: gzFile, ch: c.int ) -> c.int ---
182+ gzgetc_ :: proc (file: gzFile) -> c.int --- // backwards compat, not the same as gzget
183+ gzungetc :: proc (ch: c.int , file: gzFile) -> c.int ---
184+ gzflush :: proc (file: gzFile, flush: c.int ) -> c.int ---
185+ gzrewind :: proc (file: gzFile) -> c.int ---
186+ gzeof :: proc (file: gzFile) -> c.int ---
187+ gzdirect :: proc (file: gzFile) -> c.int ---
188+ gzclose :: proc (file: gzFile) -> c.int ---
189+ gzclose_r :: proc (file: gzFile) -> c.int ---
190+ gzclose_w :: proc (file: gzFile) -> c.int ---
191+ gzerror :: proc (file: gzFile, errnum: ^c.int ) -> cstring ---
192+ gzclearerr :: proc (file: gzFile) ---
193+ adler32 :: proc (adler: uLong, buf: [^]Bytef, len: uInt) -> uLong ---
194+ adler32_z :: proc (adler: uLong, buf: [^]Bytef, len: size_t) -> uLong ---
195+ crc32 :: proc (crc: uLong, buf: [^]Bytef, len: uInt) -> uLong ---
196+ crc32_z :: proc (crc: uLong, buf: [^]Bytef, len: size_t) -> uLong ---
197+ crc32_combine_op :: proc (crc1, crc2, op: uLong) -> uLong ---
198+ gzopen64 :: proc (cstring , cstring ) -> gzFile ---
199+ gzseek64 :: proc (gzFile, off64_t, c.int ) -> off64_t ---
200+ gztell64 :: proc (gzFile) -> off64_t ---
201+ gzoffset64 :: proc (gzFile) -> off64_t ---
202+ adler32_combine64 :: proc (uLong, uLong, off64_t) -> uLong ---
203+ crc32_combine64 :: proc (uLong, uLong, off64_t) -> uLong ---
204+ crc32_combine_gen64 :: proc (off64_t) -> uLong ---
205+ adler32_combine :: proc (uLong, uLong, off_t) -> uLong ---
206+ crc32_combine :: proc (uLong, uLong, off_t) -> uLong ---
207+ crc32_combine_gen :: proc (off_t) -> uLong ---
208+ zError :: proc (c.int ) -> cstring ---
209+ inflateSyncPoint :: proc (z_streamp) -> c.int ---
210+ get_crc_table :: proc () -> [^]crc_t ---
211+ inflateUndermine :: proc (z_streamp, c.int ) -> c.int ---
212+ inflateValidate :: proc (z_streamp, c.int ) -> c.int ---
213+ inflateCodesUsed :: proc (z_streamp) -> c.ulong ---
214+ inflateResetKeep :: proc (z_streamp) -> c.int ---
215+ deflateResetKeep :: proc (z_streamp) -> c.int ---
217216}
218217
219218// Make these private since we create wrappers below passing in version and size
220219// of the stream structure like zlib.h does
221220@(private)
222- @ (default_calling_convention = " c" )
221+ @ (default_calling_convention= " c" )
223222foreign zlib {
224- deflateInit_ :: proc (strm: z_streamp, level: c.int , version: cstring , stream_size: c.int ) -> c.int ---
225- inflateInit_ :: proc (strm: z_streamp, version: cstring , stream_size: c.int ) -> c.int ---
226- deflateInit2_ :: proc (strm: z_streamp, level, method, windowBits, memLevel, strategy: c.int , version: cstring , stream_size: c.int ) -> c.int ---
227- inflateInit2_ :: proc (strm: z_streamp, windowBits: c.int , version: cstring , stream_size: c.int ) -> c.int ---
228- inflateBackInit_ :: proc (strm: z_streamp, windowBits: c.int , window: [^]c.uchar, version: cstring , stream_size: c.int ) -> c.int ---
223+ deflateInit_ :: proc (strm: z_streamp, level: c.int , version: cstring , stream_size: c.int ) -> c.int ---
224+ inflateInit_ :: proc (strm: z_streamp, version: cstring , stream_size: c.int ) -> c.int ---
225+ deflateInit2_ :: proc (strm: z_streamp, level, method, windowBits, memLevel, strategy: c.int , version: cstring , stream_size: c.int ) -> c.int ---
226+ inflateInit2_ :: proc (strm: z_streamp, windowBits: c.int , version: cstring , stream_size: c.int ) -> c.int ---
227+ inflateBackInit_ :: proc (strm: z_streamp, windowBits: c.int , window: [^]c.uchar, version: cstring , stream_size: c.int ) -> c.int ---
229228
230229 // see below for explanation
231- @ (link_name = " gzgetc" )
232- gzgetc_unique :: proc (file: gzFile) -> c.int ---
230+ @ (link_name= " gzgetc" )
231+ gzgetc_unique :: proc (file: gzFile) -> c.int ---
233232}
234233
235234deflateInit :: #force_inline proc " c" (strm: z_streamp, level: c.int ) -> c.int {
236235 return deflateInit_ (strm, level, VERSION, c.int (size_of (z_stream)))
237236}
238237
239238inflateInit :: #force_inline proc " c" (strm: z_streamp) -> c.int {
240- return inflateInit_ (strm, VERSION, c.int (size_of (z_stream)))
239+ return inflateInit_ (strm, VERSION, c.int (size_of (z_stream)))
241240}
242241
243- deflateInit2 :: #force_inline proc " c" (
244- strm: z_streamp,
245- level, method, windowBits, memLevel, strategy: c.int ,
246- ) -> c.int {
247- return deflateInit2_ (
248- strm,
249- level,
250- method,
251- windowBits,
252- memLevel,
253- strategy,
254- VERSION,
255- c.int (size_of (z_stream)),
256- )
242+ deflateInit2 :: #force_inline proc " c" (strm: z_streamp, level, method, windowBits, memLevel, strategy: c.int ) -> c.int {
243+ return deflateInit2_ (strm, level, method, windowBits, memLevel, strategy, VERSION, c.int (size_of (z_stream)))
257244}
258245
259246inflateInit2 :: #force_inline proc " c" (strm: z_streamp, windowBits: c.int ) -> c.int {
260247 return inflateInit2_ (strm, windowBits, VERSION, c.int (size_of (z_stream)))
261248}
262249
263- inflateBackInit :: #force_inline proc " c" (
264- strm: z_streamp,
265- windowBits: c.int ,
266- window: [^]c.uchar,
267- ) -> c.int {
250+ inflateBackInit :: #force_inline proc " c" (strm: z_streamp, windowBits: c.int , window: [^]c.uchar) -> c.int {
268251 return inflateBackInit_ (strm, windowBits, window, VERSION, c.int (size_of (z_stream)))
269252}
270253
0 commit comments