1 /* zlib.h -- interface of the 'zlib' general purpose compression library
2   version 1.1.3, July 9th, 1998
3 
4   Copyright (C) 1995-1998 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 <linux/zconf.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #define ZLIB_VERSION "1.1.3"
41 
42 /*
43      The 'zlib' compression library provides in-memory compression and
44   decompression functions, including integrity checks of the uncompressed
45   data.  This version of the library supports only one compression method
46   (deflation) but other algorithms will be added later and will have the same
47   stream interface.
48 
49      Compression can be done in a single step if the buffers are large
50   enough (for example if an input file is mmap'ed), or can be done by
51   repeated calls of the compression function.  In the latter case, the
52   application must provide more input and/or consume the output
53   (providing more output space) before each call.
54 
55      The library also supports reading and writing files in gzip (.gz) format
56   with an interface similar to that of stdio.
57 
58      The library does not install any signal handler. The decoder checks
59   the consistency of the compressed data, so the library should never
60   crash even in case of corrupted input.
61 */
62 
63 typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
64 typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
65 
66 struct internal_state;
67 
68 typedef struct z_stream_s {
69     Bytef    *next_in;  /* next input byte */
70     uInt     avail_in;  /* number of bytes available at next_in */
71     uLong    total_in;  /* total nb of input bytes read so far */
72 
73     Bytef    *next_out; /* next output byte should be put there */
74     uInt     avail_out; /* remaining free space at next_out */
75     uLong    total_out; /* total nb of bytes output so far */
76 
77     char     *msg;      /* last error message, NULL if no error */
78     struct internal_state FAR *state; /* not visible by applications */
79 
80     void     *workspace; /* memory allocated for this stream */
81 
82     int     data_type;  /* best guess about the data type: ascii or binary */
83     uLong   adler;      /* adler32 value of the uncompressed data */
84     uLong   reserved;   /* reserved for future use */
85 } z_stream;
86 
87 typedef z_stream FAR *z_streamp;
88 
89 /*
90    The application must update next_in and avail_in when avail_in has
91    dropped to zero. It must update next_out and avail_out when avail_out
92    has dropped to zero. The application must initialize zalloc, zfree and
93    opaque before calling the init function. All other fields are set by the
94    compression library and must not be updated by the application.
95 
96    The opaque value provided by the application will be passed as the first
97    parameter for calls of zalloc and zfree. This can be useful for custom
98    memory management. The compression library attaches no meaning to the
99    opaque value.
100 
101    zalloc must return Z_NULL if there is not enough memory for the object.
102    If zlib is used in a multi-threaded application, zalloc and zfree must be
103    thread safe.
104 
105    On 16-bit systems, the functions zalloc and zfree must be able to allocate
106    exactly 65536 bytes, but will not be required to allocate more than this
107    if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
108    pointers returned by zalloc for objects of exactly 65536 bytes *must*
109    have their offset normalized to zero. The default allocation function
110    provided by this library ensures this (see zutil.c). To reduce memory
111    requirements and avoid any allocation of 64K objects, at the expense of
112    compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
113 
114    The fields total_in and total_out can be used for statistics or
115    progress reports. After compression, total_in holds the total size of
116    the uncompressed data and may be saved for use in the decompressor
117    (particularly if the decompressor wants to decompress everything in
118    a single step).
119 */
120 
121                         /* constants */
122 
123 #define Z_NO_FLUSH      0
124 #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
125 #define Z_PACKET_FLUSH  2
126 #define Z_SYNC_FLUSH    3
127 #define Z_FULL_FLUSH    4
128 #define Z_FINISH        5
129 /* Allowed flush values; see deflate() below for details */
130 
131 #define Z_OK            0
132 #define Z_STREAM_END    1
133 #define Z_NEED_DICT     2
134 #define Z_ERRNO        (-1)
135 #define Z_STREAM_ERROR (-2)
136 #define Z_DATA_ERROR   (-3)
137 #define Z_MEM_ERROR    (-4)
138 #define Z_BUF_ERROR    (-5)
139 #define Z_VERSION_ERROR (-6)
140 /* Return codes for the compression/decompression functions. Negative
141  * values are errors, positive values are used for special but normal events.
142  */
143 
144 #define Z_NO_COMPRESSION         0
145 #define Z_BEST_SPEED             1
146 #define Z_BEST_COMPRESSION       9
147 #define Z_DEFAULT_COMPRESSION  (-1)
148 /* compression levels */
149 
150 #define Z_FILTERED            1
151 #define Z_HUFFMAN_ONLY        2
152 #define Z_DEFAULT_STRATEGY    0
153 /* compression strategy; see deflateInit2() below for details */
154 
155 #define Z_BINARY   0
156 #define Z_ASCII    1
157 #define Z_UNKNOWN  2
158 /* Possible values of the data_type field */
159 
160 #define Z_DEFLATED   8
161 /* The deflate compression method (the only one supported in this version) */
162 
163 #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
164 
165                         /* basic functions */
166 
167 ZEXTERN const char * ZEXPORT zlib_zlibVersion OF((void));
168 /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
169    If the first character differs, the library code actually used is
170    not compatible with the zlib.h header file used by the application.
171    This check is automatically made by deflateInit and inflateInit.
172  */
173 
174 ZEXTERN int ZEXPORT zlib_deflate_workspacesize OF((void));
175 /*
176    Returns the number of bytes that needs to be allocated for a per-
177    stream workspace.  A pointer to this number of bytes should be
178    returned in stream->workspace before calling zlib_deflateInit().
179 */
180 
181 /*
182 ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
183 
184      Initializes the internal stream state for compression. The fields
185    zalloc, zfree and opaque must be initialized before by the caller.
186    If zalloc and zfree are set to Z_NULL, deflateInit updates them to
187    use default allocation functions.
188 
189      The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
190    1 gives best speed, 9 gives best compression, 0 gives no compression at
191    all (the input data is simply copied a block at a time).
192    Z_DEFAULT_COMPRESSION requests a default compromise between speed and
193    compression (currently equivalent to level 6).
194 
195      deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
196    enough memory, Z_STREAM_ERROR if level is not a valid compression level,
197    Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
198    with the version assumed by the caller (ZLIB_VERSION).
199    msg is set to null if there is no error message.  deflateInit does not
200    perform any compression: this will be done by deflate().
201 */
202 
203 
204 ZEXTERN int ZEXPORT zlib_deflate OF((z_streamp strm, int flush));
205 /*
206     deflate compresses as much data as possible, and stops when the input
207   buffer becomes empty or the output buffer becomes full. It may introduce some
208   output latency (reading input without producing any output) except when
209   forced to flush.
210 
211     The detailed semantics are as follows. deflate performs one or both of the
212   following actions:
213 
214   - Compress more input starting at next_in and update next_in and avail_in
215     accordingly. If not all input can be processed (because there is not
216     enough room in the output buffer), next_in and avail_in are updated and
217     processing will resume at this point for the next call of deflate().
218 
219   - Provide more output starting at next_out and update next_out and avail_out
220     accordingly. This action is forced if the parameter flush is non zero.
221     Forcing flush frequently degrades the compression ratio, so this parameter
222     should be set only when necessary (in interactive applications).
223     Some output may be provided even if flush is not set.
224 
225   Before the call of deflate(), the application should ensure that at least
226   one of the actions is possible, by providing more input and/or consuming
227   more output, and updating avail_in or avail_out accordingly; avail_out
228   should never be zero before the call. The application can consume the
229   compressed output when it wants, for example when the output buffer is full
230   (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
231   and with zero avail_out, it must be called again after making room in the
232   output buffer because there might be more output pending.
233 
234     If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
235   flushed to the output buffer and the output is aligned on a byte boundary, so
236   that the decompressor can get all input data available so far. (In particular
237   avail_in is zero after the call if enough output space has been provided
238   before the call.)  Flushing may degrade compression for some compression
239   algorithms and so it should be used only when necessary.
240 
241     If flush is set to Z_FULL_FLUSH, all output is flushed as with
242   Z_SYNC_FLUSH, and the compression state is reset so that decompression can
243   restart from this point if previous compressed data has been damaged or if
244   random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
245   the compression.
246 
247     If deflate returns with avail_out == 0, this function must be called again
248   with the same value of the flush parameter and more output space (updated
249   avail_out), until the flush is complete (deflate returns with non-zero
250   avail_out).
251 
252     If the parameter flush is set to Z_FINISH, pending input is processed,
253   pending output is flushed and deflate returns with Z_STREAM_END if there
254   was enough output space; if deflate returns with Z_OK, this function must be
255   called again with Z_FINISH and more output space (updated avail_out) but no
256   more input data, until it returns with Z_STREAM_END or an error. After
257   deflate has returned Z_STREAM_END, the only possible operations on the
258   stream are deflateReset or deflateEnd.
259 
260     Z_FINISH can be used immediately after deflateInit if all the compression
261   is to be done in a single step. In this case, avail_out must be at least
262   0.1% larger than avail_in plus 12 bytes.  If deflate does not return
263   Z_STREAM_END, then it must be called again as described above.
264 
265     deflate() sets strm->adler to the adler32 checksum of all input read
266   so far (that is, total_in bytes).
267 
268     deflate() may update data_type if it can make a good guess about
269   the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
270   binary. This field is only for information purposes and does not affect
271   the compression algorithm in any manner.
272 
273     deflate() returns Z_OK if some progress has been made (more input
274   processed or more output produced), Z_STREAM_END if all input has been
275   consumed and all output has been produced (only when flush is set to
276   Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
277   if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
278   (for example avail_in or avail_out was zero).
279 */
280 
281 
282 ZEXTERN int ZEXPORT zlib_deflateEnd OF((z_streamp strm));
283 /*
284      All dynamically allocated data structures for this stream are freed.
285    This function discards any unprocessed input and does not flush any
286    pending output.
287 
288      deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
289    stream state was inconsistent, Z_DATA_ERROR if the stream was freed
290    prematurely (some input or output was discarded). In the error case,
291    msg may be set but then points to a static string (which must not be
292    deallocated).
293 */
294 
295 
296 ZEXTERN int ZEXPORT zlib_inflate_workspacesize OF((void));
297 /*
298    Returns the number of bytes that needs to be allocated for a per-
299    stream workspace.  A pointer to this number of bytes should be
300    returned in stream->workspace before calling zlib_inflateInit().
301 */
302 
303 /*
304 ZEXTERN int ZEXPORT zlib_inflateInit OF((z_streamp strm));
305 
306      Initializes the internal stream state for decompression. The fields
307    next_in, avail_in, and workspace must be initialized before by
308    the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
309    value depends on the compression method), inflateInit determines the
310    compression method from the zlib header and allocates all data structures
311    accordingly; otherwise the allocation will be deferred to the first call of
312    inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
313    use default allocation functions.
314 
315      inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
316    memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
317    version assumed by the caller.  msg is set to null if there is no error
318    message. inflateInit does not perform any decompression apart from reading
319    the zlib header if present: this will be done by inflate().  (So next_in and
320    avail_in may be modified, but next_out and avail_out are unchanged.)
321 */
322 
323 
324 ZEXTERN int ZEXPORT zlib_inflate OF((z_streamp strm, int flush));
325 /*
326     inflate decompresses as much data as possible, and stops when the input
327   buffer becomes empty or the output buffer becomes full. It may some
328   introduce some output latency (reading input without producing any output)
329   except when forced to flush.
330 
331   The detailed semantics are as follows. inflate performs one or both of the
332   following actions:
333 
334   - Decompress more input starting at next_in and update next_in and avail_in
335     accordingly. If not all input can be processed (because there is not
336     enough room in the output buffer), next_in is updated and processing
337     will resume at this point for the next call of inflate().
338 
339   - Provide more output starting at next_out and update next_out and avail_out
340     accordingly.  inflate() provides as much output as possible, until there
341     is no more input data or no more space in the output buffer (see below
342     about the flush parameter).
343 
344   Before the call of inflate(), the application should ensure that at least
345   one of the actions is possible, by providing more input and/or consuming
346   more output, and updating the next_* and avail_* values accordingly.
347   The application can consume the uncompressed output when it wants, for
348   example when the output buffer is full (avail_out == 0), or after each
349   call of inflate(). If inflate returns Z_OK and with zero avail_out, it
350   must be called again after making room in the output buffer because there
351   might be more output pending.
352 
353     If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
354   output as possible to the output buffer. The flushing behavior of inflate is
355   not specified for values of the flush parameter other than Z_SYNC_FLUSH
356   and Z_FINISH, but the current implementation actually flushes as much output
357   as possible anyway.
358 
359     inflate() should normally be called until it returns Z_STREAM_END or an
360   error. However if all decompression is to be performed in a single step
361   (a single call of inflate), the parameter flush should be set to
362   Z_FINISH. In this case all pending input is processed and all pending
363   output is flushed; avail_out must be large enough to hold all the
364   uncompressed data. (The size of the uncompressed data may have been saved
365   by the compressor for this purpose.) The next operation on this stream must
366   be inflateEnd to deallocate the decompression state. The use of Z_FINISH
367   is never required, but can be used to inform inflate that a faster routine
368   may be used for the single inflate() call.
369 
370      If a preset dictionary is needed at this point (see inflateSetDictionary
371   below), inflate sets strm-adler to the adler32 checksum of the
372   dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
373   it sets strm->adler to the adler32 checksum of all output produced
374   so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
375   an error code as described below. At the end of the stream, inflate()
376   checks that its computed adler32 checksum is equal to that saved by the
377   compressor and returns Z_STREAM_END only if the checksum is correct.
378 
379     inflate() returns Z_OK if some progress has been made (more input processed
380   or more output produced), Z_STREAM_END if the end of the compressed data has
381   been reached and all uncompressed output has been produced, Z_NEED_DICT if a
382   preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
383   corrupted (input stream not conforming to the zlib format or incorrect
384   adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
385   (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
386   enough memory, Z_BUF_ERROR if no progress is possible or if there was not
387   enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
388   case, the application may then call inflateSync to look for a good
389   compression block.
390 */
391 
392 
393 ZEXTERN int ZEXPORT zlib_inflateEnd OF((z_streamp strm));
394 /*
395      All dynamically allocated data structures for this stream are freed.
396    This function discards any unprocessed input and does not flush any
397    pending output.
398 
399      inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
400    was inconsistent. In the error case, msg may be set but then points to a
401    static string (which must not be deallocated).
402 */
403 
404                         /* Advanced functions */
405 
406 /*
407     The following functions are needed only in some special applications.
408 */
409 
410 /*
411 ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
412                                      int  level,
413                                      int  method,
414                                      int  windowBits,
415                                      int  memLevel,
416                                      int  strategy));
417 
418      This is another version of deflateInit with more compression options. The
419    fields next_in, zalloc, zfree and opaque must be initialized before by
420    the caller.
421 
422      The method parameter is the compression method. It must be Z_DEFLATED in
423    this version of the library.
424 
425      The windowBits parameter is the base two logarithm of the window size
426    (the size of the history buffer).  It should be in the range 8..15 for this
427    version of the library. Larger values of this parameter result in better
428    compression at the expense of memory usage. The default value is 15 if
429    deflateInit is used instead.
430 
431      The memLevel parameter specifies how much memory should be allocated
432    for the internal compression state. memLevel=1 uses minimum memory but
433    is slow and reduces compression ratio; memLevel=9 uses maximum memory
434    for optimal speed. The default value is 8. See zconf.h for total memory
435    usage as a function of windowBits and memLevel.
436 
437      The strategy parameter is used to tune the compression algorithm. Use the
438    value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
439    filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
440    string match).  Filtered data consists mostly of small values with a
441    somewhat random distribution. In this case, the compression algorithm is
442    tuned to compress them better. The effect of Z_FILTERED is to force more
443    Huffman coding and less string matching; it is somewhat intermediate
444    between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
445    the compression ratio but not the correctness of the compressed output even
446    if it is not set appropriately.
447 
448       deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
449    memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
450    method). msg is set to null if there is no error message.  deflateInit2 does
451    not perform any compression: this will be done by deflate().
452 */
453 
454 ZEXTERN int ZEXPORT zlib_deflateSetDictionary OF((z_streamp strm,
455 						     const Bytef *dictionary,
456 						     uInt  dictLength));
457 /*
458      Initializes the compression dictionary from the given byte sequence
459    without producing any compressed output. This function must be called
460    immediately after deflateInit, deflateInit2 or deflateReset, before any
461    call of deflate. The compressor and decompressor must use exactly the same
462    dictionary (see inflateSetDictionary).
463 
464      The dictionary should consist of strings (byte sequences) that are likely
465    to be encountered later in the data to be compressed, with the most commonly
466    used strings preferably put towards the end of the dictionary. Using a
467    dictionary is most useful when the data to be compressed is short and can be
468    predicted with good accuracy; the data can then be compressed better than
469    with the default empty dictionary.
470 
471      Depending on the size of the compression data structures selected by
472    deflateInit or deflateInit2, a part of the dictionary may in effect be
473    discarded, for example if the dictionary is larger than the window size in
474    deflate or deflate2. Thus the strings most likely to be useful should be
475    put at the end of the dictionary, not at the front.
476 
477      Upon return of this function, strm->adler is set to the Adler32 value
478    of the dictionary; the decompressor may later use this value to determine
479    which dictionary has been used by the compressor. (The Adler32 value
480    applies to the whole dictionary even if only a subset of the dictionary is
481    actually used by the compressor.)
482 
483      deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
484    parameter is invalid (such as NULL dictionary) or the stream state is
485    inconsistent (for example if deflate has already been called for this stream
486    or if the compression method is bsort). deflateSetDictionary does not
487    perform any compression: this will be done by deflate().
488 */
489 
490 ZEXTERN int ZEXPORT zlib_deflateCopy OF((z_streamp dest,
491 					    z_streamp source));
492 /*
493      Sets the destination stream as a complete copy of the source stream.
494 
495      This function can be useful when several compression strategies will be
496    tried, for example when there are several ways of pre-processing the input
497    data with a filter. The streams that will be discarded should then be freed
498    by calling deflateEnd.  Note that deflateCopy duplicates the internal
499    compression state which can be quite large, so this strategy is slow and
500    can consume lots of memory.
501 
502      deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
503    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
504    (such as zalloc being NULL). msg is left unchanged in both source and
505    destination.
506 */
507 
508 ZEXTERN int ZEXPORT zlib_deflateReset OF((z_streamp strm));
509 /*
510      This function is equivalent to deflateEnd followed by deflateInit,
511    but does not free and reallocate all the internal compression state.
512    The stream will keep the same compression level and any other attributes
513    that may have been set by deflateInit2.
514 
515       deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
516    stream state was inconsistent (such as zalloc or state being NULL).
517 */
518 
deflateBound(unsigned long s)519 static inline unsigned long deflateBound(unsigned long s)
520 {
521 	return s + ((s + 7) >> 3) + ((s + 63) >> 6) + 11;
522 }
523 
524 ZEXTERN int ZEXPORT zlib_deflateParams OF((z_streamp strm,
525 					      int level,
526 					      int strategy));
527 /*
528      Dynamically update the compression level and compression strategy.  The
529    interpretation of level and strategy is as in deflateInit2.  This can be
530    used to switch between compression and straight copy of the input data, or
531    to switch to a different kind of input data requiring a different
532    strategy. If the compression level is changed, the input available so far
533    is compressed with the old level (and may be flushed); the new level will
534    take effect only at the next call of deflate().
535 
536      Before the call of deflateParams, the stream state must be set as for
537    a call of deflate(), since the currently available input may have to
538    be compressed and flushed. In particular, strm->avail_out must be non-zero.
539 
540      deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
541    stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
542    if strm->avail_out was zero.
543 */
544 
545 /*
546 ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
547                                      int  windowBits));
548 
549      This is another version of inflateInit with an extra parameter. The
550    fields next_in, avail_in, zalloc, zfree and opaque must be initialized
551    before by the caller.
552 
553      The windowBits parameter is the base two logarithm of the maximum window
554    size (the size of the history buffer).  It should be in the range 8..15 for
555    this version of the library. The default value is 15 if inflateInit is used
556    instead. If a compressed stream with a larger window size is given as
557    input, inflate() will return with the error code Z_DATA_ERROR instead of
558    trying to allocate a larger window.
559 
560       inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
561    memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
562    memLevel). msg is set to null if there is no error message.  inflateInit2
563    does not perform any decompression apart from reading the zlib header if
564    present: this will be done by inflate(). (So next_in and avail_in may be
565    modified, but next_out and avail_out are unchanged.)
566 */
567 
568 ZEXTERN int ZEXPORT zlib_inflateSetDictionary OF((z_streamp strm,
569 						     const Bytef *dictionary,
570 						     uInt  dictLength));
571 /*
572      Initializes the decompression dictionary from the given uncompressed byte
573    sequence. This function must be called immediately after a call of inflate
574    if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
575    can be determined from the Adler32 value returned by this call of
576    inflate. The compressor and decompressor must use exactly the same
577    dictionary (see deflateSetDictionary).
578 
579      inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
580    parameter is invalid (such as NULL dictionary) or the stream state is
581    inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
582    expected one (incorrect Adler32 value). inflateSetDictionary does not
583    perform any decompression: this will be done by subsequent calls of
584    inflate().
585 */
586 
587 ZEXTERN int ZEXPORT zlib_inflateSync OF((z_streamp strm));
588 /*
589     Skips invalid compressed data until a full flush point (see above the
590   description of deflate with Z_FULL_FLUSH) can be found, or until all
591   available input is skipped. No output is provided.
592 
593     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
594   if no more input was provided, Z_DATA_ERROR if no flush point has been found,
595   or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
596   case, the application may save the current current value of total_in which
597   indicates where valid compressed data was found. In the error case, the
598   application may repeatedly call inflateSync, providing more input each time,
599   until success or end of the input data.
600 */
601 
602 ZEXTERN int ZEXPORT zlib_inflateReset OF((z_streamp strm));
603 /*
604      This function is equivalent to inflateEnd followed by inflateInit,
605    but does not free and reallocate all the internal decompression state.
606    The stream will keep attributes that may have been set by inflateInit2.
607 
608       inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
609    stream state was inconsistent (such as zalloc or state being NULL).
610 */
611 
612 extern int ZEXPORT zlib_inflateIncomp OF((z_stream *strm));
613 /*
614      This function adds the data at next_in (avail_in bytes) to the output
615    history without performing any output.  There must be no pending output,
616    and the decompressor must be expecting to see the start of a block.
617    Calling this function is equivalent to decompressing a stored block
618    containing the data at next_in (except that the data is not output).
619 */
620 
621                         /* various hacks, don't look :) */
622 
623 /* deflateInit and inflateInit are macros to allow checking the zlib version
624  * and the compiler's view of z_stream:
625  */
626 ZEXTERN int ZEXPORT zlib_deflateInit_ OF((z_streamp strm, int level,
627                                      const char *version, int stream_size));
628 ZEXTERN int ZEXPORT zlib_inflateInit_ OF((z_streamp strm,
629                                      const char *version, int stream_size));
630 ZEXTERN int ZEXPORT zlib_deflateInit2_ OF((z_streamp strm, int  level, int  method,
631                                       int windowBits, int memLevel,
632                                       int strategy, const char *version,
633                                       int stream_size));
634 ZEXTERN int ZEXPORT zlib_inflateInit2_ OF((z_streamp strm, int  windowBits,
635                                       const char *version, int stream_size));
636 #define zlib_deflateInit(strm, level) \
637         zlib_deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
638 #define zlib_inflateInit(strm) \
639         zlib_inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
640 #define zlib_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
641         zlib_deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
642                       (strategy), ZLIB_VERSION, sizeof(z_stream))
643 #define zlib_inflateInit2(strm, windowBits) \
644         zlib_inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
645 
646 
647 #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
648     struct internal_state {int dummy;}; /* hack for buggy compilers */
649 #endif
650 
651 ZEXTERN const char   * ZEXPORT zlib_zError           OF((int err));
652 ZEXTERN int            ZEXPORT zlib_inflateSyncPoint OF((z_streamp z));
653 ZEXTERN const uLongf * ZEXPORT zlib_get_crc_table    OF((void));
654 
655 #ifdef __cplusplus
656 }
657 #endif
658 
659 #endif /* _ZLIB_H */
660