summaryrefslogtreecommitdiff
path: root/zlib.h
diff options
context:
space:
mode:
Diffstat (limited to 'zlib.h')
-rw-r--r--zlib.h213
1 files changed, 163 insertions, 50 deletions
diff --git a/zlib.h b/zlib.h
index a1c48ac..47960c2 100644
--- a/zlib.h
+++ b/zlib.h
@@ -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 14th, 1996. 2 version 1.0.1, May 20th, 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
@@ -32,7 +32,7 @@ extern "C" {
32 32
33#include "zconf.h" 33#include "zconf.h"
34 34
35#define ZLIB_VERSION "1.0" 35#define ZLIB_VERSION "1.0.1"
36 36
37/* 37/*
38 The 'zlib' compression library provides in-memory compression and 38 The 'zlib' compression library provides in-memory compression and
@@ -51,6 +51,11 @@ 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.
54*/ 59*/
55 60
56typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); 61typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
@@ -74,8 +79,9 @@ typedef struct z_stream_s {
74 free_func zfree; /* used to free the internal state */ 79 free_func zfree; /* used to free the internal state */
75 voidpf opaque; /* private data object passed to zalloc and zfree */ 80 voidpf opaque; /* private data object passed to zalloc and zfree */
76 81
77 Byte data_type; /* best guess about the data type: ascii or binary */ 82 int data_type; /* best guess about the data type: ascii or binary */
78 83 uLong adler; /* adler32 value of the uncompressed data */
84 uLong reserved; /* reserved for future use */
79} z_stream; 85} z_stream;
80 86
81/* 87/*
@@ -118,12 +124,16 @@ typedef struct z_stream_s {
118 124
119#define Z_OK 0 125#define Z_OK 0
120#define Z_STREAM_END 1 126#define Z_STREAM_END 1
127#define Z_NEED_DICT 2
121#define Z_ERRNO (-1) 128#define Z_ERRNO (-1)
122#define Z_STREAM_ERROR (-2) 129#define Z_STREAM_ERROR (-2)
123#define Z_DATA_ERROR (-3) 130#define Z_DATA_ERROR (-3)
124#define Z_MEM_ERROR (-4) 131#define Z_MEM_ERROR (-4)
125#define Z_BUF_ERROR (-5) 132#define Z_BUF_ERROR (-5)
126/* 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 */
127 137
128#define Z_NO_COMPRESSION 0 138#define Z_NO_COMPRESSION 0
129#define Z_BEST_SPEED 1 139#define Z_BEST_SPEED 1
@@ -134,18 +144,19 @@ typedef struct z_stream_s {
134#define Z_FILTERED 1 144#define Z_FILTERED 1
135#define Z_HUFFMAN_ONLY 2 145#define Z_HUFFMAN_ONLY 2
136#define Z_DEFAULT_STRATEGY 0 146#define Z_DEFAULT_STRATEGY 0
147/* compression strategy; see deflateInit2() below for details */
137 148
138#define Z_BINARY 0 149#define Z_BINARY 0
139#define Z_ASCII 1 150#define Z_ASCII 1
140#define Z_UNKNOWN 2 151#define Z_UNKNOWN 2
141/* Used to set the data_type field */ 152/* Possible values of the data_type field */
142 153
143#define Z_DEFLATED 8 154#define Z_DEFLATED 8
144/* The deflate compression method (the only one supported in this version) */ 155/* The deflate compression method (the only one supported in this version) */
145 156
146#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ 157#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
147 158
148extern char *zlib_version; 159extern const char *zlib_version;
149/* The application can compare zlib_version and ZLIB_VERSION for consistency. 160/* The application can compare zlib_version and ZLIB_VERSION for consistency.
150 If the first character differs, the library code actually used is 161 If the first character differs, the library code actually used is
151 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.
@@ -153,8 +164,9 @@ extern char *zlib_version;
153 164
154 /* basic functions */ 165 /* basic functions */
155 166
156extern int deflateInit OF((z_stream *strm, int level));
157/* 167/*
168extern int deflateInit OF((z_stream *strm, int level));
169
158 Initializes the internal stream state for compression. The fields 170 Initializes the internal stream state for compression. The fields
159 zalloc, zfree and opaque must be initialized before by the caller. 171 zalloc, zfree and opaque must be initialized before by the caller.
160 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
@@ -167,7 +179,9 @@ extern int deflateInit OF((z_stream *strm, int level));
167 compression (currently equivalent to level 6). 179 compression (currently equivalent to level 6).
168 180
169 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
170 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).
171 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
172 perform any compression: this will be done by deflate(). 186 perform any compression: this will be done by deflate().
173*/ 187*/
@@ -193,7 +207,9 @@ extern int deflate OF((z_stream *strm, int flush));
193 more output, and updating avail_in or avail_out accordingly; avail_out 207 more output, and updating avail_in or avail_out accordingly; avail_out
194 should never be zero before the call. The application can consume the 208 should never be zero before the call. The application can consume the
195 compressed output when it wants, for example when the output buffer is full 209 compressed output when it wants, for example when the output buffer is full
196 (avail_out == 0), or after each call of deflate(). 210 (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
211 and with zero avail_out, it must be called again after making room in the
212 output buffer because there might be more output pending.
197 213
198 If the parameter flush is set to Z_PARTIAL_FLUSH, the current compression 214 If the parameter flush is set to Z_PARTIAL_FLUSH, the current compression
199 block is terminated and flushed to the output buffer so that the 215 block is terminated and flushed to the output buffer so that the
@@ -247,22 +263,26 @@ extern int deflateEnd OF((z_stream *strm));
247 pending output. 263 pending output.
248 264
249 deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the 265 deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
250 stream state was inconsistent. In the error case, msg may be set 266 stream state was inconsistent, Z_DATA_ERROR if the stream was freed
251 but then points to a static string (which must not be deallocated). 267 prematurely (some input or output was discarded). In the error case,
268 msg may be set but then points to a static string (which must not be
269 deallocated).
252*/ 270*/
253 271
254 272
255extern int inflateInit OF((z_stream *strm));
256/* 273/*
274extern int inflateInit OF((z_stream *strm));
275
257 Initializes the internal stream state for decompression. The fields 276 Initializes the internal stream state for decompression. The fields
258 zalloc, zfree and opaque must be initialized before by the caller. If 277 zalloc, zfree and opaque must be initialized before by the caller. If
259 zalloc and zfree are set to Z_NULL, inflateInit updates them to use default 278 zalloc and zfree are set to Z_NULL, inflateInit updates them to use default
260 allocation functions. 279 allocation functions.
261 280
262 inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not 281 inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
263 enough memory. msg is set to null if there is no error message. 282 enough memory, Z_VERSION_ERROR if the zlib library version is incompatible
264 inflateInit does not perform any decompression: this will be done by 283 with the version assumed by the caller. msg is set to null if there is no
265 inflate(). 284 error message. inflateInit does not perform any decompression: this will be
285 done by inflate().
266*/ 286*/
267 287
268 288
@@ -276,15 +296,18 @@ extern int inflate OF((z_stream *strm, int flush));
276 will resume at this point for the next call of inflate(). 296 will resume at this point for the next call of inflate().
277 297
278 - Provide more output starting at next_out and update next_out and avail_out 298 - Provide more output starting at next_out and update next_out and avail_out
279 accordingly. inflate() always provides as much output as possible 299 accordingly. inflate() provides as much output as possible, until there
280 (until there is no more input data or no more space in the output buffer). 300 is no more input data or no more space in the output buffer (see below
301 about the flush parameter).
281 302
282 Before the call of inflate(), the application should ensure that at least 303 Before the call of inflate(), the application should ensure that at least
283 one of the actions is possible, by providing more input and/or consuming 304 one of the actions is possible, by providing more input and/or consuming
284 more output, and updating the next_* and avail_* values accordingly. 305 more output, and updating the next_* and avail_* values accordingly.
285 The application can consume the uncompressed output when it wants, for 306 The application can consume the uncompressed output when it wants, for
286 example when the output buffer is full (avail_out == 0), or after each 307 example when the output buffer is full (avail_out == 0), or after each
287 call of inflate(). 308 call of inflate(). If inflate returns Z_OK and with zero avail_out, it
309 must be called again after making room in the output buffer because there
310 might be more output pending.
288 311
289 If the parameter flush is set to Z_PARTIAL_FLUSH, inflate flushes as much 312 If the parameter flush is set to Z_PARTIAL_FLUSH, inflate flushes as much
290 output as possible to the output buffer. The flushing behavior of inflate is 313 output as possible to the output buffer. The flushing behavior of inflate is
@@ -306,12 +329,15 @@ extern int inflate OF((z_stream *strm, int flush));
306 inflate() returns Z_OK if some progress has been made (more input 329 inflate() returns Z_OK if some progress has been made (more input
307 processed or more output produced), Z_STREAM_END if the end of the 330 processed or more output produced), Z_STREAM_END if the end of the
308 compressed data has been reached and all uncompressed output has been 331 compressed data has been reached and all uncompressed output has been
309 produced, Z_DATA_ERROR if the input data was corrupted, Z_STREAM_ERROR if 332 produced, Z_NEED_DICT if a preset dictionary is needed at this point (see
310 the stream structure was inconsistent (for example if next_in or next_out 333 inflateSetDictionary below), Z_DATA_ERROR if the input data was corrupted,
311 was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no 334 Z_STREAM_ERROR if the stream structure was inconsistent (for example if
312 progress is possible or if there was not enough room in the output buffer 335 next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
313 when Z_FINISH is used. In the Z_DATA_ERROR case, the application may then 336 Z_BUF_ERROR if no progress is possible or if there was not enough room in
314 call inflateSync to look for a good compression block. 337 the output buffer when Z_FINISH is used. In the Z_DATA_ERROR case, the
338 application may then call inflateSync to look for a good compression block.
339 In the Z_NEED_DICT case, strm->adler is set to the Adler32 value of the
340 dictionary chosen by the compressor.
315*/ 341*/
316 342
317 343
@@ -326,19 +352,20 @@ extern int inflateEnd OF((z_stream *strm));
326 static string (which must not be deallocated). 352 static string (which must not be deallocated).
327*/ 353*/
328 354
329 /* advanced functions */ 355 /* Advanced functions */
330 356
331/* 357/*
332 The following functions are needed only in some special applications. 358 The following functions are needed only in some special applications.
333*/ 359*/
334 360
361/*
335extern int deflateInit2 OF((z_stream *strm, 362extern int deflateInit2 OF((z_stream *strm,
336 int level, 363 int level,
337 int method, 364 int method,
338 int windowBits, 365 int windowBits,
339 int memLevel, 366 int memLevel,
340 int strategy)); 367 int strategy));
341/* 368
342 This is another version of deflateInit with more compression options. The 369 This is another version of deflateInit with more compression options. The
343 fields next_in, zalloc, zfree and opaque must be initialized before by 370 fields next_in, zalloc, zfree and opaque must be initialized before by
344 the caller. 371 the caller.
@@ -353,20 +380,22 @@ extern int deflateInit2 OF((z_stream *strm,
353 values of this parameter result in better compression at the expense of 380 values of this parameter result in better compression at the expense of
354 memory usage. The default value is 15 if deflateInit is used instead. 381 memory usage. The default value is 15 if deflateInit is used instead.
355 382
356 The memLevel parameter specifies how much memory should be allocated 383 The memLevel parameter specifies how much memory should be allocated
357 for the internal compression state. memLevel=1 uses minimum memory but 384 for the internal compression state. memLevel=1 uses minimum memory but
358 is slow and reduces compression ratio; memLevel=9 uses maximum memory 385 is slow and reduces compression ratio; memLevel=9 uses maximum memory
359 for optimal speed. The default value is 8. See zconf.h for total memory 386 for optimal speed. The default value is 8. See zconf.h for total memory
360 usage as a function of windowBits and memLevel. 387 usage as a function of windowBits and memLevel.
361 388
362 The strategy parameter is used to tune the compression algorithm. Use 389 The strategy parameter is used to tune the compression algorithm. Use the
363 the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data 390 value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
364 produced by a filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman 391 filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
365 encoding only (no string match). Filtered data consists mostly of small 392 string match). Filtered data consists mostly of small values with a
366 values with a somewhat random distribution. In this case, the 393 somewhat random distribution. In this case, the compression algorithm is
367 compression algorithm is tuned to compress them better. The strategy 394 tuned to compress them better. The effect of Z_FILTERED is to force more
368 parameter only affects the compression ratio but not the correctness of 395 Huffman coding and less string matching; it is somewhat intermediate
369 the compressed output even if it is not set appropriately. 396 between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
397 the compression ratio but not the correctness of the compressed output even
398 if it is not set appropriately.
370 399
371 If next_in is not null, the library will use this buffer to hold also 400 If next_in is not null, the library will use this buffer to hold also
372 some history information; the buffer must either hold the entire input 401 some history information; the buffer must either hold the entire input
@@ -385,9 +414,38 @@ extern int deflateInit2 OF((z_stream *strm,
385 not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as 414 not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
386 an invalid method). msg is set to null if there is no error message. 415 an invalid method). msg is set to null if there is no error message.
387 deflateInit2 does not perform any compression: this will be done by 416 deflateInit2 does not perform any compression: this will be done by
388 deflate(). 417 deflate().
389*/ 418*/
390 419
420extern int deflateSetDictionary OF((z_stream *strm,
421 const Bytef *dictionary,
422 uInt dictLength));
423/*
424 Initializes the compression dictionary (history buffer) from the given
425 byte sequence without producing any compressed output. This function must
426 be called immediately after deflateInit or deflateInit2, before any call
427 of deflate. The compressor and decompressor must use exactly the same
428 dictionary (see inflateSetDictionary).
429 The dictionary should consist of strings (byte sequences) that are likely
430 to be encountered later in the data to be compressed, with the most commonly
431 used strings preferably put towards the end of the dictionary. Using a
432 dictionary is most useful when the data to be compressed is short and
433 can be predicted with good accuracy; the data can then be compressed better
434 than with the default empty dictionary. In this version of the library,
435 only the last 32K bytes of the dictionary are used.
436 Upon return of this function, strm->adler is set to the Adler32 value
437 of the dictionary; the decompressor may later use this value to determine
438 which dictionary has been used by the compressor. (The Adler32 value
439 applies to the whole dictionary even if only a subset of the dictionary is
440 actually used by the compressor.)
441
442 deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
443 parameter is invalid (such as NULL dictionary) or the stream state
444 is inconsistent (for example if deflate has already been called for this
445 stream). deflateSetDictionary does not perform any compression: this will
446 be done by deflate().
447*/
448
391extern int deflateCopy OF((z_stream *dest, 449extern int deflateCopy OF((z_stream *dest,
392 z_stream *source)); 450 z_stream *source));
393/* 451/*
@@ -398,14 +456,14 @@ extern int deflateCopy OF((z_stream *dest,
398 application to provide the correct values of next_out and avail_out for the 456 application to provide the correct values of next_out and avail_out for the
399 next call of deflate. 457 next call of deflate.
400 458
401 This function is useful when several compression strategies will be 459 This function can be useful when several compression strategies will be
402 tried, for example when there are several ways of pre-processing the input 460 tried, for example when there are several ways of pre-processing the input
403 data with a filter. The streams that will be discarded should then be freed 461 data with a filter. The streams that will be discarded should then be freed
404 by calling deflateEnd. Note that deflateCopy duplicates the internal 462 by calling deflateEnd. Note that deflateCopy duplicates the internal
405 compression state which can be quite large, so this strategy is slow and 463 compression state which can be quite large, so this strategy is slow and
406 can consume lots of memory. 464 can consume lots of memory.
407 465
408 deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not 466 deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
409 enough memory, Z_STREAM_ERROR if the source stream state was inconsistent 467 enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
410 (such as zalloc being NULL). msg is left unchanged in both source and 468 (such as zalloc being NULL). msg is left unchanged in both source and
411 destination. 469 destination.
@@ -431,13 +489,19 @@ extern int deflateParams OF((z_stream *strm, int level, int strategy));
431 available so far is compressed with the old level (and may be flushed); 489 available so far is compressed with the old level (and may be flushed);
432 the new level will take effect only at the next call of deflate(). 490 the new level will take effect only at the next call of deflate().
433 491
492 Before the call of deflateParams, the stream state must be set as for
493 a call of deflate(), since the currently available input may have to
494 be compressed and flushed. In particular, strm->avail_out must be non-zero.
495
434 deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source 496 deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
435 stream state was inconsistent or if a parameter was invalid. 497 stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
498 if strm->avail_out was zero.
436*/ 499*/
437 500
501/*
438extern int inflateInit2 OF((z_stream *strm, 502extern int inflateInit2 OF((z_stream *strm,
439 int windowBits)); 503 int windowBits));
440/* 504
441 This is another version of inflateInit with more compression options. The 505 This is another version of inflateInit with more compression options. The
442 fields next_out, zalloc, zfree and opaque must be initialized before by 506 fields next_out, zalloc, zfree and opaque must be initialized before by
443 the caller. 507 the caller.
@@ -469,6 +533,25 @@ extern int inflateInit2 OF((z_stream *strm,
469 inflate(). 533 inflate().
470*/ 534*/
471 535
536extern int inflateSetDictionary OF((z_stream *strm,
537 const Bytef *dictionary,
538 uInt dictLength));
539/*
540 Initializes the decompression dictionary (history buffer) from the given
541 uncompressed byte sequence. This function must be called immediately after
542 a call of inflate if this call returned Z_NEED_DICT. The dictionary chosen
543 by the compressor can be determined from the Adler32 value returned by this
544 call of inflate. The compressor and decompressor must use exactly the same
545 dictionary (see deflateSetDictionary).
546
547 inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
548 parameter is invalid (such as NULL dictionary) or the stream state is
549 inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
550 expected one (incorrect Adler32 value). inflateSetDictionary does not
551 perform any decompression: this will be done by subsequent calls of
552 inflate().
553*/
554
472extern int inflateSync OF((z_stream *strm)); 555extern int inflateSync OF((z_stream *strm));
473/* 556/*
474 Skips invalid compressed data until the special marker (see deflate() 557 Skips invalid compressed data until the special marker (see deflate()
@@ -506,7 +589,7 @@ extern int inflateReset OF((z_stream *strm));
506*/ 589*/
507 590
508extern int compress OF((Bytef *dest, uLongf *destLen, 591extern int compress OF((Bytef *dest, uLongf *destLen,
509 Bytef *source, uLong sourceLen)); 592 const Bytef *source, uLong sourceLen));
510/* 593/*
511 Compresses the source buffer into the destination buffer. sourceLen is 594 Compresses the source buffer into the destination buffer. sourceLen is
512 the byte length of the source buffer. Upon entry, destLen is the total 595 the byte length of the source buffer. Upon entry, destLen is the total
@@ -521,7 +604,7 @@ extern int compress OF((Bytef *dest, uLongf *destLen,
521*/ 604*/
522 605
523extern int uncompress OF((Bytef *dest, uLongf *destLen, 606extern int uncompress OF((Bytef *dest, uLongf *destLen,
524 Bytef *source, uLong sourceLen)); 607 const Bytef *source, uLong sourceLen));
525/* 608/*
526 Decompresses the source buffer into the destination buffer. sourceLen is 609 Decompresses the source buffer into the destination buffer. sourceLen is
527 the byte length of the source buffer. Upon entry, destLen is the total 610 the byte length of the source buffer. Upon entry, destLen is the total
@@ -541,7 +624,7 @@ extern int uncompress OF((Bytef *dest, uLongf *destLen,
541 624
542typedef voidp gzFile; 625typedef voidp gzFile;
543 626
544extern gzFile gzopen OF((char *path, char *mode)); 627extern gzFile gzopen OF((const char *path, const char *mode));
545/* 628/*
546 Opens a gzip (.gz) file for reading or writing. The mode parameter 629 Opens a gzip (.gz) file for reading or writing. The mode parameter
547 is as in fopen ("rb" or "wb") but can also include a compression level 630 is as in fopen ("rb" or "wb") but can also include a compression level
@@ -553,12 +636,15 @@ extern gzFile gzopen OF((char *path, char *mode));
553 zlib error is Z_MEM_ERROR). 636 zlib error is Z_MEM_ERROR).
554*/ 637*/
555 638
556extern gzFile gzdopen OF((int fd, char *mode)); 639extern gzFile gzdopen OF((int fd, const char *mode));
557/* 640/*
558 gzdopen() associates a gzFile with the file descriptor fd. File 641 gzdopen() associates a gzFile with the file descriptor fd. File
559 descriptors are obtained from calls like open, dup, creat, pipe or 642 descriptors are obtained from calls like open, dup, creat, pipe or
560 fileno (in the file has been previously opened with fopen). 643 fileno (in the file has been previously opened with fopen).
561 The mode parameter is as in fopen ("rb" or "wb"). 644 The mode parameter is as in gzopen.
645 The next call of gzclose on the returned gzFile will also close the
646 file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
647 descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
562 gzdopen returns NULL if there was insufficient memory to allocate 648 gzdopen returns NULL if there was insufficient memory to allocate
563 the (de)compression state. 649 the (de)compression state.
564*/ 650*/
@@ -571,7 +657,7 @@ extern int gzread OF((gzFile file, voidp buf, unsigned len));
571 gzread returns the number of uncompressed bytes actually read (0 for 657 gzread returns the number of uncompressed bytes actually read (0 for
572 end of file, -1 for error). */ 658 end of file, -1 for error). */
573 659
574extern int gzwrite OF((gzFile file, voidp buf, unsigned len)); 660extern int gzwrite OF((gzFile file, const voidp buf, unsigned len));
575/* 661/*
576 Writes the given number of uncompressed bytes into the compressed file. 662 Writes the given number of uncompressed bytes into the compressed file.
577 gzwrite returns the number of uncompressed bytes actually written 663 gzwrite returns the number of uncompressed bytes actually written
@@ -612,7 +698,7 @@ extern char* gzerror OF((gzFile file, int *errnum));
612 compression library. 698 compression library.
613*/ 699*/
614 700
615extern uLong adler32 OF((uLong adler, Bytef *buf, uInt len)); 701extern uLong adler32 OF((uLong adler, const Bytef *buf, uInt len));
616 702
617/* 703/*
618 Update a running Adler-32 checksum with the bytes buf[0..len-1] and 704 Update a running Adler-32 checksum with the bytes buf[0..len-1] and
@@ -629,7 +715,7 @@ extern uLong adler32 OF((uLong adler, Bytef *buf, uInt len));
629 if (adler != original_adler) error(); 715 if (adler != original_adler) error();
630*/ 716*/
631 717
632extern uLong crc32 OF((uLong crc, Bytef *buf, uInt len)); 718extern uLong crc32 OF((uLong crc, const Bytef *buf, uInt len));
633/* 719/*
634 Update a running crc with the bytes buf[0..len-1] and return the updated 720 Update a running crc with the bytes buf[0..len-1] and return the updated
635 crc. If buf is NULL, this function returns the required initial value 721 crc. If buf is NULL, this function returns the required initial value
@@ -645,10 +731,37 @@ extern uLong crc32 OF((uLong crc, Bytef *buf, uInt len));
645 if (crc != original_crc) error(); 731 if (crc != original_crc) error();
646*/ 732*/
647 733
648#ifndef _Z_UTIL_H 734
735 /* various hacks, don't look :) */
736
737/* deflateInit and inflateInit are macros to allow checking the zlib version
738 * and the compiler's view of z_stream:
739 */
740extern int deflateInit_ OF((z_stream *strm, int level,
741 const char *version, int stream_size));
742extern int inflateInit_ OF((z_stream *strm,
743 const char *version, int stream_size));
744extern int deflateInit2_ OF((z_stream *strm, int level, int method,
745 int windowBits, int memLevel, int strategy,
746 const char *version, int stream_size));
747extern int inflateInit2_ OF((z_stream *strm, int windowBits,
748 const char *version, int stream_size));
749#define deflateInit(strm, level) \
750 deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
751#define inflateInit(strm) \
752 inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
753#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
754 deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
755 (strategy), ZLIB_VERSION, sizeof(z_stream))
756#define inflateInit2(strm, windowBits) \
757 inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
758
759#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
649 struct internal_state {int dummy;}; /* hack for buggy compilers */ 760 struct internal_state {int dummy;}; /* hack for buggy compilers */
650#endif 761#endif
651 762
763uLongf *get_crc_table OF((void)); /* can be used by asm versions of crc32() */
764
652#ifdef __cplusplus 765#ifdef __cplusplus
653} 766}
654#endif 767#endif