4 { Original:
5 zlib.h -- interface of the 'zlib' general purpose compression library
6 version 1.1.0, Feb 24th, 1998
8 Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
10 This software is provided 'as-is', without any express or implied
11 warranty. In no event will the authors be held liable for any damages
12 arising from the use of this software.
14 Permission is granted to anyone to use this software for any purpose,
15 including commercial applications, and to alter it and redistribute it
16 freely, subject to the following restrictions:
18 1. The origin of this software must not be misrepresented; you must not
19 claim that you wrote the original software. If you use this software
20 in a product, an acknowledgment in the product documentation would be
21 appreciated but is not required.
22 2. Altered source versions must be plainly marked as such, and must not be
23 misrepresented as being the original software.
24 3. This notice may not be removed or altered from any source distribution.
26 Jean-loup Gailly Mark Adler
27 jloup@gzip.org madler@alumni.caltech.edu
30 The data format used by the zlib library is described by RFCs (Request for
31 Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
32 (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
35 Pascal tranlastion
36 Copyright (C) 1998 by Jacques Nomssi Nzali
37 For conditions of distribution and use, see copyright notice in readme.txt
38 }
40 interface
42 {$I imzconf.inc}
44 uses
45 imzutil;
47 { zconf.h -- configuration of the zlib compression library }
48 { zutil.c -- target dependent utility functions for the compression library }
50 { The 'zlib' compression library provides in-memory compression and
51 decompression functions, including integrity checks of the uncompressed
52 data. This version of the library supports only one compression method
53 (deflation) but other algorithms will be added later and will have the same
54 stream interface.
56 Compression can be done in a single step if the buffers are large
57 enough (for example if an input file is mmap'ed), or can be done by
58 repeated calls of the compression function. In the latter case, the
59 application must provide more input and/or consume the output
60 (providing more output space) before each call.
62 The library also supports reading and writing files in gzip (.gz) format
63 with an interface similar to that of stdio.
65 The library does not install any signal handler. The decoder checks
66 the consistency of the compressed data, so the library should never
67 crash even in case of corrupted input. }
71 { Compile with -DMAXSEG_64K if the alloc function cannot allocate more
72 than 64k bytes at a time (needed on systems with 16-bit int). }
74 { Maximum value for memLevel in deflateInit2 }
75 const
79 { Maximum value for windowBits in deflateInit2 and inflateInit2 }
80 const
83 { default windowBits for decompression. MAX_WBITS is for compression only }
84 const
87 { The memory requirements for deflate are (in bytes):
88 1 shl (windowBits+2) + 1 shl (memLevel+9)
89 that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
90 plus a few kilobytes for small objects. For example, if you want to reduce
91 the default memory requirements from 256K to 128K, compile with
92 DMAX_WBITS=14 DMAX_MEM_LEVEL=7
93 Of course this will generally degrade compression (there's no free lunch).
95 The memory requirements for inflate are (in bytes) 1 shl windowBits
96 that is, 32K for windowBits=15 (default value) plus a few kilobytes
97 for small objects. }
100 { Huffman code lookup table entry--this entry is four bytes for machines
101 that have 16-bit pointers (e.g. PC's in the small or medium model). }
103 type
109 { 16-bit, 8 bytes for 32-bit int's) }
111 { or table offset }
114 type
117 type
120 type
133 { inflate codes private state }
134 type
140 { mode dependent information }
155 { mode independent information }
162 type
165 {const buf : array of byte;}
167 type
168 inflate_block_mode =
180 type
183 { inflate blocks semi-private state }
188 { mode dependent information }
207 { mode independent information }
219 type
220 inflate_mode = (
236 { inflate private state }
237 type
243 { mode dependent information }
254 { mode independent information }
260 type
264 type
288 { The application must update next_in and avail_in when avail_in has
289 dropped to zero. It must update next_out and avail_out when avail_out
290 has dropped to zero. The application must initialize zalloc, zfree and
291 opaque before calling the init function. All other fields are set by the
292 compression library and must not be updated by the application.
294 The opaque value provided by the application will be passed as the first
295 parameter for calls of zalloc and zfree. This can be useful for custom
296 memory management. The compression library attaches no meaning to the
297 opaque value.
299 zalloc must return Z_NULL if there is not enough memory for the object.
300 On 16-bit systems, the functions zalloc and zfree must be able to allocate
301 exactly 65536 bytes, but will not be required to allocate more than this
302 if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
303 pointers returned by zalloc for objects of exactly 65536 bytes *must*
304 have their offset normalized to zero. The default allocation function
305 provided by this library ensures this (see zutil.c). To reduce memory
306 requirements and avoid any allocation of 64K objects, at the expense of
307 compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
309 The fields total_in and total_out can be used for statistics or
310 progress reports. After compression, total_in holds the total size of
311 the uncompressed data and may be saved for use in the decompressor
312 (particularly if the decompressor wants to decompress everything in
313 a single step). }
321 { Allowed flush values; see deflate() below for details }
332 { Return codes for the compression/decompression functions. Negative
333 values are errors, positive values are used for special but normal events.}
339 { compression levels }
344 { compression strategy; see deflateInit2() below for details }
349 { Possible values of the data_type field }
352 { The deflate compression method (the only one supported in this version) }
356 {$IFDEF GZIO}
357 var
359 {$ENDIF}
361 { common constants }
364 { The three kinds of block type }
365 const
369 { The minimum and maximum match lengths }
370 const
374 const
378 {$IFDEF DEBUG}
380 {$ENDIF}
390 { The application can compare zlibVersion and ZLIB_VERSION for consistency.
391 If the first character differs, the library code actually used is
392 not compatible with the zlib.h header file used by the application.
393 This check is automatically made by deflateInit and inflateInit. }
400 const
403 const
416 const
424 {$IFDEF DEBUG}
426 {$ENDIF}
428 implementation
430 uses
435 begin
441 begin
446 begin
451 begin
456 begin
459 ReadLn;
464 begin
470 begin
475 begin
481 begin
487 begin
493 begin
499 begin
505 begin
510 begin
515 begin
516 {if @strm <> Z_NULL then}