Rev 6673 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6617 | IgorA | 1 | ; zlib.inc -- interface of the 'zlib' general purpose compression library |
2 | ; version 1.2.8, April 28th, 2013 |
||
3 | |||
4 | ; Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler |
||
5 | |||
6 | ; This software is provided 'as-is', without any express or implied |
||
7 | ; warranty. In no event will the authors be held liable for any damages |
||
8 | ; arising from the use of this software. |
||
9 | |||
10 | ; Permission is granted to anyone to use this software for any purpose, |
||
11 | ; including commercial applications, and to alter it and redistribute it |
||
12 | ; freely, subject to the following restrictions: |
||
13 | |||
14 | ; 1. The origin of this software must not be misrepresented; you must not |
||
15 | ; claim that you wrote the original software. If you use this software |
||
16 | ; in a product, an acknowledgment in the product documentation would be |
||
17 | ; appreciated but is not required. |
||
18 | ; 2. Altered source versions must be plainly marked as such, and must not be |
||
19 | ; misrepresented as being the original software. |
||
20 | ; 3. This notice may not be removed or altered from any source distribution. |
||
21 | |||
22 | ; Jean-loup Gailly Mark Adler |
||
23 | ; jloup@gzip.org madler@alumni.caltech.edu |
||
24 | |||
25 | |||
26 | ; The data format used by the zlib library is described by RFCs (Request for |
||
27 | ; Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 |
||
28 | ; (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). |
||
29 | |||
30 | |||
31 | include 'zconf.inc' |
||
32 | |||
33 | align 4 |
||
34 | ZLIB_VERSION db '1.2.8',0 |
||
35 | ZLIB_VERNUM equ 0x1280 |
||
36 | ZLIB_VER_MAJOR equ 1 |
||
37 | ZLIB_VER_MINOR equ 2 |
||
38 | ZLIB_VER_REVISION equ 8 |
||
39 | ZLIB_VER_SUBREVISION equ 0 |
||
40 | |||
41 | |||
42 | ; The 'zlib' compression library provides in-memory compression and |
||
43 | ; decompression functions, including integrity checks of the uncompressed data. |
||
44 | ; This version of the library supports only one compression method (deflation) |
||
45 | ; but other algorithms will be added later and will have the same stream |
||
46 | ; interface. |
||
47 | |||
48 | ; Compression can be done in a single step if the buffers are large enough, |
||
49 | ; or can be done by repeated calls of the compression function. In the latter |
||
50 | ; case, the application must provide more input and/or consume the output |
||
51 | ; (providing more output space) before each call. |
||
52 | |||
53 | ; The compressed data format used by default by the in-memory functions is |
||
54 | ; the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped |
||
55 | ; around a deflate stream, which is itself documented in RFC 1951. |
||
56 | |||
57 | ; The library also supports reading and writing files in gzip (.gz) format |
||
58 | ; with an interface similar to that of stdio using the functions that start |
||
59 | ; with "gz". The gzip format is different from the zlib format. gzip is a |
||
60 | ; gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. |
||
61 | |||
62 | ; This library can optionally read and write gzip streams in memory as well. |
||
63 | |||
64 | ; The zlib format was designed to be compact and fast for use in memory |
||
65 | ; and on communications channels. The gzip format was designed for single- |
||
66 | ; file compression on file systems, has a larger header than zlib to maintain |
||
67 | ; directory information, and uses a different, slower check method than zlib. |
||
68 | |||
69 | ; The library does not install any signal handler. The decoder checks |
||
70 | ; the consistency of the compressed data, so the library should never crash |
||
71 | ; even in case of corrupted input. |
||
72 | |||
73 | struct z_stream ;z_stream_s |
||
74 | next_in dd ? ;z_const Bytef * ;next input byte |
||
6704 | IgorA | 75 | avail_in dd ? ;uInt ;number of bytes available at next_in |
6617 | IgorA | 76 | total_in dd ? ;uLong ;total number of input bytes read so far |
77 | |||
78 | next_out dd ? ;Bytef * ;next output byte should be put there |
||
79 | avail_out dw ? ;uInt ;remaining free space at next_out |
||
80 | total_out dd ? ;uLong ;total number of bytes output so far |
||
81 | |||
82 | msg dd ? ;z_const char * ;last error message, NULL if no error |
||
83 | state dd ? ;deflate_state* ;not visible by applications |
||
84 | |||
85 | zalloc dd ? ;alloc_func ;used to allocate the internal state |
||
86 | zfree dd ? ;free_func ;used to free the internal state |
||
87 | opaque dd ? ;voidpf ;private data object passed to zalloc and zfree |
||
88 | |||
89 | data_type dw ? ;int ;best guess about the data type: binary or text |
||
90 | adler dd ? ;uLong ;adler32 value of the uncompressed data |
||
91 | reserved dd ? ;uLong ;reserved for future use |
||
92 | ends |
||
93 | |||
94 | ; gzip header information passed to and from zlib routines. See RFC 1952 |
||
95 | ; for more details on the meanings of these fields. |
||
96 | |||
97 | struct gz_header ;_s |
||
98 | text dd ? ;int ;true if compressed data believed to be text |
||
99 | time dd ? ;uLong ;modification time |
||
100 | xflags dd ? ;int ;extra flags (not used when writing a gzip file) |
||
101 | os dd ? ;int ;operating system |
||
102 | extra dd ? ;Bytef* ;pointer to extra field or Z_NULL if none |
||
103 | extra_len dd ? ;uInt ;extra field length (valid if extra != Z_NULL) |
||
104 | extra_max dd ? ;uInt ;space at extra (only when reading header) |
||
105 | name dd ? ;Bytef* ;pointer to zero-terminated file name or Z_NULL |
||
106 | name_max dd ? ;uInt ;space at name (only when reading header) |
||
107 | comment dd ? ;Bytef* ;pointer to zero-terminated comment or Z_NULL |
||
108 | comm_max dd ? ;uInt ;space at comment (only when reading header) |
||
109 | hcrc dd ? ;int ;true if there was or will be a header crc |
||
110 | done dd ? ;int ;true when done reading gzip header (not used |
||
111 | ;when writing a gzip file) |
||
112 | ends |
||
113 | |||
114 | |||
115 | ; The application must update next_in and avail_in when avail_in has dropped |
||
116 | ; to zero. It must update next_out and avail_out when avail_out has dropped |
||
117 | ; to zero. The application must initialize zalloc, zfree and opaque before |
||
118 | ; calling the init function. All other fields are set by the compression |
||
119 | ; library and must not be updated by the application. |
||
120 | |||
121 | ; The opaque value provided by the application will be passed as the first |
||
122 | ; parameter for calls of zalloc and zfree. This can be useful for custom |
||
123 | ; memory management. The compression library attaches no meaning to the |
||
124 | ; opaque value. |
||
125 | |||
126 | ; zalloc must return Z_NULL if there is not enough memory for the object. |
||
127 | ; If zlib is used in a multi-threaded application, zalloc and zfree must be |
||
128 | ; thread safe. |
||
129 | |||
130 | ; On 16-bit systems, the functions zalloc and zfree must be able to allocate |
||
131 | ; exactly 65536 bytes, but will not be required to allocate more than this if |
||
132 | ; the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers |
||
133 | ; returned by zalloc for objects of exactly 65536 bytes *must* have their |
||
134 | ; offset normalized to zero. The default allocation function provided by this |
||
135 | ; library ensures this (see zutil.c). To reduce memory requirements and avoid |
||
136 | ; any allocation of 64K objects, at the expense of compression ratio, compile |
||
137 | ; the library with -DMAX_WBITS=14 (see zconf.h). |
||
138 | |||
139 | ; The fields total_in and total_out can be used for statistics or progress |
||
140 | ; reports. After compression, total_in holds the total size of the |
||
141 | ; uncompressed data and may be saved for use in the decompressor (particularly |
||
142 | ; if the decompressor wants to decompress everything in a single step). |
||
143 | |||
144 | |||
145 | ; constants |
||
146 | |||
147 | Z_NO_FLUSH equ 0 |
||
148 | Z_PARTIAL_FLUSH equ 1 |
||
149 | Z_SYNC_FLUSH equ 2 |
||
150 | Z_FULL_FLUSH equ 3 |
||
151 | Z_FINISH equ 4 |
||
152 | Z_BLOCK equ 5 |
||
153 | Z_TREES equ 6 |
||
154 | ; Allowed flush values; see deflate() and inflate() below for details |
||
155 | |||
156 | Z_OK equ 0 |
||
157 | Z_STREAM_END equ 1 |
||
158 | Z_NEED_DICT equ 2 |
||
159 | Z_ERRNO equ (-1) |
||
160 | Z_STREAM_ERROR equ (-2) |
||
161 | Z_DATA_ERROR equ (-3) |
||
162 | Z_MEM_ERROR equ (-4) |
||
163 | Z_BUF_ERROR equ (-5) |
||
164 | Z_VERSION_ERROR equ (-6) |
||
165 | ; Return codes for the compression/decompression functions. Negative values |
||
166 | ; are errors, positive values are used for special but normal events. |
||
167 | |||
168 | |||
169 | Z_NO_COMPRESSION equ 0 |
||
170 | Z_BEST_SPEED equ 1 |
||
171 | Z_BEST_COMPRESSION equ 9 |
||
172 | Z_DEFAULT_COMPRESSION equ (-1) |
||
173 | ; compression levels |
||
174 | |||
175 | Z_FILTERED equ 1 |
||
176 | Z_HUFFMAN_ONLY equ 2 |
||
177 | Z_RLE equ 3 |
||
178 | Z_FIXED equ 4 |
||
179 | Z_DEFAULT_STRATEGY equ 0 |
||
180 | ; compression strategy; see deflateInit2() below for details |
||
181 | |||
182 | Z_BINARY equ 0 |
||
183 | Z_TEXT equ 1 |
||
184 | Z_ASCII equ Z_TEXT ;for compatibility with 1.2.2 and earlier |
||
185 | Z_UNKNOWN equ 2 |
||
186 | ; Possible values of the data_type field (though see inflate()) |
||
187 | |||
188 | Z_DEFLATED equ 8 |
||
189 | ; The deflate compression method (the only one supported in this version) |
||
190 | |||
191 | Z_NULL equ 0 ;for initializing zalloc, zfree, opaque |
||
192 | |||
193 | zlib_version equ zlibVersion |
||
194 | ; for compatibility with versions < 1.0.2 |
||
195 | |||
196 | ; various hacks, don't look :) |
||
197 | |||
198 | ; deflateInit and inflateInit are macros to allow checking the zlib version |
||
199 | ; and the compiler's view of z_stream: |
||
200 | |||
201 | ;int inflateBackInit_ OF((z_streamp strm, int windowBits, |
||
202 | ; unsigned char FAR *window, |
||
203 | ; const char *version, |
||
204 | ; int stream_size)); |
||
205 | ;#define inflateInit(strm) \ |
||
206 | ; inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) |
||
207 | |||
208 | ;#define inflateInit2(strm, windowBits) \ |
||
209 | ; inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ |
||
210 | ; (int)sizeof(z_stream)) |
||
211 | ;#define inflateBackInit(strm, windowBits, window) \ |
||
212 | ; inflateBackInit_((strm), (windowBits), (window), \ |
||
213 | ; ZLIB_VERSION, (int)sizeof(z_stream)) |
||
214 | |||
6639 | IgorA | 215 | if Z_SOLO eq 0 |
6617 | IgorA | 216 | |
217 | ; gzgetc() macro and its supporting function and exposed data structure. Note |
||
218 | ; that the real internal state is much larger than the exposed structure. |
||
219 | ; This abbreviated structure exposes just enough for the gzgetc() macro. The |
||
220 | ; user should not mess with these exposed elements, since their names or |
||
221 | ; behavior could change in the future, perhaps even capriciously. They can |
||
222 | ; only be used by the gzgetc() macro. You have been warned. |
||
223 | |||
224 | ;struct gzFile_s { |
||
225 | ; unsigned have; |
||
226 | ; unsigned char *next; |
||
227 | ; z_off64_t pos; |
||
228 | ;}; |
||
6673 | IgorA | 229 | |
230 | if Z_PREFIX_SET eq 1 |
||
6617 | IgorA | 231 | ;# undef z_gzgetc |
232 | ;# define z_gzgetc(g) \ |
||
233 | ; ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) |
||
6673 | IgorA | 234 | else |
6617 | IgorA | 235 | ;# define gzgetc(g) \ |
236 | ; ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) |
||
6639 | IgorA | 237 | end if |
6617 | IgorA | 238 | |
6673 | IgorA | 239 | end if> |
6617 | IgorA | 240 |