1 unit zlibdef;
2 
3 interface
4 
5 uses
6   Windows;
7 
8 const
9   ZLIB_VERSION = '1.1.3';
10 
11 type
12   voidpf = Pointer;
13   int    = Integer;
14   uInt   = Cardinal;
15   pBytef = PChar;
16   uLong  = Cardinal;
17 
paquenull18   alloc_func = function(opaque: voidpf; items, size: uInt): voidpf;
19                     stdcall;
20   free_func  = procedure(opaque, address: voidpf);
21                     stdcall;
22 
23   internal_state = Pointer;
24 
25   z_streamp = ^z_stream;
26   z_stream = packed record
27     next_in: pBytef;          // next input byte
28     avail_in: uInt;           // number of bytes available at next_in
29     total_in: uLong;          // total nb of input bytes read so far
30 
31     next_out: pBytef;         // next output byte should be put there
32     avail_out: uInt;          // remaining free space at next_out
33     total_out: uLong;         // total nb of bytes output so far
34 
35     msg: PChar;               // last error message, NULL if no error
36     state: internal_state;    // not visible by applications
37 
38     zalloc: alloc_func;       // used to allocate the internal state
39     zfree: free_func;         // used to free the internal state
40     opaque: voidpf;           // private data object passed to zalloc and zfree
41 
42     data_type: int;           // best guess about the data type: ascii or binary
43     adler: uLong;             // adler32 value of the uncompressed data
44     reserved: uLong;          // reserved for future use
45     end;
46 
47 const
48   Z_NO_FLUSH      = 0;
49   Z_SYNC_FLUSH    = 2;
50   Z_FULL_FLUSH    = 3;
51   Z_FINISH        = 4;
52 
53   Z_OK            = 0;
54   Z_STREAM_END    = 1;
55 
56   Z_NO_COMPRESSION         =  0;
57   Z_BEST_SPEED             =  1;
58   Z_BEST_COMPRESSION       =  9;
59   Z_DEFAULT_COMPRESSION    = -1;
60 
61   Z_FILTERED            = 1;
62   Z_HUFFMAN_ONLY        = 2;
63   Z_DEFAULT_STRATEGY    = 0;
64 
65   Z_BINARY   = 0;
66   Z_ASCII    = 1;
67   Z_UNKNOWN  = 2;
68 
69   Z_DEFLATED    = 8;
70 
71   MAX_MEM_LEVEL = 9;
72 
adler32null73 function adler32(adler: uLong; const buf: pBytef; len: uInt): uLong;
74              stdcall;
crc32null75 function crc32(crc: uLong; const buf: pBytef; len: uInt): uLong;
76              stdcall;
deflatenull77 function deflate(strm: z_streamp; flush: int): int;
78              stdcall;
deflateCopynull79 function deflateCopy(dest, source: z_streamp): int;
80              stdcall;
deflateEndnull81 function deflateEnd(strm: z_streamp): int;
82              stdcall;
deflateInit2_null83 function deflateInit2_(strm: z_streamp; level, method,
84                        windowBits, memLevel, strategy: int;
85                        const version: PChar; stream_size: int): int;
86              stdcall;
deflateInit_null87 function deflateInit_(strm: z_streamp; level: int;
88                       const version: PChar; stream_size: int): int;
89              stdcall;
deflateParamsnull90 function deflateParams(strm: z_streamp; level, strategy: int): int;
91              stdcall;
deflateResetnull92 function deflateReset(strm: z_streamp): int;
93              stdcall;
deflateSetDictionarynull94 function deflateSetDictionary(strm: z_streamp;
95                               const dictionary: pBytef;
96                               dictLength: uInt): int;
97              stdcall;
inflatenull98 function inflate(strm: z_streamp; flush: int): int;
99              stdcall;
inflateEndnull100 function inflateEnd(strm: z_streamp): int;
101              stdcall;
inflateInit2_null102 function inflateInit2_(strm: z_streamp; windowBits: int;
103                        const version: PChar; stream_size: int): int;
104              stdcall;
inflateInit_null105 function inflateInit_(strm: z_streamp; const version: PChar;
106                       stream_size: int): int;
107              stdcall;
inflateResetnull108 function inflateReset(strm: z_streamp): int;
109              stdcall;
inflateSetDictionarynull110 function inflateSetDictionary(strm: z_streamp;
111                               const dictionary: pBytef;
112                               dictLength: uInt): int;
113              stdcall;
inflateSyncnull114 function inflateSync(strm: z_streamp): int;
115              stdcall;
116 
deflateInitnull117 function deflateInit(strm: z_streamp; level: int): int;
deflateInit2null118 function deflateInit2(strm: z_streamp; level, method, windowBits,
119                       memLevel, strategy: int): int;
inflateInitnull120 function inflateInit(strm: z_streamp): int;
inflateInit2null121 function inflateInit2(strm: z_streamp; windowBits: int): int;
122 
123 implementation
124 
deflateInitnull125 function deflateInit(strm: z_streamp; level: int): int;
126 begin
127   Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream));
128 end;
129 
deflateInit2null130 function deflateInit2(strm: z_streamp; level, method, windowBits,
131                       memLevel, strategy: int): int;
132 begin
133   Result := deflateInit2_(strm, level, method, windowBits, memLevel,
134                           strategy, ZLIB_VERSION, sizeof(z_stream));
135 end;
136 
inflateInitnull137 function inflateInit(strm: z_streamp): int;
138 begin
139   Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream));
140 end;
141 
inflateInit2null142 function inflateInit2(strm: z_streamp; windowBits: int): int;
143 begin
144   Result := inflateInit2_(strm, windowBits, ZLIB_VERSION,
145                           sizeof(z_stream));
146 end;
147 
148 const
149   zlibDLL = 'png32bd.dll';
150 
adler32null151 function adler32; external zlibDLL;
crc32null152 function crc32; external zlibDLL;
deflatenull153 function deflate; external zlibDLL;
deflateCopynull154 function deflateCopy; external zlibDLL;
deflateEndnull155 function deflateEnd; external zlibDLL;
deflateInit2_null156 function deflateInit2_; external zlibDLL;
deflateInit_null157 function deflateInit_; external zlibDLL;
deflateParamsnull158 function deflateParams; external zlibDLL;
deflateResetnull159 function deflateReset; external zlibDLL;
deflateSetDictionarynull160 function deflateSetDictionary; external zlibDLL;
inflatenull161 function inflate; external zlibDLL;
inflateEndnull162 function inflateEnd; external zlibDLL;
inflateInit2_null163 function inflateInit2_; external zlibDLL;
inflateInit_null164 function inflateInit_; external zlibDLL;
inflateResetnull165 function inflateReset; external zlibDLL;
inflateSetDictionarynull166 function inflateSetDictionary; external zlibDLL;
inflateSyncnull167 function inflateSync; external zlibDLL;
168 
169 end.
170