1311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* zlib.h -- interface of the 'zlib' general purpose compression library 2311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff version 1.2.3, July 18th, 2005 3311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 4311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler 5311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 6311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This software is provided 'as-is', without any express or implied 7311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff warranty. In no event will the authors be held liable for any damages 8311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff arising from the use of this software. 9311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 10311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Permission is granted to anyone to use this software for any purpose, 11311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff including commercial applications, and to alter it and redistribute it 12311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff freely, subject to the following restrictions: 13311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 14311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1. The origin of this software must not be misrepresented; you must not 15311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff claim that you wrote the original software. If you use this software 16311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff in a product, an acknowledgment in the product documentation would be 17311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff appreciated but is not required. 18311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 2. Altered source versions must be plainly marked as such, and must not be 19311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff misrepresented as being the original software. 20311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 3. This notice may not be removed or altered from any source distribution. 21311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 22311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Jean-loup Gailly Mark Adler 23311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff jloup@gzip.org madler@alumni.caltech.edu 24311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 25311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 26311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The data format used by the zlib library is described by RFCs (Request for 27311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt 28311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). 29311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 30311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 31311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#ifndef ZLIB_H 32311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define ZLIB_H 33311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 34311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#include "zconf.h" 35311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 36311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#ifdef __cplusplus 37311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffextern "C" { 38311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#endif 39311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 40311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define ZLIB_VERSION "1.2.3" 41311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define ZLIB_VERNUM 0x1230 42311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 43311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 44311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The 'zlib' compression library provides in-memory compression and 45311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff decompression functions, including integrity checks of the uncompressed 46311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff data. This version of the library supports only one compression method 47311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (deflation) but other algorithms will be added later and will have the same 48311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream interface. 49311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 50311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Compression can be done in a single step if the buffers are large 51311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff enough (for example if an input file is mmap'ed), or can be done by 52311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff repeated calls of the compression function. In the latter case, the 53311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff application must provide more input and/or consume the output 54311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (providing more output space) before each call. 55311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 56311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The compressed data format used by default by the in-memory functions is 57311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped 58311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff around a deflate stream, which is itself documented in RFC 1951. 59311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 60311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The library also supports reading and writing files in gzip (.gz) format 61311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff with an interface similar to that of stdio using the functions that start 62311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff with "gz". The gzip format is different from the zlib format. gzip is a 63311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. 64311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 65311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This library can optionally read and write gzip streams in memory as well. 66311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 67311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The zlib format was designed to be compact and fast for use in memory 68311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff and on communications channels. The gzip format was designed for single- 69311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff file compression on file systems, has a larger header than zlib to maintain 70311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff directory information, and uses a different, slower check method than zlib. 71311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 72311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The library does not install any signal handler. The decoder checks 73311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the consistency of the compressed data, so the library should never 74311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff crash even in case of corrupted input. 75311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 76311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 77311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdifftypedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); 78311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdifftypedef void (*free_func) OF((voidpf opaque, voidpf address)); 79311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 80311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffstruct internal_state; 81311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 82311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdifftypedef struct z_stream_s { 83311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Bytef *next_in; /* next input byte */ 84311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uInt avail_in; /* number of bytes available at next_in */ 85311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uLong total_in; /* total nb of input bytes read so far */ 86311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 87311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Bytef *next_out; /* next output byte should be put there */ 88311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uInt avail_out; /* remaining free space at next_out */ 89311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uLong total_out; /* total nb of bytes output so far */ 90311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 91311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff char *msg; /* last error message, NULL if no error */ 92311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff struct internal_state FAR *state; /* not visible by applications */ 93311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 94311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff alloc_func zalloc; /* used to allocate the internal state */ 95311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff free_func zfree; /* used to free the internal state */ 96311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff voidpf opaque; /* private data object passed to zalloc and zfree */ 97311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 98311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int data_type; /* best guess about the data type: binary or text */ 99311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uLong adler; /* adler32 value of the uncompressed data */ 100311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uLong reserved; /* reserved for future use */ 101311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff} z_stream; 102311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 103311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdifftypedef z_stream FAR *z_streamp; 104311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 105311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 106311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzip header information passed to and from zlib routines. See RFC 1952 107311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff for more details on the meanings of these fields. 108311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 109311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdifftypedef struct gz_header_s { 110311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int text; /* true if compressed data believed to be text */ 111311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uLong time; /* modification time */ 112311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int xflags; /* extra flags (not used when writing a gzip file) */ 113311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int os; /* operating system */ 114311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Bytef *extra; /* pointer to extra field or Z_NULL if none */ 115311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ 116311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uInt extra_max; /* space at extra (only when reading header) */ 117311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ 118311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uInt name_max; /* space at name (only when reading header) */ 119311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ 120311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uInt comm_max; /* space at comment (only when reading header) */ 121311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int hcrc; /* true if there was or will be a header crc */ 122311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int done; /* true when done reading gzip header (not used 123311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff when writing a gzip file) */ 124311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff} gz_header; 125311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 126311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdifftypedef gz_header FAR *gz_headerp; 127311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 128311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 129311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The application must update next_in and avail_in when avail_in has 130311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff dropped to zero. It must update next_out and avail_out when avail_out 131311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff has dropped to zero. The application must initialize zalloc, zfree and 132311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff opaque before calling the init function. All other fields are set by the 133311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compression library and must not be updated by the application. 134311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 135311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The opaque value provided by the application will be passed as the first 136311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff parameter for calls of zalloc and zfree. This can be useful for custom 137311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff memory management. The compression library attaches no meaning to the 138311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff opaque value. 139311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 140311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff zalloc must return Z_NULL if there is not enough memory for the object. 141311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If zlib is used in a multi-threaded application, zalloc and zfree must be 142311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff thread safe. 143311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 144311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff On 16-bit systems, the functions zalloc and zfree must be able to allocate 145311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff exactly 65536 bytes, but will not be required to allocate more than this 146311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, 147311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff pointers returned by zalloc for objects of exactly 65536 bytes *must* 148311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff have their offset normalized to zero. The default allocation function 149311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff provided by this library ensures this (see zutil.c). To reduce memory 150311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff requirements and avoid any allocation of 64K objects, at the expense of 151311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). 152311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 153311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The fields total_in and total_out can be used for statistics or 154311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff progress reports. After compression, total_in holds the total size of 155311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the uncompressed data and may be saved for use in the decompressor 156311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (particularly if the decompressor wants to decompress everything in 157311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff a single step). 158311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 159311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 160311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff /* constants */ 161311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 162311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_NO_FLUSH 0 163311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ 164311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_SYNC_FLUSH 2 165311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_FULL_FLUSH 3 166311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_FINISH 4 167311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_BLOCK 5 168311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* Allowed flush values; see deflate() and inflate() below for details */ 169311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 170311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_OK 0 171311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_STREAM_END 1 172311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_NEED_DICT 2 173311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_ERRNO (-1) 174311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_STREAM_ERROR (-2) 175311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_DATA_ERROR (-3) 176311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_MEM_ERROR (-4) 177311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_BUF_ERROR (-5) 178311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_VERSION_ERROR (-6) 179311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* Return codes for the compression/decompression functions. Negative 180311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * values are errors, positive values are used for special but normal events. 181311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff */ 182311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 183311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_NO_COMPRESSION 0 184311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_BEST_SPEED 1 185311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_BEST_COMPRESSION 9 186311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_DEFAULT_COMPRESSION (-1) 187311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* compression levels */ 188311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 189311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_FILTERED 1 190311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_HUFFMAN_ONLY 2 191311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_RLE 3 192311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_FIXED 4 193311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_DEFAULT_STRATEGY 0 194311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* compression strategy; see deflateInit2() below for details */ 195311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 196311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_BINARY 0 197311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_TEXT 1 198311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ 199311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_UNKNOWN 2 200311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* Possible values of the data_type field (though see inflate()) */ 201311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 202311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_DEFLATED 8 203311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* The deflate compression method (the only one supported in this version) */ 204311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 205311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ 206311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 207311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define zlib_version zlibVersion() 208311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* for compatibility with versions < 1.0.2 */ 209311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 210311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff /* basic functions */ 211311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 212311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN const char * ZEXPORT zlibVersion OF((void)); 213311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* The application can compare zlibVersion and ZLIB_VERSION for consistency. 214311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If the first character differs, the library code actually used is 215311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff not compatible with the zlib.h header file used by the application. 216311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This check is automatically made by deflateInit and inflateInit. 217311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff */ 218311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 219311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 220311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); 221311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 222311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Initializes the internal stream state for compression. The fields 223311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff zalloc, zfree and opaque must be initialized before by the caller. 224311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If zalloc and zfree are set to Z_NULL, deflateInit updates them to 225311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff use default allocation functions. 226311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 227311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 228311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1 gives best speed, 9 gives best compression, 0 gives no compression at 229311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff all (the input data is simply copied a block at a time). 230311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_DEFAULT_COMPRESSION requests a default compromise between speed and 231311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compression (currently equivalent to level 6). 232311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 233311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not 234311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff enough memory, Z_STREAM_ERROR if level is not a valid compression level, 235311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible 236311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff with the version assumed by the caller (ZLIB_VERSION). 237311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff msg is set to null if there is no error message. deflateInit does not 238311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff perform any compression: this will be done by deflate(). 239311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 240311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 241311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 242311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); 243311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 244311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate compresses as much data as possible, and stops when the input 245311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff buffer becomes empty or the output buffer becomes full. It may introduce some 246311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff output latency (reading input without producing any output) except when 247311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff forced to flush. 248311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 249311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The detailed semantics are as follows. deflate performs one or both of the 250311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff following actions: 251311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 252311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff - Compress more input starting at next_in and update next_in and avail_in 253311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff accordingly. If not all input can be processed (because there is not 254311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff enough room in the output buffer), next_in and avail_in are updated and 255311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff processing will resume at this point for the next call of deflate(). 256311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 257311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff - Provide more output starting at next_out and update next_out and avail_out 258311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff accordingly. This action is forced if the parameter flush is non zero. 259311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Forcing flush frequently degrades the compression ratio, so this parameter 260311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff should be set only when necessary (in interactive applications). 261311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Some output may be provided even if flush is not set. 262311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 263311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Before the call of deflate(), the application should ensure that at least 264311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff one of the actions is possible, by providing more input and/or consuming 265311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff more output, and updating avail_in or avail_out accordingly; avail_out 266311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff should never be zero before the call. The application can consume the 267311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compressed output when it wants, for example when the output buffer is full 268311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK 269311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff and with zero avail_out, it must be called again after making room in the 270311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff output buffer because there might be more output pending. 271311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 272311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to 273311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff decide how much data to accumualte before producing output, in order to 274311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff maximize compression. 275311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 276311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If the parameter flush is set to Z_SYNC_FLUSH, all pending output is 277311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff flushed to the output buffer and the output is aligned on a byte boundary, so 278311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff that the decompressor can get all input data available so far. (In particular 279311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff avail_in is zero after the call if enough output space has been provided 280311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff before the call.) Flushing may degrade compression for some compression 281311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff algorithms and so it should be used only when necessary. 282311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 283311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If flush is set to Z_FULL_FLUSH, all output is flushed as with 284311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_SYNC_FLUSH, and the compression state is reset so that decompression can 285311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff restart from this point if previous compressed data has been damaged or if 286311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff random access is desired. Using Z_FULL_FLUSH too often can seriously degrade 287311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compression. 288311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 289311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If deflate returns with avail_out == 0, this function must be called again 290311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff with the same value of the flush parameter and more output space (updated 291311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff avail_out), until the flush is complete (deflate returns with non-zero 292311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that 293311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff avail_out is greater than six to avoid repeated flush markers due to 294311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff avail_out == 0 on return. 295311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 296311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If the parameter flush is set to Z_FINISH, pending input is processed, 297311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff pending output is flushed and deflate returns with Z_STREAM_END if there 298311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff was enough output space; if deflate returns with Z_OK, this function must be 299311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff called again with Z_FINISH and more output space (updated avail_out) but no 300311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff more input data, until it returns with Z_STREAM_END or an error. After 301311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate has returned Z_STREAM_END, the only possible operations on the 302311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream are deflateReset or deflateEnd. 303311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 304311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_FINISH can be used immediately after deflateInit if all the compression 305311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff is to be done in a single step. In this case, avail_out must be at least 306311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the value returned by deflateBound (see below). If deflate does not return 307311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_STREAM_END, then it must be called again as described above. 308311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 309311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate() sets strm->adler to the adler32 checksum of all input read 310311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff so far (that is, total_in bytes). 311311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 312311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate() may update strm->data_type if it can make a good guess about 313311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered 314311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff binary. This field is only for information purposes and does not affect 315311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the compression algorithm in any manner. 316311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 317311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate() returns Z_OK if some progress has been made (more input 318311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff processed or more output produced), Z_STREAM_END if all input has been 319311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff consumed and all output has been produced (only when flush is set to 320311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example 321311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible 322311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not 323311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff fatal, and deflate() can be called again with more input and more output 324311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff space to continue compressing. 325311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 326311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 327311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 328311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); 329311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 330311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff All dynamically allocated data structures for this stream are freed. 331311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This function discards any unprocessed input and does not flush any 332311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff pending output. 333311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 334311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the 335311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream state was inconsistent, Z_DATA_ERROR if the stream was freed 336311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff prematurely (some input or output was discarded). In the error case, 337311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff msg may be set but then points to a static string (which must not be 338311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deallocated). 339311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 340311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 341311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 342311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 343311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); 344311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 345311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Initializes the internal stream state for decompression. The fields 346311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff next_in, avail_in, zalloc, zfree and opaque must be initialized before by 347311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the caller. If next_in is not Z_NULL and avail_in is large enough (the exact 348311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff value depends on the compression method), inflateInit determines the 349311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compression method from the zlib header and allocates all data structures 350311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff accordingly; otherwise the allocation will be deferred to the first call of 351311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to 352311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff use default allocation functions. 353311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 354311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough 355311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff memory, Z_VERSION_ERROR if the zlib library version is incompatible with the 356311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff version assumed by the caller. msg is set to null if there is no error 357311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff message. inflateInit does not perform any decompression apart from reading 358311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the zlib header if present: this will be done by inflate(). (So next_in and 359311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff avail_in may be modified, but next_out and avail_out are unchanged.) 360311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 361311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 362311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 363311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); 364311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 365311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflate decompresses as much data as possible, and stops when the input 366311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff buffer becomes empty or the output buffer becomes full. It may introduce 367311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff some output latency (reading input without producing any output) except when 368311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff forced to flush. 369311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 370311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The detailed semantics are as follows. inflate performs one or both of the 371311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff following actions: 372311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 373311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff - Decompress more input starting at next_in and update next_in and avail_in 374311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff accordingly. If not all input can be processed (because there is not 375311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff enough room in the output buffer), next_in is updated and processing 376311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff will resume at this point for the next call of inflate(). 377311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 378311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff - Provide more output starting at next_out and update next_out and avail_out 379311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff accordingly. inflate() provides as much output as possible, until there 380311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff is no more input data or no more space in the output buffer (see below 381311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff about the flush parameter). 382311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 383311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Before the call of inflate(), the application should ensure that at least 384311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff one of the actions is possible, by providing more input and/or consuming 385311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff more output, and updating the next_* and avail_* values accordingly. 386311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The application can consume the uncompressed output when it wants, for 387311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff example when the output buffer is full (avail_out == 0), or after each 388311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff call of inflate(). If inflate returns Z_OK and with zero avail_out, it 389311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff must be called again after making room in the output buffer because there 390311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff might be more output pending. 391311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 392311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, 393311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much 394311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff output as possible to the output buffer. Z_BLOCK requests that inflate() stop 395311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if and when it gets to the next deflate block boundary. When decoding the 396311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff zlib or gzip format, this will cause inflate() to return immediately after 397311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the header and before the first block. When doing a raw inflate, inflate() 398311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff will go ahead and process the first block, and will return when it gets to 399311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the end of that block, or when it runs out of data. 400311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 401311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The Z_BLOCK option assists in appending to or combining deflate streams. 402311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Also to assist in this, on return inflate() will set strm->data_type to the 403311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff number of unused bits in the last byte taken from strm->next_in, plus 64 404311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if inflate() is currently decoding the last block in the deflate stream, 405311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff plus 128 if inflate() returned immediately after decoding an end-of-block 406311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff code or decoding the complete header up to just before the first byte of the 407311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate stream. The end-of-block will not be indicated until all of the 408311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uncompressed data from that block has been written to strm->next_out. The 409311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff number of unused bits may in general be greater than seven, except when 410311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff bit 7 of data_type is set, in which case the number of unused bits will be 411311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff less than eight. 412311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 413311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflate() should normally be called until it returns Z_STREAM_END or an 414311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff error. However if all decompression is to be performed in a single step 415311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (a single call of inflate), the parameter flush should be set to 416311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_FINISH. In this case all pending input is processed and all pending 417311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff output is flushed; avail_out must be large enough to hold all the 418311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uncompressed data. (The size of the uncompressed data may have been saved 419311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff by the compressor for this purpose.) The next operation on this stream must 420311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff be inflateEnd to deallocate the decompression state. The use of Z_FINISH 421311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff is never required, but can be used to inform inflate that a faster approach 422311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff may be used for the single inflate() call. 423311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 424311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff In this implementation, inflate() always flushes as much output as 425311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff possible to the output buffer, and always uses the faster approach on the 426311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff first call. So the only effect of the flush parameter in this implementation 427311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff is on the return value of inflate(), as noted below, or when it returns early 428311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff because Z_BLOCK is used. 429311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 430311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If a preset dictionary is needed after this call (see inflateSetDictionary 431311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff below), inflate sets strm->adler to the adler32 checksum of the dictionary 432311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff chosen by the compressor and returns Z_NEED_DICT; otherwise it sets 433311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff strm->adler to the adler32 checksum of all output produced so far (that is, 434311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described 435311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff below. At the end of the stream, inflate() checks that its computed adler32 436311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff checksum is equal to that saved by the compressor and returns Z_STREAM_END 437311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff only if the checksum is correct. 438311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 439311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflate() will decompress and check either zlib-wrapped or gzip-wrapped 440311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate data. The header type is detected automatically. Any information 441311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff contained in the gzip header is not retained, so applications that need that 442311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff information should instead use raw inflate, see inflateInit2() below, or 443311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateBack() and perform their own processing of the gzip header and 444311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff trailer. 445311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 446311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflate() returns Z_OK if some progress has been made (more input processed 447311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff or more output produced), Z_STREAM_END if the end of the compressed data has 448311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff been reached and all uncompressed output has been produced, Z_NEED_DICT if a 449311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff preset dictionary is needed at this point, Z_DATA_ERROR if the input data was 450311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff corrupted (input stream not conforming to the zlib format or incorrect check 451311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff value), Z_STREAM_ERROR if the stream structure was inconsistent (for example 452311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, 453311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_BUF_ERROR if no progress is possible or if there was not enough room in the 454311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and 455311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflate() can be called again with more input and more output space to 456311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff continue decompressing. If Z_DATA_ERROR is returned, the application may then 457311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff call inflateSync() to look for a good compression block if a partial recovery 458311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff of the data is desired. 459311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 460311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 461311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 462311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); 463311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 464311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff All dynamically allocated data structures for this stream are freed. 465311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This function discards any unprocessed input and does not flush any 466311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff pending output. 467311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 468311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state 469311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff was inconsistent. In the error case, msg may be set but then points to a 470311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff static string (which must not be deallocated). 471311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 472311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 473311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff /* Advanced functions */ 474311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 475311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 476311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The following functions are needed only in some special applications. 477311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 478311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 479311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 480311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, 481311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int level, 482311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int method, 483311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int windowBits, 484311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int memLevel, 485311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int strategy)); 486311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 487311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This is another version of deflateInit with more compression options. The 488311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff fields next_in, zalloc, zfree and opaque must be initialized before by 489311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the caller. 490311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 491311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The method parameter is the compression method. It must be Z_DEFLATED in 492311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff this version of the library. 493311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 494311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The windowBits parameter is the base two logarithm of the window size 495311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (the size of the history buffer). It should be in the range 8..15 for this 496311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff version of the library. Larger values of this parameter result in better 497311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compression at the expense of memory usage. The default value is 15 if 498311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateInit is used instead. 499311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 500311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff windowBits can also be -8..-15 for raw deflate. In this case, -windowBits 501311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff determines the window size. deflate() will then generate raw deflate data 502311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff with no zlib header or trailer, and will not compute an adler32 check value. 503311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 504311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff windowBits can also be greater than 15 for optional gzip encoding. Add 505311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 16 to windowBits to write a simple gzip header and trailer around the 506311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compressed data instead of a zlib wrapper. The gzip header will have no 507311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff file name, no extra data, no comment, no modification time (set to zero), 508311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff no header crc, and the operating system will be set to 255 (unknown). If a 509311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzip stream is being written, strm->adler is a crc32 instead of an adler32. 510311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 511311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The memLevel parameter specifies how much memory should be allocated 512311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff for the internal compression state. memLevel=1 uses minimum memory but 513311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff is slow and reduces compression ratio; memLevel=9 uses maximum memory 514311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff for optimal speed. The default value is 8. See zconf.h for total memory 515311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff usage as a function of windowBits and memLevel. 516311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 517311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The strategy parameter is used to tune the compression algorithm. Use the 518311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a 519311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no 520311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff string match), or Z_RLE to limit match distances to one (run-length 521311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff encoding). Filtered data consists mostly of small values with a somewhat 522311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff random distribution. In this case, the compression algorithm is tuned to 523311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compress them better. The effect of Z_FILTERED is to force more Huffman 524311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff coding and less string matching; it is somewhat intermediate between 525311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as 526311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy 527311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff parameter only affects the compression ratio but not the correctness of the 528311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compressed output even if it is not set appropriately. Z_FIXED prevents the 529311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff use of dynamic Huffman codes, allowing for a simpler decoder for special 530311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff applications. 531311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 532311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 533311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid 534311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff method). msg is set to null if there is no error message. deflateInit2 does 535311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff not perform any compression: this will be done by deflate(). 536311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 537311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 538311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, 539311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const Bytef *dictionary, 540311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uInt dictLength)); 541311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 542311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Initializes the compression dictionary from the given byte sequence 543311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff without producing any compressed output. This function must be called 544311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff immediately after deflateInit, deflateInit2 or deflateReset, before any 545311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff call of deflate. The compressor and decompressor must use exactly the same 546311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff dictionary (see inflateSetDictionary). 547311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 548311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The dictionary should consist of strings (byte sequences) that are likely 549311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff to be encountered later in the data to be compressed, with the most commonly 550311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff used strings preferably put towards the end of the dictionary. Using a 551311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff dictionary is most useful when the data to be compressed is short and can be 552311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff predicted with good accuracy; the data can then be compressed better than 553311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff with the default empty dictionary. 554311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 555311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Depending on the size of the compression data structures selected by 556311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateInit or deflateInit2, a part of the dictionary may in effect be 557311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff discarded, for example if the dictionary is larger than the window size in 558311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate or deflate2. Thus the strings most likely to be useful should be 559311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff put at the end of the dictionary, not at the front. In addition, the 560311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff current implementation of deflate will use at most the window size minus 561311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 262 bytes of the provided dictionary. 562311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 563311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Upon return of this function, strm->adler is set to the adler32 value 564311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff of the dictionary; the decompressor may later use this value to determine 565311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff which dictionary has been used by the compressor. (The adler32 value 566311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff applies to the whole dictionary even if only a subset of the dictionary is 567311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff actually used by the compressor.) If a raw deflate was requested, then the 568311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff adler32 value is not computed and strm->adler is not set. 569311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 570311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a 571311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff parameter is invalid (such as NULL dictionary) or the stream state is 572311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inconsistent (for example if deflate has already been called for this stream 573311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff or if the compression method is bsort). deflateSetDictionary does not 574311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff perform any compression: this will be done by deflate(). 575311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 576311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 577311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, 578311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff z_streamp source)); 579311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 580311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Sets the destination stream as a complete copy of the source stream. 581311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 582311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This function can be useful when several compression strategies will be 583311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff tried, for example when there are several ways of pre-processing the input 584311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff data with a filter. The streams that will be discarded should then be freed 585311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff by calling deflateEnd. Note that deflateCopy duplicates the internal 586311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compression state which can be quite large, so this strategy is slow and 587311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff can consume lots of memory. 588311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 589311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not 590311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff enough memory, Z_STREAM_ERROR if the source stream state was inconsistent 591311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (such as zalloc being NULL). msg is left unchanged in both source and 592311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff destination. 593311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 594311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 595311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); 596311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 597311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This function is equivalent to deflateEnd followed by deflateInit, 598311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff but does not free and reallocate all the internal compression state. 599311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The stream will keep the same compression level and any other attributes 600311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff that may have been set by deflateInit2. 601311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 602311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source 603311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream state was inconsistent (such as zalloc or state being NULL). 604311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 605311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 606311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, 607311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int level, 608311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int strategy)); 609311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 610311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Dynamically update the compression level and compression strategy. The 611311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff interpretation of level and strategy is as in deflateInit2. This can be 612311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff used to switch between compression and straight copy of the input data, or 613311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff to switch to a different kind of input data requiring a different 614311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff strategy. If the compression level is changed, the input available so far 615311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff is compressed with the old level (and may be flushed); the new level will 616311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff take effect only at the next call of deflate(). 617311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 618311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Before the call of deflateParams, the stream state must be set as for 619311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff a call of deflate(), since the currently available input may have to 620311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff be compressed and flushed. In particular, strm->avail_out must be non-zero. 621311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 622311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source 623311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR 624311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if strm->avail_out was zero. 625311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 626311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 627311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, 628311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int good_length, 629311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int max_lazy, 630311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int nice_length, 631311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int max_chain)); 632311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 633311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Fine tune deflate's internal compression parameters. This should only be 634311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff used by someone who understands the algorithm used by zlib's deflate for 635311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff searching for the best matching string, and even then only by the most 636311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff fanatic optimizer trying to squeeze out the last compressed bit for their 637311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff specific input data. Read the deflate.c source code for the meaning of the 638311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff max_lazy, good_length, nice_length, and max_chain parameters. 639311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 640311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateTune() can be called after deflateInit() or deflateInit2(), and 641311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. 642311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff */ 643311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 644311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, 645311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uLong sourceLen)); 646311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 647311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateBound() returns an upper bound on the compressed size after 648311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflation of sourceLen bytes. It must be called after deflateInit() 649311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff or deflateInit2(). This would be used to allocate an output buffer 650311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff for deflation in a single pass, and so would be called before deflate(). 651311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 652311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 653311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, 654311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int bits, 655311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int value)); 656311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 657311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflatePrime() inserts bits in the deflate output stream. The intent 658311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff is that this function is used to start off the deflate output with the 659311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff bits leftover from a previous deflate stream when appending to it. As such, 660311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff this function can only be used for raw deflate, and must be used before the 661311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff first deflate() call after a deflateInit2() or deflateReset(). bits must be 662311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff less than or equal to 16, and that many of the least significant bits of 663311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff value will be inserted in the output. 664311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 665311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source 666311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream state was inconsistent. 667311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 668311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 669311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, 670311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gz_headerp head)); 671311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 672311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateSetHeader() provides gzip header information for when a gzip 673311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream is requested by deflateInit2(). deflateSetHeader() may be called 674311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff after deflateInit2() or deflateReset() and before the first call of 675311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate(). The text, time, os, extra field, name, and comment information 676311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff in the provided gz_header structure are written to the gzip header (xflag is 677311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff ignored -- the extra flags are set according to the compression level). The 678311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff caller must assure that, if not Z_NULL, name and comment are terminated with 679311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff a zero byte, and that if extra is not Z_NULL, that extra_len bytes are 680311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff available there. If hcrc is true, a gzip header crc is included. Note that 681311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the current versions of the command-line version of gzip (up through version 682311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1.3.x) do not support header crc's, and will report that it is a "multi-part 683311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzip file" and give up. 684311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 685311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If deflateSetHeader is not used, the default gzip header has text false, 686311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the time set to zero, and os set to 255, with no extra, name, or comment 687311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff fields. The gzip header is returned to the default state by deflateReset(). 688311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 689311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source 690311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream state was inconsistent. 691311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 692311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 693311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 694311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, 695311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int windowBits)); 696311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 697311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This is another version of inflateInit with an extra parameter. The 698311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff fields next_in, avail_in, zalloc, zfree and opaque must be initialized 699311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff before by the caller. 700311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 701311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The windowBits parameter is the base two logarithm of the maximum window 702311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff size (the size of the history buffer). It should be in the range 8..15 for 703311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff this version of the library. The default value is 15 if inflateInit is used 704311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff instead. windowBits must be greater than or equal to the windowBits value 705311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff provided to deflateInit2() while compressing, or it must be equal to 15 if 706311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateInit2() was not used. If a compressed stream with a larger window 707311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff size is given as input, inflate() will return with the error code 708311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_DATA_ERROR instead of trying to allocate a larger window. 709311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 710311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff windowBits can also be -8..-15 for raw inflate. In this case, -windowBits 711311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff determines the window size. inflate() will then process raw deflate data, 712311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff not looking for a zlib or gzip header, not generating a check value, and not 713311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff looking for any check values for comparison at the end of the stream. This 714311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff is for use with other formats that use the deflate compressed data format 715311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff such as zip. Those formats provide their own check values. If a custom 716311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff format is developed using the raw deflate format for compressed data, it is 717311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff recommended that a check value such as an adler32 or a crc32 be applied to 718311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the uncompressed data as is done in the zlib, gzip, and zip formats. For 719311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff most applications, the zlib format should be used as is. Note that comments 720311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff above on the use in deflateInit2() applies to the magnitude of windowBits. 721311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 722311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff windowBits can also be greater than 15 for optional gzip decoding. Add 723311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 32 to windowBits to enable zlib and gzip decoding with automatic header 724311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff detection, or add 16 to decode only the gzip format (the zlib format will 725311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is 726311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff a crc32 instead of an adler32. 727311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 728311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 729311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg 730311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff is set to null if there is no error message. inflateInit2 does not perform 731311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff any decompression apart from reading the zlib header if present: this will 732311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff be done by inflate(). (So next_in and avail_in may be modified, but next_out 733311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff and avail_out are unchanged.) 734311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 735311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 736311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, 737311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const Bytef *dictionary, 738311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uInt dictLength)); 739311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 740311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Initializes the decompression dictionary from the given uncompressed byte 741311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff sequence. This function must be called immediately after a call of inflate, 742311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if that call returned Z_NEED_DICT. The dictionary chosen by the compressor 743311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff can be determined from the adler32 value returned by that call of inflate. 744311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The compressor and decompressor must use exactly the same dictionary (see 745311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateSetDictionary). For raw inflate, this function can be called 746311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff immediately after inflateInit2() or inflateReset() and before any call of 747311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflate() to set the dictionary. The application must insure that the 748311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff dictionary that was used for compression is provided. 749311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 750311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a 751311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff parameter is invalid (such as NULL dictionary) or the stream state is 752311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the 753311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff expected one (incorrect adler32 value). inflateSetDictionary does not 754311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff perform any decompression: this will be done by subsequent calls of 755311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflate(). 756311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 757311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 758311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); 759311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 760311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Skips invalid compressed data until a full flush point (see above the 761311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff description of deflate with Z_FULL_FLUSH) can be found, or until all 762311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff available input is skipped. No output is provided. 763311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 764311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR 765311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if no more input was provided, Z_DATA_ERROR if no flush point has been found, 766311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff or Z_STREAM_ERROR if the stream structure was inconsistent. In the success 767311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff case, the application may save the current current value of total_in which 768311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff indicates where valid compressed data was found. In the error case, the 769311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff application may repeatedly call inflateSync, providing more input each time, 770311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff until success or end of the input data. 771311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 772311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 773311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, 774311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff z_streamp source)); 775311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 776311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Sets the destination stream as a complete copy of the source stream. 777311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 778311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This function can be useful when randomly accessing a large stream. The 779311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff first pass through the stream can periodically record the inflate state, 780311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff allowing restarting inflate at those points when randomly accessing the 781311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream. 782311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 783311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not 784311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff enough memory, Z_STREAM_ERROR if the source stream state was inconsistent 785311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (such as zalloc being NULL). msg is left unchanged in both source and 786311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff destination. 787311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 788311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 789311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); 790311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 791311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This function is equivalent to inflateEnd followed by inflateInit, 792311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff but does not free and reallocate all the internal decompression state. 793311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The stream will keep attributes that may have been set by inflateInit2. 794311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 795311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source 796311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream state was inconsistent (such as zalloc or state being NULL). 797311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 798311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 799311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, 800311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int bits, 801311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int value)); 802311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 803311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This function inserts bits in the inflate input stream. The intent is 804311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff that this function is used to start inflating at a bit position in the 805311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff middle of a byte. The provided bits will be used before any bytes are used 806311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff from next_in. This function should only be used with raw inflate, and 807311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff should be used before the first inflate() call after inflateInit2() or 808311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateReset(). bits must be less than or equal to 16, and that many of the 809311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff least significant bits of value will be inserted in the input. 810311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 811311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source 812311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream state was inconsistent. 813311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 814311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 815311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, 816311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gz_headerp head)); 817311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 818311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateGetHeader() requests that gzip header information be stored in the 819311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff provided gz_header structure. inflateGetHeader() may be called after 820311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateInit2() or inflateReset(), and before the first call of inflate(). 821311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff As inflate() processes the gzip stream, head->done is zero until the header 822311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff is completed, at which time head->done is set to one. If a zlib stream is 823311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff being decoded, then head->done is set to -1 to indicate that there will be 824311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff no gzip header information forthcoming. Note that Z_BLOCK can be used to 825311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff force inflate() to return immediately after header processing is complete 826311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff and before any actual data is decompressed. 827311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 828311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The text, time, xflags, and os fields are filled in with the gzip header 829311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff contents. hcrc is set to true if there is a header CRC. (The header CRC 830311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff was valid if done is set to one.) If extra is not Z_NULL, then extra_max 831311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff contains the maximum number of bytes to write to extra. Once done is true, 832311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff extra_len contains the actual extra field length, and extra contains the 833311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff extra field, or that field truncated if extra_max is less than extra_len. 834311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If name is not Z_NULL, then up to name_max characters are written there, 835311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff terminated with a zero unless the length is greater than name_max. If 836311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff comment is not Z_NULL, then up to comm_max characters are written there, 837311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff terminated with a zero unless the length is greater than comm_max. When 838311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff any of extra, name, or comment are not Z_NULL and the respective field is 839311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff not present in the header, then that field is set to Z_NULL to signal its 840311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff absence. This allows the use of deflateSetHeader() with the returned 841311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff structure to duplicate the header. However if those fields are set to 842311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff allocated memory, then the application will need to save those pointers 843311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff elsewhere so that they can be eventually freed. 844311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 845311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If inflateGetHeader is not used, then the header information is simply 846311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff discarded. The header is always checked for validity, including the header 847311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff CRC if present. inflateReset() will reset the process to discard the header 848311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff information. The application would need to call inflateGetHeader() again to 849311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff retrieve the header from the next gzip stream. 850311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 851311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source 852311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff stream state was inconsistent. 853311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 854311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 855311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 856311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, 857311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff unsigned char FAR *window)); 858311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 859311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Initialize the internal stream state for decompression using inflateBack() 860311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff calls. The fields zalloc, zfree and opaque in strm must be initialized 861311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff before the call. If zalloc and zfree are Z_NULL, then the default library- 862311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff derived memory allocation routines are used. windowBits is the base two 863311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff logarithm of the window size, in the range 8..15. window is a caller 864311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff supplied buffer of that size. Except for special applications where it is 865311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff assured that deflate was used with small window sizes, windowBits must be 15 866311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff and a 32K byte window must be supplied to be able to decompress general 867311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate streams. 868311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 869311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff See inflateBack() for the usage of these routines. 870311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 871311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of 872311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the paramaters are invalid, Z_MEM_ERROR if the internal state could not 873311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff be allocated, or Z_VERSION_ERROR if the version of the library does not 874311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff match the version of the header file. 875311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 876311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 877311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdifftypedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); 878311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdifftypedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); 879311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 880311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, 881311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff in_func in, void FAR *in_desc, 882311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff out_func out, void FAR *out_desc)); 883311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 884311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateBack() does a raw inflate with a single call using a call-back 885311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff interface for input and output. This is more efficient than inflate() for 886311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff file i/o applications in that it avoids copying between the output and the 887311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff sliding window by simply making the window itself the output buffer. This 888311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff function trusts the application to not change the output buffer passed by 889311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the output function, at least until inflateBack() returns. 890311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 891311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateBackInit() must be called first to allocate the internal state 892311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff and to initialize the state with the user-provided window buffer. 893311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateBack() may then be used multiple times to inflate a complete, raw 894311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate stream with each call. inflateBackEnd() is then called to free 895311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the allocated state. 896311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 897311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff A raw deflate stream is one with no zlib or gzip header or trailer. 898311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This routine would normally be used in a utility that reads zip or gzip 899311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff files and writes out uncompressed files. The utility would decode the 900311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff header and process the trailer on its own, hence this routine expects 901311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff only the raw deflate stream to decompress. This is different from the 902311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff normal behavior of inflate(), which expects either a zlib or gzip header and 903311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff trailer around the deflate stream. 904311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 905311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateBack() uses two subroutines supplied by the caller that are then 906311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff called by inflateBack() for input and output. inflateBack() calls those 907311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff routines until it reads a complete deflate stream and writes out all of the 908311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uncompressed data, or until it encounters an error. The function's 909311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff parameters and return types are defined above in the in_func and out_func 910311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff typedefs. inflateBack() will call in(in_desc, &buf) which should return the 911311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff number of bytes of provided input, and a pointer to that input in buf. If 912311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff there is no input available, in() must return zero--buf is ignored in that 913311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff case--and inflateBack() will return a buffer error. inflateBack() will call 914311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() 915311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff should return zero on success, or non-zero on failure. If out() returns 916311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff non-zero, inflateBack() will return with an error. Neither in() nor out() 917311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff are permitted to change the contents of the window provided to 918311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateBackInit(), which is also the buffer that out() uses to write from. 919311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The length written by out() will be at most the window size. Any non-zero 920311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff amount of input may be provided by in(). 921311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 922311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff For convenience, inflateBack() can be provided input on the first call by 923311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff setting strm->next_in and strm->avail_in. If that input is exhausted, then 924311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff in() will be called. Therefore strm->next_in must be initialized before 925311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called 926311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in 927311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff must also be initialized, and then if strm->avail_in is not zero, input will 928311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff initially be taken from strm->next_in[0 .. strm->avail_in - 1]. 929311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 930311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The in_desc and out_desc parameters of inflateBack() is passed as the 931311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff first parameter of in() and out() respectively when they are called. These 932311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff descriptors can be optionally used to pass any information that the caller- 933311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff supplied in() and out() functions need to do their job. 934311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 935311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff On return, inflateBack() will set strm->next_in and strm->avail_in to 936311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff pass back any unused input that was provided by the last in() call. The 937311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR 938311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if in() or out() returned an error, Z_DATA_ERROR if there was a format 939311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff error in the deflate stream (in which case strm->msg is set to indicate the 940311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff nature of the error), or Z_STREAM_ERROR if the stream was not properly 941311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff initialized. In the case of Z_BUF_ERROR, an input or output error can be 942311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff distinguished using strm->next_in which will be Z_NULL only if in() returned 943311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to 944311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff out() returning non-zero. (in() will always be called before out(), so 945311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff strm->next_in is assured to be defined if out() returns non-zero.) Note 946311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff that inflateBack() cannot return Z_OK. 947311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 948311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 949311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); 950311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 951311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff All memory allocated by inflateBackInit() is freed. 952311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 953311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream 954311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff state was inconsistent. 955311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 956311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 957311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); 958311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* Return flags indicating compile-time options. 959311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 960311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: 961311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1.0: size of uInt 962311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 3.2: size of uLong 963311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 5.4: size of voidpf (pointer) 964311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 7.6: size of z_off_t 965311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 966311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Compiler, assembler, and debug options: 967311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 8: DEBUG 968311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 9: ASMV or ASMINF -- use ASM code 969311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention 970311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 11: 0 (reserved) 971311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 972311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff One-time table building (smaller code, but not thread-safe if true): 973311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 12: BUILDFIXED -- build static block decoding tables when needed 974311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed 975311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 14,15: 0 (reserved) 976311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 977311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Library content (indicates missing functionality): 978311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking 979311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflate code when not needed) 980311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect 981311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff and decode gzip streams (to avoid linking crc code) 982311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 18-19: 0 (reserved) 983311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 984311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Operation variations (changes in library functionality): 985311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate 986311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 21: FASTEST -- deflate algorithm with only one, lowest compression level 987311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 22,23: 0 (reserved) 988311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 989311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The sprintf variant used by gzprintf (zero is best): 990311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format 991311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! 992311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 26: 0 = returns value, 1 = void -- 1 means inferred string length returned 993311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 994311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Remainder: 995311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 27-31: 0 (reserved) 996311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff */ 997311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 998311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 999311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff /* utility functions */ 1000311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1001311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1002311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The following utility functions are implemented on top of the 1003311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff basic stream-oriented functions. To simplify the interface, some 1004311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff default options are assumed (compression level and memory usage, 1005311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff standard memory allocation functions). The source code of these 1006311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff utility functions can easily be modified if you need special options. 1007311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1008311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1009311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, 1010311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const Bytef *source, uLong sourceLen)); 1011311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1012311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Compresses the source buffer into the destination buffer. sourceLen is 1013311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the byte length of the source buffer. Upon entry, destLen is the total 1014311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff size of the destination buffer, which must be at least the value returned 1015311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff by compressBound(sourceLen). Upon exit, destLen is the actual size of the 1016311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compressed buffer. 1017311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This function can be used to compress a whole file at once if the 1018311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff input file is mmap'ed. 1019311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compress returns Z_OK if success, Z_MEM_ERROR if there was not 1020311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff enough memory, Z_BUF_ERROR if there was not enough room in the output 1021311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff buffer. 1022311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1023311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1024311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, 1025311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const Bytef *source, uLong sourceLen, 1026311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int level)); 1027311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1028311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Compresses the source buffer into the destination buffer. The level 1029311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff parameter has the same meaning as in deflateInit. sourceLen is the byte 1030311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff length of the source buffer. Upon entry, destLen is the total size of the 1031311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff destination buffer, which must be at least the value returned by 1032311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compressBound(sourceLen). Upon exit, destLen is the actual size of the 1033311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compressed buffer. 1034311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1035311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 1036311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff memory, Z_BUF_ERROR if there was not enough room in the output buffer, 1037311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Z_STREAM_ERROR if the level parameter is invalid. 1038311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1039311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1040311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); 1041311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1042311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compressBound() returns an upper bound on the compressed size after 1043311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compress() or compress2() on sourceLen bytes. It would be used before 1044311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff a compress() or compress2() call to allocate the destination buffer. 1045311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1046311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1047311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, 1048311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const Bytef *source, uLong sourceLen)); 1049311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1050311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Decompresses the source buffer into the destination buffer. sourceLen is 1051311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the byte length of the source buffer. Upon entry, destLen is the total 1052311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff size of the destination buffer, which must be large enough to hold the 1053311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff entire uncompressed data. (The size of the uncompressed data must have 1054311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff been saved previously by the compressor and transmitted to the decompressor 1055311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff by some mechanism outside the scope of this compression library.) 1056311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Upon exit, destLen is the actual size of the compressed buffer. 1057311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This function can be used to decompress a whole file at once if the 1058311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff input file is mmap'ed. 1059311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1060311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 1061311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff enough memory, Z_BUF_ERROR if there was not enough room in the output 1062311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. 1063311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1064311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1065311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1066311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdifftypedef voidp gzFile; 1067311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1068311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); 1069311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1070311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Opens a gzip (.gz) file for reading or writing. The mode parameter 1071311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff is as in fopen ("rb" or "wb") but can also include a compression level 1072311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for 1073311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Huffman only compression as in "wb1h", or 'R' for run-length encoding 1074311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff as in "wb1R". (See the description of deflateInit2 for more information 1075311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff about the strategy parameter.) 1076311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1077311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzopen can be used to read a file which is not in gzip format; in this 1078311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff case gzread will directly read from the file without decompression. 1079311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1080311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzopen returns NULL if the file could not be opened or if there was 1081311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff insufficient memory to allocate the (de)compression state; errno 1082311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff can be checked to distinguish the two cases (if errno is zero, the 1083311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff zlib error is Z_MEM_ERROR). */ 1084311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1085311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdifflong long gzgetMtime(gzFile file); 1086311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* Return modify time */ 1087311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1088311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); 1089311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1090311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzdopen() associates a gzFile with the file descriptor fd. File 1091311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff descriptors are obtained from calls like open, dup, creat, pipe or 1092311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff fileno (in the file has been previously opened with fopen). 1093311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The mode parameter is as in gzopen. 1094311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff The next call of gzclose on the returned gzFile will also close the 1095311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff file descriptor fd, just like fclose(fdopen(fd), mode) closes the file 1096311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). 1097311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzdopen returns NULL if there was insufficient memory to allocate 1098311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the (de)compression state. 1099311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1100311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1101311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); 1102311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1103311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Dynamically update the compression level or strategy. See the description 1104311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff of deflateInit2 for the meaning of these parameters. 1105311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not 1106311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff opened for writing. 1107311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1108311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1109311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); 1110311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1111311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Reads the given number of uncompressed bytes from the compressed file. 1112311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If the input file was not in gzip format, gzread copies the given number 1113311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff of bytes into the buffer. 1114311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzread returns the number of uncompressed bytes actually read (0 for 1115311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff end of file, -1 for error). */ 1116311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1117311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzwrite OF((gzFile file, 1118311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff voidpc buf, unsigned len)); 1119311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1120311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Writes the given number of uncompressed bytes into the compressed file. 1121311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzwrite returns the number of uncompressed bytes actually written 1122311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (0 in case of error). 1123311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1124311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1125311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); 1126311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1127311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Converts, formats, and writes the args to the compressed file under 1128311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff control of the format string, as in fprintf. gzprintf returns the number of 1129311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uncompressed bytes actually written (0 in case of error). The number of 1130311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uncompressed bytes written is limited to 4095. The caller should assure that 1131311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff this limit is not exceeded. If it is exceeded, then gzprintf() will return 1132311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff return an error (0) with nothing written. In this case, there may also be a 1133311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff buffer overflow with unpredictable consequences, which is possible only if 1134311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff zlib was compiled with the insecure functions sprintf() or vsprintf() 1135311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff because the secure snprintf() or vsnprintf() functions were not available. 1136311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1137311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1138311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); 1139311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1140311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Writes the given null-terminated string to the compressed file, excluding 1141311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the terminating null character. 1142311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzputs returns the number of characters written, or -1 in case of error. 1143311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1144311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1145311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); 1146311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1147311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Reads bytes from the compressed file until len-1 characters are read, or 1148311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff a newline character is read and transferred to buf, or an end-of-file 1149311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff condition is encountered. The string is then terminated with a null 1150311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff character. 1151311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzgets returns buf, or Z_NULL in case of error. 1152311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1153311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1154311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); 1155311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1156311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Writes c, converted to an unsigned char, into the compressed file. 1157311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzputc returns the value that was written, or -1 in case of error. 1158311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1159311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1160311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzgetc OF((gzFile file)); 1161311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1162311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Reads one byte from the compressed file. gzgetc returns this byte 1163311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff or -1 in case of end of file or error. 1164311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1165311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1166311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); 1167311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1168311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Push one character back onto the stream to be read again later. 1169311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Only one character of push-back is allowed. gzungetc() returns the 1170311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff character pushed, or -1 on failure. gzungetc() will fail if a 1171311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff character has been pushed but not read yet, or if c is -1. The pushed 1172311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff character will be discarded if the stream is repositioned with gzseek() 1173311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff or gzrewind(). 1174311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1175311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1176311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); 1177311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1178311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Flushes all pending output into the compressed file. The parameter 1179311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff flush is as in the deflate() function. The return value is the zlib 1180311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff error number (see function gzerror below). gzflush returns Z_OK if 1181311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the flush parameter is Z_FINISH and all output could be flushed. 1182311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzflush should be called only when strictly necessary because it can 1183311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff degrade compression. 1184311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1185311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1186311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, 1187311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff z_off_t offset, int whence)); 1188311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1189311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Sets the starting position for the next gzread or gzwrite on the 1190311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff given compressed file. The offset represents a number of bytes in the 1191311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uncompressed data stream. The whence parameter is defined as in lseek(2); 1192311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the value SEEK_END is not supported. 1193311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff If the file is opened for reading, this function is emulated but can be 1194311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff extremely slow. If the file is opened for writing, only forward seeks are 1195311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff supported; gzseek then compresses a sequence of zeroes up to the new 1196311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff starting position. 1197311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1198311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzseek returns the resulting offset location as measured in bytes from 1199311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the beginning of the uncompressed stream, or -1 in case of error, in 1200311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff particular if the file is opened for writing and the new starting position 1201311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff would be before the current position. 1202311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1203311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1204311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzrewind OF((gzFile file)); 1205311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1206311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Rewinds the given file. This function is supported only for reading. 1207311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1208311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) 1209311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1210311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1211311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); 1212311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1213311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Returns the starting position for the next gzread or gzwrite on the 1214311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff given compressed file. This position represents a number of bytes in the 1215311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uncompressed data stream. 1216311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1217311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) 1218311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1219311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1220311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzeof OF((gzFile file)); 1221311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1222311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Returns 1 when EOF has previously been detected reading the given 1223311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff input stream, otherwise zero. 1224311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1225311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1226311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzdirect OF((gzFile file)); 1227311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1228311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Returns 1 if file is being read directly without decompression, otherwise 1229311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff zero. 1230311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1231311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1232311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT gzclose OF((gzFile file)); 1233311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1234311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Flushes all pending output if necessary, closes the compressed file 1235311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff and deallocates all the (de)compression state. The return value is the zlib 1236311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff error number (see function gzerror below). 1237311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1238311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1239311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); 1240311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1241311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Returns the error message for the last error which occurred on the 1242311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff given compressed file. errnum is set to zlib error number. If an 1243311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff error occurred in the file system and not in the compression library, 1244311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff errnum is set to Z_ERRNO and the application may consult errno 1245311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff to get the exact error code. 1246311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1247311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1248311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); 1249311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1250311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Clears the error and end-of-file flags for file. This is analogous to the 1251311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff clearerr() function in stdio. This is useful for continuing to read a gzip 1252311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff file that is being written concurrently. 1253311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1254311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1255311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff /* checksum functions */ 1256311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1257311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1258311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff These functions are not related to compression but are exported 1259311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff anyway because they might be useful in applications using the 1260311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff compression library. 1261311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1262311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1263311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); 1264311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1265311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Update a running Adler-32 checksum with the bytes buf[0..len-1] and 1266311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff return the updated checksum. If buf is NULL, this function returns 1267311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff the required initial value for the checksum. 1268311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff An Adler-32 checksum is almost as reliable as a CRC32 but can be computed 1269311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff much faster. Usage example: 1270311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1271311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uLong adler = adler32(0L, Z_NULL, 0); 1272311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1273311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff while (read_buffer(buffer, length) != EOF) { 1274311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff adler = adler32(adler, buffer, length); 1275311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff } 1276311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if (adler != original_adler) error(); 1277311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1278311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1279311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN void ZEXPORT adler32_range OF((uLong* min, uLong* max)); 1280311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1281311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Set *min and *max (both of which must not be null) to the minimum and 1282311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff maximum possible checksum values that adler32 can produce. 1283311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1284311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff This function is not part of original software distribution. It is 1285311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff added at Google (2003) in accordance with the copyright notice above, 1286311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff which permits alteration and redistribution of the original software 1287311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff provided, among other things, that altered source versions must be 1288311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff plainly marked as such and not misrepresented as being the original 1289311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff software. 1290311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1291311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1292311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, 1293311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff z_off_t len2)); 1294311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1295311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 1296311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for 1297311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of 1298311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. 1299311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1300311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1301311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); 1302311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1303311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Update a running CRC-32 with the bytes buf[0..len-1] and return the 1304311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff updated CRC-32. If buf is NULL, this function returns the required initial 1305311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff value for the for the crc. Pre- and post-conditioning (one's complement) is 1306311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff performed within this function so it shouldn't be done by the application. 1307311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Usage example: 1308311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1309311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff uLong crc = crc32(0L, Z_NULL, 0); 1310311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1311311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff while (read_buffer(buffer, length) != EOF) { 1312311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff crc = crc32(crc, buffer, length); 1313311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff } 1314311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if (crc != original_crc) error(); 1315311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1316311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1317311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); 1318311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1319311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* 1320311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff Combine two CRC-32 check values into one. For two sequences of bytes, 1321311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff seq1 and seq2 with lengths len1 and len2, CRC-32 check values were 1322311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 1323311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and 1324311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff len2. 1325311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff*/ 1326311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1327311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1328311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff /* various hacks, don't look :) */ 1329311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1330311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/* deflateInit and inflateInit are macros to allow checking the zlib version 1331311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * and the compiler's view of z_stream: 1332311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff */ 1333311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, 1334311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const char *version, int stream_size)); 1335311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, 1336311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const char *version, int stream_size)); 1337311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, 1338311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int windowBits, int memLevel, 1339311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int strategy, const char *version, 1340311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int stream_size)); 1341311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, 1342311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const char *version, int stream_size)); 1343311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, 1344311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff unsigned char FAR *window, 1345311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff const char *version, 1346311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int stream_size)); 1347311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define deflateInit(strm, level) \ 1348311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) 1349311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define inflateInit(strm) \ 1350311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) 1351311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ 1352311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ 1353311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (strategy), ZLIB_VERSION, sizeof(z_stream)) 1354311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define inflateInit2(strm, windowBits) \ 1355311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) 1356311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define inflateBackInit(strm, windowBits, window) \ 1357311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff inflateBackInit_((strm), (windowBits), (window), \ 1358311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff ZLIB_VERSION, sizeof(z_stream)) 1359311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1360311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1361311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) 1362311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff struct internal_state {int dummy;}; /* hack for buggy compilers */ 1363311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#endif 1364311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1365311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN const char * ZEXPORT zError OF((int)); 1366311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); 1367311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); 1368311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1369311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#ifdef __cplusplus 1370311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff} 1371311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#endif 1372311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 1373311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#endif /* ZLIB_H */ 1374