71
68
{ 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). }
69
than 64k bytes at a time (needed on systems with 16-bit integer). }
74
71
{ Maximum value for memLevel in deflateInit2 }
75
72
{$ifdef MAXSEG_64K}
78
DEF_MEM_LEVEL = MAX_MEM_LEVEL; { default memLevel }
76
DEF_MEM_LEVEL = MAX_MEM_LEVEL; { default memLevel }
80
DEF_MEM_LEVEL = MAX_MEM_LEVEL; { default memLevel }
85
88
{ Maximum value for windowBits in deflateInit2 and inflateInit2 }
91
MAX_WBITS = 14; { 32K LZ77 window }
87
93
MAX_WBITS = 15; { 32K LZ77 window }
88
96
{ default windowBits for decompression. MAX_WBITS is for compression only }
90
98
DEF_WBITS = MAX_WBITS;
101
type Pbytearray=^Tbytearray;
102
Pwordarray=^Twordarray;
103
Pcardinalarray=^Tcardinalarray;
105
Tbytearray = array [0..maxint div sizeof(byte)-1] of byte;
106
Twordarray = array [0..maxint div sizeof(word)-1] of word;
107
Tintegerarray = array [0..maxint div sizeof(integer)-1] of integer;
108
Tcardinalarray = array [0..maxint div sizeof(cardinal)-1] of cardinal;
92
111
{ The memory requirements for deflate are (in bytes):
93
112
1 shl (windowBits+2) + 1 shl (memLevel+9)
94
113
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
110
129
inflate_huft = Record
111
130
Exop, { number of extra bits or operation }
112
131
bits : Byte; { number of bits in this code or subcode }
113
{pad : uInt;} { pad structure to a power of 2 (4 bytes for }
114
{ 16-bit, 8 bytes for 32-bit int's) }
115
base : uInt; { literal, length base, or distance base }
132
{pad : cardinal;} { pad structure to a power of 2 (4 bytes for }
133
{ 16-bit, 8 bytes for 32-bit integer's) }
134
base : cardinal; { literal, length base, or distance base }
116
135
{ or table offset }
120
huft_field = Array[0..(MaxInt div SizeOf(inflate_huft))-1] of inflate_huft;
139
huft_field = Array[0..(maxint div SizeOf(inflate_huft))-1] of inflate_huft;
121
140
huft_ptr = ^huft_field;
123
142
ppInflate_huft = ^pInflate_huft;
143
162
mode : inflate_codes_mode; { current inflate_codes mode }
145
164
{ mode dependent information }
147
166
sub : record { submode }
149
168
0:(code : record { if LEN or DIST, where in tree }
150
169
tree : pInflate_huft; { pointer into tree }
151
need : uInt; { bits needed }
170
need : cardinal; { bits needed }
153
1:(lit : uInt); { if LIT, literal }
172
1:(lit : cardinal); { if LIT, literal }
154
173
2:(copy: record { if EXT or COPY, where and how much }
155
get : uInt; { bits to get for extra }
156
dist : uInt; { distance back to copy from }
174
get : cardinal; { bits to get for extra }
175
dist : cardinal; { distance back to copy from }
193
212
{ mode dependent information }
194
213
sub : record { submode }
196
0:(left : uInt); { if STORED, bytes left to copy }
215
0:(left : cardinal); { if STORED, bytes left to copy }
197
216
1:(trees : record { if DTREE, decoding info for trees }
198
table : uInt; { table lengths (14 bits) }
199
index : uInt; { index into blens (or border) }
200
blens : PuIntArray; { bit lengths of codes }
201
bb : uInt; { bit length tree depth }
217
table : cardinal; { table lengths (14 bits) }
218
index : cardinal; { index into blens (or border) }
219
blens : Pcardinalarray; { bit lengths of codes }
220
bb : cardinal; { bit length tree depth }
202
221
tb : pInflate_huft; { bit length decoding tree }
204
223
2:(decode : record { if CODES, current state }
210
229
last : boolean; { true if this block is the last block }
212
231
{ mode independent information }
213
bitk : uInt; { bits in bit buffer }
214
bitb : uLong; { bit buffer }
232
bitk : cardinal; { bits in bit buffer }
233
bitb : cardinal; { bit buffer }
215
234
hufts : huft_ptr; {pInflate_huft;} { single malloc for tree space }
216
window : pBytef; { sliding window }
217
zend : pBytef; { one byte after sliding window }
218
read : pBytef; { window read pointer }
219
write : pBytef; { window write pointer }
235
window : Pbyte; { sliding window }
236
zend : Pbyte; { one byte after sliding window }
237
read : Pbyte; { window read pointer }
238
write : Pbyte; { window write pointer }
220
239
checkfn : check_func; { check function }
221
check : uLong; { check on output }
240
check : cardinal; { check on output }
248
267
{ mode dependent information }
249
268
sub : record { submode }
251
0:(method : uInt); { if FLAGS, method byte }
270
0:(method : cardinal); { if FLAGS, method byte }
252
271
1:(check : record { if CHECK, check values to compare }
253
was : uLong; { computed check value }
254
need : uLong; { stream check value }
272
was : cardinal; { computed check value }
273
need : cardinal; { stream check value }
256
2:(marker : uInt); { if BAD, inflateSync's marker bytes count }
275
2:(marker : cardinal); { if BAD, inflateSync's marker bytes count }
259
278
{ mode independent information }
260
279
nowrap : boolean; { flag for no wrapper }
261
wbits : uInt; { log2(window size) (8..15, defaults to 15) }
280
wbits : cardinal; { log2(window size) (8..15, defaults to 15) }
262
281
blocks : pInflate_blocks_state; { current inflate_blocks state }
266
alloc_func = function(opaque : voidpf; items : uInt; size : uInt) : voidpf;
267
free_func = procedure(opaque : voidpf; address : voidpf);
285
alloc_func = function(opaque : pointer; items : cardinal; size : cardinal) : pointer;
286
free_func = procedure(opaque : pointer; address : pointer);
270
289
z_streamp = ^z_stream;
271
290
z_stream = record
272
next_in : pBytef; { next input byte }
273
avail_in : uInt; { number of bytes available at next_in }
274
total_in : uLong; { total nb of input bytes read so far }
276
next_out : pBytef; { next output byte should be put there }
277
avail_out : uInt; { remaining free space at next_out }
278
total_out : uLong; { total nb of bytes output so far }
280
msg : string; { last error message, '' if no error }
291
next_in : Pbyte; { next input byte }
292
avail_in : cardinal; { number of bytes available at next_in }
293
total_in : cardinal; { total nb of input bytes read so far }
295
next_out : Pbyte; { next output byte should be put there }
296
avail_out : cardinal; { remaining free space at next_out }
297
total_out : cardinal; { total nb of bytes output so far }
299
msg : string[255]; { last error message, '' if no error }
281
300
state : pInternal_state; { not visible by applications }
283
zalloc : alloc_func; { used to allocate the internal state }
284
zfree : free_func; { used to free the internal state }
285
opaque : voidpf; { private data object passed to zalloc and zfree }
287
data_type : int; { best guess about the data type: ascii or binary }
288
adler : uLong; { adler32 value of the uncompressed data }
289
reserved : uLong; { reserved for future use }
302
data_type : integer; { best guess about the data type: ascii or binary }
303
adler : cardinal; { adler32 value of the uncompressed data }
304
reserved : cardinal; { reserved for future use }
293
PZStream = ^TZStream;
296
308
{ The application must update next_in and avail_in when avail_in has
297
309
dropped to zero. It must update next_out and avail_out when avail_out
404
416
not compatible with the zlib.h header file used by the application.
405
417
This check is automatically made by deflateInit and inflateInit. }
407
function zError(err : int) : string;
409
function ZALLOC (var strm : z_stream; items : uInt; size : uInt) : voidpf;
411
procedure ZFREE (var strm : z_stream; ptr : voidpf);
413
procedure TRY_FREE (var strm : z_stream; ptr : voidpf);
419
function zError(err : integer) : string;
421
function ZALLOC (var strm : z_stream; items : cardinal; size : cardinal) : pointer;
423
procedure ZFREE (var strm : z_stream; ptr : pointer);
425
procedure TRY_FREE (var strm : z_stream; ptr : pointer);
416
428
ZLIB_VERSION : string[10] = '1.1.2';
499
function ZALLOC (var strm : z_stream; items : uInt; size : uInt) : voidpf;
501
ZALLOC := strm.zalloc(strm.opaque, items, size);
504
procedure ZFREE (var strm : z_stream; ptr : voidpf);
506
strm.zfree(strm.opaque, ptr);
509
procedure TRY_FREE (var strm : z_stream; ptr : voidpf);
511
{if @strm <> Z_NULL then}
512
strm.zfree(strm.opaque, ptr);
511
function ZALLOC (var strm : z_stream; items : cardinal; size : cardinal) : pointer;
513
getmem(ZALLOC,items*size);
516
procedure ZFREE (var strm : z_stream; ptr : pointer);
521
procedure TRY_FREE (var strm : z_stream; ptr : pointer);
b'\\ No newline at end of file'