xref: /titanic_51/usr/src/cmd/cmd-inet/usr.bin/pppdump/zlib.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*	$Id: zlib.h,v 1.1 1999/03/23 03:21:58 paulus Exp $	*/
2*7c478bd9Sstevel@tonic-gate 
3*7c478bd9Sstevel@tonic-gate /*
4*7c478bd9Sstevel@tonic-gate  * This file is derived from zlib.h and zconf.h from the zlib-0.95
5*7c478bd9Sstevel@tonic-gate  * distribution by Jean-loup Gailly and Mark Adler, with some additions
6*7c478bd9Sstevel@tonic-gate  * by Paul Mackerras to aid in implementing Deflate compression and
7*7c478bd9Sstevel@tonic-gate  * decompression for PPP packets.
8*7c478bd9Sstevel@tonic-gate  */
9*7c478bd9Sstevel@tonic-gate 
10*7c478bd9Sstevel@tonic-gate /* zlib.h -- interface of the 'zlib' general purpose compression library
11*7c478bd9Sstevel@tonic-gate   version 0.95, Aug 16th, 1995.
12*7c478bd9Sstevel@tonic-gate 
13*7c478bd9Sstevel@tonic-gate   Copyright (C) 1995 Jean-loup Gailly and Mark Adler
14*7c478bd9Sstevel@tonic-gate 
15*7c478bd9Sstevel@tonic-gate   This software is provided 'as-is', without any express or implied
16*7c478bd9Sstevel@tonic-gate   warranty.  In no event will the authors be held liable for any damages
17*7c478bd9Sstevel@tonic-gate   arising from the use of this software.
18*7c478bd9Sstevel@tonic-gate 
19*7c478bd9Sstevel@tonic-gate   Permission is granted to anyone to use this software for any purpose,
20*7c478bd9Sstevel@tonic-gate   including commercial applications, and to alter it and redistribute it
21*7c478bd9Sstevel@tonic-gate   freely, subject to the following restrictions:
22*7c478bd9Sstevel@tonic-gate 
23*7c478bd9Sstevel@tonic-gate   1. The origin of this software must not be misrepresented; you must not
24*7c478bd9Sstevel@tonic-gate      claim that you wrote the original software. If you use this software
25*7c478bd9Sstevel@tonic-gate      in a product, an acknowledgment in the product documentation would be
26*7c478bd9Sstevel@tonic-gate      appreciated but is not required.
27*7c478bd9Sstevel@tonic-gate   2. Altered source versions must be plainly marked as such, and must not be
28*7c478bd9Sstevel@tonic-gate      misrepresented as being the original software.
29*7c478bd9Sstevel@tonic-gate   3. This notice may not be removed or altered from any source distribution.
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate   Jean-loup Gailly        Mark Adler
32*7c478bd9Sstevel@tonic-gate   gzip@prep.ai.mit.edu    madler@alumni.caltech.edu
33*7c478bd9Sstevel@tonic-gate  */
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #ifndef _ZLIB_H
36*7c478bd9Sstevel@tonic-gate #define _ZLIB_H
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate /* #include "zconf.h" */	/* included directly here */
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate /* zconf.h -- configuration of the zlib compression library
41*7c478bd9Sstevel@tonic-gate  * Copyright (C) 1995 Jean-loup Gailly.
42*7c478bd9Sstevel@tonic-gate  * For conditions of distribution and use, see copyright notice in zlib.h
43*7c478bd9Sstevel@tonic-gate  */
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate /* From: zconf.h,v 1.12 1995/05/03 17:27:12 jloup Exp */
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate /*
48*7c478bd9Sstevel@tonic-gate      The library does not install any signal handler. It is recommended to
49*7c478bd9Sstevel@tonic-gate   add at least a handler for SIGSEGV when decompressing; the library checks
50*7c478bd9Sstevel@tonic-gate   the consistency of the input data whenever possible but may go nuts
51*7c478bd9Sstevel@tonic-gate   for some forms of corrupted input.
52*7c478bd9Sstevel@tonic-gate  */
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate /*
55*7c478bd9Sstevel@tonic-gate  * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
56*7c478bd9Sstevel@tonic-gate  * than 64k bytes at a time (needed on systems with 16-bit int).
57*7c478bd9Sstevel@tonic-gate  * Compile with -DUNALIGNED_OK if it is OK to access shorts or ints
58*7c478bd9Sstevel@tonic-gate  * at addresses which are not a multiple of their size.
59*7c478bd9Sstevel@tonic-gate  * Under DOS, -DFAR=far or -DFAR=__far may be needed.
60*7c478bd9Sstevel@tonic-gate  */
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate #ifndef STDC
63*7c478bd9Sstevel@tonic-gate #  if defined(MSDOS) || defined(__STDC__) || defined(__cplusplus)
64*7c478bd9Sstevel@tonic-gate #    define STDC
65*7c478bd9Sstevel@tonic-gate #  endif
66*7c478bd9Sstevel@tonic-gate #endif
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate #ifdef	__MWERKS__ /* Metrowerks CodeWarrior declares fileno() in unix.h */
69*7c478bd9Sstevel@tonic-gate #  include <unix.h>
70*7c478bd9Sstevel@tonic-gate #endif
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate /* Maximum value for memLevel in deflateInit2 */
73*7c478bd9Sstevel@tonic-gate #ifndef MAX_MEM_LEVEL
74*7c478bd9Sstevel@tonic-gate #  ifdef MAXSEG_64K
75*7c478bd9Sstevel@tonic-gate #    define MAX_MEM_LEVEL 8
76*7c478bd9Sstevel@tonic-gate #  else
77*7c478bd9Sstevel@tonic-gate #    define MAX_MEM_LEVEL 9
78*7c478bd9Sstevel@tonic-gate #  endif
79*7c478bd9Sstevel@tonic-gate #endif
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate #ifndef FAR
82*7c478bd9Sstevel@tonic-gate #  define FAR
83*7c478bd9Sstevel@tonic-gate #endif
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate /* Maximum value for windowBits in deflateInit2 and inflateInit2 */
86*7c478bd9Sstevel@tonic-gate #ifndef MAX_WBITS
87*7c478bd9Sstevel@tonic-gate #  define MAX_WBITS   15 /* 32K LZ77 window */
88*7c478bd9Sstevel@tonic-gate #endif
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate /* The memory requirements for deflate are (in bytes):
91*7c478bd9Sstevel@tonic-gate             1 << (windowBits+2)   +  1 << (memLevel+9)
92*7c478bd9Sstevel@tonic-gate  that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
93*7c478bd9Sstevel@tonic-gate  plus a few kilobytes for small objects. For example, if you want to reduce
94*7c478bd9Sstevel@tonic-gate  the default memory requirements from 256K to 128K, compile with
95*7c478bd9Sstevel@tonic-gate      make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
96*7c478bd9Sstevel@tonic-gate  Of course this will generally degrade compression (there's no free lunch).
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate    The memory requirements for inflate are (in bytes) 1 << windowBits
99*7c478bd9Sstevel@tonic-gate  that is, 32K for windowBits=15 (default value) plus a few kilobytes
100*7c478bd9Sstevel@tonic-gate  for small objects.
101*7c478bd9Sstevel@tonic-gate */
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate                         /* Type declarations */
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate #ifndef OF /* function prototypes */
106*7c478bd9Sstevel@tonic-gate #  ifdef STDC
107*7c478bd9Sstevel@tonic-gate #    define OF(args)  args
108*7c478bd9Sstevel@tonic-gate #  else
109*7c478bd9Sstevel@tonic-gate #    define OF(args)  ()
110*7c478bd9Sstevel@tonic-gate #  endif
111*7c478bd9Sstevel@tonic-gate #endif
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate typedef unsigned char  Byte;  /* 8 bits */
114*7c478bd9Sstevel@tonic-gate typedef unsigned int   uInt;  /* 16 bits or more */
115*7c478bd9Sstevel@tonic-gate typedef unsigned long  uLong; /* 32 bits or more */
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate typedef Byte FAR Bytef;
118*7c478bd9Sstevel@tonic-gate typedef char FAR charf;
119*7c478bd9Sstevel@tonic-gate typedef int FAR intf;
120*7c478bd9Sstevel@tonic-gate typedef uInt FAR uIntf;
121*7c478bd9Sstevel@tonic-gate typedef uLong FAR uLongf;
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate #ifdef STDC
124*7c478bd9Sstevel@tonic-gate    typedef void FAR *voidpf;
125*7c478bd9Sstevel@tonic-gate    typedef void     *voidp;
126*7c478bd9Sstevel@tonic-gate #else
127*7c478bd9Sstevel@tonic-gate    typedef Byte FAR *voidpf;
128*7c478bd9Sstevel@tonic-gate    typedef Byte     *voidp;
129*7c478bd9Sstevel@tonic-gate #endif
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate /* end of original zconf.h */
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate #define ZLIB_VERSION "0.95P"
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate /*
136*7c478bd9Sstevel@tonic-gate      The 'zlib' compression library provides in-memory compression and
137*7c478bd9Sstevel@tonic-gate   decompression functions, including integrity checks of the uncompressed
138*7c478bd9Sstevel@tonic-gate   data.  This version of the library supports only one compression method
139*7c478bd9Sstevel@tonic-gate   (deflation) but other algorithms may be added later and will have the same
140*7c478bd9Sstevel@tonic-gate   stream interface.
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate      For compression the application must provide the output buffer and
143*7c478bd9Sstevel@tonic-gate   may optionally provide the input buffer for optimization. For decompression,
144*7c478bd9Sstevel@tonic-gate   the application must provide the input buffer and may optionally provide
145*7c478bd9Sstevel@tonic-gate   the output buffer for optimization.
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate      Compression can be done in a single step if the buffers are large
148*7c478bd9Sstevel@tonic-gate   enough (for example if an input file is mmap'ed), or can be done by
149*7c478bd9Sstevel@tonic-gate   repeated calls of the compression function.  In the latter case, the
150*7c478bd9Sstevel@tonic-gate   application must provide more input and/or consume the output
151*7c478bd9Sstevel@tonic-gate   (providing more output space) before each call.
152*7c478bd9Sstevel@tonic-gate */
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
155*7c478bd9Sstevel@tonic-gate typedef void   (*free_func)  OF((voidpf opaque, voidpf address, uInt nbytes));
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate struct internal_state;
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate typedef struct z_stream_s {
160*7c478bd9Sstevel@tonic-gate     Bytef    *next_in;  /* next input byte */
161*7c478bd9Sstevel@tonic-gate     uInt     avail_in;  /* number of bytes available at next_in */
162*7c478bd9Sstevel@tonic-gate     uLong    total_in;  /* total nb of input bytes read so far */
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate     Bytef    *next_out; /* next output byte should be put there */
165*7c478bd9Sstevel@tonic-gate     uInt     avail_out; /* remaining free space at next_out */
166*7c478bd9Sstevel@tonic-gate     uLong    total_out; /* total nb of bytes output so far */
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate     char     *msg;      /* last error message, NULL if no error */
169*7c478bd9Sstevel@tonic-gate     struct internal_state FAR *state; /* not visible by applications */
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate     alloc_func zalloc;  /* used to allocate the internal state */
172*7c478bd9Sstevel@tonic-gate     free_func  zfree;   /* used to free the internal state */
173*7c478bd9Sstevel@tonic-gate     voidp      opaque;  /* private data object passed to zalloc and zfree */
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate     Byte     data_type; /* best guess about the data type: ascii or binary */
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate } z_stream;
178*7c478bd9Sstevel@tonic-gate 
179*7c478bd9Sstevel@tonic-gate /*
180*7c478bd9Sstevel@tonic-gate    The application must update next_in and avail_in when avail_in has
181*7c478bd9Sstevel@tonic-gate    dropped to zero. It must update next_out and avail_out when avail_out
182*7c478bd9Sstevel@tonic-gate    has dropped to zero. The application must initialize zalloc, zfree and
183*7c478bd9Sstevel@tonic-gate    opaque before calling the init function. All other fields are set by the
184*7c478bd9Sstevel@tonic-gate    compression library and must not be updated by the application.
185*7c478bd9Sstevel@tonic-gate 
186*7c478bd9Sstevel@tonic-gate    The opaque value provided by the application will be passed as the first
187*7c478bd9Sstevel@tonic-gate    parameter for calls of zalloc and zfree. This can be useful for custom
188*7c478bd9Sstevel@tonic-gate    memory management. The compression library attaches no meaning to the
189*7c478bd9Sstevel@tonic-gate    opaque value.
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate    zalloc must return Z_NULL if there is not enough memory for the object.
192*7c478bd9Sstevel@tonic-gate    On 16-bit systems, the functions zalloc and zfree must be able to allocate
193*7c478bd9Sstevel@tonic-gate    exactly 65536 bytes, but will not be required to allocate more than this
194*7c478bd9Sstevel@tonic-gate    if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
195*7c478bd9Sstevel@tonic-gate    pointers returned by zalloc for objects of exactly 65536 bytes *must*
196*7c478bd9Sstevel@tonic-gate    have their offset normalized to zero. The default allocation function
197*7c478bd9Sstevel@tonic-gate    provided by this library ensures this (see zutil.c). To reduce memory
198*7c478bd9Sstevel@tonic-gate    requirements and avoid any allocation of 64K objects, at the expense of
199*7c478bd9Sstevel@tonic-gate    compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
200*7c478bd9Sstevel@tonic-gate 
201*7c478bd9Sstevel@tonic-gate    The fields total_in and total_out can be used for statistics or
202*7c478bd9Sstevel@tonic-gate    progress reports. After compression, total_in holds the total size of
203*7c478bd9Sstevel@tonic-gate    the uncompressed data and may be saved for use in the decompressor
204*7c478bd9Sstevel@tonic-gate    (particularly if the decompressor wants to decompress everything in
205*7c478bd9Sstevel@tonic-gate    a single step).
206*7c478bd9Sstevel@tonic-gate */
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate                         /* constants */
209*7c478bd9Sstevel@tonic-gate 
210*7c478bd9Sstevel@tonic-gate #define Z_NO_FLUSH      0
211*7c478bd9Sstevel@tonic-gate #define Z_PARTIAL_FLUSH 1
212*7c478bd9Sstevel@tonic-gate #define Z_FULL_FLUSH    2
213*7c478bd9Sstevel@tonic-gate #define Z_SYNC_FLUSH    3 /* experimental: partial_flush + byte align */
214*7c478bd9Sstevel@tonic-gate #define Z_FINISH        4
215*7c478bd9Sstevel@tonic-gate #define Z_PACKET_FLUSH	5
216*7c478bd9Sstevel@tonic-gate /* See deflate() below for the usage of these constants */
217*7c478bd9Sstevel@tonic-gate 
218*7c478bd9Sstevel@tonic-gate #define Z_OK            0
219*7c478bd9Sstevel@tonic-gate #define Z_STREAM_END    1
220*7c478bd9Sstevel@tonic-gate #define Z_ERRNO        (-1)
221*7c478bd9Sstevel@tonic-gate #define Z_STREAM_ERROR (-2)
222*7c478bd9Sstevel@tonic-gate #define Z_DATA_ERROR   (-3)
223*7c478bd9Sstevel@tonic-gate #define Z_MEM_ERROR    (-4)
224*7c478bd9Sstevel@tonic-gate #define Z_BUF_ERROR    (-5)
225*7c478bd9Sstevel@tonic-gate /* error codes for the compression/decompression functions */
226*7c478bd9Sstevel@tonic-gate 
227*7c478bd9Sstevel@tonic-gate #define Z_BEST_SPEED             1
228*7c478bd9Sstevel@tonic-gate #define Z_BEST_COMPRESSION       9
229*7c478bd9Sstevel@tonic-gate #define Z_DEFAULT_COMPRESSION  (-1)
230*7c478bd9Sstevel@tonic-gate /* compression levels */
231*7c478bd9Sstevel@tonic-gate 
232*7c478bd9Sstevel@tonic-gate #define Z_FILTERED            1
233*7c478bd9Sstevel@tonic-gate #define Z_HUFFMAN_ONLY        2
234*7c478bd9Sstevel@tonic-gate #define Z_DEFAULT_STRATEGY    0
235*7c478bd9Sstevel@tonic-gate 
236*7c478bd9Sstevel@tonic-gate #define Z_BINARY   0
237*7c478bd9Sstevel@tonic-gate #define Z_ASCII    1
238*7c478bd9Sstevel@tonic-gate #define Z_UNKNOWN  2
239*7c478bd9Sstevel@tonic-gate /* Used to set the data_type field */
240*7c478bd9Sstevel@tonic-gate 
241*7c478bd9Sstevel@tonic-gate #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
242*7c478bd9Sstevel@tonic-gate 
243*7c478bd9Sstevel@tonic-gate extern char *zlib_version;
244*7c478bd9Sstevel@tonic-gate /* The application can compare zlib_version and ZLIB_VERSION for consistency.
245*7c478bd9Sstevel@tonic-gate    If the first character differs, the library code actually used is
246*7c478bd9Sstevel@tonic-gate    not compatible with the zlib.h header file used by the application.
247*7c478bd9Sstevel@tonic-gate  */
248*7c478bd9Sstevel@tonic-gate 
249*7c478bd9Sstevel@tonic-gate                         /* basic functions */
250*7c478bd9Sstevel@tonic-gate 
251*7c478bd9Sstevel@tonic-gate extern int deflateInit OF((z_stream *strm, int level));
252*7c478bd9Sstevel@tonic-gate /*
253*7c478bd9Sstevel@tonic-gate      Initializes the internal stream state for compression. The fields
254*7c478bd9Sstevel@tonic-gate    zalloc, zfree and opaque must be initialized before by the caller.
255*7c478bd9Sstevel@tonic-gate    If zalloc and zfree are set to Z_NULL, deflateInit updates them to
256*7c478bd9Sstevel@tonic-gate    use default allocation functions.
257*7c478bd9Sstevel@tonic-gate 
258*7c478bd9Sstevel@tonic-gate      The compression level must be Z_DEFAULT_COMPRESSION, or between 1 and 9:
259*7c478bd9Sstevel@tonic-gate    1 gives best speed, 9 gives best compression. Z_DEFAULT_COMPRESSION requests
260*7c478bd9Sstevel@tonic-gate    a default compromise between speed and compression (currently equivalent
261*7c478bd9Sstevel@tonic-gate    to level 6).
262*7c478bd9Sstevel@tonic-gate 
263*7c478bd9Sstevel@tonic-gate      deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
264*7c478bd9Sstevel@tonic-gate    enough memory, Z_STREAM_ERROR if level is not a valid compression level.
265*7c478bd9Sstevel@tonic-gate    msg is set to null if there is no error message.  deflateInit does not
266*7c478bd9Sstevel@tonic-gate    perform any compression: this will be done by deflate().
267*7c478bd9Sstevel@tonic-gate */
268*7c478bd9Sstevel@tonic-gate 
269*7c478bd9Sstevel@tonic-gate 
270*7c478bd9Sstevel@tonic-gate extern int deflate OF((z_stream *strm, int flush));
271*7c478bd9Sstevel@tonic-gate /*
272*7c478bd9Sstevel@tonic-gate   Performs one or both of the following actions:
273*7c478bd9Sstevel@tonic-gate 
274*7c478bd9Sstevel@tonic-gate   - Compress more input starting at next_in and update next_in and avail_in
275*7c478bd9Sstevel@tonic-gate     accordingly. If not all input can be processed (because there is not
276*7c478bd9Sstevel@tonic-gate     enough room in the output buffer), next_in and avail_in are updated and
277*7c478bd9Sstevel@tonic-gate     processing will resume at this point for the next call of deflate().
278*7c478bd9Sstevel@tonic-gate 
279*7c478bd9Sstevel@tonic-gate   - Provide more output starting at next_out and update next_out and avail_out
280*7c478bd9Sstevel@tonic-gate     accordingly. This action is forced if the parameter flush is non zero.
281*7c478bd9Sstevel@tonic-gate     Forcing flush frequently degrades the compression ratio, so this parameter
282*7c478bd9Sstevel@tonic-gate     should be set only when necessary (in interactive applications).
283*7c478bd9Sstevel@tonic-gate     Some output may be provided even if flush is not set.
284*7c478bd9Sstevel@tonic-gate 
285*7c478bd9Sstevel@tonic-gate   Before the call of deflate(), the application should ensure that at least
286*7c478bd9Sstevel@tonic-gate   one of the actions is possible, by providing more input and/or consuming
287*7c478bd9Sstevel@tonic-gate   more output, and updating avail_in or avail_out accordingly; avail_out
288*7c478bd9Sstevel@tonic-gate   should never be zero before the call. The application can consume the
289*7c478bd9Sstevel@tonic-gate   compressed output when it wants, for example when the output buffer is full
290*7c478bd9Sstevel@tonic-gate   (avail_out == 0), or after each call of deflate().
291*7c478bd9Sstevel@tonic-gate 
292*7c478bd9Sstevel@tonic-gate     If the parameter flush is set to Z_PARTIAL_FLUSH, the current compression
293*7c478bd9Sstevel@tonic-gate   block is terminated and flushed to the output buffer so that the
294*7c478bd9Sstevel@tonic-gate   decompressor can get all input data available so far. For method 9, a future
295*7c478bd9Sstevel@tonic-gate   variant on method 8, the current block will be flushed but not terminated.
296*7c478bd9Sstevel@tonic-gate   If flush is set to Z_FULL_FLUSH, the compression block is terminated, a
297*7c478bd9Sstevel@tonic-gate   special marker is output and the compression dictionary is discarded; this
298*7c478bd9Sstevel@tonic-gate   is useful to allow the decompressor to synchronize if one compressed block
299*7c478bd9Sstevel@tonic-gate   has been damaged (see inflateSync below).  Flushing degrades compression and
300*7c478bd9Sstevel@tonic-gate   so should be used only when necessary.  Using Z_FULL_FLUSH too often can
301*7c478bd9Sstevel@tonic-gate   seriously degrade the compression. If deflate returns with avail_out == 0,
302*7c478bd9Sstevel@tonic-gate   this function must be called again with the same value of the flush
303*7c478bd9Sstevel@tonic-gate   parameter and more output space (updated avail_out), until the flush is
304*7c478bd9Sstevel@tonic-gate   complete (deflate returns with non-zero avail_out).
305*7c478bd9Sstevel@tonic-gate 
306*7c478bd9Sstevel@tonic-gate     If the parameter flush is set to Z_PACKET_FLUSH, the compression
307*7c478bd9Sstevel@tonic-gate   block is terminated, and a zero-length stored block is output,
308*7c478bd9Sstevel@tonic-gate   omitting the length bytes (the effect of this is that the 3-bit type
309*7c478bd9Sstevel@tonic-gate   code 000 for a stored block is output, and the output is then
310*7c478bd9Sstevel@tonic-gate   byte-aligned).  This is designed for use at the end of a PPP packet.
311*7c478bd9Sstevel@tonic-gate   In addition, if the current compression block contains all the data
312*7c478bd9Sstevel@tonic-gate   since the last Z_PACKET_FLUSH, it is never output as a stored block.
313*7c478bd9Sstevel@tonic-gate   If the current compression block output as a static or dynamic block
314*7c478bd9Sstevel@tonic-gate   would not be at least `minCompression' bytes smaller than the
315*7c478bd9Sstevel@tonic-gate   original data, then nothing is output for that block.  (The type
316*7c478bd9Sstevel@tonic-gate   code for the zero-length stored block is still output, resulting in
317*7c478bd9Sstevel@tonic-gate   a single zero byte being output for the whole packet.)
318*7c478bd9Sstevel@tonic-gate   `MinCompression' is a parameter to deflateInit2, or 0 if deflateInit
319*7c478bd9Sstevel@tonic-gate   is used.
320*7c478bd9Sstevel@tonic-gate 
321*7c478bd9Sstevel@tonic-gate     If the parameter flush is set to Z_FINISH, all pending input is processed,
322*7c478bd9Sstevel@tonic-gate   all pending output is flushed and deflate returns with Z_STREAM_END if there
323*7c478bd9Sstevel@tonic-gate   was enough output space; if deflate returns with Z_OK, this function must be
324*7c478bd9Sstevel@tonic-gate   called again with Z_FINISH and more output space (updated avail_out) but no
325*7c478bd9Sstevel@tonic-gate   more input data, until it returns with Z_STREAM_END or an error. After
326*7c478bd9Sstevel@tonic-gate   deflate has returned Z_STREAM_END, the only possible operations on the
327*7c478bd9Sstevel@tonic-gate   stream are deflateReset or deflateEnd.
328*7c478bd9Sstevel@tonic-gate 
329*7c478bd9Sstevel@tonic-gate     Z_FINISH can be used immediately after deflateInit if all the compression
330*7c478bd9Sstevel@tonic-gate   is to be done in a single step. In this case, avail_out must be at least
331*7c478bd9Sstevel@tonic-gate   0.1% larger than avail_in plus 12 bytes.  If deflate does not return
332*7c478bd9Sstevel@tonic-gate   Z_STREAM_END, then it must be called again as described above.
333*7c478bd9Sstevel@tonic-gate 
334*7c478bd9Sstevel@tonic-gate     deflate() may update data_type if it can make a good guess about
335*7c478bd9Sstevel@tonic-gate   the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
336*7c478bd9Sstevel@tonic-gate   binary. This field is only for information purposes and does not affect
337*7c478bd9Sstevel@tonic-gate   the compression algorithm in any manner.
338*7c478bd9Sstevel@tonic-gate 
339*7c478bd9Sstevel@tonic-gate     deflate() returns Z_OK if some progress has been made (more input
340*7c478bd9Sstevel@tonic-gate   processed or more output produced), Z_STREAM_END if all input has been
341*7c478bd9Sstevel@tonic-gate   consumed and all output has been produced (only when flush is set to
342*7c478bd9Sstevel@tonic-gate   Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
343*7c478bd9Sstevel@tonic-gate   if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible.
344*7c478bd9Sstevel@tonic-gate */
345*7c478bd9Sstevel@tonic-gate 
346*7c478bd9Sstevel@tonic-gate 
347*7c478bd9Sstevel@tonic-gate extern int deflateEnd OF((z_stream *strm));
348*7c478bd9Sstevel@tonic-gate /*
349*7c478bd9Sstevel@tonic-gate      All dynamically allocated data structures for this stream are freed.
350*7c478bd9Sstevel@tonic-gate    This function discards any unprocessed input and does not flush any
351*7c478bd9Sstevel@tonic-gate    pending output.
352*7c478bd9Sstevel@tonic-gate 
353*7c478bd9Sstevel@tonic-gate      deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
354*7c478bd9Sstevel@tonic-gate    stream state was inconsistent. In the error case, msg may be set
355*7c478bd9Sstevel@tonic-gate    but then points to a static string (which must not be deallocated).
356*7c478bd9Sstevel@tonic-gate */
357*7c478bd9Sstevel@tonic-gate 
358*7c478bd9Sstevel@tonic-gate 
359*7c478bd9Sstevel@tonic-gate extern int inflateInit OF((z_stream *strm));
360*7c478bd9Sstevel@tonic-gate /*
361*7c478bd9Sstevel@tonic-gate      Initializes the internal stream state for decompression. The fields
362*7c478bd9Sstevel@tonic-gate    zalloc and zfree must be initialized before by the caller.  If zalloc and
363*7c478bd9Sstevel@tonic-gate    zfree are set to Z_NULL, inflateInit updates them to use default allocation
364*7c478bd9Sstevel@tonic-gate    functions.
365*7c478bd9Sstevel@tonic-gate 
366*7c478bd9Sstevel@tonic-gate      inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
367*7c478bd9Sstevel@tonic-gate    enough memory.  msg is set to null if there is no error message.
368*7c478bd9Sstevel@tonic-gate    inflateInit does not perform any decompression: this will be done by
369*7c478bd9Sstevel@tonic-gate    inflate().
370*7c478bd9Sstevel@tonic-gate */
371*7c478bd9Sstevel@tonic-gate 
372*7c478bd9Sstevel@tonic-gate 
373*7c478bd9Sstevel@tonic-gate extern int inflate OF((z_stream *strm, int flush));
374*7c478bd9Sstevel@tonic-gate /*
375*7c478bd9Sstevel@tonic-gate   Performs one or both of the following actions:
376*7c478bd9Sstevel@tonic-gate 
377*7c478bd9Sstevel@tonic-gate   - Decompress more input starting at next_in and update next_in and avail_in
378*7c478bd9Sstevel@tonic-gate     accordingly. If not all input can be processed (because there is not
379*7c478bd9Sstevel@tonic-gate     enough room in the output buffer), next_in is updated and processing
380*7c478bd9Sstevel@tonic-gate     will resume at this point for the next call of inflate().
381*7c478bd9Sstevel@tonic-gate 
382*7c478bd9Sstevel@tonic-gate   - Provide more output starting at next_out and update next_out and avail_out
383*7c478bd9Sstevel@tonic-gate     accordingly.  inflate() always provides as much output as possible
384*7c478bd9Sstevel@tonic-gate     (until there is no more input data or no more space in the output buffer).
385*7c478bd9Sstevel@tonic-gate 
386*7c478bd9Sstevel@tonic-gate   Before the call of inflate(), the application should ensure that at least
387*7c478bd9Sstevel@tonic-gate   one of the actions is possible, by providing more input and/or consuming
388*7c478bd9Sstevel@tonic-gate   more output, and updating the next_* and avail_* values accordingly.
389*7c478bd9Sstevel@tonic-gate   The application can consume the uncompressed output when it wants, for
390*7c478bd9Sstevel@tonic-gate   example when the output buffer is full (avail_out == 0), or after each
391*7c478bd9Sstevel@tonic-gate   call of inflate().
392*7c478bd9Sstevel@tonic-gate 
393*7c478bd9Sstevel@tonic-gate     If the parameter flush is set to Z_PARTIAL_FLUSH or Z_PACKET_FLUSH,
394*7c478bd9Sstevel@tonic-gate   inflate flushes as much output as possible to the output buffer. The
395*7c478bd9Sstevel@tonic-gate   flushing behavior of inflate is not specified for values of the flush
396*7c478bd9Sstevel@tonic-gate   parameter other than Z_PARTIAL_FLUSH, Z_PACKET_FLUSH or Z_FINISH, but the
397*7c478bd9Sstevel@tonic-gate   current implementation actually flushes as much output as possible
398*7c478bd9Sstevel@tonic-gate   anyway.  For Z_PACKET_FLUSH, inflate checks that once all the input data
399*7c478bd9Sstevel@tonic-gate   has been consumed, it is expecting to see the length field of a stored
400*7c478bd9Sstevel@tonic-gate   block; if not, it returns Z_DATA_ERROR.
401*7c478bd9Sstevel@tonic-gate 
402*7c478bd9Sstevel@tonic-gate     inflate() should normally be called until it returns Z_STREAM_END or an
403*7c478bd9Sstevel@tonic-gate   error. However if all decompression is to be performed in a single step
404*7c478bd9Sstevel@tonic-gate   (a single call of inflate), the parameter flush should be set to
405*7c478bd9Sstevel@tonic-gate   Z_FINISH. In this case all pending input is processed and all pending
406*7c478bd9Sstevel@tonic-gate   output is flushed; avail_out must be large enough to hold all the
407*7c478bd9Sstevel@tonic-gate   uncompressed data. (The size of the uncompressed data may have been saved
408*7c478bd9Sstevel@tonic-gate   by the compressor for this purpose.) The next operation on this stream must
409*7c478bd9Sstevel@tonic-gate   be inflateEnd to deallocate the decompression state. The use of Z_FINISH
410*7c478bd9Sstevel@tonic-gate   is never required, but can be used to inform inflate that a faster routine
411*7c478bd9Sstevel@tonic-gate   may be used for the single inflate() call.
412*7c478bd9Sstevel@tonic-gate 
413*7c478bd9Sstevel@tonic-gate     inflate() returns Z_OK if some progress has been made (more input
414*7c478bd9Sstevel@tonic-gate   processed or more output produced), Z_STREAM_END if the end of the
415*7c478bd9Sstevel@tonic-gate   compressed data has been reached and all uncompressed output has been
416*7c478bd9Sstevel@tonic-gate   produced, Z_DATA_ERROR if the input data was corrupted, Z_STREAM_ERROR if
417*7c478bd9Sstevel@tonic-gate   the stream structure was inconsistent (for example if next_in or next_out
418*7c478bd9Sstevel@tonic-gate   was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no
419*7c478bd9Sstevel@tonic-gate   progress is possible or if there was not enough room in the output buffer
420*7c478bd9Sstevel@tonic-gate   when Z_FINISH is used. In the Z_DATA_ERROR case, the application may then
421*7c478bd9Sstevel@tonic-gate   call inflateSync to look for a good compression block.  */
422*7c478bd9Sstevel@tonic-gate 
423*7c478bd9Sstevel@tonic-gate 
424*7c478bd9Sstevel@tonic-gate extern int inflateEnd OF((z_stream *strm));
425*7c478bd9Sstevel@tonic-gate /*
426*7c478bd9Sstevel@tonic-gate      All dynamically allocated data structures for this stream are freed.
427*7c478bd9Sstevel@tonic-gate    This function discards any unprocessed input and does not flush any
428*7c478bd9Sstevel@tonic-gate    pending output.
429*7c478bd9Sstevel@tonic-gate 
430*7c478bd9Sstevel@tonic-gate      inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
431*7c478bd9Sstevel@tonic-gate    was inconsistent. In the error case, msg may be set but then points to a
432*7c478bd9Sstevel@tonic-gate    static string (which must not be deallocated).
433*7c478bd9Sstevel@tonic-gate */
434*7c478bd9Sstevel@tonic-gate 
435*7c478bd9Sstevel@tonic-gate                         /* advanced functions */
436*7c478bd9Sstevel@tonic-gate 
437*7c478bd9Sstevel@tonic-gate /*
438*7c478bd9Sstevel@tonic-gate     The following functions are needed only in some special applications.
439*7c478bd9Sstevel@tonic-gate */
440*7c478bd9Sstevel@tonic-gate 
441*7c478bd9Sstevel@tonic-gate extern int deflateInit2 OF((z_stream *strm,
442*7c478bd9Sstevel@tonic-gate                             int  level,
443*7c478bd9Sstevel@tonic-gate                             int  method,
444*7c478bd9Sstevel@tonic-gate                             int  windowBits,
445*7c478bd9Sstevel@tonic-gate                             int  memLevel,
446*7c478bd9Sstevel@tonic-gate                             int  strategy,
447*7c478bd9Sstevel@tonic-gate 			    int  minCompression));
448*7c478bd9Sstevel@tonic-gate /*
449*7c478bd9Sstevel@tonic-gate      This is another version of deflateInit with more compression options. The
450*7c478bd9Sstevel@tonic-gate    fields next_in, zalloc and zfree must be initialized before by the caller.
451*7c478bd9Sstevel@tonic-gate 
452*7c478bd9Sstevel@tonic-gate      The method parameter is the compression method. It must be 8 in this
453*7c478bd9Sstevel@tonic-gate    version of the library. (Method 9 will allow a 64K history buffer and
454*7c478bd9Sstevel@tonic-gate    partial block flushes.)
455*7c478bd9Sstevel@tonic-gate 
456*7c478bd9Sstevel@tonic-gate      The windowBits parameter is the base two logarithm of the window size
457*7c478bd9Sstevel@tonic-gate    (the size of the history buffer).  It should be in the range 8..15 for this
458*7c478bd9Sstevel@tonic-gate    version of the library (the value 16 will be allowed for method 9). Larger
459*7c478bd9Sstevel@tonic-gate    values of this parameter result in better compression at the expense of
460*7c478bd9Sstevel@tonic-gate    memory usage. The default value is 15 if deflateInit is used instead.
461*7c478bd9Sstevel@tonic-gate 
462*7c478bd9Sstevel@tonic-gate     The memLevel parameter specifies how much memory should be allocated
463*7c478bd9Sstevel@tonic-gate    for the internal compression state. memLevel=1 uses minimum memory but
464*7c478bd9Sstevel@tonic-gate    is slow and reduces compression ratio; memLevel=9 uses maximum memory
465*7c478bd9Sstevel@tonic-gate    for optimal speed. The default value is 8. See zconf.h for total memory
466*7c478bd9Sstevel@tonic-gate    usage as a function of windowBits and memLevel.
467*7c478bd9Sstevel@tonic-gate 
468*7c478bd9Sstevel@tonic-gate      The strategy parameter is used to tune the compression algorithm. Use
469*7c478bd9Sstevel@tonic-gate    the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data
470*7c478bd9Sstevel@tonic-gate    produced by a filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman
471*7c478bd9Sstevel@tonic-gate    encoding only (no string match).  Filtered data consists mostly of small
472*7c478bd9Sstevel@tonic-gate    values with a somewhat random distribution. In this case, the
473*7c478bd9Sstevel@tonic-gate    compression algorithm is tuned to compress them better. The strategy
474*7c478bd9Sstevel@tonic-gate    parameter only affects the compression ratio but not the correctness of
475*7c478bd9Sstevel@tonic-gate    the compressed output even if it is not set appropriately.
476*7c478bd9Sstevel@tonic-gate 
477*7c478bd9Sstevel@tonic-gate      The minCompression parameter specifies the minimum reduction in size
478*7c478bd9Sstevel@tonic-gate    required for a compressed block to be output when Z_PACKET_FLUSH is
479*7c478bd9Sstevel@tonic-gate    used (see the description of deflate above).
480*7c478bd9Sstevel@tonic-gate 
481*7c478bd9Sstevel@tonic-gate      If next_in is not null, the library will use this buffer to hold also
482*7c478bd9Sstevel@tonic-gate    some history information; the buffer must either hold the entire input
483*7c478bd9Sstevel@tonic-gate    data, or have at least 1<<(windowBits+1) bytes and be writable. If next_in
484*7c478bd9Sstevel@tonic-gate    is null, the library will allocate its own history buffer (and leave next_in
485*7c478bd9Sstevel@tonic-gate    null). next_out need not be provided here but must be provided by the
486*7c478bd9Sstevel@tonic-gate    application for the next call of deflate().
487*7c478bd9Sstevel@tonic-gate 
488*7c478bd9Sstevel@tonic-gate      If the history buffer is provided by the application, next_in must
489*7c478bd9Sstevel@tonic-gate    must never be changed by the application since the compressor maintains
490*7c478bd9Sstevel@tonic-gate    information inside this buffer from call to call; the application
491*7c478bd9Sstevel@tonic-gate    must provide more input only by increasing avail_in. next_in is always
492*7c478bd9Sstevel@tonic-gate    reset by the library in this case.
493*7c478bd9Sstevel@tonic-gate 
494*7c478bd9Sstevel@tonic-gate       deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was
495*7c478bd9Sstevel@tonic-gate    not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
496*7c478bd9Sstevel@tonic-gate    an invalid method). msg is set to null if there is no error message.
497*7c478bd9Sstevel@tonic-gate    deflateInit2 does not perform any compression: this will be done by
498*7c478bd9Sstevel@tonic-gate    deflate().
499*7c478bd9Sstevel@tonic-gate */
500*7c478bd9Sstevel@tonic-gate 
501*7c478bd9Sstevel@tonic-gate extern int deflateCopy OF((z_stream *dest,
502*7c478bd9Sstevel@tonic-gate                            z_stream *source));
503*7c478bd9Sstevel@tonic-gate /*
504*7c478bd9Sstevel@tonic-gate      Sets the destination stream as a complete copy of the source stream.  If
505*7c478bd9Sstevel@tonic-gate    the source stream is using an application-supplied history buffer, a new
506*7c478bd9Sstevel@tonic-gate    buffer is allocated for the destination stream.  The compressed output
507*7c478bd9Sstevel@tonic-gate    buffer is always application-supplied. It's the responsibility of the
508*7c478bd9Sstevel@tonic-gate    application to provide the correct values of next_out and avail_out for the
509*7c478bd9Sstevel@tonic-gate    next call of deflate.
510*7c478bd9Sstevel@tonic-gate 
511*7c478bd9Sstevel@tonic-gate      This function is useful when several compression strategies will be
512*7c478bd9Sstevel@tonic-gate    tried, for example when there are several ways of pre-processing the input
513*7c478bd9Sstevel@tonic-gate    data with a filter. The streams that will be discarded should then be freed
514*7c478bd9Sstevel@tonic-gate    by calling deflateEnd.  Note that deflateCopy duplicates the internal
515*7c478bd9Sstevel@tonic-gate    compression state which can be quite large, so this strategy is slow and
516*7c478bd9Sstevel@tonic-gate    can consume lots of memory.
517*7c478bd9Sstevel@tonic-gate 
518*7c478bd9Sstevel@tonic-gate       deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
519*7c478bd9Sstevel@tonic-gate    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
520*7c478bd9Sstevel@tonic-gate    (such as zalloc being NULL). msg is left unchanged in both source and
521*7c478bd9Sstevel@tonic-gate    destination.
522*7c478bd9Sstevel@tonic-gate */
523*7c478bd9Sstevel@tonic-gate 
524*7c478bd9Sstevel@tonic-gate extern int deflateReset OF((z_stream *strm));
525*7c478bd9Sstevel@tonic-gate /*
526*7c478bd9Sstevel@tonic-gate      This function is equivalent to deflateEnd followed by deflateInit,
527*7c478bd9Sstevel@tonic-gate    but does not free and reallocate all the internal compression state.
528*7c478bd9Sstevel@tonic-gate    The stream will keep the same compression level and any other attributes
529*7c478bd9Sstevel@tonic-gate    that may have been set by deflateInit2.
530*7c478bd9Sstevel@tonic-gate 
531*7c478bd9Sstevel@tonic-gate       deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
532*7c478bd9Sstevel@tonic-gate    stream state was inconsistent (such as zalloc or state being NULL).
533*7c478bd9Sstevel@tonic-gate */
534*7c478bd9Sstevel@tonic-gate 
535*7c478bd9Sstevel@tonic-gate extern int inflateInit2 OF((z_stream *strm,
536*7c478bd9Sstevel@tonic-gate                             int  windowBits));
537*7c478bd9Sstevel@tonic-gate /*
538*7c478bd9Sstevel@tonic-gate      This is another version of inflateInit with more compression options. The
539*7c478bd9Sstevel@tonic-gate    fields next_out, zalloc and zfree must be initialized before by the caller.
540*7c478bd9Sstevel@tonic-gate 
541*7c478bd9Sstevel@tonic-gate      The windowBits parameter is the base two logarithm of the maximum window
542*7c478bd9Sstevel@tonic-gate    size (the size of the history buffer).  It should be in the range 8..15 for
543*7c478bd9Sstevel@tonic-gate    this version of the library (the value 16 will be allowed soon). The
544*7c478bd9Sstevel@tonic-gate    default value is 15 if inflateInit is used instead. If a compressed stream
545*7c478bd9Sstevel@tonic-gate    with a larger window size is given as input, inflate() will return with
546*7c478bd9Sstevel@tonic-gate    the error code Z_DATA_ERROR instead of trying to allocate a larger window.
547*7c478bd9Sstevel@tonic-gate 
548*7c478bd9Sstevel@tonic-gate      If next_out is not null, the library will use this buffer for the history
549*7c478bd9Sstevel@tonic-gate    buffer; the buffer must either be large enough to hold the entire output
550*7c478bd9Sstevel@tonic-gate    data, or have at least 1<<windowBits bytes.  If next_out is null, the
551*7c478bd9Sstevel@tonic-gate    library will allocate its own buffer (and leave next_out null). next_in
552*7c478bd9Sstevel@tonic-gate    need not be provided here but must be provided by the application for the
553*7c478bd9Sstevel@tonic-gate    next call of inflate().
554*7c478bd9Sstevel@tonic-gate 
555*7c478bd9Sstevel@tonic-gate      If the history buffer is provided by the application, next_out must
556*7c478bd9Sstevel@tonic-gate    never be changed by the application since the decompressor maintains
557*7c478bd9Sstevel@tonic-gate    history information inside this buffer from call to call; the application
558*7c478bd9Sstevel@tonic-gate    can only reset next_out to the beginning of the history buffer when
559*7c478bd9Sstevel@tonic-gate    avail_out is zero and all output has been consumed.
560*7c478bd9Sstevel@tonic-gate 
561*7c478bd9Sstevel@tonic-gate       inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was
562*7c478bd9Sstevel@tonic-gate    not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
563*7c478bd9Sstevel@tonic-gate    windowBits < 8). msg is set to null if there is no error message.
564*7c478bd9Sstevel@tonic-gate    inflateInit2 does not perform any decompression: this will be done by
565*7c478bd9Sstevel@tonic-gate    inflate().
566*7c478bd9Sstevel@tonic-gate */
567*7c478bd9Sstevel@tonic-gate 
568*7c478bd9Sstevel@tonic-gate extern int inflateSync OF((z_stream *strm));
569*7c478bd9Sstevel@tonic-gate /*
570*7c478bd9Sstevel@tonic-gate     Skips invalid compressed data until the special marker (see deflate()
571*7c478bd9Sstevel@tonic-gate   above) can be found, or until all available input is skipped. No output
572*7c478bd9Sstevel@tonic-gate   is provided.
573*7c478bd9Sstevel@tonic-gate 
574*7c478bd9Sstevel@tonic-gate     inflateSync returns Z_OK if the special marker has been found, Z_BUF_ERROR
575*7c478bd9Sstevel@tonic-gate   if no more input was provided, Z_DATA_ERROR if no marker has been found,
576*7c478bd9Sstevel@tonic-gate   or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
577*7c478bd9Sstevel@tonic-gate   case, the application may save the current current value of total_in which
578*7c478bd9Sstevel@tonic-gate   indicates where valid compressed data was found. In the error case, the
579*7c478bd9Sstevel@tonic-gate   application may repeatedly call inflateSync, providing more input each time,
580*7c478bd9Sstevel@tonic-gate   until success or end of the input data.
581*7c478bd9Sstevel@tonic-gate */
582*7c478bd9Sstevel@tonic-gate 
583*7c478bd9Sstevel@tonic-gate extern int inflateReset OF((z_stream *strm));
584*7c478bd9Sstevel@tonic-gate /*
585*7c478bd9Sstevel@tonic-gate      This function is equivalent to inflateEnd followed by inflateInit,
586*7c478bd9Sstevel@tonic-gate    but does not free and reallocate all the internal decompression state.
587*7c478bd9Sstevel@tonic-gate    The stream will keep attributes that may have been set by inflateInit2.
588*7c478bd9Sstevel@tonic-gate 
589*7c478bd9Sstevel@tonic-gate       inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
590*7c478bd9Sstevel@tonic-gate    stream state was inconsistent (such as zalloc or state being NULL).
591*7c478bd9Sstevel@tonic-gate */
592*7c478bd9Sstevel@tonic-gate 
593*7c478bd9Sstevel@tonic-gate extern int inflateIncomp OF((z_stream *strm));
594*7c478bd9Sstevel@tonic-gate /*
595*7c478bd9Sstevel@tonic-gate      This function adds the data at next_in (avail_in bytes) to the output
596*7c478bd9Sstevel@tonic-gate    history without performing any output.  There must be no pending output,
597*7c478bd9Sstevel@tonic-gate    and the decompressor must be expecting to see the start of a block.
598*7c478bd9Sstevel@tonic-gate    Calling this function is equivalent to decompressing a stored block
599*7c478bd9Sstevel@tonic-gate    containing the data at next_in (except that the data is not output).
600*7c478bd9Sstevel@tonic-gate */
601*7c478bd9Sstevel@tonic-gate 
602*7c478bd9Sstevel@tonic-gate                         /* checksum functions */
603*7c478bd9Sstevel@tonic-gate 
604*7c478bd9Sstevel@tonic-gate /*
605*7c478bd9Sstevel@tonic-gate      This function is not related to compression but is exported
606*7c478bd9Sstevel@tonic-gate    anyway because it might be useful in applications using the
607*7c478bd9Sstevel@tonic-gate    compression library.
608*7c478bd9Sstevel@tonic-gate */
609*7c478bd9Sstevel@tonic-gate 
610*7c478bd9Sstevel@tonic-gate extern uLong adler32 OF((uLong adler, Bytef *buf, uInt len));
611*7c478bd9Sstevel@tonic-gate 
612*7c478bd9Sstevel@tonic-gate /*
613*7c478bd9Sstevel@tonic-gate      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
614*7c478bd9Sstevel@tonic-gate    return the updated checksum. If buf is NULL, this function returns
615*7c478bd9Sstevel@tonic-gate    the required initial value for the checksum.
616*7c478bd9Sstevel@tonic-gate    An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
617*7c478bd9Sstevel@tonic-gate    much faster. Usage example:
618*7c478bd9Sstevel@tonic-gate 
619*7c478bd9Sstevel@tonic-gate      uLong adler = adler32(0L, Z_NULL, 0);
620*7c478bd9Sstevel@tonic-gate 
621*7c478bd9Sstevel@tonic-gate      while (read_buffer(buffer, length) != EOF) {
622*7c478bd9Sstevel@tonic-gate        adler = adler32(adler, buffer, length);
623*7c478bd9Sstevel@tonic-gate      }
624*7c478bd9Sstevel@tonic-gate      if (adler != original_adler) error();
625*7c478bd9Sstevel@tonic-gate */
626*7c478bd9Sstevel@tonic-gate 
627*7c478bd9Sstevel@tonic-gate #ifndef _Z_UTIL_H
628*7c478bd9Sstevel@tonic-gate     struct internal_state {int dummy;}; /* hack for buggy compilers */
629*7c478bd9Sstevel@tonic-gate #endif
630*7c478bd9Sstevel@tonic-gate 
631*7c478bd9Sstevel@tonic-gate #endif /* _ZLIB_H */
632