security/nss/lib/jar/jzlib.h

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

mercurial