os/ossrv/compressionlibs/ziplib/test/oldezlib/inc/zlib.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/compressionlibs/ziplib/test/oldezlib/inc/zlib.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,899 @@
     1.4 +/* zlib.h -- interface of the 'zlib' general purpose compression library
     1.5 +  version 1.1.3, July 9th, 1998
     1.6 +
     1.7 +  Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
     1.8 +
     1.9 +  This software is provided 'as-is', without any express or implied
    1.10 +  warranty.  In no event will the authors be held liable for any damages
    1.11 +  arising from the use of this software.
    1.12 +
    1.13 +  Permission is granted to anyone to use this software for any purpose,
    1.14 +  including commercial applications, and to alter it and redistribute it
    1.15 +  freely, subject to the following restrictions:
    1.16 +
    1.17 +  1. The origin of this software must not be misrepresented; you must not
    1.18 +     claim that you wrote the original software. If you use this software
    1.19 +     in a product, an acknowledgment in the product documentation would be
    1.20 +     appreciated but is not required.
    1.21 +  2. Altered source versions must be plainly marked as such, and must not be
    1.22 +     misrepresented as being the original software.
    1.23 +  3. This notice may not be removed or altered from any source distribution.
    1.24 +
    1.25 +  Jean-loup Gailly        Mark Adler
    1.26 +  jloup@gzip.org          madler@alumni.caltech.edu
    1.27 +
    1.28 +
    1.29 +  The data format used by the zlib library is described by RFCs (Request for
    1.30 +  Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
    1.31 +  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
    1.32 +*/
    1.33 +
    1.34 +/**
    1.35 + @file
    1.36 + Contains macro definitions and function signatures for ezlib library 
    1.37 + @internalAll
    1.38 + */
    1.39 +
    1.40 +#ifndef _ZLIB_H
    1.41 +#define _ZLIB_H
    1.42 +
    1.43 +#include "zconf.h"
    1.44 +
    1.45 +#ifdef __cplusplus
    1.46 +extern "C" {
    1.47 +#endif
    1.48 +
    1.49 +#define ZLIB_VERSION "1.1.3"
    1.50 +
    1.51 +/* 
    1.52 +     The 'zlib' compression library provides in-memory compression and
    1.53 +  decompression functions, including integrity checks of the uncompressed
    1.54 +  data.  This version of the library supports only one compression method
    1.55 +  (deflation) but other algorithms will be added later and will have the same
    1.56 +  stream interface.
    1.57 +
    1.58 +     Compression can be done in a single step if the buffers are large
    1.59 +  enough (for example if an input file is mmap'ed), or can be done by
    1.60 +  repeated calls of the compression function.  In the latter case, the
    1.61 +  application must provide more input and/or consume the output
    1.62 +  (providing more output space) before each call.
    1.63 +
    1.64 +     The library also supports reading and writing files in gzip (.gz) format
    1.65 +  with an interface similar to that of stdio.
    1.66 +
    1.67 +     The library does not install any signal handler. The decoder checks
    1.68 +  the consistency of the compressed data, so the library should never
    1.69 +  crash even in case of corrupted input.
    1.70 +*/
    1.71 +
    1.72 +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
    1.73 +typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
    1.74 +
    1.75 +struct internal_state;
    1.76 +
    1.77 +typedef struct z_stream_s {
    1.78 +    Bytef    *next_in;  /* next input byte */
    1.79 +    uInt     avail_in;  /* number of bytes available at next_in */
    1.80 +    uLong    total_in;  /* total nb of input bytes read so far */
    1.81 +
    1.82 +    Bytef    *next_out; /* next output byte should be put there */
    1.83 +    uInt     avail_out; /* remaining free space at next_out */
    1.84 +    uLong    total_out; /* total nb of bytes output so far */
    1.85 +
    1.86 +    char     *msg;      /* last error message, NULL if no error */
    1.87 +    struct internal_state FAR *state; /* not visible by applications */
    1.88 +
    1.89 +    alloc_func zalloc;  /* used to allocate the internal state */
    1.90 +    free_func  zfree;   /* used to free the internal state */
    1.91 +    voidpf     opaque;  /* private data object passed to zalloc and zfree */
    1.92 +
    1.93 +    int     data_type;  /* best guess about the data type: ascii or binary */
    1.94 +    uLong   adler;      /* adler32 value of the uncompressed data */
    1.95 +    uLong   reserved;   /* reserved for future use */
    1.96 +} z_stream;
    1.97 +
    1.98 +typedef z_stream FAR *z_streamp;
    1.99 +
   1.100 +/*
   1.101 +   The application must update next_in and avail_in when avail_in has
   1.102 +   dropped to zero. It must update next_out and avail_out when avail_out
   1.103 +   has dropped to zero. The application must initialize zalloc, zfree and
   1.104 +   opaque before calling the init function. All other fields are set by the
   1.105 +   compression library and must not be updated by the application.
   1.106 +
   1.107 +   The opaque value provided by the application will be passed as the first
   1.108 +   parameter for calls of zalloc and zfree. This can be useful for custom
   1.109 +   memory management. The compression library attaches no meaning to the
   1.110 +   opaque value.
   1.111 +
   1.112 +   zalloc must return Z_NULL if there is not enough memory for the object.
   1.113 +   If zlib is used in a multi-threaded application, zalloc and zfree must be
   1.114 +   thread safe.
   1.115 +
   1.116 +   On 16-bit systems, the functions zalloc and zfree must be able to allocate
   1.117 +   exactly 65536 bytes, but will not be required to allocate more than this
   1.118 +   if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
   1.119 +   pointers returned by zalloc for objects of exactly 65536 bytes *must*
   1.120 +   have their offset normalized to zero. The default allocation function
   1.121 +   provided by this library ensures this (see zutil.c). To reduce memory
   1.122 +   requirements and avoid any allocation of 64K objects, at the expense of
   1.123 +   compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
   1.124 +
   1.125 +   The fields total_in and total_out can be used for statistics or
   1.126 +   progress reports. After compression, total_in holds the total size of
   1.127 +   the uncompressed data and may be saved for use in the decompressor
   1.128 +   (particularly if the decompressor wants to decompress everything in
   1.129 +   a single step).
   1.130 +*/
   1.131 +
   1.132 +                        /* constants */
   1.133 +
   1.134 +#define Z_NO_FLUSH      0
   1.135 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
   1.136 +#define Z_SYNC_FLUSH    2
   1.137 +#define Z_FULL_FLUSH    3
   1.138 +#define Z_FINISH        4
   1.139 +/* Allowed flush values; see deflate() below for details */
   1.140 +
   1.141 +#define Z_OK            0
   1.142 +#define Z_STREAM_END    1
   1.143 +#define Z_NEED_DICT     2
   1.144 +#define Z_ERRNO        (-1)
   1.145 +#define Z_STREAM_ERROR (-2)
   1.146 +#define Z_DATA_ERROR   (-3)
   1.147 +#define Z_MEM_ERROR    (-4)
   1.148 +#define Z_BUF_ERROR    (-5)
   1.149 +#define Z_VERSION_ERROR (-6)
   1.150 +/* Return codes for the compression/decompression functions. Negative
   1.151 + * values are errors, positive values are used for special but normal events.
   1.152 + */
   1.153 +
   1.154 +#define Z_NO_COMPRESSION         0
   1.155 +#define Z_BEST_SPEED             1
   1.156 +#define Z_BEST_COMPRESSION       9
   1.157 +#define Z_DEFAULT_COMPRESSION  (-1)
   1.158 +/* compression levels */
   1.159 +
   1.160 +#define Z_FILTERED            1
   1.161 +#define Z_HUFFMAN_ONLY        2
   1.162 +#define Z_DEFAULT_STRATEGY    0
   1.163 +/* compression strategy; see deflateInit2() below for details */
   1.164 +
   1.165 +#define Z_BINARY   0
   1.166 +#define Z_ASCII    1
   1.167 +#define Z_UNKNOWN  2
   1.168 +/* Possible values of the data_type field */
   1.169 +
   1.170 +#define Z_DEFLATED   8
   1.171 +/* The deflate compression method (the only one supported in this version) */
   1.172 +
   1.173 +#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
   1.174 +
   1.175 +#define zlib_version zlibVersion()
   1.176 +/* for compatibility with versions < 1.0.2 */
   1.177 +
   1.178 +                        /* basic functions */
   1.179 +
   1.180 +ZEXTERN const char * ZEXPORT zlibVersion OF((void));
   1.181 +/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
   1.182 +   If the first character differs, the library code actually used is
   1.183 +   not compatible with the zlib.h header file used by the application.
   1.184 +   This check is automatically made by deflateInit and inflateInit.
   1.185 + */
   1.186 +
   1.187 +/* 
   1.188 +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
   1.189 +
   1.190 +     Initializes the internal stream state for compression. The fields
   1.191 +   zalloc, zfree and opaque must be initialized before by the caller.
   1.192 +   If zalloc and zfree are set to Z_NULL, deflateInit updates them to
   1.193 +   use default allocation functions.
   1.194 +
   1.195 +     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
   1.196 +   1 gives best speed, 9 gives best compression, 0 gives no compression at
   1.197 +   all (the input data is simply copied a block at a time).
   1.198 +   Z_DEFAULT_COMPRESSION requests a default compromise between speed and
   1.199 +   compression (currently equivalent to level 6).
   1.200 +
   1.201 +     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
   1.202 +   enough memory, Z_STREAM_ERROR if level is not a valid compression level,
   1.203 +   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
   1.204 +   with the version assumed by the caller (ZLIB_VERSION).
   1.205 +   msg is set to null if there is no error message.  deflateInit does not
   1.206 +   perform any compression: this will be done by deflate().
   1.207 +*/
   1.208 +
   1.209 +
   1.210 +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
   1.211 +/*
   1.212 +    deflate compresses as much data as possible, and stops when the input
   1.213 +  buffer becomes empty or the output buffer becomes full. It may introduce some
   1.214 +  output latency (reading input without producing any output) except when
   1.215 +  forced to flush.
   1.216 +
   1.217 +    The detailed semantics are as follows. deflate performs one or both of the
   1.218 +  following actions:
   1.219 +
   1.220 +  - Compress more input starting at next_in and update next_in and avail_in
   1.221 +    accordingly. If not all input can be processed (because there is not
   1.222 +    enough room in the output buffer), next_in and avail_in are updated and
   1.223 +    processing will resume at this point for the next call of deflate().
   1.224 +
   1.225 +  - Provide more output starting at next_out and update next_out and avail_out
   1.226 +    accordingly. This action is forced if the parameter flush is non zero.
   1.227 +    Forcing flush frequently degrades the compression ratio, so this parameter
   1.228 +    should be set only when necessary (in interactive applications).
   1.229 +    Some output may be provided even if flush is not set.
   1.230 +
   1.231 +  Before the call of deflate(), the application should ensure that at least
   1.232 +  one of the actions is possible, by providing more input and/or consuming
   1.233 +  more output, and updating avail_in or avail_out accordingly; avail_out
   1.234 +  should never be zero before the call. The application can consume the
   1.235 +  compressed output when it wants, for example when the output buffer is full
   1.236 +  (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
   1.237 +  and with zero avail_out, it must be called again after making room in the
   1.238 +  output buffer because there might be more output pending.
   1.239 +
   1.240 +    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
   1.241 +  flushed to the output buffer and the output is aligned on a byte boundary, so
   1.242 +  that the decompressor can get all input data available so far. (In particular
   1.243 +  avail_in is zero after the call if enough output space has been provided
   1.244 +  before the call.)  Flushing may degrade compression for some compression
   1.245 +  algorithms and so it should be used only when necessary.
   1.246 +
   1.247 +    If flush is set to Z_FULL_FLUSH, all output is flushed as with
   1.248 +  Z_SYNC_FLUSH, and the compression state is reset so that decompression can
   1.249 +  restart from this point if previous compressed data has been damaged or if
   1.250 +  random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
   1.251 +  the compression.
   1.252 +
   1.253 +    If deflate returns with avail_out == 0, this function must be called again
   1.254 +  with the same value of the flush parameter and more output space (updated
   1.255 +  avail_out), until the flush is complete (deflate returns with non-zero
   1.256 +  avail_out).
   1.257 +
   1.258 +    If the parameter flush is set to Z_FINISH, pending input is processed,
   1.259 +  pending output is flushed and deflate returns with Z_STREAM_END if there
   1.260 +  was enough output space; if deflate returns with Z_OK, this function must be
   1.261 +  called again with Z_FINISH and more output space (updated avail_out) but no
   1.262 +  more input data, until it returns with Z_STREAM_END or an error. After
   1.263 +  deflate has returned Z_STREAM_END, the only possible operations on the
   1.264 +  stream are deflateReset or deflateEnd.
   1.265 +  
   1.266 +    Z_FINISH can be used immediately after deflateInit if all the compression
   1.267 +  is to be done in a single step. In this case, avail_out must be at least
   1.268 +  0.1% larger than avail_in plus 12 bytes.  If deflate does not return
   1.269 +  Z_STREAM_END, then it must be called again as described above.
   1.270 +
   1.271 +    deflate() sets strm->adler to the adler32 checksum of all input read
   1.272 +  so far (that is, total_in bytes).
   1.273 +
   1.274 +    deflate() may update data_type if it can make a good guess about
   1.275 +  the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
   1.276 +  binary. This field is only for information purposes and does not affect
   1.277 +  the compression algorithm in any manner.
   1.278 +
   1.279 +    deflate() returns Z_OK if some progress has been made (more input
   1.280 +  processed or more output produced), Z_STREAM_END if all input has been
   1.281 +  consumed and all output has been produced (only when flush is set to
   1.282 +  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
   1.283 +  if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
   1.284 +  (for example avail_in or avail_out was zero).
   1.285 +*/
   1.286 +
   1.287 +
   1.288 +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
   1.289 +/*
   1.290 +     All dynamically allocated data structures for this stream are freed.
   1.291 +   This function discards any unprocessed input and does not flush any
   1.292 +   pending output.
   1.293 +
   1.294 +     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
   1.295 +   stream state was inconsistent, Z_DATA_ERROR if the stream was freed
   1.296 +   prematurely (some input or output was discarded). In the error case,
   1.297 +   msg may be set but then points to a static string (which must not be
   1.298 +   deallocated).
   1.299 +*/
   1.300 +
   1.301 +
   1.302 +/* 
   1.303 +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
   1.304 +
   1.305 +     Initializes the internal stream state for decompression. The fields
   1.306 +   next_in, avail_in, zalloc, zfree and opaque must be initialized before by
   1.307 +   the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
   1.308 +   value depends on the compression method), inflateInit determines the
   1.309 +   compression method from the zlib header and allocates all data structures
   1.310 +   accordingly; otherwise the allocation will be deferred to the first call of
   1.311 +   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
   1.312 +   use default allocation functions.
   1.313 +
   1.314 +     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
   1.315 +   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
   1.316 +   version assumed by the caller.  msg is set to null if there is no error
   1.317 +   message. inflateInit does not perform any decompression apart from reading
   1.318 +   the zlib header if present: this will be done by inflate().  (So next_in and
   1.319 +   avail_in may be modified, but next_out and avail_out are unchanged.)
   1.320 +*/
   1.321 +
   1.322 +
   1.323 +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
   1.324 +/*
   1.325 +    inflate decompresses as much data as possible, and stops when the input
   1.326 +  buffer becomes empty or the output buffer becomes full. It may some
   1.327 +  introduce some output latency (reading input without producing any output)
   1.328 +  except when forced to flush.
   1.329 +
   1.330 +  The detailed semantics are as follows. inflate performs one or both of the
   1.331 +  following actions:
   1.332 +
   1.333 +  - Decompress more input starting at next_in and update next_in and avail_in
   1.334 +    accordingly. If not all input can be processed (because there is not
   1.335 +    enough room in the output buffer), next_in is updated and processing
   1.336 +    will resume at this point for the next call of inflate().
   1.337 +
   1.338 +  - Provide more output starting at next_out and update next_out and avail_out
   1.339 +    accordingly.  inflate() provides as much output as possible, until there
   1.340 +    is no more input data or no more space in the output buffer (see below
   1.341 +    about the flush parameter).
   1.342 +
   1.343 +  Before the call of inflate(), the application should ensure that at least
   1.344 +  one of the actions is possible, by providing more input and/or consuming
   1.345 +  more output, and updating the next_* and avail_* values accordingly.
   1.346 +  The application can consume the uncompressed output when it wants, for
   1.347 +  example when the output buffer is full (avail_out == 0), or after each
   1.348 +  call of inflate(). If inflate returns Z_OK and with zero avail_out, it
   1.349 +  must be called again after making room in the output buffer because there
   1.350 +  might be more output pending.
   1.351 +
   1.352 +    If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
   1.353 +  output as possible to the output buffer. The flushing behavior of inflate is
   1.354 +  not specified for values of the flush parameter other than Z_SYNC_FLUSH
   1.355 +  and Z_FINISH, but the current implementation actually flushes as much output
   1.356 +  as possible anyway.
   1.357 +
   1.358 +    inflate() should normally be called until it returns Z_STREAM_END or an
   1.359 +  error. However if all decompression is to be performed in a single step
   1.360 +  (a single call of inflate), the parameter flush should be set to
   1.361 +  Z_FINISH. In this case all pending input is processed and all pending
   1.362 +  output is flushed; avail_out must be large enough to hold all the
   1.363 +  uncompressed data. (The size of the uncompressed data may have been saved
   1.364 +  by the compressor for this purpose.) The next operation on this stream must
   1.365 +  be inflateEnd to deallocate the decompression state. The use of Z_FINISH
   1.366 +  is never required, but can be used to inform inflate that a faster routine
   1.367 +  may be used for the single inflate() call.
   1.368 +
   1.369 +     If a preset dictionary is needed at this point (see inflateSetDictionary
   1.370 +  below), inflate sets strm-adler to the adler32 checksum of the
   1.371 +  dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise 
   1.372 +  it sets strm->adler to the adler32 checksum of all output produced
   1.373 +  so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
   1.374 +  an error code as described below. At the end of the stream, inflate()
   1.375 +  checks that its computed adler32 checksum is equal to that saved by the
   1.376 +  compressor and returns Z_STREAM_END only if the checksum is correct.
   1.377 +
   1.378 +    inflate() returns Z_OK if some progress has been made (more input processed
   1.379 +  or more output produced), Z_STREAM_END if the end of the compressed data has
   1.380 +  been reached and all uncompressed output has been produced, Z_NEED_DICT if a
   1.381 +  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
   1.382 +  corrupted (input stream not conforming to the zlib format or incorrect
   1.383 +  adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
   1.384 +  (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
   1.385 +  enough memory, Z_BUF_ERROR if no progress is possible or if there was not
   1.386 +  enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
   1.387 +  case, the application may then call inflateSync to look for a good
   1.388 +  compression block.
   1.389 +*/
   1.390 +
   1.391 +
   1.392 +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
   1.393 +/*
   1.394 +     All dynamically allocated data structures for this stream are freed.
   1.395 +   This function discards any unprocessed input and does not flush any
   1.396 +   pending output.
   1.397 +
   1.398 +     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
   1.399 +   was inconsistent. In the error case, msg may be set but then points to a
   1.400 +   static string (which must not be deallocated).
   1.401 +*/
   1.402 +
   1.403 +                        /* Advanced functions */
   1.404 +
   1.405 +/*
   1.406 +    The following functions are needed only in some special applications.
   1.407 +*/
   1.408 +
   1.409 +/*   
   1.410 +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
   1.411 +                                     int  level,
   1.412 +                                     int  method,
   1.413 +                                     int  windowBits,
   1.414 +                                     int  memLevel,
   1.415 +                                     int  strategy));
   1.416 +
   1.417 +     This is another version of deflateInit with more compression options. The
   1.418 +   fields next_in, zalloc, zfree and opaque must be initialized before by
   1.419 +   the caller.
   1.420 +
   1.421 +     The method parameter is the compression method. It must be Z_DEFLATED in
   1.422 +   this version of the library.
   1.423 +
   1.424 +     The windowBits parameter is the base two logarithm of the window size
   1.425 +   (the size of the history buffer).  It should be in the range 8..15 for this
   1.426 +   version of the library. Larger values of this parameter result in better
   1.427 +   compression at the expense of memory usage. The default value is 15 if
   1.428 +   deflateInit is used instead.
   1.429 +
   1.430 +     The memLevel parameter specifies how much memory should be allocated
   1.431 +   for the internal compression state. memLevel=1 uses minimum memory but
   1.432 +   is slow and reduces compression ratio; memLevel=9 uses maximum memory
   1.433 +   for optimal speed. The default value is 8. See zconf.h for total memory
   1.434 +   usage as a function of windowBits and memLevel.
   1.435 +
   1.436 +     The strategy parameter is used to tune the compression algorithm. Use the
   1.437 +   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
   1.438 +   filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
   1.439 +   string match).  Filtered data consists mostly of small values with a
   1.440 +   somewhat random distribution. In this case, the compression algorithm is
   1.441 +   tuned to compress them better. The effect of Z_FILTERED is to force more
   1.442 +   Huffman coding and less string matching; it is somewhat intermediate
   1.443 +   between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
   1.444 +   the compression ratio but not the correctness of the compressed output even
   1.445 +   if it is not set appropriately.
   1.446 +
   1.447 +      deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
   1.448 +   memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
   1.449 +   method). msg is set to null if there is no error message.  deflateInit2 does
   1.450 +   not perform any compression: this will be done by deflate().
   1.451 +*/
   1.452 +                            
   1.453 +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
   1.454 +                                             const Bytef *dictionary,
   1.455 +                                             uInt  dictLength));
   1.456 +/*
   1.457 +     Initializes the compression dictionary from the given byte sequence
   1.458 +   without producing any compressed output. This function must be called
   1.459 +   immediately after deflateInit, deflateInit2 or deflateReset, before any
   1.460 +   call of deflate. The compressor and decompressor must use exactly the same
   1.461 +   dictionary (see inflateSetDictionary).
   1.462 +
   1.463 +     The dictionary should consist of strings (byte sequences) that are likely
   1.464 +   to be encountered later in the data to be compressed, with the most commonly
   1.465 +   used strings preferably put towards the end of the dictionary. Using a
   1.466 +   dictionary is most useful when the data to be compressed is short and can be
   1.467 +   predicted with good accuracy; the data can then be compressed better than
   1.468 +   with the default empty dictionary.
   1.469 +
   1.470 +     Depending on the size of the compression data structures selected by
   1.471 +   deflateInit or deflateInit2, a part of the dictionary may in effect be
   1.472 +   discarded, for example if the dictionary is larger than the window size in
   1.473 +   deflate or deflate2. Thus the strings most likely to be useful should be
   1.474 +   put at the end of the dictionary, not at the front.
   1.475 +
   1.476 +     Upon return of this function, strm->adler is set to the Adler32 value
   1.477 +   of the dictionary; the decompressor may later use this value to determine
   1.478 +   which dictionary has been used by the compressor. (The Adler32 value
   1.479 +   applies to the whole dictionary even if only a subset of the dictionary is
   1.480 +   actually used by the compressor.)
   1.481 +
   1.482 +     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
   1.483 +   parameter is invalid (such as NULL dictionary) or the stream state is
   1.484 +   inconsistent (for example if deflate has already been called for this stream
   1.485 +   or if the compression method is bsort). deflateSetDictionary does not
   1.486 +   perform any compression: this will be done by deflate().
   1.487 +*/
   1.488 +
   1.489 +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
   1.490 +                                    z_streamp source));
   1.491 +/*
   1.492 +     Sets the destination stream as a complete copy of the source stream.
   1.493 +
   1.494 +     This function can be useful when several compression strategies will be
   1.495 +   tried, for example when there are several ways of pre-processing the input
   1.496 +   data with a filter. The streams that will be discarded should then be freed
   1.497 +   by calling deflateEnd.  Note that deflateCopy duplicates the internal
   1.498 +   compression state which can be quite large, so this strategy is slow and
   1.499 +   can consume lots of memory.
   1.500 +
   1.501 +     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
   1.502 +   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
   1.503 +   (such as zalloc being NULL). msg is left unchanged in both source and
   1.504 +   destination.
   1.505 +*/
   1.506 +
   1.507 +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
   1.508 +/*
   1.509 +     This function is equivalent to deflateEnd followed by deflateInit,
   1.510 +   but does not free and reallocate all the internal compression state.
   1.511 +   The stream will keep the same compression level and any other attributes
   1.512 +   that may have been set by deflateInit2.
   1.513 +
   1.514 +      deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
   1.515 +   stream state was inconsistent (such as zalloc or state being NULL).
   1.516 +*/
   1.517 +
   1.518 +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
   1.519 +				      int level,
   1.520 +				      int strategy));
   1.521 +/*
   1.522 +     Dynamically update the compression level and compression strategy.  The
   1.523 +   interpretation of level and strategy is as in deflateInit2.  This can be
   1.524 +   used to switch between compression and straight copy of the input data, or
   1.525 +   to switch to a different kind of input data requiring a different
   1.526 +   strategy. If the compression level is changed, the input available so far
   1.527 +   is compressed with the old level (and may be flushed); the new level will
   1.528 +   take effect only at the next call of deflate().
   1.529 +
   1.530 +     Before the call of deflateParams, the stream state must be set as for
   1.531 +   a call of deflate(), since the currently available input may have to
   1.532 +   be compressed and flushed. In particular, strm->avail_out must be non-zero.
   1.533 +
   1.534 +     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
   1.535 +   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
   1.536 +   if strm->avail_out was zero.
   1.537 +*/
   1.538 +
   1.539 +/*   
   1.540 +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
   1.541 +                                     int  windowBits));
   1.542 +
   1.543 +     This is another version of inflateInit with an extra parameter. The
   1.544 +   fields next_in, avail_in, zalloc, zfree and opaque must be initialized
   1.545 +   before by the caller.
   1.546 +
   1.547 +     The windowBits parameter is the base two logarithm of the maximum window
   1.548 +   size (the size of the history buffer).  It should be in the range 8..15 for
   1.549 +   this version of the library. The default value is 15 if inflateInit is used
   1.550 +   instead. If a compressed stream with a larger window size is given as
   1.551 +   input, inflate() will return with the error code Z_DATA_ERROR instead of
   1.552 +   trying to allocate a larger window.
   1.553 +
   1.554 +      inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
   1.555 +   memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
   1.556 +   memLevel). msg is set to null if there is no error message.  inflateInit2
   1.557 +   does not perform any decompression apart from reading the zlib header if
   1.558 +   present: this will be done by inflate(). (So next_in and avail_in may be
   1.559 +   modified, but next_out and avail_out are unchanged.)
   1.560 +*/
   1.561 +
   1.562 +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
   1.563 +                                             const Bytef *dictionary,
   1.564 +                                             uInt  dictLength));
   1.565 +/*
   1.566 +     Initializes the decompression dictionary from the given uncompressed byte
   1.567 +   sequence. This function must be called immediately after a call of inflate
   1.568 +   if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
   1.569 +   can be determined from the Adler32 value returned by this call of
   1.570 +   inflate. The compressor and decompressor must use exactly the same
   1.571 +   dictionary (see deflateSetDictionary).
   1.572 +
   1.573 +     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
   1.574 +   parameter is invalid (such as NULL dictionary) or the stream state is
   1.575 +   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
   1.576 +   expected one (incorrect Adler32 value). inflateSetDictionary does not
   1.577 +   perform any decompression: this will be done by subsequent calls of
   1.578 +   inflate().
   1.579 +*/
   1.580 +
   1.581 +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
   1.582 +/* 
   1.583 +    Skips invalid compressed data until a full flush point (see above the
   1.584 +  description of deflate with Z_FULL_FLUSH) can be found, or until all
   1.585 +  available input is skipped. No output is provided.
   1.586 +
   1.587 +    inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
   1.588 +  if no more input was provided, Z_DATA_ERROR if no flush point has been found,
   1.589 +  or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
   1.590 +  case, the application may save the current current value of total_in which
   1.591 +  indicates where valid compressed data was found. In the error case, the
   1.592 +  application may repeatedly call inflateSync, providing more input each time,
   1.593 +  until success or end of the input data.
   1.594 +*/
   1.595 +
   1.596 +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
   1.597 +/*
   1.598 +     This function is equivalent to inflateEnd followed by inflateInit,
   1.599 +   but does not free and reallocate all the internal decompression state.
   1.600 +   The stream will keep attributes that may have been set by inflateInit2.
   1.601 +
   1.602 +      inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
   1.603 +   stream state was inconsistent (such as zalloc or state being NULL).
   1.604 +*/
   1.605 +
   1.606 +
   1.607 +                        /* utility functions */
   1.608 +
   1.609 +/*
   1.610 +     The following utility functions are implemented on top of the
   1.611 +   basic stream-oriented functions. To simplify the interface, some
   1.612 +   default options are assumed (compression level and memory usage,
   1.613 +   standard memory allocation functions). The source code of these
   1.614 +   utility functions can easily be modified if you need special options.
   1.615 +*/
   1.616 +
   1.617 +ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
   1.618 +                                 const Bytef *source, uLong sourceLen));
   1.619 +/*
   1.620 +     Compresses the source buffer into the destination buffer.  sourceLen is
   1.621 +   the byte length of the source buffer. Upon entry, destLen is the total
   1.622 +   size of the destination buffer, which must be at least 0.1% larger than
   1.623 +   sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
   1.624 +   compressed buffer.
   1.625 +     This function can be used to compress a whole file at once if the
   1.626 +   input file is mmap'ed.
   1.627 +     compress returns Z_OK if success, Z_MEM_ERROR if there was not
   1.628 +   enough memory, Z_BUF_ERROR if there was not enough room in the output
   1.629 +   buffer.
   1.630 +*/
   1.631 +
   1.632 +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
   1.633 +                                  const Bytef *source, uLong sourceLen,
   1.634 +                                  int level));
   1.635 +/*
   1.636 +     Compresses the source buffer into the destination buffer. The level
   1.637 +   parameter has the same meaning as in deflateInit.  sourceLen is the byte
   1.638 +   length of the source buffer. Upon entry, destLen is the total size of the
   1.639 +   destination buffer, which must be at least 0.1% larger than sourceLen plus
   1.640 +   12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
   1.641 +
   1.642 +     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
   1.643 +   memory, Z_BUF_ERROR if there was not enough room in the output buffer,
   1.644 +   Z_STREAM_ERROR if the level parameter is invalid.
   1.645 +*/
   1.646 +
   1.647 +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
   1.648 +                                   const Bytef *source, uLong sourceLen));
   1.649 +/*
   1.650 +     Decompresses the source buffer into the destination buffer.  sourceLen is
   1.651 +   the byte length of the source buffer. Upon entry, destLen is the total
   1.652 +   size of the destination buffer, which must be large enough to hold the
   1.653 +   entire uncompressed data. (The size of the uncompressed data must have
   1.654 +   been saved previously by the compressor and transmitted to the decompressor
   1.655 +   by some mechanism outside the scope of this compression library.)
   1.656 +   Upon exit, destLen is the actual size of the compressed buffer.
   1.657 +     This function can be used to decompress a whole file at once if the
   1.658 +   input file is mmap'ed.
   1.659 +
   1.660 +     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
   1.661 +   enough memory, Z_BUF_ERROR if there was not enough room in the output
   1.662 +   buffer, or Z_DATA_ERROR if the input data was corrupted.
   1.663 +*/
   1.664 +
   1.665 +
   1.666 +typedef voidp gzFile;
   1.667 +
   1.668 +ZEXTERN gzFile ZEXPORT gzopen  OF((const char *path, const char *mode));
   1.669 +/*
   1.670 +     Opens a gzip (.gz) file for reading or writing. The mode parameter
   1.671 +   is as in fopen ("rb" or "wb") but can also include a compression level
   1.672 +   ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
   1.673 +   Huffman only compression as in "wb1h". (See the description
   1.674 +   of deflateInit2 for more information about the strategy parameter.)
   1.675 +
   1.676 +     gzopen can be used to read a file which is not in gzip format; in this
   1.677 +   case gzread will directly read from the file without decompression.
   1.678 +
   1.679 +     gzopen returns NULL if the file could not be opened or if there was
   1.680 +   insufficient memory to allocate the (de)compression state; errno
   1.681 +   can be checked to distinguish the two cases (if errno is zero, the
   1.682 +   zlib error is Z_MEM_ERROR).  */
   1.683 +
   1.684 +ZEXTERN gzFile ZEXPORT gzdopen  OF((int fd, const char *mode));
   1.685 +/*
   1.686 +     gzdopen() associates a gzFile with the file descriptor fd.  File
   1.687 +   descriptors are obtained from calls like open, dup, creat, pipe or
   1.688 +   fileno (in the file has been previously opened with fopen).
   1.689 +   The mode parameter is as in gzopen.
   1.690 +     The next call of gzclose on the returned gzFile will also close the
   1.691 +   file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
   1.692 +   descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
   1.693 +     gzdopen returns NULL if there was insufficient memory to allocate
   1.694 +   the (de)compression state.
   1.695 +*/
   1.696 +
   1.697 +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
   1.698 +/*
   1.699 +     Dynamically update the compression level or strategy. See the description
   1.700 +   of deflateInit2 for the meaning of these parameters.
   1.701 +     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
   1.702 +   opened for writing.
   1.703 +*/
   1.704 +
   1.705 +ZEXTERN int ZEXPORT    gzread  OF((gzFile file, voidp buf, unsigned len));
   1.706 +/*
   1.707 +     Reads the given number of uncompressed bytes from the compressed file.
   1.708 +   If the input file was not in gzip format, gzread copies the given number
   1.709 +   of bytes into the buffer.
   1.710 +     gzread returns the number of uncompressed bytes actually read (0 for
   1.711 +   end of file, -1 for error). */
   1.712 +
   1.713 +ZEXTERN int ZEXPORT    gzwrite OF((gzFile file, 
   1.714 +				   const voidp buf, unsigned len));
   1.715 +/*
   1.716 +     Writes the given number of uncompressed bytes into the compressed file.
   1.717 +   gzwrite returns the number of uncompressed bytes actually written
   1.718 +   (0 in case of error).
   1.719 +*/
   1.720 +
   1.721 +ZEXTERN int ZEXPORTVA   gzprintf OF((gzFile file, const char *format, ...));
   1.722 +/*
   1.723 +     Converts, formats, and writes the args to the compressed file under
   1.724 +   control of the format string, as in fprintf. gzprintf returns the number of
   1.725 +   uncompressed bytes actually written (0 in case of error).
   1.726 +*/
   1.727 +
   1.728 +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
   1.729 +/*
   1.730 +      Writes the given null-terminated string to the compressed file, excluding
   1.731 +   the terminating null character.
   1.732 +      gzputs returns the number of characters written, or -1 in case of error.
   1.733 +*/
   1.734 +
   1.735 +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
   1.736 +/*
   1.737 +      Reads bytes from the compressed file until len-1 characters are read, or
   1.738 +   a newline character is read and transferred to buf, or an end-of-file
   1.739 +   condition is encountered.  The string is then terminated with a null
   1.740 +   character.
   1.741 +      gzgets returns buf, or Z_NULL in case of error.
   1.742 +*/
   1.743 +
   1.744 +ZEXTERN int ZEXPORT    gzputc OF((gzFile file, int c));
   1.745 +/*
   1.746 +      Writes c, converted to an unsigned char, into the compressed file.
   1.747 +   gzputc returns the value that was written, or -1 in case of error.
   1.748 +*/
   1.749 +
   1.750 +ZEXTERN int ZEXPORT    gzgetc OF((gzFile file));
   1.751 +/*
   1.752 +      Reads one byte from the compressed file. gzgetc returns this byte
   1.753 +   or -1 in case of end of file or error.
   1.754 +*/
   1.755 +
   1.756 +ZEXTERN int ZEXPORT    gzflush OF((gzFile file, int flush));
   1.757 +/*
   1.758 +     Flushes all pending output into the compressed file. The parameter
   1.759 +   flush is as in the deflate() function. The return value is the zlib
   1.760 +   error number (see function gzerror below). gzflush returns Z_OK if
   1.761 +   the flush parameter is Z_FINISH and all output could be flushed.
   1.762 +     gzflush should be called only when strictly necessary because it can
   1.763 +   degrade compression.
   1.764 +*/
   1.765 +
   1.766 +ZEXTERN z_off_t ZEXPORT    gzseek OF((gzFile file,
   1.767 +				      z_off_t offset, int whence));
   1.768 +/* 
   1.769 +      Sets the starting position for the next gzread or gzwrite on the
   1.770 +   given compressed file. The offset represents a number of bytes in the
   1.771 +   uncompressed data stream. The whence parameter is defined as in lseek(2);
   1.772 +   the value SEEK_END is not supported.
   1.773 +     If the file is opened for reading, this function is emulated but can be
   1.774 +   extremely slow. If the file is opened for writing, only forward seeks are
   1.775 +   supported; gzseek then compresses a sequence of zeroes up to the new
   1.776 +   starting position.
   1.777 +
   1.778 +      gzseek returns the resulting offset location as measured in bytes from
   1.779 +   the beginning of the uncompressed stream, or -1 in case of error, in
   1.780 +   particular if the file is opened for writing and the new starting position
   1.781 +   would be before the current position.
   1.782 +*/
   1.783 +
   1.784 +ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
   1.785 +/*
   1.786 +     Rewinds the given file. This function is supported only for reading.
   1.787 +
   1.788 +   gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
   1.789 +*/
   1.790 +
   1.791 +ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
   1.792 +/*
   1.793 +     Returns the starting position for the next gzread or gzwrite on the
   1.794 +   given compressed file. This position represents a number of bytes in the
   1.795 +   uncompressed data stream.
   1.796 +
   1.797 +   gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
   1.798 +*/
   1.799 +
   1.800 +ZEXTERN int ZEXPORT gzeof OF((gzFile file));
   1.801 +/*
   1.802 +     Returns 1 when EOF has previously been detected reading the given
   1.803 +   input stream, otherwise zero.
   1.804 +*/
   1.805 +
   1.806 +ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
   1.807 +/*
   1.808 +     Flushes all pending output if necessary, closes the compressed file
   1.809 +   and deallocates all the (de)compression state. The return value is the zlib
   1.810 +   error number (see function gzerror below).
   1.811 +*/
   1.812 +
   1.813 +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
   1.814 +/*
   1.815 +     Returns the error message for the last error which occurred on the
   1.816 +   given compressed file. errnum is set to zlib error number. If an
   1.817 +   error occurred in the file system and not in the compression library,
   1.818 +   errnum is set to Z_ERRNO and the application may consult errno
   1.819 +   to get the exact error code.
   1.820 +*/
   1.821 +
   1.822 +                        /* checksum functions */
   1.823 +
   1.824 +/*
   1.825 +     These functions are not related to compression but are exported
   1.826 +   anyway because they might be useful in applications using the
   1.827 +   compression library.
   1.828 +*/
   1.829 +
   1.830 +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
   1.831 +
   1.832 +/*
   1.833 +     Update a running Adler-32 checksum with the bytes buf[0..len-1] and
   1.834 +   return the updated checksum. If buf is NULL, this function returns
   1.835 +   the required initial value for the checksum.
   1.836 +   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
   1.837 +   much faster. Usage example:
   1.838 +
   1.839 +     uLong adler = adler32(0L, Z_NULL, 0);
   1.840 +
   1.841 +     while (read_buffer(buffer, length) != EOF) {
   1.842 +       adler = adler32(adler, buffer, length);
   1.843 +     }
   1.844 +     if (adler != original_adler) error();
   1.845 +*/
   1.846 +
   1.847 +ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
   1.848 +/*
   1.849 +     Update a running crc with the bytes buf[0..len-1] and return the updated
   1.850 +   crc. If buf is NULL, this function returns the required initial value
   1.851 +   for the crc. Pre- and post-conditioning (one's complement) is performed
   1.852 +   within this function so it shouldn't be done by the application.
   1.853 +   Usage example:
   1.854 +
   1.855 +     uLong crc = crc32(0L, Z_NULL, 0);
   1.856 +
   1.857 +     while (read_buffer(buffer, length) != EOF) {
   1.858 +       crc = crc32(crc, buffer, length);
   1.859 +     }
   1.860 +     if (crc != original_crc) error();
   1.861 +*/
   1.862 +
   1.863 +
   1.864 +                        /* various hacks, don't look :) */
   1.865 +
   1.866 +/* deflateInit and inflateInit are macros to allow checking the zlib version
   1.867 + * and the compiler's view of z_stream:
   1.868 + */
   1.869 +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
   1.870 +                                     const char *version, int stream_size));
   1.871 +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
   1.872 +                                     const char *version, int stream_size));
   1.873 +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
   1.874 +                                      int windowBits, int memLevel,
   1.875 +                                      int strategy, const char *version,
   1.876 +                                      int stream_size));
   1.877 +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
   1.878 +                                      const char *version, int stream_size));
   1.879 +#define deflateInit(strm, level) \
   1.880 +        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
   1.881 +#define inflateInit(strm) \
   1.882 +        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
   1.883 +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
   1.884 +        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
   1.885 +                      (strategy),           ZLIB_VERSION, sizeof(z_stream))
   1.886 +#define inflateInit2(strm, windowBits) \
   1.887 +        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
   1.888 +
   1.889 +
   1.890 +#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
   1.891 +    struct internal_state {int dummy;}; /* hack for buggy compilers */
   1.892 +#endif
   1.893 +
   1.894 +ZEXTERN const char   * ZEXPORT zError           OF((int err));
   1.895 +ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp z));
   1.896 +ZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));
   1.897 +
   1.898 +#ifdef __cplusplus
   1.899 +}
   1.900 +#endif
   1.901 +
   1.902 +#endif /* _ZLIB_H */