150477Speter/* $FreeBSD$	*/
228415Speter
328415Speter/*
434768Speter * This file is derived from zlib.h and zconf.h from the zlib-1.0.4
528415Speter * distribution by Jean-loup Gailly and Mark Adler, with some additions
628415Speter * by Paul Mackerras to aid in implementing Deflate compression and
728415Speter * decompression for PPP packets.
828415Speter */
928415Speter
1028415Speter/*
1134768Speter *  ==FILEVERSION 971127==
1228415Speter *
1328415Speter * This marker is used by the Linux installation script to determine
1428415Speter * whether an up-to-date version of this file is already installed.
1528415Speter */
1628415Speter
1734768Speter
1834768Speter/* +++ zlib.h */
19139823Simp/*-
20139823Simp  zlib.h -- interface of the 'zlib' general purpose compression library
2134768Speter  version 1.0.4, Jul 24th, 1996.
2228415Speter
2334768Speter  Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler
2428415Speter
2528415Speter  This software is provided 'as-is', without any express or implied
2628415Speter  warranty.  In no event will the authors be held liable for any damages
2728415Speter  arising from the use of this software.
2828415Speter
2928415Speter  Permission is granted to anyone to use this software for any purpose,
3028415Speter  including commercial applications, and to alter it and redistribute it
3128415Speter  freely, subject to the following restrictions:
3228415Speter
3328415Speter  1. The origin of this software must not be misrepresented; you must not
3428415Speter     claim that you wrote the original software. If you use this software
3528415Speter     in a product, an acknowledgment in the product documentation would be
3628415Speter     appreciated but is not required.
3728415Speter  2. Altered source versions must be plainly marked as such, and must not be
3828415Speter     misrepresented as being the original software.
3928415Speter  3. This notice may not be removed or altered from any source distribution.
4028415Speter
4128415Speter  Jean-loup Gailly        Mark Adler
4228415Speter  gzip@prep.ai.mit.edu    madler@alumni.caltech.edu
43139823Simp*/
44139823Simp/*
4534768Speter  The data format used by the zlib library is described by RFCs (Request for
4634768Speter  Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
4734768Speter  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
4834768Speter*/
4934768Speter
5028415Speter#ifndef _ZLIB_H
5128415Speter#define _ZLIB_H
5228415Speter
5334768Speter#ifdef __cplusplus
5434768Speterextern "C" {
5534768Speter#endif
5628415Speter
5734768Speter
5834768Speter/* +++ zconf.h */
5928415Speter/* zconf.h -- configuration of the zlib compression library
6034768Speter * Copyright (C) 1995-1996 Jean-loup Gailly.
6128415Speter * For conditions of distribution and use, see copyright notice in zlib.h
6228415Speter */
6328415Speter
6434768Speter/* From: zconf.h,v 1.20 1996/07/02 15:09:28 me Exp $ */
6528415Speter
6634768Speter#ifndef _ZCONF_H
6734768Speter#define _ZCONF_H
6834768Speter
6928415Speter/*
7034768Speter * If you *really* need a unique prefix for all types and library functions,
7134768Speter * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
7228415Speter */
7334768Speter#ifdef Z_PREFIX
7434768Speter#  define deflateInit_	z_deflateInit_
7534768Speter#  define deflate	z_deflate
7634768Speter#  define deflateEnd	z_deflateEnd
7734768Speter#  define inflateInit_ 	z_inflateInit_
7834768Speter#  define inflate	z_inflate
7934768Speter#  define inflateEnd	z_inflateEnd
8034768Speter#  define deflateInit2_	z_deflateInit2_
8134768Speter#  define deflateSetDictionary z_deflateSetDictionary
8234768Speter#  define deflateCopy	z_deflateCopy
8334768Speter#  define deflateReset	z_deflateReset
8434768Speter#  define deflateParams	z_deflateParams
8534768Speter#  define inflateInit2_	z_inflateInit2_
8634768Speter#  define inflateSetDictionary z_inflateSetDictionary
8734768Speter#  define inflateSync	z_inflateSync
8834768Speter#  define inflateReset	z_inflateReset
8934768Speter#  define compress	z_compress
9034768Speter#  define uncompress	z_uncompress
9134768Speter#  define adler32	z_adler32
9297512Sphk#if 0
9334768Speter#  define crc32		z_crc32
9434768Speter#  define get_crc_table z_get_crc_table
9597512Sphk#endif
9628415Speter
9734768Speter#  define Byte		z_Byte
9834768Speter#  define uInt		z_uInt
9934768Speter#  define uLong		z_uLong
10034768Speter#  define Bytef	        z_Bytef
10134768Speter#  define charf		z_charf
10234768Speter#  define intf		z_intf
10334768Speter#  define uIntf		z_uIntf
10434768Speter#  define uLongf	z_uLongf
10534768Speter#  define voidpf	z_voidpf
10634768Speter#  define voidp		z_voidp
10734768Speter#endif
10834768Speter
10934768Speter#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
11034768Speter#  define WIN32
11134768Speter#endif
112231678Stijl#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(__i386__)
11334768Speter#  ifndef __32BIT__
11434768Speter#    define __32BIT__
11534768Speter#  endif
11634768Speter#endif
11734768Speter#if defined(__MSDOS__) && !defined(MSDOS)
11834768Speter#  define MSDOS
11934768Speter#endif
12034768Speter
12128415Speter/*
12228415Speter * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
12328415Speter * than 64k bytes at a time (needed on systems with 16-bit int).
12428415Speter */
12534768Speter#if defined(MSDOS) && !defined(__32BIT__)
12634768Speter#  define MAXSEG_64K
12734768Speter#endif
12834768Speter#ifdef MSDOS
12934768Speter#  define UNALIGNED_OK
13034768Speter#endif
13128415Speter
13234768Speter#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32))  && !defined(STDC)
13334768Speter#  define STDC
13434768Speter#endif
13534768Speter#if (defined(__STDC__) || defined(__cplusplus)) && !defined(STDC)
13634768Speter#  define STDC
13734768Speter#endif
13834768Speter
13928415Speter#ifndef STDC
14034768Speter#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
14134768Speter#    define const
14228415Speter#  endif
14328415Speter#endif
14428415Speter
14534768Speter/* Some Mac compilers merge all .h files incorrectly: */
14634768Speter#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__)
14734768Speter#  define NO_DUMMY_DECL
14828415Speter#endif
14928415Speter
15028415Speter/* Maximum value for memLevel in deflateInit2 */
15128415Speter#ifndef MAX_MEM_LEVEL
15228415Speter#  ifdef MAXSEG_64K
15328415Speter#    define MAX_MEM_LEVEL 8
15428415Speter#  else
15528415Speter#    define MAX_MEM_LEVEL 9
15628415Speter#  endif
15728415Speter#endif
15828415Speter
15928415Speter/* Maximum value for windowBits in deflateInit2 and inflateInit2 */
16028415Speter#ifndef MAX_WBITS
16128415Speter#  define MAX_WBITS   15 /* 32K LZ77 window */
16228415Speter#endif
16328415Speter
16428415Speter/* The memory requirements for deflate are (in bytes):
16528415Speter            1 << (windowBits+2)   +  1 << (memLevel+9)
16628415Speter that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
16728415Speter plus a few kilobytes for small objects. For example, if you want to reduce
16828415Speter the default memory requirements from 256K to 128K, compile with
16928415Speter     make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
17028415Speter Of course this will generally degrade compression (there's no free lunch).
17128415Speter
17228415Speter   The memory requirements for inflate are (in bytes) 1 << windowBits
17328415Speter that is, 32K for windowBits=15 (default value) plus a few kilobytes
17428415Speter for small objects.
17528415Speter*/
17628415Speter
17728415Speter                        /* Type declarations */
17828415Speter
17928415Speter#ifndef OF /* function prototypes */
18028415Speter#  ifdef STDC
18128415Speter#    define OF(args)  args
18228415Speter#  else
18328415Speter#    define OF(args)  ()
18428415Speter#  endif
18528415Speter#endif
18628415Speter
18734768Speter/* The following definitions for FAR are needed only for MSDOS mixed
18834768Speter * model programming (small or medium model with some far allocations).
18934768Speter * This was tested only with MSC; for other MSDOS compilers you may have
19034768Speter * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
19134768Speter * just define FAR to be empty.
19234768Speter */
19334768Speter#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__)
19434768Speter   /* MSC small or medium model */
19534768Speter#  define SMALL_MEDIUM
19634768Speter#  ifdef _MSC_VER
19734768Speter#    define FAR __far
19834768Speter#  else
19934768Speter#    define FAR far
20034768Speter#  endif
20134768Speter#endif
20234768Speter#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
20334768Speter#  ifndef __32BIT__
20434768Speter#    define SMALL_MEDIUM
20534768Speter#    define FAR __far
20634768Speter#  endif
20734768Speter#endif
20834768Speter#ifndef FAR
20934768Speter#   define FAR
21034768Speter#endif
21134768Speter
21228415Spetertypedef unsigned char  Byte;  /* 8 bits */
21328415Spetertypedef unsigned int   uInt;  /* 16 bits or more */
21428415Spetertypedef unsigned long  uLong; /* 32 bits or more */
21528415Speter
21634768Speter#if defined(__BORLANDC__) && defined(SMALL_MEDIUM)
21734768Speter   /* Borland C/C++ ignores FAR inside typedef */
21834768Speter#  define Bytef Byte FAR
21934768Speter#else
22034768Speter   typedef Byte  FAR Bytef;
22134768Speter#endif
22234768Spetertypedef char  FAR charf;
22334768Spetertypedef int   FAR intf;
22434768Spetertypedef uInt  FAR uIntf;
22528415Spetertypedef uLong FAR uLongf;
22628415Speter
22728415Speter#ifdef STDC
22828415Speter   typedef void FAR *voidpf;
22928415Speter   typedef void     *voidp;
23028415Speter#else
23128415Speter   typedef Byte FAR *voidpf;
23228415Speter   typedef Byte     *voidp;
23328415Speter#endif
23428415Speter
23528415Speter
23634768Speter/* Compile with -DZLIB_DLL for Windows DLL support */
23734768Speter#if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL)
23834768Speter#  include <windows.h>
23934768Speter#  define EXPORT  WINAPI
24034768Speter#else
24134768Speter#  define EXPORT
24234768Speter#endif
24328415Speter
24434768Speter#endif /* _ZCONF_H */
24534768Speter/* --- zconf.h */
24634768Speter
24734768Speter#define ZLIB_VERSION "1.0.4P"
24834768Speter
24928415Speter/*
25028415Speter     The 'zlib' compression library provides in-memory compression and
25128415Speter  decompression functions, including integrity checks of the uncompressed
25228415Speter  data.  This version of the library supports only one compression method
25328415Speter  (deflation) but other algorithms may be added later and will have the same
25428415Speter  stream interface.
25528415Speter
25628415Speter     For compression the application must provide the output buffer and
25728415Speter  may optionally provide the input buffer for optimization. For decompression,
25828415Speter  the application must provide the input buffer and may optionally provide
25928415Speter  the output buffer for optimization.
26028415Speter
26128415Speter     Compression can be done in a single step if the buffers are large
26228415Speter  enough (for example if an input file is mmap'ed), or can be done by
26328415Speter  repeated calls of the compression function.  In the latter case, the
26428415Speter  application must provide more input and/or consume the output
26528415Speter  (providing more output space) before each call.
26634768Speter
26734768Speter     The library does not install any signal handler. It is recommended to
26834768Speter  add at least a handler for SIGSEGV when decompressing; the library checks
26934768Speter  the consistency of the input data whenever possible but may go nuts
27034768Speter  for some forms of corrupted input.
27128415Speter*/
27228415Speter
27328415Spetertypedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
27434768Spetertypedef void   (*free_func)  OF((voidpf opaque, voidpf address));
27528415Speter
27628415Speterstruct internal_state;
27728415Speter
27828415Spetertypedef struct z_stream_s {
27928415Speter    Bytef    *next_in;  /* next input byte */
28028415Speter    uInt     avail_in;  /* number of bytes available at next_in */
28128415Speter    uLong    total_in;  /* total nb of input bytes read so far */
28228415Speter
28328415Speter    Bytef    *next_out; /* next output byte should be put there */
28428415Speter    uInt     avail_out; /* remaining free space at next_out */
28528415Speter    uLong    total_out; /* total nb of bytes output so far */
28628415Speter
28743305Sdillon    const char     *msg; /* last error message, NULL if no error */
28828415Speter    struct internal_state FAR *state; /* not visible by applications */
28928415Speter
29028415Speter    alloc_func zalloc;  /* used to allocate the internal state */
29128415Speter    free_func  zfree;   /* used to free the internal state */
29234768Speter    voidpf     opaque;  /* private data object passed to zalloc and zfree */
29328415Speter
29434768Speter    int     data_type;  /* best guess about the data type: ascii or binary */
29534768Speter    uLong   adler;      /* adler32 value of the uncompressed data */
29634768Speter    uLong   reserved;   /* reserved for future use */
29728415Speter} z_stream;
29828415Speter
29934768Spetertypedef z_stream FAR *z_streamp;
30034768Speter
30128415Speter/*
30228415Speter   The application must update next_in and avail_in when avail_in has
30328415Speter   dropped to zero. It must update next_out and avail_out when avail_out
30428415Speter   has dropped to zero. The application must initialize zalloc, zfree and
30528415Speter   opaque before calling the init function. All other fields are set by the
30628415Speter   compression library and must not be updated by the application.
30728415Speter
30828415Speter   The opaque value provided by the application will be passed as the first
30928415Speter   parameter for calls of zalloc and zfree. This can be useful for custom
31028415Speter   memory management. The compression library attaches no meaning to the
31128415Speter   opaque value.
31228415Speter
31328415Speter   zalloc must return Z_NULL if there is not enough memory for the object.
31428415Speter   On 16-bit systems, the functions zalloc and zfree must be able to allocate
31528415Speter   exactly 65536 bytes, but will not be required to allocate more than this
31628415Speter   if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
31728415Speter   pointers returned by zalloc for objects of exactly 65536 bytes *must*
31828415Speter   have their offset normalized to zero. The default allocation function
31928415Speter   provided by this library ensures this (see zutil.c). To reduce memory
32028415Speter   requirements and avoid any allocation of 64K objects, at the expense of
32128415Speter   compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
32228415Speter
32328415Speter   The fields total_in and total_out can be used for statistics or
32428415Speter   progress reports. After compression, total_in holds the total size of
32528415Speter   the uncompressed data and may be saved for use in the decompressor
32628415Speter   (particularly if the decompressor wants to decompress everything in
32728415Speter   a single step).
32828415Speter*/
32928415Speter
33028415Speter                        /* constants */
33128415Speter
33228415Speter#define Z_NO_FLUSH      0
33328415Speter#define Z_PARTIAL_FLUSH 1
33434768Speter#define Z_PACKET_FLUSH	2
33534768Speter#define Z_SYNC_FLUSH    3
33634768Speter#define Z_FULL_FLUSH    4
33734768Speter#define Z_FINISH        5
33834768Speter/* Allowed flush values; see deflate() below for details */
33928415Speter
34028415Speter#define Z_OK            0
34128415Speter#define Z_STREAM_END    1
34234768Speter#define Z_NEED_DICT     2
34328415Speter#define Z_ERRNO        (-1)
34428415Speter#define Z_STREAM_ERROR (-2)
34528415Speter#define Z_DATA_ERROR   (-3)
34628415Speter#define Z_MEM_ERROR    (-4)
34728415Speter#define Z_BUF_ERROR    (-5)
34834768Speter#define Z_VERSION_ERROR (-6)
34934768Speter/* Return codes for the compression/decompression functions. Negative
35034768Speter * values are errors, positive values are used for special but normal events.
35134768Speter */
35228415Speter
35334768Speter#define Z_NO_COMPRESSION         0
35428415Speter#define Z_BEST_SPEED             1
35528415Speter#define Z_BEST_COMPRESSION       9
35628415Speter#define Z_DEFAULT_COMPRESSION  (-1)
35728415Speter/* compression levels */
35828415Speter
35928415Speter#define Z_FILTERED            1
36028415Speter#define Z_HUFFMAN_ONLY        2
36128415Speter#define Z_DEFAULT_STRATEGY    0
36234768Speter/* compression strategy; see deflateInit2() below for details */
36328415Speter
36428415Speter#define Z_BINARY   0
36528415Speter#define Z_ASCII    1
36628415Speter#define Z_UNKNOWN  2
36734768Speter/* Possible values of the data_type field */
36828415Speter
36934768Speter#define Z_DEFLATED   8
37034768Speter/* The deflate compression method (the only one supported in this version) */
37134768Speter
37228415Speter#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
37328415Speter
37434768Speter#define zlib_version zlibVersion()
37534768Speter/* for compatibility with versions < 1.0.2 */
37634768Speter
37734768Speter                        /* basic functions */
37834768Speter
37934768Speterextern const char * EXPORT zlibVersion OF((void));
38034768Speter/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
38128415Speter   If the first character differs, the library code actually used is
38228415Speter   not compatible with the zlib.h header file used by the application.
38334768Speter   This check is automatically made by deflateInit and inflateInit.
38428415Speter */
38528415Speter
38634768Speter/*
38734768Speterextern int EXPORT deflateInit OF((z_streamp strm, int level));
38828415Speter
38928415Speter     Initializes the internal stream state for compression. The fields
39028415Speter   zalloc, zfree and opaque must be initialized before by the caller.
39128415Speter   If zalloc and zfree are set to Z_NULL, deflateInit updates them to
39228415Speter   use default allocation functions.
39328415Speter
39434768Speter     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
39534768Speter   1 gives best speed, 9 gives best compression, 0 gives no compression at
39634768Speter   all (the input data is simply copied a block at a time).
39734768Speter   Z_DEFAULT_COMPRESSION requests a default compromise between speed and
39834768Speter   compression (currently equivalent to level 6).
39928415Speter
40028415Speter     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
40134768Speter   enough memory, Z_STREAM_ERROR if level is not a valid compression level,
40234768Speter   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
40334768Speter   with the version assumed by the caller (ZLIB_VERSION).
40428415Speter   msg is set to null if there is no error message.  deflateInit does not
40528415Speter   perform any compression: this will be done by deflate().
40628415Speter*/
40728415Speter
40828415Speter
40934768Speterextern int EXPORT deflate OF((z_streamp strm, int flush));
41028415Speter/*
41128415Speter  Performs one or both of the following actions:
41228415Speter
41328415Speter  - Compress more input starting at next_in and update next_in and avail_in
41428415Speter    accordingly. If not all input can be processed (because there is not
41528415Speter    enough room in the output buffer), next_in and avail_in are updated and
41628415Speter    processing will resume at this point for the next call of deflate().
41728415Speter
41828415Speter  - Provide more output starting at next_out and update next_out and avail_out
41928415Speter    accordingly. This action is forced if the parameter flush is non zero.
42028415Speter    Forcing flush frequently degrades the compression ratio, so this parameter
42128415Speter    should be set only when necessary (in interactive applications).
42228415Speter    Some output may be provided even if flush is not set.
42328415Speter
42428415Speter  Before the call of deflate(), the application should ensure that at least
42528415Speter  one of the actions is possible, by providing more input and/or consuming
42628415Speter  more output, and updating avail_in or avail_out accordingly; avail_out
42728415Speter  should never be zero before the call. The application can consume the
42828415Speter  compressed output when it wants, for example when the output buffer is full
42934768Speter  (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
43034768Speter  and with zero avail_out, it must be called again after making room in the
43134768Speter  output buffer because there might be more output pending.
43228415Speter
43328415Speter    If the parameter flush is set to Z_PARTIAL_FLUSH, the current compression
43428415Speter  block is terminated and flushed to the output buffer so that the
43528415Speter  decompressor can get all input data available so far. For method 9, a future
43628415Speter  variant on method 8, the current block will be flushed but not terminated.
43734768Speter  Z_SYNC_FLUSH has the same effect as partial flush except that the compressed
43834768Speter  output is byte aligned (the compressor can clear its internal bit buffer)
43934768Speter  and the current block is always terminated; this can be useful if the
44034768Speter  compressor has to be restarted from scratch after an interruption (in which
44134768Speter  case the internal state of the compressor may be lost).
44234768Speter    If flush is set to Z_FULL_FLUSH, the compression block is terminated, a
44328415Speter  special marker is output and the compression dictionary is discarded; this
44428415Speter  is useful to allow the decompressor to synchronize if one compressed block
44528415Speter  has been damaged (see inflateSync below).  Flushing degrades compression and
44628415Speter  so should be used only when necessary.  Using Z_FULL_FLUSH too often can
44728415Speter  seriously degrade the compression. If deflate returns with avail_out == 0,
44828415Speter  this function must be called again with the same value of the flush
44928415Speter  parameter and more output space (updated avail_out), until the flush is
45028415Speter  complete (deflate returns with non-zero avail_out).
45128415Speter
45228415Speter    If the parameter flush is set to Z_PACKET_FLUSH, the compression
45328415Speter  block is terminated, and a zero-length stored block is output,
45428415Speter  omitting the length bytes (the effect of this is that the 3-bit type
45528415Speter  code 000 for a stored block is output, and the output is then
45628415Speter  byte-aligned).  This is designed for use at the end of a PPP packet.
45728415Speter
45834768Speter    If the parameter flush is set to Z_FINISH, pending input is processed,
45934768Speter  pending output is flushed and deflate returns with Z_STREAM_END if there
46028415Speter  was enough output space; if deflate returns with Z_OK, this function must be
46128415Speter  called again with Z_FINISH and more output space (updated avail_out) but no
46228415Speter  more input data, until it returns with Z_STREAM_END or an error. After
46328415Speter  deflate has returned Z_STREAM_END, the only possible operations on the
46428415Speter  stream are deflateReset or deflateEnd.
46528415Speter
46628415Speter    Z_FINISH can be used immediately after deflateInit if all the compression
46728415Speter  is to be done in a single step. In this case, avail_out must be at least
46828415Speter  0.1% larger than avail_in plus 12 bytes.  If deflate does not return
46928415Speter  Z_STREAM_END, then it must be called again as described above.
47028415Speter
47128415Speter    deflate() may update data_type if it can make a good guess about
47228415Speter  the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
47328415Speter  binary. This field is only for information purposes and does not affect
47428415Speter  the compression algorithm in any manner.
47528415Speter
47628415Speter    deflate() returns Z_OK if some progress has been made (more input
47728415Speter  processed or more output produced), Z_STREAM_END if all input has been
47828415Speter  consumed and all output has been produced (only when flush is set to
47928415Speter  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
48028415Speter  if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible.
48128415Speter*/
48228415Speter
48328415Speter
48434768Speterextern int EXPORT deflateEnd OF((z_streamp strm));
48528415Speter/*
48628415Speter     All dynamically allocated data structures for this stream are freed.
48728415Speter   This function discards any unprocessed input and does not flush any
48828415Speter   pending output.
48928415Speter
49028415Speter     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
49134768Speter   stream state was inconsistent, Z_DATA_ERROR if the stream was freed
49234768Speter   prematurely (some input or output was discarded). In the error case,
49334768Speter   msg may be set but then points to a static string (which must not be
49434768Speter   deallocated).
49528415Speter*/
49628415Speter
49728415Speter
49828415Speter/*
49934768Speterextern int EXPORT inflateInit OF((z_streamp strm));
50034768Speter
50128415Speter     Initializes the internal stream state for decompression. The fields
50234768Speter   zalloc, zfree and opaque must be initialized before by the caller.  If
50334768Speter   zalloc and zfree are set to Z_NULL, inflateInit updates them to use default
50434768Speter   allocation functions.
50528415Speter
50628415Speter     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
50734768Speter   enough memory, Z_VERSION_ERROR if the zlib library version is incompatible
50834768Speter   with the version assumed by the caller.  msg is set to null if there is no
50934768Speter   error message. inflateInit does not perform any decompression: this will be
51034768Speter   done by inflate().
51128415Speter*/
51228415Speter
51355205Speter#if defined(__FreeBSD__) && defined(_KERNEL)
514245102Speter#define inflate       _zlib104_inflate     /* FreeBSD already has an inflate :-( */
51528415Speter#endif
51628415Speter
51734768Speterextern int EXPORT inflate OF((z_streamp strm, int flush));
51828415Speter/*
51928415Speter  Performs one or both of the following actions:
52028415Speter
52128415Speter  - Decompress more input starting at next_in and update next_in and avail_in
52228415Speter    accordingly. If not all input can be processed (because there is not
52328415Speter    enough room in the output buffer), next_in is updated and processing
52428415Speter    will resume at this point for the next call of inflate().
52528415Speter
52628415Speter  - Provide more output starting at next_out and update next_out and avail_out
52734768Speter    accordingly.  inflate() provides as much output as possible, until there
52834768Speter    is no more input data or no more space in the output buffer (see below
52934768Speter    about the flush parameter).
53028415Speter
53128415Speter  Before the call of inflate(), the application should ensure that at least
53228415Speter  one of the actions is possible, by providing more input and/or consuming
53328415Speter  more output, and updating the next_* and avail_* values accordingly.
53428415Speter  The application can consume the uncompressed output when it wants, for
53528415Speter  example when the output buffer is full (avail_out == 0), or after each
53634768Speter  call of inflate(). If inflate returns Z_OK and with zero avail_out, it
53734768Speter  must be called again after making room in the output buffer because there
53834768Speter  might be more output pending.
53928415Speter
54028415Speter    If the parameter flush is set to Z_PARTIAL_FLUSH or Z_PACKET_FLUSH,
54128415Speter  inflate flushes as much output as possible to the output buffer. The
54228415Speter  flushing behavior of inflate is not specified for values of the flush
54328415Speter  parameter other than Z_PARTIAL_FLUSH, Z_PACKET_FLUSH or Z_FINISH, but the
54428415Speter  current implementation actually flushes as much output as possible
54528415Speter  anyway.  For Z_PACKET_FLUSH, inflate checks that once all the input data
54628415Speter  has been consumed, it is expecting to see the length field of a stored
54728415Speter  block; if not, it returns Z_DATA_ERROR.
54828415Speter
54928415Speter    inflate() should normally be called until it returns Z_STREAM_END or an
55028415Speter  error. However if all decompression is to be performed in a single step
55128415Speter  (a single call of inflate), the parameter flush should be set to
55228415Speter  Z_FINISH. In this case all pending input is processed and all pending
55328415Speter  output is flushed; avail_out must be large enough to hold all the
55428415Speter  uncompressed data. (The size of the uncompressed data may have been saved
55528415Speter  by the compressor for this purpose.) The next operation on this stream must
55628415Speter  be inflateEnd to deallocate the decompression state. The use of Z_FINISH
55728415Speter  is never required, but can be used to inform inflate that a faster routine
55828415Speter  may be used for the single inflate() call.
55928415Speter
56028415Speter    inflate() returns Z_OK if some progress has been made (more input
56128415Speter  processed or more output produced), Z_STREAM_END if the end of the
56228415Speter  compressed data has been reached and all uncompressed output has been
56334768Speter  produced, Z_NEED_DICT if a preset dictionary is needed at this point (see
56434768Speter  inflateSetDictionary below), Z_DATA_ERROR if the input data was corrupted,
56534768Speter  Z_STREAM_ERROR if the stream structure was inconsistent (for example if
56634768Speter  next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
56734768Speter  Z_BUF_ERROR if no progress is possible or if there was not enough room in
56834768Speter  the output buffer when Z_FINISH is used. In the Z_DATA_ERROR case, the
56934768Speter  application may then call inflateSync to look for a good compression block.
57034768Speter  In the Z_NEED_DICT case, strm->adler is set to the Adler32 value of the
57134768Speter  dictionary chosen by the compressor.
57234768Speter*/
57328415Speter
57428415Speter
57534768Speterextern int EXPORT inflateEnd OF((z_streamp strm));
57628415Speter/*
57728415Speter     All dynamically allocated data structures for this stream are freed.
57828415Speter   This function discards any unprocessed input and does not flush any
57928415Speter   pending output.
58028415Speter
58128415Speter     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
58228415Speter   was inconsistent. In the error case, msg may be set but then points to a
58328415Speter   static string (which must not be deallocated).
58428415Speter*/
58528415Speter
58634768Speter                        /* Advanced functions */
58728415Speter
58828415Speter/*
58928415Speter    The following functions are needed only in some special applications.
59028415Speter*/
59128415Speter
59228415Speter/*
59334768Speterextern int EXPORT deflateInit2 OF((z_streamp strm,
59434768Speter                                   int  level,
59534768Speter                                   int  method,
59634768Speter                                   int  windowBits,
59734768Speter                                   int  memLevel,
59834768Speter                                   int  strategy));
59934768Speter
60028415Speter     This is another version of deflateInit with more compression options. The
60134768Speter   fields next_in, zalloc, zfree and opaque must be initialized before by
60234768Speter   the caller.
60328415Speter
60434768Speter     The method parameter is the compression method. It must be Z_DEFLATED in
60534768Speter   this version of the library. (Method 9 will allow a 64K history buffer and
60628415Speter   partial block flushes.)
60728415Speter
60828415Speter     The windowBits parameter is the base two logarithm of the window size
60928415Speter   (the size of the history buffer).  It should be in the range 8..15 for this
61028415Speter   version of the library (the value 16 will be allowed for method 9). Larger
61128415Speter   values of this parameter result in better compression at the expense of
61228415Speter   memory usage. The default value is 15 if deflateInit is used instead.
61328415Speter
61434768Speter     The memLevel parameter specifies how much memory should be allocated
61528415Speter   for the internal compression state. memLevel=1 uses minimum memory but
61628415Speter   is slow and reduces compression ratio; memLevel=9 uses maximum memory
61728415Speter   for optimal speed. The default value is 8. See zconf.h for total memory
61828415Speter   usage as a function of windowBits and memLevel.
61928415Speter
62034768Speter     The strategy parameter is used to tune the compression algorithm. Use the
62134768Speter   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
62234768Speter   filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
62334768Speter   string match).  Filtered data consists mostly of small values with a
62434768Speter   somewhat random distribution. In this case, the compression algorithm is
62534768Speter   tuned to compress them better. The effect of Z_FILTERED is to force more
62634768Speter   Huffman coding and less string matching; it is somewhat intermediate
62734768Speter   between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
62834768Speter   the compression ratio but not the correctness of the compressed output even
62934768Speter   if it is not set appropriately.
63028415Speter
63128415Speter     If next_in is not null, the library will use this buffer to hold also
63228415Speter   some history information; the buffer must either hold the entire input
63328415Speter   data, or have at least 1<<(windowBits+1) bytes and be writable. If next_in
63428415Speter   is null, the library will allocate its own history buffer (and leave next_in
63528415Speter   null). next_out need not be provided here but must be provided by the
63628415Speter   application for the next call of deflate().
63728415Speter
63828415Speter     If the history buffer is provided by the application, next_in must
63928415Speter   must never be changed by the application since the compressor maintains
64028415Speter   information inside this buffer from call to call; the application
64128415Speter   must provide more input only by increasing avail_in. next_in is always
64228415Speter   reset by the library in this case.
64328415Speter
64428415Speter      deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was
64528415Speter   not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
64628415Speter   an invalid method). msg is set to null if there is no error message.
64728415Speter   deflateInit2 does not perform any compression: this will be done by
64834768Speter   deflate().
64928415Speter*/
65028415Speter
65134768Speterextern int EXPORT deflateSetDictionary OF((z_streamp strm,
65234768Speter                                           const Bytef *dictionary,
65334768Speter				           uInt  dictLength));
65428415Speter/*
65534768Speter     Initializes the compression dictionary (history buffer) from the given
65634768Speter   byte sequence without producing any compressed output. This function must
65734768Speter   be called immediately after deflateInit or deflateInit2, before any call
65834768Speter   of deflate. The compressor and decompressor must use exactly the same
65934768Speter   dictionary (see inflateSetDictionary).
66034768Speter     The dictionary should consist of strings (byte sequences) that are likely
66134768Speter   to be encountered later in the data to be compressed, with the most commonly
66234768Speter   used strings preferably put towards the end of the dictionary. Using a
66334768Speter   dictionary is most useful when the data to be compressed is short and
66434768Speter   can be predicted with good accuracy; the data can then be compressed better
66534768Speter   than with the default empty dictionary. In this version of the library,
66634768Speter   only the last 32K bytes of the dictionary are used.
66734768Speter     Upon return of this function, strm->adler is set to the Adler32 value
66834768Speter   of the dictionary; the decompressor may later use this value to determine
66934768Speter   which dictionary has been used by the compressor. (The Adler32 value
67034768Speter   applies to the whole dictionary even if only a subset of the dictionary is
67134768Speter   actually used by the compressor.)
67234768Speter
67334768Speter     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
67434768Speter   parameter is invalid (such as NULL dictionary) or the stream state
67534768Speter   is inconsistent (for example if deflate has already been called for this
67634768Speter   stream). deflateSetDictionary does not perform any compression: this will
67734768Speter   be done by deflate().
67834768Speter*/
67934768Speter
68034768Speterextern int EXPORT deflateCopy OF((z_streamp dest,
68134768Speter                                  z_streamp source));
68234768Speter/*
68328415Speter     Sets the destination stream as a complete copy of the source stream.  If
68428415Speter   the source stream is using an application-supplied history buffer, a new
68528415Speter   buffer is allocated for the destination stream.  The compressed output
68628415Speter   buffer is always application-supplied. It's the responsibility of the
68728415Speter   application to provide the correct values of next_out and avail_out for the
68828415Speter   next call of deflate.
68928415Speter
69034768Speter     This function can be useful when several compression strategies will be
69128415Speter   tried, for example when there are several ways of pre-processing the input
69228415Speter   data with a filter. The streams that will be discarded should then be freed
69328415Speter   by calling deflateEnd.  Note that deflateCopy duplicates the internal
69428415Speter   compression state which can be quite large, so this strategy is slow and
69528415Speter   can consume lots of memory.
69628415Speter
69734768Speter     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
69828415Speter   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
69928415Speter   (such as zalloc being NULL). msg is left unchanged in both source and
70028415Speter   destination.
70128415Speter*/
70228415Speter
70334768Speterextern int EXPORT deflateReset OF((z_streamp strm));
70428415Speter/*
70528415Speter     This function is equivalent to deflateEnd followed by deflateInit,
70628415Speter   but does not free and reallocate all the internal compression state.
70728415Speter   The stream will keep the same compression level and any other attributes
70828415Speter   that may have been set by deflateInit2.
70928415Speter
71028415Speter      deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
71128415Speter   stream state was inconsistent (such as zalloc or state being NULL).
71228415Speter*/
71328415Speter
71434768Speterextern int EXPORT deflateParams OF((z_streamp strm, int level, int strategy));
71534768Speter/*
71634768Speter     Dynamically update the compression level and compression strategy.
71734768Speter   This can be used to switch between compression and straight copy of
71834768Speter   the input data, or to switch to a different kind of input data requiring
71934768Speter   a different strategy. If the compression level is changed, the input
72034768Speter   available so far is compressed with the old level (and may be flushed);
72134768Speter   the new level will take effect only at the next call of deflate().
72234768Speter
72334768Speter     Before the call of deflateParams, the stream state must be set as for
72434768Speter   a call of deflate(), since the currently available input may have to
72534768Speter   be compressed and flushed. In particular, strm->avail_out must be non-zero.
72634768Speter
72734768Speter     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
72834768Speter   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
72934768Speter   if strm->avail_out was zero.
73034768Speter*/
73134768Speter
73234768Speterextern int EXPORT deflateOutputPending OF((z_streamp strm));
73334768Speter/*
73434768Speter     Returns the number of bytes of output which are immediately
73534768Speter   available from the compressor (i.e. without any further input
73634768Speter   or flush).
73734768Speter*/
73834768Speter
73928415Speter/*
74034768Speterextern int EXPORT inflateInit2 OF((z_streamp strm,
74134768Speter                                   int  windowBits));
74234768Speter
74328415Speter     This is another version of inflateInit with more compression options. The
74434768Speter   fields next_out, zalloc, zfree and opaque must be initialized before by
74534768Speter   the caller.
74628415Speter
74728415Speter     The windowBits parameter is the base two logarithm of the maximum window
74828415Speter   size (the size of the history buffer).  It should be in the range 8..15 for
74928415Speter   this version of the library (the value 16 will be allowed soon). The
75028415Speter   default value is 15 if inflateInit is used instead. If a compressed stream
75128415Speter   with a larger window size is given as input, inflate() will return with
75228415Speter   the error code Z_DATA_ERROR instead of trying to allocate a larger window.
75328415Speter
75428415Speter     If next_out is not null, the library will use this buffer for the history
75528415Speter   buffer; the buffer must either be large enough to hold the entire output
75628415Speter   data, or have at least 1<<windowBits bytes.  If next_out is null, the
75728415Speter   library will allocate its own buffer (and leave next_out null). next_in
75828415Speter   need not be provided here but must be provided by the application for the
75928415Speter   next call of inflate().
76028415Speter
76128415Speter     If the history buffer is provided by the application, next_out must
76228415Speter   never be changed by the application since the decompressor maintains
76328415Speter   history information inside this buffer from call to call; the application
76428415Speter   can only reset next_out to the beginning of the history buffer when
76528415Speter   avail_out is zero and all output has been consumed.
76628415Speter
76728415Speter      inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was
76828415Speter   not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
76928415Speter   windowBits < 8). msg is set to null if there is no error message.
77028415Speter   inflateInit2 does not perform any decompression: this will be done by
77128415Speter   inflate().
77228415Speter*/
77328415Speter
77434768Speterextern int EXPORT inflateSetDictionary OF((z_streamp strm,
77534768Speter				           const Bytef *dictionary,
77634768Speter					   uInt  dictLength));
77734768Speter/*
77834768Speter     Initializes the decompression dictionary (history buffer) from the given
77934768Speter   uncompressed byte sequence. This function must be called immediately after
78034768Speter   a call of inflate if this call returned Z_NEED_DICT. The dictionary chosen
78134768Speter   by the compressor can be determined from the Adler32 value returned by this
78234768Speter   call of inflate. The compressor and decompressor must use exactly the same
78334768Speter   dictionary (see deflateSetDictionary).
78434768Speter
78534768Speter     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
78634768Speter   parameter is invalid (such as NULL dictionary) or the stream state is
78734768Speter   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
78834768Speter   expected one (incorrect Adler32 value). inflateSetDictionary does not
78934768Speter   perform any decompression: this will be done by subsequent calls of
79034768Speter   inflate().
79134768Speter*/
79234768Speter
79334768Speterextern int EXPORT inflateSync OF((z_streamp strm));
79428415Speter/*
79528415Speter    Skips invalid compressed data until the special marker (see deflate()
79628415Speter  above) can be found, or until all available input is skipped. No output
79728415Speter  is provided.
79828415Speter
79928415Speter    inflateSync returns Z_OK if the special marker has been found, Z_BUF_ERROR
80028415Speter  if no more input was provided, Z_DATA_ERROR if no marker has been found,
80128415Speter  or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
80228415Speter  case, the application may save the current current value of total_in which
80328415Speter  indicates where valid compressed data was found. In the error case, the
80428415Speter  application may repeatedly call inflateSync, providing more input each time,
80528415Speter  until success or end of the input data.
80628415Speter*/
80728415Speter
80834768Speterextern int EXPORT inflateReset OF((z_streamp strm));
80928415Speter/*
81028415Speter     This function is equivalent to inflateEnd followed by inflateInit,
81128415Speter   but does not free and reallocate all the internal decompression state.
81228415Speter   The stream will keep attributes that may have been set by inflateInit2.
81328415Speter
81428415Speter      inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
81528415Speter   stream state was inconsistent (such as zalloc or state being NULL).
81628415Speter*/
81728415Speter
81828415Speterextern int inflateIncomp OF((z_stream *strm));
81928415Speter/*
82028415Speter     This function adds the data at next_in (avail_in bytes) to the output
82128415Speter   history without performing any output.  There must be no pending output,
82228415Speter   and the decompressor must be expecting to see the start of a block.
82328415Speter   Calling this function is equivalent to decompressing a stored block
82428415Speter   containing the data at next_in (except that the data is not output).
82528415Speter*/
82628415Speter
82734768Speter                        /* utility functions */
82834768Speter
82934768Speter/*
83034768Speter     The following utility functions are implemented on top of the
83134768Speter   basic stream-oriented functions. To simplify the interface, some
83234768Speter   default options are assumed (compression level, window size,
83334768Speter   standard memory allocation functions). The source code of these
83434768Speter   utility functions can easily be modified if you need special options.
83534768Speter*/
83634768Speter
83734768Speterextern int EXPORT compress OF((Bytef *dest,   uLongf *destLen,
83834768Speter			       const Bytef *source, uLong sourceLen));
83934768Speter/*
84034768Speter     Compresses the source buffer into the destination buffer.  sourceLen is
84134768Speter   the byte length of the source buffer. Upon entry, destLen is the total
84234768Speter   size of the destination buffer, which must be at least 0.1% larger than
84334768Speter   sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
84434768Speter   compressed buffer.
84534768Speter     This function can be used to compress a whole file at once if the
84634768Speter   input file is mmap'ed.
84734768Speter     compress returns Z_OK if success, Z_MEM_ERROR if there was not
84834768Speter   enough memory, Z_BUF_ERROR if there was not enough room in the output
84934768Speter   buffer.
85034768Speter*/
85134768Speter
85234768Speterextern int EXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
85334768Speter				 const Bytef *source, uLong sourceLen));
85434768Speter/*
85534768Speter     Decompresses the source buffer into the destination buffer.  sourceLen is
85634768Speter   the byte length of the source buffer. Upon entry, destLen is the total
85734768Speter   size of the destination buffer, which must be large enough to hold the
85834768Speter   entire uncompressed data. (The size of the uncompressed data must have
85934768Speter   been saved previously by the compressor and transmitted to the decompressor
86034768Speter   by some mechanism outside the scope of this compression library.)
86134768Speter   Upon exit, destLen is the actual size of the compressed buffer.
86234768Speter     This function can be used to decompress a whole file at once if the
86334768Speter   input file is mmap'ed.
86434768Speter
86534768Speter     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
86634768Speter   enough memory, Z_BUF_ERROR if there was not enough room in the output
86734768Speter   buffer, or Z_DATA_ERROR if the input data was corrupted.
86834768Speter*/
86934768Speter
87034768Speter
87134768Spetertypedef voidp gzFile;
87234768Speter
87334768Speterextern gzFile EXPORT gzopen  OF((const char *path, const char *mode));
87434768Speter/*
87534768Speter     Opens a gzip (.gz) file for reading or writing. The mode parameter
87634768Speter   is as in fopen ("rb" or "wb") but can also include a compression level
87734768Speter   ("wb9").  gzopen can be used to read a file which is not in gzip format;
87834768Speter   in this case gzread will directly read from the file without decompression.
87934768Speter     gzopen returns NULL if the file could not be opened or if there was
88034768Speter   insufficient memory to allocate the (de)compression state; errno
88134768Speter   can be checked to distinguish the two cases (if errno is zero, the
88234768Speter   zlib error is Z_MEM_ERROR).
88334768Speter*/
88434768Speter
88534768Speterextern gzFile EXPORT gzdopen  OF((int fd, const char *mode));
88634768Speter/*
88734768Speter     gzdopen() associates a gzFile with the file descriptor fd.  File
88834768Speter   descriptors are obtained from calls like open, dup, creat, pipe or
88934768Speter   fileno (in the file has been previously opened with fopen).
89034768Speter   The mode parameter is as in gzopen.
89134768Speter     The next call of gzclose on the returned gzFile will also close the
89234768Speter   file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
89334768Speter   descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
89434768Speter     gzdopen returns NULL if there was insufficient memory to allocate
89534768Speter   the (de)compression state.
89634768Speter*/
89734768Speter
89834768Speterextern int EXPORT    gzread  OF((gzFile file, voidp buf, unsigned len));
89934768Speter/*
90034768Speter     Reads the given number of uncompressed bytes from the compressed file.
90134768Speter   If the input file was not in gzip format, gzread copies the given number
90234768Speter   of bytes into the buffer.
90334768Speter     gzread returns the number of uncompressed bytes actually read (0 for
90434768Speter   end of file, -1 for error). */
90534768Speter
90634768Speterextern int EXPORT    gzwrite OF((gzFile file, const voidp buf, unsigned len));
90734768Speter/*
90834768Speter     Writes the given number of uncompressed bytes into the compressed file.
90934768Speter   gzwrite returns the number of uncompressed bytes actually written
91034768Speter   (0 in case of error).
91134768Speter*/
91234768Speter
91334768Speterextern int EXPORT    gzflush OF((gzFile file, int flush));
91434768Speter/*
91534768Speter     Flushes all pending output into the compressed file. The parameter
91634768Speter   flush is as in the deflate() function. The return value is the zlib
91734768Speter   error number (see function gzerror below). gzflush returns Z_OK if
91834768Speter   the flush parameter is Z_FINISH and all output could be flushed.
91934768Speter     gzflush should be called only when strictly necessary because it can
92034768Speter   degrade compression.
92134768Speter*/
92234768Speter
92334768Speterextern int EXPORT    gzclose OF((gzFile file));
92434768Speter/*
92534768Speter     Flushes all pending output if necessary, closes the compressed file
92634768Speter   and deallocates all the (de)compression state. The return value is the zlib
92734768Speter   error number (see function gzerror below).
92834768Speter*/
92934768Speter
93034768Speterextern const char * EXPORT gzerror OF((gzFile file, int *errnum));
93134768Speter/*
93234768Speter     Returns the error message for the last error which occurred on the
93334768Speter   given compressed file. errnum is set to zlib error number. If an
93496755Strhodes   error occurred in the filesystem and not in the compression library,
93534768Speter   errnum is set to Z_ERRNO and the application may consult errno
93634768Speter   to get the exact error code.
93734768Speter*/
93834768Speter
93928415Speter                        /* checksum functions */
94028415Speter
94128415Speter/*
94234768Speter     These functions are not related to compression but are exported
94334768Speter   anyway because they might be useful in applications using the
94428415Speter   compression library.
94528415Speter*/
94628415Speter
94734768Speterextern uLong EXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
94828415Speter
94928415Speter/*
95028415Speter     Update a running Adler-32 checksum with the bytes buf[0..len-1] and
95128415Speter   return the updated checksum. If buf is NULL, this function returns
95228415Speter   the required initial value for the checksum.
95328415Speter   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
95428415Speter   much faster. Usage example:
95528415Speter
95628415Speter     uLong adler = adler32(0L, Z_NULL, 0);
95728415Speter
95828415Speter     while (read_buffer(buffer, length) != EOF) {
95928415Speter       adler = adler32(adler, buffer, length);
96028415Speter     }
96128415Speter     if (adler != original_adler) error();
96228415Speter*/
96328415Speter
96497512Sphk#if 0
96534768Speterextern uLong EXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
96634768Speter/*
96734768Speter     Update a running crc with the bytes buf[0..len-1] and return the updated
96834768Speter   crc. If buf is NULL, this function returns the required initial value
96934768Speter   for the crc. Pre- and post-conditioning (one's complement) is performed
97034768Speter   within this function so it shouldn't be done by the application.
97134768Speter   Usage example:
97234768Speter
97334768Speter     uLong crc = crc32(0L, Z_NULL, 0);
97434768Speter
97534768Speter     while (read_buffer(buffer, length) != EOF) {
97634768Speter       crc = crc32(crc, buffer, length);
97734768Speter     }
97834768Speter     if (crc != original_crc) error();
97934768Speter*/
98097512Sphk#endif
98134768Speter
98234768Speter
98334768Speter                        /* various hacks, don't look :) */
98434768Speter
98534768Speter/* deflateInit and inflateInit are macros to allow checking the zlib version
98634768Speter * and the compiler's view of z_stream:
98734768Speter */
98834768Speterextern int EXPORT deflateInit_ OF((z_streamp strm, int level,
98934768Speter			           const char *version, int stream_size));
99034768Speterextern int EXPORT inflateInit_ OF((z_streamp strm,
99134768Speter				   const char *version, int stream_size));
99234768Speterextern int EXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
99334768Speter				    int windowBits, int memLevel, int strategy,
99434768Speter				    const char *version, int stream_size));
99534768Speterextern int EXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
99634768Speter				    const char *version, int stream_size));
99734768Speter#define deflateInit(strm, level) \
99834768Speter        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
99934768Speter#define inflateInit(strm) \
100034768Speter        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
100134768Speter#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
100234768Speter        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
100334768Speter		      (strategy),           ZLIB_VERSION, sizeof(z_stream))
100434768Speter#define inflateInit2(strm, windowBits) \
100534768Speter        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
100634768Speter
100734768Speter#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
100828415Speter    struct internal_state {int dummy;}; /* hack for buggy compilers */
100928415Speter#endif
101028415Speter
101134768SpeteruLongf *get_crc_table OF((void)); /* can be used by asm versions of crc32() */
101234768Speter
1013204552Salfred#ifdef _KERNEL
1014204552Salfredstruct vnode;
1015204552Salfredextern gzFile gz_open     OF((const char *path, const char *mode,
1016204552Salfred	                              struct vnode *vp));
1017204552Salfred#endif
1018204552Salfred
1019204552Salfred
102034768Speter#ifdef __cplusplus
102134768Speter}
102234768Speter#endif
102334768Speter
102428415Speter#endif /* _ZLIB_H */
102534768Speter/* --- zlib.h */
1026