|
ZLIB
|
These functions are needed only in some special applications. More...
Typedefs | |
| typedef unsigned(* | in_func) (void *, const unsigned char **) |
| Input function used by inflateBack() | |
| typedef int(* | out_func) (void *, unsigned char *, unsigned) |
| Output function used by inflateBack() | |
Functions | |
| int ZEXPORT | deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength) |
| Initializes the compression dictionary from the given byte sequence without producing any compressed output. | |
| int ZEXPORT | deflateGetDictionary (z_streamp strm, Bytef *dictionary, uInt *dictLength) |
| Returns the sliding dictionary being maintained by deflate. | |
| int ZEXPORT | deflateCopy (z_streamp dest, z_streamp source) |
| Sets the destination stream as a complete copy of the source stream. | |
| int ZEXPORT | deflateReset (z_streamp strm) |
| This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate the internal compression state. | |
| int ZEXPORT | deflateParams (z_streamp strm, int level, int strategy) |
| Dynamically update the compression level and compression strategy. | |
| int ZEXPORT | deflateTune (z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain) |
| Fine tune deflate's internal compression parameters. | |
| uLong ZEXPORT | deflateBound (z_streamp strm, uLong sourceLen) |
| Returns an upper bound on the compressed size after deflation of sourceLen bytes. | |
| int ZEXPORT | deflatePending (z_streamp strm, unsigned *pending, int *bits) |
| Returns the number of bytes and bits of output that have been generated, but not yet provided in the available output. | |
| int ZEXPORT | deflatePrime (z_streamp strm, int bits, int value) |
| Inserts bits in the deflate output stream. | |
| int ZEXPORT | deflateSetHeader (z_streamp strm, gz_headerp head) |
| Provides gzip header information for when a gzip stream is requested by deflateInit2(). | |
| int ZEXPORT | inflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength) |
| Initializes the decompression dictionary from the given uncompressed byte sequence. | |
| int ZEXPORT | inflateGetDictionary (z_streamp strm, Bytef *dictionary, uInt *dictLength) |
| Returns the sliding dictionary being maintained by inflate. | |
| int ZEXPORT | inflateSync (z_streamp strm) |
| Skips invalid compressed data until a possible full flush point (see above for the description of deflate with Z_FULL_FLUSH) can be found, or until all available input is skipped. | |
| ZEXTERN int ZEXPORT | inflateCopy (z_streamp dest, z_streamp source) |
| Sets the destination stream as a complete copy of the source stream. | |
| int ZEXPORT | inflateReset (z_streamp strm) |
| This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate the internal decompression state. | |
| int ZEXPORT | inflateReset2 (z_streamp strm, int windowBits) |
| This function is the same as inflateReset, but it also permits changing the wrap and window size requests. | |
| int ZEXPORT | inflatePrime (z_streamp strm, int bits, int value) |
| This function inserts bits in the inflate input stream. | |
| long ZEXPORT | inflateMark (z_streamp strm) |
| This function returns two values, one in the lower 16 bits of the return value, and the other in the remaining upper bits, obtained by shifting the return value down 16 bits. | |
| int ZEXPORT | inflateGetHeader (z_streamp strm, gz_headerp head) |
| Requests that gzip header information be stored in the provided gz_header structure. | |
| int ZEXPORT | inflateBack (z_streamp strm, in_func in, void *in_desc, out_func out, void *out_desc) |
| Does a raw inflate with a single call using a call-back interface for input and output. | |
| int ZEXPORT | inflateBackEnd (z_streamp strm) |
| All memory allocated by inflateBackInit() is freed. | |
| uLong ZEXPORT | zlibCompileFlags (void) |
| Return flags indicating compile-time options. | |
| int ZEXPORT | deflateInit2_ (z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size) |
| Another version of deflateInit() with more compression options. | |
These functions are needed only in some special applications.
| uLong ZEXPORT deflateBound | ( | z_streamp | strm, |
| uLong | sourceLen | ||
| ) |
Returns an upper bound on the compressed size after deflation of sourceLen bytes.
It must be called after deflateInit() or deflateInit2(), and after deflateSetHeader(), if used. This would be used to allocate an output buffer for deflation in a single pass, and so would be called before deflate(). If that first deflate() call is provided the sourceLen input bytes, an output buffer allocated to the size returned by deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed to return Z_STREAM_END. Note that it is possible for the compressed size to be larger than the value returned by deflateBound() if flush options other than Z_FINISH or Z_NO_FLUSH are used.
For the default windowBits of 15 and memLevel of 8, this function returns a close to exact, as well as small, upper bound on the compressed size. This is an expansion of ~0.03%, plus a small constant.
For any setting other than those defaults for windowBits and memLevel, one of two worst case bounds is returned. This is at most an expansion of ~4% or ~13%, plus a small constant.
Both the 0.03% and 4% derive from the overhead of stored blocks. The first one is for stored blocks of 16383 bytes (memLevel == 8), whereas the second is for stored blocks of 127 bytes (the worst case memLevel == 1). The expansion results from five bytes of header for each stored block.
The larger expansion of 13% results from a window size less than or equal to the symbols buffer size (windowBits <= memLevel + 7). In that case some of the data being compressed may have slid out of the sliding window, impeding a stored block from being emitted. Then the only choice is a fixed or dynamic block, where a fixed block limits the maximum expansion to 9 bits per 8-bit byte, plus 10 bits for every block. The smallest block size for which this can occur is 255 (memLevel == 2).
Shifts are used to approximate divisions, for speed.
Sets the destination stream as a complete copy of the source stream.
This function can be useful when several compression strategies will be tried, for example when there are several ways of pre-processing the input data with a filter. The streams that will be discarded should then be freed by calling deflateEnd. Note that deflateCopy duplicates the internal compression state which can be quite large, so this strategy is slow and can consume lots of memory.
To simplify the source, this is not supported for 16-bit MSDOS (which doesn't have enough memory anyway to duplicate compression states).
Z_NULL).msg is left unchanged in both source and destination.
| int ZEXPORT deflateGetDictionary | ( | z_streamp | strm, |
| Bytef * | dictionary, | ||
| uInt * | dictLength | ||
| ) |
Returns the sliding dictionary being maintained by deflate.
dictLength is set to the number of bytes in the dictionary, and that many bytes are copied to dictionary. dictionary must have enough space, where 32768 bytes is always enough. If deflateGetDictionary() is called with dictionary equal to Z_NULL, then only the dictionary length is returned, and nothing is copied. Similarly, if dictLength is Z_NULL, then it is not set.
deflateGetDictionary() may return a length less than the window size, even when more than the window size in input has been provided. It may return up to 258 bytes less in that case, due to how zlib's implementation of deflate manages the sliding window and lookahead for matches, where matches can be up to 258 bytes long. If the application needs the last window-size bytes of input, then that would need to be saved by the application outside of zlib.
Z_OK on success, or Z_STREAM_ERROR if the stream state is inconsistent. | int ZEXPORT deflateInit2_ | ( | z_streamp | strm, |
| int | level, | ||
| int | method, | ||
| int | windowBits, | ||
| int | memLevel, | ||
| int | strategy, | ||
| const char * | version, | ||
| int | stream_size | ||
| ) |
Another version of deflateInit() with more compression options.
| strm | pointer to compressed stream state information The fields z_stream::zalloc, z_stream::zfree and z_stream::opaque must be initialized before by the caller. |
| level | Compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression (currently equivalent to level 6). |
| method | compression method. It must be Z_DEFLATED in this version of the library. |
| windowBits | the base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage. The default value is 15 if deflateInit is used instead. |
| memLevel | amount of memory to be allocated for compression state (see below) |
| strategy | tuning of compression algorithm (see below) |
| version | library version string used for compatibility checking |
| stream_size | size of z_streamp structure used for compatibility checking |
For the current implementation of deflate(), a windowBits value of 8 (a window size of 256 bytes) is not supported. As a result, a request for 8 will result in 9 (a 512-byte window). In that case, providing 8 to inflateInit2() will result in an error when the zlib header with 9 is checked against the initialization of inflate(). The remedy is to not use 8 with deflateInit2() with this initialization, or at least in that case use 9 with inflateInit2().
windowBits can also be -8..-15 for raw deflate. In this case, -windowBits determines the window size. deflate() will then generate raw deflate data with no zlib header or trailer, and will not compute a check value.
windowBits can also be greater than 15 for optional gzip encoding. Add 16 to windowBits to write a simple gzip header and trailer around the compressed data instead of a zlib wrapper. The gzip header will have no file name, no extra data, no comment, no modification time (set to zero), no header crc, and the operating system will be set to the appropriate value, if the operating system was determined at compile time. If a gzip stream is being written, strm->adler is a CRC-32 instead of an Adler-32.
For raw deflate or gzip encoding, a request for a 256-byte window is rejected as invalid, since only the zlib header provides a means of transmitting the window size to the decompressor.
The memLevel parameter specifies how much memory should be allocated for the internal compression state:
windowBits and memLevel.The strategy parameter is used to tune the compression algorithm. Use the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no string match), or Z_RLE to limit match distances to one (run-length encoding). Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better. The effect of Z_FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately. Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
| int ZEXPORT deflateParams | ( | z_streamp | strm, |
| int | level, | ||
| int | strategy | ||
| ) |
Dynamically update the compression level and compression strategy.
The interpretation of level and strategy is as in deflateInit2(). This can be used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression approach (which is a function of the level) or the strategy is changed, and if there have been any deflate() calls since the state was initialized or reset, then the input available so far is compressed with the old level and strategy using deflate(strm, Z_BLOCK). There are three approaches for the compression levels 0, 1..3, and 4..9 respectively. The new level and strategy will take effect at the next call of deflate().
If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does not have enough output space to complete, then the parameter change will not take effect. In this case, deflateParams() can be called again with the same parameters and more output space to try again.
In order to assure a change in the parameters on the first try, the deflate stream should be flushed using deflate() with Z_BLOCK or other flush request until strm.avail_out is not zero, before calling deflateParams(). Then no more input data should be provided before the deflateParams() call. If this is done, the old level and strategy will be applied to the data compressed before deflateParams(), and the new level and strategy will be applied to the data compressed after deflateParams().
deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if there was not enough output space to complete the compression of the available input data before a change in the strategy or approach. Note that in the case of a Z_BUF_ERROR, the parameters are not changed. A return value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be retried with more output space.
| int ZEXPORT deflatePending | ( | z_streamp | strm, |
| unsigned * | pending, | ||
| int * | bits | ||
| ) |
Returns the number of bytes and bits of output that have been generated, but not yet provided in the available output.
The bytes not provided would be due to the available output space having being consumed. The number of bits of output not provided are between 0 and 7, where they await more bits to join them in order to fill out a full byte. If pending or bits are Z_NULL, then those values are not set.
| int ZEXPORT deflatePrime | ( | z_streamp | strm, |
| int | bits, | ||
| int | value | ||
| ) |
Inserts bits in the deflate output stream.
The intent is that this function is used to start off the deflate output with the bits leftover from a previous deflate stream when appending to it. As such, this function can only be used for raw deflate, and must be used before the first deflate() call after a deflateInit2() or deflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the output.
deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the source stream state was inconsistent.
| int ZEXPORT deflateReset | ( | z_streamp | strm | ) |
This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate the internal compression state.
The stream will leave the compression level and any other attributes that may have been set unchanged. total_in, total_out, adler, and msg are initialized.
deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL).
| int ZEXPORT deflateSetDictionary | ( | z_streamp | strm, |
| const Bytef * | dictionary, | ||
| uInt | dictLength | ||
| ) |
Initializes the compression dictionary from the given byte sequence without producing any compressed output.
When using the zlib format, this function must be called immediately after deflateInit, deflateInit2 or deflateReset, and before any call of deflate. When doing raw deflate, this function must be called either before any call of deflate, or immediately after the completion of a deflate block, i.e. after all input has been consumed and all output has been delivered when using any of the flush options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The compressor and decompressor must use exactly the same dictionary (see inflateSetDictionary).
The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary.
Depending on the size of the compression data structures selected by deflateInit or deflateInit2, a part of the dictionary may in effect be discarded, for example if the dictionary is larger than the window size provided in deflateInit or deflateInit2. Thus the strings most likely to be useful should be put at the end of the dictionary, not at the front. In addition, the current implementation of deflate will use at most the window size minus 262 bytes of the provided dictionary.
Upon return of this function, strm->adler is set to the Adler-32 value of the dictionary; the decompressor may later use this value to determine which dictionary has been used by the compressor. (The Adler-32 value applies to the whole dictionary even if only a subset of the dictionary is actually used by the compressor.) If a raw deflate was requested, then the Adler-32 value is not computed and strm->adler is not set.
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent (for example if deflate has already been called for this stream or if not at a block boundary for raw deflate). deflateSetDictionary does not perform any compression: this will be done by deflate().
| int ZEXPORT deflateSetHeader | ( | z_streamp | strm, |
| gz_headerp | head | ||
| ) |
Provides gzip header information for when a gzip stream is requested by deflateInit2().
deflateSetHeader() may be called after deflateInit2() or deflateReset() and before the first call of deflate(). The text, time, os, extra field, name, and comment information in the provided gz_header structure are written to the gzip header (xflag is ignored – the extra flags are set according to the compression level). The caller must assure that, if not Z_NULL, name and comment are terminated with a zero byte, and that if extra is not Z_NULL, that extra_len bytes are available there. If hcrc is true, a gzip header crc is included. Note that the current versions of the command-line version of gzip (up through version 1.3.x) do not support header crc's, and will report that it is a "multi-part gzip file" and give up.
If deflateSetHeader is not used, the default gzip header has text false, the time set to zero, and os set to the current operating system, with no extra, name, or comment fields. The gzip header is returned to the default state by deflateReset().
deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent.
| int ZEXPORT deflateTune | ( | z_streamp | strm, |
| int | good_length, | ||
| int | max_lazy, | ||
| int | nice_length, | ||
| int | max_chain | ||
| ) |
Fine tune deflate's internal compression parameters.
This should only be used by someone who understands the algorithm used by zlib's deflate for searching for the best matching string, and even then only by the most fanatic optimizer trying to squeeze out the last compressed bit for their specific input data. Read the deflate.c source code for the meaning of the max_lazy, good_length, nice_length, and max_chain parameters.
deflateTune() can be called after deflateInit() or deflateInit2(), and returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
| int ZEXPORT inflateBack | ( | z_streamp | strm, |
| in_func | in, | ||
| void * | in_desc, | ||
| out_func | out, | ||
| void * | out_desc | ||
| ) |
Does a raw inflate with a single call using a call-back interface for input and output.
This is potentially more efficient than inflate() for file i/o applications, in that it avoids copying between the output and the sliding window by simply making the window itself the output buffer. inflate() can be faster on modern CPUs when used with large buffers. inflateBack() trusts the application to not change the output buffer passed by the output function, at least until inflateBack() returns.
inflateBackInit() must be called first to allocate the internal state and to initialize the state with the user-provided window buffer. inflateBack() may then be used multiple times to inflate a complete, raw deflate stream with each call. inflateBackEnd() is then called to free the allocated state.
A raw deflate stream is one with no zlib or gzip header or trailer. This routine would normally be used in a utility that reads zip or gzip files and writes out uncompressed files. The utility would decode the header and process the trailer on its own, hence this routine expects only the raw deflate stream to decompress. This is different from the default behavior of inflate(), which expects a zlib header and trailer around the deflate stream.
inflateBack() uses two subroutines supplied by the caller that are then called by inflateBack() for input and output. inflateBack() calls those routines until it reads a complete deflate stream and writes out all of the uncompressed data, or until it encounters an error. The function's parameters and return types are defined above in the in_func and out_func typedefs. inflateBack() will call in(in_desc, &buf) which should return the number of bytes of provided input, and a pointer to that input in buf. If there is no input available, in() must return zero – buf is ignored in that case – and inflateBack() will return a buffer error. inflateBack() will call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() should return zero on success, or non-zero on failure. If out() returns non-zero, inflateBack() will return with an error. Neither in() nor out() are permitted to change the contents of the window provided to inflateBackInit(), which is also the buffer that out() uses to write from. The length written by out() will be at most the window size. Any non-zero amount of input may be provided by in().
For convenience, inflateBack() can be provided input on the first call by setting strm->next_in and strm->avail_in. If that input is exhausted, then in() will be called. Therefore strm->next_in must be initialized before calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in must also be initialized, and then if strm->avail_in is not zero, input will initially be taken from strm->next_in[0 .. strm->avail_in - 1].
The in_desc and out_desc parameters of inflateBack() is passed as the first parameter of in() and out() respectively when they are called. These descriptors can be optionally used to pass any information that the caller- supplied in() and out() functions need to do their job.
On return, inflateBack() will set strm->next_in and strm->avail_in to pass back any unused input that was provided by the last in() call. The return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR if in() or out() returned an error, Z_DATA_ERROR if there was a format error in the deflate stream (in which case strm->msg is set to indicate the nature of the error), or Z_STREAM_ERROR if the stream was not properly initialized. In the case of Z_BUF_ERROR, an input or output error can be distinguished using strm->next_in which will be Z_NULL only if in() returned an error. If strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning non-zero. (in() will always be called before out(), so strm->next_in is assured to be defined if out() returns non-zero.) Note that inflateBack() cannot return Z_OK.
strm provides the memory allocation functions and window buffer on input, and provides information on the unused input on return. For Z_DATA_ERROR returns, strm will also provide an error message.
in() and out() are the call-back input and output functions. When inflateBack() needs more input, it calls in(). When inflateBack() has filled the window with output, or when it completes with data in the window, it calls out() to write out the data. The application must not change the provided input until in() is called again or inflateBack() returns. The application must not change the window/output buffer until inflateBack() returns.
in() and out() are called with a descriptor parameter provided in the inflateBack() call. This parameter can be a structure that provides the information required to do the read or write, as well as accumulated information on the input and output such as totals and check values.
in() should return zero on failure. out() should return non-zero on failure. If either in() or out() fails, than inflateBack() returns a Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it was in() or out() that caused in the error. Otherwise, inflateBack() returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format error, or Z_MEM_ERROR if it could not allocate memory for the state. inflateBack() can also return Z_STREAM_ERROR if the input parameters are not correct, i.e. strm is Z_NULL or the state was not initialized.
| int ZEXPORT inflateBackEnd | ( | z_streamp | strm | ) |
All memory allocated by inflateBackInit() is freed.
Sets the destination stream as a complete copy of the source stream.
This function can be useful when randomly accessing a large stream. The first pass through the stream can periodically record the inflate state, allowing restarting inflate at those points when randomly accessing the stream.
inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc being Z_NULL). msg is left unchanged in both source and destination.
| int ZEXPORT inflateGetDictionary | ( | z_streamp | strm, |
| Bytef * | dictionary, | ||
| uInt * | dictLength | ||
| ) |
Returns the sliding dictionary being maintained by inflate.
dictLength is set to the number of bytes in the dictionary, and that many bytes are copied to dictionary. dictionary must have enough space, where 32768 bytes is always enough. If inflateGetDictionary() is called with dictionary equal to Z_NULL, then only the dictionary length is returned, and nothing is copied. Similarly, if dictLength is Z_NULL, then it is not set.
inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the stream state is inconsistent.
| int ZEXPORT inflateGetHeader | ( | z_streamp | strm, |
| gz_headerp | head | ||
| ) |
Requests that gzip header information be stored in the provided gz_header structure.
inflateGetHeader() may be called after inflateInit2() or inflateReset(), and before the first call of inflate(). As inflate() processes the gzip stream, head->done is zero until the header is completed, at which time head->done is set to one. If a zlib stream is being decoded, then head->done is set to -1 to indicate that there will be no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be used to force inflate() to return immediately after header processing is complete and before any actual data is decompressed.
The text, time, xflags, and os fields are filled in with the gzip header contents. hcrc is set to true if there is a header CRC. (The header CRC was valid if done is set to one.) If extra is not Z_NULL, then extra_max contains the maximum number of bytes to write to extra. Once done is true, extra_len contains the actual extra field length, and extra contains the extra field, or that field truncated if extra_max is less than extra_len. If name is not Z_NULL, then up to name_max characters are written there, terminated with a zero unless the length is greater than name_max. If comment is not Z_NULL, then up to comm_max characters are written there, terminated with a zero unless the length is greater than comm_max. When any of extra, name, or comment are not Z_NULL and the respective field is not present in the header, then that field is set to Z_NULL to signal its absence. This allows the use of deflateSetHeader() with the returned structure to duplicate the header. However if those fields are set to allocated memory, then the application will need to save those pointers elsewhere so that they can be eventually freed.
If inflateGetHeader is not used, then the header information is simply discarded. The header is always checked for validity, including the header CRC if present. inflateReset() will reset the process to discard the header information. The application would need to call inflateGetHeader() again to retrieve the header from the next gzip stream.
| long ZEXPORT inflateMark | ( | z_streamp | strm | ) |
This function returns two values, one in the lower 16 bits of the return value, and the other in the remaining upper bits, obtained by shifting the return value down 16 bits.
If the upper value is -1 and the lower value is zero, then inflate() is currently decoding information outside of a block. If the upper value is -1 and the lower value is non-zero, then inflate is in the middle of a stored block, with the lower value equaling the number of bytes from the input remaining to copy. If the upper value is not -1, then it is the number of bits back from the current bit position in the input of the code (literal or length/distance pair) currently being processed. In that case the lower value is the number of bytes already emitted for that code.
A code is being processed if inflate is waiting for more input to complete decoding of the code, or if it has completed decoding but is waiting for more output space to write the literal or match data.
inflateMark() is used to mark locations in the input data for random access, which may be at bit positions, and to note those cases where the output of a code may span boundaries of random access blocks. The current location in the input stream can be determined from avail_in and data_type as noted in the description for the Z_BLOCK flush parameter for inflate.
inflateMark returns the value noted above, or -65536 if the provided source stream state was inconsistent.
| int ZEXPORT inflatePrime | ( | z_streamp | strm, |
| int | bits, | ||
| int | value | ||
| ) |
This function inserts bits in the inflate input stream.
The intent is that this function is used to start inflating at a bit position in the middle of a byte. The provided bits will be used before any bytes are used from next_in. This function should only be used with raw inflate, and should be used before the first inflate() call after inflateInit2() or inflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the input.
If bits is negative, then the input stream bit buffer is emptied. Then inflatePrime() can be called again to put bits in the buffer. This is used to clear out bits leftover after feeding inflate a block description prior to feeding inflate codes.
inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent.
| int ZEXPORT inflateReset | ( | z_streamp | strm | ) |
This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate the internal decompression state.
The stream will keep attributes that may have been set by inflateInit2. total_in, total_out, adler, and msg are initialized.
inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL).
| int ZEXPORT inflateReset2 | ( | z_streamp | strm, |
| int | windowBits | ||
| ) |
This function is the same as inflateReset, but it also permits changing the wrap and window size requests.
The windowBits parameter is interpreted the same as it is for inflateInit2. If the window size is changed, then the memory allocated for the window is freed, and the window will be reallocated by inflate() if needed.
inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL), or if the windowBits parameter is invalid.
| int ZEXPORT inflateSetDictionary | ( | z_streamp | strm, |
| const Bytef * | dictionary, | ||
| uInt | dictLength | ||
| ) |
Initializes the decompression dictionary from the given uncompressed byte sequence.
This function must be called immediately after a call of inflate(), if that call returned Z_NEED_DICT. The dictionary chosen by the compressor can be determined from the Adler-32 value returned by that call of inflate. The compressor and decompressor must use exactly the same dictionary (see deflateSetDictionary). For raw inflate, this function can be called at any time to set the dictionary. If the provided dictionary is smaller than the window and there is already data in the window, then the provided dictionary will amend what's there. The application must insure that the dictionary that was used for compression is provided.
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the expected one (incorrect Adler-32 value). inflateSetDictionary does not perform any decompression: this will be done by subsequent calls of inflate().
| int ZEXPORT inflateSync | ( | z_streamp | strm | ) |
Skips invalid compressed data until a possible full flush point (see above for the description of deflate with Z_FULL_FLUSH) can be found, or until all available input is skipped.
No output is provided.
inflateSync searches for a 00 00 FF FF pattern in the compressed data. All full flush points have this pattern, but not all occurrences of this pattern are full flush points.
inflateSync returns Z_OK if a possible full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the success case, the application may save the current current value of total_in which indicates where valid compressed data was found. In the error case, the application may repeatedly call inflateSync, providing more input each time, until success or end of the input data.
| uLong ZEXPORT zlibCompileFlags | ( | void | ) |
Return flags indicating compile-time options.
Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
Compiler, assembler, and debug options:
One-time table building (smaller code, but not thread-safe if true):
Library content (indicates missing functionality):
Operation variations (changes in library functionality):
The sprintf variant used by gzprintf (zero is best):
Remainder: 27-31: 0 (reserved)