1 | /* zlib.h -- interface of the 'zlib' general purpose compression library
|
---|
2 | version 1.1.4, March 11th, 2002
|
---|
3 |
|
---|
4 | Copyright (C) 1995-2002 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 ftp://ds.internic.net/rfc/rfc1950.txt
|
---|
28 | (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifndef _ZLIB_H
|
---|
32 | #define _ZLIB_H
|
---|
33 |
|
---|
34 | #include "zconf.h"
|
---|
35 |
|
---|
36 | #ifdef __cplusplus
|
---|
37 | extern "C" {
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | #define ZLIB_VERSION "1.1.4"
|
---|
41 |
|
---|
42 | #ifdef QT_MAKEDLL
|
---|
43 | #define Q_ZEXPORT __declspec(dllexport)
|
---|
44 | #else
|
---|
45 | #if defined(QT_DLL) && !defined(QT_PLUGIN)
|
---|
46 | #define Q_ZEXPORT __declspec(dllimport)
|
---|
47 | #else
|
---|
48 | #define Q_ZEXPORT ZEXPORT
|
---|
49 | #endif
|
---|
50 | #endif
|
---|
51 | #ifdef Q_OS_TEMP
|
---|
52 | #include <qfunctions_wce.h>
|
---|
53 | #endif
|
---|
54 | /*
|
---|
55 | The 'zlib' compression library provides in-memory compression and
|
---|
56 | decompression functions, including integrity checks of the uncompressed
|
---|
57 | data. This version of the library supports only one compression method
|
---|
58 | (deflation) but other algorithms will be added later and will have the same
|
---|
59 | stream interface.
|
---|
60 |
|
---|
61 | Compression can be done in a single step if the buffers are large
|
---|
62 | enough (for example if an input file is mmap'ed), or can be done by
|
---|
63 | repeated calls of the compression function. In the latter case, the
|
---|
64 | application must provide more input and/or consume the output
|
---|
65 | (providing more output space) before each call.
|
---|
66 |
|
---|
67 | The library also supports reading and writing files in gzip (.gz) format
|
---|
68 | with an interface similar to that of stdio.
|
---|
69 |
|
---|
70 | The library does not install any signal handler. The decoder checks
|
---|
71 | the consistency of the compressed data, so the library should never
|
---|
72 | crash even in case of corrupted input.
|
---|
73 | */
|
---|
74 |
|
---|
75 | typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
|
---|
76 | typedef void (*free_func) OF((voidpf opaque, voidpf address));
|
---|
77 |
|
---|
78 | struct internal_state;
|
---|
79 |
|
---|
80 | typedef struct z_stream_s {
|
---|
81 | Bytef *next_in; /* next input byte */
|
---|
82 | uInt avail_in; /* number of bytes available at next_in */
|
---|
83 | uLong total_in; /* total nb of input bytes read so far */
|
---|
84 |
|
---|
85 | Bytef *next_out; /* next output byte should be put there */
|
---|
86 | uInt avail_out; /* remaining free space at next_out */
|
---|
87 | uLong total_out; /* total nb of bytes output so far */
|
---|
88 |
|
---|
89 | char *msg; /* last error message, NULL if no error */
|
---|
90 | struct internal_state FAR *state; /* not visible by applications */
|
---|
91 |
|
---|
92 | alloc_func zalloc; /* used to allocate the internal state */
|
---|
93 | free_func zfree; /* used to free the internal state */
|
---|
94 | voidpf opaque; /* private data object passed to zalloc and zfree */
|
---|
95 |
|
---|
96 | int data_type; /* best guess about the data type: ascii or binary */
|
---|
97 | uLong adler; /* adler32 value of the uncompressed data */
|
---|
98 | uLong reserved; /* reserved for future use */
|
---|
99 | } z_stream;
|
---|
100 |
|
---|
101 | typedef z_stream FAR *z_streamp;
|
---|
102 |
|
---|
103 | /*
|
---|
104 | The application must update next_in and avail_in when avail_in has
|
---|
105 | dropped to zero. It must update next_out and avail_out when avail_out
|
---|
106 | has dropped to zero. The application must initialize zalloc, zfree and
|
---|
107 | opaque before calling the init function. All other fields are set by the
|
---|
108 | compression library and must not be updated by the application.
|
---|
109 |
|
---|
110 | The opaque value provided by the application will be passed as the first
|
---|
111 | parameter for calls of zalloc and zfree. This can be useful for custom
|
---|
112 | memory management. The compression library attaches no meaning to the
|
---|
113 | opaque value.
|
---|
114 |
|
---|
115 | zalloc must return Z_NULL if there is not enough memory for the object.
|
---|
116 | If zlib is used in a multi-threaded application, zalloc and zfree must be
|
---|
117 | thread safe.
|
---|
118 |
|
---|
119 | On 16-bit systems, the functions zalloc and zfree must be able to allocate
|
---|
120 | exactly 65536 bytes, but will not be required to allocate more than this
|
---|
121 | if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
|
---|
122 | pointers returned by zalloc for objects of exactly 65536 bytes *must*
|
---|
123 | have their offset normalized to zero. The default allocation function
|
---|
124 | provided by this library ensures this (see zutil.c). To reduce memory
|
---|
125 | requirements and avoid any allocation of 64K objects, at the expense of
|
---|
126 | compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
|
---|
127 |
|
---|
128 | The fields total_in and total_out can be used for statistics or
|
---|
129 | progress reports. After compression, total_in holds the total size of
|
---|
130 | the uncompressed data and may be saved for use in the decompressor
|
---|
131 | (particularly if the decompressor wants to decompress everything in
|
---|
132 | a single step).
|
---|
133 | */
|
---|
134 |
|
---|
135 | /* constants */
|
---|
136 |
|
---|
137 | #define Z_NO_FLUSH 0
|
---|
138 | #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
|
---|
139 | #define Z_SYNC_FLUSH 2
|
---|
140 | #define Z_FULL_FLUSH 3
|
---|
141 | #define Z_FINISH 4
|
---|
142 | /* Allowed flush values; see deflate() below for details */
|
---|
143 |
|
---|
144 | #define Z_OK 0
|
---|
145 | #define Z_STREAM_END 1
|
---|
146 | #define Z_NEED_DICT 2
|
---|
147 | #define Z_ERRNO (-1)
|
---|
148 | #define Z_STREAM_ERROR (-2)
|
---|
149 | #define Z_DATA_ERROR (-3)
|
---|
150 | #define Z_MEM_ERROR (-4)
|
---|
151 | #define Z_BUF_ERROR (-5)
|
---|
152 | #define Z_VERSION_ERROR (-6)
|
---|
153 | /* Return codes for the compression/decompression functions. Negative
|
---|
154 | * values are errors, positive values are used for special but normal events.
|
---|
155 | */
|
---|
156 |
|
---|
157 | #define Z_NO_COMPRESSION 0
|
---|
158 | #define Z_BEST_SPEED 1
|
---|
159 | #define Z_BEST_COMPRESSION 9
|
---|
160 | #define Z_DEFAULT_COMPRESSION (-1)
|
---|
161 | /* compression levels */
|
---|
162 |
|
---|
163 | #define Z_FILTERED 1
|
---|
164 | #define Z_HUFFMAN_ONLY 2
|
---|
165 | #define Z_DEFAULT_STRATEGY 0
|
---|
166 | /* compression strategy; see deflateInit2() below for details */
|
---|
167 |
|
---|
168 | #define Z_BINARY 0
|
---|
169 | #define Z_ASCII 1
|
---|
170 | #define Z_UNKNOWN 2
|
---|
171 | /* Possible values of the data_type field */
|
---|
172 |
|
---|
173 | #define Z_DEFLATED 8
|
---|
174 | /* The deflate compression method (the only one supported in this version) */
|
---|
175 |
|
---|
176 | #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
|
---|
177 |
|
---|
178 | #define zlib_version zlibVersion()
|
---|
179 | /* for compatibility with versions < 1.0.2 */
|
---|
180 |
|
---|
181 | /* basic functions */
|
---|
182 |
|
---|
183 | ZEXTERN Q_ZEXPORT const char * zlibVersion OF((void));
|
---|
184 | /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
|
---|
185 | If the first character differs, the library code actually used is
|
---|
186 | not compatible with the zlib.h header file used by the application.
|
---|
187 | This check is automatically made by deflateInit and inflateInit.
|
---|
188 | */
|
---|
189 |
|
---|
190 | /*
|
---|
191 | ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
|
---|
192 |
|
---|
193 | Initializes the internal stream state for compression. The fields
|
---|
194 | zalloc, zfree and opaque must be initialized before by the caller.
|
---|
195 | If zalloc and zfree are set to Z_NULL, deflateInit updates them to
|
---|
196 | use default allocation functions.
|
---|
197 |
|
---|
198 | The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
|
---|
199 | 1 gives best speed, 9 gives best compression, 0 gives no compression at
|
---|
200 | all (the input data is simply copied a block at a time).
|
---|
201 | Z_DEFAULT_COMPRESSION requests a default compromise between speed and
|
---|
202 | compression (currently equivalent to level 6).
|
---|
203 |
|
---|
204 | deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
|
---|
205 | enough memory, Z_STREAM_ERROR if level is not a valid compression level,
|
---|
206 | Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
|
---|
207 | with the version assumed by the caller (ZLIB_VERSION).
|
---|
208 | msg is set to null if there is no error message. deflateInit does not
|
---|
209 | perform any compression: this will be done by deflate().
|
---|
210 | */
|
---|
211 |
|
---|
212 |
|
---|
213 | ZEXTERN int Q_ZEXPORT deflate OF((z_streamp strm, int flush));
|
---|
214 | /*
|
---|
215 | deflate compresses as much data as possible, and stops when the input
|
---|
216 | buffer becomes empty or the output buffer becomes full. It may introduce some
|
---|
217 | output latency (reading input without producing any output) except when
|
---|
218 | forced to flush.
|
---|
219 |
|
---|
220 | The detailed semantics are as follows. deflate performs one or both of the
|
---|
221 | following actions:
|
---|
222 |
|
---|
223 | - Compress more input starting at next_in and update next_in and avail_in
|
---|
224 | accordingly. If not all input can be processed (because there is not
|
---|
225 | enough room in the output buffer), next_in and avail_in are updated and
|
---|
226 | processing will resume at this point for the next call of deflate().
|
---|
227 |
|
---|
228 | - Provide more output starting at next_out and update next_out and avail_out
|
---|
229 | accordingly. This action is forced if the parameter flush is non zero.
|
---|
230 | Forcing flush frequently degrades the compression ratio, so this parameter
|
---|
231 | should be set only when necessary (in interactive applications).
|
---|
232 | Some output may be provided even if flush is not set.
|
---|
233 |
|
---|
234 | Before the call of deflate(), the application should ensure that at least
|
---|
235 | one of the actions is possible, by providing more input and/or consuming
|
---|
236 | more output, and updating avail_in or avail_out accordingly; avail_out
|
---|
237 | should never be zero before the call. The application can consume the
|
---|
238 | compressed output when it wants, for example when the output buffer is full
|
---|
239 | (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
|
---|
240 | and with zero avail_out, it must be called again after making room in the
|
---|
241 | output buffer because there might be more output pending.
|
---|
242 |
|
---|
243 | If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
|
---|
244 | flushed to the output buffer and the output is aligned on a byte boundary, so
|
---|
245 | that the decompressor can get all input data available so far. (In particular
|
---|
246 | avail_in is zero after the call if enough output space has been provided
|
---|
247 | before the call.) Flushing may degrade compression for some compression
|
---|
248 | algorithms and so it should be used only when necessary.
|
---|
249 |
|
---|
250 | If flush is set to Z_FULL_FLUSH, all output is flushed as with
|
---|
251 | Z_SYNC_FLUSH, and the compression state is reset so that decompression can
|
---|
252 | restart from this point if previous compressed data has been damaged or if
|
---|
253 | random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
|
---|
254 | the compression.
|
---|
255 |
|
---|
256 | If deflate returns with avail_out == 0, this function must be called again
|
---|
257 | with the same value of the flush parameter and more output space (updated
|
---|
258 | avail_out), until the flush is complete (deflate returns with non-zero
|
---|
259 | avail_out).
|
---|
260 |
|
---|
261 | If the parameter flush is set to Z_FINISH, pending input is processed,
|
---|
262 | pending output is flushed and deflate returns with Z_STREAM_END if there
|
---|
263 | was enough output space; if deflate returns with Z_OK, this function must be
|
---|
264 | called again with Z_FINISH and more output space (updated avail_out) but no
|
---|
265 | more input data, until it returns with Z_STREAM_END or an error. After
|
---|
266 | deflate has returned Z_STREAM_END, the only possible operations on the
|
---|
267 | stream are deflateReset or deflateEnd.
|
---|
268 |
|
---|
269 | Z_FINISH can be used immediately after deflateInit if all the compression
|
---|
270 | is to be done in a single step. In this case, avail_out must be at least
|
---|
271 | 0.1% larger than avail_in plus 12 bytes. If deflate does not return
|
---|
272 | Z_STREAM_END, then it must be called again as described above.
|
---|
273 |
|
---|
274 | deflate() sets strm->adler to the adler32 checksum of all input read
|
---|
275 | so far (that is, total_in bytes).
|
---|
276 |
|
---|
277 | deflate() may update data_type if it can make a good guess about
|
---|
278 | the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
|
---|
279 | binary. This field is only for information purposes and does not affect
|
---|
280 | the compression algorithm in any manner.
|
---|
281 |
|
---|
282 | deflate() returns Z_OK if some progress has been made (more input
|
---|
283 | processed or more output produced), Z_STREAM_END if all input has been
|
---|
284 | consumed and all output has been produced (only when flush is set to
|
---|
285 | Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
|
---|
286 | if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
|
---|
287 | (for example avail_in or avail_out was zero).
|
---|
288 | */
|
---|
289 |
|
---|
290 |
|
---|
291 | ZEXTERN int Q_ZEXPORT deflateEnd OF((z_streamp strm));
|
---|
292 | /*
|
---|
293 | All dynamically allocated data structures for this stream are freed.
|
---|
294 | This function discards any unprocessed input and does not flush any
|
---|
295 | pending output.
|
---|
296 |
|
---|
297 | deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
|
---|
298 | stream state was inconsistent, Z_DATA_ERROR if the stream was freed
|
---|
299 | prematurely (some input or output was discarded). In the error case,
|
---|
300 | msg may be set but then points to a static string (which must not be
|
---|
301 | deallocated).
|
---|
302 | */
|
---|
303 |
|
---|
304 |
|
---|
305 | /*
|
---|
306 | ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
|
---|
307 |
|
---|
308 | Initializes the internal stream state for decompression. The fields
|
---|
309 | next_in, avail_in, zalloc, zfree and opaque must be initialized before by
|
---|
310 | the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
|
---|
311 | value depends on the compression method), inflateInit determines the
|
---|
312 | compression method from the zlib header and allocates all data structures
|
---|
313 | accordingly; otherwise the allocation will be deferred to the first call of
|
---|
314 | inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
|
---|
315 | use default allocation functions.
|
---|
316 |
|
---|
317 | inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
---|
318 | memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
---|
319 | version assumed by the caller. msg is set to null if there is no error
|
---|
320 | message. inflateInit does not perform any decompression apart from reading
|
---|
321 | the zlib header if present: this will be done by inflate(). (So next_in and
|
---|
322 | avail_in may be modified, but next_out and avail_out are unchanged.)
|
---|
323 | */
|
---|
324 |
|
---|
325 |
|
---|
326 | ZEXTERN int Q_ZEXPORT inflate OF((z_streamp strm, int flush));
|
---|
327 | /*
|
---|
328 | inflate decompresses as much data as possible, and stops when the input
|
---|
329 | buffer becomes empty or the output buffer becomes full. It may some
|
---|
330 | introduce some output latency (reading input without producing any output)
|
---|
331 | except when forced to flush.
|
---|
332 |
|
---|
333 | The detailed semantics are as follows. inflate performs one or both of the
|
---|
334 | following actions:
|
---|
335 |
|
---|
336 | - Decompress more input starting at next_in and update next_in and avail_in
|
---|
337 | accordingly. If not all input can be processed (because there is not
|
---|
338 | enough room in the output buffer), next_in is updated and processing
|
---|
339 | will resume at this point for the next call of inflate().
|
---|
340 |
|
---|
341 | - Provide more output starting at next_out and update next_out and avail_out
|
---|
342 | accordingly. inflate() provides as much output as possible, until there
|
---|
343 | is no more input data or no more space in the output buffer (see below
|
---|
344 | about the flush parameter).
|
---|
345 |
|
---|
346 | Before the call of inflate(), the application should ensure that at least
|
---|
347 | one of the actions is possible, by providing more input and/or consuming
|
---|
348 | more output, and updating the next_* and avail_* values accordingly.
|
---|
349 | The application can consume the uncompressed output when it wants, for
|
---|
350 | example when the output buffer is full (avail_out == 0), or after each
|
---|
351 | call of inflate(). If inflate returns Z_OK and with zero avail_out, it
|
---|
352 | must be called again after making room in the output buffer because there
|
---|
353 | might be more output pending.
|
---|
354 |
|
---|
355 | If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
|
---|
356 | output as possible to the output buffer. The flushing behavior of inflate is
|
---|
357 | not specified for values of the flush parameter other than Z_SYNC_FLUSH
|
---|
358 | and Z_FINISH, but the current implementation actually flushes as much output
|
---|
359 | as possible anyway.
|
---|
360 |
|
---|
361 | inflate() should normally be called until it returns Z_STREAM_END or an
|
---|
362 | error. However if all decompression is to be performed in a single step
|
---|
363 | (a single call of inflate), the parameter flush should be set to
|
---|
364 | Z_FINISH. In this case all pending input is processed and all pending
|
---|
365 | output is flushed; avail_out must be large enough to hold all the
|
---|
366 | uncompressed data. (The size of the uncompressed data may have been saved
|
---|
367 | by the compressor for this purpose.) The next operation on this stream must
|
---|
368 | be inflateEnd to deallocate the decompression state. The use of Z_FINISH
|
---|
369 | is never required, but can be used to inform inflate that a faster routine
|
---|
370 | may be used for the single inflate() call.
|
---|
371 |
|
---|
372 | If a preset dictionary is needed at this point (see inflateSetDictionary
|
---|
373 | below), inflate sets strm-adler to the adler32 checksum of the
|
---|
374 | dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
|
---|
375 | it sets strm->adler to the adler32 checksum of all output produced
|
---|
376 | so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
|
---|
377 | an error code as described below. At the end of the stream, inflate()
|
---|
378 | checks that its computed adler32 checksum is equal to that saved by the
|
---|
379 | compressor and returns Z_STREAM_END only if the checksum is correct.
|
---|
380 |
|
---|
381 | inflate() returns Z_OK if some progress has been made (more input processed
|
---|
382 | or more output produced), Z_STREAM_END if the end of the compressed data has
|
---|
383 | been reached and all uncompressed output has been produced, Z_NEED_DICT if a
|
---|
384 | preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
|
---|
385 | corrupted (input stream not conforming to the zlib format or incorrect
|
---|
386 | adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
|
---|
387 | (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
|
---|
388 | enough memory, Z_BUF_ERROR if no progress is possible or if there was not
|
---|
389 | enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
|
---|
390 | case, the application may then call inflateSync to look for a good
|
---|
391 | compression block.
|
---|
392 | */
|
---|
393 |
|
---|
394 |
|
---|
395 | ZEXTERN int Q_ZEXPORT inflateEnd OF((z_streamp strm));
|
---|
396 | /*
|
---|
397 | All dynamically allocated data structures for this stream are freed.
|
---|
398 | This function discards any unprocessed input and does not flush any
|
---|
399 | pending output.
|
---|
400 |
|
---|
401 | inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
|
---|
402 | was inconsistent. In the error case, msg may be set but then points to a
|
---|
403 | static string (which must not be deallocated).
|
---|
404 | */
|
---|
405 |
|
---|
406 | /* Advanced functions */
|
---|
407 |
|
---|
408 | /*
|
---|
409 | The following functions are needed only in some special applications.
|
---|
410 | */
|
---|
411 |
|
---|
412 | /*
|
---|
413 | ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
---|
414 | int level,
|
---|
415 | int method,
|
---|
416 | int windowBits,
|
---|
417 | int memLevel,
|
---|
418 | int strategy));
|
---|
419 |
|
---|
420 | This is another version of deflateInit with more compression options. The
|
---|
421 | fields next_in, zalloc, zfree and opaque must be initialized before by
|
---|
422 | the caller.
|
---|
423 |
|
---|
424 | The method parameter is the compression method. It must be Z_DEFLATED in
|
---|
425 | this version of the library.
|
---|
426 |
|
---|
427 | The windowBits parameter is the base two logarithm of the window size
|
---|
428 | (the size of the history buffer). It should be in the range 8..15 for this
|
---|
429 | version of the library. Larger values of this parameter result in better
|
---|
430 | compression at the expense of memory usage. The default value is 15 if
|
---|
431 | deflateInit is used instead.
|
---|
432 |
|
---|
433 | The memLevel parameter specifies how much memory should be allocated
|
---|
434 | for the internal compression state. memLevel=1 uses minimum memory but
|
---|
435 | is slow and reduces compression ratio; memLevel=9 uses maximum memory
|
---|
436 | for optimal speed. The default value is 8. See zconf.h for total memory
|
---|
437 | usage as a function of windowBits and memLevel.
|
---|
438 |
|
---|
439 | The strategy parameter is used to tune the compression algorithm. Use the
|
---|
440 | value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
|
---|
441 | filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
|
---|
442 | string match). Filtered data consists mostly of small values with a
|
---|
443 | somewhat random distribution. In this case, the compression algorithm is
|
---|
444 | tuned to compress them better. The effect of Z_FILTERED is to force more
|
---|
445 | Huffman coding and less string matching; it is somewhat intermediate
|
---|
446 | between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
|
---|
447 | the compression ratio but not the correctness of the compressed output even
|
---|
448 | if it is not set appropriately.
|
---|
449 |
|
---|
450 | deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
---|
451 | memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
|
---|
452 | method). msg is set to null if there is no error message. deflateInit2 does
|
---|
453 | not perform any compression: this will be done by deflate().
|
---|
454 | */
|
---|
455 |
|
---|
456 | ZEXTERN int Q_ZEXPORT deflateSetDictionary OF((z_streamp strm,
|
---|
457 | const Bytef *dictionary,
|
---|
458 | uInt dictLength));
|
---|
459 | /*
|
---|
460 | Initializes the compression dictionary from the given byte sequence
|
---|
461 | without producing any compressed output. This function must be called
|
---|
462 | immediately after deflateInit, deflateInit2 or deflateReset, before any
|
---|
463 | call of deflate. The compressor and decompressor must use exactly the same
|
---|
464 | dictionary (see inflateSetDictionary).
|
---|
465 |
|
---|
466 | The dictionary should consist of strings (byte sequences) that are likely
|
---|
467 | to be encountered later in the data to be compressed, with the most commonly
|
---|
468 | used strings preferably put towards the end of the dictionary. Using a
|
---|
469 | dictionary is most useful when the data to be compressed is short and can be
|
---|
470 | predicted with good accuracy; the data can then be compressed better than
|
---|
471 | with the default empty dictionary.
|
---|
472 |
|
---|
473 | Depending on the size of the compression data structures selected by
|
---|
474 | deflateInit or deflateInit2, a part of the dictionary may in effect be
|
---|
475 | discarded, for example if the dictionary is larger than the window size in
|
---|
476 | deflate or deflate2. Thus the strings most likely to be useful should be
|
---|
477 | put at the end of the dictionary, not at the front.
|
---|
478 |
|
---|
479 | Upon return of this function, strm->adler is set to the Adler32 value
|
---|
480 | of the dictionary; the decompressor may later use this value to determine
|
---|
481 | which dictionary has been used by the compressor. (The Adler32 value
|
---|
482 | applies to the whole dictionary even if only a subset of the dictionary is
|
---|
483 | actually used by the compressor.)
|
---|
484 |
|
---|
485 | deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
|
---|
486 | parameter is invalid (such as NULL dictionary) or the stream state is
|
---|
487 | inconsistent (for example if deflate has already been called for this stream
|
---|
488 | or if the compression method is bsort). deflateSetDictionary does not
|
---|
489 | perform any compression: this will be done by deflate().
|
---|
490 | */
|
---|
491 |
|
---|
492 | ZEXTERN int Q_ZEXPORT deflateCopy OF((z_streamp dest,
|
---|
493 | z_streamp source));
|
---|
494 | /*
|
---|
495 | Sets the destination stream as a complete copy of the source stream.
|
---|
496 |
|
---|
497 | This function can be useful when several compression strategies will be
|
---|
498 | tried, for example when there are several ways of pre-processing the input
|
---|
499 | data with a filter. The streams that will be discarded should then be freed
|
---|
500 | by calling deflateEnd. Note that deflateCopy duplicates the internal
|
---|
501 | compression state which can be quite large, so this strategy is slow and
|
---|
502 | can consume lots of memory.
|
---|
503 |
|
---|
504 | deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
|
---|
505 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
|
---|
506 | (such as zalloc being NULL). msg is left unchanged in both source and
|
---|
507 | destination.
|
---|
508 | */
|
---|
509 |
|
---|
510 | ZEXTERN int Q_ZEXPORT deflateReset OF((z_streamp strm));
|
---|
511 | /*
|
---|
512 | This function is equivalent to deflateEnd followed by deflateInit,
|
---|
513 | but does not free and reallocate all the internal compression state.
|
---|
514 | The stream will keep the same compression level and any other attributes
|
---|
515 | that may have been set by deflateInit2.
|
---|
516 |
|
---|
517 | deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
|
---|
518 | stream state was inconsistent (such as zalloc or state being NULL).
|
---|
519 | */
|
---|
520 |
|
---|
521 | ZEXTERN int Q_ZEXPORT deflateParams OF((z_streamp strm,
|
---|
522 | int level,
|
---|
523 | int strategy));
|
---|
524 | /*
|
---|
525 | Dynamically update the compression level and compression strategy. The
|
---|
526 | interpretation of level and strategy is as in deflateInit2. This can be
|
---|
527 | used to switch between compression and straight copy of the input data, or
|
---|
528 | to switch to a different kind of input data requiring a different
|
---|
529 | strategy. If the compression level is changed, the input available so far
|
---|
530 | is compressed with the old level (and may be flushed); the new level will
|
---|
531 | take effect only at the next call of deflate().
|
---|
532 |
|
---|
533 | Before the call of deflateParams, the stream state must be set as for
|
---|
534 | a call of deflate(), since the currently available input may have to
|
---|
535 | be compressed and flushed. In particular, strm->avail_out must be non-zero.
|
---|
536 |
|
---|
537 | deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
|
---|
538 | stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
|
---|
539 | if strm->avail_out was zero.
|
---|
540 | */
|
---|
541 |
|
---|
542 | /*
|
---|
543 | ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
---|
544 | int windowBits));
|
---|
545 |
|
---|
546 | This is another version of inflateInit with an extra parameter. The
|
---|
547 | fields next_in, avail_in, zalloc, zfree and opaque must be initialized
|
---|
548 | before by the caller.
|
---|
549 |
|
---|
550 | The windowBits parameter is the base two logarithm of the maximum window
|
---|
551 | size (the size of the history buffer). It should be in the range 8..15 for
|
---|
552 | this version of the library. The default value is 15 if inflateInit is used
|
---|
553 | instead. If a compressed stream with a larger window size is given as
|
---|
554 | input, inflate() will return with the error code Z_DATA_ERROR instead of
|
---|
555 | trying to allocate a larger window.
|
---|
556 |
|
---|
557 | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
---|
558 | memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
|
---|
559 | memLevel). msg is set to null if there is no error message. inflateInit2
|
---|
560 | does not perform any decompression apart from reading the zlib header if
|
---|
561 | present: this will be done by inflate(). (So next_in and avail_in may be
|
---|
562 | modified, but next_out and avail_out are unchanged.)
|
---|
563 | */
|
---|
564 |
|
---|
565 | ZEXTERN int Q_ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
---|
566 | const Bytef *dictionary,
|
---|
567 | uInt dictLength));
|
---|
568 | /*
|
---|
569 | Initializes the decompression dictionary from the given uncompressed byte
|
---|
570 | sequence. This function must be called immediately after a call of inflate
|
---|
571 | if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
|
---|
572 | can be determined from the Adler32 value returned by this call of
|
---|
573 | inflate. The compressor and decompressor must use exactly the same
|
---|
574 | dictionary (see deflateSetDictionary).
|
---|
575 |
|
---|
576 | inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
|
---|
577 | parameter is invalid (such as NULL dictionary) or the stream state is
|
---|
578 | inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
|
---|
579 | expected one (incorrect Adler32 value). inflateSetDictionary does not
|
---|
580 | perform any decompression: this will be done by subsequent calls of
|
---|
581 | inflate().
|
---|
582 | */
|
---|
583 |
|
---|
584 | ZEXTERN int Q_ZEXPORT inflateSync OF((z_streamp strm));
|
---|
585 | /*
|
---|
586 | Skips invalid compressed data until a full flush point (see above the
|
---|
587 | description of deflate with Z_FULL_FLUSH) can be found, or until all
|
---|
588 | available input is skipped. No output is provided.
|
---|
589 |
|
---|
590 | inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
|
---|
591 | if no more input was provided, Z_DATA_ERROR if no flush point has been found,
|
---|
592 | or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
|
---|
593 | case, the application may save the current current value of total_in which
|
---|
594 | indicates where valid compressed data was found. In the error case, the
|
---|
595 | application may repeatedly call inflateSync, providing more input each time,
|
---|
596 | until success or end of the input data.
|
---|
597 | */
|
---|
598 |
|
---|
599 | ZEXTERN int Q_ZEXPORT inflateReset OF((z_streamp strm));
|
---|
600 | /*
|
---|
601 | This function is equivalent to inflateEnd followed by inflateInit,
|
---|
602 | but does not free and reallocate all the internal decompression state.
|
---|
603 | The stream will keep attributes that may have been set by inflateInit2.
|
---|
604 |
|
---|
605 | inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
|
---|
606 | stream state was inconsistent (such as zalloc or state being NULL).
|
---|
607 | */
|
---|
608 |
|
---|
609 |
|
---|
610 | /* utility functions */
|
---|
611 |
|
---|
612 | /*
|
---|
613 | The following utility functions are implemented on top of the
|
---|
614 | basic stream-oriented functions. To simplify the interface, some
|
---|
615 | default options are assumed (compression level and memory usage,
|
---|
616 | standard memory allocation functions). The source code of these
|
---|
617 | utility functions can easily be modified if you need special options.
|
---|
618 | */
|
---|
619 |
|
---|
620 | ZEXTERN int Q_ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
|
---|
621 | const Bytef *source, uLong sourceLen));
|
---|
622 | /*
|
---|
623 | Compresses the source buffer into the destination buffer. sourceLen is
|
---|
624 | the byte length of the source buffer. Upon entry, destLen is the total
|
---|
625 | size of the destination buffer, which must be at least 0.1% larger than
|
---|
626 | sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
|
---|
627 | compressed buffer.
|
---|
628 | This function can be used to compress a whole file at once if the
|
---|
629 | input file is mmap'ed.
|
---|
630 | compress returns Z_OK if success, Z_MEM_ERROR if there was not
|
---|
631 | enough memory, Z_BUF_ERROR if there was not enough room in the output
|
---|
632 | buffer.
|
---|
633 | */
|
---|
634 |
|
---|
635 | ZEXTERN int Q_ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
|
---|
636 | const Bytef *source, uLong sourceLen,
|
---|
637 | int level));
|
---|
638 | /*
|
---|
639 | Compresses the source buffer into the destination buffer. The level
|
---|
640 | parameter has the same meaning as in deflateInit. sourceLen is the byte
|
---|
641 | length of the source buffer. Upon entry, destLen is the total size of the
|
---|
642 | destination buffer, which must be at least 0.1% larger than sourceLen plus
|
---|
643 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
|
---|
644 |
|
---|
645 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
---|
646 | memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
---|
647 | Z_STREAM_ERROR if the level parameter is invalid.
|
---|
648 | */
|
---|
649 |
|
---|
650 | ZEXTERN int Q_ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
|
---|
651 | const Bytef *source, uLong sourceLen));
|
---|
652 | /*
|
---|
653 | Decompresses the source buffer into the destination buffer. sourceLen is
|
---|
654 | the byte length of the source buffer. Upon entry, destLen is the total
|
---|
655 | size of the destination buffer, which must be large enough to hold the
|
---|
656 | entire uncompressed data. (The size of the uncompressed data must have
|
---|
657 | been saved previously by the compressor and transmitted to the decompressor
|
---|
658 | by some mechanism outside the scope of this compression library.)
|
---|
659 | Upon exit, destLen is the actual size of the compressed buffer.
|
---|
660 | This function can be used to decompress a whole file at once if the
|
---|
661 | input file is mmap'ed.
|
---|
662 |
|
---|
663 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
---|
664 | enough memory, Z_BUF_ERROR if there was not enough room in the output
|
---|
665 | buffer, or Z_DATA_ERROR if the input data was corrupted.
|
---|
666 | */
|
---|
667 |
|
---|
668 |
|
---|
669 | typedef voidp gzFile;
|
---|
670 |
|
---|
671 | ZEXTERN gzFile Q_ZEXPORT gzopen OF((const char *path, const char *mode));
|
---|
672 | /*
|
---|
673 | Opens a gzip (.gz) file for reading or writing. The mode parameter
|
---|
674 | is as in fopen ("rb" or "wb") but can also include a compression level
|
---|
675 | ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
|
---|
676 | Huffman only compression as in "wb1h". (See the description
|
---|
677 | of deflateInit2 for more information about the strategy parameter.)
|
---|
678 |
|
---|
679 | gzopen can be used to read a file which is not in gzip format; in this
|
---|
680 | case gzread will directly read from the file without decompression.
|
---|
681 |
|
---|
682 | gzopen returns NULL if the file could not be opened or if there was
|
---|
683 | insufficient memory to allocate the (de)compression state; errno
|
---|
684 | can be checked to distinguish the two cases (if errno is zero, the
|
---|
685 | zlib error is Z_MEM_ERROR). */
|
---|
686 |
|
---|
687 | ZEXTERN gzFile Q_ZEXPORT gzdopen OF((int fd, const char *mode));
|
---|
688 | /*
|
---|
689 | gzdopen() associates a gzFile with the file descriptor fd. File
|
---|
690 | descriptors are obtained from calls like open, dup, creat, pipe or
|
---|
691 | fileno (in the file has been previously opened with fopen).
|
---|
692 | The mode parameter is as in gzopen.
|
---|
693 | The next call of gzclose on the returned gzFile will also close the
|
---|
694 | file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
|
---|
695 | descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
|
---|
696 | gzdopen returns NULL if there was insufficient memory to allocate
|
---|
697 | the (de)compression state.
|
---|
698 | */
|
---|
699 |
|
---|
700 | ZEXTERN int Q_ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
|
---|
701 | /*
|
---|
702 | Dynamically update the compression level or strategy. See the description
|
---|
703 | of deflateInit2 for the meaning of these parameters.
|
---|
704 | gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
|
---|
705 | opened for writing.
|
---|
706 | */
|
---|
707 |
|
---|
708 | ZEXTERN int Q_ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
---|
709 | /*
|
---|
710 | Reads the given number of uncompressed bytes from the compressed file.
|
---|
711 | If the input file was not in gzip format, gzread copies the given number
|
---|
712 | of bytes into the buffer.
|
---|
713 | gzread returns the number of uncompressed bytes actually read (0 for
|
---|
714 | end of file, -1 for error). */
|
---|
715 |
|
---|
716 | ZEXTERN int Q_ZEXPORT gzwrite OF((gzFile file,
|
---|
717 | const voidp buf, unsigned len));
|
---|
718 | /*
|
---|
719 | Writes the given number of uncompressed bytes into the compressed file.
|
---|
720 | gzwrite returns the number of uncompressed bytes actually written
|
---|
721 | (0 in case of error).
|
---|
722 | */
|
---|
723 |
|
---|
724 | ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
|
---|
725 | /*
|
---|
726 | Converts, formats, and writes the args to the compressed file under
|
---|
727 | control of the format string, as in fprintf. gzprintf returns the number of
|
---|
728 | uncompressed bytes actually written (0 in case of error).
|
---|
729 | */
|
---|
730 |
|
---|
731 | ZEXTERN int Q_ZEXPORT gzputs OF((gzFile file, const char *s));
|
---|
732 | /*
|
---|
733 | Writes the given null-terminated string to the compressed file, excluding
|
---|
734 | the terminating null character.
|
---|
735 | gzputs returns the number of characters written, or -1 in case of error.
|
---|
736 | */
|
---|
737 |
|
---|
738 | ZEXTERN Q_ZEXPORT char *gzgets OF((gzFile file, char *buf, int len));
|
---|
739 | /*
|
---|
740 | Reads bytes from the compressed file until len-1 characters are read, or
|
---|
741 | a newline character is read and transferred to buf, or an end-of-file
|
---|
742 | condition is encountered. The string is then terminated with a null
|
---|
743 | character.
|
---|
744 | gzgets returns buf, or Z_NULL in case of error.
|
---|
745 | */
|
---|
746 |
|
---|
747 | ZEXTERN int Q_ZEXPORT gzputc OF((gzFile file, int c));
|
---|
748 | /*
|
---|
749 | Writes c, converted to an unsigned char, into the compressed file.
|
---|
750 | gzputc returns the value that was written, or -1 in case of error.
|
---|
751 | */
|
---|
752 |
|
---|
753 | ZEXTERN int Q_ZEXPORT gzgetc OF((gzFile file));
|
---|
754 | /*
|
---|
755 | Reads one byte from the compressed file. gzgetc returns this byte
|
---|
756 | or -1 in case of end of file or error.
|
---|
757 | */
|
---|
758 |
|
---|
759 | ZEXTERN int Q_ZEXPORT gzflush OF((gzFile file, int flush));
|
---|
760 | /*
|
---|
761 | Flushes all pending output into the compressed file. The parameter
|
---|
762 | flush is as in the deflate() function. The return value is the zlib
|
---|
763 | error number (see function gzerror below). gzflush returns Z_OK if
|
---|
764 | the flush parameter is Z_FINISH and all output could be flushed.
|
---|
765 | gzflush should be called only when strictly necessary because it can
|
---|
766 | degrade compression.
|
---|
767 | */
|
---|
768 |
|
---|
769 | ZEXTERN z_off_t Q_ZEXPORT gzseek OF((gzFile file,
|
---|
770 | z_off_t offset, int whence));
|
---|
771 | /*
|
---|
772 | Sets the starting position for the next gzread or gzwrite on the
|
---|
773 | given compressed file. The offset represents a number of bytes in the
|
---|
774 | uncompressed data stream. The whence parameter is defined as in lseek(2);
|
---|
775 | the value SEEK_END is not supported.
|
---|
776 | If the file is opened for reading, this function is emulated but can be
|
---|
777 | extremely slow. If the file is opened for writing, only forward seeks are
|
---|
778 | supported; gzseek then compresses a sequence of zeroes up to the new
|
---|
779 | starting position.
|
---|
780 |
|
---|
781 | gzseek returns the resulting offset location as measured in bytes from
|
---|
782 | the beginning of the uncompressed stream, or -1 in case of error, in
|
---|
783 | particular if the file is opened for writing and the new starting position
|
---|
784 | would be before the current position.
|
---|
785 | */
|
---|
786 |
|
---|
787 | ZEXTERN int Q_ZEXPORT gzrewind OF((gzFile file));
|
---|
788 | /*
|
---|
789 | Rewinds the given file. This function is supported only for reading.
|
---|
790 |
|
---|
791 | gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
|
---|
792 | */
|
---|
793 |
|
---|
794 | ZEXTERN z_off_t Q_ZEXPORT gztell OF((gzFile file));
|
---|
795 | /*
|
---|
796 | Returns the starting position for the next gzread or gzwrite on the
|
---|
797 | given compressed file. This position represents a number of bytes in the
|
---|
798 | uncompressed data stream.
|
---|
799 |
|
---|
800 | gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
|
---|
801 | */
|
---|
802 |
|
---|
803 | ZEXTERN int Q_ZEXPORT gzeof OF((gzFile file));
|
---|
804 | /*
|
---|
805 | Returns 1 when EOF has previously been detected reading the given
|
---|
806 | input stream, otherwise zero.
|
---|
807 | */
|
---|
808 |
|
---|
809 | ZEXTERN int Q_ZEXPORT gzclose OF((gzFile file));
|
---|
810 | /*
|
---|
811 | Flushes all pending output if necessary, closes the compressed file
|
---|
812 | and deallocates all the (de)compression state. The return value is the zlib
|
---|
813 | error number (see function gzerror below).
|
---|
814 | */
|
---|
815 |
|
---|
816 | ZEXTERN Q_ZEXPORT const char *gzerror OF((gzFile file, int *errnum));
|
---|
817 | /*
|
---|
818 | Returns the error message for the last error which occurred on the
|
---|
819 | given compressed file. errnum is set to zlib error number. If an
|
---|
820 | error occurred in the file system and not in the compression library,
|
---|
821 | errnum is set to Z_ERRNO and the application may consult errno
|
---|
822 | to get the exact error code.
|
---|
823 | */
|
---|
824 |
|
---|
825 | /* checksum functions */
|
---|
826 |
|
---|
827 | /*
|
---|
828 | These functions are not related to compression but are exported
|
---|
829 | anyway because they might be useful in applications using the
|
---|
830 | compression library.
|
---|
831 | */
|
---|
832 |
|
---|
833 | ZEXTERN uLong Q_ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
---|
834 |
|
---|
835 | /*
|
---|
836 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
---|
837 | return the updated checksum. If buf is NULL, this function returns
|
---|
838 | the required initial value for the checksum.
|
---|
839 | An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
|
---|
840 | much faster. Usage example:
|
---|
841 |
|
---|
842 | uLong adler = adler32(0L, Z_NULL, 0);
|
---|
843 |
|
---|
844 | while (read_buffer(buffer, length) != EOF) {
|
---|
845 | adler = adler32(adler, buffer, length);
|
---|
846 | }
|
---|
847 | if (adler != original_adler) error();
|
---|
848 | */
|
---|
849 |
|
---|
850 | ZEXTERN uLong Q_ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
---|
851 | /*
|
---|
852 | Update a running crc with the bytes buf[0..len-1] and return the updated
|
---|
853 | crc. If buf is NULL, this function returns the required initial value
|
---|
854 | for the crc. Pre- and post-conditioning (one's complement) is performed
|
---|
855 | within this function so it shouldn't be done by the application.
|
---|
856 | Usage example:
|
---|
857 |
|
---|
858 | uLong crc = crc32(0L, Z_NULL, 0);
|
---|
859 |
|
---|
860 | while (read_buffer(buffer, length) != EOF) {
|
---|
861 | crc = crc32(crc, buffer, length);
|
---|
862 | }
|
---|
863 | if (crc != original_crc) error();
|
---|
864 | */
|
---|
865 |
|
---|
866 |
|
---|
867 | /* various hacks, don't look :) */
|
---|
868 |
|
---|
869 | /* deflateInit and inflateInit are macros to allow checking the zlib version
|
---|
870 | * and the compiler's view of z_stream:
|
---|
871 | */
|
---|
872 | ZEXTERN int Q_ZEXPORT deflateInit_ OF((z_streamp strm, int level,
|
---|
873 | const char *version, int stream_size));
|
---|
874 | ZEXTERN int Q_ZEXPORT inflateInit_ OF((z_streamp strm,
|
---|
875 | const char *version, int stream_size));
|
---|
876 | ZEXTERN int Q_ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
|
---|
877 | int windowBits, int memLevel,
|
---|
878 | int strategy, const char *version,
|
---|
879 | int stream_size));
|
---|
880 | ZEXTERN int Q_ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
|
---|
881 | const char *version, int stream_size));
|
---|
882 | #define deflateInit(strm, level) \
|
---|
883 | deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
|
---|
884 | #define inflateInit(strm) \
|
---|
885 | inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
|
---|
886 | #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
|
---|
887 | deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
|
---|
888 | (strategy), ZLIB_VERSION, sizeof(z_stream))
|
---|
889 | #define inflateInit2(strm, windowBits) \
|
---|
890 | inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
|
---|
891 |
|
---|
892 |
|
---|
893 | #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
|
---|
894 | struct internal_state {int dummy;}; /* hack for buggy compilers */
|
---|
895 | #endif
|
---|
896 |
|
---|
897 | ZEXTERN Q_ZEXPORT const char * zError OF((int err));
|
---|
898 | ZEXTERN int Q_ZEXPORT inflateSyncPoint OF((z_streamp z));
|
---|
899 | ZEXTERN Q_ZEXPORT const uLongf *get_crc_table OF((void));
|
---|
900 |
|
---|
901 | #ifdef __cplusplus
|
---|
902 | }
|
---|
903 | #endif
|
---|
904 |
|
---|
905 | #endif /* _ZLIB_H */
|
---|