summaryrefslogtreecommitdiff
path: root/zlib.h
diff options
context:
space:
mode:
Diffstat (limited to 'zlib.h')
-rw-r--r--zlib.h259
1 files changed, 198 insertions, 61 deletions
diff --git a/zlib.h b/zlib.h
index 73185ec..7fc868b 100644
--- a/zlib.h
+++ b/zlib.h
@@ -1,7 +1,7 @@
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.95, Aug 16th, 1995. 2 version 1.0, Jan 27th, 1996.
3 3
4 Copyright (C) 1995 Jean-loup Gailly and Mark Adler 4 Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler
5 5
6 This software is provided 'as-is', without any express or implied 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 7 warranty. In no event will the authors be held liable for any damages
@@ -26,9 +26,13 @@
26#ifndef _ZLIB_H 26#ifndef _ZLIB_H
27#define _ZLIB_H 27#define _ZLIB_H
28 28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
29#include "zconf.h" 33#include "zconf.h"
30 34
31#define ZLIB_VERSION "0.95" 35#define ZLIB_VERSION "1.0"
32 36
33/* 37/*
34 The 'zlib' compression library provides in-memory compression and 38 The 'zlib' compression library provides in-memory compression and
@@ -47,6 +51,11 @@
47 repeated calls of the compression function. In the latter case, the 51 repeated calls of the compression function. In the latter case, the
48 application must provide more input and/or consume the output 52 application must provide more input and/or consume the output
49 (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.
50*/ 59*/
51 60
52typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); 61typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
@@ -68,10 +77,11 @@ typedef struct z_stream_s {
68 77
69 alloc_func zalloc; /* used to allocate the internal state */ 78 alloc_func zalloc; /* used to allocate the internal state */
70 free_func zfree; /* used to free the internal state */ 79 free_func zfree; /* used to free the internal state */
71 voidp opaque; /* private data object passed to zalloc and zfree */ 80 voidpf opaque; /* private data object passed to zalloc and zfree */
72
73 Byte data_type; /* best guess about the data type: ascii or binary */
74 81
82 int data_type; /* best guess about the data type: ascii or binary */
83 uLong adler; /* adler32 value of the uncompressed data */
84 uLong reserved; /* reserved for future use */
75} z_stream; 85} z_stream;
76 86
77/* 87/*
@@ -107,20 +117,25 @@ typedef struct z_stream_s {
107 117
108#define Z_NO_FLUSH 0 118#define Z_NO_FLUSH 0
109#define Z_PARTIAL_FLUSH 1 119#define Z_PARTIAL_FLUSH 1
110#define Z_FULL_FLUSH 2 120#define Z_SYNC_FLUSH 2
111#define Z_SYNC_FLUSH 3 /* experimental: partial_flush + byte align */ 121#define Z_FULL_FLUSH 3
112#define Z_FINISH 4 122#define Z_FINISH 4
113/* See deflate() below for the usage of these constants */ 123/* Allowed flush values; see deflate() below for details */
114 124
115#define Z_OK 0 125#define Z_OK 0
116#define Z_STREAM_END 1 126#define Z_STREAM_END 1
127#define Z_NEED_DICT 2
117#define Z_ERRNO (-1) 128#define Z_ERRNO (-1)
118#define Z_STREAM_ERROR (-2) 129#define Z_STREAM_ERROR (-2)
119#define Z_DATA_ERROR (-3) 130#define Z_DATA_ERROR (-3)
120#define Z_MEM_ERROR (-4) 131#define Z_MEM_ERROR (-4)
121#define Z_BUF_ERROR (-5) 132#define Z_BUF_ERROR (-5)
122/* error codes for the compression/decompression functions */ 133#define Z_VERSION_ERROR (-6)
134/* Return codes for the compression/decompression functions. Negative
135 * values are errors, positive values are used for special but normal events.
136 */
123 137
138#define Z_NO_COMPRESSION 0
124#define Z_BEST_SPEED 1 139#define Z_BEST_SPEED 1
125#define Z_BEST_COMPRESSION 9 140#define Z_BEST_COMPRESSION 9
126#define Z_DEFAULT_COMPRESSION (-1) 141#define Z_DEFAULT_COMPRESSION (-1)
@@ -129,15 +144,19 @@ typedef struct z_stream_s {
129#define Z_FILTERED 1 144#define Z_FILTERED 1
130#define Z_HUFFMAN_ONLY 2 145#define Z_HUFFMAN_ONLY 2
131#define Z_DEFAULT_STRATEGY 0 146#define Z_DEFAULT_STRATEGY 0
147/* compression strategy; see deflateInit2() below for details */
132 148
133#define Z_BINARY 0 149#define Z_BINARY 0
134#define Z_ASCII 1 150#define Z_ASCII 1
135#define Z_UNKNOWN 2 151#define Z_UNKNOWN 2
136/* Used to set the data_type field */ 152/* Possible values of the data_type field */
153
154#define Z_DEFLATED 8
155/* The deflate compression method (the only one supported in this version) */
137 156
138#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ 157#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
139 158
140extern char *zlib_version; 159extern const char *zlib_version;
141/* The application can compare zlib_version and ZLIB_VERSION for consistency. 160/* The application can compare zlib_version and ZLIB_VERSION for consistency.
142 If the first character differs, the library code actually used is 161 If the first character differs, the library code actually used is
143 not compatible with the zlib.h header file used by the application. 162 not compatible with the zlib.h header file used by the application.
@@ -145,20 +164,24 @@ extern char *zlib_version;
145 164
146 /* basic functions */ 165 /* basic functions */
147 166
148extern int deflateInit OF((z_stream *strm, int level));
149/* 167/*
168extern int deflateInit OF((z_stream *strm, int level));
169
150 Initializes the internal stream state for compression. The fields 170 Initializes the internal stream state for compression. The fields
151 zalloc, zfree and opaque must be initialized before by the caller. 171 zalloc, zfree and opaque must be initialized before by the caller.
152 If zalloc and zfree are set to Z_NULL, deflateInit updates them to 172 If zalloc and zfree are set to Z_NULL, deflateInit updates them to
153 use default allocation functions. 173 use default allocation functions.
154 174
155 The compression level must be Z_DEFAULT_COMPRESSION, or between 1 and 9: 175 The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
156 1 gives best speed, 9 gives best compression. Z_DEFAULT_COMPRESSION requests 176 1 gives best speed, 9 gives best compression, 0 gives no compression at
157 a default compromise between speed and compression (currently equivalent 177 all (the input data is simply copied a block at a time).
158 to level 6). 178 Z_DEFAULT_COMPRESSION requests a default compromise between speed and
179 compression (currently equivalent to level 6).
159 180
160 deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not 181 deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
161 enough memory, Z_STREAM_ERROR if level is not a valid compression level. 182 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).
162 msg is set to null if there is no error message. deflateInit does not 185 msg is set to null if there is no error message. deflateInit does not
163 perform any compression: this will be done by deflate(). 186 perform any compression: this will be done by deflate().
164*/ 187*/
@@ -190,7 +213,12 @@ extern int deflate OF((z_stream *strm, int flush));
190 block is terminated and flushed to the output buffer so that the 213 block is terminated and flushed to the output buffer so that the
191 decompressor can get all input data available so far. For method 9, a future 214 decompressor can get all input data available so far. For method 9, a future
192 variant on method 8, the current block will be flushed but not terminated. 215 variant on method 8, the current block will be flushed but not terminated.
193 If flush is set to Z_FULL_FLUSH, the compression block is terminated, a 216 Z_SYNC_FLUSH has the same effect as partial flush except that the compressed
217 output is byte aligned (the compressor can clear its internal bit buffer)
218 and the current block is always terminated; this can be useful if the
219 compressor has to be restarted from scratch after an interruption (in which
220 case the internal state of the compressor may be lost).
221 If flush is set to Z_FULL_FLUSH, the compression block is terminated, a
194 special marker is output and the compression dictionary is discarded; this 222 special marker is output and the compression dictionary is discarded; this
195 is useful to allow the decompressor to synchronize if one compressed block 223 is useful to allow the decompressor to synchronize if one compressed block
196 has been damaged (see inflateSync below). Flushing degrades compression and 224 has been damaged (see inflateSync below). Flushing degrades compression and
@@ -233,22 +261,26 @@ extern int deflateEnd OF((z_stream *strm));
233 pending output. 261 pending output.
234 262
235 deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the 263 deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
236 stream state was inconsistent. In the error case, msg may be set 264 stream state was inconsistent, Z_DATA_ERROR if the stream was freed
237 but then points to a static string (which must not be deallocated). 265 prematurely (some input or output was discarded). In the error case,
266 msg may be set but then points to a static string (which must not be
267 deallocated).
238*/ 268*/
239 269
240 270
241extern int inflateInit OF((z_stream *strm));
242/* 271/*
272extern int inflateInit OF((z_stream *strm));
273
243 Initializes the internal stream state for decompression. The fields 274 Initializes the internal stream state for decompression. The fields
244 zalloc and zfree must be initialized before by the caller. If zalloc and 275 zalloc, zfree and opaque must be initialized before by the caller. If
245 zfree are set to Z_NULL, inflateInit updates them to use default allocation 276 zalloc and zfree are set to Z_NULL, inflateInit updates them to use default
246 functions. 277 allocation functions.
247 278
248 inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not 279 inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
249 enough memory. msg is set to null if there is no error message. 280 enough memory, Z_VERSION_ERROR if the zlib library version is incompatible
250 inflateInit does not perform any decompression: this will be done by 281 with the version assumed by the caller. msg is set to null if there is no
251 inflate(). 282 error message. inflateInit does not perform any decompression: this will be
283 done by inflate().
252*/ 284*/
253 285
254 286
@@ -292,12 +324,15 @@ extern int inflate OF((z_stream *strm, int flush));
292 inflate() returns Z_OK if some progress has been made (more input 324 inflate() returns Z_OK if some progress has been made (more input
293 processed or more output produced), Z_STREAM_END if the end of the 325 processed or more output produced), Z_STREAM_END if the end of the
294 compressed data has been reached and all uncompressed output has been 326 compressed data has been reached and all uncompressed output has been
295 produced, Z_DATA_ERROR if the input data was corrupted, Z_STREAM_ERROR if 327 produced, Z_NEED_DICT if a preset dictionary is needed at this point (see
296 the stream structure was inconsistent (for example if next_in or next_out 328 inflateSetDictionary below), Z_DATA_ERROR if the input data was corrupted,
297 was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no 329 Z_STREAM_ERROR if the stream structure was inconsistent (for example if
298 progress is possible or if there was not enough room in the output buffer 330 next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
299 when Z_FINISH is used. In the Z_DATA_ERROR case, the application may then 331 Z_BUF_ERROR if no progress is possible or if there was not enough room in
300 call inflateSync to look for a good compression block. 332 the output buffer when Z_FINISH is used. In the Z_DATA_ERROR case, the
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.
301*/ 336*/
302 337
303 338
@@ -312,24 +347,26 @@ extern int inflateEnd OF((z_stream *strm));
312 static string (which must not be deallocated). 347 static string (which must not be deallocated).
313*/ 348*/
314 349
315 /* advanced functions */ 350 /* Advanced functions */
316 351
317/* 352/*
318 The following functions are needed only in some special applications. 353 The following functions are needed only in some special applications.
319*/ 354*/
320 355
356/*
321extern int deflateInit2 OF((z_stream *strm, 357extern int deflateInit2 OF((z_stream *strm,
322 int level, 358 int level,
323 int method, 359 int method,
324 int windowBits, 360 int windowBits,
325 int memLevel, 361 int memLevel,
326 int strategy)); 362 int strategy));
327/* 363
328 This is another version of deflateInit with more compression options. The 364 This is another version of deflateInit with more compression options. The
329 fields next_in, zalloc and zfree must be initialized before by the caller. 365 fields next_in, zalloc, zfree and opaque must be initialized before by
366 the caller.
330 367
331 The method parameter is the compression method. It must be 8 in this 368 The method parameter is the compression method. It must be Z_DEFLATED in
332 version of the library. (Method 9 will allow a 64K history buffer and 369 this version of the library. (Method 9 will allow a 64K history buffer and
333 partial block flushes.) 370 partial block flushes.)
334 371
335 The windowBits parameter is the base two logarithm of the window size 372 The windowBits parameter is the base two logarithm of the window size
@@ -338,20 +375,22 @@ extern int deflateInit2 OF((z_stream *strm,
338 values of this parameter result in better compression at the expense of 375 values of this parameter result in better compression at the expense of
339 memory usage. The default value is 15 if deflateInit is used instead. 376 memory usage. The default value is 15 if deflateInit is used instead.
340 377
341 The memLevel parameter specifies how much memory should be allocated 378 The memLevel parameter specifies how much memory should be allocated
342 for the internal compression state. memLevel=1 uses minimum memory but 379 for the internal compression state. memLevel=1 uses minimum memory but
343 is slow and reduces compression ratio; memLevel=9 uses maximum memory 380 is slow and reduces compression ratio; memLevel=9 uses maximum memory
344 for optimal speed. The default value is 8. See zconf.h for total memory 381 for optimal speed. The default value is 8. See zconf.h for total memory
345 usage as a function of windowBits and memLevel. 382 usage as a function of windowBits and memLevel.
346 383
347 The strategy parameter is used to tune the compression algorithm. Use 384 The strategy parameter is used to tune the compression algorithm. Use the
348 the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data 385 value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
349 produced by a filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman 386 filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
350 encoding only (no string match). Filtered data consists mostly of small 387 string match). Filtered data consists mostly of small values with a
351 values with a somewhat random distribution. In this case, the 388 somewhat random distribution. In this case, the compression algorithm is
352 compression algorithm is tuned to compress them better. The strategy 389 tuned to compress them better. The effect of Z_FILTERED is to force more
353 parameter only affects the compression ratio but not the correctness of 390 Huffman coding and less string matching; it is somewhat intermediate
354 the compressed output even if it is not set appropriately. 391 between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
392 the compression ratio but not the correctness of the compressed output even
393 if it is not set appropriately.
355 394
356 If next_in is not null, the library will use this buffer to hold also 395 If next_in is not null, the library will use this buffer to hold also
357 some history information; the buffer must either hold the entire input 396 some history information; the buffer must either hold the entire input
@@ -370,9 +409,38 @@ extern int deflateInit2 OF((z_stream *strm,
370 not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as 409 not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
371 an invalid method). msg is set to null if there is no error message. 410 an invalid method). msg is set to null if there is no error message.
372 deflateInit2 does not perform any compression: this will be done by 411 deflateInit2 does not perform any compression: this will be done by
373 deflate(). 412 deflate().
374*/ 413*/
375 414
415extern 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
376extern int deflateCopy OF((z_stream *dest, 444extern int deflateCopy OF((z_stream *dest,
377 z_stream *source)); 445 z_stream *source));
378/* 446/*
@@ -383,14 +451,14 @@ extern int deflateCopy OF((z_stream *dest,
383 application to provide the correct values of next_out and avail_out for the 451 application to provide the correct values of next_out and avail_out for the
384 next call of deflate. 452 next call of deflate.
385 453
386 This function is useful when several compression strategies will be 454 This function can be useful when several compression strategies will be
387 tried, for example when there are several ways of pre-processing the input 455 tried, for example when there are several ways of pre-processing the input
388 data with a filter. The streams that will be discarded should then be freed 456 data with a filter. The streams that will be discarded should then be freed
389 by calling deflateEnd. Note that deflateCopy duplicates the internal 457 by calling deflateEnd. Note that deflateCopy duplicates the internal
390 compression state which can be quite large, so this strategy is slow and 458 compression state which can be quite large, so this strategy is slow and
391 can consume lots of memory. 459 can consume lots of memory.
392 460
393 deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not 461 deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
394 enough memory, Z_STREAM_ERROR if the source stream state was inconsistent 462 enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
395 (such as zalloc being NULL). msg is left unchanged in both source and 463 (such as zalloc being NULL). msg is left unchanged in both source and
396 destination. 464 destination.
@@ -407,11 +475,26 @@ extern int deflateReset OF((z_stream *strm));
407 stream state was inconsistent (such as zalloc or state being NULL). 475 stream state was inconsistent (such as zalloc or state being NULL).
408*/ 476*/
409 477
478extern int deflateParams OF((z_stream *strm, int level, int strategy));
479/*
480 Dynamically update the compression level and compression strategy.
481 This can be used to switch between compression and straight copy of
482 the input data, or to switch to a different kind of input data requiring
483 a different strategy. If the compression level is changed, the input
484 available so far is compressed with the old level (and may be flushed);
485 the new level will take effect only at the next call of deflate().
486
487 deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
488 stream state was inconsistent or if a parameter was invalid.
489*/
490
491/*
410extern int inflateInit2 OF((z_stream *strm, 492extern int inflateInit2 OF((z_stream *strm,
411 int windowBits)); 493 int windowBits));
412/* 494
413 This is another version of inflateInit with more compression options. The 495 This is another version of inflateInit with more compression options. The
414 fields next_out, zalloc and zfree must be initialized before by the caller. 496 fields next_out, zalloc, zfree and opaque must be initialized before by
497 the caller.
415 498
416 The windowBits parameter is the base two logarithm of the maximum window 499 The windowBits parameter is the base two logarithm of the maximum window
417 size (the size of the history buffer). It should be in the range 8..15 for 500 size (the size of the history buffer). It should be in the range 8..15 for
@@ -440,6 +523,25 @@ extern int inflateInit2 OF((z_stream *strm,
440 inflate(). 523 inflate().
441*/ 524*/
442 525
526extern 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
443extern int inflateSync OF((z_stream *strm)); 545extern int inflateSync OF((z_stream *strm));
444/* 546/*
445 Skips invalid compressed data until the special marker (see deflate() 547 Skips invalid compressed data until the special marker (see deflate()
@@ -477,7 +579,7 @@ extern int inflateReset OF((z_stream *strm));
477*/ 579*/
478 580
479extern int compress OF((Bytef *dest, uLongf *destLen, 581extern int compress OF((Bytef *dest, uLongf *destLen,
480 Bytef *source, uLong sourceLen)); 582 const Bytef *source, uLong sourceLen));
481/* 583/*
482 Compresses the source buffer into the destination buffer. sourceLen is 584 Compresses the source buffer into the destination buffer. sourceLen is
483 the byte length of the source buffer. Upon entry, destLen is the total 585 the byte length of the source buffer. Upon entry, destLen is the total
@@ -492,7 +594,7 @@ extern int compress OF((Bytef *dest, uLongf *destLen,
492*/ 594*/
493 595
494extern int uncompress OF((Bytef *dest, uLongf *destLen, 596extern int uncompress OF((Bytef *dest, uLongf *destLen,
495 Bytef *source, uLong sourceLen)); 597 const Bytef *source, uLong sourceLen));
496/* 598/*
497 Decompresses the source buffer into the destination buffer. sourceLen is 599 Decompresses the source buffer into the destination buffer. sourceLen is
498 the byte length of the source buffer. Upon entry, destLen is the total 600 the byte length of the source buffer. Upon entry, destLen is the total
@@ -512,7 +614,7 @@ extern int uncompress OF((Bytef *dest, uLongf *destLen,
512 614
513typedef voidp gzFile; 615typedef voidp gzFile;
514 616
515extern gzFile gzopen OF((char *path, char *mode)); 617extern gzFile gzopen OF((const char *path, const char *mode));
516/* 618/*
517 Opens a gzip (.gz) file for reading or writing. The mode parameter 619 Opens a gzip (.gz) file for reading or writing. The mode parameter
518 is as in fopen ("rb" or "wb") but can also include a compression level 620 is as in fopen ("rb" or "wb") but can also include a compression level
@@ -524,11 +626,15 @@ extern gzFile gzopen OF((char *path, char *mode));
524 zlib error is Z_MEM_ERROR). 626 zlib error is Z_MEM_ERROR).
525*/ 627*/
526 628
527extern gzFile gzdopen OF((int fd, char *mode)); 629extern gzFile gzdopen OF((int fd, const char *mode));
528/* 630/*
529 gzdopen() associates a gzFile with the file descriptor fd. File 631 gzdopen() associates a gzFile with the file descriptor fd. File
530 descriptors are obtained from calls like open, dup, creat, or pipe. 632 descriptors are obtained from calls like open, dup, creat, pipe or
633 fileno (in the file has been previously opened with fopen).
531 The mode parameter is as in fopen ("rb" or "wb"). 634 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).
532 gzdopen returns NULL if there was insufficient memory to allocate 638 gzdopen returns NULL if there was insufficient memory to allocate
533 the (de)compression state. 639 the (de)compression state.
534*/ 640*/
@@ -541,7 +647,7 @@ extern int gzread OF((gzFile file, voidp buf, unsigned len));
541 gzread returns the number of uncompressed bytes actually read (0 for 647 gzread returns the number of uncompressed bytes actually read (0 for
542 end of file, -1 for error). */ 648 end of file, -1 for error). */
543 649
544extern int gzwrite OF((gzFile file, voidp buf, unsigned len)); 650extern int gzwrite OF((gzFile file, const voidp buf, unsigned len));
545/* 651/*
546 Writes the given number of uncompressed bytes into the compressed file. 652 Writes the given number of uncompressed bytes into the compressed file.
547 gzwrite returns the number of uncompressed bytes actually written 653 gzwrite returns the number of uncompressed bytes actually written
@@ -582,7 +688,7 @@ extern char* gzerror OF((gzFile file, int *errnum));
582 compression library. 688 compression library.
583*/ 689*/
584 690
585extern uLong adler32 OF((uLong adler, Bytef *buf, uInt len)); 691extern uLong adler32 OF((uLong adler, const Bytef *buf, uInt len));
586 692
587/* 693/*
588 Update a running Adler-32 checksum with the bytes buf[0..len-1] and 694 Update a running Adler-32 checksum with the bytes buf[0..len-1] and
@@ -599,7 +705,7 @@ extern uLong adler32 OF((uLong adler, Bytef *buf, uInt len));
599 if (adler != original_adler) error(); 705 if (adler != original_adler) error();
600*/ 706*/
601 707
602extern uLong crc32 OF((uLong crc, Bytef *buf, uInt len)); 708extern uLong crc32 OF((uLong crc, const Bytef *buf, uInt len));
603/* 709/*
604 Update a running crc with the bytes buf[0..len-1] and return the updated 710 Update a running crc with the bytes buf[0..len-1] and return the updated
605 crc. If buf is NULL, this function returns the required initial value 711 crc. If buf is NULL, this function returns the required initial value
@@ -615,8 +721,39 @@ extern uLong crc32 OF((uLong crc, Bytef *buf, uInt len));
615 if (crc != original_crc) error(); 721 if (crc != original_crc) error();
616*/ 722*/
617 723
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 */
730extern int deflateInit_ OF((z_stream *strm, int level,
731 const char *version, int stream_size));
732extern int inflateInit_ OF((z_stream *strm,
733 const char *version, int stream_size));
734extern int deflateInit2_ OF((z_stream *strm, int level, int method,
735 int windowBits, int memLevel, int strategy,
736 const char *version, int stream_size));
737extern 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
618#ifndef _Z_UTIL_H 749#ifndef _Z_UTIL_H
619 struct internal_state {int dummy;}; /* hack for buggy compilers */ 750 struct internal_state {int dummy;}; /* hack for buggy compilers */
620#endif 751#endif
621 752
753uLongf *get_crc_table OF((void)); /* can be used by asm versions of crc32() */
754
755#ifdef __cplusplus
756}
757#endif
758
622#endif /* _ZLIB_H */ 759#endif /* _ZLIB_H */