annotate src/zlib-1.2.7/contrib/pascal/zlibpas.pas @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 8a15ff55d9af
children
rev   line source
cannam@89 1 (* zlibpas -- Pascal interface to the zlib data compression library
cannam@89 2 *
cannam@89 3 * Copyright (C) 2003 Cosmin Truta.
cannam@89 4 * Derived from original sources by Bob Dellaca.
cannam@89 5 * For conditions of distribution and use, see copyright notice in readme.txt
cannam@89 6 *)
cannam@89 7
cannam@89 8 unit zlibpas;
cannam@89 9
cannam@89 10 interface
cannam@89 11
cannam@89 12 const
cannam@89 13 ZLIB_VERSION = '1.2.7';
cannam@89 14 ZLIB_VERNUM = $1270;
cannam@89 15
cannam@89 16 type
cannam@89 17 alloc_func = function(opaque: Pointer; items, size: Integer): Pointer;
cannam@89 18 cdecl;
cannam@89 19 free_func = procedure(opaque, address: Pointer);
cannam@89 20 cdecl;
cannam@89 21
cannam@89 22 in_func = function(opaque: Pointer; var buf: PByte): Integer;
cannam@89 23 cdecl;
cannam@89 24 out_func = function(opaque: Pointer; buf: PByte; size: Integer): Integer;
cannam@89 25 cdecl;
cannam@89 26
cannam@89 27 z_streamp = ^z_stream;
cannam@89 28 z_stream = packed record
cannam@89 29 next_in: PChar; (* next input byte *)
cannam@89 30 avail_in: Integer; (* number of bytes available at next_in *)
cannam@89 31 total_in: LongInt; (* total nb of input bytes read so far *)
cannam@89 32
cannam@89 33 next_out: PChar; (* next output byte should be put there *)
cannam@89 34 avail_out: Integer; (* remaining free space at next_out *)
cannam@89 35 total_out: LongInt; (* total nb of bytes output so far *)
cannam@89 36
cannam@89 37 msg: PChar; (* last error message, NULL if no error *)
cannam@89 38 state: Pointer; (* not visible by applications *)
cannam@89 39
cannam@89 40 zalloc: alloc_func; (* used to allocate the internal state *)
cannam@89 41 zfree: free_func; (* used to free the internal state *)
cannam@89 42 opaque: Pointer; (* private data object passed to zalloc and zfree *)
cannam@89 43
cannam@89 44 data_type: Integer; (* best guess about the data type: ascii or binary *)
cannam@89 45 adler: LongInt; (* adler32 value of the uncompressed data *)
cannam@89 46 reserved: LongInt; (* reserved for future use *)
cannam@89 47 end;
cannam@89 48
cannam@89 49 gz_headerp = ^gz_header;
cannam@89 50 gz_header = packed record
cannam@89 51 text: Integer; (* true if compressed data believed to be text *)
cannam@89 52 time: LongInt; (* modification time *)
cannam@89 53 xflags: Integer; (* extra flags (not used when writing a gzip file) *)
cannam@89 54 os: Integer; (* operating system *)
cannam@89 55 extra: PChar; (* pointer to extra field or Z_NULL if none *)
cannam@89 56 extra_len: Integer; (* extra field length (valid if extra != Z_NULL) *)
cannam@89 57 extra_max: Integer; (* space at extra (only when reading header) *)
cannam@89 58 name: PChar; (* pointer to zero-terminated file name or Z_NULL *)
cannam@89 59 name_max: Integer; (* space at name (only when reading header) *)
cannam@89 60 comment: PChar; (* pointer to zero-terminated comment or Z_NULL *)
cannam@89 61 comm_max: Integer; (* space at comment (only when reading header) *)
cannam@89 62 hcrc: Integer; (* true if there was or will be a header crc *)
cannam@89 63 done: Integer; (* true when done reading gzip header *)
cannam@89 64 end;
cannam@89 65
cannam@89 66 (* constants *)
cannam@89 67 const
cannam@89 68 Z_NO_FLUSH = 0;
cannam@89 69 Z_PARTIAL_FLUSH = 1;
cannam@89 70 Z_SYNC_FLUSH = 2;
cannam@89 71 Z_FULL_FLUSH = 3;
cannam@89 72 Z_FINISH = 4;
cannam@89 73 Z_BLOCK = 5;
cannam@89 74 Z_TREES = 6;
cannam@89 75
cannam@89 76 Z_OK = 0;
cannam@89 77 Z_STREAM_END = 1;
cannam@89 78 Z_NEED_DICT = 2;
cannam@89 79 Z_ERRNO = -1;
cannam@89 80 Z_STREAM_ERROR = -2;
cannam@89 81 Z_DATA_ERROR = -3;
cannam@89 82 Z_MEM_ERROR = -4;
cannam@89 83 Z_BUF_ERROR = -5;
cannam@89 84 Z_VERSION_ERROR = -6;
cannam@89 85
cannam@89 86 Z_NO_COMPRESSION = 0;
cannam@89 87 Z_BEST_SPEED = 1;
cannam@89 88 Z_BEST_COMPRESSION = 9;
cannam@89 89 Z_DEFAULT_COMPRESSION = -1;
cannam@89 90
cannam@89 91 Z_FILTERED = 1;
cannam@89 92 Z_HUFFMAN_ONLY = 2;
cannam@89 93 Z_RLE = 3;
cannam@89 94 Z_FIXED = 4;
cannam@89 95 Z_DEFAULT_STRATEGY = 0;
cannam@89 96
cannam@89 97 Z_BINARY = 0;
cannam@89 98 Z_TEXT = 1;
cannam@89 99 Z_ASCII = 1;
cannam@89 100 Z_UNKNOWN = 2;
cannam@89 101
cannam@89 102 Z_DEFLATED = 8;
cannam@89 103
cannam@89 104 (* basic functions *)
cannam@89 105 function zlibVersion: PChar;
cannam@89 106 function deflateInit(var strm: z_stream; level: Integer): Integer;
cannam@89 107 function deflate(var strm: z_stream; flush: Integer): Integer;
cannam@89 108 function deflateEnd(var strm: z_stream): Integer;
cannam@89 109 function inflateInit(var strm: z_stream): Integer;
cannam@89 110 function inflate(var strm: z_stream; flush: Integer): Integer;
cannam@89 111 function inflateEnd(var strm: z_stream): Integer;
cannam@89 112
cannam@89 113 (* advanced functions *)
cannam@89 114 function deflateInit2(var strm: z_stream; level, method, windowBits,
cannam@89 115 memLevel, strategy: Integer): Integer;
cannam@89 116 function deflateSetDictionary(var strm: z_stream; const dictionary: PChar;
cannam@89 117 dictLength: Integer): Integer;
cannam@89 118 function deflateCopy(var dest, source: z_stream): Integer;
cannam@89 119 function deflateReset(var strm: z_stream): Integer;
cannam@89 120 function deflateParams(var strm: z_stream; level, strategy: Integer): Integer;
cannam@89 121 function deflateTune(var strm: z_stream; good_length, max_lazy, nice_length, max_chain: Integer): Integer;
cannam@89 122 function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt;
cannam@89 123 function deflatePending(var strm: z_stream; var pending: Integer; var bits: Integer): Integer;
cannam@89 124 function deflatePrime(var strm: z_stream; bits, value: Integer): Integer;
cannam@89 125 function deflateSetHeader(var strm: z_stream; head: gz_header): Integer;
cannam@89 126 function inflateInit2(var strm: z_stream; windowBits: Integer): Integer;
cannam@89 127 function inflateSetDictionary(var strm: z_stream; const dictionary: PChar;
cannam@89 128 dictLength: Integer): Integer;
cannam@89 129 function inflateSync(var strm: z_stream): Integer;
cannam@89 130 function inflateCopy(var dest, source: z_stream): Integer;
cannam@89 131 function inflateReset(var strm: z_stream): Integer;
cannam@89 132 function inflateReset2(var strm: z_stream; windowBits: Integer): Integer;
cannam@89 133 function inflatePrime(var strm: z_stream; bits, value: Integer): Integer;
cannam@89 134 function inflateMark(var strm: z_stream): LongInt;
cannam@89 135 function inflateGetHeader(var strm: z_stream; var head: gz_header): Integer;
cannam@89 136 function inflateBackInit(var strm: z_stream;
cannam@89 137 windowBits: Integer; window: PChar): Integer;
cannam@89 138 function inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer;
cannam@89 139 out_fn: out_func; out_desc: Pointer): Integer;
cannam@89 140 function inflateBackEnd(var strm: z_stream): Integer;
cannam@89 141 function zlibCompileFlags: LongInt;
cannam@89 142
cannam@89 143 (* utility functions *)
cannam@89 144 function compress(dest: PChar; var destLen: LongInt;
cannam@89 145 const source: PChar; sourceLen: LongInt): Integer;
cannam@89 146 function compress2(dest: PChar; var destLen: LongInt;
cannam@89 147 const source: PChar; sourceLen: LongInt;
cannam@89 148 level: Integer): Integer;
cannam@89 149 function compressBound(sourceLen: LongInt): LongInt;
cannam@89 150 function uncompress(dest: PChar; var destLen: LongInt;
cannam@89 151 const source: PChar; sourceLen: LongInt): Integer;
cannam@89 152
cannam@89 153 (* checksum functions *)
cannam@89 154 function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt;
cannam@89 155 function adler32_combine(adler1, adler2, len2: LongInt): LongInt;
cannam@89 156 function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt;
cannam@89 157 function crc32_combine(crc1, crc2, len2: LongInt): LongInt;
cannam@89 158
cannam@89 159 (* various hacks, don't look :) *)
cannam@89 160 function deflateInit_(var strm: z_stream; level: Integer;
cannam@89 161 const version: PChar; stream_size: Integer): Integer;
cannam@89 162 function inflateInit_(var strm: z_stream; const version: PChar;
cannam@89 163 stream_size: Integer): Integer;
cannam@89 164 function deflateInit2_(var strm: z_stream;
cannam@89 165 level, method, windowBits, memLevel, strategy: Integer;
cannam@89 166 const version: PChar; stream_size: Integer): Integer;
cannam@89 167 function inflateInit2_(var strm: z_stream; windowBits: Integer;
cannam@89 168 const version: PChar; stream_size: Integer): Integer;
cannam@89 169 function inflateBackInit_(var strm: z_stream;
cannam@89 170 windowBits: Integer; window: PChar;
cannam@89 171 const version: PChar; stream_size: Integer): Integer;
cannam@89 172
cannam@89 173
cannam@89 174 implementation
cannam@89 175
cannam@89 176 {$L adler32.obj}
cannam@89 177 {$L compress.obj}
cannam@89 178 {$L crc32.obj}
cannam@89 179 {$L deflate.obj}
cannam@89 180 {$L infback.obj}
cannam@89 181 {$L inffast.obj}
cannam@89 182 {$L inflate.obj}
cannam@89 183 {$L inftrees.obj}
cannam@89 184 {$L trees.obj}
cannam@89 185 {$L uncompr.obj}
cannam@89 186 {$L zutil.obj}
cannam@89 187
cannam@89 188 function adler32; external;
cannam@89 189 function adler32_combine; external;
cannam@89 190 function compress; external;
cannam@89 191 function compress2; external;
cannam@89 192 function compressBound; external;
cannam@89 193 function crc32; external;
cannam@89 194 function crc32_combine; external;
cannam@89 195 function deflate; external;
cannam@89 196 function deflateBound; external;
cannam@89 197 function deflateCopy; external;
cannam@89 198 function deflateEnd; external;
cannam@89 199 function deflateInit_; external;
cannam@89 200 function deflateInit2_; external;
cannam@89 201 function deflateParams; external;
cannam@89 202 function deflatePending; external;
cannam@89 203 function deflatePrime; external;
cannam@89 204 function deflateReset; external;
cannam@89 205 function deflateSetDictionary; external;
cannam@89 206 function deflateSetHeader; external;
cannam@89 207 function deflateTune; external;
cannam@89 208 function inflate; external;
cannam@89 209 function inflateBack; external;
cannam@89 210 function inflateBackEnd; external;
cannam@89 211 function inflateBackInit_; external;
cannam@89 212 function inflateCopy; external;
cannam@89 213 function inflateEnd; external;
cannam@89 214 function inflateGetHeader; external;
cannam@89 215 function inflateInit_; external;
cannam@89 216 function inflateInit2_; external;
cannam@89 217 function inflateMark; external;
cannam@89 218 function inflatePrime; external;
cannam@89 219 function inflateReset; external;
cannam@89 220 function inflateReset2; external;
cannam@89 221 function inflateSetDictionary; external;
cannam@89 222 function inflateSync; external;
cannam@89 223 function uncompress; external;
cannam@89 224 function zlibCompileFlags; external;
cannam@89 225 function zlibVersion; external;
cannam@89 226
cannam@89 227 function deflateInit(var strm: z_stream; level: Integer): Integer;
cannam@89 228 begin
cannam@89 229 Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream));
cannam@89 230 end;
cannam@89 231
cannam@89 232 function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel,
cannam@89 233 strategy: Integer): Integer;
cannam@89 234 begin
cannam@89 235 Result := deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
cannam@89 236 ZLIB_VERSION, sizeof(z_stream));
cannam@89 237 end;
cannam@89 238
cannam@89 239 function inflateInit(var strm: z_stream): Integer;
cannam@89 240 begin
cannam@89 241 Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream));
cannam@89 242 end;
cannam@89 243
cannam@89 244 function inflateInit2(var strm: z_stream; windowBits: Integer): Integer;
cannam@89 245 begin
cannam@89 246 Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, sizeof(z_stream));
cannam@89 247 end;
cannam@89 248
cannam@89 249 function inflateBackInit(var strm: z_stream;
cannam@89 250 windowBits: Integer; window: PChar): Integer;
cannam@89 251 begin
cannam@89 252 Result := inflateBackInit_(strm, windowBits, window,
cannam@89 253 ZLIB_VERSION, sizeof(z_stream));
cannam@89 254 end;
cannam@89 255
cannam@89 256 function _malloc(Size: Integer): Pointer; cdecl;
cannam@89 257 begin
cannam@89 258 GetMem(Result, Size);
cannam@89 259 end;
cannam@89 260
cannam@89 261 procedure _free(Block: Pointer); cdecl;
cannam@89 262 begin
cannam@89 263 FreeMem(Block);
cannam@89 264 end;
cannam@89 265
cannam@89 266 procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl;
cannam@89 267 begin
cannam@89 268 FillChar(P^, count, B);
cannam@89 269 end;
cannam@89 270
cannam@89 271 procedure _memcpy(dest, source: Pointer; count: Integer); cdecl;
cannam@89 272 begin
cannam@89 273 Move(source^, dest^, count);
cannam@89 274 end;
cannam@89 275
cannam@89 276 end.