4 #include <exec/types.h>
10 #define ZLIB_VERSION "1.2.4"
11 #define ZLIB_VERNUM 0x1240
12 #define ZLIB_VER_MAJOR 1
13 #define ZLIB_VER_MINOR 2
14 #define ZLIB_VER_REVISION 4
15 #define ZLIB_VER_SUBREVISION 0
18 The 'zlib' compression library provides in-memory compression and
19 decompression functions, including integrity checks of the uncompressed data.
20 This version of the library supports only one compression method (deflation)
21 but other algorithms will be added later and will have the same stream
24 Compression can be done in a single step if the buffers are large enough,
25 or can be done by repeated calls of the compression function. In the latter
26 case, the application must provide more input and/or consume the output
27 (providing more output space) before each call.
29 The compressed data format used by default by the in-memory functions is
30 the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
31 around a deflate stream, which is itself documented in RFC 1951.
33 The library also supports reading and writing files in gzip (.gz) format
34 with an interface similar to that of stdio using the functions that start
35 with "gz". The gzip format is different from the zlib format. gzip is a
36 gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
38 This library can optionally read and write gzip streams in memory as well.
40 The zlib format was designed to be compact and fast for use in memory
41 and on communications channels. The gzip format was designed for single-
42 file compression on file systems, has a larger header than zlib to maintain
43 directory information, and uses a different, slower check method than zlib.
45 The library does not install any signal handler. The decoder checks
46 the consistency of the compressed data, so the library should never crash
47 even in case of corrupted input.
50 typedef APTR (*alloc_func
) (APTR opaque
, ULONG items
, ULONG size
);
51 typedef void (*free_func
) (APTR opaque
, APTR address
);
53 struct internal_state
;
55 typedef struct z_stream_s
{
56 UBYTE
*next_in
; /* next input byte */
57 ULONG avail_in
; /* number of bytes available at next_in */
58 ULONG total_in
; /* total nb of input bytes read so far */
60 UBYTE
*next_out
; /* next output byte should be put there */
61 ULONG avail_out
; /* remaining free space at next_out */
62 ULONG total_out
; /* total nb of bytes output so far */
64 char *msg
; /* last error message, NULL if no error */
65 struct internal_state
*state
; /* not visible by applications */
67 alloc_func zalloc
; /* used to allocate the internal state */
68 free_func zfree
; /* used to free the internal state */
69 APTR opaque
; /* private data object passed to zalloc and zfree */
71 LONG data_type
; /* best guess about the data type: binary or text */
72 ULONG adler
; /* adler32 value of the uncompressed data */
73 ULONG reserved
; /* reserved for future use */
76 typedef z_stream
*z_streamp
;
79 gzip header information passed to and from zlib routines. See RFC 1952
80 for more details on the meanings of these fields.
82 typedef struct gz_header_s
{
83 LONG text
; /* true if compressed data believed to be text */
84 ULONG time
; /* modification time */
85 LONG xflags
; /* extra flags (not used when writing a gzip file) */
86 LONG os
; /* operating system */
87 UBYTE
*extra
; /* pointer to extra field or Z_NULL if none */
88 ULONG extra_len
; /* extra field length (valid if extra != Z_NULL) */
89 ULONG extra_max
; /* space at extra (only when reading header) */
90 UBYTE
*name
; /* pointer to zero-terminated file name or Z_NULL */
91 ULONG name_max
; /* space at name (only when reading header) */
92 UBYTE
*comment
; /* pointer to zero-terminated comment or Z_NULL */
93 ULONG comm_max
; /* space at comment (only when reading header) */
94 LONG hcrc
; /* true if there was or will be a header crc */
95 LONG done
; /* true when done reading gzip header (not used
96 when writing a gzip file) */
99 typedef gz_header
*gz_headerp
;
102 The application must update next_in and avail_in when avail_in has dropped
103 to zero. It must update next_out and avail_out when avail_out has dropped
104 to zero. The application must initialize zalloc, zfree and opaque before
105 calling the init function. All other fields are set by the compression
106 library and must not be updated by the application.
108 The opaque value provided by the application will be passed as the first
109 parameter for calls of zalloc and zfree. This can be useful for custom
110 memory management. The compression library attaches no meaning to the
113 zalloc must return Z_NULL if there is not enough memory for the object.
114 If zlib is used in a multi-threaded application, zalloc and zfree must be
117 On 16-bit systems, the functions zalloc and zfree must be able to allocate
118 exactly 65536 bytes, but will not be required to allocate more than this if
119 the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers
120 returned by zalloc for objects of exactly 65536 bytes *must* have their
121 offset normalized to zero. The default allocation function provided by this
122 library ensures this (see zutil.c). To reduce memory requirements and avoid
123 any allocation of 64K objects, at the expense of compression ratio, compile
124 the library with -DMAX_WBITS=14 (see zconf.h).
126 The fields total_in and total_out can be used for statistics or progress
127 reports. After compression, total_in holds the total size of the
128 uncompressed data and may be saved for use in the decompressor (particularly
129 if the decompressor wants to decompress everything in a single step).
135 #define Z_PARTIAL_FLUSH 1
136 #define Z_SYNC_FLUSH 2
137 #define Z_FULL_FLUSH 3
141 /* Allowed flush values; see deflate() and inflate() below for details */
144 #define Z_STREAM_END 1
145 #define Z_NEED_DICT 2
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 values
153 * are errors, positive values are used for special but normal events.
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 */
163 #define Z_HUFFMAN_ONLY 2
166 #define Z_DEFAULT_STRATEGY 0
167 /* compression strategy; see deflateInit2() below for details */
171 #define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
173 /* Possible values of the data_type field (though see inflate()) */
176 /* The deflate compression method (the only one supported in this version) */
178 #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
180 /* Typedefs for the interface */
182 typedef ULONG (*in_func
) (APTR
, UBYTE
**);
183 typedef LONG (*out_func
) (APTR
, UBYTE
*, ULONG
);