File Annotation

Not logged in
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
5128eecc9f 2011-02-23        kinaba: /*= This source is Modified a little by K.INABA.              =*/
5128eecc9f 2011-02-23        kinaba: /*=                                                           =*/
5128eecc9f 2011-02-23        kinaba: /*= Since 'XacRett' doesn't compress, I removed               =*/
5128eecc9f 2011-02-23        kinaba: /*=  compression codes by #ifdef KI_GZ_NO_COMPRESSION .       =*/
5128eecc9f 2011-02-23        kinaba: /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
5128eecc9f 2011-02-23        kinaba: #ifndef KI_GZ_NO_COMPRESSION
5128eecc9f 2011-02-23        kinaba: #define KI_GZ_NO_COMPRESSION
5128eecc9f 2011-02-23        kinaba: #endif
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /* zlib.h -- interface of the 'zlib' general purpose compression library
5128eecc9f 2011-02-23        kinaba:   version 1.1.3, July 9th, 1998
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   This software is provided 'as-is', without any express or implied
5128eecc9f 2011-02-23        kinaba:   warranty.  In no event will the authors be held liable for any damages
5128eecc9f 2011-02-23        kinaba:   arising from the use of this software.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   Permission is granted to anyone to use this software for any purpose,
5128eecc9f 2011-02-23        kinaba:   including commercial applications, and to alter it and redistribute it
5128eecc9f 2011-02-23        kinaba:   freely, subject to the following restrictions:
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   1. The origin of this software must not be misrepresented; you must not
5128eecc9f 2011-02-23        kinaba:      claim that you wrote the original software. If you use this software
5128eecc9f 2011-02-23        kinaba:      in a product, an acknowledgment in the product documentation would be
5128eecc9f 2011-02-23        kinaba:      appreciated but is not required.
5128eecc9f 2011-02-23        kinaba:   2. Altered source versions must be plainly marked as such, and must not be
5128eecc9f 2011-02-23        kinaba:      misrepresented as being the original software.
5128eecc9f 2011-02-23        kinaba:   3. This notice may not be removed or altered from any source distribution.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   Jean-loup Gailly        Mark Adler
5128eecc9f 2011-02-23        kinaba:   jloup@gzip.org          madler@alumni.caltech.edu
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   The data format used by the zlib library is described by RFCs (Request for
5128eecc9f 2011-02-23        kinaba:   Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
5128eecc9f 2011-02-23        kinaba:   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #ifndef _ZLIB_H
5128eecc9f 2011-02-23        kinaba: #define _ZLIB_H
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #include "zconf.h"
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #ifdef __cplusplus
5128eecc9f 2011-02-23        kinaba: extern "C" {
5128eecc9f 2011-02-23        kinaba: #endif
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #define ZLIB_VERSION "1.1.3"
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      The 'zlib' compression library provides in-memory compression and
5128eecc9f 2011-02-23        kinaba:   decompression functions, including integrity checks of the uncompressed
5128eecc9f 2011-02-23        kinaba:   data.  This version of the library supports only one compression method
5128eecc9f 2011-02-23        kinaba:   (deflation) but other algorithms will be added later and will have the same
5128eecc9f 2011-02-23        kinaba:   stream interface.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      Compression can be done in a single step if the buffers are large
5128eecc9f 2011-02-23        kinaba:   enough (for example if an input file is mmap'ed), or can be done by
5128eecc9f 2011-02-23        kinaba:   repeated calls of the compression function.  In the latter case, the
5128eecc9f 2011-02-23        kinaba:   application must provide more input and/or consume the output
5128eecc9f 2011-02-23        kinaba:   (providing more output space) before each call.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      The library also supports reading and writing files in gzip (.gz) format
5128eecc9f 2011-02-23        kinaba:   with an interface similar to that of stdio.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      The library does not install any signal handler. The decoder checks
5128eecc9f 2011-02-23        kinaba:   the consistency of the compressed data, so the library should never
5128eecc9f 2011-02-23        kinaba:   crash even in case of corrupted input.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
5128eecc9f 2011-02-23        kinaba: typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: struct internal_state;
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: typedef struct z_stream_s {
5128eecc9f 2011-02-23        kinaba:     Bytef    *next_in;  /* next input byte */
5128eecc9f 2011-02-23        kinaba:     uInt     avail_in;  /* number of bytes available at next_in */
5128eecc9f 2011-02-23        kinaba:     uLong    total_in;  /* total nb of input bytes read so far */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     Bytef    *next_out; /* next output byte should be put there */
5128eecc9f 2011-02-23        kinaba:     uInt     avail_out; /* remaining free space at next_out */
5128eecc9f 2011-02-23        kinaba:     uLong    total_out; /* total nb of bytes output so far */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     char     *msg;      /* last error message, NULL if no error */
5128eecc9f 2011-02-23        kinaba:     struct internal_state FAR *state; /* not visible by applications */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     alloc_func zalloc;  /* used to allocate the internal state */
5128eecc9f 2011-02-23        kinaba:     free_func  zfree;   /* used to free the internal state */
5128eecc9f 2011-02-23        kinaba:     voidpf     opaque;  /* private data object passed to zalloc and zfree */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     int     data_type;  /* best guess about the data type: ascii or binary */
5128eecc9f 2011-02-23        kinaba:     uLong   adler;      /* adler32 value of the uncompressed data */
5128eecc9f 2011-02-23        kinaba:     uLong   reserved;   /* reserved for future use */
5128eecc9f 2011-02-23        kinaba: } z_stream;
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: typedef z_stream FAR *z_streamp;
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:    The application must update next_in and avail_in when avail_in has
5128eecc9f 2011-02-23        kinaba:    dropped to zero. It must update next_out and avail_out when avail_out
5128eecc9f 2011-02-23        kinaba:    has dropped to zero. The application must initialize zalloc, zfree and
5128eecc9f 2011-02-23        kinaba:    opaque before calling the init function. All other fields are set by the
5128eecc9f 2011-02-23        kinaba:    compression library and must not be updated by the application.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:    The opaque value provided by the application will be passed as the first
5128eecc9f 2011-02-23        kinaba:    parameter for calls of zalloc and zfree. This can be useful for custom
5128eecc9f 2011-02-23        kinaba:    memory management. The compression library attaches no meaning to the
5128eecc9f 2011-02-23        kinaba:    opaque value.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:    zalloc must return Z_NULL if there is not enough memory for the object.
5128eecc9f 2011-02-23        kinaba:    If zlib is used in a multi-threaded application, zalloc and zfree must be
5128eecc9f 2011-02-23        kinaba:    thread safe.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:    On 16-bit systems, the functions zalloc and zfree must be able to allocate
5128eecc9f 2011-02-23        kinaba:    exactly 65536 bytes, but will not be required to allocate more than this
5128eecc9f 2011-02-23        kinaba:    if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
5128eecc9f 2011-02-23        kinaba:    pointers returned by zalloc for objects of exactly 65536 bytes *must*
5128eecc9f 2011-02-23        kinaba:    have their offset normalized to zero. The default allocation function
5128eecc9f 2011-02-23        kinaba:    provided by this library ensures this (see zutil.c). To reduce memory
5128eecc9f 2011-02-23        kinaba:    requirements and avoid any allocation of 64K objects, at the expense of
5128eecc9f 2011-02-23        kinaba:    compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:    The fields total_in and total_out can be used for statistics or
5128eecc9f 2011-02-23        kinaba:    progress reports. After compression, total_in holds the total size of
5128eecc9f 2011-02-23        kinaba:    the uncompressed data and may be saved for use in the decompressor
5128eecc9f 2011-02-23        kinaba:    (particularly if the decompressor wants to decompress everything in
5128eecc9f 2011-02-23        kinaba:    a single step).
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:                         /* constants */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #define Z_NO_FLUSH      0
5128eecc9f 2011-02-23        kinaba: #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
5128eecc9f 2011-02-23        kinaba: #define Z_SYNC_FLUSH    2
5128eecc9f 2011-02-23        kinaba: #define Z_FULL_FLUSH    3
5128eecc9f 2011-02-23        kinaba: #define Z_FINISH        4
5128eecc9f 2011-02-23        kinaba: /* Allowed flush values; see deflate() below for details */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #define Z_OK            0
5128eecc9f 2011-02-23        kinaba: #define Z_STREAM_END    1
5128eecc9f 2011-02-23        kinaba: #define Z_NEED_DICT     2
5128eecc9f 2011-02-23        kinaba: #define Z_ERRNO        (-1)
5128eecc9f 2011-02-23        kinaba: #define Z_STREAM_ERROR (-2)
5128eecc9f 2011-02-23        kinaba: #define Z_DATA_ERROR   (-3)
5128eecc9f 2011-02-23        kinaba: #define Z_MEM_ERROR    (-4)
5128eecc9f 2011-02-23        kinaba: #define Z_BUF_ERROR    (-5)
5128eecc9f 2011-02-23        kinaba: #define Z_VERSION_ERROR (-6)
5128eecc9f 2011-02-23        kinaba: /* Return codes for the compression/decompression functions. Negative
5128eecc9f 2011-02-23        kinaba:  * values are errors, positive values are used for special but normal events.
5128eecc9f 2011-02-23        kinaba:  */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #define Z_NO_COMPRESSION         0
5128eecc9f 2011-02-23        kinaba: #define Z_BEST_SPEED             1
5128eecc9f 2011-02-23        kinaba: #define Z_BEST_COMPRESSION       9
5128eecc9f 2011-02-23        kinaba: #define Z_DEFAULT_COMPRESSION  (-1)
5128eecc9f 2011-02-23        kinaba: /* compression levels */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #define Z_FILTERED            1
5128eecc9f 2011-02-23        kinaba: #define Z_HUFFMAN_ONLY        2
5128eecc9f 2011-02-23        kinaba: #define Z_DEFAULT_STRATEGY    0
5128eecc9f 2011-02-23        kinaba: /* compression strategy; see deflateInit2() below for details */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #define Z_BINARY   0
5128eecc9f 2011-02-23        kinaba: #define Z_ASCII    1
5128eecc9f 2011-02-23        kinaba: #define Z_UNKNOWN  2
5128eecc9f 2011-02-23        kinaba: /* Possible values of the data_type field */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #define Z_DEFLATED   8
5128eecc9f 2011-02-23        kinaba: /* The deflate compression method (the only one supported in this version) */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #define zlib_version zlibVersion()
5128eecc9f 2011-02-23        kinaba: /* for compatibility with versions < 1.0.2 */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:                         /* basic functions */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN const char * ZEXPORT zlibVersion OF((void));
5128eecc9f 2011-02-23        kinaba: /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
5128eecc9f 2011-02-23        kinaba:    If the first character differs, the library code actually used is
5128eecc9f 2011-02-23        kinaba:    not compatible with the zlib.h header file used by the application.
5128eecc9f 2011-02-23        kinaba:    This check is automatically made by deflateInit and inflateInit.
5128eecc9f 2011-02-23        kinaba:  */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      Initializes the internal stream state for compression. The fields
5128eecc9f 2011-02-23        kinaba:    zalloc, zfree and opaque must be initialized before by the caller.
5128eecc9f 2011-02-23        kinaba:    If zalloc and zfree are set to Z_NULL, deflateInit updates them to
5128eecc9f 2011-02-23        kinaba:    use default allocation functions.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
5128eecc9f 2011-02-23        kinaba:    1 gives best speed, 9 gives best compression, 0 gives no compression at
5128eecc9f 2011-02-23        kinaba:    all (the input data is simply copied a block at a time).
5128eecc9f 2011-02-23        kinaba:    Z_DEFAULT_COMPRESSION requests a default compromise between speed and
5128eecc9f 2011-02-23        kinaba:    compression (currently equivalent to level 6).
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
5128eecc9f 2011-02-23        kinaba:    enough memory, Z_STREAM_ERROR if level is not a valid compression level,
5128eecc9f 2011-02-23        kinaba:    Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
5128eecc9f 2011-02-23        kinaba:    with the version assumed by the caller (ZLIB_VERSION).
5128eecc9f 2011-02-23        kinaba:    msg is set to null if there is no error message.  deflateInit does not
5128eecc9f 2011-02-23        kinaba:    perform any compression: this will be done by deflate().
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #ifndef KI_GZ_NO_COMPRESSION
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:     deflate compresses as much data as possible, and stops when the input
5128eecc9f 2011-02-23        kinaba:   buffer becomes empty or the output buffer becomes full. It may introduce some
5128eecc9f 2011-02-23        kinaba:   output latency (reading input without producing any output) except when
5128eecc9f 2011-02-23        kinaba:   forced to flush.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     The detailed semantics are as follows. deflate performs one or both of the
5128eecc9f 2011-02-23        kinaba:   following actions:
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   - Compress more input starting at next_in and update next_in and avail_in
5128eecc9f 2011-02-23        kinaba:     accordingly. If not all input can be processed (because there is not
5128eecc9f 2011-02-23        kinaba:     enough room in the output buffer), next_in and avail_in are updated and
5128eecc9f 2011-02-23        kinaba:     processing will resume at this point for the next call of deflate().
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   - Provide more output starting at next_out and update next_out and avail_out
5128eecc9f 2011-02-23        kinaba:     accordingly. This action is forced if the parameter flush is non zero.
5128eecc9f 2011-02-23        kinaba:     Forcing flush frequently degrades the compression ratio, so this parameter
5128eecc9f 2011-02-23        kinaba:     should be set only when necessary (in interactive applications).
5128eecc9f 2011-02-23        kinaba:     Some output may be provided even if flush is not set.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   Before the call of deflate(), the application should ensure that at least
5128eecc9f 2011-02-23        kinaba:   one of the actions is possible, by providing more input and/or consuming
5128eecc9f 2011-02-23        kinaba:   more output, and updating avail_in or avail_out accordingly; avail_out
5128eecc9f 2011-02-23        kinaba:   should never be zero before the call. The application can consume the
5128eecc9f 2011-02-23        kinaba:   compressed output when it wants, for example when the output buffer is full
5128eecc9f 2011-02-23        kinaba:   (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
5128eecc9f 2011-02-23        kinaba:   and with zero avail_out, it must be called again after making room in the
5128eecc9f 2011-02-23        kinaba:   output buffer because there might be more output pending.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
5128eecc9f 2011-02-23        kinaba:   flushed to the output buffer and the output is aligned on a byte boundary, so
5128eecc9f 2011-02-23        kinaba:   that the decompressor can get all input data available so far. (In particular
5128eecc9f 2011-02-23        kinaba:   avail_in is zero after the call if enough output space has been provided
5128eecc9f 2011-02-23        kinaba:   before the call.)  Flushing may degrade compression for some compression
5128eecc9f 2011-02-23        kinaba:   algorithms and so it should be used only when necessary.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     If flush is set to Z_FULL_FLUSH, all output is flushed as with
5128eecc9f 2011-02-23        kinaba:   Z_SYNC_FLUSH, and the compression state is reset so that decompression can
5128eecc9f 2011-02-23        kinaba:   restart from this point if previous compressed data has been damaged or if
5128eecc9f 2011-02-23        kinaba:   random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
5128eecc9f 2011-02-23        kinaba:   the compression.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     If deflate returns with avail_out == 0, this function must be called again
5128eecc9f 2011-02-23        kinaba:   with the same value of the flush parameter and more output space (updated
5128eecc9f 2011-02-23        kinaba:   avail_out), until the flush is complete (deflate returns with non-zero
5128eecc9f 2011-02-23        kinaba:   avail_out).
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     If the parameter flush is set to Z_FINISH, pending input is processed,
5128eecc9f 2011-02-23        kinaba:   pending output is flushed and deflate returns with Z_STREAM_END if there
5128eecc9f 2011-02-23        kinaba:   was enough output space; if deflate returns with Z_OK, this function must be
5128eecc9f 2011-02-23        kinaba:   called again with Z_FINISH and more output space (updated avail_out) but no
5128eecc9f 2011-02-23        kinaba:   more input data, until it returns with Z_STREAM_END or an error. After
5128eecc9f 2011-02-23        kinaba:   deflate has returned Z_STREAM_END, the only possible operations on the
5128eecc9f 2011-02-23        kinaba:   stream are deflateReset or deflateEnd.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     Z_FINISH can be used immediately after deflateInit if all the compression
5128eecc9f 2011-02-23        kinaba:   is to be done in a single step. In this case, avail_out must be at least
5128eecc9f 2011-02-23        kinaba:   0.1% larger than avail_in plus 12 bytes.  If deflate does not return
5128eecc9f 2011-02-23        kinaba:   Z_STREAM_END, then it must be called again as described above.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     deflate() sets strm->adler to the adler32 checksum of all input read
5128eecc9f 2011-02-23        kinaba:   so far (that is, total_in bytes).
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     deflate() may update data_type if it can make a good guess about
5128eecc9f 2011-02-23        kinaba:   the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
5128eecc9f 2011-02-23        kinaba:   binary. This field is only for information purposes and does not affect
5128eecc9f 2011-02-23        kinaba:   the compression algorithm in any manner.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     deflate() returns Z_OK if some progress has been made (more input
5128eecc9f 2011-02-23        kinaba:   processed or more output produced), Z_STREAM_END if all input has been
5128eecc9f 2011-02-23        kinaba:   consumed and all output has been produced (only when flush is set to
5128eecc9f 2011-02-23        kinaba:   Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
5128eecc9f 2011-02-23        kinaba:   if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
5128eecc9f 2011-02-23        kinaba:   (for example avail_in or avail_out was zero).
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      All dynamically allocated data structures for this stream are freed.
5128eecc9f 2011-02-23        kinaba:    This function discards any unprocessed input and does not flush any
5128eecc9f 2011-02-23        kinaba:    pending output.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
5128eecc9f 2011-02-23        kinaba:    stream state was inconsistent, Z_DATA_ERROR if the stream was freed
5128eecc9f 2011-02-23        kinaba:    prematurely (some input or output was discarded). In the error case,
5128eecc9f 2011-02-23        kinaba:    msg may be set but then points to a static string (which must not be
5128eecc9f 2011-02-23        kinaba:    deallocated).
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #endif /* KI_GZ_NO_COMPRESSION */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      Initializes the internal stream state for decompression. The fields
5128eecc9f 2011-02-23        kinaba:    next_in, avail_in, zalloc, zfree and opaque must be initialized before by
5128eecc9f 2011-02-23        kinaba:    the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
5128eecc9f 2011-02-23        kinaba:    value depends on the compression method), inflateInit determines the
5128eecc9f 2011-02-23        kinaba:    compression method from the zlib header and allocates all data structures
5128eecc9f 2011-02-23        kinaba:    accordingly; otherwise the allocation will be deferred to the first call of
5128eecc9f 2011-02-23        kinaba:    inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
5128eecc9f 2011-02-23        kinaba:    use default allocation functions.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
5128eecc9f 2011-02-23        kinaba:    memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
5128eecc9f 2011-02-23        kinaba:    version assumed by the caller.  msg is set to null if there is no error
5128eecc9f 2011-02-23        kinaba:    message. inflateInit does not perform any decompression apart from reading
5128eecc9f 2011-02-23        kinaba:    the zlib header if present: this will be done by inflate().  (So next_in and
5128eecc9f 2011-02-23        kinaba:    avail_in may be modified, but next_out and avail_out are unchanged.)
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:     inflate decompresses as much data as possible, and stops when the input
5128eecc9f 2011-02-23        kinaba:   buffer becomes empty or the output buffer becomes full. It may some
5128eecc9f 2011-02-23        kinaba:   introduce some output latency (reading input without producing any output)
5128eecc9f 2011-02-23        kinaba:   except when forced to flush.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   The detailed semantics are as follows. inflate performs one or both of the
5128eecc9f 2011-02-23        kinaba:   following actions:
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   - Decompress more input starting at next_in and update next_in and avail_in
5128eecc9f 2011-02-23        kinaba:     accordingly. If not all input can be processed (because there is not
5128eecc9f 2011-02-23        kinaba:     enough room in the output buffer), next_in is updated and processing
5128eecc9f 2011-02-23        kinaba:     will resume at this point for the next call of inflate().
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   - Provide more output starting at next_out and update next_out and avail_out
5128eecc9f 2011-02-23        kinaba:     accordingly.  inflate() provides as much output as possible, until there
5128eecc9f 2011-02-23        kinaba:     is no more input data or no more space in the output buffer (see below
5128eecc9f 2011-02-23        kinaba:     about the flush parameter).
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:   Before the call of inflate(), the application should ensure that at least
5128eecc9f 2011-02-23        kinaba:   one of the actions is possible, by providing more input and/or consuming
5128eecc9f 2011-02-23        kinaba:   more output, and updating the next_* and avail_* values accordingly.
5128eecc9f 2011-02-23        kinaba:   The application can consume the uncompressed output when it wants, for
5128eecc9f 2011-02-23        kinaba:   example when the output buffer is full (avail_out == 0), or after each
5128eecc9f 2011-02-23        kinaba:   call of inflate(). If inflate returns Z_OK and with zero avail_out, it
5128eecc9f 2011-02-23        kinaba:   must be called again after making room in the output buffer because there
5128eecc9f 2011-02-23        kinaba:   might be more output pending.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
5128eecc9f 2011-02-23        kinaba:   output as possible to the output buffer. The flushing behavior of inflate is
5128eecc9f 2011-02-23        kinaba:   not specified for values of the flush parameter other than Z_SYNC_FLUSH
5128eecc9f 2011-02-23        kinaba:   and Z_FINISH, but the current implementation actually flushes as much output
5128eecc9f 2011-02-23        kinaba:   as possible anyway.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     inflate() should normally be called until it returns Z_STREAM_END or an
5128eecc9f 2011-02-23        kinaba:   error. However if all decompression is to be performed in a single step
5128eecc9f 2011-02-23        kinaba:   (a single call of inflate), the parameter flush should be set to
5128eecc9f 2011-02-23        kinaba:   Z_FINISH. In this case all pending input is processed and all pending
5128eecc9f 2011-02-23        kinaba:   output is flushed; avail_out must be large enough to hold all the
5128eecc9f 2011-02-23        kinaba:   uncompressed data. (The size of the uncompressed data may have been saved
5128eecc9f 2011-02-23        kinaba:   by the compressor for this purpose.) The next operation on this stream must
5128eecc9f 2011-02-23        kinaba:   be inflateEnd to deallocate the decompression state. The use of Z_FINISH
5128eecc9f 2011-02-23        kinaba:   is never required, but can be used to inform inflate that a faster routine
5128eecc9f 2011-02-23        kinaba:   may be used for the single inflate() call.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      If a preset dictionary is needed at this point (see inflateSetDictionary
5128eecc9f 2011-02-23        kinaba:   below), inflate sets strm-adler to the adler32 checksum of the
5128eecc9f 2011-02-23        kinaba:   dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
5128eecc9f 2011-02-23        kinaba:   it sets strm->adler to the adler32 checksum of all output produced
5128eecc9f 2011-02-23        kinaba:   so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
5128eecc9f 2011-02-23        kinaba:   an error code as described below. At the end of the stream, inflate()
5128eecc9f 2011-02-23        kinaba:   checks that its computed adler32 checksum is equal to that saved by the
5128eecc9f 2011-02-23        kinaba:   compressor and returns Z_STREAM_END only if the checksum is correct.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     inflate() returns Z_OK if some progress has been made (more input processed
5128eecc9f 2011-02-23        kinaba:   or more output produced), Z_STREAM_END if the end of the compressed data has
5128eecc9f 2011-02-23        kinaba:   been reached and all uncompressed output has been produced, Z_NEED_DICT if a
5128eecc9f 2011-02-23        kinaba:   preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
5128eecc9f 2011-02-23        kinaba:   corrupted (input stream not conforming to the zlib format or incorrect
5128eecc9f 2011-02-23        kinaba:   adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
5128eecc9f 2011-02-23        kinaba:   (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
5128eecc9f 2011-02-23        kinaba:   enough memory, Z_BUF_ERROR if no progress is possible or if there was not
5128eecc9f 2011-02-23        kinaba:   enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
5128eecc9f 2011-02-23        kinaba:   case, the application may then call inflateSync to look for a good
5128eecc9f 2011-02-23        kinaba:   compression block.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      All dynamically allocated data structures for this stream are freed.
5128eecc9f 2011-02-23        kinaba:    This function discards any unprocessed input and does not flush any
5128eecc9f 2011-02-23        kinaba:    pending output.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
5128eecc9f 2011-02-23        kinaba:    was inconsistent. In the error case, msg may be set but then points to a
5128eecc9f 2011-02-23        kinaba:    static string (which must not be deallocated).
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:                         /* Advanced functions */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:     The following functions are needed only in some special applications.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
5128eecc9f 2011-02-23        kinaba:                                      int  level,
5128eecc9f 2011-02-23        kinaba:                                      int  method,
5128eecc9f 2011-02-23        kinaba:                                      int  windowBits,
5128eecc9f 2011-02-23        kinaba:                                      int  memLevel,
5128eecc9f 2011-02-23        kinaba:                                      int  strategy));
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      This is another version of deflateInit with more compression options. The
5128eecc9f 2011-02-23        kinaba:    fields next_in, zalloc, zfree and opaque must be initialized before by
5128eecc9f 2011-02-23        kinaba:    the caller.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      The method parameter is the compression method. It must be Z_DEFLATED in
5128eecc9f 2011-02-23        kinaba:    this version of the library.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      The windowBits parameter is the base two logarithm of the window size
5128eecc9f 2011-02-23        kinaba:    (the size of the history buffer).  It should be in the range 8..15 for this
5128eecc9f 2011-02-23        kinaba:    version of the library. Larger values of this parameter result in better
5128eecc9f 2011-02-23        kinaba:    compression at the expense of memory usage. The default value is 15 if
5128eecc9f 2011-02-23        kinaba:    deflateInit is used instead.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      The memLevel parameter specifies how much memory should be allocated
5128eecc9f 2011-02-23        kinaba:    for the internal compression state. memLevel=1 uses minimum memory but
5128eecc9f 2011-02-23        kinaba:    is slow and reduces compression ratio; memLevel=9 uses maximum memory
5128eecc9f 2011-02-23        kinaba:    for optimal speed. The default value is 8. See zconf.h for total memory
5128eecc9f 2011-02-23        kinaba:    usage as a function of windowBits and memLevel.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      The strategy parameter is used to tune the compression algorithm. Use the
5128eecc9f 2011-02-23        kinaba:    value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
5128eecc9f 2011-02-23        kinaba:    filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
5128eecc9f 2011-02-23        kinaba:    string match).  Filtered data consists mostly of small values with a
5128eecc9f 2011-02-23        kinaba:    somewhat random distribution. In this case, the compression algorithm is
5128eecc9f 2011-02-23        kinaba:    tuned to compress them better. The effect of Z_FILTERED is to force more
5128eecc9f 2011-02-23        kinaba:    Huffman coding and less string matching; it is somewhat intermediate
5128eecc9f 2011-02-23        kinaba:    between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
5128eecc9f 2011-02-23        kinaba:    the compression ratio but not the correctness of the compressed output even
5128eecc9f 2011-02-23        kinaba:    if it is not set appropriately.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:       deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
5128eecc9f 2011-02-23        kinaba:    memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
5128eecc9f 2011-02-23        kinaba:    method). msg is set to null if there is no error message.  deflateInit2 does
5128eecc9f 2011-02-23        kinaba:    not perform any compression: this will be done by deflate().
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #ifndef KI_GZ_NO_COMPRESSION
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
5128eecc9f 2011-02-23        kinaba:                                              const Bytef *dictionary,
5128eecc9f 2011-02-23        kinaba:                                              uInt  dictLength));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Initializes the compression dictionary from the given byte sequence
5128eecc9f 2011-02-23        kinaba:    without producing any compressed output. This function must be called
5128eecc9f 2011-02-23        kinaba:    immediately after deflateInit, deflateInit2 or deflateReset, before any
5128eecc9f 2011-02-23        kinaba:    call of deflate. The compressor and decompressor must use exactly the same
5128eecc9f 2011-02-23        kinaba:    dictionary (see inflateSetDictionary).
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      The dictionary should consist of strings (byte sequences) that are likely
5128eecc9f 2011-02-23        kinaba:    to be encountered later in the data to be compressed, with the most commonly
5128eecc9f 2011-02-23        kinaba:    used strings preferably put towards the end of the dictionary. Using a
5128eecc9f 2011-02-23        kinaba:    dictionary is most useful when the data to be compressed is short and can be
5128eecc9f 2011-02-23        kinaba:    predicted with good accuracy; the data can then be compressed better than
5128eecc9f 2011-02-23        kinaba:    with the default empty dictionary.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      Depending on the size of the compression data structures selected by
5128eecc9f 2011-02-23        kinaba:    deflateInit or deflateInit2, a part of the dictionary may in effect be
5128eecc9f 2011-02-23        kinaba:    discarded, for example if the dictionary is larger than the window size in
5128eecc9f 2011-02-23        kinaba:    deflate or deflate2. Thus the strings most likely to be useful should be
5128eecc9f 2011-02-23        kinaba:    put at the end of the dictionary, not at the front.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      Upon return of this function, strm->adler is set to the Adler32 value
5128eecc9f 2011-02-23        kinaba:    of the dictionary; the decompressor may later use this value to determine
5128eecc9f 2011-02-23        kinaba:    which dictionary has been used by the compressor. (The Adler32 value
5128eecc9f 2011-02-23        kinaba:    applies to the whole dictionary even if only a subset of the dictionary is
5128eecc9f 2011-02-23        kinaba:    actually used by the compressor.)
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
5128eecc9f 2011-02-23        kinaba:    parameter is invalid (such as NULL dictionary) or the stream state is
5128eecc9f 2011-02-23        kinaba:    inconsistent (for example if deflate has already been called for this stream
5128eecc9f 2011-02-23        kinaba:    or if the compression method is bsort). deflateSetDictionary does not
5128eecc9f 2011-02-23        kinaba:    perform any compression: this will be done by deflate().
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
5128eecc9f 2011-02-23        kinaba:                                     z_streamp source));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Sets the destination stream as a complete copy of the source stream.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      This function can be useful when several compression strategies will be
5128eecc9f 2011-02-23        kinaba:    tried, for example when there are several ways of pre-processing the input
5128eecc9f 2011-02-23        kinaba:    data with a filter. The streams that will be discarded should then be freed
5128eecc9f 2011-02-23        kinaba:    by calling deflateEnd.  Note that deflateCopy duplicates the internal
5128eecc9f 2011-02-23        kinaba:    compression state which can be quite large, so this strategy is slow and
5128eecc9f 2011-02-23        kinaba:    can consume lots of memory.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
5128eecc9f 2011-02-23        kinaba:    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
5128eecc9f 2011-02-23        kinaba:    (such as zalloc being NULL). msg is left unchanged in both source and
5128eecc9f 2011-02-23        kinaba:    destination.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      This function is equivalent to deflateEnd followed by deflateInit,
5128eecc9f 2011-02-23        kinaba:    but does not free and reallocate all the internal compression state.
5128eecc9f 2011-02-23        kinaba:    The stream will keep the same compression level and any other attributes
5128eecc9f 2011-02-23        kinaba:    that may have been set by deflateInit2.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:       deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
5128eecc9f 2011-02-23        kinaba:    stream state was inconsistent (such as zalloc or state being NULL).
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
5128eecc9f 2011-02-23        kinaba: 				      int level,
5128eecc9f 2011-02-23        kinaba: 				      int strategy));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Dynamically update the compression level and compression strategy.  The
5128eecc9f 2011-02-23        kinaba:    interpretation of level and strategy is as in deflateInit2.  This can be
5128eecc9f 2011-02-23        kinaba:    used to switch between compression and straight copy of the input data, or
5128eecc9f 2011-02-23        kinaba:    to switch to a different kind of input data requiring a different
5128eecc9f 2011-02-23        kinaba:    strategy. If the compression level is changed, the input available so far
5128eecc9f 2011-02-23        kinaba:    is compressed with the old level (and may be flushed); the new level will
5128eecc9f 2011-02-23        kinaba:    take effect only at the next call of deflate().
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      Before the call of deflateParams, the stream state must be set as for
5128eecc9f 2011-02-23        kinaba:    a call of deflate(), since the currently available input may have to
5128eecc9f 2011-02-23        kinaba:    be compressed and flushed. In particular, strm->avail_out must be non-zero.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
5128eecc9f 2011-02-23        kinaba:    stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
5128eecc9f 2011-02-23        kinaba:    if strm->avail_out was zero.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #endif /* KI_GZ_NO_COMPRESSION */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
5128eecc9f 2011-02-23        kinaba:                                      int  windowBits));
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      This is another version of inflateInit with an extra parameter. The
5128eecc9f 2011-02-23        kinaba:    fields next_in, avail_in, zalloc, zfree and opaque must be initialized
5128eecc9f 2011-02-23        kinaba:    before by the caller.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      The windowBits parameter is the base two logarithm of the maximum window
5128eecc9f 2011-02-23        kinaba:    size (the size of the history buffer).  It should be in the range 8..15 for
5128eecc9f 2011-02-23        kinaba:    this version of the library. The default value is 15 if inflateInit is used
5128eecc9f 2011-02-23        kinaba:    instead. If a compressed stream with a larger window size is given as
5128eecc9f 2011-02-23        kinaba:    input, inflate() will return with the error code Z_DATA_ERROR instead of
5128eecc9f 2011-02-23        kinaba:    trying to allocate a larger window.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:       inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
5128eecc9f 2011-02-23        kinaba:    memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
5128eecc9f 2011-02-23        kinaba:    memLevel). msg is set to null if there is no error message.  inflateInit2
5128eecc9f 2011-02-23        kinaba:    does not perform any decompression apart from reading the zlib header if
5128eecc9f 2011-02-23        kinaba:    present: this will be done by inflate(). (So next_in and avail_in may be
5128eecc9f 2011-02-23        kinaba:    modified, but next_out and avail_out are unchanged.)
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
5128eecc9f 2011-02-23        kinaba:                                              const Bytef *dictionary,
5128eecc9f 2011-02-23        kinaba:                                              uInt  dictLength));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Initializes the decompression dictionary from the given uncompressed byte
5128eecc9f 2011-02-23        kinaba:    sequence. This function must be called immediately after a call of inflate
5128eecc9f 2011-02-23        kinaba:    if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
5128eecc9f 2011-02-23        kinaba:    can be determined from the Adler32 value returned by this call of
5128eecc9f 2011-02-23        kinaba:    inflate. The compressor and decompressor must use exactly the same
5128eecc9f 2011-02-23        kinaba:    dictionary (see deflateSetDictionary).
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
5128eecc9f 2011-02-23        kinaba:    parameter is invalid (such as NULL dictionary) or the stream state is
5128eecc9f 2011-02-23        kinaba:    inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
5128eecc9f 2011-02-23        kinaba:    expected one (incorrect Adler32 value). inflateSetDictionary does not
5128eecc9f 2011-02-23        kinaba:    perform any decompression: this will be done by subsequent calls of
5128eecc9f 2011-02-23        kinaba:    inflate().
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:     Skips invalid compressed data until a full flush point (see above the
5128eecc9f 2011-02-23        kinaba:   description of deflate with Z_FULL_FLUSH) can be found, or until all
5128eecc9f 2011-02-23        kinaba:   available input is skipped. No output is provided.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
5128eecc9f 2011-02-23        kinaba:   if no more input was provided, Z_DATA_ERROR if no flush point has been found,
5128eecc9f 2011-02-23        kinaba:   or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
5128eecc9f 2011-02-23        kinaba:   case, the application may save the current current value of total_in which
5128eecc9f 2011-02-23        kinaba:   indicates where valid compressed data was found. In the error case, the
5128eecc9f 2011-02-23        kinaba:   application may repeatedly call inflateSync, providing more input each time,
5128eecc9f 2011-02-23        kinaba:   until success or end of the input data.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      This function is equivalent to inflateEnd followed by inflateInit,
5128eecc9f 2011-02-23        kinaba:    but does not free and reallocate all the internal decompression state.
5128eecc9f 2011-02-23        kinaba:    The stream will keep attributes that may have been set by inflateInit2.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:       inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
5128eecc9f 2011-02-23        kinaba:    stream state was inconsistent (such as zalloc or state being NULL).
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:                         /* utility functions */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      The following utility functions are implemented on top of the
5128eecc9f 2011-02-23        kinaba:    basic stream-oriented functions. To simplify the interface, some
5128eecc9f 2011-02-23        kinaba:    default options are assumed (compression level and memory usage,
5128eecc9f 2011-02-23        kinaba:    standard memory allocation functions). The source code of these
5128eecc9f 2011-02-23        kinaba:    utility functions can easily be modified if you need special options.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #ifndef KI_GZ_NO_COMPRESSION
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
5128eecc9f 2011-02-23        kinaba:                                  const Bytef *source, uLong sourceLen));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Compresses the source buffer into the destination buffer.  sourceLen is
5128eecc9f 2011-02-23        kinaba:    the byte length of the source buffer. Upon entry, destLen is the total
5128eecc9f 2011-02-23        kinaba:    size of the destination buffer, which must be at least 0.1% larger than
5128eecc9f 2011-02-23        kinaba:    sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
5128eecc9f 2011-02-23        kinaba:    compressed buffer.
5128eecc9f 2011-02-23        kinaba:      This function can be used to compress a whole file at once if the
5128eecc9f 2011-02-23        kinaba:    input file is mmap'ed.
5128eecc9f 2011-02-23        kinaba:      compress returns Z_OK if success, Z_MEM_ERROR if there was not
5128eecc9f 2011-02-23        kinaba:    enough memory, Z_BUF_ERROR if there was not enough room in the output
5128eecc9f 2011-02-23        kinaba:    buffer.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
5128eecc9f 2011-02-23        kinaba:                                   const Bytef *source, uLong sourceLen,
5128eecc9f 2011-02-23        kinaba:                                   int level));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Compresses the source buffer into the destination buffer. The level
5128eecc9f 2011-02-23        kinaba:    parameter has the same meaning as in deflateInit.  sourceLen is the byte
5128eecc9f 2011-02-23        kinaba:    length of the source buffer. Upon entry, destLen is the total size of the
5128eecc9f 2011-02-23        kinaba:    destination buffer, which must be at least 0.1% larger than sourceLen plus
5128eecc9f 2011-02-23        kinaba:    12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
5128eecc9f 2011-02-23        kinaba:    memory, Z_BUF_ERROR if there was not enough room in the output buffer,
5128eecc9f 2011-02-23        kinaba:    Z_STREAM_ERROR if the level parameter is invalid.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #endif /* KI_GZ_NO_COMPRESSION */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
5128eecc9f 2011-02-23        kinaba:                                    const Bytef *source, uLong sourceLen));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Decompresses the source buffer into the destination buffer.  sourceLen is
5128eecc9f 2011-02-23        kinaba:    the byte length of the source buffer. Upon entry, destLen is the total
5128eecc9f 2011-02-23        kinaba:    size of the destination buffer, which must be large enough to hold the
5128eecc9f 2011-02-23        kinaba:    entire uncompressed data. (The size of the uncompressed data must have
5128eecc9f 2011-02-23        kinaba:    been saved previously by the compressor and transmitted to the decompressor
5128eecc9f 2011-02-23        kinaba:    by some mechanism outside the scope of this compression library.)
5128eecc9f 2011-02-23        kinaba:    Upon exit, destLen is the actual size of the compressed buffer.
5128eecc9f 2011-02-23        kinaba:      This function can be used to decompress a whole file at once if the
5128eecc9f 2011-02-23        kinaba:    input file is mmap'ed.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
5128eecc9f 2011-02-23        kinaba:    enough memory, Z_BUF_ERROR if there was not enough room in the output
5128eecc9f 2011-02-23        kinaba:    buffer, or Z_DATA_ERROR if the input data was corrupted.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: typedef voidp gzFile;
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN gzFile ZEXPORT gzopen  OF((const char *path, const char *mode));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Opens a gzip (.gz) file for reading or writing. The mode parameter
5128eecc9f 2011-02-23        kinaba:    is as in fopen ("rb" or "wb") but can also include a compression level
5128eecc9f 2011-02-23        kinaba:    ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
5128eecc9f 2011-02-23        kinaba:    Huffman only compression as in "wb1h". (See the description
5128eecc9f 2011-02-23        kinaba:    of deflateInit2 for more information about the strategy parameter.)
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      gzopen can be used to read a file which is not in gzip format; in this
5128eecc9f 2011-02-23        kinaba:    case gzread will directly read from the file without decompression.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      gzopen returns NULL if the file could not be opened or if there was
5128eecc9f 2011-02-23        kinaba:    insufficient memory to allocate the (de)compression state; errno
5128eecc9f 2011-02-23        kinaba:    can be checked to distinguish the two cases (if errno is zero, the
5128eecc9f 2011-02-23        kinaba:    zlib error is Z_MEM_ERROR).  */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN gzFile ZEXPORT gzdopen  OF((int fd, const char *mode));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      gzdopen() associates a gzFile with the file descriptor fd.  File
5128eecc9f 2011-02-23        kinaba:    descriptors are obtained from calls like open, dup, creat, pipe or
5128eecc9f 2011-02-23        kinaba:    fileno (in the file has been previously opened with fopen).
5128eecc9f 2011-02-23        kinaba:    The mode parameter is as in gzopen.
5128eecc9f 2011-02-23        kinaba:      The next call of gzclose on the returned gzFile will also close the
5128eecc9f 2011-02-23        kinaba:    file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
5128eecc9f 2011-02-23        kinaba:    descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
5128eecc9f 2011-02-23        kinaba:      gzdopen returns NULL if there was insufficient memory to allocate
5128eecc9f 2011-02-23        kinaba:    the (de)compression state.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Dynamically update the compression level or strategy. See the description
5128eecc9f 2011-02-23        kinaba:    of deflateInit2 for the meaning of these parameters.
5128eecc9f 2011-02-23        kinaba:      gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
5128eecc9f 2011-02-23        kinaba:    opened for writing.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT    gzread  OF((gzFile file, voidp buf, unsigned len));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Reads the given number of uncompressed bytes from the compressed file.
5128eecc9f 2011-02-23        kinaba:    If the input file was not in gzip format, gzread copies the given number
5128eecc9f 2011-02-23        kinaba:    of bytes into the buffer.
5128eecc9f 2011-02-23        kinaba:      gzread returns the number of uncompressed bytes actually read (0 for
5128eecc9f 2011-02-23        kinaba:    end of file, -1 for error). */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #ifndef KI_GZ_NO_COMPRESSION
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT    gzwrite OF((gzFile file,
5128eecc9f 2011-02-23        kinaba: 				   const voidp buf, unsigned len));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Writes the given number of uncompressed bytes into the compressed file.
5128eecc9f 2011-02-23        kinaba:    gzwrite returns the number of uncompressed bytes actually written
5128eecc9f 2011-02-23        kinaba:    (0 in case of error).
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORTVA   gzprintf OF((gzFile file, const char *format, ...));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Converts, formats, and writes the args to the compressed file under
5128eecc9f 2011-02-23        kinaba:    control of the format string, as in fprintf. gzprintf returns the number of
5128eecc9f 2011-02-23        kinaba:    uncompressed bytes actually written (0 in case of error).
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:       Writes the given null-terminated string to the compressed file, excluding
5128eecc9f 2011-02-23        kinaba:    the terminating null character.
5128eecc9f 2011-02-23        kinaba:       gzputs returns the number of characters written, or -1 in case of error.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #endif /* KI_GZ_NO_COMPRESSION */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:       Reads bytes from the compressed file until len-1 characters are read, or
5128eecc9f 2011-02-23        kinaba:    a newline character is read and transferred to buf, or an end-of-file
5128eecc9f 2011-02-23        kinaba:    condition is encountered.  The string is then terminated with a null
5128eecc9f 2011-02-23        kinaba:    character.
5128eecc9f 2011-02-23        kinaba:       gzgets returns buf, or Z_NULL in case of error.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #ifdef KI_GZ_NO_COMPRESSION
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT    gzputc OF((gzFile file, int c));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:       Writes c, converted to an unsigned char, into the compressed file.
5128eecc9f 2011-02-23        kinaba:    gzputc returns the value that was written, or -1 in case of error.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #endif /* KI_GZ_NO_COMPRESSION */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT    gzgetc OF((gzFile file));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:       Reads one byte from the compressed file. gzgetc returns this byte
5128eecc9f 2011-02-23        kinaba:    or -1 in case of end of file or error.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #ifndef KI_GZ_NO_COMPRESSION
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT    gzflush OF((gzFile file, int flush));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Flushes all pending output into the compressed file. The parameter
5128eecc9f 2011-02-23        kinaba:    flush is as in the deflate() function. The return value is the zlib
5128eecc9f 2011-02-23        kinaba:    error number (see function gzerror below). gzflush returns Z_OK if
5128eecc9f 2011-02-23        kinaba:    the flush parameter is Z_FINISH and all output could be flushed.
5128eecc9f 2011-02-23        kinaba:      gzflush should be called only when strictly necessary because it can
5128eecc9f 2011-02-23        kinaba:    degrade compression.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: #endif /* KI_GZ_NO_COMPRESSION */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN z_off_t ZEXPORT    gzseek OF((gzFile file,
5128eecc9f 2011-02-23        kinaba: 				      z_off_t offset, int whence));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:       Sets the starting position for the next gzread or gzwrite on the
5128eecc9f 2011-02-23        kinaba:    given compressed file. The offset represents a number of bytes in the
5128eecc9f 2011-02-23        kinaba:    uncompressed data stream. The whence parameter is defined as in lseek(2);
5128eecc9f 2011-02-23        kinaba:    the value SEEK_END is not supported.
5128eecc9f 2011-02-23        kinaba:      If the file is opened for reading, this function is emulated but can be
5128eecc9f 2011-02-23        kinaba:    extremely slow. If the file is opened for writing, only forward seeks are
5128eecc9f 2011-02-23        kinaba:    supported; gzseek then compresses a sequence of zeroes up to the new
5128eecc9f 2011-02-23        kinaba:    starting position.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:       gzseek returns the resulting offset location as measured in bytes from
5128eecc9f 2011-02-23        kinaba:    the beginning of the uncompressed stream, or -1 in case of error, in
5128eecc9f 2011-02-23        kinaba:    particular if the file is opened for writing and the new starting position
5128eecc9f 2011-02-23        kinaba:    would be before the current position.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Rewinds the given file. This function is supported only for reading.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:    gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Returns the starting position for the next gzread or gzwrite on the
5128eecc9f 2011-02-23        kinaba:    given compressed file. This position represents a number of bytes in the
5128eecc9f 2011-02-23        kinaba:    uncompressed data stream.
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:    gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT gzeof OF((gzFile file));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Returns 1 when EOF has previously been detected reading the given
5128eecc9f 2011-02-23        kinaba:    input stream, otherwise zero.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Flushes all pending output if necessary, closes the compressed file
5128eecc9f 2011-02-23        kinaba:    and deallocates all the (de)compression state. The return value is the zlib
5128eecc9f 2011-02-23        kinaba:    error number (see function gzerror below).
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Returns the error message for the last error which occurred on the
5128eecc9f 2011-02-23        kinaba:    given compressed file. errnum is set to zlib error number. If an
5128eecc9f 2011-02-23        kinaba:    error occurred in the file system and not in the compression library,
5128eecc9f 2011-02-23        kinaba:    errnum is set to Z_ERRNO and the application may consult errno
5128eecc9f 2011-02-23        kinaba:    to get the exact error code.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:                         /* checksum functions */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      These functions are not related to compression but are exported
5128eecc9f 2011-02-23        kinaba:    anyway because they might be useful in applications using the
5128eecc9f 2011-02-23        kinaba:    compression library.
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
5128eecc9f 2011-02-23        kinaba:    return the updated checksum. If buf is NULL, this function returns
5128eecc9f 2011-02-23        kinaba:    the required initial value for the checksum.
5128eecc9f 2011-02-23        kinaba:    An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
5128eecc9f 2011-02-23        kinaba:    much faster. Usage example:
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      uLong adler = adler32(0L, Z_NULL, 0);
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      while (read_buffer(buffer, length) != EOF) {
5128eecc9f 2011-02-23        kinaba:        adler = adler32(adler, buffer, length);
5128eecc9f 2011-02-23        kinaba:      }
5128eecc9f 2011-02-23        kinaba:      if (adler != original_adler) error();
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
5128eecc9f 2011-02-23        kinaba: /*
5128eecc9f 2011-02-23        kinaba:      Update a running crc with the bytes buf[0..len-1] and return the updated
5128eecc9f 2011-02-23        kinaba:    crc. If buf is NULL, this function returns the required initial value
5128eecc9f 2011-02-23        kinaba:    for the crc. Pre- and post-conditioning (one's complement) is performed
5128eecc9f 2011-02-23        kinaba:    within this function so it shouldn't be done by the application.
5128eecc9f 2011-02-23        kinaba:    Usage example:
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      uLong crc = crc32(0L, Z_NULL, 0);
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:      while (read_buffer(buffer, length) != EOF) {
5128eecc9f 2011-02-23        kinaba:        crc = crc32(crc, buffer, length);
5128eecc9f 2011-02-23        kinaba:      }
5128eecc9f 2011-02-23        kinaba:      if (crc != original_crc) error();
5128eecc9f 2011-02-23        kinaba: */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba:                         /* various hacks, don't look :) */
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: /* deflateInit and inflateInit are macros to allow checking the zlib version
5128eecc9f 2011-02-23        kinaba:  * and the compiler's view of z_stream:
5128eecc9f 2011-02-23        kinaba:  */
5128eecc9f 2011-02-23        kinaba: #ifndef KI_GZ_NO_COMPRESSION
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
5128eecc9f 2011-02-23        kinaba:                                      const char *version, int stream_size));
5128eecc9f 2011-02-23        kinaba: #endif /* KI_GZ_NO_COMPRESSION */
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
5128eecc9f 2011-02-23        kinaba:                                      const char *version, int stream_size));
5128eecc9f 2011-02-23        kinaba: #ifndef KI_GZ_NO_COMPRESSION
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
5128eecc9f 2011-02-23        kinaba:                                       int windowBits, int memLevel,
5128eecc9f 2011-02-23        kinaba:                                       int strategy, const char *version,
5128eecc9f 2011-02-23        kinaba:                                       int stream_size));
5128eecc9f 2011-02-23        kinaba: #endif /* KI_GZ_NO_COMPRESSION */
5128eecc9f 2011-02-23        kinaba: ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
5128eecc9f 2011-02-23        kinaba:                                       const char *version, int stream_size));
5128eecc9f 2011-02-23        kinaba: #define deflateInit(strm, level) \
5128eecc9f 2011-02-23        kinaba:         deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
5128eecc9f 2011-02-23        kinaba: #define inflateInit(strm) \
5128eecc9f 2011-02-23        kinaba:         inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
5128eecc9f 2011-02-23        kinaba: #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
5128eecc9f 2011-02-23        kinaba:         deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
5128eecc9f 2011-02-23        kinaba:                       (strategy),           ZLIB_VERSION, sizeof(z_stream))
5128eecc9f 2011-02-23        kinaba: #define inflateInit2(strm, windowBits) \
5128eecc9f 2011-02-23        kinaba:         inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
5128eecc9f 2011-02-23        kinaba:     struct internal_state {int dummy;}; /* hack for buggy compilers */
5128eecc9f 2011-02-23        kinaba: #endif
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: ZEXTERN const char   * ZEXPORT zError           OF((int err));
5128eecc9f 2011-02-23        kinaba: ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp z));
5128eecc9f 2011-02-23        kinaba: ZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #ifdef __cplusplus
5128eecc9f 2011-02-23        kinaba: }
5128eecc9f 2011-02-23        kinaba: #endif
5128eecc9f 2011-02-23        kinaba: 
5128eecc9f 2011-02-23        kinaba: #endif /* _ZLIB_H */