Home | History | Annotate | Line # | Download | only in net
zlib.h revision 1.10
      1 /* $NetBSD: zlib.h,v 1.10 2005/12/10 23:21:39 elad 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 (at) gzip.org          madler (at) 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 _NET_ZLIB_H_
     34 #define _NET_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.10 2005/12/10 23:21:39 elad 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, uInt, uInt));
    355 typedef void   (*free_func)  __P((voidpf, voidpf));
    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     const 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, int));
    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, int));
    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));
    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));
    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, int));
    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));
    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, int, int, int, int, int));
    704 
    705      This is another version of deflateInit with more compression options. The
    706    fields next_in, zalloc, zfree and opaque must be initialized before by
    707    the caller.
    708 
    709      The method parameter is the compression method. It must be Z_DEFLATED in
    710    this version of the library.
    711 
    712      The windowBits parameter is the base two logarithm of the window size
    713    (the size of the history buffer).  It should be in the range 8..15 for this
    714    version of the library. Larger values of this parameter result in better
    715    compression at the expense of memory usage. The default value is 15 if
    716    deflateInit is used instead.
    717 
    718      The memLevel parameter specifies how much memory should be allocated
    719    for the internal compression state. memLevel=1 uses minimum memory but
    720    is slow and reduces compression ratio; memLevel=9 uses maximum memory
    721    for optimal speed. The default value is 8. See zconf.h for total memory
    722    usage as a function of windowBits and memLevel.
    723 
    724      The strategy parameter is used to tune the compression algorithm. Use the
    725    value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
    726    filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
    727    string match).  Filtered data consists mostly of small values with a
    728    somewhat random distribution. In this case, the compression algorithm is
    729    tuned to compress them better. The effect of Z_FILTERED is to force more
    730    Huffman coding and less string matching; it is somewhat intermediate
    731    between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
    732    the compression ratio but not the correctness of the compressed output even
    733    if it is not set appropriately.
    734 
    735       deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    736    memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
    737    method). msg is set to null if there is no error message.  deflateInit2 does
    738    not perform any compression: this will be done by deflate().
    739 */
    740 
    741 ZEXTERN int ZEXPORT deflateSetDictionary __P((z_streamp, const Bytef *, uInt));
    742 /*
    743      Initializes the compression dictionary from the given byte sequence
    744    without producing any compressed output. This function must be called
    745    immediately after deflateInit, deflateInit2 or deflateReset, before any
    746    call of deflate. The compressor and decompressor must use exactly the same
    747    dictionary (see inflateSetDictionary).
    748 
    749      The dictionary should consist of strings (byte sequences) that are likely
    750    to be encountered later in the data to be compressed, with the most commonly
    751    used strings preferably put towards the end of the dictionary. Using a
    752    dictionary is most useful when the data to be compressed is short and can be
    753    predicted with good accuracy; the data can then be compressed better than
    754    with the default empty dictionary.
    755 
    756      Depending on the size of the compression data structures selected by
    757    deflateInit or deflateInit2, a part of the dictionary may in effect be
    758    discarded, for example if the dictionary is larger than the window size in
    759    deflate or deflate2. Thus the strings most likely to be useful should be
    760    put at the end of the dictionary, not at the front.
    761 
    762      Upon return of this function, strm->adler is set to the Adler32 value
    763    of the dictionary; the decompressor may later use this value to determine
    764    which dictionary has been used by the compressor. (The Adler32 value
    765    applies to the whole dictionary even if only a subset of the dictionary is
    766    actually used by the compressor.)
    767 
    768      deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
    769    parameter is invalid (such as NULL dictionary) or the stream state is
    770    inconsistent (for example if deflate has already been called for this stream
    771    or if the compression method is bsort). deflateSetDictionary does not
    772    perform any compression: this will be done by deflate().
    773 */
    774 
    775 ZEXTERN int ZEXPORT deflateCopy __P((z_streamp, z_streamp));
    776 /*
    777      Sets the destination stream as a complete copy of the source stream.
    778 
    779      This function can be useful when several compression strategies will be
    780    tried, for example when there are several ways of pre-processing the input
    781    data with a filter. The streams that will be discarded should then be freed
    782    by calling deflateEnd.  Note that deflateCopy duplicates the internal
    783    compression state which can be quite large, so this strategy is slow and
    784    can consume lots of memory.
    785 
    786      deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
    787    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
    788    (such as zalloc being NULL). msg is left unchanged in both source and
    789    destination.
    790 */
    791 
    792 extern int inflateIncomp __P((z_stream *));
    793 /*
    794      This function adds the data at next_in (avail_in bytes) to the output
    795    history without performing any output.  There must be no pending output,
    796    and the decompressor must be expecting to see the start of a block.
    797    Calling this function is equivalent to decompressing a stored block
    798    containing the data at next_in (except that the data is not output).
    799 */
    800 
    801 ZEXTERN int ZEXPORT deflateReset __P((z_streamp));
    802 /*
    803      This function is equivalent to deflateEnd followed by deflateInit,
    804    but does not free and reallocate all the internal compression state.
    805    The stream will keep the same compression level and any other attributes
    806    that may have been set by deflateInit2.
    807 
    808       deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
    809    stream state was inconsistent (such as zalloc or state being NULL).
    810 */
    811 
    812 ZEXTERN int ZEXPORT deflateParams __P((z_streamp, int, int));
    813 /*
    814      Dynamically update the compression level and compression strategy.  The
    815    interpretation of level and strategy is as in deflateInit2.  This can be
    816    used to switch between compression and straight copy of the input data, or
    817    to switch to a different kind of input data requiring a different
    818    strategy. If the compression level is changed, the input available so far
    819    is compressed with the old level (and may be flushed); the new level will
    820    take effect only at the next call of deflate().
    821 
    822      Before the call of deflateParams, the stream state must be set as for
    823    a call of deflate(), since the currently available input may have to
    824    be compressed and flushed. In particular, strm->avail_out must be non-zero.
    825 
    826      deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
    827    stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
    828    if strm->avail_out was zero.
    829 */
    830 
    831 ZEXTERN int ZEXPORT deflateOutputPending __P((z_streamp));
    832 /*
    833      Returns the number of bytes of output which are immediately
    834    available from the compressor (i.e. without any further input
    835    or flush).
    836 */
    837 
    838 /*
    839 ZEXTERN int ZEXPORT inflateInit2 __P((z_streamp, int));
    840 
    841      This is another version of inflateInit with an extra parameter. The
    842    fields next_in, avail_in, zalloc, zfree and opaque must be initialized
    843    before by the caller.
    844 
    845      The windowBits parameter is the base two logarithm of the maximum window
    846    size (the size of the history buffer).  It should be in the range 8..15 for
    847    this version of the library. The default value is 15 if inflateInit is used
    848    instead. If a compressed stream with a larger window size is given as
    849    input, inflate() will return with the error code Z_DATA_ERROR instead of
    850    trying to allocate a larger window.
    851 
    852       inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    853    memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
    854    memLevel). msg is set to null if there is no error message.  inflateInit2
    855    does not perform any decompression apart from reading the zlib header if
    856    present: this will be done by inflate(). (So next_in and avail_in may be
    857    modified, but next_out and avail_out are unchanged.)
    858 */
    859 
    860 ZEXTERN int ZEXPORT inflateSetDictionary __P((z_streamp, const Bytef *, uInt));
    861 /*
    862      Initializes the decompression dictionary from the given uncompressed byte
    863    sequence. This function must be called immediately after a call of inflate
    864    if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
    865    can be determined from the Adler32 value returned by this call of
    866    inflate. The compressor and decompressor must use exactly the same
    867    dictionary (see deflateSetDictionary).
    868 
    869      inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
    870    parameter is invalid (such as NULL dictionary) or the stream state is
    871    inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
    872    expected one (incorrect Adler32 value). inflateSetDictionary does not
    873    perform any decompression: this will be done by subsequent calls of
    874    inflate().
    875 */
    876 
    877 ZEXTERN int ZEXPORT inflateSync __P((z_streamp));
    878 /*
    879     Skips invalid compressed data until a full flush point (see above the
    880   description of deflate with Z_FULL_FLUSH) can be found, or until all
    881   available input is skipped. No output is provided.
    882 
    883     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
    884   if no more input was provided, Z_DATA_ERROR if no flush point has been found,
    885   or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
    886   case, the application may save the current current value of total_in which
    887   indicates where valid compressed data was found. In the error case, the
    888   application may repeatedly call inflateSync, providing more input each time,
    889   until success or end of the input data.
    890 */
    891 
    892 ZEXTERN int ZEXPORT inflateReset __P((z_streamp));
    893 /*
    894      This function is equivalent to inflateEnd followed by inflateInit,
    895    but does not free and reallocate all the internal decompression state.
    896    The stream will keep attributes that may have been set by inflateInit2.
    897 
    898       inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
    899    stream state was inconsistent (such as zalloc or state being NULL).
    900 */
    901 
    902 
    903                         /* utility functions */
    904 
    905 /*
    906      The following utility functions are implemented on top of the
    907    basic stream-oriented functions. To simplify the interface, some
    908    default options are assumed (compression level and memory usage,
    909    standard memory allocation functions). The source code of these
    910    utility functions can easily be modified if you need special options.
    911 */
    912 
    913 ZEXTERN int ZEXPORT compress __P((Bytef *, uLongf *, const Bytef *, uLong));
    914 /*
    915      Compresses the source buffer into the destination buffer.  sourceLen is
    916    the byte length of the source buffer. Upon entry, destLen is the total
    917    size of the destination buffer, which must be at least 0.1% larger than
    918    sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
    919    compressed buffer.
    920      This function can be used to compress a whole file at once if the
    921    input file is mmap'ed.
    922      compress returns Z_OK if success, Z_MEM_ERROR if there was not
    923    enough memory, Z_BUF_ERROR if there was not enough room in the output
    924    buffer.
    925 */
    926 
    927 ZEXTERN int ZEXPORT compress2 __P((Bytef *, uLongf *, const Bytef *,
    928 	    uLong, int));
    929 /*
    930      Compresses the source buffer into the destination buffer. The level
    931    parameter has the same meaning as in deflateInit.  sourceLen is the byte
    932    length of the source buffer. Upon entry, destLen is the total size of the
    933    destination buffer, which must be at least 0.1% larger than sourceLen plus
    934    12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
    935 
    936      compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    937    memory, Z_BUF_ERROR if there was not enough room in the output buffer,
    938    Z_STREAM_ERROR if the level parameter is invalid.
    939 */
    940 
    941 ZEXTERN int ZEXPORT uncompress __P((Bytef *, uLongf *, const Bytef *, uLong));
    942 /*
    943      Decompresses the source buffer into the destination buffer.  sourceLen is
    944    the byte length of the source buffer. Upon entry, destLen is the total
    945    size of the destination buffer, which must be large enough to hold the
    946    entire uncompressed data. (The size of the uncompressed data must have
    947    been saved previously by the compressor and transmitted to the decompressor
    948    by some mechanism outside the scope of this compression library.)
    949    Upon exit, destLen is the actual size of the compressed buffer.
    950      This function can be used to decompress a whole file at once if the
    951    input file is mmap'ed.
    952 
    953      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
    954    enough memory, Z_BUF_ERROR if there was not enough room in the output
    955    buffer, or Z_DATA_ERROR if the input data was corrupted.
    956 */
    957 
    958 
    959 typedef voidp gzFile;
    960 
    961 ZEXTERN gzFile ZEXPORT gzopen  __P((const char *, const char *));
    962 /*
    963      Opens a gzip (.gz) file for reading or writing. The mode parameter
    964    is as in fopen ("rb" or "wb") but can also include a compression level
    965    ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
    966    Huffman only compression as in "wb1h". (See the description
    967    of deflateInit2 for more information about the strategy parameter.)
    968 
    969      gzopen can be used to read a file which is not in gzip format; in this
    970    case gzread will directly read from the file without decompression.
    971 
    972      gzopen returns NULL if the file could not be opened or if there was
    973    insufficient memory to allocate the (de)compression state; errno
    974    can be checked to distinguish the two cases (if errno is zero, the
    975    zlib error is Z_MEM_ERROR).  */
    976 
    977 ZEXTERN gzFile ZEXPORT gzdopen  __P((int, const char *));
    978 /*
    979      gzdopen() associates a gzFile with the file descriptor fd.  File
    980    descriptors are obtained from calls like open, dup, creat, pipe or
    981    fileno (in the file has been previously opened with fopen).
    982    The mode parameter is as in gzopen.
    983      The next call of gzclose on the returned gzFile will also close the
    984    file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
    985    descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
    986      gzdopen returns NULL if there was insufficient memory to allocate
    987    the (de)compression state.
    988 */
    989 
    990 ZEXTERN int ZEXPORT gzsetparams __P((gzFile, int, int));
    991 /*
    992      Dynamically update the compression level or strategy. See the description
    993    of deflateInit2 for the meaning of these parameters.
    994      gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
    995    opened for writing.
    996 */
    997 
    998 ZEXTERN int ZEXPORT    gzread  __P((gzFile, voidp, unsigned));
    999 /*
   1000      Reads the given number of uncompressed bytes from the compressed file.
   1001    If the input file was not in gzip format, gzread copies the given number
   1002    of bytes into the buffer.
   1003      gzread returns the number of uncompressed bytes actually read (0 for
   1004    end of file, -1 for error). */
   1005 
   1006 ZEXTERN int ZEXPORT    gzwrite __P((gzFile, const voidp, unsigned));
   1007 /*
   1008      Writes the given number of uncompressed bytes into the compressed file.
   1009    gzwrite returns the number of uncompressed bytes actually written
   1010    (0 in case of error).
   1011 */
   1012 
   1013 ZEXTERN int ZEXPORTVA   gzprintf __P((gzFile, const char *, ...))
   1014 		__attribute__((__format__(__printf__, 2, 3)));
   1015 /*
   1016      Converts, formats, and writes the args to the compressed file under
   1017    control of the format string, as in fprintf. gzprintf returns the number of
   1018    uncompressed bytes actually written (0 in case of error).
   1019 */
   1020 
   1021 ZEXTERN int ZEXPORT gzputs __P((gzFile, const char *));
   1022 /*
   1023       Writes the given null-terminated string to the compressed file, excluding
   1024    the terminating null character.
   1025       gzputs returns the number of characters written, or -1 in case of error.
   1026 */
   1027 
   1028 ZEXTERN char * ZEXPORT gzgets __P((gzFile, char *, int));
   1029 /*
   1030       Reads bytes from the compressed file until len-1 characters are read, or
   1031    a newline character is read and transferred to buf, or an end-of-file
   1032    condition is encountered.  The string is then terminated with a null
   1033    character.
   1034       gzgets returns buf, or Z_NULL in case of error.
   1035 */
   1036 
   1037 ZEXTERN int ZEXPORT    gzputc __P((gzFile, int));
   1038 /*
   1039       Writes c, converted to an unsigned char, into the compressed file.
   1040    gzputc returns the value that was written, or -1 in case of error.
   1041 */
   1042 
   1043 ZEXTERN int ZEXPORT    gzgetc __P((gzFile));
   1044 /*
   1045       Reads one byte from the compressed file. gzgetc returns this byte
   1046    or -1 in case of end of file or error.
   1047 */
   1048 
   1049 ZEXTERN int ZEXPORT    gzflush __P((gzFile, int));
   1050 /*
   1051      Flushes all pending output into the compressed file. The parameter
   1052    flush is as in the deflate() function. The return value is the zlib
   1053    error number (see function gzerror below). gzflush returns Z_OK if
   1054    the flush parameter is Z_FINISH and all output could be flushed.
   1055      gzflush should be called only when strictly necessary because it can
   1056    degrade compression.
   1057 
   1058 */
   1059 
   1060 /*
   1061  * NetBSD note:
   1062  * "long" gzseek has been there till Oct 1999 (1.4L), which was wrong.
   1063  */
   1064 ZEXTERN z_off_t ZEXPORT    gzseek __P((gzFile, z_off_t, int));
   1065 /*
   1066       Sets the starting position for the next gzread or gzwrite on the
   1067    given compressed file. The offset represents a number of bytes in the
   1068    uncompressed data stream. The whence parameter is defined as in lseek(2);
   1069    the value SEEK_END is not supported.
   1070      If the file is opened for reading, this function is emulated but can be
   1071    extremely slow. If the file is opened for writing, only forward seeks are
   1072    supported; gzseek then compresses a sequence of zeroes up to the new
   1073    starting position.
   1074 
   1075       gzseek returns the resulting offset location as measured in bytes from
   1076    the beginning of the uncompressed stream, or -1 in case of error, in
   1077    particular if the file is opened for writing and the new starting position
   1078    would be before the current position.
   1079 */
   1080 
   1081 ZEXTERN int ZEXPORT    gzrewind __P((gzFile));
   1082 /*
   1083      Rewinds the given file. This function is supported only for reading.
   1084 
   1085    gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
   1086 */
   1087 
   1088 /*
   1089  * NetBSD note:
   1090  * "long" gztell has been there till Oct 1999 (1.4L), which was wrong.
   1091  */
   1092 ZEXTERN z_off_t ZEXPORT    gztell __P((gzFile));
   1093 /*
   1094      Returns the starting position for the next gzread or gzwrite on the
   1095    given compressed file. This position represents a number of bytes in the
   1096    uncompressed data stream.
   1097 
   1098    gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
   1099 */
   1100 
   1101 ZEXTERN int ZEXPORT gzeof __P((gzFile));
   1102 /*
   1103      Returns 1 when EOF has previously been detected reading the given
   1104    input stream, otherwise zero.
   1105 */
   1106 
   1107 ZEXTERN int ZEXPORT    gzclose __P((gzFile));
   1108 /*
   1109      Flushes all pending output if necessary, closes the compressed file
   1110    and deallocates all the (de)compression state. The return value is the zlib
   1111    error number (see function gzerror below).
   1112 */
   1113 
   1114 ZEXTERN const char * ZEXPORT gzerror __P((gzFile, int *));
   1115 /*
   1116      Returns the error message for the last error which occurred on the
   1117    given compressed file. errnum is set to zlib error number. If an
   1118    error occurred in the file system and not in the compression library,
   1119    errnum is set to Z_ERRNO and the application may consult errno
   1120    to get the exact error code.
   1121 */
   1122 
   1123                         /* checksum functions */
   1124 
   1125 /*
   1126      These functions are not related to compression but are exported
   1127    anyway because they might be useful in applications using the
   1128    compression library.
   1129 */
   1130 
   1131 ZEXTERN uLong ZEXPORT adler32 __P((uLong, const Bytef *, uInt));
   1132 
   1133 /*
   1134      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
   1135    return the updated checksum. If buf is NULL, this function returns
   1136    the required initial value for the checksum.
   1137    An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
   1138    much faster. Usage example:
   1139 
   1140      uLong adler = adler32(0L, Z_NULL, 0);
   1141 
   1142      while (read_buffer(buffer, length) != EOF) {
   1143        adler = adler32(adler, buffer, length);
   1144      }
   1145      if (adler != original_adler) error();
   1146 */
   1147 
   1148 ZEXTERN uLong ZEXPORT crc32   __P((uLong, const Bytef *, uInt));
   1149 /*
   1150      Update a running crc with the bytes buf[0..len-1] and return the updated
   1151    crc. If buf is NULL, this function returns the required initial value
   1152    for the crc. Pre- and post-conditioning (one's complement) is performed
   1153    within this function so it shouldn't be done by the application.
   1154    Usage example:
   1155 
   1156      uLong crc = crc32(0L, Z_NULL, 0);
   1157 
   1158      while (read_buffer(buffer, length) != EOF) {
   1159        crc = crc32(crc, buffer, length);
   1160      }
   1161      if (crc != original_crc) error();
   1162 */
   1163 
   1164 
   1165                         /* various hacks, don't look :) */
   1166 
   1167 /* deflateInit and inflateInit are macros to allow checking the zlib version
   1168  * and the compiler's view of z_stream:
   1169  */
   1170 ZEXTERN int ZEXPORT deflateInit_ __P((z_streamp, int, const char *, int));
   1171 ZEXTERN int ZEXPORT inflateInit_ __P((z_streamp, const char *, int));
   1172 ZEXTERN int ZEXPORT deflateInit2_ __P((z_streamp, int, int, int, int,
   1173                                       int, const char *, int));
   1174 ZEXTERN int ZEXPORT inflateInit2_ __P((z_streamp, int, const char *, int));
   1175 #define deflateInit(strm, level) \
   1176         deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
   1177 #define inflateInit(strm) \
   1178         inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
   1179 #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
   1180         deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
   1181                       (strategy),           ZLIB_VERSION, sizeof(z_stream))
   1182 #define inflateInit2(strm, windowBits) \
   1183         inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
   1184 
   1185 
   1186 #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
   1187     struct internal_state {int dummy;}; /* hack for buggy compilers */
   1188 #endif
   1189 
   1190 ZEXTERN const char   * ZEXPORT zError           __P((int));
   1191 ZEXTERN int            ZEXPORT inflateSyncPoint __P((z_streamp));
   1192 ZEXTERN const uLongf * ZEXPORT get_crc_table    __P((void));
   1193 
   1194 #ifdef __cplusplus
   1195 }
   1196 #endif
   1197 
   1198 #endif /* !_NET_ZLIB_H_ */
   1199 /* -- zlib.h */
   1200