1
(* zlibpas -- Pascal interface to the zlib data compression library
3
* Copyright (C) 2003 Cosmin Truta.
4
* Derived from original sources by Bob Dellaca.
5
* For conditions of distribution and use, see copyright notice in readme.txt
13
ZLIB_VERSION = '1.2.5';
16
alloc_func = function(opaque: Pointer; items, size: Integer): Pointer;
18
free_func = procedure(opaque, address: Pointer);
21
in_func = function(opaque: Pointer; var buf: PByte): Integer;
23
out_func = function(opaque: Pointer; buf: PByte; size: Integer): Integer;
26
z_streamp = ^z_stream;
27
z_stream = packed record
28
next_in: PChar; (* next input byte *)
29
avail_in: Integer; (* number of bytes available at next_in *)
30
total_in: LongInt; (* total nb of input bytes read so far *)
32
next_out: PChar; (* next output byte should be put there *)
33
avail_out: Integer; (* remaining free space at next_out *)
34
total_out: LongInt; (* total nb of bytes output so far *)
36
msg: PChar; (* last error message, NULL if no error *)
37
state: Pointer; (* not visible by applications *)
39
zalloc: alloc_func; (* used to allocate the internal state *)
40
zfree: free_func; (* used to free the internal state *)
41
opaque: Pointer; (* private data object passed to zalloc and zfree *)
43
data_type: Integer; (* best guess about the data type: ascii or binary *)
44
adler: LongInt; (* adler32 value of the uncompressed data *)
45
reserved: LongInt; (* reserved for future use *)
68
Z_BEST_COMPRESSION = 9;
69
Z_DEFAULT_COMPRESSION = -1;
74
Z_DEFAULT_STRATEGY = 0;
83
function zlibVersion: PChar;
84
function deflateInit(var strm: z_stream; level: Integer): Integer;
85
function deflate(var strm: z_stream; flush: Integer): Integer;
86
function deflateEnd(var strm: z_stream): Integer;
87
function inflateInit(var strm: z_stream): Integer;
88
function inflate(var strm: z_stream; flush: Integer): Integer;
89
function inflateEnd(var strm: z_stream): Integer;
91
(* advanced functions *)
92
function deflateInit2(var strm: z_stream; level, method, windowBits,
93
memLevel, strategy: Integer): Integer;
94
function deflateSetDictionary(var strm: z_stream; const dictionary: PChar;
95
dictLength: Integer): Integer;
96
function deflateCopy(var dest, source: z_stream): Integer;
97
function deflateReset(var strm: z_stream): Integer;
98
function deflateParams(var strm: z_stream; level, strategy: Integer): Integer;
99
function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt;
100
function deflatePrime(var strm: z_stream; bits, value: Integer): Integer;
101
function inflateInit2(var strm: z_stream; windowBits: Integer): Integer;
102
function inflateSetDictionary(var strm: z_stream; const dictionary: PChar;
103
dictLength: Integer): Integer;
104
function inflateSync(var strm: z_stream): Integer;
105
function inflateCopy(var dest, source: z_stream): Integer;
106
function inflateReset(var strm: z_stream): Integer;
107
function inflateBackInit(var strm: z_stream;
108
windowBits: Integer; window: PChar): Integer;
109
function inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer;
110
out_fn: out_func; out_desc: Pointer): Integer;
111
function inflateBackEnd(var strm: z_stream): Integer;
112
function zlibCompileFlags: LongInt;
114
(* utility functions *)
115
function compress(dest: PChar; var destLen: LongInt;
116
const source: PChar; sourceLen: LongInt): Integer;
117
function compress2(dest: PChar; var destLen: LongInt;
118
const source: PChar; sourceLen: LongInt;
119
level: Integer): Integer;
120
function compressBound(sourceLen: LongInt): LongInt;
121
function uncompress(dest: PChar; var destLen: LongInt;
122
const source: PChar; sourceLen: LongInt): Integer;
124
(* checksum functions *)
125
function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt;
126
function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt;
128
(* various hacks, don't look :) *)
129
function deflateInit_(var strm: z_stream; level: Integer;
130
const version: PChar; stream_size: Integer): Integer;
131
function inflateInit_(var strm: z_stream; const version: PChar;
132
stream_size: Integer): Integer;
133
function deflateInit2_(var strm: z_stream;
134
level, method, windowBits, memLevel, strategy: Integer;
135
const version: PChar; stream_size: Integer): Integer;
136
function inflateInit2_(var strm: z_stream; windowBits: Integer;
137
const version: PChar; stream_size: Integer): Integer;
138
function inflateBackInit_(var strm: z_stream;
139
windowBits: Integer; window: PChar;
140
const version: PChar; stream_size: Integer): Integer;
157
function adler32; external;
158
function compress; external;
159
function compress2; external;
160
function compressBound; external;
161
function crc32; external;
162
function deflate; external;
163
function deflateBound; external;
164
function deflateCopy; external;
165
function deflateEnd; external;
166
function deflateInit_; external;
167
function deflateInit2_; external;
168
function deflateParams; external;
169
function deflatePrime; external;
170
function deflateReset; external;
171
function deflateSetDictionary; external;
172
function inflate; external;
173
function inflateBack; external;
174
function inflateBackEnd; external;
175
function inflateBackInit_; external;
176
function inflateCopy; external;
177
function inflateEnd; external;
178
function inflateInit_; external;
179
function inflateInit2_; external;
180
function inflateReset; external;
181
function inflateSetDictionary; external;
182
function inflateSync; external;
183
function uncompress; external;
184
function zlibCompileFlags; external;
185
function zlibVersion; external;
187
function deflateInit(var strm: z_stream; level: Integer): Integer;
189
Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream));
192
function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel,
193
strategy: Integer): Integer;
195
Result := deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
196
ZLIB_VERSION, sizeof(z_stream));
199
function inflateInit(var strm: z_stream): Integer;
201
Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream));
204
function inflateInit2(var strm: z_stream; windowBits: Integer): Integer;
206
Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, sizeof(z_stream));
209
function inflateBackInit(var strm: z_stream;
210
windowBits: Integer; window: PChar): Integer;
212
Result := inflateBackInit_(strm, windowBits, window,
213
ZLIB_VERSION, sizeof(z_stream));
216
function _malloc(Size: Integer): Pointer; cdecl;
218
GetMem(Result, Size);
221
procedure _free(Block: Pointer); cdecl;
226
procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl;
228
FillChar(P^, count, B);
231
procedure _memcpy(dest, source: Pointer; count: Integer); cdecl;
233
Move(source^, dest^, count);