Back to home page

OSCL-LXR

 
 

    


0001 /* zlib.h -- interface of the 'zlib' general purpose compression library
0002 
0003   Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
0004 
0005   This software is provided 'as-is', without any express or implied
0006   warranty.  In no event will the authors be held liable for any damages
0007   arising from the use of this software.
0008 
0009   Permission is granted to anyone to use this software for any purpose,
0010   including commercial applications, and to alter it and redistribute it
0011   freely, subject to the following restrictions:
0012 
0013   1. The origin of this software must not be misrepresented; you must not
0014      claim that you wrote the original software. If you use this software
0015      in a product, an acknowledgment in the product documentation would be
0016      appreciated but is not required.
0017   2. Altered source versions must be plainly marked as such, and must not be
0018      misrepresented as being the original software.
0019   3. This notice may not be removed or altered from any source distribution.
0020 
0021   Jean-loup Gailly        Mark Adler
0022   jloup@gzip.org          madler@alumni.caltech.edu
0023 
0024 
0025   The data format used by the zlib library is described by RFCs (Request for
0026   Comments) 1950 to 1952 in the files https://www.ietf.org/rfc/rfc1950.txt
0027   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
0028 */
0029 
0030 #ifndef _ZLIB_H
0031 #define _ZLIB_H
0032 
0033 #include <linux/zconf.h>
0034 
0035 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
0036 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
0037 
0038 /*
0039   This is a modified version of zlib for use inside the Linux kernel.
0040   The main changes are to perform all memory allocation in advance.
0041 
0042   Inflation Changes:
0043     * Z_PACKET_FLUSH is added and used by ppp_deflate. Before returning
0044       this checks there is no more input data available and the next data
0045       is a STORED block. It also resets the mode to be read for the next
0046       data, all as per PPP requirements.
0047     * Addition of zlib_inflateIncomp which copies incompressible data into
0048       the history window and adjusts the accoutning without calling
0049       zlib_inflate itself to inflate the data.
0050 */
0051 
0052 /* 
0053      The 'zlib' compression library provides in-memory compression and
0054   decompression functions, including integrity checks of the uncompressed
0055   data.  This version of the library supports only one compression method
0056   (deflation) but other algorithms will be added later and will have the same
0057   stream interface.
0058 
0059      Compression can be done in a single step if the buffers are large
0060   enough (for example if an input file is mmap'ed), or can be done by
0061   repeated calls of the compression function.  In the latter case, the
0062   application must provide more input and/or consume the output
0063   (providing more output space) before each call.
0064 
0065      The compressed data format used by default by the in-memory functions is
0066   the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
0067   around a deflate stream, which is itself documented in RFC 1951.
0068 
0069      The library also supports reading and writing files in gzip (.gz) format
0070   with an interface similar to that of stdio.
0071 
0072      The zlib format was designed to be compact and fast for use in memory
0073   and on communications channels.  The gzip format was designed for single-
0074   file compression on file systems, has a larger header than zlib to maintain
0075   directory information, and uses a different, slower check method than zlib.
0076 
0077      The library does not install any signal handler. The decoder checks
0078   the consistency of the compressed data, so the library should never
0079   crash even in case of corrupted input.
0080 */
0081 
0082 struct internal_state;
0083 
0084 typedef struct z_stream_s {
0085     const Byte *next_in;   /* next input byte */
0086     uLong avail_in;  /* number of bytes available at next_in */
0087     uLong    total_in;  /* total nb of input bytes read so far */
0088 
0089     Byte    *next_out;  /* next output byte should be put there */
0090     uLong avail_out; /* remaining free space at next_out */
0091     uLong    total_out; /* total nb of bytes output so far */
0092 
0093     char     *msg;      /* last error message, NULL if no error */
0094     struct internal_state *state; /* not visible by applications */
0095 
0096     void     *workspace; /* memory allocated for this stream */
0097 
0098     int     data_type;  /* best guess about the data type: ascii or binary */
0099     uLong   adler;      /* adler32 value of the uncompressed data */
0100     uLong   reserved;   /* reserved for future use */
0101 } z_stream;
0102 
0103 typedef z_stream *z_streamp;
0104 
0105 /*
0106    The application must update next_in and avail_in when avail_in has
0107    dropped to zero. It must update next_out and avail_out when avail_out
0108    has dropped to zero. The application must initialize zalloc, zfree and
0109    opaque before calling the init function. All other fields are set by the
0110    compression library and must not be updated by the application.
0111 
0112    The opaque value provided by the application will be passed as the first
0113    parameter for calls of zalloc and zfree. This can be useful for custom
0114    memory management. The compression library attaches no meaning to the
0115    opaque value.
0116 
0117    zalloc must return NULL if there is not enough memory for the object.
0118    If zlib is used in a multi-threaded application, zalloc and zfree must be
0119    thread safe.
0120 
0121    On 16-bit systems, the functions zalloc and zfree must be able to allocate
0122    exactly 65536 bytes, but will not be required to allocate more than this
0123    if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
0124    pointers returned by zalloc for objects of exactly 65536 bytes *must*
0125    have their offset normalized to zero. The default allocation function
0126    provided by this library ensures this (see zutil.c). To reduce memory
0127    requirements and avoid any allocation of 64K objects, at the expense of
0128    compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
0129 
0130    The fields total_in and total_out can be used for statistics or
0131    progress reports. After compression, total_in holds the total size of
0132    the uncompressed data and may be saved for use in the decompressor
0133    (particularly if the decompressor wants to decompress everything in
0134    a single step).
0135 */
0136 
0137                         /* constants */
0138 
0139 #define Z_NO_FLUSH      0
0140 #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
0141 #define Z_PACKET_FLUSH  2
0142 #define Z_SYNC_FLUSH    3
0143 #define Z_FULL_FLUSH    4
0144 #define Z_FINISH        5
0145 #define Z_BLOCK         6 /* Only for inflate at present */
0146 /* Allowed flush values; see deflate() and inflate() below for details */
0147 
0148 #define Z_OK            0
0149 #define Z_STREAM_END    1
0150 #define Z_NEED_DICT     2
0151 #define Z_ERRNO        (-1)
0152 #define Z_STREAM_ERROR (-2)
0153 #define Z_DATA_ERROR   (-3)
0154 #define Z_MEM_ERROR    (-4)
0155 #define Z_BUF_ERROR    (-5)
0156 #define Z_VERSION_ERROR (-6)
0157 /* Return codes for the compression/decompression functions. Negative
0158  * values are errors, positive values are used for special but normal events.
0159  */
0160 
0161 #define Z_NO_COMPRESSION         0
0162 #define Z_BEST_SPEED             1
0163 #define Z_BEST_COMPRESSION       9
0164 #define Z_DEFAULT_COMPRESSION  (-1)
0165 /* compression levels */
0166 
0167 #define Z_FILTERED            1
0168 #define Z_HUFFMAN_ONLY        2
0169 #define Z_DEFAULT_STRATEGY    0
0170 /* compression strategy; see deflateInit2() below for details */
0171 
0172 #define Z_BINARY   0
0173 #define Z_ASCII    1
0174 #define Z_UNKNOWN  2
0175 /* Possible values of the data_type field */
0176 
0177 #define Z_DEFLATED   8
0178 /* The deflate compression method (the only one supported in this version) */
0179 
0180                         /* basic functions */
0181 
0182 extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
0183 /*
0184    Returns the number of bytes that needs to be allocated for a per-
0185    stream workspace with the specified parameters.  A pointer to this
0186    number of bytes should be returned in stream->workspace before
0187    you call zlib_deflateInit() or zlib_deflateInit2().  If you call
0188    zlib_deflateInit(), specify windowBits = MAX_WBITS and memLevel =
0189    MAX_MEM_LEVEL here.  If you call zlib_deflateInit2(), the windowBits
0190    and memLevel parameters passed to zlib_deflateInit2() must not
0191    exceed those passed here.
0192 */
0193 
0194 extern int zlib_deflate_dfltcc_enabled (void);
0195 /*
0196    Returns 1 if Deflate-Conversion facility is installed and enabled,
0197    otherwise 0.
0198 */
0199 
0200 /* 
0201 extern int deflateInit (z_streamp strm, int level);
0202 
0203      Initializes the internal stream state for compression. The fields
0204    zalloc, zfree and opaque must be initialized before by the caller.
0205    If zalloc and zfree are set to NULL, deflateInit updates them to
0206    use default allocation functions.
0207 
0208      The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
0209    1 gives best speed, 9 gives best compression, 0 gives no compression at
0210    all (the input data is simply copied a block at a time).
0211    Z_DEFAULT_COMPRESSION requests a default compromise between speed and
0212    compression (currently equivalent to level 6).
0213 
0214      deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
0215    enough memory, Z_STREAM_ERROR if level is not a valid compression level,
0216    Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
0217    with the version assumed by the caller (ZLIB_VERSION).
0218    msg is set to null if there is no error message.  deflateInit does not
0219    perform any compression: this will be done by deflate().
0220 */
0221 
0222 
0223 extern int zlib_deflate (z_streamp strm, int flush);
0224 /*
0225     deflate compresses as much data as possible, and stops when the input
0226   buffer becomes empty or the output buffer becomes full. It may introduce some
0227   output latency (reading input without producing any output) except when
0228   forced to flush.
0229 
0230     The detailed semantics are as follows. deflate performs one or both of the
0231   following actions:
0232 
0233   - Compress more input starting at next_in and update next_in and avail_in
0234     accordingly. If not all input can be processed (because there is not
0235     enough room in the output buffer), next_in and avail_in are updated and
0236     processing will resume at this point for the next call of deflate().
0237 
0238   - Provide more output starting at next_out and update next_out and avail_out
0239     accordingly. This action is forced if the parameter flush is non zero.
0240     Forcing flush frequently degrades the compression ratio, so this parameter
0241     should be set only when necessary (in interactive applications).
0242     Some output may be provided even if flush is not set.
0243 
0244   Before the call of deflate(), the application should ensure that at least
0245   one of the actions is possible, by providing more input and/or consuming
0246   more output, and updating avail_in or avail_out accordingly; avail_out
0247   should never be zero before the call. The application can consume the
0248   compressed output when it wants, for example when the output buffer is full
0249   (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
0250   and with zero avail_out, it must be called again after making room in the
0251   output buffer because there might be more output pending.
0252 
0253     If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
0254   flushed to the output buffer and the output is aligned on a byte boundary, so
0255   that the decompressor can get all input data available so far. (In particular
0256   avail_in is zero after the call if enough output space has been provided
0257   before the call.)  Flushing may degrade compression for some compression
0258   algorithms and so it should be used only when necessary.
0259 
0260     If flush is set to Z_FULL_FLUSH, all output is flushed as with
0261   Z_SYNC_FLUSH, and the compression state is reset so that decompression can
0262   restart from this point if previous compressed data has been damaged or if
0263   random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
0264   the compression.
0265 
0266     If deflate returns with avail_out == 0, this function must be called again
0267   with the same value of the flush parameter and more output space (updated
0268   avail_out), until the flush is complete (deflate returns with non-zero
0269   avail_out).
0270 
0271     If the parameter flush is set to Z_FINISH, pending input is processed,
0272   pending output is flushed and deflate returns with Z_STREAM_END if there
0273   was enough output space; if deflate returns with Z_OK, this function must be
0274   called again with Z_FINISH and more output space (updated avail_out) but no
0275   more input data, until it returns with Z_STREAM_END or an error. After
0276   deflate has returned Z_STREAM_END, the only possible operations on the
0277   stream are deflateReset or deflateEnd.
0278   
0279     Z_FINISH can be used immediately after deflateInit if all the compression
0280   is to be done in a single step. In this case, avail_out must be at least
0281   0.1% larger than avail_in plus 12 bytes.  If deflate does not return
0282   Z_STREAM_END, then it must be called again as described above.
0283 
0284     deflate() sets strm->adler to the adler32 checksum of all input read
0285   so far (that is, total_in bytes).
0286 
0287     deflate() may update data_type if it can make a good guess about
0288   the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
0289   binary. This field is only for information purposes and does not affect
0290   the compression algorithm in any manner.
0291 
0292     deflate() returns Z_OK if some progress has been made (more input
0293   processed or more output produced), Z_STREAM_END if all input has been
0294   consumed and all output has been produced (only when flush is set to
0295   Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
0296   if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
0297   (for example avail_in or avail_out was zero).
0298 */
0299 
0300 
0301 extern int zlib_deflateEnd (z_streamp strm);
0302 /*
0303      All dynamically allocated data structures for this stream are freed.
0304    This function discards any unprocessed input and does not flush any
0305    pending output.
0306 
0307      deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
0308    stream state was inconsistent, Z_DATA_ERROR if the stream was freed
0309    prematurely (some input or output was discarded). In the error case,
0310    msg may be set but then points to a static string (which must not be
0311    deallocated).
0312 */
0313 
0314 
0315 extern int zlib_inflate_workspacesize (void);
0316 /*
0317    Returns the number of bytes that needs to be allocated for a per-
0318    stream workspace.  A pointer to this number of bytes should be
0319    returned in stream->workspace before calling zlib_inflateInit().
0320 */
0321 
0322 /* 
0323 extern int zlib_inflateInit (z_streamp strm);
0324 
0325      Initializes the internal stream state for decompression. The fields
0326    next_in, avail_in, and workspace must be initialized before by
0327    the caller. If next_in is not NULL and avail_in is large enough (the exact
0328    value depends on the compression method), inflateInit determines the
0329    compression method from the zlib header and allocates all data structures
0330    accordingly; otherwise the allocation will be deferred to the first call of
0331    inflate.  If zalloc and zfree are set to NULL, inflateInit updates them to
0332    use default allocation functions.
0333 
0334      inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
0335    memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
0336    version assumed by the caller.  msg is set to null if there is no error
0337    message. inflateInit does not perform any decompression apart from reading
0338    the zlib header if present: this will be done by inflate().  (So next_in and
0339    avail_in may be modified, but next_out and avail_out are unchanged.)
0340 */
0341 
0342 
0343 extern int zlib_inflate (z_streamp strm, int flush);
0344 /*
0345     inflate decompresses as much data as possible, and stops when the input
0346   buffer becomes empty or the output buffer becomes full. It may introduce
0347   some output latency (reading input without producing any output) except when
0348   forced to flush.
0349 
0350   The detailed semantics are as follows. inflate performs one or both of the
0351   following actions:
0352 
0353   - Decompress more input starting at next_in and update next_in and avail_in
0354     accordingly. If not all input can be processed (because there is not
0355     enough room in the output buffer), next_in is updated and processing
0356     will resume at this point for the next call of inflate().
0357 
0358   - Provide more output starting at next_out and update next_out and avail_out
0359     accordingly.  inflate() provides as much output as possible, until there
0360     is no more input data or no more space in the output buffer (see below
0361     about the flush parameter).
0362 
0363   Before the call of inflate(), the application should ensure that at least
0364   one of the actions is possible, by providing more input and/or consuming
0365   more output, and updating the next_* and avail_* values accordingly.
0366   The application can consume the uncompressed output when it wants, for
0367   example when the output buffer is full (avail_out == 0), or after each
0368   call of inflate(). If inflate returns Z_OK and with zero avail_out, it
0369   must be called again after making room in the output buffer because there
0370   might be more output pending.
0371 
0372     The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
0373   Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
0374   output as possible to the output buffer. Z_BLOCK requests that inflate() stop
0375   if and when it gets to the next deflate block boundary. When decoding the
0376   zlib or gzip format, this will cause inflate() to return immediately after
0377   the header and before the first block. When doing a raw inflate, inflate()
0378   will go ahead and process the first block, and will return when it gets to
0379   the end of that block, or when it runs out of data.
0380 
0381     The Z_BLOCK option assists in appending to or combining deflate streams.
0382   Also to assist in this, on return inflate() will set strm->data_type to the
0383   number of unused bits in the last byte taken from strm->next_in, plus 64
0384   if inflate() is currently decoding the last block in the deflate stream,
0385   plus 128 if inflate() returned immediately after decoding an end-of-block
0386   code or decoding the complete header up to just before the first byte of the
0387   deflate stream. The end-of-block will not be indicated until all of the
0388   uncompressed data from that block has been written to strm->next_out.  The
0389   number of unused bits may in general be greater than seven, except when
0390   bit 7 of data_type is set, in which case the number of unused bits will be
0391   less than eight.
0392 
0393     inflate() should normally be called until it returns Z_STREAM_END or an
0394   error. However if all decompression is to be performed in a single step
0395   (a single call of inflate), the parameter flush should be set to
0396   Z_FINISH. In this case all pending input is processed and all pending
0397   output is flushed; avail_out must be large enough to hold all the
0398   uncompressed data. (The size of the uncompressed data may have been saved
0399   by the compressor for this purpose.) The next operation on this stream must
0400   be inflateEnd to deallocate the decompression state. The use of Z_FINISH
0401   is never required, but can be used to inform inflate that a faster approach
0402   may be used for the single inflate() call.
0403 
0404      In this implementation, inflate() always flushes as much output as
0405   possible to the output buffer, and always uses the faster approach on the
0406   first call. So the only effect of the flush parameter in this implementation
0407   is on the return value of inflate(), as noted below, or when it returns early
0408   because Z_BLOCK is used.
0409 
0410      If a preset dictionary is needed after this call (see inflateSetDictionary
0411   below), inflate sets strm->adler to the adler32 checksum of the dictionary
0412   chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
0413   strm->adler to the adler32 checksum of all output produced so far (that is,
0414   total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
0415   below. At the end of the stream, inflate() checks that its computed adler32
0416   checksum is equal to that saved by the compressor and returns Z_STREAM_END
0417   only if the checksum is correct.
0418 
0419     inflate() will decompress and check either zlib-wrapped or gzip-wrapped
0420   deflate data.  The header type is detected automatically.  Any information
0421   contained in the gzip header is not retained, so applications that need that
0422   information should instead use raw inflate, see inflateInit2() below, or
0423   inflateBack() and perform their own processing of the gzip header and
0424   trailer.
0425 
0426     inflate() returns Z_OK if some progress has been made (more input processed
0427   or more output produced), Z_STREAM_END if the end of the compressed data has
0428   been reached and all uncompressed output has been produced, Z_NEED_DICT if a
0429   preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
0430   corrupted (input stream not conforming to the zlib format or incorrect check
0431   value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
0432   if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
0433   Z_BUF_ERROR if no progress is possible or if there was not enough room in the
0434   output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
0435   inflate() can be called again with more input and more output space to
0436   continue decompressing. If Z_DATA_ERROR is returned, the application may then
0437   call inflateSync() to look for a good compression block if a partial recovery
0438   of the data is desired.
0439 */
0440 
0441 
0442 extern int zlib_inflateEnd (z_streamp strm);
0443 /*
0444      All dynamically allocated data structures for this stream are freed.
0445    This function discards any unprocessed input and does not flush any
0446    pending output.
0447 
0448      inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
0449    was inconsistent. In the error case, msg may be set but then points to a
0450    static string (which must not be deallocated).
0451 */
0452 
0453                         /* Advanced functions */
0454 
0455 /*
0456     The following functions are needed only in some special applications.
0457 */
0458 
0459 /*   
0460 extern int deflateInit2 (z_streamp strm,
0461                                      int  level,
0462                                      int  method,
0463                                      int  windowBits,
0464                                      int  memLevel,
0465                                      int  strategy);
0466 
0467      This is another version of deflateInit with more compression options. The
0468    fields next_in, zalloc, zfree and opaque must be initialized before by
0469    the caller.
0470 
0471      The method parameter is the compression method. It must be Z_DEFLATED in
0472    this version of the library.
0473 
0474      The windowBits parameter is the base two logarithm of the window size
0475    (the size of the history buffer).  It should be in the range 8..15 for this
0476    version of the library. Larger values of this parameter result in better
0477    compression at the expense of memory usage. The default value is 15 if
0478    deflateInit is used instead.
0479 
0480      The memLevel parameter specifies how much memory should be allocated
0481    for the internal compression state. memLevel=1 uses minimum memory but
0482    is slow and reduces compression ratio; memLevel=9 uses maximum memory
0483    for optimal speed. The default value is 8. See zconf.h for total memory
0484    usage as a function of windowBits and memLevel.
0485 
0486      The strategy parameter is used to tune the compression algorithm. Use the
0487    value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
0488    filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
0489    string match).  Filtered data consists mostly of small values with a
0490    somewhat random distribution. In this case, the compression algorithm is
0491    tuned to compress them better. The effect of Z_FILTERED is to force more
0492    Huffman coding and less string matching; it is somewhat intermediate
0493    between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
0494    the compression ratio but not the correctness of the compressed output even
0495    if it is not set appropriately.
0496 
0497       deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
0498    memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
0499    method). msg is set to null if there is no error message.  deflateInit2 does
0500    not perform any compression: this will be done by deflate().
0501 */
0502 
0503 extern int zlib_deflateReset (z_streamp strm);
0504 /*
0505      This function is equivalent to deflateEnd followed by deflateInit,
0506    but does not free and reallocate all the internal compression state.
0507    The stream will keep the same compression level and any other attributes
0508    that may have been set by deflateInit2.
0509 
0510       deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
0511    stream state was inconsistent (such as zalloc or state being NULL).
0512 */
0513 
0514 static inline unsigned long deflateBound(unsigned long s)
0515 {
0516     return s + ((s + 7) >> 3) + ((s + 63) >> 6) + 11;
0517 }
0518 
0519 /*   
0520 extern int inflateInit2 (z_streamp strm, int  windowBits);
0521 
0522      This is another version of inflateInit with an extra parameter. The
0523    fields next_in, avail_in, zalloc, zfree and opaque must be initialized
0524    before by the caller.
0525 
0526      The windowBits parameter is the base two logarithm of the maximum window
0527    size (the size of the history buffer).  It should be in the range 8..15 for
0528    this version of the library. The default value is 15 if inflateInit is used
0529    instead. windowBits must be greater than or equal to the windowBits value
0530    provided to deflateInit2() while compressing, or it must be equal to 15 if
0531    deflateInit2() was not used. If a compressed stream with a larger window
0532    size is given as input, inflate() will return with the error code
0533    Z_DATA_ERROR instead of trying to allocate a larger window.
0534 
0535      windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
0536    determines the window size. inflate() will then process raw deflate data,
0537    not looking for a zlib or gzip header, not generating a check value, and not
0538    looking for any check values for comparison at the end of the stream. This
0539    is for use with other formats that use the deflate compressed data format
0540    such as zip.  Those formats provide their own check values. If a custom
0541    format is developed using the raw deflate format for compressed data, it is
0542    recommended that a check value such as an adler32 or a crc32 be applied to
0543    the uncompressed data as is done in the zlib, gzip, and zip formats.  For
0544    most applications, the zlib format should be used as is. Note that comments
0545    above on the use in deflateInit2() applies to the magnitude of windowBits.
0546 
0547      windowBits can also be greater than 15 for optional gzip decoding. Add
0548    32 to windowBits to enable zlib and gzip decoding with automatic header
0549    detection, or add 16 to decode only the gzip format (the zlib format will
0550    return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is
0551    a crc32 instead of an adler32.
0552 
0553      inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
0554    memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
0555    is set to null if there is no error message.  inflateInit2 does not perform
0556    any decompression apart from reading the zlib header if present: this will
0557    be done by inflate(). (So next_in and avail_in may be modified, but next_out
0558    and avail_out are unchanged.)
0559 */
0560 
0561 extern int zlib_inflateReset (z_streamp strm);
0562 /*
0563      This function is equivalent to inflateEnd followed by inflateInit,
0564    but does not free and reallocate all the internal decompression state.
0565    The stream will keep attributes that may have been set by inflateInit2.
0566 
0567       inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
0568    stream state was inconsistent (such as zalloc or state being NULL).
0569 */
0570 
0571 extern int zlib_inflateIncomp (z_stream *strm);
0572 /*
0573      This function adds the data at next_in (avail_in bytes) to the output
0574    history without performing any output.  There must be no pending output,
0575    and the decompressor must be expecting to see the start of a block.
0576    Calling this function is equivalent to decompressing a stored block
0577    containing the data at next_in (except that the data is not output).
0578 */
0579 
0580 #define zlib_deflateInit(strm, level) \
0581     zlib_deflateInit2((strm), (level), Z_DEFLATED, MAX_WBITS, \
0582                   DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY)
0583 #define zlib_inflateInit(strm) \
0584     zlib_inflateInit2((strm), DEF_WBITS)
0585 
0586 extern int zlib_deflateInit2(z_streamp strm, int  level, int  method,
0587                                       int windowBits, int memLevel,
0588                                       int strategy);
0589 extern int zlib_inflateInit2(z_streamp strm, int  windowBits);
0590 
0591 #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
0592     struct internal_state {int dummy;}; /* hack for buggy compilers */
0593 #endif
0594 
0595 /* Utility function: initialize zlib, unpack binary blob, clean up zlib,
0596  * return len or negative error code. */
0597 extern int zlib_inflate_blob(void *dst, unsigned dst_sz, const void *src, unsigned src_sz);
0598 
0599 #endif /* _ZLIB_H */