zlib.h (131377) | zlib.h (145474) |
---|---|
1/* zlib.h -- interface of the 'zlib' general purpose compression library | 1/* zlib.h -- interface of the 'zlib' general purpose compression library |
2 version 1.2.1, November 17th, 2003 | 2 version 1.2.2, October 3rd, 2004 |
3 | 3 |
4 Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler | 4 Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler |
5 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. 9 10 Permission is granted to anyone to use this software for any purpose, 11 including commercial applications, and to alter it and redistribute it 12 freely, subject to the following restrictions: --- 19 unchanged lines hidden (view full) --- 32#define ZLIB_H 33 34#include "zconf.h" 35 36#ifdef __cplusplus 37extern "C" { 38#endif 39 | 5 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. 9 10 Permission is granted to anyone to use this software for any purpose, 11 including commercial applications, and to alter it and redistribute it 12 freely, subject to the following restrictions: --- 19 unchanged lines hidden (view full) --- 32#define ZLIB_H 33 34#include "zconf.h" 35 36#ifdef __cplusplus 37extern "C" { 38#endif 39 |
40#define ZLIB_VERSION "1.2.1" 41#define ZLIB_VERNUM 0x1210 | 40#define ZLIB_VERSION "1.2.2" 41#define ZLIB_VERNUM 0x1220 |
42 43/* 44 The 'zlib' compression library provides in-memory compression and 45 decompression functions, including integrity checks of the uncompressed 46 data. This version of the library supports only one compression method 47 (deflation) but other algorithms will be added later and will have the same 48 stream interface. 49 50 Compression can be done in a single step if the buffers are large 51 enough (for example if an input file is mmap'ed), or can be done by 52 repeated calls of the compression function. In the latter case, the 53 application must provide more input and/or consume the output 54 (providing more output space) before each call. 55 | 42 43/* 44 The 'zlib' compression library provides in-memory compression and 45 decompression functions, including integrity checks of the uncompressed 46 data. This version of the library supports only one compression method 47 (deflation) but other algorithms will be added later and will have the same 48 stream interface. 49 50 Compression can be done in a single step if the buffers are large 51 enough (for example if an input file is mmap'ed), or can be done by 52 repeated calls of the compression function. In the latter case, the 53 application must provide more input and/or consume the output 54 (providing more output space) before each call. 55 |
56 The compressed data format used by the in-memory functions is the zlib 57 format, which is a zlib wrapper documented in RFC 1950, wrapped around a 58 deflate stream, which is itself documented in RFC 1951. | 56 The compressed data format used by default by the in-memory functions is 57 the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped 58 around a deflate stream, which is itself documented in RFC 1951. |
59 60 The library also supports reading and writing files in gzip (.gz) format 61 with an interface similar to that of stdio using the functions that start 62 with "gz". The gzip format is different from the zlib format. gzip is a 63 gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. 64 | 59 60 The library also supports reading and writing files in gzip (.gz) format 61 with an interface similar to that of stdio using the functions that start 62 with "gz". The gzip format is different from the zlib format. gzip is a 63 gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. 64 |
65 This library can optionally read and write gzip streams in memory as well. 66 |
|
65 The zlib format was designed to be compact and fast for use in memory 66 and on communications channels. The gzip format was designed for single- 67 file compression on file systems, has a larger header than zlib to maintain 68 directory information, and uses a different, slower check method than zlib. 69 | 67 The zlib format was designed to be compact and fast for use in memory 68 and on communications channels. The gzip format was designed for single- 69 file compression on file systems, has a larger header than zlib to maintain 70 directory information, and uses a different, slower check method than zlib. 71 |
70 This library does not provide any functions to write gzip files in memory. 71 However such functions could be easily written using zlib's deflate function, 72 the documentation in the gzip RFC, and the examples in gzio.c. 73 | |
74 The library does not install any signal handler. The decoder checks 75 the consistency of the compressed data, so the library should never 76 crash even in case of corrupted input. 77*/ 78 79typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); 80typedef void (*free_func) OF((voidpf opaque, voidpf address)); 81 --- 314 unchanged lines hidden (view full) --- 396 397 In this implementation, inflate() always flushes as much output as 398 possible to the output buffer, and always uses the faster approach on the 399 first call. So the only effect of the flush parameter in this implementation 400 is on the return value of inflate(), as noted below, or when it returns early 401 because Z_BLOCK is used. 402 403 If a preset dictionary is needed after this call (see inflateSetDictionary | 72 The library does not install any signal handler. The decoder checks 73 the consistency of the compressed data, so the library should never 74 crash even in case of corrupted input. 75*/ 76 77typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); 78typedef void (*free_func) OF((voidpf opaque, voidpf address)); 79 --- 314 unchanged lines hidden (view full) --- 394 395 In this implementation, inflate() always flushes as much output as 396 possible to the output buffer, and always uses the faster approach on the 397 first call. So the only effect of the flush parameter in this implementation 398 is on the return value of inflate(), as noted below, or when it returns early 399 because Z_BLOCK is used. 400 401 If a preset dictionary is needed after this call (see inflateSetDictionary |
404 below), inflate sets strm-adler to the adler32 checksum of the dictionary | 402 below), inflate sets strm->adler to the adler32 checksum of the dictionary |
405 chosen by the compressor and returns Z_NEED_DICT; otherwise it sets 406 strm->adler to the adler32 checksum of all output produced so far (that is, 407 total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described 408 below. At the end of the stream, inflate() checks that its computed adler32 409 checksum is equal to that saved by the compressor and returns Z_STREAM_END 410 only if the checksum is correct. 411 412 inflate() will decompress and check either zlib-wrapped or gzip-wrapped --- 60 unchanged lines hidden (view full) --- 473 windowBits can also be -8..-15 for raw deflate. In this case, -windowBits 474 determines the window size. deflate() will then generate raw deflate data 475 with no zlib header or trailer, and will not compute an adler32 check value. 476 477 windowBits can also be greater than 15 for optional gzip encoding. Add 478 16 to windowBits to write a simple gzip header and trailer around the 479 compressed data instead of a zlib wrapper. The gzip header will have no 480 file name, no extra data, no comment, no modification time (set to zero), | 403 chosen by the compressor and returns Z_NEED_DICT; otherwise it sets 404 strm->adler to the adler32 checksum of all output produced so far (that is, 405 total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described 406 below. At the end of the stream, inflate() checks that its computed adler32 407 checksum is equal to that saved by the compressor and returns Z_STREAM_END 408 only if the checksum is correct. 409 410 inflate() will decompress and check either zlib-wrapped or gzip-wrapped --- 60 unchanged lines hidden (view full) --- 471 windowBits can also be -8..-15 for raw deflate. In this case, -windowBits 472 determines the window size. deflate() will then generate raw deflate data 473 with no zlib header or trailer, and will not compute an adler32 check value. 474 475 windowBits can also be greater than 15 for optional gzip encoding. Add 476 16 to windowBits to write a simple gzip header and trailer around the 477 compressed data instead of a zlib wrapper. The gzip header will have no 478 file name, no extra data, no comment, no modification time (set to zero), |
481 no header crc, and the operating system will be set to 255 (unknown). | 479 no header crc, and the operating system will be set to 255 (unknown). If a 480 gzip stream is being written, strm->adler is a crc32 instead of an adler32. |
482 483 The memLevel parameter specifies how much memory should be allocated 484 for the internal compression state. memLevel=1 uses minimum memory but 485 is slow and reduces compression ratio; memLevel=9 uses maximum memory 486 for optimal speed. The default value is 8. See zconf.h for total memory 487 usage as a function of windowBits and memLevel. 488 489 The strategy parameter is used to tune the compression algorithm. Use the --- 154 unchanged lines hidden (view full) --- 644 recommended that a check value such as an adler32 or a crc32 be applied to 645 the uncompressed data as is done in the zlib, gzip, and zip formats. For 646 most applications, the zlib format should be used as is. Note that comments 647 above on the use in deflateInit2() applies to the magnitude of windowBits. 648 649 windowBits can also be greater than 15 for optional gzip decoding. Add 650 32 to windowBits to enable zlib and gzip decoding with automatic header 651 detection, or add 16 to decode only the gzip format (the zlib format will | 481 482 The memLevel parameter specifies how much memory should be allocated 483 for the internal compression state. memLevel=1 uses minimum memory but 484 is slow and reduces compression ratio; memLevel=9 uses maximum memory 485 for optimal speed. The default value is 8. See zconf.h for total memory 486 usage as a function of windowBits and memLevel. 487 488 The strategy parameter is used to tune the compression algorithm. Use the --- 154 unchanged lines hidden (view full) --- 643 recommended that a check value such as an adler32 or a crc32 be applied to 644 the uncompressed data as is done in the zlib, gzip, and zip formats. For 645 most applications, the zlib format should be used as is. Note that comments 646 above on the use in deflateInit2() applies to the magnitude of windowBits. 647 648 windowBits can also be greater than 15 for optional gzip decoding. Add 649 32 to windowBits to enable zlib and gzip decoding with automatic header 650 detection, or add 16 to decode only the gzip format (the zlib format will |
652 return a Z_DATA_ERROR). | 651 return a Z_DATA_ERROR. If a gzip stream is being decoded, strm->adler is 652 a crc32 instead of an adler32. |
653 654 inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 655 memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative 656 memLevel). msg is set to null if there is no error message. inflateInit2 657 does not perform any decompression apart from reading the zlib header if 658 present: this will be done by inflate(). (So next_in and avail_in may be 659 modified, but next_out and avail_out are unchanged.) 660*/ --- 523 unchanged lines hidden (view full) --- 1184 inflateBackInit_((strm), (windowBits), (window), \ 1185 ZLIB_VERSION, sizeof(z_stream)) 1186 1187 1188#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) 1189 struct internal_state {int dummy;}; /* hack for buggy compilers */ 1190#endif 1191 | 653 654 inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 655 memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative 656 memLevel). msg is set to null if there is no error message. inflateInit2 657 does not perform any decompression apart from reading the zlib header if 658 present: this will be done by inflate(). (So next_in and avail_in may be 659 modified, but next_out and avail_out are unchanged.) 660*/ --- 523 unchanged lines hidden (view full) --- 1184 inflateBackInit_((strm), (windowBits), (window), \ 1185 ZLIB_VERSION, sizeof(z_stream)) 1186 1187 1188#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) 1189 struct internal_state {int dummy;}; /* hack for buggy compilers */ 1190#endif 1191 |
1192ZEXTERN const char * ZEXPORT zError OF((int err)); | 1192ZEXTERN const char * ZEXPORT zError OF((int)); |
1193ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); 1194ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); 1195 1196#ifdef __cplusplus 1197} 1198#endif 1199 1200#endif /* ZLIB_H */ | 1193ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); 1194ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); 1195 1196#ifdef __cplusplus 1197} 1198#endif 1199 1200#endif /* ZLIB_H */ |