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