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