1275793eaSopenharmony_ci(* zlibpas -- Pascal interface to the zlib data compression library 2275793eaSopenharmony_ci * 3275793eaSopenharmony_ci * Copyright (C) 2003 Cosmin Truta. 4275793eaSopenharmony_ci * Derived from original sources by Bob Dellaca. 5275793eaSopenharmony_ci * For conditions of distribution and use, see copyright notice in readme.txt 6275793eaSopenharmony_ci *) 7275793eaSopenharmony_ci 8275793eaSopenharmony_ciunit zlibpas; 9275793eaSopenharmony_ci 10275793eaSopenharmony_ciinterface 11275793eaSopenharmony_ci 12275793eaSopenharmony_ciconst 13275793eaSopenharmony_ci ZLIB_VERSION = '1.3.1'; 14275793eaSopenharmony_ci ZLIB_VERNUM = $12a0; 15275793eaSopenharmony_ci 16275793eaSopenharmony_citype 17275793eaSopenharmony_ci alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; 18275793eaSopenharmony_ci cdecl; 19275793eaSopenharmony_ci free_func = procedure(opaque, address: Pointer); 20275793eaSopenharmony_ci cdecl; 21275793eaSopenharmony_ci 22275793eaSopenharmony_ci in_func = function(opaque: Pointer; var buf: PByte): Integer; 23275793eaSopenharmony_ci cdecl; 24275793eaSopenharmony_ci out_func = function(opaque: Pointer; buf: PByte; size: Integer): Integer; 25275793eaSopenharmony_ci cdecl; 26275793eaSopenharmony_ci 27275793eaSopenharmony_ci z_streamp = ^z_stream; 28275793eaSopenharmony_ci z_stream = packed record 29275793eaSopenharmony_ci next_in: PChar; (* next input byte *) 30275793eaSopenharmony_ci avail_in: Integer; (* number of bytes available at next_in *) 31275793eaSopenharmony_ci total_in: LongInt; (* total nb of input bytes read so far *) 32275793eaSopenharmony_ci 33275793eaSopenharmony_ci next_out: PChar; (* next output byte should be put there *) 34275793eaSopenharmony_ci avail_out: Integer; (* remaining free space at next_out *) 35275793eaSopenharmony_ci total_out: LongInt; (* total nb of bytes output so far *) 36275793eaSopenharmony_ci 37275793eaSopenharmony_ci msg: PChar; (* last error message, NULL if no error *) 38275793eaSopenharmony_ci state: Pointer; (* not visible by applications *) 39275793eaSopenharmony_ci 40275793eaSopenharmony_ci zalloc: alloc_func; (* used to allocate the internal state *) 41275793eaSopenharmony_ci zfree: free_func; (* used to free the internal state *) 42275793eaSopenharmony_ci opaque: Pointer; (* private data object passed to zalloc and zfree *) 43275793eaSopenharmony_ci 44275793eaSopenharmony_ci data_type: Integer; (* best guess about the data type: ascii or binary *) 45275793eaSopenharmony_ci adler: LongInt; (* adler32 value of the uncompressed data *) 46275793eaSopenharmony_ci reserved: LongInt; (* reserved for future use *) 47275793eaSopenharmony_ci end; 48275793eaSopenharmony_ci 49275793eaSopenharmony_ci gz_headerp = ^gz_header; 50275793eaSopenharmony_ci gz_header = packed record 51275793eaSopenharmony_ci text: Integer; (* true if compressed data believed to be text *) 52275793eaSopenharmony_ci time: LongInt; (* modification time *) 53275793eaSopenharmony_ci xflags: Integer; (* extra flags (not used when writing a gzip file) *) 54275793eaSopenharmony_ci os: Integer; (* operating system *) 55275793eaSopenharmony_ci extra: PChar; (* pointer to extra field or Z_NULL if none *) 56275793eaSopenharmony_ci extra_len: Integer; (* extra field length (valid if extra != Z_NULL) *) 57275793eaSopenharmony_ci extra_max: Integer; (* space at extra (only when reading header) *) 58275793eaSopenharmony_ci name: PChar; (* pointer to zero-terminated file name or Z_NULL *) 59275793eaSopenharmony_ci name_max: Integer; (* space at name (only when reading header) *) 60275793eaSopenharmony_ci comment: PChar; (* pointer to zero-terminated comment or Z_NULL *) 61275793eaSopenharmony_ci comm_max: Integer; (* space at comment (only when reading header) *) 62275793eaSopenharmony_ci hcrc: Integer; (* true if there was or will be a header crc *) 63275793eaSopenharmony_ci done: Integer; (* true when done reading gzip header *) 64275793eaSopenharmony_ci end; 65275793eaSopenharmony_ci 66275793eaSopenharmony_ci(* constants *) 67275793eaSopenharmony_ciconst 68275793eaSopenharmony_ci Z_NO_FLUSH = 0; 69275793eaSopenharmony_ci Z_PARTIAL_FLUSH = 1; 70275793eaSopenharmony_ci Z_SYNC_FLUSH = 2; 71275793eaSopenharmony_ci Z_FULL_FLUSH = 3; 72275793eaSopenharmony_ci Z_FINISH = 4; 73275793eaSopenharmony_ci Z_BLOCK = 5; 74275793eaSopenharmony_ci Z_TREES = 6; 75275793eaSopenharmony_ci 76275793eaSopenharmony_ci Z_OK = 0; 77275793eaSopenharmony_ci Z_STREAM_END = 1; 78275793eaSopenharmony_ci Z_NEED_DICT = 2; 79275793eaSopenharmony_ci Z_ERRNO = -1; 80275793eaSopenharmony_ci Z_STREAM_ERROR = -2; 81275793eaSopenharmony_ci Z_DATA_ERROR = -3; 82275793eaSopenharmony_ci Z_MEM_ERROR = -4; 83275793eaSopenharmony_ci Z_BUF_ERROR = -5; 84275793eaSopenharmony_ci Z_VERSION_ERROR = -6; 85275793eaSopenharmony_ci 86275793eaSopenharmony_ci Z_NO_COMPRESSION = 0; 87275793eaSopenharmony_ci Z_BEST_SPEED = 1; 88275793eaSopenharmony_ci Z_BEST_COMPRESSION = 9; 89275793eaSopenharmony_ci Z_DEFAULT_COMPRESSION = -1; 90275793eaSopenharmony_ci 91275793eaSopenharmony_ci Z_FILTERED = 1; 92275793eaSopenharmony_ci Z_HUFFMAN_ONLY = 2; 93275793eaSopenharmony_ci Z_RLE = 3; 94275793eaSopenharmony_ci Z_FIXED = 4; 95275793eaSopenharmony_ci Z_DEFAULT_STRATEGY = 0; 96275793eaSopenharmony_ci 97275793eaSopenharmony_ci Z_BINARY = 0; 98275793eaSopenharmony_ci Z_TEXT = 1; 99275793eaSopenharmony_ci Z_ASCII = 1; 100275793eaSopenharmony_ci Z_UNKNOWN = 2; 101275793eaSopenharmony_ci 102275793eaSopenharmony_ci Z_DEFLATED = 8; 103275793eaSopenharmony_ci 104275793eaSopenharmony_ci(* basic functions *) 105275793eaSopenharmony_cifunction zlibVersion: PChar; 106275793eaSopenharmony_cifunction deflateInit(var strm: z_stream; level: Integer): Integer; 107275793eaSopenharmony_cifunction deflate(var strm: z_stream; flush: Integer): Integer; 108275793eaSopenharmony_cifunction deflateEnd(var strm: z_stream): Integer; 109275793eaSopenharmony_cifunction inflateInit(var strm: z_stream): Integer; 110275793eaSopenharmony_cifunction inflate(var strm: z_stream; flush: Integer): Integer; 111275793eaSopenharmony_cifunction inflateEnd(var strm: z_stream): Integer; 112275793eaSopenharmony_ci 113275793eaSopenharmony_ci(* advanced functions *) 114275793eaSopenharmony_cifunction deflateInit2(var strm: z_stream; level, method, windowBits, 115275793eaSopenharmony_ci memLevel, strategy: Integer): Integer; 116275793eaSopenharmony_cifunction deflateSetDictionary(var strm: z_stream; const dictionary: PChar; 117275793eaSopenharmony_ci dictLength: Integer): Integer; 118275793eaSopenharmony_cifunction deflateCopy(var dest, source: z_stream): Integer; 119275793eaSopenharmony_cifunction deflateReset(var strm: z_stream): Integer; 120275793eaSopenharmony_cifunction deflateParams(var strm: z_stream; level, strategy: Integer): Integer; 121275793eaSopenharmony_cifunction deflateTune(var strm: z_stream; good_length, max_lazy, nice_length, max_chain: Integer): Integer; 122275793eaSopenharmony_cifunction deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt; 123275793eaSopenharmony_cifunction deflatePending(var strm: z_stream; var pending: Integer; var bits: Integer): Integer; 124275793eaSopenharmony_cifunction deflatePrime(var strm: z_stream; bits, value: Integer): Integer; 125275793eaSopenharmony_cifunction deflateSetHeader(var strm: z_stream; head: gz_header): Integer; 126275793eaSopenharmony_cifunction inflateInit2(var strm: z_stream; windowBits: Integer): Integer; 127275793eaSopenharmony_cifunction inflateSetDictionary(var strm: z_stream; const dictionary: PChar; 128275793eaSopenharmony_ci dictLength: Integer): Integer; 129275793eaSopenharmony_cifunction inflateSync(var strm: z_stream): Integer; 130275793eaSopenharmony_cifunction inflateCopy(var dest, source: z_stream): Integer; 131275793eaSopenharmony_cifunction inflateReset(var strm: z_stream): Integer; 132275793eaSopenharmony_cifunction inflateReset2(var strm: z_stream; windowBits: Integer): Integer; 133275793eaSopenharmony_cifunction inflatePrime(var strm: z_stream; bits, value: Integer): Integer; 134275793eaSopenharmony_cifunction inflateMark(var strm: z_stream): LongInt; 135275793eaSopenharmony_cifunction inflateGetHeader(var strm: z_stream; var head: gz_header): Integer; 136275793eaSopenharmony_cifunction inflateBackInit(var strm: z_stream; 137275793eaSopenharmony_ci windowBits: Integer; window: PChar): Integer; 138275793eaSopenharmony_cifunction inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer; 139275793eaSopenharmony_ci out_fn: out_func; out_desc: Pointer): Integer; 140275793eaSopenharmony_cifunction inflateBackEnd(var strm: z_stream): Integer; 141275793eaSopenharmony_cifunction zlibCompileFlags: LongInt; 142275793eaSopenharmony_ci 143275793eaSopenharmony_ci(* utility functions *) 144275793eaSopenharmony_cifunction compress(dest: PChar; var destLen: LongInt; 145275793eaSopenharmony_ci const source: PChar; sourceLen: LongInt): Integer; 146275793eaSopenharmony_cifunction compress2(dest: PChar; var destLen: LongInt; 147275793eaSopenharmony_ci const source: PChar; sourceLen: LongInt; 148275793eaSopenharmony_ci level: Integer): Integer; 149275793eaSopenharmony_cifunction compressBound(sourceLen: LongInt): LongInt; 150275793eaSopenharmony_cifunction uncompress(dest: PChar; var destLen: LongInt; 151275793eaSopenharmony_ci const source: PChar; sourceLen: LongInt): Integer; 152275793eaSopenharmony_ci 153275793eaSopenharmony_ci(* checksum functions *) 154275793eaSopenharmony_cifunction adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt; 155275793eaSopenharmony_cifunction adler32_combine(adler1, adler2, len2: LongInt): LongInt; 156275793eaSopenharmony_cifunction crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt; 157275793eaSopenharmony_cifunction crc32_combine(crc1, crc2, len2: LongInt): LongInt; 158275793eaSopenharmony_ci 159275793eaSopenharmony_ci(* various hacks, don't look :) *) 160275793eaSopenharmony_cifunction deflateInit_(var strm: z_stream; level: Integer; 161275793eaSopenharmony_ci const version: PChar; stream_size: Integer): Integer; 162275793eaSopenharmony_cifunction inflateInit_(var strm: z_stream; const version: PChar; 163275793eaSopenharmony_ci stream_size: Integer): Integer; 164275793eaSopenharmony_cifunction deflateInit2_(var strm: z_stream; 165275793eaSopenharmony_ci level, method, windowBits, memLevel, strategy: Integer; 166275793eaSopenharmony_ci const version: PChar; stream_size: Integer): Integer; 167275793eaSopenharmony_cifunction inflateInit2_(var strm: z_stream; windowBits: Integer; 168275793eaSopenharmony_ci const version: PChar; stream_size: Integer): Integer; 169275793eaSopenharmony_cifunction inflateBackInit_(var strm: z_stream; 170275793eaSopenharmony_ci windowBits: Integer; window: PChar; 171275793eaSopenharmony_ci const version: PChar; stream_size: Integer): Integer; 172275793eaSopenharmony_ci 173275793eaSopenharmony_ci 174275793eaSopenharmony_ciimplementation 175275793eaSopenharmony_ci 176275793eaSopenharmony_ci{$L adler32.obj} 177275793eaSopenharmony_ci{$L compress.obj} 178275793eaSopenharmony_ci{$L crc32.obj} 179275793eaSopenharmony_ci{$L deflate.obj} 180275793eaSopenharmony_ci{$L infback.obj} 181275793eaSopenharmony_ci{$L inffast.obj} 182275793eaSopenharmony_ci{$L inflate.obj} 183275793eaSopenharmony_ci{$L inftrees.obj} 184275793eaSopenharmony_ci{$L trees.obj} 185275793eaSopenharmony_ci{$L uncompr.obj} 186275793eaSopenharmony_ci{$L zutil.obj} 187275793eaSopenharmony_ci 188275793eaSopenharmony_cifunction adler32; external; 189275793eaSopenharmony_cifunction adler32_combine; external; 190275793eaSopenharmony_cifunction compress; external; 191275793eaSopenharmony_cifunction compress2; external; 192275793eaSopenharmony_cifunction compressBound; external; 193275793eaSopenharmony_cifunction crc32; external; 194275793eaSopenharmony_cifunction crc32_combine; external; 195275793eaSopenharmony_cifunction deflate; external; 196275793eaSopenharmony_cifunction deflateBound; external; 197275793eaSopenharmony_cifunction deflateCopy; external; 198275793eaSopenharmony_cifunction deflateEnd; external; 199275793eaSopenharmony_cifunction deflateInit_; external; 200275793eaSopenharmony_cifunction deflateInit2_; external; 201275793eaSopenharmony_cifunction deflateParams; external; 202275793eaSopenharmony_cifunction deflatePending; external; 203275793eaSopenharmony_cifunction deflatePrime; external; 204275793eaSopenharmony_cifunction deflateReset; external; 205275793eaSopenharmony_cifunction deflateSetDictionary; external; 206275793eaSopenharmony_cifunction deflateSetHeader; external; 207275793eaSopenharmony_cifunction deflateTune; external; 208275793eaSopenharmony_cifunction inflate; external; 209275793eaSopenharmony_cifunction inflateBack; external; 210275793eaSopenharmony_cifunction inflateBackEnd; external; 211275793eaSopenharmony_cifunction inflateBackInit_; external; 212275793eaSopenharmony_cifunction inflateCopy; external; 213275793eaSopenharmony_cifunction inflateEnd; external; 214275793eaSopenharmony_cifunction inflateGetHeader; external; 215275793eaSopenharmony_cifunction inflateInit_; external; 216275793eaSopenharmony_cifunction inflateInit2_; external; 217275793eaSopenharmony_cifunction inflateMark; external; 218275793eaSopenharmony_cifunction inflatePrime; external; 219275793eaSopenharmony_cifunction inflateReset; external; 220275793eaSopenharmony_cifunction inflateReset2; external; 221275793eaSopenharmony_cifunction inflateSetDictionary; external; 222275793eaSopenharmony_cifunction inflateSync; external; 223275793eaSopenharmony_cifunction uncompress; external; 224275793eaSopenharmony_cifunction zlibCompileFlags; external; 225275793eaSopenharmony_cifunction zlibVersion; external; 226275793eaSopenharmony_ci 227275793eaSopenharmony_cifunction deflateInit(var strm: z_stream; level: Integer): Integer; 228275793eaSopenharmony_cibegin 229275793eaSopenharmony_ci Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream)); 230275793eaSopenharmony_ciend; 231275793eaSopenharmony_ci 232275793eaSopenharmony_cifunction deflateInit2(var strm: z_stream; level, method, windowBits, memLevel, 233275793eaSopenharmony_ci strategy: Integer): Integer; 234275793eaSopenharmony_cibegin 235275793eaSopenharmony_ci Result := deflateInit2_(strm, level, method, windowBits, memLevel, strategy, 236275793eaSopenharmony_ci ZLIB_VERSION, sizeof(z_stream)); 237275793eaSopenharmony_ciend; 238275793eaSopenharmony_ci 239275793eaSopenharmony_cifunction inflateInit(var strm: z_stream): Integer; 240275793eaSopenharmony_cibegin 241275793eaSopenharmony_ci Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream)); 242275793eaSopenharmony_ciend; 243275793eaSopenharmony_ci 244275793eaSopenharmony_cifunction inflateInit2(var strm: z_stream; windowBits: Integer): Integer; 245275793eaSopenharmony_cibegin 246275793eaSopenharmony_ci Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, sizeof(z_stream)); 247275793eaSopenharmony_ciend; 248275793eaSopenharmony_ci 249275793eaSopenharmony_cifunction inflateBackInit(var strm: z_stream; 250275793eaSopenharmony_ci windowBits: Integer; window: PChar): Integer; 251275793eaSopenharmony_cibegin 252275793eaSopenharmony_ci Result := inflateBackInit_(strm, windowBits, window, 253275793eaSopenharmony_ci ZLIB_VERSION, sizeof(z_stream)); 254275793eaSopenharmony_ciend; 255275793eaSopenharmony_ci 256275793eaSopenharmony_cifunction _malloc(Size: Integer): Pointer; cdecl; 257275793eaSopenharmony_cibegin 258275793eaSopenharmony_ci GetMem(Result, Size); 259275793eaSopenharmony_ciend; 260275793eaSopenharmony_ci 261275793eaSopenharmony_ciprocedure _free(Block: Pointer); cdecl; 262275793eaSopenharmony_cibegin 263275793eaSopenharmony_ci FreeMem(Block); 264275793eaSopenharmony_ciend; 265275793eaSopenharmony_ci 266275793eaSopenharmony_ciprocedure _memset(P: Pointer; B: Byte; count: Integer); cdecl; 267275793eaSopenharmony_cibegin 268275793eaSopenharmony_ci FillChar(P^, count, B); 269275793eaSopenharmony_ciend; 270275793eaSopenharmony_ci 271275793eaSopenharmony_ciprocedure _memcpy(dest, source: Pointer; count: Integer); cdecl; 272275793eaSopenharmony_cibegin 273275793eaSopenharmony_ci Move(source^, dest^, count); 274275793eaSopenharmony_ciend; 275275793eaSopenharmony_ci 276275793eaSopenharmony_ciend. 277