]> git.saurik.com Git - apple/xnu.git/blame - bsd/net/zlib.h
xnu-792.24.17.tar.gz
[apple/xnu.git] / bsd / net / zlib.h
CommitLineData
9bccf70c 1/* $FreeBSD: src/sys/net/zlib.h,v 1.7 1999/12/29 04:38:38 peter Exp $ */
1c79356b
A
2
3/*
9bccf70c
A
4 * This file is derived from zlib.h and zconf.h from the zlib-1.1.4
5 * distribution by Jean-loup Gailly and Mark Adler.
1c79356b
A
6 */
7
1c79356b
A
8/* +++ zlib.h */
9/* zlib.h -- interface of the 'zlib' general purpose compression library
9bccf70c 10 version 1.1.4, March 11th, 2002
1c79356b 11
9bccf70c 12 Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler
1c79356b
A
13
14 This software is provided 'as-is', without any express or implied
15 warranty. In no event will the authors be held liable for any damages
16 arising from the use of this software.
17
18 Permission is granted to anyone to use this software for any purpose,
19 including commercial applications, and to alter it and redistribute it
20 freely, subject to the following restrictions:
21
22 1. The origin of this software must not be misrepresented; you must not
23 claim that you wrote the original software. If you use this software
24 in a product, an acknowledgment in the product documentation would be
25 appreciated but is not required.
26 2. Altered source versions must be plainly marked as such, and must not be
27 misrepresented as being the original software.
28 3. This notice may not be removed or altered from any source distribution.
29
30 Jean-loup Gailly Mark Adler
9bccf70c 31 jloup@gzip.org madler@alumni.caltech.edu
1c79356b
A
32
33
34 The data format used by the zlib library is described by RFCs (Request for
35 Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
36 (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
37*/
38
39#ifndef _ZLIB_H
40#define _ZLIB_H
9bccf70c
A
41#include <sys/appleapiopts.h>
42
91447636 43#ifdef KERNEL_PRIVATE
1c79356b
A
44
45#if __cplusplus
46extern "C" {
47#endif
48
49
50/* +++ zconf.h */
51/* zconf.h -- configuration of the zlib compression library
9bccf70c 52 * Copyright (C) 1995-2002 Jean-loup Gailly.
1c79356b
A
53 * For conditions of distribution and use, see copyright notice in zlib.h
54 */
55
1c79356b
A
56#ifndef _ZCONF_H
57#define _ZCONF_H
58
59/*
60 * If you *really* need a unique prefix for all types and library functions,
61 * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
62 */
9bccf70c 63#ifdef Z_PREFIX
1c79356b
A
64# define deflateInit_ z_deflateInit_
65# define deflate z_deflate
66# define deflateEnd z_deflateEnd
67# define inflateInit_ z_inflateInit_
68# define inflate z_inflate
69# define inflateEnd z_inflateEnd
70# define deflateInit2_ z_deflateInit2_
71# define deflateSetDictionary z_deflateSetDictionary
72# define deflateCopy z_deflateCopy
73# define deflateReset z_deflateReset
74# define deflateParams z_deflateParams
75# define inflateInit2_ z_inflateInit2_
76# define inflateSetDictionary z_inflateSetDictionary
77# define inflateSync z_inflateSync
9bccf70c 78# define inflateSyncPoint z_inflateSyncPoint
1c79356b
A
79# define inflateReset z_inflateReset
80# define compress z_compress
9bccf70c 81# define compress2 z_compress2
1c79356b
A
82# define uncompress z_uncompress
83# define adler32 z_adler32
91447636 84#if 0
1c79356b
A
85# define crc32 z_crc32
86# define get_crc_table z_get_crc_table
91447636 87#endif
1c79356b
A
88
89# define Byte z_Byte
90# define uInt z_uInt
91# define uLong z_uLong
92# define Bytef z_Bytef
93# define charf z_charf
94# define intf z_intf
95# define uIntf z_uIntf
96# define uLongf z_uLongf
97# define voidpf z_voidpf
98# define voidp z_voidp
99#endif
100
101#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
102# define WIN32
103#endif
104#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386)
105# ifndef __32BIT__
106# define __32BIT__
107# endif
108#endif
109#if defined(__MSDOS__) && !defined(MSDOS)
110# define MSDOS
111#endif
112
113/*
114 * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
115 * than 64k bytes at a time (needed on systems with 16-bit int).
116 */
117#if defined(MSDOS) && !defined(__32BIT__)
118# define MAXSEG_64K
119#endif
9bccf70c 120#ifdef MSDOS
1c79356b
A
121# define UNALIGNED_OK
122#endif
123
124#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC)
125# define STDC
126#endif
9bccf70c
A
127#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__)
128# ifndef STDC
129# define STDC
130# endif
1c79356b
A
131#endif
132
133#ifndef STDC
134# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
135# define const
136# endif
137#endif
138
139/* Some Mac compilers merge all .h files incorrectly: */
140#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__)
141# define NO_DUMMY_DECL
142#endif
143
9bccf70c
A
144/* Old Borland C incorrectly complains about missing returns: */
145#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
146# define NEED_DUMMY_RETURN
147#endif
148
149
1c79356b
A
150/* Maximum value for memLevel in deflateInit2 */
151#ifndef MAX_MEM_LEVEL
152# ifdef MAXSEG_64K
153# define MAX_MEM_LEVEL 8
154# else
155# define MAX_MEM_LEVEL 9
156# endif
157#endif
158
9bccf70c
A
159/* Maximum value for windowBits in deflateInit2 and inflateInit2.
160 * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
161 * created by gzip. (Files created by minigzip can still be extracted by
162 * gzip.)
163 */
1c79356b
A
164#ifndef MAX_WBITS
165# define MAX_WBITS 15 /* 32K LZ77 window */
166#endif
167
168/* The memory requirements for deflate are (in bytes):
9bccf70c 169 (1 << (windowBits+2)) + (1 << (memLevel+9))
1c79356b
A
170 that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
171 plus a few kilobytes for small objects. For example, if you want to reduce
172 the default memory requirements from 256K to 128K, compile with
173 make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
174 Of course this will generally degrade compression (there's no free lunch).
175
176 The memory requirements for inflate are (in bytes) 1 << windowBits
177 that is, 32K for windowBits=15 (default value) plus a few kilobytes
178 for small objects.
179*/
180
181 /* Type declarations */
182
183#ifndef OF /* function prototypes */
184# ifdef STDC
185# define OF(args) args
186# else
187# define OF(args) ()
188# endif
189#endif
190
191/* The following definitions for FAR are needed only for MSDOS mixed
192 * model programming (small or medium model with some far allocations).
193 * This was tested only with MSC; for other MSDOS compilers you may have
194 * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
195 * just define FAR to be empty.
196 */
197#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__)
198 /* MSC small or medium model */
199# define SMALL_MEDIUM
200# ifdef _MSC_VER
9bccf70c 201# define FAR _far
1c79356b
A
202# else
203# define FAR far
204# endif
205#endif
206#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
207# ifndef __32BIT__
208# define SMALL_MEDIUM
9bccf70c 209# define FAR _far
1c79356b
A
210# endif
211#endif
9bccf70c
A
212
213/* Compile with -DZLIB_DLL for Windows DLL support */
214#if defined(ZLIB_DLL)
215# if defined(_WINDOWS) || defined(WINDOWS)
216# ifdef FAR
217# undef FAR
218# endif
219# include <windows.h>
220# define ZEXPORT WINAPI
221# ifdef WIN32
222# define ZEXPORTVA WINAPIV
223# else
224# define ZEXPORTVA FAR _cdecl _export
225# endif
226# endif
227# if defined (__BORLANDC__)
228# if (__BORLANDC__ >= 0x0500) && defined (WIN32)
229# include <windows.h>
230# define ZEXPORT __declspec(dllexport) WINAPI
231# define ZEXPORTRVA __declspec(dllexport) WINAPIV
232# else
233# if defined (_Windows) && defined (__DLL__)
234# define ZEXPORT _export
235# define ZEXPORTVA _export
236# endif
237# endif
238# endif
239#endif
240
241#if defined (__BEOS__)
242# if defined (ZLIB_DLL)
243# define ZEXTERN extern __declspec(dllexport)
244# else
245# define ZEXTERN extern __declspec(dllimport)
246# endif
247#endif
248
249#ifndef ZEXPORT
250# define ZEXPORT
251#endif
252#ifndef ZEXPORTVA
253# define ZEXPORTVA
254#endif
255#ifndef ZEXTERN
256# define ZEXTERN extern
257#endif
258
1c79356b
A
259#ifndef FAR
260# define FAR
261#endif
262
9bccf70c 263#if !defined(MACOS) && !defined(TARGET_OS_MAC)
1c79356b 264typedef unsigned char Byte; /* 8 bits */
9bccf70c 265#endif
1c79356b
A
266typedef unsigned int uInt; /* 16 bits or more */
267typedef unsigned long uLong; /* 32 bits or more */
268
9bccf70c
A
269#ifdef SMALL_MEDIUM
270 /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
1c79356b
A
271# define Bytef Byte FAR
272#else
273 typedef Byte FAR Bytef;
274#endif
275typedef char FAR charf;
276typedef int FAR intf;
277typedef uInt FAR uIntf;
278typedef uLong FAR uLongf;
279
280#ifdef STDC
281 typedef void FAR *voidpf;
282 typedef void *voidp;
283#else
284 typedef Byte FAR *voidpf;
285 typedef Byte *voidp;
286#endif
287
9bccf70c
A
288#ifdef HAVE_UNISTD_H
289# include <sys/types.h> /* for off_t */
290# include <unistd.h> /* for SEEK_* and off_t */
291# define z_off_t off_t
292#endif
293#ifndef SEEK_SET
294# define SEEK_SET 0 /* Seek from beginning of file. */
295# define SEEK_CUR 1 /* Seek from current position. */
296# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
297#endif
298#ifndef z_off_t
299# define z_off_t long
300#endif
1c79356b 301
9bccf70c
A
302/* MVS linker does not support external names larger than 8 bytes */
303#if defined(__MVS__)
304# pragma map(deflateInit_,"DEIN")
305# pragma map(deflateInit2_,"DEIN2")
306# pragma map(deflateEnd,"DEEND")
307# pragma map(inflateInit_,"ININ")
308# pragma map(inflateInit2_,"ININ2")
309# pragma map(inflateEnd,"INEND")
310# pragma map(inflateSync,"INSY")
311# pragma map(inflateSetDictionary,"INSEDI")
312# pragma map(inflate_blocks,"INBL")
313# pragma map(inflate_blocks_new,"INBLNE")
314# pragma map(inflate_blocks_free,"INBLFR")
315# pragma map(inflate_blocks_reset,"INBLRE")
316# pragma map(inflate_codes_free,"INCOFR")
317# pragma map(inflate_codes,"INCO")
318# pragma map(inflate_fast,"INFA")
319# pragma map(inflate_flush,"INFLU")
320# pragma map(inflate_mask,"INMA")
321# pragma map(inflate_set_dictionary,"INSEDI2")
322# pragma map(inflate_copyright,"INCOPY")
323# pragma map(inflate_trees_bits,"INTRBI")
324# pragma map(inflate_trees_dynamic,"INTRDY")
325# pragma map(inflate_trees_fixed,"INTRFI")
326# pragma map(inflate_trees_free,"INTRFR")
1c79356b
A
327#endif
328
329#endif /* _ZCONF_H */
330/* --- zconf.h */
331
9bccf70c 332#define ZLIB_VERSION "1.1.4"
1c79356b
A
333
334/*
335 The 'zlib' compression library provides in-memory compression and
336 decompression functions, including integrity checks of the uncompressed
337 data. This version of the library supports only one compression method
9bccf70c 338 (deflation) but other algorithms will be added later and will have the same
1c79356b
A
339 stream interface.
340
1c79356b
A
341 Compression can be done in a single step if the buffers are large
342 enough (for example if an input file is mmap'ed), or can be done by
343 repeated calls of the compression function. In the latter case, the
344 application must provide more input and/or consume the output
345 (providing more output space) before each call.
346
9bccf70c
A
347 The library also supports reading and writing files in gzip (.gz) format
348 with an interface similar to that of stdio.
349
350 The library does not install any signal handler. The decoder checks
351 the consistency of the compressed data, so the library should never
352 crash even in case of corrupted input.
1c79356b
A
353*/
354
355typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
356typedef void (*free_func) OF((voidpf opaque, voidpf address));
357
358struct internal_state;
359
360typedef struct z_stream_s {
361 Bytef *next_in; /* next input byte */
362 uInt avail_in; /* number of bytes available at next_in */
363 uLong total_in; /* total nb of input bytes read so far */
364
365 Bytef *next_out; /* next output byte should be put there */
366 uInt avail_out; /* remaining free space at next_out */
367 uLong total_out; /* total nb of bytes output so far */
368
369 char *msg; /* last error message, NULL if no error */
370 struct internal_state FAR *state; /* not visible by applications */
371
372 alloc_func zalloc; /* used to allocate the internal state */
373 free_func zfree; /* used to free the internal state */
374 voidpf opaque; /* private data object passed to zalloc and zfree */
375
376 int data_type; /* best guess about the data type: ascii or binary */
377 uLong adler; /* adler32 value of the uncompressed data */
378 uLong reserved; /* reserved for future use */
379} z_stream;
380
381typedef z_stream FAR *z_streamp;
382
383/*
384 The application must update next_in and avail_in when avail_in has
385 dropped to zero. It must update next_out and avail_out when avail_out
386 has dropped to zero. The application must initialize zalloc, zfree and
387 opaque before calling the init function. All other fields are set by the
388 compression library and must not be updated by the application.
389
390 The opaque value provided by the application will be passed as the first
391 parameter for calls of zalloc and zfree. This can be useful for custom
392 memory management. The compression library attaches no meaning to the
393 opaque value.
394
395 zalloc must return Z_NULL if there is not enough memory for the object.
9bccf70c
A
396 If zlib is used in a multi-threaded application, zalloc and zfree must be
397 thread safe.
398
1c79356b
A
399 On 16-bit systems, the functions zalloc and zfree must be able to allocate
400 exactly 65536 bytes, but will not be required to allocate more than this
401 if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
402 pointers returned by zalloc for objects of exactly 65536 bytes *must*
403 have their offset normalized to zero. The default allocation function
404 provided by this library ensures this (see zutil.c). To reduce memory
405 requirements and avoid any allocation of 64K objects, at the expense of
406 compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
407
408 The fields total_in and total_out can be used for statistics or
409 progress reports. After compression, total_in holds the total size of
410 the uncompressed data and may be saved for use in the decompressor
411 (particularly if the decompressor wants to decompress everything in
412 a single step).
413*/
414
415 /* constants */
416
417#define Z_NO_FLUSH 0
9bccf70c 418#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
1c79356b
A
419#define Z_PACKET_FLUSH 2
420#define Z_SYNC_FLUSH 3
421#define Z_FULL_FLUSH 4
422#define Z_FINISH 5
423/* Allowed flush values; see deflate() below for details */
424
425#define Z_OK 0
426#define Z_STREAM_END 1
427#define Z_NEED_DICT 2
428#define Z_ERRNO (-1)
429#define Z_STREAM_ERROR (-2)
430#define Z_DATA_ERROR (-3)
431#define Z_MEM_ERROR (-4)
432#define Z_BUF_ERROR (-5)
433#define Z_VERSION_ERROR (-6)
434/* Return codes for the compression/decompression functions. Negative
435 * values are errors, positive values are used for special but normal events.
436 */
437
438#define Z_NO_COMPRESSION 0
439#define Z_BEST_SPEED 1
440#define Z_BEST_COMPRESSION 9
441#define Z_DEFAULT_COMPRESSION (-1)
442/* compression levels */
443
444#define Z_FILTERED 1
445#define Z_HUFFMAN_ONLY 2
446#define Z_DEFAULT_STRATEGY 0
447/* compression strategy; see deflateInit2() below for details */
448
449#define Z_BINARY 0
450#define Z_ASCII 1
451#define Z_UNKNOWN 2
452/* Possible values of the data_type field */
453
454#define Z_DEFLATED 8
455/* The deflate compression method (the only one supported in this version) */
456
457#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
458
459#define zlib_version zlibVersion()
460/* for compatibility with versions < 1.0.2 */
461
462 /* basic functions */
463
9bccf70c 464ZEXTERN const char * ZEXPORT zlibVersion OF((void));
1c79356b
A
465/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
466 If the first character differs, the library code actually used is
467 not compatible with the zlib.h header file used by the application.
468 This check is automatically made by deflateInit and inflateInit.
469 */
470
471/*
9bccf70c 472ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
1c79356b
A
473
474 Initializes the internal stream state for compression. The fields
475 zalloc, zfree and opaque must be initialized before by the caller.
476 If zalloc and zfree are set to Z_NULL, deflateInit updates them to
477 use default allocation functions.
478
479 The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
480 1 gives best speed, 9 gives best compression, 0 gives no compression at
481 all (the input data is simply copied a block at a time).
482 Z_DEFAULT_COMPRESSION requests a default compromise between speed and
483 compression (currently equivalent to level 6).
484
485 deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
486 enough memory, Z_STREAM_ERROR if level is not a valid compression level,
487 Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
488 with the version assumed by the caller (ZLIB_VERSION).
489 msg is set to null if there is no error message. deflateInit does not
490 perform any compression: this will be done by deflate().
491*/
492
493
9bccf70c 494ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
1c79356b 495/*
9bccf70c
A
496 deflate compresses as much data as possible, and stops when the input
497 buffer becomes empty or the output buffer becomes full. It may introduce some
498 output latency (reading input without producing any output) except when
499 forced to flush.
500
501 The detailed semantics are as follows. deflate performs one or both of the
502 following actions:
1c79356b
A
503
504 - Compress more input starting at next_in and update next_in and avail_in
505 accordingly. If not all input can be processed (because there is not
506 enough room in the output buffer), next_in and avail_in are updated and
507 processing will resume at this point for the next call of deflate().
508
509 - Provide more output starting at next_out and update next_out and avail_out
510 accordingly. This action is forced if the parameter flush is non zero.
511 Forcing flush frequently degrades the compression ratio, so this parameter
512 should be set only when necessary (in interactive applications).
513 Some output may be provided even if flush is not set.
514
515 Before the call of deflate(), the application should ensure that at least
516 one of the actions is possible, by providing more input and/or consuming
517 more output, and updating avail_in or avail_out accordingly; avail_out
518 should never be zero before the call. The application can consume the
519 compressed output when it wants, for example when the output buffer is full
520 (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
521 and with zero avail_out, it must be called again after making room in the
522 output buffer because there might be more output pending.
523
9bccf70c
A
524 If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
525 flushed to the output buffer and the output is aligned on a byte boundary, so
526 that the decompressor can get all input data available so far. (In particular
527 avail_in is zero after the call if enough output space has been provided
528 before the call.) Flushing may degrade compression for some compression
529 algorithms and so it should be used only when necessary.
530
531 If flush is set to Z_FULL_FLUSH, all output is flushed as with
532 Z_SYNC_FLUSH, and the compression state is reset so that decompression can
533 restart from this point if previous compressed data has been damaged or if
534 random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
535 the compression.
536
537 If deflate returns with avail_out == 0, this function must be called again
538 with the same value of the flush parameter and more output space (updated
539 avail_out), until the flush is complete (deflate returns with non-zero
540 avail_out).
1c79356b
A
541
542 If the parameter flush is set to Z_FINISH, pending input is processed,
543 pending output is flushed and deflate returns with Z_STREAM_END if there
544 was enough output space; if deflate returns with Z_OK, this function must be
545 called again with Z_FINISH and more output space (updated avail_out) but no
546 more input data, until it returns with Z_STREAM_END or an error. After
547 deflate has returned Z_STREAM_END, the only possible operations on the
548 stream are deflateReset or deflateEnd.
549
550 Z_FINISH can be used immediately after deflateInit if all the compression
551 is to be done in a single step. In this case, avail_out must be at least
552 0.1% larger than avail_in plus 12 bytes. If deflate does not return
553 Z_STREAM_END, then it must be called again as described above.
554
9bccf70c
A
555 deflate() sets strm->adler to the adler32 checksum of all input read
556 so far (that is, total_in bytes).
557
1c79356b
A
558 deflate() may update data_type if it can make a good guess about
559 the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
560 binary. This field is only for information purposes and does not affect
561 the compression algorithm in any manner.
562
563 deflate() returns Z_OK if some progress has been made (more input
564 processed or more output produced), Z_STREAM_END if all input has been
565 consumed and all output has been produced (only when flush is set to
566 Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
9bccf70c
A
567 if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
568 (for example avail_in or avail_out was zero).
1c79356b
A
569*/
570
571
9bccf70c 572ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
1c79356b
A
573/*
574 All dynamically allocated data structures for this stream are freed.
575 This function discards any unprocessed input and does not flush any
576 pending output.
577
578 deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
579 stream state was inconsistent, Z_DATA_ERROR if the stream was freed
580 prematurely (some input or output was discarded). In the error case,
581 msg may be set but then points to a static string (which must not be
582 deallocated).
583*/
584
585
586/*
9bccf70c 587ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
1c79356b
A
588
589 Initializes the internal stream state for decompression. The fields
9bccf70c
A
590 next_in, avail_in, zalloc, zfree and opaque must be initialized before by
591 the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
592 value depends on the compression method), inflateInit determines the
593 compression method from the zlib header and allocates all data structures
594 accordingly; otherwise the allocation will be deferred to the first call of
595 inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
596 use default allocation functions.
1c79356b 597
9bccf70c
A
598 inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
599 memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
600 version assumed by the caller. msg is set to null if there is no error
601 message. inflateInit does not perform any decompression apart from reading
602 the zlib header if present: this will be done by inflate(). (So next_in and
603 avail_in may be modified, but next_out and avail_out are unchanged.)
1c79356b
A
604*/
605
1c79356b 606
9bccf70c 607ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
1c79356b 608/*
9bccf70c
A
609 inflate decompresses as much data as possible, and stops when the input
610 buffer becomes empty or the output buffer becomes full. It may some
611 introduce some output latency (reading input without producing any output)
612 except when forced to flush.
613
614 The detailed semantics are as follows. inflate performs one or both of the
615 following actions:
1c79356b
A
616
617 - Decompress more input starting at next_in and update next_in and avail_in
618 accordingly. If not all input can be processed (because there is not
619 enough room in the output buffer), next_in is updated and processing
620 will resume at this point for the next call of inflate().
621
622 - Provide more output starting at next_out and update next_out and avail_out
623 accordingly. inflate() provides as much output as possible, until there
624 is no more input data or no more space in the output buffer (see below
625 about the flush parameter).
626
627 Before the call of inflate(), the application should ensure that at least
628 one of the actions is possible, by providing more input and/or consuming
629 more output, and updating the next_* and avail_* values accordingly.
630 The application can consume the uncompressed output when it wants, for
631 example when the output buffer is full (avail_out == 0), or after each
632 call of inflate(). If inflate returns Z_OK and with zero avail_out, it
633 must be called again after making room in the output buffer because there
634 might be more output pending.
635
9bccf70c
A
636 If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
637 output as possible to the output buffer. The flushing behavior of inflate is
638 not specified for values of the flush parameter other than Z_SYNC_FLUSH
639 and Z_FINISH, but the current implementation actually flushes as much output
640 as possible anyway.
1c79356b
A
641
642 inflate() should normally be called until it returns Z_STREAM_END or an
643 error. However if all decompression is to be performed in a single step
644 (a single call of inflate), the parameter flush should be set to
645 Z_FINISH. In this case all pending input is processed and all pending
646 output is flushed; avail_out must be large enough to hold all the
647 uncompressed data. (The size of the uncompressed data may have been saved
648 by the compressor for this purpose.) The next operation on this stream must
649 be inflateEnd to deallocate the decompression state. The use of Z_FINISH
650 is never required, but can be used to inform inflate that a faster routine
651 may be used for the single inflate() call.
652
9bccf70c
A
653 If a preset dictionary is needed at this point (see inflateSetDictionary
654 below), inflate sets strm-adler to the adler32 checksum of the
655 dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
656 it sets strm->adler to the adler32 checksum of all output produced
657 so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
658 an error code as described below. At the end of the stream, inflate()
659 checks that its computed adler32 checksum is equal to that saved by the
660 compressor and returns Z_STREAM_END only if the checksum is correct.
661
662 inflate() returns Z_OK if some progress has been made (more input processed
663 or more output produced), Z_STREAM_END if the end of the compressed data has
664 been reached and all uncompressed output has been produced, Z_NEED_DICT if a
665 preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
666 corrupted (input stream not conforming to the zlib format or incorrect
667 adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
668 (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
669 enough memory, Z_BUF_ERROR if no progress is possible or if there was not
670 enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
671 case, the application may then call inflateSync to look for a good
672 compression block.
1c79356b
A
673*/
674
675
9bccf70c 676ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
1c79356b
A
677/*
678 All dynamically allocated data structures for this stream are freed.
679 This function discards any unprocessed input and does not flush any
680 pending output.
681
682 inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
683 was inconsistent. In the error case, msg may be set but then points to a
684 static string (which must not be deallocated).
685*/
686
687 /* Advanced functions */
688
689/*
690 The following functions are needed only in some special applications.
691*/
692
693/*
9bccf70c
A
694ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
695 int level,
696 int method,
697 int windowBits,
698 int memLevel,
699 int strategy));
1c79356b
A
700
701 This is another version of deflateInit with more compression options. The
702 fields next_in, zalloc, zfree and opaque must be initialized before by
703 the caller.
704
705 The method parameter is the compression method. It must be Z_DEFLATED in
9bccf70c 706 this version of the library.
1c79356b
A
707
708 The windowBits parameter is the base two logarithm of the window size
709 (the size of the history buffer). It should be in the range 8..15 for this
9bccf70c
A
710 version of the library. Larger values of this parameter result in better
711 compression at the expense of memory usage. The default value is 15 if
712 deflateInit is used instead.
1c79356b
A
713
714 The memLevel parameter specifies how much memory should be allocated
715 for the internal compression state. memLevel=1 uses minimum memory but
716 is slow and reduces compression ratio; memLevel=9 uses maximum memory
717 for optimal speed. The default value is 8. See zconf.h for total memory
718 usage as a function of windowBits and memLevel.
719
720 The strategy parameter is used to tune the compression algorithm. Use the
721 value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
722 filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
723 string match). Filtered data consists mostly of small values with a
724 somewhat random distribution. In this case, the compression algorithm is
725 tuned to compress them better. The effect of Z_FILTERED is to force more
726 Huffman coding and less string matching; it is somewhat intermediate
727 between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
728 the compression ratio but not the correctness of the compressed output even
729 if it is not set appropriately.
730
9bccf70c
A
731 deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
732 memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
733 method). msg is set to null if there is no error message. deflateInit2 does
734 not perform any compression: this will be done by deflate().
1c79356b
A
735*/
736
9bccf70c
A
737ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
738 const Bytef *dictionary,
739 uInt dictLength));
740/*
741 Initializes the compression dictionary from the given byte sequence
742 without producing any compressed output. This function must be called
743 immediately after deflateInit, deflateInit2 or deflateReset, before any
744 call of deflate. The compressor and decompressor must use exactly the same
1c79356b 745 dictionary (see inflateSetDictionary).
9bccf70c 746
1c79356b
A
747 The dictionary should consist of strings (byte sequences) that are likely
748 to be encountered later in the data to be compressed, with the most commonly
749 used strings preferably put towards the end of the dictionary. Using a
9bccf70c
A
750 dictionary is most useful when the data to be compressed is short and can be
751 predicted with good accuracy; the data can then be compressed better than
752 with the default empty dictionary.
753
754 Depending on the size of the compression data structures selected by
755 deflateInit or deflateInit2, a part of the dictionary may in effect be
756 discarded, for example if the dictionary is larger than the window size in
757 deflate or deflate2. Thus the strings most likely to be useful should be
758 put at the end of the dictionary, not at the front.
759
1c79356b
A
760 Upon return of this function, strm->adler is set to the Adler32 value
761 of the dictionary; the decompressor may later use this value to determine
762 which dictionary has been used by the compressor. (The Adler32 value
763 applies to the whole dictionary even if only a subset of the dictionary is
764 actually used by the compressor.)
765
766 deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
9bccf70c
A
767 parameter is invalid (such as NULL dictionary) or the stream state is
768 inconsistent (for example if deflate has already been called for this stream
769 or if the compression method is bsort). deflateSetDictionary does not
770 perform any compression: this will be done by deflate().
1c79356b
A
771*/
772
9bccf70c
A
773ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
774 z_streamp source));
1c79356b 775/*
9bccf70c 776 Sets the destination stream as a complete copy of the source stream.
1c79356b
A
777
778 This function can be useful when several compression strategies will be
779 tried, for example when there are several ways of pre-processing the input
780 data with a filter. The streams that will be discarded should then be freed
781 by calling deflateEnd. Note that deflateCopy duplicates the internal
782 compression state which can be quite large, so this strategy is slow and
783 can consume lots of memory.
784
785 deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
786 enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
787 (such as zalloc being NULL). msg is left unchanged in both source and
788 destination.
789*/
790
9bccf70c 791ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
1c79356b
A
792/*
793 This function is equivalent to deflateEnd followed by deflateInit,
794 but does not free and reallocate all the internal compression state.
795 The stream will keep the same compression level and any other attributes
796 that may have been set by deflateInit2.
797
798 deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
799 stream state was inconsistent (such as zalloc or state being NULL).
800*/
801
9bccf70c
A
802ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
803 int level,
804 int strategy));
1c79356b 805/*
9bccf70c
A
806 Dynamically update the compression level and compression strategy. The
807 interpretation of level and strategy is as in deflateInit2. This can be
808 used to switch between compression and straight copy of the input data, or
809 to switch to a different kind of input data requiring a different
810 strategy. If the compression level is changed, the input available so far
811 is compressed with the old level (and may be flushed); the new level will
812 take effect only at the next call of deflate().
1c79356b
A
813
814 Before the call of deflateParams, the stream state must be set as for
815 a call of deflate(), since the currently available input may have to
816 be compressed and flushed. In particular, strm->avail_out must be non-zero.
817
818 deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
819 stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
820 if strm->avail_out was zero.
821*/
822
1c79356b 823/*
9bccf70c
A
824ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
825 int windowBits));
1c79356b 826
9bccf70c
A
827 This is another version of inflateInit with an extra parameter. The
828 fields next_in, avail_in, zalloc, zfree and opaque must be initialized
829 before by the caller.
1c79356b
A
830
831 The windowBits parameter is the base two logarithm of the maximum window
832 size (the size of the history buffer). It should be in the range 8..15 for
9bccf70c
A
833 this version of the library. The default value is 15 if inflateInit is used
834 instead. If a compressed stream with a larger window size is given as
835 input, inflate() will return with the error code Z_DATA_ERROR instead of
836 trying to allocate a larger window.
837
838 inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
839 memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
840 memLevel). msg is set to null if there is no error message. inflateInit2
841 does not perform any decompression apart from reading the zlib header if
842 present: this will be done by inflate(). (So next_in and avail_in may be
843 modified, but next_out and avail_out are unchanged.)
1c79356b
A
844*/
845
9bccf70c
A
846ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
847 const Bytef *dictionary,
848 uInt dictLength));
1c79356b 849/*
9bccf70c
A
850 Initializes the decompression dictionary from the given uncompressed byte
851 sequence. This function must be called immediately after a call of inflate
852 if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
853 can be determined from the Adler32 value returned by this call of
854 inflate. The compressor and decompressor must use exactly the same
1c79356b
A
855 dictionary (see deflateSetDictionary).
856
857 inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
858 parameter is invalid (such as NULL dictionary) or the stream state is
859 inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
860 expected one (incorrect Adler32 value). inflateSetDictionary does not
861 perform any decompression: this will be done by subsequent calls of
862 inflate().
863*/
864
9bccf70c 865ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
1c79356b 866/*
9bccf70c
A
867 Skips invalid compressed data until a full flush point (see above the
868 description of deflate with Z_FULL_FLUSH) can be found, or until all
869 available input is skipped. No output is provided.
1c79356b 870
9bccf70c
A
871 inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
872 if no more input was provided, Z_DATA_ERROR if no flush point has been found,
1c79356b
A
873 or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
874 case, the application may save the current current value of total_in which
875 indicates where valid compressed data was found. In the error case, the
876 application may repeatedly call inflateSync, providing more input each time,
877 until success or end of the input data.
878*/
879
9bccf70c 880ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
1c79356b
A
881/*
882 This function is equivalent to inflateEnd followed by inflateInit,
883 but does not free and reallocate all the internal decompression state.
884 The stream will keep attributes that may have been set by inflateInit2.
885
886 inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
887 stream state was inconsistent (such as zalloc or state being NULL).
888*/
889
1c79356b
A
890
891 /* utility functions */
892
893/*
894 The following utility functions are implemented on top of the
895 basic stream-oriented functions. To simplify the interface, some
9bccf70c 896 default options are assumed (compression level and memory usage,
1c79356b
A
897 standard memory allocation functions). The source code of these
898 utility functions can easily be modified if you need special options.
899*/
900
9bccf70c
A
901ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
902 const Bytef *source, uLong sourceLen));
1c79356b
A
903/*
904 Compresses the source buffer into the destination buffer. sourceLen is
905 the byte length of the source buffer. Upon entry, destLen is the total
906 size of the destination buffer, which must be at least 0.1% larger than
907 sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
908 compressed buffer.
909 This function can be used to compress a whole file at once if the
910 input file is mmap'ed.
911 compress returns Z_OK if success, Z_MEM_ERROR if there was not
912 enough memory, Z_BUF_ERROR if there was not enough room in the output
913 buffer.
914*/
915
9bccf70c
A
916ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
917 const Bytef *source, uLong sourceLen,
918 int level));
919/*
920 Compresses the source buffer into the destination buffer. The level
921 parameter has the same meaning as in deflateInit. sourceLen is the byte
922 length of the source buffer. Upon entry, destLen is the total size of the
923 destination buffer, which must be at least 0.1% larger than sourceLen plus
924 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
925
926 compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
927 memory, Z_BUF_ERROR if there was not enough room in the output buffer,
928 Z_STREAM_ERROR if the level parameter is invalid.
929*/
930
931ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
932 const Bytef *source, uLong sourceLen));
1c79356b
A
933/*
934 Decompresses the source buffer into the destination buffer. sourceLen is
935 the byte length of the source buffer. Upon entry, destLen is the total
936 size of the destination buffer, which must be large enough to hold the
937 entire uncompressed data. (The size of the uncompressed data must have
938 been saved previously by the compressor and transmitted to the decompressor
939 by some mechanism outside the scope of this compression library.)
940 Upon exit, destLen is the actual size of the compressed buffer.
941 This function can be used to decompress a whole file at once if the
942 input file is mmap'ed.
943
944 uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
945 enough memory, Z_BUF_ERROR if there was not enough room in the output
946 buffer, or Z_DATA_ERROR if the input data was corrupted.
947*/
948
949
950typedef voidp gzFile;
951
9bccf70c 952ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
1c79356b
A
953/*
954 Opens a gzip (.gz) file for reading or writing. The mode parameter
955 is as in fopen ("rb" or "wb") but can also include a compression level
9bccf70c
A
956 ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
957 Huffman only compression as in "wb1h". (See the description
958 of deflateInit2 for more information about the strategy parameter.)
959
960 gzopen can be used to read a file which is not in gzip format; in this
961 case gzread will directly read from the file without decompression.
962
1c79356b
A
963 gzopen returns NULL if the file could not be opened or if there was
964 insufficient memory to allocate the (de)compression state; errno
965 can be checked to distinguish the two cases (if errno is zero, the
9bccf70c 966 zlib error is Z_MEM_ERROR). */
1c79356b 967
9bccf70c 968ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
1c79356b
A
969/*
970 gzdopen() associates a gzFile with the file descriptor fd. File
971 descriptors are obtained from calls like open, dup, creat, pipe or
972 fileno (in the file has been previously opened with fopen).
973 The mode parameter is as in gzopen.
974 The next call of gzclose on the returned gzFile will also close the
975 file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
976 descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
977 gzdopen returns NULL if there was insufficient memory to allocate
978 the (de)compression state.
979*/
980
9bccf70c
A
981ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
982/*
983 Dynamically update the compression level or strategy. See the description
984 of deflateInit2 for the meaning of these parameters.
985 gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
986 opened for writing.
987*/
988
989ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
1c79356b
A
990/*
991 Reads the given number of uncompressed bytes from the compressed file.
992 If the input file was not in gzip format, gzread copies the given number
993 of bytes into the buffer.
994 gzread returns the number of uncompressed bytes actually read (0 for
995 end of file, -1 for error). */
996
9bccf70c
A
997ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
998 const voidp buf, unsigned len));
1c79356b
A
999/*
1000 Writes the given number of uncompressed bytes into the compressed file.
1001 gzwrite returns the number of uncompressed bytes actually written
1002 (0 in case of error).
1003*/
1004
9bccf70c
A
1005ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
1006/*
1007 Converts, formats, and writes the args to the compressed file under
1008 control of the format string, as in fprintf. gzprintf returns the number of
1009 uncompressed bytes actually written (0 in case of error).
1010*/
1011
1012ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
1013/*
1014 Writes the given null-terminated string to the compressed file, excluding
1015 the terminating null character.
1016 gzputs returns the number of characters written, or -1 in case of error.
1017*/
1018
1019ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
1020/*
1021 Reads bytes from the compressed file until len-1 characters are read, or
1022 a newline character is read and transferred to buf, or an end-of-file
1023 condition is encountered. The string is then terminated with a null
1024 character.
1025 gzgets returns buf, or Z_NULL in case of error.
1026*/
1027
1028ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
1029/*
1030 Writes c, converted to an unsigned char, into the compressed file.
1031 gzputc returns the value that was written, or -1 in case of error.
1032*/
1033
1034ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
1035/*
1036 Reads one byte from the compressed file. gzgetc returns this byte
1037 or -1 in case of end of file or error.
1038*/
1039
1040ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
1c79356b
A
1041/*
1042 Flushes all pending output into the compressed file. The parameter
1043 flush is as in the deflate() function. The return value is the zlib
1044 error number (see function gzerror below). gzflush returns Z_OK if
1045 the flush parameter is Z_FINISH and all output could be flushed.
1046 gzflush should be called only when strictly necessary because it can
1047 degrade compression.
1048*/
1049
9bccf70c
A
1050ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
1051 z_off_t offset, int whence));
1052/*
1053 Sets the starting position for the next gzread or gzwrite on the
1054 given compressed file. The offset represents a number of bytes in the
1055 uncompressed data stream. The whence parameter is defined as in lseek(2);
1056 the value SEEK_END is not supported.
1057 If the file is opened for reading, this function is emulated but can be
1058 extremely slow. If the file is opened for writing, only forward seeks are
1059 supported; gzseek then compresses a sequence of zeroes up to the new
1060 starting position.
1061
1062 gzseek returns the resulting offset location as measured in bytes from
1063 the beginning of the uncompressed stream, or -1 in case of error, in
1064 particular if the file is opened for writing and the new starting position
1065 would be before the current position.
1066*/
1067
1068ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
1069/*
1070 Rewinds the given file. This function is supported only for reading.
1071
1072 gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
1073*/
1074
1075ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
1076/*
1077 Returns the starting position for the next gzread or gzwrite on the
1078 given compressed file. This position represents a number of bytes in the
1079 uncompressed data stream.
1080
1081 gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
1082*/
1083
1084ZEXTERN int ZEXPORT gzeof OF((gzFile file));
1085/*
1086 Returns 1 when EOF has previously been detected reading the given
1087 input stream, otherwise zero.
1088*/
1089
1090ZEXTERN int ZEXPORT gzclose OF((gzFile file));
1c79356b
A
1091/*
1092 Flushes all pending output if necessary, closes the compressed file
1093 and deallocates all the (de)compression state. The return value is the zlib
1094 error number (see function gzerror below).
1095*/
1096
9bccf70c 1097ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
1c79356b
A
1098/*
1099 Returns the error message for the last error which occurred on the
1100 given compressed file. errnum is set to zlib error number. If an
1101 error occurred in the file system and not in the compression library,
1102 errnum is set to Z_ERRNO and the application may consult errno
1103 to get the exact error code.
1104*/
1105
1106 /* checksum functions */
1107
1108/*
1109 These functions are not related to compression but are exported
1110 anyway because they might be useful in applications using the
1111 compression library.
1112*/
1113
9bccf70c 1114ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
1c79356b
A
1115
1116/*
1117 Update a running Adler-32 checksum with the bytes buf[0..len-1] and
1118 return the updated checksum. If buf is NULL, this function returns
1119 the required initial value for the checksum.
1120 An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
1121 much faster. Usage example:
1122
1123 uLong adler = adler32(0L, Z_NULL, 0);
1124
1125 while (read_buffer(buffer, length) != EOF) {
1126 adler = adler32(adler, buffer, length);
1127 }
1128 if (adler != original_adler) error();
1129*/
1130
91447636 1131#if 0
9bccf70c 1132ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
1c79356b
A
1133/*
1134 Update a running crc with the bytes buf[0..len-1] and return the updated
1135 crc. If buf is NULL, this function returns the required initial value
1136 for the crc. Pre- and post-conditioning (one's complement) is performed
1137 within this function so it shouldn't be done by the application.
1138 Usage example:
1139
1140 uLong crc = crc32(0L, Z_NULL, 0);
1141
1142 while (read_buffer(buffer, length) != EOF) {
1143 crc = crc32(crc, buffer, length);
1144 }
1145 if (crc != original_crc) error();
1146*/
91447636 1147#endif
1c79356b
A
1148
1149
1150 /* various hacks, don't look :) */
1151
1152/* deflateInit and inflateInit are macros to allow checking the zlib version
1153 * and the compiler's view of z_stream:
1154 */
9bccf70c
A
1155ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
1156 const char *version, int stream_size));
1157ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
1158 const char *version, int stream_size));
1159ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
1160 int windowBits, int memLevel,
1161 int strategy, const char *version,
1162 int stream_size));
1163ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
1164 const char *version, int stream_size));
1c79356b
A
1165#define deflateInit(strm, level) \
1166 deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
1167#define inflateInit(strm) \
1168 inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
1169#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
1170 deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
9bccf70c 1171 (strategy), ZLIB_VERSION, sizeof(z_stream))
1c79356b
A
1172#define inflateInit2(strm, windowBits) \
1173 inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
1174
9bccf70c 1175
1c79356b
A
1176#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
1177 struct internal_state {int dummy;}; /* hack for buggy compilers */
1178#endif
1179
9bccf70c
A
1180ZEXTERN const char * ZEXPORT zError OF((int err));
1181ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
1182ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
1c79356b 1183
9bccf70c 1184#ifdef __cplusplus
1c79356b
A
1185}
1186#endif
1187
91447636 1188#endif KERNEL_PRIVATE
1c79356b
A
1189#endif /* _ZLIB_H */
1190/* --- zlib.h */