unit zlibpas;
interface
const
ZLIB_VERSION = '1.2.3';
type
alloc_func = function(opaque: Pointer; items, size: Integer): Pointer;
cdecl;
free_func = procedure(opaque, address: Pointer);
cdecl;
in_func = function(opaque: Pointer; var buf: PByte): Integer;
cdecl;
out_func = function(opaque: Pointer; buf: PByte; size: Integer): Integer;
cdecl;
z_streamp = ^z_stream;
z_stream = packed record
next_in: PChar;
avail_in: Integer;
total_in: LongInt;
next_out: PChar;
avail_out: Integer;
total_out: LongInt;
msg: PChar;
state: Pointer;
zalloc: alloc_func;
zfree: free_func;
opaque: Pointer;
data_type: Integer;
adler: LongInt;
reserved: LongInt;
end;
const
Z_NO_FLUSH = 0;
Z_PARTIAL_FLUSH = 1;
Z_SYNC_FLUSH = 2;
Z_FULL_FLUSH = 3;
Z_FINISH = 4;
Z_OK = 0;
Z_STREAM_END = 1;
Z_NEED_DICT = 2;
Z_ERRNO = -1;
Z_STREAM_ERROR = -2;
Z_DATA_ERROR = -3;
Z_MEM_ERROR = -4;
Z_BUF_ERROR = -5;
Z_VERSION_ERROR = -6;
Z_NO_COMPRESSION = 0;
Z_BEST_SPEED = 1;
Z_BEST_COMPRESSION = 9;
Z_DEFAULT_COMPRESSION = -1;
Z_FILTERED = 1;
Z_HUFFMAN_ONLY = 2;
Z_RLE = 3;
Z_DEFAULT_STRATEGY = 0;
Z_BINARY = 0;
Z_ASCII = 1;
Z_UNKNOWN = 2;
Z_DEFLATED = 8;
function zlibVersion: PChar;
function deflateInit(var strm: z_stream; level: Integer): Integer;
function deflate(var strm: z_stream; flush: Integer): Integer;
function deflateEnd(var strm: z_stream): Integer;
function inflateInit(var strm: z_stream): Integer;
function inflate(var strm: z_stream; flush: Integer): Integer;
function inflateEnd(var strm: z_stream): Integer;
function deflateInit2(var strm: z_stream; level, method, windowBits,
memLevel, strategy: Integer): Integer;
function deflateSetDictionary(var strm: z_stream; const dictionary: PChar;
dictLength: Integer): Integer;
function deflateCopy(var dest, source: z_stream): Integer;
function deflateReset(var strm: z_stream): Integer;
function deflateParams(var strm: z_stream; level, strategy: Integer): Integer;
function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt;
function deflatePrime(var strm: z_stream; bits, value: Integer): Integer;
function inflateInit2(var strm: z_stream; windowBits: Integer): Integer;
function inflateSetDictionary(var strm: z_stream; const dictionary: PChar;
dictLength: Integer): Integer;
function inflateSync(var strm: z_stream): Integer;
function inflateCopy(var dest, source: z_stream): Integer;
function inflateReset(var strm: z_stream): Integer;
function inflateBackInit(var strm: z_stream;
windowBits: Integer; window: PChar): Integer;
function inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer;
out_fn: out_func; out_desc: Pointer): Integer;
function inflateBackEnd(var strm: z_stream): Integer;
function zlibCompileFlags: LongInt;
function compress(dest: PChar; var destLen: LongInt;
const source: PChar; sourceLen: LongInt): Integer;
function compress2(dest: PChar; var destLen: LongInt;
const source: PChar; sourceLen: LongInt;
level: Integer): Integer;
function compressBound(sourceLen: LongInt): LongInt;
function uncompress(dest: PChar; var destLen: LongInt;
const source: PChar; sourceLen: LongInt): Integer;
function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt;
function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt;
function deflateInit_(var strm: z_stream; level: Integer;
const version: PChar; stream_size: Integer): Integer;
function inflateInit_(var strm: z_stream; const version: PChar;
stream_size: Integer): Integer;
function deflateInit2_(var strm: z_stream;
level, method, windowBits, memLevel, strategy: Integer;
const version: PChar; stream_size: Integer): Integer;
function inflateInit2_(var strm: z_stream; windowBits: Integer;
const version: PChar; stream_size: Integer): Integer;
function inflateBackInit_(var strm: z_stream;
windowBits: Integer; window: PChar;
const version: PChar; stream_size: Integer): Integer;
implementation
function adler32; external;
function compress; external;
function compress2; external;
function compressBound; external;
function crc32; external;
function deflate; external;
function deflateBound; external;
function deflateCopy; external;
function deflateEnd; external;
function deflateInit_; external;
function deflateInit2_; external;
function deflateParams; external;
function deflatePrime; external;
function deflateReset; external;
function deflateSetDictionary; external;
function inflate; external;
function inflateBack; external;
function inflateBackEnd; external;
function inflateBackInit_; external;
function inflateCopy; external;
function inflateEnd; external;
function inflateInit_; external;
function inflateInit2_; external;
function inflateReset; external;
function inflateSetDictionary; external;
function inflateSync; external;
function uncompress; external;
function zlibCompileFlags; external;
function zlibVersion; external;
function deflateInit(var strm: z_stream; level: Integer): Integer;
begin
Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream));
end;
function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel,
strategy: Integer): Integer;
begin
Result := deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
ZLIB_VERSION, sizeof(z_stream));
end;
function inflateInit(var strm: z_stream): Integer;
begin
Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream));
end;
function inflateInit2(var strm: z_stream; windowBits: Integer): Integer;
begin
Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, sizeof(z_stream));
end;
function inflateBackInit(var strm: z_stream;
windowBits: Integer; window: PChar): Integer;
begin
Result := inflateBackInit_(strm, windowBits, window,
ZLIB_VERSION, sizeof(z_stream));
end;
function _malloc(Size: Integer): Pointer; cdecl;
begin
GetMem(Result, Size);
end;
procedure _free(Block: Pointer); cdecl;
begin
FreeMem(Block);
end;
procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl;
begin
FillChar(P^, count, B);
end;
procedure _memcpy(dest, source: Pointer; count: Integer); cdecl;
begin
Move(source^, dest^, count);
end;
end.