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