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