diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:09:18 -0700 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:09:18 -0700 |
| commit | 23c69f10698301ae97709eb0bbfb371d66b99a08 (patch) | |
| tree | 1956b671b3df8d12c315a38f33b190677ccd659e /zlib.h | |
| parent | 6b834a58bdef976383cff6e2a83f353e668a9cf1 (diff) | |
| download | zlib-23c69f10698301ae97709eb0bbfb371d66b99a08.tar.gz zlib-23c69f10698301ae97709eb0bbfb371d66b99a08.tar.bz2 zlib-23c69f10698301ae97709eb0bbfb371d66b99a08.zip | |
zlib 0.94v0.94
Diffstat (limited to '')
| -rw-r--r-- | zlib.h | 102 |
1 files changed, 54 insertions, 48 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 0.93 June 25th, 1995. | 2 | version 0.94, Aug 13th, 1995. |
| 3 | 3 | ||
| 4 | Copyright (C) 1995 Jean-loup Gailly and Mark Adler | 4 | Copyright (C) 1995 Jean-loup Gailly and Mark Adler |
| 5 | 5 | ||
| @@ -28,7 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | #include "zconf.h" | 29 | #include "zconf.h" |
| 30 | 30 | ||
| 31 | #define ZLIB_VERSION "0.93" | 31 | #define ZLIB_VERSION "0.94" |
| 32 | 32 | ||
| 33 | /* | 33 | /* |
| 34 | The 'zlib' compression library provides in-memory compression and | 34 | The 'zlib' compression library provides in-memory compression and |
| @@ -49,22 +49,22 @@ | |||
| 49 | (providing more output space) before each call. | 49 | (providing more output space) before each call. |
| 50 | */ | 50 | */ |
| 51 | 51 | ||
| 52 | typedef voidp (*alloc_func) __P((voidp opaque, uInt items, uInt size)); | 52 | typedef voidp (*alloc_func) OF((voidp opaque, uInt items, uInt size)); |
| 53 | typedef void (*free_func) __P((voidp opaque, voidp address)); | 53 | typedef void (*free_func) OF((voidp opaque, voidp address)); |
| 54 | 54 | ||
| 55 | struct internal_state; | 55 | struct internal_state; |
| 56 | 56 | ||
| 57 | typedef struct z_stream_s { | 57 | typedef struct z_stream_s { |
| 58 | Byte *next_in; /* next input byte */ | 58 | Bytef *next_in; /* next input byte */ |
| 59 | uInt avail_in; /* number of bytes available at next_in */ | 59 | uInt avail_in; /* number of bytes available at next_in */ |
| 60 | uLong total_in; /* total nb of input bytes read so far */ | 60 | uLong total_in; /* total nb of input bytes read so far */ |
| 61 | 61 | ||
| 62 | Byte *next_out; /* next output byte should be put there */ | 62 | Bytef *next_out; /* next output byte should be put there */ |
| 63 | uInt avail_out; /* remaining free space at next_out */ | 63 | uInt avail_out; /* remaining free space at next_out */ |
| 64 | uLong total_out; /* total nb of bytes output so far */ | 64 | uLong total_out; /* total nb of bytes output so far */ |
| 65 | 65 | ||
| 66 | char *msg; /* last error message, NULL if no error */ | 66 | char *msg; /* last error message, NULL if no error */ |
| 67 | struct internal_state *state; /* not visible by applications */ | 67 | struct internal_state FAR *state; /* not visible by applications */ |
| 68 | 68 | ||
| 69 | alloc_func zalloc; /* used to allocate the internal state */ | 69 | alloc_func zalloc; /* used to allocate the internal state */ |
| 70 | free_func zfree; /* used to free the internal state */ | 70 | free_func zfree; /* used to free the internal state */ |
| @@ -145,7 +145,7 @@ extern char *zlib_version; | |||
| 145 | 145 | ||
| 146 | /* basic functions */ | 146 | /* basic functions */ |
| 147 | 147 | ||
| 148 | extern int deflateInit __P((z_stream *strm, int level)); | 148 | extern int deflateInit OF((z_stream *strm, int level)); |
| 149 | /* | 149 | /* |
| 150 | Initializes the internal stream state for compression. The fields | 150 | Initializes the internal stream state for compression. The fields |
| 151 | zalloc, zfree and opaque must be initialized before by the caller. | 151 | zalloc, zfree and opaque must be initialized before by the caller. |
| @@ -164,7 +164,7 @@ extern int deflateInit __P((z_stream *strm, int level)); | |||
| 164 | */ | 164 | */ |
| 165 | 165 | ||
| 166 | 166 | ||
| 167 | extern int deflate __P((z_stream *strm, int flush)); | 167 | extern int deflate OF((z_stream *strm, int flush)); |
| 168 | /* | 168 | /* |
| 169 | Performs one or both of the following actions: | 169 | Performs one or both of the following actions: |
| 170 | 170 | ||
| @@ -195,7 +195,10 @@ extern int deflate __P((z_stream *strm, int flush)); | |||
| 195 | is useful to allow the decompressor to synchronize if one compressed block | 195 | is useful to allow the decompressor to synchronize if one compressed block |
| 196 | has been damaged (see inflateSync below). Flushing degrades compression and | 196 | has been damaged (see inflateSync below). Flushing degrades compression and |
| 197 | so should be used only when necessary. Using Z_FULL_FLUSH too often can | 197 | so should be used only when necessary. Using Z_FULL_FLUSH too often can |
| 198 | seriously degrade the compression. | 198 | seriously degrade the compression. If deflate returns with avail_out == 0, |
| 199 | this function must be called again with the same value of the flush | ||
| 200 | parameter and more output space (updated avail_out), until the flush is | ||
| 201 | complete (deflate returns with non-zero avail_out). | ||
| 199 | 202 | ||
| 200 | If the parameter flush is set to Z_FINISH, all pending input is processed, | 203 | If the parameter flush is set to Z_FINISH, all pending input is processed, |
| 201 | all pending output is flushed and deflate returns with Z_STREAM_END if there | 204 | all pending output is flushed and deflate returns with Z_STREAM_END if there |
| @@ -223,7 +226,7 @@ extern int deflate __P((z_stream *strm, int flush)); | |||
| 223 | */ | 226 | */ |
| 224 | 227 | ||
| 225 | 228 | ||
| 226 | extern int deflateEnd __P((z_stream *strm)); | 229 | extern int deflateEnd OF((z_stream *strm)); |
| 227 | /* | 230 | /* |
| 228 | All dynamically allocated data structures for this stream are freed. | 231 | All dynamically allocated data structures for this stream are freed. |
| 229 | This function discards any unprocessed input and does not flush any | 232 | This function discards any unprocessed input and does not flush any |
| @@ -235,11 +238,11 @@ extern int deflateEnd __P((z_stream *strm)); | |||
| 235 | */ | 238 | */ |
| 236 | 239 | ||
| 237 | 240 | ||
| 238 | extern int inflateInit __P((z_stream *strm)); | 241 | extern int inflateInit OF((z_stream *strm)); |
| 239 | /* | 242 | /* |
| 240 | Initializes the internal stream state for decompression. The fields | 243 | Initializes the internal stream state for decompression. The fields |
| 241 | zalloc and zfree must be initialized before by the caller. If zalloc and | 244 | zalloc and zfree must be initialized before by the caller. If zalloc and |
| 242 | zfree are set to Z_NULL, deflateInit updates them to use default allocation | 245 | zfree are set to Z_NULL, inflateInit updates them to use default allocation |
| 243 | functions. | 246 | functions. |
| 244 | 247 | ||
| 245 | inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not | 248 | inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not |
| @@ -249,7 +252,7 @@ extern int inflateInit __P((z_stream *strm)); | |||
| 249 | */ | 252 | */ |
| 250 | 253 | ||
| 251 | 254 | ||
| 252 | extern int inflate __P((z_stream *strm, int flush)); | 255 | extern int inflate OF((z_stream *strm, int flush)); |
| 253 | /* | 256 | /* |
| 254 | Performs one or both of the following actions: | 257 | Performs one or both of the following actions: |
| 255 | 258 | ||
| @@ -260,7 +263,7 @@ extern int inflate __P((z_stream *strm, int flush)); | |||
| 260 | 263 | ||
| 261 | - Provide more output starting at next_out and update next_out and avail_out | 264 | - Provide more output starting at next_out and update next_out and avail_out |
| 262 | accordingly. inflate() always provides as much output as possible | 265 | accordingly. inflate() always provides as much output as possible |
| 263 | (until no more input data or no more space in the output buffer). | 266 | (until there is no more input data or no more space in the output buffer). |
| 264 | 267 | ||
| 265 | Before the call of inflate(), the application should ensure that at least | 268 | Before the call of inflate(), the application should ensure that at least |
| 266 | one of the actions is possible, by providing more input and/or consuming | 269 | one of the actions is possible, by providing more input and/or consuming |
| @@ -282,7 +285,9 @@ extern int inflate __P((z_stream *strm, int flush)); | |||
| 282 | output is flushed; avail_out must be large enough to hold all the | 285 | output is flushed; avail_out must be large enough to hold all the |
| 283 | uncompressed data. (The size of the uncompressed data may have been saved | 286 | uncompressed data. (The size of the uncompressed data may have been saved |
| 284 | by the compressor for this purpose.) The next operation on this stream must | 287 | by the compressor for this purpose.) The next operation on this stream must |
| 285 | be inflateEnd to deallocate the decompression state. | 288 | be inflateEnd to deallocate the decompression state. The use of Z_FINISH |
| 289 | is never required, but can be used to inform inflate that a faster routine | ||
| 290 | may be used for the single inflate() call. | ||
| 286 | 291 | ||
| 287 | inflate() returns Z_OK if some progress has been made (more input | 292 | inflate() returns Z_OK if some progress has been made (more input |
| 288 | processed or more output produced), Z_STREAM_END if the end of the | 293 | processed or more output produced), Z_STREAM_END if the end of the |
| @@ -296,7 +301,7 @@ extern int inflate __P((z_stream *strm, int flush)); | |||
| 296 | */ | 301 | */ |
| 297 | 302 | ||
| 298 | 303 | ||
| 299 | extern int inflateEnd __P((z_stream *strm)); | 304 | extern int inflateEnd OF((z_stream *strm)); |
| 300 | /* | 305 | /* |
| 301 | All dynamically allocated data structures for this stream are freed. | 306 | All dynamically allocated data structures for this stream are freed. |
| 302 | This function discards any unprocessed input and does not flush any | 307 | This function discards any unprocessed input and does not flush any |
| @@ -313,12 +318,12 @@ extern int inflateEnd __P((z_stream *strm)); | |||
| 313 | The following functions are needed only in some special applications. | 318 | The following functions are needed only in some special applications. |
| 314 | */ | 319 | */ |
| 315 | 320 | ||
| 316 | extern int deflateInit2 __P((z_stream *strm, | 321 | extern int deflateInit2 OF((z_stream *strm, |
| 317 | int level, | 322 | int level, |
| 318 | int method, | 323 | int method, |
| 319 | int windowBits, | 324 | int windowBits, |
| 320 | int memLevel, | 325 | int memLevel, |
| 321 | int strategy)); | 326 | int strategy)); |
| 322 | /* | 327 | /* |
| 323 | This is another version of deflateInit with more compression options. The | 328 | This is another version of deflateInit with more compression options. The |
| 324 | fields next_in, zalloc and zfree must be initialized before by the caller. | 329 | fields next_in, zalloc and zfree must be initialized before by the caller. |
| @@ -368,8 +373,8 @@ extern int deflateInit2 __P((z_stream *strm, | |||
| 368 | deflate(). | 373 | deflate(). |
| 369 | */ | 374 | */ |
| 370 | 375 | ||
| 371 | extern int deflateCopy __P((z_stream *dest, | 376 | extern int deflateCopy OF((z_stream *dest, |
| 372 | z_stream *source)); | 377 | z_stream *source)); |
| 373 | /* | 378 | /* |
| 374 | Sets the destination stream as a complete copy of the source stream. If | 379 | Sets the destination stream as a complete copy of the source stream. If |
| 375 | the source stream is using an application-supplied history buffer, a new | 380 | the source stream is using an application-supplied history buffer, a new |
| @@ -391,7 +396,7 @@ extern int deflateCopy __P((z_stream *dest, | |||
| 391 | destination. | 396 | destination. |
| 392 | */ | 397 | */ |
| 393 | 398 | ||
| 394 | extern int deflateReset __P((z_stream *strm)); | 399 | extern int deflateReset OF((z_stream *strm)); |
| 395 | /* | 400 | /* |
| 396 | This function is equivalent to deflateEnd followed by deflateInit, | 401 | This function is equivalent to deflateEnd followed by deflateInit, |
| 397 | but does not free and reallocate all the internal compression state. | 402 | but does not free and reallocate all the internal compression state. |
| @@ -402,8 +407,8 @@ extern int deflateReset __P((z_stream *strm)); | |||
| 402 | stream state was inconsistent (such as zalloc or state being NULL). | 407 | stream state was inconsistent (such as zalloc or state being NULL). |
| 403 | */ | 408 | */ |
| 404 | 409 | ||
| 405 | extern int inflateInit2 __P((z_stream *strm, | 410 | extern int inflateInit2 OF((z_stream *strm, |
| 406 | int windowBits)); | 411 | int windowBits)); |
| 407 | /* | 412 | /* |
| 408 | This is another version of inflateInit with more compression options. The | 413 | This is another version of inflateInit with more compression options. The |
| 409 | fields next_out, zalloc and zfree must be initialized before by the caller. | 414 | fields next_out, zalloc and zfree must be initialized before by the caller. |
| @@ -431,11 +436,11 @@ extern int inflateInit2 __P((z_stream *strm, | |||
| 431 | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was | 436 | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was |
| 432 | not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as | 437 | not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as |
| 433 | windowBits < 8). msg is set to null if there is no error message. | 438 | windowBits < 8). msg is set to null if there is no error message. |
| 434 | inflateInit2 does not perform any compression: this will be done by | 439 | inflateInit2 does not perform any decompression: this will be done by |
| 435 | inflate(). | 440 | inflate(). |
| 436 | */ | 441 | */ |
| 437 | 442 | ||
| 438 | extern int inflateSync __P((z_stream *strm)); | 443 | extern int inflateSync OF((z_stream *strm)); |
| 439 | /* | 444 | /* |
| 440 | Skips invalid compressed data until the special marker (see deflate() | 445 | Skips invalid compressed data until the special marker (see deflate() |
| 441 | above) can be found, or until all available input is skipped. No output | 446 | above) can be found, or until all available input is skipped. No output |
| @@ -450,7 +455,7 @@ extern int inflateSync __P((z_stream *strm)); | |||
| 450 | until success or end of the input data. | 455 | until success or end of the input data. |
| 451 | */ | 456 | */ |
| 452 | 457 | ||
| 453 | extern int inflateReset __P((z_stream *strm)); | 458 | extern int inflateReset OF((z_stream *strm)); |
| 454 | /* | 459 | /* |
| 455 | This function is equivalent to inflateEnd followed by inflateInit, | 460 | This function is equivalent to inflateEnd followed by inflateInit, |
| 456 | but does not free and reallocate all the internal decompression state. | 461 | but does not free and reallocate all the internal decompression state. |
| @@ -471,8 +476,8 @@ extern int inflateReset __P((z_stream *strm)); | |||
| 471 | utility functions can easily be modified if you need special options. | 476 | utility functions can easily be modified if you need special options. |
| 472 | */ | 477 | */ |
| 473 | 478 | ||
| 474 | extern int compress __P((Byte *dest, uLong *destLen, | 479 | extern int compress OF((Bytef *dest, uLongf *destLen, |
| 475 | Byte *source, uLong sourceLen)); | 480 | Bytef *source, uLong sourceLen)); |
| 476 | /* | 481 | /* |
| 477 | Compresses the source buffer into the destination buffer. sourceLen is | 482 | Compresses the source buffer into the destination buffer. sourceLen is |
| 478 | the byte length of the source buffer. Upon entry, destLen is the total | 483 | the byte length of the source buffer. Upon entry, destLen is the total |
| @@ -486,8 +491,8 @@ extern int compress __P((Byte *dest, uLong *destLen, | |||
| 486 | buffer. | 491 | buffer. |
| 487 | */ | 492 | */ |
| 488 | 493 | ||
| 489 | extern int uncompress __P((Byte *dest, uLong *destLen, | 494 | extern int uncompress OF((Bytef *dest, uLongf *destLen, |
| 490 | Byte *source, uLong sourceLen)); | 495 | Bytef *source, uLong sourceLen)); |
| 491 | /* | 496 | /* |
| 492 | Decompresses the source buffer into the destination buffer. sourceLen is | 497 | Decompresses the source buffer into the destination buffer. sourceLen is |
| 493 | the byte length of the source buffer. Upon entry, destLen is the total | 498 | the byte length of the source buffer. Upon entry, destLen is the total |
| @@ -505,21 +510,21 @@ extern int uncompress __P((Byte *dest, uLong *destLen, | |||
| 505 | */ | 510 | */ |
| 506 | 511 | ||
| 507 | 512 | ||
| 508 | typedef voidp gzFile; | 513 | typedef voidnp gzFile; |
| 509 | 514 | ||
| 510 | extern gzFile gzopen __P((char *path, char *mode)); | 515 | extern gzFile gzopen OF((char *path, char *mode)); |
| 511 | /* | 516 | /* |
| 512 | Opens a gzip (.gz) file for reading or writing. The mode parameter | 517 | Opens a gzip (.gz) file for reading or writing. The mode parameter |
| 513 | is as in fopen ("rb" or "wb"). gzopen can also be used to read a file | 518 | is as in fopen ("rb" or "wb") but can also include a compression level |
| 514 | which is not in gzip format; in this case gzread will directly read from | 519 | ("wb9"). gzopen can be used to read a file which is not in gzip format; |
| 515 | the file without decompression. | 520 | in this case gzread will directly read from the file without decompression. |
| 516 | gzopen returns NULL if the file could not be opened or if there was | 521 | gzopen returns NULL if the file could not be opened or if there was |
| 517 | insufficient memory to allocate the (de)compression state; errno | 522 | insufficient memory to allocate the (de)compression state; errno |
| 518 | can be checked to distinguish the two cases (if errno is zero, the | 523 | can be checked to distinguish the two cases (if errno is zero, the |
| 519 | zlib error is Z_MEM_ERROR). | 524 | zlib error is Z_MEM_ERROR). |
| 520 | */ | 525 | */ |
| 521 | 526 | ||
| 522 | extern gzFile gzdopen __P((int fd, char *mode)); | 527 | extern gzFile gzdopen OF((int fd, char *mode)); |
| 523 | /* | 528 | /* |
| 524 | gzdopen() associates a gzFile with the file descriptor fd. File | 529 | gzdopen() associates a gzFile with the file descriptor fd. File |
| 525 | descriptors are obtained from calls like open, dup, creat, or pipe. | 530 | descriptors are obtained from calls like open, dup, creat, or pipe. |
| @@ -528,7 +533,7 @@ extern gzFile gzdopen __P((int fd, char *mode)); | |||
| 528 | the (de)compression state. | 533 | the (de)compression state. |
| 529 | */ | 534 | */ |
| 530 | 535 | ||
| 531 | extern int gzread __P((gzFile file, voidp buf, unsigned len)); | 536 | extern int gzread OF((gzFile file, voidnp buf, unsigned len)); |
| 532 | /* | 537 | /* |
| 533 | Reads the given number of uncompressed bytes from the compressed file. | 538 | Reads the given number of uncompressed bytes from the compressed file. |
| 534 | If the input file was not in gzip format, gzread copies the given number | 539 | If the input file was not in gzip format, gzread copies the given number |
| @@ -536,14 +541,14 @@ extern int gzread __P((gzFile file, voidp buf, unsigned len)); | |||
| 536 | gzread returns the number of uncompressed bytes actually read (0 for | 541 | gzread returns the number of uncompressed bytes actually read (0 for |
| 537 | end of file, -1 for error). */ | 542 | end of file, -1 for error). */ |
| 538 | 543 | ||
| 539 | extern int gzwrite __P((gzFile file, voidp buf, unsigned len)); | 544 | extern int gzwrite OF((gzFile file, voidnp buf, unsigned len)); |
| 540 | /* | 545 | /* |
| 541 | Writes the given number of uncompressed bytes into the compressed file. | 546 | Writes the given number of uncompressed bytes into the compressed file. |
| 542 | gzwrite returns the number of uncompressed bytes actually written | 547 | gzwrite returns the number of uncompressed bytes actually written |
| 543 | (0 in case of error). | 548 | (0 in case of error). |
| 544 | */ | 549 | */ |
| 545 | 550 | ||
| 546 | extern int gzflush __P((gzFile file, int flush)); | 551 | extern int gzflush OF((gzFile file, int flush)); |
| 547 | /* | 552 | /* |
| 548 | Flushes all pending output into the compressed file. The parameter | 553 | Flushes all pending output into the compressed file. The parameter |
| 549 | flush is as in the deflate() function. The return value is the zlib | 554 | flush is as in the deflate() function. The return value is the zlib |
| @@ -553,14 +558,14 @@ extern int gzflush __P((gzFile file, int flush)); | |||
| 553 | degrade compression. | 558 | degrade compression. |
| 554 | */ | 559 | */ |
| 555 | 560 | ||
| 556 | extern int gzclose __P((gzFile file)); | 561 | extern int gzclose OF((gzFile file)); |
| 557 | /* | 562 | /* |
| 558 | Flushes all pending output if necessary, closes the compressed file | 563 | Flushes all pending output if necessary, closes the compressed file |
| 559 | and deallocates all the (de)compression state. The return value is the zlib | 564 | and deallocates all the (de)compression state. The return value is the zlib |
| 560 | error number (see function gzerror below). | 565 | error number (see function gzerror below). |
| 561 | */ | 566 | */ |
| 562 | 567 | ||
| 563 | extern char* gzerror __P((gzFile file, int *errnum)); | 568 | extern char* gzerror OF((gzFile file, int *errnum)); |
| 564 | /* | 569 | /* |
| 565 | Returns the error message for the last error which occurred on the | 570 | Returns the error message for the last error which occurred on the |
| 566 | given compressed file. errnum is set to zlib error number. If an | 571 | given compressed file. errnum is set to zlib error number. If an |
| @@ -577,7 +582,8 @@ extern char* gzerror __P((gzFile file, int *errnum)); | |||
| 577 | compression library. | 582 | compression library. |
| 578 | */ | 583 | */ |
| 579 | 584 | ||
| 580 | extern uLong adler32 __P((uLong adler, Byte *buf, uInt len)); | 585 | extern uLong adler32 OF((uLong adler, Bytef *buf, uInt len)); |
| 586 | |||
| 581 | /* | 587 | /* |
| 582 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and | 588 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and |
| 583 | return the updated checksum. If buf is NULL, this function returns | 589 | return the updated checksum. If buf is NULL, this function returns |
| @@ -593,7 +599,7 @@ extern uLong adler32 __P((uLong adler, Byte *buf, uInt len)); | |||
| 593 | if (adler != original_adler) error(); | 599 | if (adler != original_adler) error(); |
| 594 | */ | 600 | */ |
| 595 | 601 | ||
| 596 | extern uLong crc32 __P((uLong crc, Byte *buf, uInt len)); | 602 | extern uLong crc32 OF((uLong crc, Bytef *buf, uInt len)); |
| 597 | /* | 603 | /* |
| 598 | Update a running crc with the bytes buf[0..len-1] and return the updated | 604 | Update a running crc with the bytes buf[0..len-1] and return the updated |
| 599 | crc. If buf is NULL, this function returns the required initial value | 605 | crc. If buf is NULL, this function returns the required initial value |
