Lines Matching +full:no +full:- +full:use +full:- +full:before +full:- +full:define
1 /* zlib.h -- interface of the 'zlib' general purpose compression library
4 Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
6 This software is provided 'as-is', without any express or implied
7 warranty. In no event will the authors be held liable for any damages
8 arising from the use of this software.
10 Permission is granted to anyone to use this software for any purpose,
15 claim that you wrote the original software. If you use this software
22 Jean-loup Gailly Mark Adler
32 #define ZLIB_H
40 #define ZLIB_VERSION "1.2.12"
41 #define ZLIB_VERNUM 0x12c0
42 #define ZLIB_VER_MAJOR 1
43 #define ZLIB_VER_MINOR 2
44 #define ZLIB_VER_REVISION 12
45 #define ZLIB_VER_SUBREVISION 0
48 The 'zlib' compression library provides in-memory compression and
57 (providing more output space) before each call.
59 The compressed data format used by default by the in-memory functions is
71 The zlib format was designed to be compact and fast for use in memory
72 and on communications channels. The gzip format was designed for single-
95 z_const char *msg; /* last error message, NULL if no error */
104 uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */
105 uLong reserved; /* reserved for future use */
122 Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
124 Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
136 to zero. The application must initialize zalloc, zfree and opaque before
142 memory management. The compression library attaches no meaning to the
146 If zlib is used in a multi-threaded application, zalloc and zfree must be
147 thread safe. In that case, zlib is thread-safe. When zalloc and zfree are
149 routines that use the standard library functions malloc() and free().
151 On 16-bit systems, the functions zalloc and zfree must be able to allocate
158 the library with -DMAX_WBITS=14 (see zconf.h).
162 uncompressed data and may be saved for use by the decompressor (particularly
168 #define Z_NO_FLUSH 0
169 #define Z_PARTIAL_FLUSH 1
170 #define Z_SYNC_FLUSH 2
171 #define Z_FULL_FLUSH 3
172 #define Z_FINISH 4
173 #define Z_BLOCK 5
174 #define Z_TREES 6
177 #define Z_OK 0
178 #define Z_STREAM_END 1
179 #define Z_NEED_DICT 2
180 #define Z_ERRNO (-1)
181 #define Z_STREAM_ERROR (-2)
182 #define Z_DATA_ERROR (-3)
183 #define Z_MEM_ERROR (-4)
184 #define Z_BUF_ERROR (-5)
185 #define Z_VERSION_ERROR (-6)
190 #define Z_NO_COMPRESSION 0
191 #define Z_BEST_SPEED 1
192 #define Z_BEST_COMPRESSION 9
193 #define Z_DEFAULT_COMPRESSION (-1)
196 #define Z_FILTERED 1
197 #define Z_HUFFMAN_ONLY 2
198 #define Z_RLE 3
199 #define Z_FIXED 4
200 #define Z_DEFAULT_STRATEGY 0
203 #define Z_BINARY 0
204 #define Z_TEXT 1
205 #define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
206 #define Z_UNKNOWN 2
209 #define Z_DEFLATED 8
212 #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
214 #define zlib_version zlibVersion()
231 zalloc, zfree and opaque must be initialized before by the caller. If
232 zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
236 1 gives best speed, 9 gives best compression, 0 gives no compression at all
245 if there is no error message. deflateInit does not perform any compression:
260 - Compress more input starting at next_in and update next_in and avail_in
265 - Generate more output starting at next_out and update next_out and avail_out
271 Before the call of deflate(), the application should ensure that at least
274 never be zero before the call. The application can consume the compressed
283 decide how much data to accumulate before producing output, in order to
290 provided before the call.) Flushing may degrade compression for some
301 in order for the decompressor to finish the block before the empty fixed
321 avail_out), until the flush is complete (deflate returns with non-zero
330 avail_out) but no more input data, until it returns with Z_STREAM_END or an
341 deflate() sets strm->adler to the Adler-32 checksum of all input read
343 strm->adler will be the CRC-32 checksum of the input read so far. (See
346 deflate() may update strm->data_type if it can make a good guess about
356 by the application), or Z_BUF_ERROR if no progress is possible (for example
381 next_in, avail_in, zalloc, zfree and opaque must be initialized before by
386 them to use default allocation functions.
392 there is no error message. inflateInit does not perform any decompression.
395 implementation of inflateInit() does not process any header information --
410 - Decompress more input starting at next_in and update next_in and avail_in
416 - Generate more output starting at next_out and update next_out and avail_out
418 no more input data or no more space in the output buffer (see below about
421 Before the call of inflate(), the application should ensure that at least
425 output space, it is possible that there will be no progress made. The
437 after the header and before the first block. When doing a raw inflate,
442 To assist in this, on return inflate() always sets strm->data_type to the
443 number of unused bits in the last byte taken from strm->next_in, plus 64 if
445 128 if inflate() returned immediately after decoding an end-of-block code or
446 decoding the complete header up to just before the first byte of the deflate
447 stream. The end-of-block will not be indicated until all of the uncompressed
448 data from that block has been written to strm->next_out. The number of
456 end of each deflate block header is reached, before any actual data in that
458 deflate block header for later use in random access within a deflate block.
459 256 is added to the value of strm->data_type when inflate() returns
468 saved by the compressor for this purpose.) The use of Z_FINISH is not
486 below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
488 strm->adler to the Adler-32 checksum of all output produced so far (that is,
490 below. At the end of the stream, inflate() checks that its computed Adler-32
494 inflate() can decompress and check either zlib-wrapped or gzip-wrapped
498 gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
499 produced so far. The CRC-32 is checked against the gzip trailer, as is the
507 value, in which case strm->msg points to a string with a more specific
511 if no progress was possible or if there was not enough room in the output
546 fields zalloc, zfree and opaque must be initialized before by the caller.
559 will result in 9 (a 512-byte window). In that case, providing 8 to
561 checked against the initialization of inflate(). The remedy is to not use 8
562 with deflateInit2() with this initialization, or at least in that case use 9
565 windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
567 with no zlib header or trailer, and will not compute a check value.
571 compressed data instead of a zlib wrapper. The gzip header will have no
572 file name, no extra data, no comment, no modification time (set to zero), no
575 being written, strm->adler is a CRC-32 instead of an Adler-32.
577 For raw deflate or gzip encoding, a request for a 256-byte window is
587 The strategy parameter is used to tune the compression algorithm. Use the
589 filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
590 string match), or Z_RLE to limit match distances to one (run-length
599 Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
606 set to null if there is no error message. deflateInit2 does not perform any
617 deflateReset, and before any call of deflate. When doing raw deflate, this
618 function must be called either before any call of deflate, or immediately
622 compressor and decompressor must use exactly the same dictionary (see
637 addition, the current implementation of deflate will use at most the window
640 Upon return of this function, strm->adler is set to the Adler-32 value
641 of the dictionary; the decompressor may later use this value to determine
642 which dictionary has been used by the compressor. (The Adler-32 value
645 Adler-32 value is not computed and strm->adler is not set.
669 up to 258 bytes long. If the application needs the last window-size bytes of
682 tried, for example when there are several ways of pre-processing the input
728 request until strm.avail_out is not zero, before calling deflateParams().
729 Then no more input data should be provided before the deflateParams() call.
731 compressed before deflateParams(), and the new level and strategy will be
737 available input data before a change in the strategy or approach. Note that
767 called before deflate(). If that first deflate() call is provided the
797 function can only be used for raw deflate, and must be used before the first
812 after deflateInit2() or deflateReset() and before the first call of
815 ignored -- the extra flags are set according to the compression level). The
819 the current versions of the command-line version of gzip (up through version
820 1.3.x) do not support header crc's, and will report that it is a "multi-part
824 the time set to zero, and os set to 255, with no extra, name, or comment
837 before by the caller.
848 windowBits can also be zero to request that inflate use the window size in
851 windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
855 is for use with other formats that use the deflate compressed data format
858 recommended that a check value such as an Adler-32 or a CRC-32 be applied to
861 above on the use in deflateInit2() applies to the magnitude of windowBits.
866 return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
867 CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see
878 there is no error message. inflateInit2 does not perform any decompression
882 of inflateInit2() does not process any header information -- that is
893 can be determined from the Adler-32 value returned by that call of inflate.
894 The compressor and decompressor must use exactly the same dictionary (see
904 expected one (incorrect Adler-32 value). inflateSetDictionary does not
928 available input is skipped. No output is provided.
935 Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
989 middle of a byte. The provided bits will be used before any bytes are used
991 should be used before the first inflate() call after inflateInit2() or
1008 return value down 16 bits. If the upper value is -1 and the lower value is
1010 If the upper value is -1 and the lower value is non-zero, then inflate is in
1012 bytes from the input remaining to copy. If the upper value is not -1, then
1028 inflateMark returns the value noted above, or -65536 if the provided
1037 inflateInit2() or inflateReset(), and before the first call of inflate().
1038 As inflate() processes the gzip stream, head->done is zero until the header
1039 is completed, at which time head->done is set to one. If a zlib stream is
1040 being decoded, then head->done is set to -1 to indicate that there will be
1041 no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be
1043 complete and before any actual data is decompressed.
1057 absence. This allows the use of deflateSetHeader() with the returned
1078 before the call. If zalloc and zfree are Z_NULL, then the default library-
1102 inflateBack() does a raw inflate with a single call using a call-back
1111 and to initialize the state with the user-provided window buffer.
1116 A raw deflate stream is one with no zlib or gzip header or trailer.
1131 there is no input available, in() must return zero -- buf is ignored in that
1132 case -- and inflateBack() will return a buffer error. inflateBack() will
1133 call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].
1134 out() should return zero on success, or non-zero on failure. If out()
1135 returns non-zero, inflateBack() will return with an error. Neither in() nor
1138 The length written by out() will be at most the window size. Any non-zero
1142 setting strm->next_in and strm->avail_in. If that input is exhausted, then
1143 in() will be called. Therefore strm->next_in must be initialized before
1144 calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
1145 immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
1146 must also be initialized, and then if strm->avail_in is not zero, input will
1147 initially be taken from strm->next_in[0 .. strm->avail_in - 1].
1151 descriptors can be optionally used to pass any information that the caller-
1154 On return, inflateBack() will set strm->next_in and strm->avail_in to
1158 in the deflate stream (in which case strm->msg is set to indicate the nature
1161 using strm->next_in which will be Z_NULL only if in() returned an error. If
1162 strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
1163 non-zero. (in() will always be called before out(), so strm->next_in is
1164 assured to be defined if out() returns non-zero.) Note that inflateBack()
1177 /* Return flags indicating compile-time options.
1187 9: ASMV or ASMINF -- use ASM code
1188 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
1191 One-time table building (smaller code, but not thread-safe if true):
1192 12: BUILDFIXED -- build static block decoding tables when needed
1193 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
1197 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
1199 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
1201 18-19: 0 (reserved)
1204 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
1205 21: FASTEST -- deflate algorithm with only one, lowest compression level
1209 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
1210 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
1211 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
1214 27-31: 0 (reserved)
1223 stream-oriented functions. To simplify the interface, some default options
1263 compress() or compress2() on sourceLen bytes. It would be used before a
1302 typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
1310 filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h",
1311 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression
1314 appending with no compression and not using the gzip format.
1332 reading, this will be detected automatically by looking for the magic two-
1350 fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
1353 file descriptor from a FILE *, then you will have to use dup() to avoid
1354 double-close()ing the file descriptor. Both gzclose() and fclose() will
1360 provided, or '+' was provided), or if fd is -1. The file descriptor is not
1362 will not detect if fd is invalid (unless fd is -1).
1369 after gzopen() or gzdopen(), and before any other calls that read or write
1377 gzbuffer() returns 0 on success, or -1 on failure, such as being called
1385 provided data is flushed before applying the parameter changes.
1402 that remaining trailing garbage is ignored (and no error is returned).
1410 middle of a gzip stream. Note that gzread does not return -1 in the event
1413 stream. Alternatively, gzerror can be used before gzclose to detect this
1417 len for end of file, or -1 for error. If len is too large to fit in an int,
1418 then nothing is read, -1 is returned, and the error state is set to
1441 and the end-of-file flag is set. The length of the partial item read is not
1444 but it prevents the direct use of gzfread() to read a concurrently written
1445 file, reseting and retrying on end-of-file, when size is not 1.
1485 Compress and write the given null-terminated string s to file, excluding
1488 gzputs returns the number of characters written, or -1 in case of error.
1493 Read and decompress bytes from file into buf, until len-1 characters are
1495 end-of-file condition is encountered. If any characters are read or if len
1496 is one, the string is terminated with a null character. If no characters
1497 are read due to an end-of-file or len is less than one, then the buffer is
1500 gzgets returns buf which is a null-terminated string, or it returns NULL
1501 for end-of-file or in case of error. If there was an error, the contents at
1508 returns the value that was written, or -1 in case of error.
1513 Read and decompress one byte from file. gzgetc returns this byte or -1
1523 the next read. At least one character of push-back is always allowed.
1524 gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
1525 fail if c is -1, and may fail if a character has been pushed but not read
1562 the beginning of the uncompressed stream, or -1 in case of error, in
1564 would be before the current position.
1592 be used for a progress indicator. On error, gzoffset() returns -1.
1597 Return true (1) if the end-of-file indicator for file has been set while
1598 reading, false (0) otherwise. Note that the end-of-file indicator is set
1600 Therefore, just like feof(), gzeof() may return false even if there is no
1605 If gzeof() returns true, then the read functions will return no more data,
1606 unless the end-of-file indicator is reset by gzclearerr() and the input file
1620 is a gzip file. Therefore if gzbuffer() is used, it should be called before
1647 Same as gzclose(), but gzclose_r() is only for use when reading, and
1648 gzclose_w() is only for use when writing or appending. The advantage to
1665 closed, then the string previously returned by gzerror will no longer be
1668 gzerror() should be used to distinguish errors from end-of-file for those
1674 Clear the error and end-of-file flags for file. This is analogous to the
1691 Update a running Adler-32 checksum with the bytes buf[0..len-1] and
1692 return the updated checksum. An Adler-32 value is in the range of a 32-bit
1696 An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
1719 Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
1720 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
1721 each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
1724 negative, the result has no meaning or utility.
1729 Update a running CRC-32 with the bytes buf[0..len-1] and return the
1730 updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer.
1732 crc. Pre- and post-conditioning (one's complement) is performed within this
1754 Combine two CRC-32 check values into one. For two sequences of bytes,
1755 seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
1756 calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
1796 # define z_deflateInit(strm, level) \
1798 # define z_inflateInit(strm) \
1800 # define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
1803 # define z_inflateInit2(strm, windowBits) \
1806 # define z_inflateBackInit(strm, windowBits, window) \
1810 # define deflateInit(strm, level) \
1812 # define inflateInit(strm) \
1814 # define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
1817 # define inflateInit2(strm, windowBits) \
1820 # define inflateBackInit(strm, windowBits, window) \
1842 # define z_gzgetc(g) \
1843 ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
1845 # define gzgetc(g) \
1846 ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
1849 /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
1852 * functions are changed to 64 bits) -- in case these are set on systems
1867 # define z_gzopen z_gzopen64
1868 # define z_gzseek z_gzseek64
1869 # define z_gztell z_gztell64
1870 # define z_gzoffset z_gzoffset64
1871 # define z_adler32_combine z_adler32_combine64
1872 # define z_crc32_combine z_crc32_combine64
1873 # define z_crc32_combine_gen z_crc32_combine_gen64
1875 # define gzopen gzopen64
1876 # define gzseek gzseek64
1877 # define gztell gztell64
1878 # define gzoffset gzoffset64
1879 # define adler32_combine adler32_combine64
1880 # define crc32_combine crc32_combine64
1881 # define crc32_combine_gen crc32_combine_gen64