Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/saltstac.../salt/include
File: zlib.h
/* zlib.h -- interface of the 'zlib' general purpose compression library
[0] Fix | Delete
version 1.3.1, January 22nd, 2024
[1] Fix | Delete
[2] Fix | Delete
Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
[3] Fix | Delete
[4] Fix | Delete
This software is provided 'as-is', without any express or implied
[5] Fix | Delete
warranty. In no event will the authors be held liable for any damages
[6] Fix | Delete
arising from the use of this software.
[7] Fix | Delete
[8] Fix | Delete
Permission is granted to anyone to use this software for any purpose,
[9] Fix | Delete
including commercial applications, and to alter it and redistribute it
[10] Fix | Delete
freely, subject to the following restrictions:
[11] Fix | Delete
[12] Fix | Delete
1. The origin of this software must not be misrepresented; you must not
[13] Fix | Delete
claim that you wrote the original software. If you use this software
[14] Fix | Delete
in a product, an acknowledgment in the product documentation would be
[15] Fix | Delete
appreciated but is not required.
[16] Fix | Delete
2. Altered source versions must be plainly marked as such, and must not be
[17] Fix | Delete
misrepresented as being the original software.
[18] Fix | Delete
3. This notice may not be removed or altered from any source distribution.
[19] Fix | Delete
[20] Fix | Delete
Jean-loup Gailly Mark Adler
[21] Fix | Delete
jloup@gzip.org madler@alumni.caltech.edu
[22] Fix | Delete
[23] Fix | Delete
[24] Fix | Delete
The data format used by the zlib library is described by RFCs (Request for
[25] Fix | Delete
Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
[26] Fix | Delete
(zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
[27] Fix | Delete
*/
[28] Fix | Delete
[29] Fix | Delete
#ifndef ZLIB_H
[30] Fix | Delete
#define ZLIB_H
[31] Fix | Delete
[32] Fix | Delete
#include "zconf.h"
[33] Fix | Delete
[34] Fix | Delete
#ifdef __cplusplus
[35] Fix | Delete
extern "C" {
[36] Fix | Delete
#endif
[37] Fix | Delete
[38] Fix | Delete
#define ZLIB_VERSION "1.3.1"
[39] Fix | Delete
#define ZLIB_VERNUM 0x1310
[40] Fix | Delete
#define ZLIB_VER_MAJOR 1
[41] Fix | Delete
#define ZLIB_VER_MINOR 3
[42] Fix | Delete
#define ZLIB_VER_REVISION 1
[43] Fix | Delete
#define ZLIB_VER_SUBREVISION 0
[44] Fix | Delete
[45] Fix | Delete
/*
[46] Fix | Delete
The 'zlib' compression library provides in-memory compression and
[47] Fix | Delete
decompression functions, including integrity checks of the uncompressed data.
[48] Fix | Delete
This version of the library supports only one compression method (deflation)
[49] Fix | Delete
but other algorithms will be added later and will have the same stream
[50] Fix | Delete
interface.
[51] Fix | Delete
[52] Fix | Delete
Compression can be done in a single step if the buffers are large enough,
[53] Fix | Delete
or can be done by repeated calls of the compression function. In the latter
[54] Fix | Delete
case, the application must provide more input and/or consume the output
[55] Fix | Delete
(providing more output space) before each call.
[56] Fix | Delete
[57] Fix | Delete
The compressed data format used by default by the in-memory functions is
[58] Fix | Delete
the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
[59] Fix | Delete
around a deflate stream, which is itself documented in RFC 1951.
[60] Fix | Delete
[61] Fix | Delete
The library also supports reading and writing files in gzip (.gz) format
[62] Fix | Delete
with an interface similar to that of stdio using the functions that start
[63] Fix | Delete
with "gz". The gzip format is different from the zlib format. gzip is a
[64] Fix | Delete
gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
[65] Fix | Delete
[66] Fix | Delete
This library can optionally read and write gzip and raw deflate streams in
[67] Fix | Delete
memory as well.
[68] Fix | Delete
[69] Fix | Delete
The zlib format was designed to be compact and fast for use in memory
[70] Fix | Delete
and on communications channels. The gzip format was designed for single-
[71] Fix | Delete
file compression on file systems, has a larger header than zlib to maintain
[72] Fix | Delete
directory information, and uses a different, slower check method than zlib.
[73] Fix | Delete
[74] Fix | Delete
The library does not install any signal handler. The decoder checks
[75] Fix | Delete
the consistency of the compressed data, so the library should never crash
[76] Fix | Delete
even in the case of corrupted input.
[77] Fix | Delete
*/
[78] Fix | Delete
[79] Fix | Delete
typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size);
[80] Fix | Delete
typedef void (*free_func)(voidpf opaque, voidpf address);
[81] Fix | Delete
[82] Fix | Delete
struct internal_state;
[83] Fix | Delete
[84] Fix | Delete
typedef struct z_stream_s {
[85] Fix | Delete
z_const Bytef *next_in; /* next input byte */
[86] Fix | Delete
uInt avail_in; /* number of bytes available at next_in */
[87] Fix | Delete
uLong total_in; /* total number of input bytes read so far */
[88] Fix | Delete
[89] Fix | Delete
Bytef *next_out; /* next output byte will go here */
[90] Fix | Delete
uInt avail_out; /* remaining free space at next_out */
[91] Fix | Delete
uLong total_out; /* total number of bytes output so far */
[92] Fix | Delete
[93] Fix | Delete
z_const char *msg; /* last error message, NULL if no error */
[94] Fix | Delete
struct internal_state FAR *state; /* not visible by applications */
[95] Fix | Delete
[96] Fix | Delete
alloc_func zalloc; /* used to allocate the internal state */
[97] Fix | Delete
free_func zfree; /* used to free the internal state */
[98] Fix | Delete
voidpf opaque; /* private data object passed to zalloc and zfree */
[99] Fix | Delete
[100] Fix | Delete
int data_type; /* best guess about the data type: binary or text
[101] Fix | Delete
for deflate, or the decoding state for inflate */
[102] Fix | Delete
uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */
[103] Fix | Delete
uLong reserved; /* reserved for future use */
[104] Fix | Delete
} z_stream;
[105] Fix | Delete
[106] Fix | Delete
typedef z_stream FAR *z_streamp;
[107] Fix | Delete
[108] Fix | Delete
/*
[109] Fix | Delete
gzip header information passed to and from zlib routines. See RFC 1952
[110] Fix | Delete
for more details on the meanings of these fields.
[111] Fix | Delete
*/
[112] Fix | Delete
typedef struct gz_header_s {
[113] Fix | Delete
int text; /* true if compressed data believed to be text */
[114] Fix | Delete
uLong time; /* modification time */
[115] Fix | Delete
int xflags; /* extra flags (not used when writing a gzip file) */
[116] Fix | Delete
int os; /* operating system */
[117] Fix | Delete
Bytef *extra; /* pointer to extra field or Z_NULL if none */
[118] Fix | Delete
uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
[119] Fix | Delete
uInt extra_max; /* space at extra (only when reading header) */
[120] Fix | Delete
Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
[121] Fix | Delete
uInt name_max; /* space at name (only when reading header) */
[122] Fix | Delete
Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
[123] Fix | Delete
uInt comm_max; /* space at comment (only when reading header) */
[124] Fix | Delete
int hcrc; /* true if there was or will be a header crc */
[125] Fix | Delete
int done; /* true when done reading gzip header (not used
[126] Fix | Delete
when writing a gzip file) */
[127] Fix | Delete
} gz_header;
[128] Fix | Delete
[129] Fix | Delete
typedef gz_header FAR *gz_headerp;
[130] Fix | Delete
[131] Fix | Delete
/*
[132] Fix | Delete
The application must update next_in and avail_in when avail_in has dropped
[133] Fix | Delete
to zero. It must update next_out and avail_out when avail_out has dropped
[134] Fix | Delete
to zero. The application must initialize zalloc, zfree and opaque before
[135] Fix | Delete
calling the init function. All other fields are set by the compression
[136] Fix | Delete
library and must not be updated by the application.
[137] Fix | Delete
[138] Fix | Delete
The opaque value provided by the application will be passed as the first
[139] Fix | Delete
parameter for calls of zalloc and zfree. This can be useful for custom
[140] Fix | Delete
memory management. The compression library attaches no meaning to the
[141] Fix | Delete
opaque value.
[142] Fix | Delete
[143] Fix | Delete
zalloc must return Z_NULL if there is not enough memory for the object.
[144] Fix | Delete
If zlib is used in a multi-threaded application, zalloc and zfree must be
[145] Fix | Delete
thread safe. In that case, zlib is thread-safe. When zalloc and zfree are
[146] Fix | Delete
Z_NULL on entry to the initialization function, they are set to internal
[147] Fix | Delete
routines that use the standard library functions malloc() and free().
[148] Fix | Delete
[149] Fix | Delete
On 16-bit systems, the functions zalloc and zfree must be able to allocate
[150] Fix | Delete
exactly 65536 bytes, but will not be required to allocate more than this if
[151] Fix | Delete
the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers
[152] Fix | Delete
returned by zalloc for objects of exactly 65536 bytes *must* have their
[153] Fix | Delete
offset normalized to zero. The default allocation function provided by this
[154] Fix | Delete
library ensures this (see zutil.c). To reduce memory requirements and avoid
[155] Fix | Delete
any allocation of 64K objects, at the expense of compression ratio, compile
[156] Fix | Delete
the library with -DMAX_WBITS=14 (see zconf.h).
[157] Fix | Delete
[158] Fix | Delete
The fields total_in and total_out can be used for statistics or progress
[159] Fix | Delete
reports. After compression, total_in holds the total size of the
[160] Fix | Delete
uncompressed data and may be saved for use by the decompressor (particularly
[161] Fix | Delete
if the decompressor wants to decompress everything in a single step).
[162] Fix | Delete
*/
[163] Fix | Delete
[164] Fix | Delete
/* constants */
[165] Fix | Delete
[166] Fix | Delete
#define Z_NO_FLUSH 0
[167] Fix | Delete
#define Z_PARTIAL_FLUSH 1
[168] Fix | Delete
#define Z_SYNC_FLUSH 2
[169] Fix | Delete
#define Z_FULL_FLUSH 3
[170] Fix | Delete
#define Z_FINISH 4
[171] Fix | Delete
#define Z_BLOCK 5
[172] Fix | Delete
#define Z_TREES 6
[173] Fix | Delete
/* Allowed flush values; see deflate() and inflate() below for details */
[174] Fix | Delete
[175] Fix | Delete
#define Z_OK 0
[176] Fix | Delete
#define Z_STREAM_END 1
[177] Fix | Delete
#define Z_NEED_DICT 2
[178] Fix | Delete
#define Z_ERRNO (-1)
[179] Fix | Delete
#define Z_STREAM_ERROR (-2)
[180] Fix | Delete
#define Z_DATA_ERROR (-3)
[181] Fix | Delete
#define Z_MEM_ERROR (-4)
[182] Fix | Delete
#define Z_BUF_ERROR (-5)
[183] Fix | Delete
#define Z_VERSION_ERROR (-6)
[184] Fix | Delete
/* Return codes for the compression/decompression functions. Negative values
[185] Fix | Delete
* are errors, positive values are used for special but normal events.
[186] Fix | Delete
*/
[187] Fix | Delete
[188] Fix | Delete
#define Z_NO_COMPRESSION 0
[189] Fix | Delete
#define Z_BEST_SPEED 1
[190] Fix | Delete
#define Z_BEST_COMPRESSION 9
[191] Fix | Delete
#define Z_DEFAULT_COMPRESSION (-1)
[192] Fix | Delete
/* compression levels */
[193] Fix | Delete
[194] Fix | Delete
#define Z_FILTERED 1
[195] Fix | Delete
#define Z_HUFFMAN_ONLY 2
[196] Fix | Delete
#define Z_RLE 3
[197] Fix | Delete
#define Z_FIXED 4
[198] Fix | Delete
#define Z_DEFAULT_STRATEGY 0
[199] Fix | Delete
/* compression strategy; see deflateInit2() below for details */
[200] Fix | Delete
[201] Fix | Delete
#define Z_BINARY 0
[202] Fix | Delete
#define Z_TEXT 1
[203] Fix | Delete
#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
[204] Fix | Delete
#define Z_UNKNOWN 2
[205] Fix | Delete
/* Possible values of the data_type field for deflate() */
[206] Fix | Delete
[207] Fix | Delete
#define Z_DEFLATED 8
[208] Fix | Delete
/* The deflate compression method (the only one supported in this version) */
[209] Fix | Delete
[210] Fix | Delete
#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
[211] Fix | Delete
[212] Fix | Delete
#define zlib_version zlibVersion()
[213] Fix | Delete
/* for compatibility with versions < 1.0.2 */
[214] Fix | Delete
[215] Fix | Delete
[216] Fix | Delete
/* basic functions */
[217] Fix | Delete
[218] Fix | Delete
ZEXTERN const char * ZEXPORT zlibVersion(void);
[219] Fix | Delete
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
[220] Fix | Delete
If the first character differs, the library code actually used is not
[221] Fix | Delete
compatible with the zlib.h header file used by the application. This check
[222] Fix | Delete
is automatically made by deflateInit and inflateInit.
[223] Fix | Delete
*/
[224] Fix | Delete
[225] Fix | Delete
/*
[226] Fix | Delete
ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level);
[227] Fix | Delete
[228] Fix | Delete
Initializes the internal stream state for compression. The fields
[229] Fix | Delete
zalloc, zfree and opaque must be initialized before by the caller. If
[230] Fix | Delete
zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
[231] Fix | Delete
allocation functions. total_in, total_out, adler, and msg are initialized.
[232] Fix | Delete
[233] Fix | Delete
The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
[234] Fix | Delete
1 gives best speed, 9 gives best compression, 0 gives no compression at all
[235] Fix | Delete
(the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION
[236] Fix | Delete
requests a default compromise between speed and compression (currently
[237] Fix | Delete
equivalent to level 6).
[238] Fix | Delete
[239] Fix | Delete
deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
[240] Fix | Delete
memory, Z_STREAM_ERROR if level is not a valid compression level, or
[241] Fix | Delete
Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
[242] Fix | Delete
with the version assumed by the caller (ZLIB_VERSION). msg is set to null
[243] Fix | Delete
if there is no error message. deflateInit does not perform any compression:
[244] Fix | Delete
this will be done by deflate().
[245] Fix | Delete
*/
[246] Fix | Delete
[247] Fix | Delete
[248] Fix | Delete
ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush);
[249] Fix | Delete
/*
[250] Fix | Delete
deflate compresses as much data as possible, and stops when the input
[251] Fix | Delete
buffer becomes empty or the output buffer becomes full. It may introduce
[252] Fix | Delete
some output latency (reading input without producing any output) except when
[253] Fix | Delete
forced to flush.
[254] Fix | Delete
[255] Fix | Delete
The detailed semantics are as follows. deflate performs one or both of the
[256] Fix | Delete
following actions:
[257] Fix | Delete
[258] Fix | Delete
- Compress more input starting at next_in and update next_in and avail_in
[259] Fix | Delete
accordingly. If not all input can be processed (because there is not
[260] Fix | Delete
enough room in the output buffer), next_in and avail_in are updated and
[261] Fix | Delete
processing will resume at this point for the next call of deflate().
[262] Fix | Delete
[263] Fix | Delete
- Generate more output starting at next_out and update next_out and avail_out
[264] Fix | Delete
accordingly. This action is forced if the parameter flush is non zero.
[265] Fix | Delete
Forcing flush frequently degrades the compression ratio, so this parameter
[266] Fix | Delete
should be set only when necessary. Some output may be provided even if
[267] Fix | Delete
flush is zero.
[268] Fix | Delete
[269] Fix | Delete
Before the call of deflate(), the application should ensure that at least
[270] Fix | Delete
one of the actions is possible, by providing more input and/or consuming more
[271] Fix | Delete
output, and updating avail_in or avail_out accordingly; avail_out should
[272] Fix | Delete
never be zero before the call. The application can consume the compressed
[273] Fix | Delete
output when it wants, for example when the output buffer is full (avail_out
[274] Fix | Delete
== 0), or after each call of deflate(). If deflate returns Z_OK and with
[275] Fix | Delete
zero avail_out, it must be called again after making room in the output
[276] Fix | Delete
buffer because there might be more output pending. See deflatePending(),
[277] Fix | Delete
which can be used if desired to determine whether or not there is more output
[278] Fix | Delete
in that case.
[279] Fix | Delete
[280] Fix | Delete
Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
[281] Fix | Delete
decide how much data to accumulate before producing output, in order to
[282] Fix | Delete
maximize compression.
[283] Fix | Delete
[284] Fix | Delete
If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
[285] Fix | Delete
flushed to the output buffer and the output is aligned on a byte boundary, so
[286] Fix | Delete
that the decompressor can get all input data available so far. (In
[287] Fix | Delete
particular avail_in is zero after the call if enough output space has been
[288] Fix | Delete
provided before the call.) Flushing may degrade compression for some
[289] Fix | Delete
compression algorithms and so it should be used only when necessary. This
[290] Fix | Delete
completes the current deflate block and follows it with an empty stored block
[291] Fix | Delete
that is three bits plus filler bits to the next byte, followed by four bytes
[292] Fix | Delete
(00 00 ff ff).
[293] Fix | Delete
[294] Fix | Delete
If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
[295] Fix | Delete
output buffer, but the output is not aligned to a byte boundary. All of the
[296] Fix | Delete
input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
[297] Fix | Delete
This completes the current deflate block and follows it with an empty fixed
[298] Fix | Delete
codes block that is 10 bits long. This assures that enough bytes are output
[299] Fix | Delete
in order for the decompressor to finish the block before the empty fixed
[300] Fix | Delete
codes block.
[301] Fix | Delete
[302] Fix | Delete
If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
[303] Fix | Delete
for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
[304] Fix | Delete
seven bits of the current block are held to be written as the next byte after
[305] Fix | Delete
the next deflate block is completed. In this case, the decompressor may not
[306] Fix | Delete
be provided enough bits at this point in order to complete decompression of
[307] Fix | Delete
the data provided so far to the compressor. It may need to wait for the next
[308] Fix | Delete
block to be emitted. This is for advanced applications that need to control
[309] Fix | Delete
the emission of deflate blocks.
[310] Fix | Delete
[311] Fix | Delete
If flush is set to Z_FULL_FLUSH, all output is flushed as with
[312] Fix | Delete
Z_SYNC_FLUSH, and the compression state is reset so that decompression can
[313] Fix | Delete
restart from this point if previous compressed data has been damaged or if
[314] Fix | Delete
random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
[315] Fix | Delete
compression.
[316] Fix | Delete
[317] Fix | Delete
If deflate returns with avail_out == 0, this function must be called again
[318] Fix | Delete
with the same value of the flush parameter and more output space (updated
[319] Fix | Delete
avail_out), until the flush is complete (deflate returns with non-zero
[320] Fix | Delete
avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
[321] Fix | Delete
avail_out is greater than six when the flush marker begins, in order to avoid
[322] Fix | Delete
repeated flush markers upon calling deflate() again when avail_out == 0.
[323] Fix | Delete
[324] Fix | Delete
If the parameter flush is set to Z_FINISH, pending input is processed,
[325] Fix | Delete
pending output is flushed and deflate returns with Z_STREAM_END if there was
[326] Fix | Delete
enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this
[327] Fix | Delete
function must be called again with Z_FINISH and more output space (updated
[328] Fix | Delete
avail_out) but no more input data, until it returns with Z_STREAM_END or an
[329] Fix | Delete
error. After deflate has returned Z_STREAM_END, the only possible operations
[330] Fix | Delete
on the stream are deflateReset or deflateEnd.
[331] Fix | Delete
[332] Fix | Delete
Z_FINISH can be used in the first deflate call after deflateInit if all the
[333] Fix | Delete
compression is to be done in a single step. In order to complete in one
[334] Fix | Delete
call, avail_out must be at least the value returned by deflateBound (see
[335] Fix | Delete
below). Then deflate is guaranteed to return Z_STREAM_END. If not enough
[336] Fix | Delete
output space is provided, deflate will not return Z_STREAM_END, and it must
[337] Fix | Delete
be called again as described above.
[338] Fix | Delete
[339] Fix | Delete
deflate() sets strm->adler to the Adler-32 checksum of all input read
[340] Fix | Delete
so far (that is, total_in bytes). If a gzip stream is being generated, then
[341] Fix | Delete
strm->adler will be the CRC-32 checksum of the input read so far. (See
[342] Fix | Delete
deflateInit2 below.)
[343] Fix | Delete
[344] Fix | Delete
deflate() may update strm->data_type if it can make a good guess about
[345] Fix | Delete
the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is
[346] Fix | Delete
considered binary. This field is only for information purposes and does not
[347] Fix | Delete
affect the compression algorithm in any manner.
[348] Fix | Delete
[349] Fix | Delete
deflate() returns Z_OK if some progress has been made (more input
[350] Fix | Delete
processed or more output produced), Z_STREAM_END if all input has been
[351] Fix | Delete
consumed and all output has been produced (only when flush is set to
[352] Fix | Delete
Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
[353] Fix | Delete
if next_in or next_out was Z_NULL or the state was inadvertently written over
[354] Fix | Delete
by the application), or Z_BUF_ERROR if no progress is possible (for example
[355] Fix | Delete
avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and
[356] Fix | Delete
deflate() can be called again with more input and more output space to
[357] Fix | Delete
continue compressing.
[358] Fix | Delete
*/
[359] Fix | Delete
[360] Fix | Delete
[361] Fix | Delete
ZEXTERN int ZEXPORT deflateEnd(z_streamp strm);
[362] Fix | Delete
/*
[363] Fix | Delete
All dynamically allocated data structures for this stream are freed.
[364] Fix | Delete
This function discards any unprocessed input and does not flush any pending
[365] Fix | Delete
output.
[366] Fix | Delete
[367] Fix | Delete
deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
[368] Fix | Delete
stream state was inconsistent, Z_DATA_ERROR if the stream was freed
[369] Fix | Delete
prematurely (some input or output was discarded). In the error case, msg
[370] Fix | Delete
may be set but then points to a static string (which must not be
[371] Fix | Delete
deallocated).
[372] Fix | Delete
*/
[373] Fix | Delete
[374] Fix | Delete
[375] Fix | Delete
/*
[376] Fix | Delete
ZEXTERN int ZEXPORT inflateInit(z_streamp strm);
[377] Fix | Delete
[378] Fix | Delete
Initializes the internal stream state for decompression. The fields
[379] Fix | Delete
next_in, avail_in, zalloc, zfree and opaque must be initialized before by
[380] Fix | Delete
the caller. In the current version of inflate, the provided input is not
[381] Fix | Delete
read or consumed. The allocation of a sliding window will be deferred to
[382] Fix | Delete
the first call of inflate (if the decompression does not complete on the
[383] Fix | Delete
first call). If zalloc and zfree are set to Z_NULL, inflateInit updates
[384] Fix | Delete
them to use default allocation functions. total_in, total_out, adler, and
[385] Fix | Delete
msg are initialized.
[386] Fix | Delete
[387] Fix | Delete
inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
[388] Fix | Delete
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
[389] Fix | Delete
version assumed by the caller, or Z_STREAM_ERROR if the parameters are
[390] Fix | Delete
invalid, such as a null pointer to the structure. msg is set to null if
[391] Fix | Delete
there is no error message. inflateInit does not perform any decompression.
[392] Fix | Delete
Actual decompression will be done by inflate(). So next_in, and avail_in,
[393] Fix | Delete
next_out, and avail_out are unused and unchanged. The current
[394] Fix | Delete
implementation of inflateInit() does not process any header information --
[395] Fix | Delete
that is deferred until inflate() is called.
[396] Fix | Delete
*/
[397] Fix | Delete
[398] Fix | Delete
[399] Fix | Delete
ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush);
[400] Fix | Delete
/*
[401] Fix | Delete
inflate decompresses as much data as possible, and stops when the input
[402] Fix | Delete
buffer becomes empty or the output buffer becomes full. It may introduce
[403] Fix | Delete
some output latency (reading input without producing any output) except when
[404] Fix | Delete
forced to flush.
[405] Fix | Delete
[406] Fix | Delete
The detailed semantics are as follows. inflate performs one or both of the
[407] Fix | Delete
following actions:
[408] Fix | Delete
[409] Fix | Delete
- Decompress more input starting at next_in and update next_in and avail_in
[410] Fix | Delete
accordingly. If not all input can be processed (because there is not
[411] Fix | Delete
enough room in the output buffer), then next_in and avail_in are updated
[412] Fix | Delete
accordingly, and processing will resume at this point for the next call of
[413] Fix | Delete
inflate().
[414] Fix | Delete
[415] Fix | Delete
- Generate more output starting at next_out and update next_out and avail_out
[416] Fix | Delete
accordingly. inflate() provides as much output as possible, until there is
[417] Fix | Delete
no more input data or no more space in the output buffer (see below about
[418] Fix | Delete
the flush parameter).
[419] Fix | Delete
[420] Fix | Delete
Before the call of inflate(), the application should ensure that at least
[421] Fix | Delete
one of the actions is possible, by providing more input and/or consuming more
[422] Fix | Delete
output, and updating the next_* and avail_* values accordingly. If the
[423] Fix | Delete
caller of inflate() does not provide both available input and available
[424] Fix | Delete
output space, it is possible that there will be no progress made. The
[425] Fix | Delete
application can consume the uncompressed output when it wants, for example
[426] Fix | Delete
when the output buffer is full (avail_out == 0), or after each call of
[427] Fix | Delete
inflate(). If inflate returns Z_OK and with zero avail_out, it must be
[428] Fix | Delete
called again after making room in the output buffer because there might be
[429] Fix | Delete
more output pending.
[430] Fix | Delete
[431] Fix | Delete
The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
[432] Fix | Delete
Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much
[433] Fix | Delete
output as possible to the output buffer. Z_BLOCK requests that inflate()
[434] Fix | Delete
stop if and when it gets to the next deflate block boundary. When decoding
[435] Fix | Delete
the zlib or gzip format, this will cause inflate() to return immediately
[436] Fix | Delete
after the header and before the first block. When doing a raw inflate,
[437] Fix | Delete
inflate() will go ahead and process the first block, and will return when it
[438] Fix | Delete
gets to the end of that block, or when it runs out of data.
[439] Fix | Delete
[440] Fix | Delete
The Z_BLOCK option assists in appending to or combining deflate streams.
[441] Fix | Delete
To assist in this, on return inflate() always sets strm->data_type to the
[442] Fix | Delete
number of unused bits in the last byte taken from strm->next_in, plus 64 if
[443] Fix | Delete
inflate() is currently decoding the last block in the deflate stream, plus
[444] Fix | Delete
128 if inflate() returned immediately after decoding an end-of-block code or
[445] Fix | Delete
decoding the complete header up to just before the first byte of the deflate
[446] Fix | Delete
stream. The end-of-block will not be indicated until all of the uncompressed
[447] Fix | Delete
data from that block has been written to strm->next_out. The number of
[448] Fix | Delete
unused bits may in general be greater than seven, except when bit 7 of
[449] Fix | Delete
data_type is set, in which case the number of unused bits will be less than
[450] Fix | Delete
eight. data_type is set as noted here every time inflate() returns for all
[451] Fix | Delete
flush options, and so can be used to determine the amount of currently
[452] Fix | Delete
consumed input in bits.
[453] Fix | Delete
[454] Fix | Delete
The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
[455] Fix | Delete
end of each deflate block header is reached, before any actual data in that
[456] Fix | Delete
block is decoded. This allows the caller to determine the length of the
[457] Fix | Delete
deflate block header for later use in random access within a deflate block.
[458] Fix | Delete
256 is added to the value of strm->data_type when inflate() returns
[459] Fix | Delete
immediately after reaching the end of the deflate block header.
[460] Fix | Delete
[461] Fix | Delete
inflate() should normally be called until it returns Z_STREAM_END or an
[462] Fix | Delete
error. However if all decompression is to be performed in a single step (a
[463] Fix | Delete
single call of inflate), the parameter flush should be set to Z_FINISH. In
[464] Fix | Delete
this case all pending input is processed and all pending output is flushed;
[465] Fix | Delete
avail_out must be large enough to hold all of the uncompressed data for the
[466] Fix | Delete
operation to complete. (The size of the uncompressed data may have been
[467] Fix | Delete
saved by the compressor for this purpose.) The use of Z_FINISH is not
[468] Fix | Delete
required to perform an inflation in one step. However it may be used to
[469] Fix | Delete
inform inflate that a faster approach can be used for the single inflate()
[470] Fix | Delete
call. Z_FINISH also informs inflate to not maintain a sliding window if the
[471] Fix | Delete
stream completes, which reduces inflate's memory footprint. If the stream
[472] Fix | Delete
does not complete, either because not all of the stream is provided or not
[473] Fix | Delete
enough output space is provided, then a sliding window will be allocated and
[474] Fix | Delete
inflate() can be called again to continue the operation as if Z_NO_FLUSH had
[475] Fix | Delete
been used.
[476] Fix | Delete
[477] Fix | Delete
In this implementation, inflate() always flushes as much output as
[478] Fix | Delete
possible to the output buffer, and always uses the faster approach on the
[479] Fix | Delete
first call. So the effects of the flush parameter in this implementation are
[480] Fix | Delete
on the return value of inflate() as noted below, when inflate() returns early
[481] Fix | Delete
when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
[482] Fix | Delete
memory for a sliding window when Z_FINISH is used.
[483] Fix | Delete
[484] Fix | Delete
If a preset dictionary is needed after this call (see inflateSetDictionary
[485] Fix | Delete
below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
[486] Fix | Delete
chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
[487] Fix | Delete
strm->adler to the Adler-32 checksum of all output produced so far (that is,
[488] Fix | Delete
total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
[489] Fix | Delete
below. At the end of the stream, inflate() checks that its computed Adler-32
[490] Fix | Delete
checksum is equal to that saved by the compressor and returns Z_STREAM_END
[491] Fix | Delete
only if the checksum is correct.
[492] Fix | Delete
[493] Fix | Delete
inflate() can decompress and check either zlib-wrapped or gzip-wrapped
[494] Fix | Delete
deflate data. The header type is detected automatically, if requested when
[495] Fix | Delete
initializing with inflateInit2(). Any information contained in the gzip
[496] Fix | Delete
header is not retained unless inflateGetHeader() is used. When processing
[497] Fix | Delete
gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
[498] Fix | Delete
produced so far. The CRC-32 is checked against the gzip trailer, as is the
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function