xref: /netbsd/sys/net/zlib.h (revision bf9ec67e)
1 /* $NetBSD: zlib.h,v 1.6 2002/03/13 03:59:35 fvdl Exp $ */
2 
3 /* zlib.h -- interface of the 'zlib' general purpose compression library
4   version 1.1.4, March 11th, 2002
5 
6   Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler
7 
8   This software is provided 'as-is', without any express or implied
9   warranty.  In no event will the authors be held liable for any damages
10   arising from the use of this software.
11 
12   Permission is granted to anyone to use this software for any purpose,
13   including commercial applications, and to alter it and redistribute it
14   freely, subject to the following restrictions:
15 
16   1. The origin of this software must not be misrepresented; you must not
17      claim that you wrote the original software. If you use this software
18      in a product, an acknowledgment in the product documentation would be
19      appreciated but is not required.
20   2. Altered source versions must be plainly marked as such, and must not be
21      misrepresented as being the original software.
22   3. This notice may not be removed or altered from any source distribution.
23 
24   Jean-loup Gailly        Mark Adler
25   jloup@gzip.org          madler@alumni.caltech.edu
26 
27 
28   The data format used by the zlib library is described by RFCs (Request for
29   Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
30   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
31 */
32 
33 #ifndef _ZLIB_H
34 #define _ZLIB_H
35 
36 #ifdef __NetBSD__
37 #include <sys/cdefs.h>
38 #endif
39 
40 /* +++ zconf.h */
41 /* zconf.h -- configuration of the zlib compression library
42  * Copyright (C) 1995-2002 Jean-loup Gailly.
43  * For conditions of distribution and use, see copyright notice in zlib.h
44  */
45 
46 /* @(#) $Id: zlib.h,v 1.6 2002/03/13 03:59:35 fvdl Exp $ */
47 
48 #ifndef _ZCONF_H
49 #define _ZCONF_H
50 
51 /*
52  * Warning:  This file pollutes the user's namespace with:
53  * 	Byte Bytef EXPORT FAR OF STDC
54  *  charf intf uInt uIntf uLong uLonf
55  * Programs using this library appear to expect those...
56  */
57 
58 #include <sys/types.h>
59 
60 /*
61  * If you *really* need a unique prefix for all types and library functions,
62  * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
63  */
64 #ifdef Z_PREFIX
65 #  define deflateInit_	z_deflateInit_
66 #  define deflate	z_deflate
67 #  define deflateEnd	z_deflateEnd
68 #  define inflateInit_ 	z_inflateInit_
69 #  define inflate	z_inflate
70 #  define inflateEnd	z_inflateEnd
71 #  define deflateInit2_	z_deflateInit2_
72 #  define deflateSetDictionary z_deflateSetDictionary
73 #  define deflateCopy	z_deflateCopy
74 #  define deflateReset	z_deflateReset
75 #  define deflateParams	z_deflateParams
76 #  define inflateInit2_	z_inflateInit2_
77 #  define inflateSetDictionary z_inflateSetDictionary
78 #  define inflateSync	z_inflateSync
79 #  define inflateSyncPoint z_inflateSyncPoint
80 #  define inflateReset	z_inflateReset
81 #  define compress	z_compress
82 #  define compress2	z_compress2
83 #  define uncompress	z_uncompress
84 #  define adler32	z_adler32
85 #  define crc32		z_crc32
86 #  define get_crc_table z_get_crc_table
87 
88 #  define Byte		z_Byte
89 #  define uInt		z_uInt
90 #  define uLong		z_uLong
91 #  define Bytef	        z_Bytef
92 #  define charf		z_charf
93 #  define intf		z_intf
94 #  define uIntf		z_uIntf
95 #  define uLongf	z_uLongf
96 #  define voidpf	z_voidpf
97 #  define voidp		z_voidp
98 #endif
99 
100 #ifndef __32BIT__
101 /* Don't be alarmed; this just means we have at least 32-bits */
102 #  define __32BIT__
103 #endif
104 
105 /*
106  * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
107  * than 64k bytes at a time (needed on systems with 16-bit int).
108  */
109 #if defined(MSDOS) && !defined(__32BIT__)
110 #  define MAXSEG_64K
111 #endif
112 
113 #if 0
114 /* XXX: Are there machines where we should define this?  m68k? */
115 #  define UNALIGNED_OK
116 #endif
117 
118 #if (defined(__STDC__) || defined(__cplusplus)) && !defined(STDC)
119 /* XXX: Look out - this is used in zutil.h and elsewhere... */
120 #  define STDC
121 #endif
122 #if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__)
123 #  ifndef STDC
124 #    define STDC
125 #  endif
126 #endif
127 
128 #ifndef STDC
129 #  ifndef const
130 #    define const
131 #  endif
132 #endif
133 
134 /* Some Mac compilers merge all .h files incorrectly: */
135 #if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__)
136 #  define NO_DUMMY_DECL
137 #endif
138 
139 /* Old Borland C incorrectly complains about missing returns: */
140 #if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
141 #  define NEED_DUMMY_RETURN
142 #endif
143 
144 
145 /* Maximum value for memLevel in deflateInit2 */
146 #ifndef MAX_MEM_LEVEL
147 #  ifdef MAXSEG_64K
148 #    define MAX_MEM_LEVEL 8
149 #  else
150 #    define MAX_MEM_LEVEL 9
151 #  endif
152 #endif
153 
154 /* Maximum value for windowBits in deflateInit2 and inflateInit2.
155  * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
156  * created by gzip. (Files created by minigzip can still be extracted by
157  * gzip.)
158  */
159 #ifndef MAX_WBITS
160 #  define MAX_WBITS   15 /* 32K LZ77 window */
161 #endif
162 
163 /* The memory requirements for deflate are (in bytes):
164             (1 << (windowBits+2)) +  (1 << (memLevel+9))
165  that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
166  plus a few kilobytes for small objects. For example, if you want to reduce
167  the default memory requirements from 256K to 128K, compile with
168      make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
169  Of course this will generally degrade compression (there's no free lunch).
170 
171    The memory requirements for inflate are (in bytes) 1 << windowBits
172  that is, 32K for windowBits=15 (default value) plus a few kilobytes
173  for small objects.
174 */
175 
176                         /* Type declarations */
177 
178 #ifndef __P /* function prototypes */
179 #  ifdef STDC
180 #    define __P(args)  args
181 #  else
182 #    define __P(args)  ()
183 #  endif
184 #endif
185 
186 /* The following definitions for FAR are needed only for MSDOS mixed
187  * model programming (small or medium model with some far allocations).
188  * This was tested only with MSC; for other MSDOS compilers you may have
189  * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
190  * just define FAR to be empty.
191  */
192 #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__)
193    /* MSC small or medium model */
194 #  define SMALL_MEDIUM
195 #  ifdef _MSC_VER
196 #    define FAR _far
197 #  else
198 #    define FAR far
199 #  endif
200 #endif
201 #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
202 #  ifndef __32BIT__
203 #    define SMALL_MEDIUM
204 #    define FAR _far
205 #  endif
206 #endif
207 
208 /* Compile with -DZLIB_DLL for Windows DLL support */
209 #if defined(ZLIB_DLL)
210 #  if defined(_WINDOWS) || defined(WINDOWS)
211 #    ifdef FAR
212 #      undef FAR
213 #    endif
214 #    include <windows.h>
215 #    define ZEXPORT  WINAPI
216 #    ifdef WIN32
217 #      define ZEXPORTVA  WINAPIV
218 #    else
219 #      define ZEXPORTVA  FAR _cdecl _export
220 #    endif
221 #  endif
222 #  if defined (__BORLANDC__)
223 #    if (__BORLANDC__ >= 0x0500) && defined (WIN32)
224 #      include <windows.h>
225 #      define ZEXPORT __declspec(dllexport) WINAPI
226 #      define ZEXPORTRVA __declspec(dllexport) WINAPIV
227 #    else
228 #      if defined (_Windows) && defined (__DLL__)
229 #        define ZEXPORT _export
230 #        define ZEXPORTVA _export
231 #      endif
232 #    endif
233 #  endif
234 #endif
235 
236 #if defined (__BEOS__)
237 #  if defined (ZLIB_DLL)
238 #    define ZEXTERN extern __declspec(dllexport)
239 #  else
240 #    define ZEXTERN extern __declspec(dllimport)
241 #  endif
242 #endif
243 
244 #ifndef ZEXPORT
245 #  define ZEXPORT
246 #endif
247 #ifndef ZEXPORTVA
248 #  define ZEXPORTVA
249 #endif
250 #ifndef ZEXTERN
251 #  define ZEXTERN extern
252 #endif
253 
254 #ifndef FAR
255 #   define FAR
256 #endif
257 
258 #if !defined(MACOS) && !defined(TARGET_OS_MAC)
259 typedef unsigned char  Byte;  /* 8 bits */
260 #endif
261 typedef unsigned int   uInt;  /* 16 bits or more */
262 typedef unsigned long  uLong; /* 32 bits or more */
263 
264 #ifdef SMALL_MEDIUM
265    /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
266 #  define Bytef Byte FAR
267 #else
268    typedef Byte  FAR Bytef;
269 #endif
270 typedef char  FAR charf;
271 typedef int   FAR intf;
272 typedef uInt  FAR uIntf;
273 typedef uLong FAR uLongf;
274 
275 #ifdef STDC
276    typedef void FAR *voidpf;
277    typedef void     *voidp;
278 #else
279    typedef Byte FAR *voidpf;
280    typedef Byte     *voidp;
281 #endif
282 
283 #if (defined(HAVE_UNISTD_H) || defined(__NetBSD__)) && !defined(_KERNEL)
284 #  include <sys/types.h> /* for off_t */
285 #  include <unistd.h>    /* for SEEK_* and off_t */
286 #  define z_off_t  off_t
287 #endif
288 #ifndef SEEK_SET
289 #  define SEEK_SET        0       /* Seek from beginning of file.  */
290 #  define SEEK_CUR        1       /* Seek from current position.  */
291 #  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
292 #endif
293 #ifndef z_off_t
294 #  define  z_off_t long
295 #endif
296 
297 /* MVS linker does not support external names larger than 8 bytes */
298 #if defined(__MVS__)
299 #   pragma map(deflateInit_,"DEIN")
300 #   pragma map(deflateInit2_,"DEIN2")
301 #   pragma map(deflateEnd,"DEEND")
302 #   pragma map(inflateInit_,"ININ")
303 #   pragma map(inflateInit2_,"ININ2")
304 #   pragma map(inflateEnd,"INEND")
305 #   pragma map(inflateSync,"INSY")
306 #   pragma map(inflateSetDictionary,"INSEDI")
307 #   pragma map(inflate_blocks,"INBL")
308 #   pragma map(inflate_blocks_new,"INBLNE")
309 #   pragma map(inflate_blocks_free,"INBLFR")
310 #   pragma map(inflate_blocks_reset,"INBLRE")
311 #   pragma map(inflate_codes_free,"INCOFR")
312 #   pragma map(inflate_codes,"INCO")
313 #   pragma map(inflate_fast,"INFA")
314 #   pragma map(inflate_flush,"INFLU")
315 #   pragma map(inflate_mask,"INMA")
316 #   pragma map(inflate_set_dictionary,"INSEDI2")
317 #   pragma map(inflate_copyright,"INCOPY")
318 #   pragma map(inflate_trees_bits,"INTRBI")
319 #   pragma map(inflate_trees_dynamic,"INTRDY")
320 #   pragma map(inflate_trees_fixed,"INTRFI")
321 #   pragma map(inflate_trees_free,"INTRFR")
322 #endif
323 
324 #endif /* _ZCONF_H */
325 /* --- zconf.h */
326 
327 #ifdef __cplusplus
328 extern "C" {
329 #endif
330 
331 #define ZLIB_VERSION "1.1.4"
332 
333 /*
334      The 'zlib' compression library provides in-memory compression and
335   decompression functions, including integrity checks of the uncompressed
336   data.  This version of the library supports only one compression method
337   (deflation) but other algorithms will be added later and will have the same
338   stream interface.
339 
340      Compression can be done in a single step if the buffers are large
341   enough (for example if an input file is mmap'ed), or can be done by
342   repeated calls of the compression function.  In the latter case, the
343   application must provide more input and/or consume the output
344   (providing more output space) before each call.
345 
346      The library also supports reading and writing files in gzip (.gz) format
347   with an interface similar to that of stdio.
348 
349      The library does not install any signal handler. The decoder checks
350   the consistency of the compressed data, so the library should never
351   crash even in case of corrupted input.
352 */
353 
354 typedef voidpf (*alloc_func) __P((voidpf opaque, uInt items, uInt size));
355 typedef void   (*free_func)  __P((voidpf opaque, voidpf address));
356 
357 struct internal_state;
358 
359 typedef struct z_stream_s {
360     Bytef    *next_in;  /* next input byte */
361     uInt     avail_in;  /* number of bytes available at next_in */
362     uLong    total_in;  /* total nb of input bytes read so far */
363 
364     Bytef    *next_out; /* next output byte should be put there */
365     uInt     avail_out; /* remaining free space at next_out */
366     uLong    total_out; /* total nb of bytes output so far */
367 
368     char     *msg;      /* last error message, NULL if no error */
369     struct internal_state FAR *state; /* not visible by applications */
370 
371     alloc_func zalloc;  /* used to allocate the internal state */
372     free_func  zfree;   /* used to free the internal state */
373     voidpf     opaque;  /* private data object passed to zalloc and zfree */
374 
375     int     data_type;  /* best guess about the data type: ascii or binary */
376     uLong   adler;      /* adler32 value of the uncompressed data */
377     uLong   reserved;   /* reserved for future use */
378 } z_stream;
379 
380 typedef z_stream FAR *z_streamp;
381 
382 /*
383    The application must update next_in and avail_in when avail_in has
384    dropped to zero. It must update next_out and avail_out when avail_out
385    has dropped to zero. The application must initialize zalloc, zfree and
386    opaque before calling the init function. All other fields are set by the
387    compression library and must not be updated by the application.
388 
389    The opaque value provided by the application will be passed as the first
390    parameter for calls of zalloc and zfree. This can be useful for custom
391    memory management. The compression library attaches no meaning to the
392    opaque value.
393 
394    zalloc must return Z_NULL if there is not enough memory for the object.
395    If zlib is used in a multi-threaded application, zalloc and zfree must be
396    thread safe.
397 
398    On 16-bit systems, the functions zalloc and zfree must be able to allocate
399    exactly 65536 bytes, but will not be required to allocate more than this
400    if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
401    pointers returned by zalloc for objects of exactly 65536 bytes *must*
402    have their offset normalized to zero. The default allocation function
403    provided by this library ensures this (see zutil.c). To reduce memory
404    requirements and avoid any allocation of 64K objects, at the expense of
405    compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
406 
407    The fields total_in and total_out can be used for statistics or
408    progress reports. After compression, total_in holds the total size of
409    the uncompressed data and may be saved for use in the decompressor
410    (particularly if the decompressor wants to decompress everything in
411    a single step).
412 */
413 
414                         /* constants */
415 
416 #define Z_NO_FLUSH      0
417 #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
418 #define Z_PACKET_FLUSH  2
419 #define Z_SYNC_FLUSH    3
420 #define Z_FULL_FLUSH    4
421 #define Z_FINISH        5
422 /* Allowed flush values; see deflate() below for details */
423 
424 #define Z_OK            0
425 #define Z_STREAM_END    1
426 #define Z_NEED_DICT     2
427 #define Z_ERRNO        (-1)
428 #define Z_STREAM_ERROR (-2)
429 #define Z_DATA_ERROR   (-3)
430 #define Z_MEM_ERROR    (-4)
431 #define Z_BUF_ERROR    (-5)
432 #define Z_VERSION_ERROR (-6)
433 /* Return codes for the compression/decompression functions. Negative
434  * values are errors, positive values are used for special but normal events.
435  */
436 
437 #define Z_NO_COMPRESSION         0
438 #define Z_BEST_SPEED             1
439 #define Z_BEST_COMPRESSION       9
440 #define Z_DEFAULT_COMPRESSION  (-1)
441 /* compression levels */
442 
443 #define Z_FILTERED            1
444 #define Z_HUFFMAN_ONLY        2
445 #define Z_DEFAULT_STRATEGY    0
446 /* compression strategy; see deflateInit2() below for details */
447 
448 #define Z_BINARY   0
449 #define Z_ASCII    1
450 #define Z_UNKNOWN  2
451 /* Possible values of the data_type field */
452 
453 #define Z_DEFLATED   8
454 /* The deflate compression method (the only one supported in this version) */
455 
456 #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
457 
458 #define zlib_version zlibVersion()
459 /* for compatibility with versions < 1.0.2 */
460 
461                         /* basic functions */
462 
463 ZEXTERN const char * ZEXPORT zlibVersion __P((void));
464 /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
465    If the first character differs, the library code actually used is
466    not compatible with the zlib.h header file used by the application.
467    This check is automatically made by deflateInit and inflateInit.
468  */
469 
470 /*
471 ZEXTERN int ZEXPORT deflateInit __P((z_streamp strm, int level));
472 
473      Initializes the internal stream state for compression. The fields
474    zalloc, zfree and opaque must be initialized before by the caller.
475    If zalloc and zfree are set to Z_NULL, deflateInit updates them to
476    use default allocation functions.
477 
478      The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
479    1 gives best speed, 9 gives best compression, 0 gives no compression at
480    all (the input data is simply copied a block at a time).
481    Z_DEFAULT_COMPRESSION requests a default compromise between speed and
482    compression (currently equivalent to level 6).
483 
484      deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
485    enough memory, Z_STREAM_ERROR if level is not a valid compression level,
486    Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
487    with the version assumed by the caller (ZLIB_VERSION).
488    msg is set to null if there is no error message.  deflateInit does not
489    perform any compression: this will be done by deflate().
490 */
491 
492 
493 ZEXTERN int ZEXPORT deflate __P((z_streamp strm, int flush));
494 /*
495     deflate compresses as much data as possible, and stops when the input
496   buffer becomes empty or the output buffer becomes full. It may introduce some
497   output latency (reading input without producing any output) except when
498   forced to flush.
499 
500     The detailed semantics are as follows. deflate performs one or both of the
501   following actions:
502 
503   - Compress more input starting at next_in and update next_in and avail_in
504     accordingly. If not all input can be processed (because there is not
505     enough room in the output buffer), next_in and avail_in are updated and
506     processing will resume at this point for the next call of deflate().
507 
508   - Provide more output starting at next_out and update next_out and avail_out
509     accordingly. This action is forced if the parameter flush is non zero.
510     Forcing flush frequently degrades the compression ratio, so this parameter
511     should be set only when necessary (in interactive applications).
512     Some output may be provided even if flush is not set.
513 
514   Before the call of deflate(), the application should ensure that at least
515   one of the actions is possible, by providing more input and/or consuming
516   more output, and updating avail_in or avail_out accordingly; avail_out
517   should never be zero before the call. The application can consume the
518   compressed output when it wants, for example when the output buffer is full
519   (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
520   and with zero avail_out, it must be called again after making room in the
521   output buffer because there might be more output pending.
522 
523     If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
524   flushed to the output buffer and the output is aligned on a byte boundary, so
525   that the decompressor can get all input data available so far. (In particular
526   avail_in is zero after the call if enough output space has been provided
527   before the call.)  Flushing may degrade compression for some compression
528   algorithms and so it should be used only when necessary.
529 
530     If flush is set to Z_FULL_FLUSH, all output is flushed as with
531   Z_SYNC_FLUSH, and the compression state is reset so that decompression can
532   restart from this point if previous compressed data has been damaged or if
533   random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
534   the compression.
535 
536     If deflate returns with avail_out == 0, this function must be called again
537   with the same value of the flush parameter and more output space (updated
538   avail_out), until the flush is complete (deflate returns with non-zero
539   avail_out).
540 
541     If the parameter flush is set to Z_PACKET_FLUSH, the compression
542   block is terminated, and a zero-length stored block is output,
543   omitting the length bytes (the effect of this is that the 3-bit type
544   code 000 for a stored block is output, and the output is then
545   byte-aligned).  This is designed for use at the end of a PPP packet.
546 
547 
548     If the parameter flush is set to Z_FINISH, pending input is processed,
549   pending output is flushed and deflate returns with Z_STREAM_END if there
550   was enough output space; if deflate returns with Z_OK, this function must be
551   called again with Z_FINISH and more output space (updated avail_out) but no
552   more input data, until it returns with Z_STREAM_END or an error. After
553   deflate has returned Z_STREAM_END, the only possible operations on the
554   stream are deflateReset or deflateEnd.
555 
556     Z_FINISH can be used immediately after deflateInit if all the compression
557   is to be done in a single step. In this case, avail_out must be at least
558   0.1% larger than avail_in plus 12 bytes.  If deflate does not return
559   Z_STREAM_END, then it must be called again as described above.
560 
561     deflate() sets strm->adler to the adler32 checksum of all input read
562   so far (that is, total_in bytes).
563 
564     deflate() may update data_type if it can make a good guess about
565   the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
566   binary. This field is only for information purposes and does not affect
567   the compression algorithm in any manner.
568 
569     deflate() returns Z_OK if some progress has been made (more input
570   processed or more output produced), Z_STREAM_END if all input has been
571   consumed and all output has been produced (only when flush is set to
572   Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
573   if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
574   (for example avail_in or avail_out was zero).
575 */
576 
577 
578 ZEXTERN int ZEXPORT deflateEnd __P((z_streamp strm));
579 /*
580      All dynamically allocated data structures for this stream are freed.
581    This function discards any unprocessed input and does not flush any
582    pending output.
583 
584      deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
585    stream state was inconsistent, Z_DATA_ERROR if the stream was freed
586    prematurely (some input or output was discarded). In the error case,
587    msg may be set but then points to a static string (which must not be
588    deallocated).
589 */
590 
591 
592 /*
593 ZEXTERN int ZEXPORT inflateInit __P((z_streamp strm));
594 
595      Initializes the internal stream state for decompression. The fields
596    next_in, avail_in, zalloc, zfree and opaque must be initialized before by
597    the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
598    value depends on the compression method), inflateInit determines the
599    compression method from the zlib header and allocates all data structures
600    accordingly; otherwise the allocation will be deferred to the first call of
601    inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
602    use default allocation functions.
603 
604      inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
605    memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
606    version assumed by the caller.  msg is set to null if there is no error
607    message. inflateInit does not perform any decompression apart from reading
608    the zlib header if present: this will be done by inflate().  (So next_in and
609    avail_in may be modified, but next_out and avail_out are unchanged.)
610 */
611 
612 
613 ZEXTERN int ZEXPORT inflate __P((z_streamp strm, int flush));
614 /*
615     inflate decompresses as much data as possible, and stops when the input
616   buffer becomes empty or the output buffer becomes full. It may some
617   introduce some output latency (reading input without producing any output)
618   except when forced to flush.
619 
620   The detailed semantics are as follows. inflate performs one or both of the
621   following actions:
622 
623   - Decompress more input starting at next_in and update next_in and avail_in
624     accordingly. If not all input can be processed (because there is not
625     enough room in the output buffer), next_in is updated and processing
626     will resume at this point for the next call of inflate().
627 
628   - Provide more output starting at next_out and update next_out and avail_out
629     accordingly.  inflate() provides as much output as possible, until there
630     is no more input data or no more space in the output buffer (see below
631     about the flush parameter).
632 
633   Before the call of inflate(), the application should ensure that at least
634   one of the actions is possible, by providing more input and/or consuming
635   more output, and updating the next_* and avail_* values accordingly.
636   The application can consume the uncompressed output when it wants, for
637   example when the output buffer is full (avail_out == 0), or after each
638   call of inflate(). If inflate returns Z_OK and with zero avail_out, it
639   must be called again after making room in the output buffer because there
640   might be more output pending.
641 
642     If the parameter flush is set to Z_SYNC_FLUSH or Z_PACKET_FLUSH,
643   inflate flushes as much output as possible to the output buffer. The
644   flushing behavior of inflate is not specified for values of the flush
645   parameter other than Z_SYNC_FLUSH, Z_PACKET_FLUSH or Z_FINISH, but the
646   current implementation actually flushes as much output as possible
647   anyway. For Z_PACKET_FLUSH, inflate checks that once all the input data
648   has been consumed, it is expecting to see the length field of a stored
649   block; if not, it returns Z_DATA_ERROR.
650 
651     inflate() should normally be called until it returns Z_STREAM_END or an
652   error. However if all decompression is to be performed in a single step
653   (a single call of inflate), the parameter flush should be set to
654   Z_FINISH. In this case all pending input is processed and all pending
655   output is flushed; avail_out must be large enough to hold all the
656   uncompressed data. (The size of the uncompressed data may have been saved
657   by the compressor for this purpose.) The next operation on this stream must
658   be inflateEnd to deallocate the decompression state. The use of Z_FINISH
659   is never required, but can be used to inform inflate that a faster routine
660   may be used for the single inflate() call.
661 
662      If a preset dictionary is needed at this point (see inflateSetDictionary
663   below), inflate sets strm-adler to the adler32 checksum of the
664   dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
665   it sets strm->adler to the adler32 checksum of all output produced
666   so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
667   an error code as described below. At the end of the stream, inflate()
668   checks that its computed adler32 checksum is equal to that saved by the
669   compressor and returns Z_STREAM_END only if the checksum is correct.
670 
671     inflate() returns Z_OK if some progress has been made (more input processed
672   or more output produced), Z_STREAM_END if the end of the compressed data has
673   been reached and all uncompressed output has been produced, Z_NEED_DICT if a
674   preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
675   corrupted (input stream not conforming to the zlib format or incorrect
676   adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
677   (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
678   enough memory, Z_BUF_ERROR if no progress is possible or if there was not
679   enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
680   case, the application may then call inflateSync to look for a good
681   compression block.
682 */
683 
684 
685 ZEXTERN int ZEXPORT inflateEnd __P((z_streamp strm));
686 /*
687      All dynamically allocated data structures for this stream are freed.
688    This function discards any unprocessed input and does not flush any
689    pending output.
690 
691      inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
692    was inconsistent. In the error case, msg may be set but then points to a
693    static string (which must not be deallocated).
694 */
695 
696                         /* Advanced functions */
697 
698 /*
699     The following functions are needed only in some special applications.
700 */
701 
702 /*
703 ZEXTERN int ZEXPORT deflateInit2 __P((z_streamp strm,
704                                      int  level,
705                                      int  method,
706                                      int  windowBits,
707                                      int  memLevel,
708                                      int  strategy));
709 
710      This is another version of deflateInit with more compression options. The
711    fields next_in, zalloc, zfree and opaque must be initialized before by
712    the caller.
713 
714      The method parameter is the compression method. It must be Z_DEFLATED in
715    this version of the library.
716 
717      The windowBits parameter is the base two logarithm of the window size
718    (the size of the history buffer).  It should be in the range 8..15 for this
719    version of the library. Larger values of this parameter result in better
720    compression at the expense of memory usage. The default value is 15 if
721    deflateInit is used instead.
722 
723      The memLevel parameter specifies how much memory should be allocated
724    for the internal compression state. memLevel=1 uses minimum memory but
725    is slow and reduces compression ratio; memLevel=9 uses maximum memory
726    for optimal speed. The default value is 8. See zconf.h for total memory
727    usage as a function of windowBits and memLevel.
728 
729      The strategy parameter is used to tune the compression algorithm. Use the
730    value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
731    filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
732    string match).  Filtered data consists mostly of small values with a
733    somewhat random distribution. In this case, the compression algorithm is
734    tuned to compress them better. The effect of Z_FILTERED is to force more
735    Huffman coding and less string matching; it is somewhat intermediate
736    between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
737    the compression ratio but not the correctness of the compressed output even
738    if it is not set appropriately.
739 
740       deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
741    memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
742    method). msg is set to null if there is no error message.  deflateInit2 does
743    not perform any compression: this will be done by deflate().
744 */
745 
746 ZEXTERN int ZEXPORT deflateSetDictionary __P((z_streamp strm,
747                                              const Bytef *dictionary,
748                                              uInt  dictLength));
749 /*
750      Initializes the compression dictionary from the given byte sequence
751    without producing any compressed output. This function must be called
752    immediately after deflateInit, deflateInit2 or deflateReset, before any
753    call of deflate. The compressor and decompressor must use exactly the same
754    dictionary (see inflateSetDictionary).
755 
756      The dictionary should consist of strings (byte sequences) that are likely
757    to be encountered later in the data to be compressed, with the most commonly
758    used strings preferably put towards the end of the dictionary. Using a
759    dictionary is most useful when the data to be compressed is short and can be
760    predicted with good accuracy; the data can then be compressed better than
761    with the default empty dictionary.
762 
763      Depending on the size of the compression data structures selected by
764    deflateInit or deflateInit2, a part of the dictionary may in effect be
765    discarded, for example if the dictionary is larger than the window size in
766    deflate or deflate2. Thus the strings most likely to be useful should be
767    put at the end of the dictionary, not at the front.
768 
769      Upon return of this function, strm->adler is set to the Adler32 value
770    of the dictionary; the decompressor may later use this value to determine
771    which dictionary has been used by the compressor. (The Adler32 value
772    applies to the whole dictionary even if only a subset of the dictionary is
773    actually used by the compressor.)
774 
775      deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
776    parameter is invalid (such as NULL dictionary) or the stream state is
777    inconsistent (for example if deflate has already been called for this stream
778    or if the compression method is bsort). deflateSetDictionary does not
779    perform any compression: this will be done by deflate().
780 */
781 
782 ZEXTERN int ZEXPORT deflateCopy __P((z_streamp dest,
783                                     z_streamp source));
784 /*
785      Sets the destination stream as a complete copy of the source stream.
786 
787      This function can be useful when several compression strategies will be
788    tried, for example when there are several ways of pre-processing the input
789    data with a filter. The streams that will be discarded should then be freed
790    by calling deflateEnd.  Note that deflateCopy duplicates the internal
791    compression state which can be quite large, so this strategy is slow and
792    can consume lots of memory.
793 
794      deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
795    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
796    (such as zalloc being NULL). msg is left unchanged in both source and
797    destination.
798 */
799 
800 extern int inflateIncomp __P((z_stream *strm));
801 /*
802      This function adds the data at next_in (avail_in bytes) to the output
803    history without performing any output.  There must be no pending output,
804    and the decompressor must be expecting to see the start of a block.
805    Calling this function is equivalent to decompressing a stored block
806    containing the data at next_in (except that the data is not output).
807 */
808 
809 ZEXTERN int ZEXPORT deflateReset __P((z_streamp strm));
810 /*
811      This function is equivalent to deflateEnd followed by deflateInit,
812    but does not free and reallocate all the internal compression state.
813    The stream will keep the same compression level and any other attributes
814    that may have been set by deflateInit2.
815 
816       deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
817    stream state was inconsistent (such as zalloc or state being NULL).
818 */
819 
820 ZEXTERN int ZEXPORT deflateParams __P((z_streamp strm,
821 				      int level,
822 				      int strategy));
823 /*
824      Dynamically update the compression level and compression strategy.  The
825    interpretation of level and strategy is as in deflateInit2.  This can be
826    used to switch between compression and straight copy of the input data, or
827    to switch to a different kind of input data requiring a different
828    strategy. If the compression level is changed, the input available so far
829    is compressed with the old level (and may be flushed); the new level will
830    take effect only at the next call of deflate().
831 
832      Before the call of deflateParams, the stream state must be set as for
833    a call of deflate(), since the currently available input may have to
834    be compressed and flushed. In particular, strm->avail_out must be non-zero.
835 
836      deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
837    stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
838    if strm->avail_out was zero.
839 */
840 
841 ZEXTERN int ZEXPORT deflateOutputPending __P((z_streamp strm));
842 /*
843      Returns the number of bytes of output which are immediately
844    available from the compressor (i.e. without any further input
845    or flush).
846 */
847 
848 /*
849 ZEXTERN int ZEXPORT inflateInit2 __P((z_streamp strm,
850                                      int  windowBits));
851 
852      This is another version of inflateInit with an extra parameter. The
853    fields next_in, avail_in, zalloc, zfree and opaque must be initialized
854    before by the caller.
855 
856      The windowBits parameter is the base two logarithm of the maximum window
857    size (the size of the history buffer).  It should be in the range 8..15 for
858    this version of the library. The default value is 15 if inflateInit is used
859    instead. If a compressed stream with a larger window size is given as
860    input, inflate() will return with the error code Z_DATA_ERROR instead of
861    trying to allocate a larger window.
862 
863       inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
864    memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
865    memLevel). msg is set to null if there is no error message.  inflateInit2
866    does not perform any decompression apart from reading the zlib header if
867    present: this will be done by inflate(). (So next_in and avail_in may be
868    modified, but next_out and avail_out are unchanged.)
869 */
870 
871 ZEXTERN int ZEXPORT inflateSetDictionary __P((z_streamp strm,
872                                              const Bytef *dictionary,
873                                              uInt  dictLength));
874 /*
875      Initializes the decompression dictionary from the given uncompressed byte
876    sequence. This function must be called immediately after a call of inflate
877    if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
878    can be determined from the Adler32 value returned by this call of
879    inflate. The compressor and decompressor must use exactly the same
880    dictionary (see deflateSetDictionary).
881 
882      inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
883    parameter is invalid (such as NULL dictionary) or the stream state is
884    inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
885    expected one (incorrect Adler32 value). inflateSetDictionary does not
886    perform any decompression: this will be done by subsequent calls of
887    inflate().
888 */
889 
890 ZEXTERN int ZEXPORT inflateSync __P((z_streamp strm));
891 /*
892     Skips invalid compressed data until a full flush point (see above the
893   description of deflate with Z_FULL_FLUSH) can be found, or until all
894   available input is skipped. No output is provided.
895 
896     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
897   if no more input was provided, Z_DATA_ERROR if no flush point has been found,
898   or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
899   case, the application may save the current current value of total_in which
900   indicates where valid compressed data was found. In the error case, the
901   application may repeatedly call inflateSync, providing more input each time,
902   until success or end of the input data.
903 */
904 
905 ZEXTERN int ZEXPORT inflateReset __P((z_streamp strm));
906 /*
907      This function is equivalent to inflateEnd followed by inflateInit,
908    but does not free and reallocate all the internal decompression state.
909    The stream will keep attributes that may have been set by inflateInit2.
910 
911       inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
912    stream state was inconsistent (such as zalloc or state being NULL).
913 */
914 
915 
916                         /* utility functions */
917 
918 /*
919      The following utility functions are implemented on top of the
920    basic stream-oriented functions. To simplify the interface, some
921    default options are assumed (compression level and memory usage,
922    standard memory allocation functions). The source code of these
923    utility functions can easily be modified if you need special options.
924 */
925 
926 ZEXTERN int ZEXPORT compress __P((Bytef *dest,   uLongf *destLen,
927                                  const Bytef *source, uLong sourceLen));
928 /*
929      Compresses the source buffer into the destination buffer.  sourceLen is
930    the byte length of the source buffer. Upon entry, destLen is the total
931    size of the destination buffer, which must be at least 0.1% larger than
932    sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
933    compressed buffer.
934      This function can be used to compress a whole file at once if the
935    input file is mmap'ed.
936      compress returns Z_OK if success, Z_MEM_ERROR if there was not
937    enough memory, Z_BUF_ERROR if there was not enough room in the output
938    buffer.
939 */
940 
941 ZEXTERN int ZEXPORT compress2 __P((Bytef *dest,   uLongf *destLen,
942                                   const Bytef *source, uLong sourceLen,
943                                   int level));
944 /*
945      Compresses the source buffer into the destination buffer. The level
946    parameter has the same meaning as in deflateInit.  sourceLen is the byte
947    length of the source buffer. Upon entry, destLen is the total size of the
948    destination buffer, which must be at least 0.1% larger than sourceLen plus
949    12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
950 
951      compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
952    memory, Z_BUF_ERROR if there was not enough room in the output buffer,
953    Z_STREAM_ERROR if the level parameter is invalid.
954 */
955 
956 ZEXTERN int ZEXPORT uncompress __P((Bytef *dest,   uLongf *destLen,
957                                    const Bytef *source, uLong sourceLen));
958 /*
959      Decompresses the source buffer into the destination buffer.  sourceLen is
960    the byte length of the source buffer. Upon entry, destLen is the total
961    size of the destination buffer, which must be large enough to hold the
962    entire uncompressed data. (The size of the uncompressed data must have
963    been saved previously by the compressor and transmitted to the decompressor
964    by some mechanism outside the scope of this compression library.)
965    Upon exit, destLen is the actual size of the compressed buffer.
966      This function can be used to decompress a whole file at once if the
967    input file is mmap'ed.
968 
969      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
970    enough memory, Z_BUF_ERROR if there was not enough room in the output
971    buffer, or Z_DATA_ERROR if the input data was corrupted.
972 */
973 
974 
975 typedef voidp gzFile;
976 
977 ZEXTERN gzFile ZEXPORT gzopen  __P((const char *path, const char *mode));
978 /*
979      Opens a gzip (.gz) file for reading or writing. The mode parameter
980    is as in fopen ("rb" or "wb") but can also include a compression level
981    ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
982    Huffman only compression as in "wb1h". (See the description
983    of deflateInit2 for more information about the strategy parameter.)
984 
985      gzopen can be used to read a file which is not in gzip format; in this
986    case gzread will directly read from the file without decompression.
987 
988      gzopen returns NULL if the file could not be opened or if there was
989    insufficient memory to allocate the (de)compression state; errno
990    can be checked to distinguish the two cases (if errno is zero, the
991    zlib error is Z_MEM_ERROR).  */
992 
993 ZEXTERN gzFile ZEXPORT gzdopen  __P((int fd, const char *mode));
994 /*
995      gzdopen() associates a gzFile with the file descriptor fd.  File
996    descriptors are obtained from calls like open, dup, creat, pipe or
997    fileno (in the file has been previously opened with fopen).
998    The mode parameter is as in gzopen.
999      The next call of gzclose on the returned gzFile will also close the
1000    file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
1001    descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
1002      gzdopen returns NULL if there was insufficient memory to allocate
1003    the (de)compression state.
1004 */
1005 
1006 ZEXTERN int ZEXPORT gzsetparams __P((gzFile file, int level, int strategy));
1007 /*
1008      Dynamically update the compression level or strategy. See the description
1009    of deflateInit2 for the meaning of these parameters.
1010      gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
1011    opened for writing.
1012 */
1013 
1014 ZEXTERN int ZEXPORT    gzread  __P((gzFile file, voidp buf, unsigned len));
1015 /*
1016      Reads the given number of uncompressed bytes from the compressed file.
1017    If the input file was not in gzip format, gzread copies the given number
1018    of bytes into the buffer.
1019      gzread returns the number of uncompressed bytes actually read (0 for
1020    end of file, -1 for error). */
1021 
1022 ZEXTERN int ZEXPORT    gzwrite __P((gzFile file,
1023 				   const voidp buf, unsigned len));
1024 /*
1025      Writes the given number of uncompressed bytes into the compressed file.
1026    gzwrite returns the number of uncompressed bytes actually written
1027    (0 in case of error).
1028 */
1029 
1030 ZEXTERN int ZEXPORTVA   gzprintf __P((gzFile file, const char *format, ...))
1031 		__attribute__((__format__(__printf__, 2, 3)));
1032 /*
1033      Converts, formats, and writes the args to the compressed file under
1034    control of the format string, as in fprintf. gzprintf returns the number of
1035    uncompressed bytes actually written (0 in case of error).
1036 */
1037 
1038 ZEXTERN int ZEXPORT gzputs __P((gzFile file, const char *s));
1039 /*
1040       Writes the given null-terminated string to the compressed file, excluding
1041    the terminating null character.
1042       gzputs returns the number of characters written, or -1 in case of error.
1043 */
1044 
1045 ZEXTERN char * ZEXPORT gzgets __P((gzFile file, char *buf, int len));
1046 /*
1047       Reads bytes from the compressed file until len-1 characters are read, or
1048    a newline character is read and transferred to buf, or an end-of-file
1049    condition is encountered.  The string is then terminated with a null
1050    character.
1051       gzgets returns buf, or Z_NULL in case of error.
1052 */
1053 
1054 ZEXTERN int ZEXPORT    gzputc __P((gzFile file, int c));
1055 /*
1056       Writes c, converted to an unsigned char, into the compressed file.
1057    gzputc returns the value that was written, or -1 in case of error.
1058 */
1059 
1060 ZEXTERN int ZEXPORT    gzgetc __P((gzFile file));
1061 /*
1062       Reads one byte from the compressed file. gzgetc returns this byte
1063    or -1 in case of end of file or error.
1064 */
1065 
1066 ZEXTERN int ZEXPORT    gzflush __P((gzFile file, int flush));
1067 /*
1068      Flushes all pending output into the compressed file. The parameter
1069    flush is as in the deflate() function. The return value is the zlib
1070    error number (see function gzerror below). gzflush returns Z_OK if
1071    the flush parameter is Z_FINISH and all output could be flushed.
1072      gzflush should be called only when strictly necessary because it can
1073    degrade compression.
1074 
1075 */
1076 
1077 /*
1078  * NetBSD note:
1079  * "long" gzseek has been there till Oct 1999 (1.4L), which was wrong.
1080  */
1081 ZEXTERN z_off_t ZEXPORT    gzseek __P((gzFile file,
1082 				      z_off_t offset, int whence));
1083 /*
1084       Sets the starting position for the next gzread or gzwrite on the
1085    given compressed file. The offset represents a number of bytes in the
1086    uncompressed data stream. The whence parameter is defined as in lseek(2);
1087    the value SEEK_END is not supported.
1088      If the file is opened for reading, this function is emulated but can be
1089    extremely slow. If the file is opened for writing, only forward seeks are
1090    supported; gzseek then compresses a sequence of zeroes up to the new
1091    starting position.
1092 
1093       gzseek returns the resulting offset location as measured in bytes from
1094    the beginning of the uncompressed stream, or -1 in case of error, in
1095    particular if the file is opened for writing and the new starting position
1096    would be before the current position.
1097 */
1098 
1099 ZEXTERN int ZEXPORT    gzrewind __P((gzFile file));
1100 /*
1101      Rewinds the given file. This function is supported only for reading.
1102 
1103    gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
1104 */
1105 
1106 /*
1107  * NetBSD note:
1108  * "long" gztell has been there till Oct 1999 (1.4L), which was wrong.
1109  */
1110 ZEXTERN z_off_t ZEXPORT    gztell __P((gzFile file));
1111 /*
1112      Returns the starting position for the next gzread or gzwrite on the
1113    given compressed file. This position represents a number of bytes in the
1114    uncompressed data stream.
1115 
1116    gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
1117 */
1118 
1119 ZEXTERN int ZEXPORT gzeof __P((gzFile file));
1120 /*
1121      Returns 1 when EOF has previously been detected reading the given
1122    input stream, otherwise zero.
1123 */
1124 
1125 ZEXTERN int ZEXPORT    gzclose __P((gzFile file));
1126 /*
1127      Flushes all pending output if necessary, closes the compressed file
1128    and deallocates all the (de)compression state. The return value is the zlib
1129    error number (see function gzerror below).
1130 */
1131 
1132 ZEXTERN const char * ZEXPORT gzerror __P((gzFile file, int *errnum));
1133 /*
1134      Returns the error message for the last error which occurred on the
1135    given compressed file. errnum is set to zlib error number. If an
1136    error occurred in the file system and not in the compression library,
1137    errnum is set to Z_ERRNO and the application may consult errno
1138    to get the exact error code.
1139 */
1140 
1141                         /* checksum functions */
1142 
1143 /*
1144      These functions are not related to compression but are exported
1145    anyway because they might be useful in applications using the
1146    compression library.
1147 */
1148 
1149 ZEXTERN uLong ZEXPORT adler32 __P((uLong adler, const Bytef *buf, uInt len));
1150 
1151 /*
1152      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
1153    return the updated checksum. If buf is NULL, this function returns
1154    the required initial value for the checksum.
1155    An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
1156    much faster. Usage example:
1157 
1158      uLong adler = adler32(0L, Z_NULL, 0);
1159 
1160      while (read_buffer(buffer, length) != EOF) {
1161        adler = adler32(adler, buffer, length);
1162      }
1163      if (adler != original_adler) error();
1164 */
1165 
1166 ZEXTERN uLong ZEXPORT crc32   __P((uLong crc, const Bytef *buf, uInt len));
1167 /*
1168      Update a running crc with the bytes buf[0..len-1] and return the updated
1169    crc. If buf is NULL, this function returns the required initial value
1170    for the crc. Pre- and post-conditioning (one's complement) is performed
1171    within this function so it shouldn't be done by the application.
1172    Usage example:
1173 
1174      uLong crc = crc32(0L, Z_NULL, 0);
1175 
1176      while (read_buffer(buffer, length) != EOF) {
1177        crc = crc32(crc, buffer, length);
1178      }
1179      if (crc != original_crc) error();
1180 */
1181 
1182 
1183                         /* various hacks, don't look :) */
1184 
1185 /* deflateInit and inflateInit are macros to allow checking the zlib version
1186  * and the compiler's view of z_stream:
1187  */
1188 ZEXTERN int ZEXPORT deflateInit_ __P((z_streamp strm, int level,
1189                                      const char *version, int stream_size));
1190 ZEXTERN int ZEXPORT inflateInit_ __P((z_streamp strm,
1191                                      const char *version, int stream_size));
1192 ZEXTERN int ZEXPORT deflateInit2_ __P((z_streamp strm, int  level, int  method,
1193                                       int windowBits, int memLevel,
1194                                       int strategy, const char *version,
1195                                       int stream_size));
1196 ZEXTERN int ZEXPORT inflateInit2_ __P((z_streamp strm, int  windowBits,
1197                                       const char *version, int stream_size));
1198 #define deflateInit(strm, level) \
1199         deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
1200 #define inflateInit(strm) \
1201         inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
1202 #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
1203         deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
1204                       (strategy),           ZLIB_VERSION, sizeof(z_stream))
1205 #define inflateInit2(strm, windowBits) \
1206         inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
1207 
1208 
1209 #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
1210     struct internal_state {int dummy;}; /* hack for buggy compilers */
1211 #endif
1212 
1213 ZEXTERN const char   * ZEXPORT zError           __P((int err));
1214 ZEXTERN int            ZEXPORT inflateSyncPoint __P((z_streamp z));
1215 ZEXTERN const uLongf * ZEXPORT get_crc_table    __P((void));
1216 
1217 #ifdef __cplusplus
1218 }
1219 #endif
1220 
1221 #endif /* _ZLIB_H */
1222 /* -- zlib.h */
1223