diff options
Diffstat (limited to 'zlib.h')
-rw-r--r-- | zlib.h | 187 |
1 files changed, 42 insertions, 145 deletions
@@ -1,5 +1,5 @@ | |||
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.0, Jan 27th, 1996. | 2 | version 1.0, Jan 14th, 1996. |
3 | 3 | ||
4 | Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler | 4 | Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler |
5 | 5 | ||
@@ -51,11 +51,6 @@ extern "C" { | |||
51 | repeated calls of the compression function. In the latter case, the | 51 | repeated calls of the compression function. In the latter case, the |
52 | application must provide more input and/or consume the output | 52 | application must provide more input and/or consume the output |
53 | (providing more output space) before each call. | 53 | (providing more output space) before each call. |
54 | |||
55 | The library does not install any signal handler. It is recommended to | ||
56 | add at least a handler for SIGSEGV when decompressing; the library checks | ||
57 | the consistency of the input data whenever possible but may go nuts | ||
58 | for some forms of corrupted input. | ||
59 | */ | 54 | */ |
60 | 55 | ||
61 | typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); | 56 | typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); |
@@ -79,9 +74,8 @@ typedef struct z_stream_s { | |||
79 | free_func zfree; /* used to free the internal state */ | 74 | free_func zfree; /* used to free the internal state */ |
80 | voidpf opaque; /* private data object passed to zalloc and zfree */ | 75 | voidpf opaque; /* private data object passed to zalloc and zfree */ |
81 | 76 | ||
82 | int data_type; /* best guess about the data type: ascii or binary */ | 77 | Byte data_type; /* best guess about the data type: ascii or binary */ |
83 | uLong adler; /* adler32 value of the uncompressed data */ | 78 | |
84 | uLong reserved; /* reserved for future use */ | ||
85 | } z_stream; | 79 | } z_stream; |
86 | 80 | ||
87 | /* | 81 | /* |
@@ -124,16 +118,12 @@ typedef struct z_stream_s { | |||
124 | 118 | ||
125 | #define Z_OK 0 | 119 | #define Z_OK 0 |
126 | #define Z_STREAM_END 1 | 120 | #define Z_STREAM_END 1 |
127 | #define Z_NEED_DICT 2 | ||
128 | #define Z_ERRNO (-1) | 121 | #define Z_ERRNO (-1) |
129 | #define Z_STREAM_ERROR (-2) | 122 | #define Z_STREAM_ERROR (-2) |
130 | #define Z_DATA_ERROR (-3) | 123 | #define Z_DATA_ERROR (-3) |
131 | #define Z_MEM_ERROR (-4) | 124 | #define Z_MEM_ERROR (-4) |
132 | #define Z_BUF_ERROR (-5) | 125 | #define Z_BUF_ERROR (-5) |
133 | #define Z_VERSION_ERROR (-6) | 126 | /* error codes for the compression/decompression functions */ |
134 | /* Return codes for the compression/decompression functions. Negative | ||
135 | * values are errors, positive values are used for special but normal events. | ||
136 | */ | ||
137 | 127 | ||
138 | #define Z_NO_COMPRESSION 0 | 128 | #define Z_NO_COMPRESSION 0 |
139 | #define Z_BEST_SPEED 1 | 129 | #define Z_BEST_SPEED 1 |
@@ -144,19 +134,18 @@ typedef struct z_stream_s { | |||
144 | #define Z_FILTERED 1 | 134 | #define Z_FILTERED 1 |
145 | #define Z_HUFFMAN_ONLY 2 | 135 | #define Z_HUFFMAN_ONLY 2 |
146 | #define Z_DEFAULT_STRATEGY 0 | 136 | #define Z_DEFAULT_STRATEGY 0 |
147 | /* compression strategy; see deflateInit2() below for details */ | ||
148 | 137 | ||
149 | #define Z_BINARY 0 | 138 | #define Z_BINARY 0 |
150 | #define Z_ASCII 1 | 139 | #define Z_ASCII 1 |
151 | #define Z_UNKNOWN 2 | 140 | #define Z_UNKNOWN 2 |
152 | /* Possible values of the data_type field */ | 141 | /* Used to set the data_type field */ |
153 | 142 | ||
154 | #define Z_DEFLATED 8 | 143 | #define Z_DEFLATED 8 |
155 | /* The deflate compression method (the only one supported in this version) */ | 144 | /* The deflate compression method (the only one supported in this version) */ |
156 | 145 | ||
157 | #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ | 146 | #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ |
158 | 147 | ||
159 | extern const char *zlib_version; | 148 | extern char *zlib_version; |
160 | /* The application can compare zlib_version and ZLIB_VERSION for consistency. | 149 | /* The application can compare zlib_version and ZLIB_VERSION for consistency. |
161 | If the first character differs, the library code actually used is | 150 | If the first character differs, the library code actually used is |
162 | not compatible with the zlib.h header file used by the application. | 151 | not compatible with the zlib.h header file used by the application. |
@@ -164,9 +153,8 @@ extern const char *zlib_version; | |||
164 | 153 | ||
165 | /* basic functions */ | 154 | /* basic functions */ |
166 | 155 | ||
167 | /* | ||
168 | extern int deflateInit OF((z_stream *strm, int level)); | 156 | extern int deflateInit OF((z_stream *strm, int level)); |
169 | 157 | /* | |
170 | Initializes the internal stream state for compression. The fields | 158 | Initializes the internal stream state for compression. The fields |
171 | zalloc, zfree and opaque must be initialized before by the caller. | 159 | zalloc, zfree and opaque must be initialized before by the caller. |
172 | If zalloc and zfree are set to Z_NULL, deflateInit updates them to | 160 | If zalloc and zfree are set to Z_NULL, deflateInit updates them to |
@@ -179,9 +167,7 @@ extern int deflateInit OF((z_stream *strm, int level)); | |||
179 | compression (currently equivalent to level 6). | 167 | compression (currently equivalent to level 6). |
180 | 168 | ||
181 | deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not | 169 | deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not |
182 | enough memory, Z_STREAM_ERROR if level is not a valid compression level, | 170 | enough memory, Z_STREAM_ERROR if level is not a valid compression level. |
183 | Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible | ||
184 | with the version assumed by the caller (ZLIB_VERSION). | ||
185 | msg is set to null if there is no error message. deflateInit does not | 171 | msg is set to null if there is no error message. deflateInit does not |
186 | perform any compression: this will be done by deflate(). | 172 | perform any compression: this will be done by deflate(). |
187 | */ | 173 | */ |
@@ -261,26 +247,22 @@ extern int deflateEnd OF((z_stream *strm)); | |||
261 | pending output. | 247 | pending output. |
262 | 248 | ||
263 | deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the | 249 | deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the |
264 | stream state was inconsistent, Z_DATA_ERROR if the stream was freed | 250 | stream state was inconsistent. In the error case, msg may be set |
265 | prematurely (some input or output was discarded). In the error case, | 251 | but then points to a static string (which must not be deallocated). |
266 | msg may be set but then points to a static string (which must not be | ||
267 | deallocated). | ||
268 | */ | 252 | */ |
269 | 253 | ||
270 | 254 | ||
271 | /* | ||
272 | extern int inflateInit OF((z_stream *strm)); | 255 | extern int inflateInit OF((z_stream *strm)); |
273 | 256 | /* | |
274 | Initializes the internal stream state for decompression. The fields | 257 | Initializes the internal stream state for decompression. The fields |
275 | zalloc, zfree and opaque must be initialized before by the caller. If | 258 | zalloc, zfree and opaque must be initialized before by the caller. If |
276 | zalloc and zfree are set to Z_NULL, inflateInit updates them to use default | 259 | zalloc and zfree are set to Z_NULL, inflateInit updates them to use default |
277 | allocation functions. | 260 | allocation functions. |
278 | 261 | ||
279 | inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not | 262 | inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not |
280 | enough memory, Z_VERSION_ERROR if the zlib library version is incompatible | 263 | enough memory. msg is set to null if there is no error message. |
281 | with the version assumed by the caller. msg is set to null if there is no | 264 | inflateInit does not perform any decompression: this will be done by |
282 | error message. inflateInit does not perform any decompression: this will be | 265 | inflate(). |
283 | done by inflate(). | ||
284 | */ | 266 | */ |
285 | 267 | ||
286 | 268 | ||
@@ -324,15 +306,12 @@ extern int inflate OF((z_stream *strm, int flush)); | |||
324 | inflate() returns Z_OK if some progress has been made (more input | 306 | inflate() returns Z_OK if some progress has been made (more input |
325 | processed or more output produced), Z_STREAM_END if the end of the | 307 | processed or more output produced), Z_STREAM_END if the end of the |
326 | compressed data has been reached and all uncompressed output has been | 308 | compressed data has been reached and all uncompressed output has been |
327 | produced, Z_NEED_DICT if a preset dictionary is needed at this point (see | 309 | produced, Z_DATA_ERROR if the input data was corrupted, Z_STREAM_ERROR if |
328 | inflateSetDictionary below), Z_DATA_ERROR if the input data was corrupted, | 310 | the stream structure was inconsistent (for example if next_in or next_out |
329 | Z_STREAM_ERROR if the stream structure was inconsistent (for example if | 311 | was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no |
330 | next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, | 312 | progress is possible or if there was not enough room in the output buffer |
331 | Z_BUF_ERROR if no progress is possible or if there was not enough room in | 313 | when Z_FINISH is used. In the Z_DATA_ERROR case, the application may then |
332 | the output buffer when Z_FINISH is used. In the Z_DATA_ERROR case, the | 314 | call inflateSync to look for a good compression block. |
333 | application may then call inflateSync to look for a good compression block. | ||
334 | In the Z_NEED_DICT case, strm->adler is set to the Adler32 value of the | ||
335 | dictionary chosen by the compressor. | ||
336 | */ | 315 | */ |
337 | 316 | ||
338 | 317 | ||
@@ -347,20 +326,19 @@ extern int inflateEnd OF((z_stream *strm)); | |||
347 | static string (which must not be deallocated). | 326 | static string (which must not be deallocated). |
348 | */ | 327 | */ |
349 | 328 | ||
350 | /* Advanced functions */ | 329 | /* advanced functions */ |
351 | 330 | ||
352 | /* | 331 | /* |
353 | The following functions are needed only in some special applications. | 332 | The following functions are needed only in some special applications. |
354 | */ | 333 | */ |
355 | 334 | ||
356 | /* | ||
357 | extern int deflateInit2 OF((z_stream *strm, | 335 | extern int deflateInit2 OF((z_stream *strm, |
358 | int level, | 336 | int level, |
359 | int method, | 337 | int method, |
360 | int windowBits, | 338 | int windowBits, |
361 | int memLevel, | 339 | int memLevel, |
362 | int strategy)); | 340 | int strategy)); |
363 | 341 | /* | |
364 | This is another version of deflateInit with more compression options. The | 342 | This is another version of deflateInit with more compression options. The |
365 | fields next_in, zalloc, zfree and opaque must be initialized before by | 343 | fields next_in, zalloc, zfree and opaque must be initialized before by |
366 | the caller. | 344 | the caller. |
@@ -375,22 +353,20 @@ extern int deflateInit2 OF((z_stream *strm, | |||
375 | values of this parameter result in better compression at the expense of | 353 | values of this parameter result in better compression at the expense of |
376 | memory usage. The default value is 15 if deflateInit is used instead. | 354 | memory usage. The default value is 15 if deflateInit is used instead. |
377 | 355 | ||
378 | The memLevel parameter specifies how much memory should be allocated | 356 | The memLevel parameter specifies how much memory should be allocated |
379 | for the internal compression state. memLevel=1 uses minimum memory but | 357 | for the internal compression state. memLevel=1 uses minimum memory but |
380 | is slow and reduces compression ratio; memLevel=9 uses maximum memory | 358 | is slow and reduces compression ratio; memLevel=9 uses maximum memory |
381 | for optimal speed. The default value is 8. See zconf.h for total memory | 359 | for optimal speed. The default value is 8. See zconf.h for total memory |
382 | usage as a function of windowBits and memLevel. | 360 | usage as a function of windowBits and memLevel. |
383 | 361 | ||
384 | The strategy parameter is used to tune the compression algorithm. Use the | 362 | The strategy parameter is used to tune the compression algorithm. Use |
385 | value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a | 363 | the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data |
386 | filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no | 364 | produced by a filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman |
387 | string match). Filtered data consists mostly of small values with a | 365 | encoding only (no string match). Filtered data consists mostly of small |
388 | somewhat random distribution. In this case, the compression algorithm is | 366 | values with a somewhat random distribution. In this case, the |
389 | tuned to compress them better. The effect of Z_FILTERED is to force more | 367 | compression algorithm is tuned to compress them better. The strategy |
390 | Huffman coding and less string matching; it is somewhat intermediate | 368 | parameter only affects the compression ratio but not the correctness of |
391 | between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects | 369 | the compressed output even if it is not set appropriately. |
392 | the compression ratio but not the correctness of the compressed output even | ||
393 | if it is not set appropriately. | ||
394 | 370 | ||
395 | If next_in is not null, the library will use this buffer to hold also | 371 | If next_in is not null, the library will use this buffer to hold also |
396 | some history information; the buffer must either hold the entire input | 372 | some history information; the buffer must either hold the entire input |
@@ -409,38 +385,9 @@ extern int deflateInit2 OF((z_stream *strm, | |||
409 | not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as | 385 | not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as |
410 | an invalid method). msg is set to null if there is no error message. | 386 | an invalid method). msg is set to null if there is no error message. |
411 | deflateInit2 does not perform any compression: this will be done by | 387 | deflateInit2 does not perform any compression: this will be done by |
412 | deflate(). | 388 | deflate(). |
413 | */ | 389 | */ |
414 | 390 | ||
415 | extern int deflateSetDictionary OF((z_stream *strm, | ||
416 | const Bytef *dictionary, | ||
417 | uInt dictLength)); | ||
418 | /* | ||
419 | Initializes the compression dictionary (history buffer) from the given | ||
420 | byte sequence without producing any compressed output. This function must | ||
421 | be called immediately after deflateInit or deflateInit2, before any call | ||
422 | of deflate. The compressor and decompressor must use exactly the same | ||
423 | dictionary (see inflateSetDictionary). | ||
424 | The dictionary should consist of strings (byte sequences) that are likely | ||
425 | to be encountered later in the data to be compressed, with the most commonly | ||
426 | used strings preferably put towards the end of the dictionary. Using a | ||
427 | dictionary is most useful when the data to be compressed is short and | ||
428 | can be predicted with good accuracy; the data can then be compressed better | ||
429 | than with the default empty dictionary. In this version of the library, | ||
430 | only the last 32K bytes of the dictionary are used. | ||
431 | Upon return of this function, strm->adler is set to the Adler32 value | ||
432 | of the dictionary; the decompressor may later use this value to determine | ||
433 | which dictionary has been used by the compressor. (The Adler32 value | ||
434 | applies to the whole dictionary even if only a subset of the dictionary is | ||
435 | actually used by the compressor.) | ||
436 | |||
437 | deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a | ||
438 | parameter is invalid (such as NULL dictionary) or the stream state | ||
439 | is inconsistent (for example if deflate has already been called for this | ||
440 | stream). deflateSetDictionary does not perform any compression: this will | ||
441 | be done by deflate(). | ||
442 | */ | ||
443 | |||
444 | extern int deflateCopy OF((z_stream *dest, | 391 | extern int deflateCopy OF((z_stream *dest, |
445 | z_stream *source)); | 392 | z_stream *source)); |
446 | /* | 393 | /* |
@@ -451,14 +398,14 @@ extern int deflateCopy OF((z_stream *dest, | |||
451 | application to provide the correct values of next_out and avail_out for the | 398 | application to provide the correct values of next_out and avail_out for the |
452 | next call of deflate. | 399 | next call of deflate. |
453 | 400 | ||
454 | This function can be useful when several compression strategies will be | 401 | This function is useful when several compression strategies will be |
455 | tried, for example when there are several ways of pre-processing the input | 402 | tried, for example when there are several ways of pre-processing the input |
456 | data with a filter. The streams that will be discarded should then be freed | 403 | data with a filter. The streams that will be discarded should then be freed |
457 | by calling deflateEnd. Note that deflateCopy duplicates the internal | 404 | by calling deflateEnd. Note that deflateCopy duplicates the internal |
458 | compression state which can be quite large, so this strategy is slow and | 405 | compression state which can be quite large, so this strategy is slow and |
459 | can consume lots of memory. | 406 | can consume lots of memory. |
460 | 407 | ||
461 | deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not | 408 | deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not |
462 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent | 409 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent |
463 | (such as zalloc being NULL). msg is left unchanged in both source and | 410 | (such as zalloc being NULL). msg is left unchanged in both source and |
464 | destination. | 411 | destination. |
@@ -488,10 +435,9 @@ extern int deflateParams OF((z_stream *strm, int level, int strategy)); | |||
488 | stream state was inconsistent or if a parameter was invalid. | 435 | stream state was inconsistent or if a parameter was invalid. |
489 | */ | 436 | */ |
490 | 437 | ||
491 | /* | ||
492 | extern int inflateInit2 OF((z_stream *strm, | 438 | extern int inflateInit2 OF((z_stream *strm, |
493 | int windowBits)); | 439 | int windowBits)); |
494 | 440 | /* | |
495 | This is another version of inflateInit with more compression options. The | 441 | This is another version of inflateInit with more compression options. The |
496 | fields next_out, zalloc, zfree and opaque must be initialized before by | 442 | fields next_out, zalloc, zfree and opaque must be initialized before by |
497 | the caller. | 443 | the caller. |
@@ -523,25 +469,6 @@ extern int inflateInit2 OF((z_stream *strm, | |||
523 | inflate(). | 469 | inflate(). |
524 | */ | 470 | */ |
525 | 471 | ||
526 | extern int inflateSetDictionary OF((z_stream *strm, | ||
527 | const Bytef *dictionary, | ||
528 | uInt dictLength)); | ||
529 | /* | ||
530 | Initializes the decompression dictionary (history buffer) from the given | ||
531 | uncompressed byte sequence. This function must be called immediately after | ||
532 | a call of inflate if this call returned Z_NEED_DICT. The dictionary chosen | ||
533 | by the compressor can be determined from the Adler32 value returned by this | ||
534 | call of inflate. The compressor and decompressor must use exactly the same | ||
535 | dictionary (see deflateSetDictionary). | ||
536 | |||
537 | inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a | ||
538 | parameter is invalid (such as NULL dictionary) or the stream state is | ||
539 | inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the | ||
540 | expected one (incorrect Adler32 value). inflateSetDictionary does not | ||
541 | perform any decompression: this will be done by subsequent calls of | ||
542 | inflate(). | ||
543 | */ | ||
544 | |||
545 | extern int inflateSync OF((z_stream *strm)); | 472 | extern int inflateSync OF((z_stream *strm)); |
546 | /* | 473 | /* |
547 | Skips invalid compressed data until the special marker (see deflate() | 474 | Skips invalid compressed data until the special marker (see deflate() |
@@ -579,7 +506,7 @@ extern int inflateReset OF((z_stream *strm)); | |||
579 | */ | 506 | */ |
580 | 507 | ||
581 | extern int compress OF((Bytef *dest, uLongf *destLen, | 508 | extern int compress OF((Bytef *dest, uLongf *destLen, |
582 | const Bytef *source, uLong sourceLen)); | 509 | Bytef *source, uLong sourceLen)); |
583 | /* | 510 | /* |
584 | Compresses the source buffer into the destination buffer. sourceLen is | 511 | Compresses the source buffer into the destination buffer. sourceLen is |
585 | the byte length of the source buffer. Upon entry, destLen is the total | 512 | the byte length of the source buffer. Upon entry, destLen is the total |
@@ -594,7 +521,7 @@ extern int compress OF((Bytef *dest, uLongf *destLen, | |||
594 | */ | 521 | */ |
595 | 522 | ||
596 | extern int uncompress OF((Bytef *dest, uLongf *destLen, | 523 | extern int uncompress OF((Bytef *dest, uLongf *destLen, |
597 | const Bytef *source, uLong sourceLen)); | 524 | Bytef *source, uLong sourceLen)); |
598 | /* | 525 | /* |
599 | Decompresses the source buffer into the destination buffer. sourceLen is | 526 | Decompresses the source buffer into the destination buffer. sourceLen is |
600 | the byte length of the source buffer. Upon entry, destLen is the total | 527 | the byte length of the source buffer. Upon entry, destLen is the total |
@@ -614,7 +541,7 @@ extern int uncompress OF((Bytef *dest, uLongf *destLen, | |||
614 | 541 | ||
615 | typedef voidp gzFile; | 542 | typedef voidp gzFile; |
616 | 543 | ||
617 | extern gzFile gzopen OF((const char *path, const char *mode)); | 544 | extern gzFile gzopen OF((char *path, char *mode)); |
618 | /* | 545 | /* |
619 | Opens a gzip (.gz) file for reading or writing. The mode parameter | 546 | Opens a gzip (.gz) file for reading or writing. The mode parameter |
620 | is as in fopen ("rb" or "wb") but can also include a compression level | 547 | is as in fopen ("rb" or "wb") but can also include a compression level |
@@ -626,15 +553,12 @@ extern gzFile gzopen OF((const char *path, const char *mode)); | |||
626 | zlib error is Z_MEM_ERROR). | 553 | zlib error is Z_MEM_ERROR). |
627 | */ | 554 | */ |
628 | 555 | ||
629 | extern gzFile gzdopen OF((int fd, const char *mode)); | 556 | extern gzFile gzdopen OF((int fd, char *mode)); |
630 | /* | 557 | /* |
631 | gzdopen() associates a gzFile with the file descriptor fd. File | 558 | gzdopen() associates a gzFile with the file descriptor fd. File |
632 | descriptors are obtained from calls like open, dup, creat, pipe or | 559 | descriptors are obtained from calls like open, dup, creat, pipe or |
633 | fileno (in the file has been previously opened with fopen). | 560 | fileno (in the file has been previously opened with fopen). |
634 | The mode parameter is as in fopen ("rb" or "wb"). | 561 | The mode parameter is as in fopen ("rb" or "wb"). |
635 | The next call of gzclose on the returned gzFile will also close the | ||
636 | file descriptor fd, just like fclose(fdopen(fd), mode) closes the file | ||
637 | descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). | ||
638 | gzdopen returns NULL if there was insufficient memory to allocate | 562 | gzdopen returns NULL if there was insufficient memory to allocate |
639 | the (de)compression state. | 563 | the (de)compression state. |
640 | */ | 564 | */ |
@@ -647,7 +571,7 @@ extern int gzread OF((gzFile file, voidp buf, unsigned len)); | |||
647 | gzread returns the number of uncompressed bytes actually read (0 for | 571 | gzread returns the number of uncompressed bytes actually read (0 for |
648 | end of file, -1 for error). */ | 572 | end of file, -1 for error). */ |
649 | 573 | ||
650 | extern int gzwrite OF((gzFile file, const voidp buf, unsigned len)); | 574 | extern int gzwrite OF((gzFile file, voidp buf, unsigned len)); |
651 | /* | 575 | /* |
652 | Writes the given number of uncompressed bytes into the compressed file. | 576 | Writes the given number of uncompressed bytes into the compressed file. |
653 | gzwrite returns the number of uncompressed bytes actually written | 577 | gzwrite returns the number of uncompressed bytes actually written |
@@ -688,7 +612,7 @@ extern char* gzerror OF((gzFile file, int *errnum)); | |||
688 | compression library. | 612 | compression library. |
689 | */ | 613 | */ |
690 | 614 | ||
691 | extern uLong adler32 OF((uLong adler, const Bytef *buf, uInt len)); | 615 | extern uLong adler32 OF((uLong adler, Bytef *buf, uInt len)); |
692 | 616 | ||
693 | /* | 617 | /* |
694 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and | 618 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and |
@@ -705,7 +629,7 @@ extern uLong adler32 OF((uLong adler, const Bytef *buf, uInt len)); | |||
705 | if (adler != original_adler) error(); | 629 | if (adler != original_adler) error(); |
706 | */ | 630 | */ |
707 | 631 | ||
708 | extern uLong crc32 OF((uLong crc, const Bytef *buf, uInt len)); | 632 | extern uLong crc32 OF((uLong crc, Bytef *buf, uInt len)); |
709 | /* | 633 | /* |
710 | Update a running crc with the bytes buf[0..len-1] and return the updated | 634 | Update a running crc with the bytes buf[0..len-1] and return the updated |
711 | crc. If buf is NULL, this function returns the required initial value | 635 | crc. If buf is NULL, this function returns the required initial value |
@@ -721,37 +645,10 @@ extern uLong crc32 OF((uLong crc, const Bytef *buf, uInt len)); | |||
721 | if (crc != original_crc) error(); | 645 | if (crc != original_crc) error(); |
722 | */ | 646 | */ |
723 | 647 | ||
724 | |||
725 | /* various hacks, don't look :) */ | ||
726 | |||
727 | /* deflateInit and inflateInit are macros to allow checking the zlib version | ||
728 | * and the compiler's view of z_stream: | ||
729 | */ | ||
730 | extern int deflateInit_ OF((z_stream *strm, int level, | ||
731 | const char *version, int stream_size)); | ||
732 | extern int inflateInit_ OF((z_stream *strm, | ||
733 | const char *version, int stream_size)); | ||
734 | extern int deflateInit2_ OF((z_stream *strm, int level, int method, | ||
735 | int windowBits, int memLevel, int strategy, | ||
736 | const char *version, int stream_size)); | ||
737 | extern int inflateInit2_ OF((z_stream *strm, int windowBits, | ||
738 | const char *version, int stream_size)); | ||
739 | #define deflateInit(strm, level) \ | ||
740 | deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) | ||
741 | #define inflateInit(strm) \ | ||
742 | inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) | ||
743 | #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ | ||
744 | deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ | ||
745 | (strategy), ZLIB_VERSION, sizeof(z_stream)) | ||
746 | #define inflateInit2(strm, windowBits) \ | ||
747 | inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) | ||
748 | |||
749 | #ifndef _Z_UTIL_H | 648 | #ifndef _Z_UTIL_H |
750 | struct internal_state {int dummy;}; /* hack for buggy compilers */ | 649 | struct internal_state {int dummy;}; /* hack for buggy compilers */ |
751 | #endif | 650 | #endif |
752 | 651 | ||
753 | uLongf *get_crc_table OF((void)); /* can be used by asm versions of crc32() */ | ||
754 | |||
755 | #ifdef __cplusplus | 652 | #ifdef __cplusplus |
756 | } | 653 | } |
757 | #endif | 654 | #endif |