📄 zlib.h
字号:
#define Z_FULL_FLUSH 2#define Z_SYNC_FLUSH 3 /* experimental: partial_flush + byte align */#define Z_FINISH 4#define Z_PACKET_FLUSH 5/* See deflate() below for the usage of these constants */#define Z_OK 0#define Z_STREAM_END 1#define Z_ERRNO (-1)#define Z_STREAM_ERROR (-2)#define Z_DATA_ERROR (-3)#define Z_MEM_ERROR (-4)#define Z_BUF_ERROR (-5)/* error codes for the compression/decompression functions */#define Z_BEST_SPEED 1#define Z_BEST_COMPRESSION 9#define Z_DEFAULT_COMPRESSION (-1)/* compression levels */#define Z_FILTERED 1#define Z_HUFFMAN_ONLY 2#define Z_DEFAULT_STRATEGY 0#define Z_BINARY 0#define Z_ASCII 1#define Z_UNKNOWN 2/* Used to set the data_type field */#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */extern char *zlib_version;/* The application can compare zlib_version and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. */ /* basic functions */extern int inflateInit OF((z_stream *strm));/* Initializes the internal stream state for decompression. The fields zalloc and zfree must be initialized before by the caller. If zalloc and zfree are set to Z_NULL, inflateInit updates them to use default allocation functions. inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory. msg is set to null if there is no error message. inflateInit does not perform any decompression: this will be done by inflate().*/extern int inflate OF((z_stream *strm, int flush));/* Performs one or both of the following actions: - Decompress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in is updated and processing will resume at this point for the next call of inflate(). - Provide more output starting at next_out and update next_out and avail_out accordingly. inflate() always provides as much output as possible (until there is no more input data or no more space in the output buffer). Before the call of inflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating the next_* and avail_* values accordingly. The application can consume the uncompressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of inflate(). If the parameter flush is set to Z_PARTIAL_FLUSH or Z_PACKET_FLUSH, inflate flushes as much output as possible to the output buffer. The flushing behavior of inflate is not specified for values of the flush parameter other than Z_PARTIAL_FLUSH, Z_PACKET_FLUSH or Z_FINISH, but the current implementation actually flushes as much output as possible anyway. For Z_PACKET_FLUSH, inflate checks that once all the input data has been consumed, it is expecting to see the length field of a stored block; if not, it returns Z_DATA_ERROR. inflate() should normally be called until it returns Z_STREAM_END or an error. However if all decompression is to be performed in a single step (a single call of inflate), the parameter flush should be set to Z_FINISH. In this case all pending input is processed and all pending output is flushed; avail_out must be large enough to hold all the uncompressed data. (The size of the uncompressed data may have been saved by the compressor for this purpose.) The next operation on this stream must be inflateEnd to deallocate the decompression state. The use of Z_FINISH is never required, but can be used to inform inflate that a faster routine may be used for the single inflate() call. inflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has been reached and all uncompressed output has been produced, Z_DATA_ERROR if the input data was corrupted, Z_STREAM_ERROR if the stream structure was inconsistent (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no progress is possible or if there was not enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR case, the application may then call inflateSync to look for a good compression block. */extern int inflateEnd OF((z_stream *strm));/* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent. In the error case, msg may be set but then points to a static string (which must not be deallocated).*/ /* advanced functions */extern int inflateInit2 OF((z_stream *strm, int windowBits));/* This is another version of inflateInit with more compression options. The fields next_out, zalloc and zfree must be initialized before by the caller. The windowBits parameter is the base two logarithm of the maximum window size (the size of the history buffer). It should be in the range 8..15 for this version of the library (the value 16 will be allowed soon). The default value is 15 if inflateInit is used instead. If a compressed stream with a larger window size is given as input, inflate() will return with the error code Z_DATA_ERROR instead of trying to allocate a larger window. If next_out is not null, the library will use this buffer for the history buffer; the buffer must either be large enough to hold the entire output data, or have at least 1<<windowBits bytes. If next_out is null, the library will allocate its own buffer (and leave next_out null). next_in need not be provided here but must be provided by the application for the next call of inflate(). If the history buffer is provided by the application, next_out must never be changed by the application since the decompressor maintains history information inside this buffer from call to call; the application can only reset next_out to the beginning of the history buffer when avail_out is zero and all output has been consumed. inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as windowBits < 8). msg is set to null if there is no error message. inflateInit2 does not perform any decompression: this will be done by inflate().*/extern int inflateSync OF((z_stream *strm));/* Skips invalid compressed data until the special marker (see deflate() above) can be found, or until all available input is skipped. No output is provided. inflateSync returns Z_OK if the special marker has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no marker 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.*/extern int inflateReset OF((z_stream *strm));/* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate all the internal decompression state. The stream will keep attributes that may have been set by inflateInit2. inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being NULL).*/extern int inflateIncomp OF((z_stream *strm));/* This function adds the data at next_in (avail_in bytes) to the output history without performing any output. There must be no pending output, and the decompressor must be expecting to see the start of a block. Calling this function is equivalent to decompressing a stored block containing the data at next_in (except that the data is not output).*/ /* checksum functions *//* This function is not related to compression but is exported anyway because it might be useful in applications using the compression library.*/extern uLong adler32 OF((uLong adler, Bytef *buf, uInt len));/* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. If buf is NULL, this function returns the required initial value for the checksum. An Adler-32 checksum is almost as reliable as a CRC32 but can be computed much faster. Usage example: uLong adler = adler32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { adler = adler32(adler, buffer, length); } if (adler != original_adler) error();*/#ifndef _Z_UTIL_H struct internal_state {int dummy;}; /* hack for buggy compilers */#endif#endif /* _ZLIB_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -