d710e13d13c689c55dba3ad4c2bfbdb16bfc23aa
[platform/upstream/zlib.git] / as400 / zlib.inc
1       *  ZLIB.INC - Interface to the general purpose compression library
2       *
3       *  ILE RPG400 version by Patrick Monnerat, DATASPHERE.
4       *  Version 1.2.5.3
5       *
6       *
7       *  WARNING:
8       *     Procedures inflateInit(), inflateInit2(), deflateInit(),
9       *         deflateInit2() and inflateBackInit() need to be called with
10       *         two additional arguments:
11       *         the package version string and the stream control structure.
12       *         size. This is needed because RPG lacks some macro feature.
13       *         Call these procedures as:
14       *             inflateInit(...: ZLIB_VERSION: %size(z_stream))
15       *
16       /if not defined(ZLIB_H_)
17       /define ZLIB_H_
18       *
19       **************************************************************************
20       *                               Constants
21       **************************************************************************
22       *
23       *  Versioning information.
24       *
25      D ZLIB_VERSION    C                   '1.2.5.3'
26      D ZLIB_VERNUM     C                   X'1253'
27      D ZLIB_VER_MAJOR  C                   1
28      D ZLIB_VER_MINOR  C                   2
29      D ZLIB_VER_REVISION...
30      D                 C                   5
31      D ZLIB_VER_SUBREVISION...
32      D                 C                   0
33       *
34       *  Other equates.
35       *
36      D Z_NO_FLUSH      C                   0
37      D Z_PARTIAL_FLUSH...
38      D                 C                   1
39      D Z_SYNC_FLUSH    C                   2
40      D Z_FULL_FLUSH    C                   3
41      D Z_FINISH        C                   4
42      D Z_BLOCK         C                   5
43      D Z_TREES         C                   6
44       *
45      D Z_OK            C                   0
46      D Z_STREAM_END    C                   1
47      D Z_NEED_DICT     C                   2
48      D Z_ERRNO         C                   -1
49      D Z_STREAM_ERROR  C                   -2
50      D Z_DATA_ERROR    C                   -3
51      D Z_MEM_ERROR     C                   -4
52      D Z_BUF_ERROR     C                   -5
53      DZ_VERSION_ERROR  C                   -6
54       *
55      D Z_NO_COMPRESSION...
56      D                 C                   0
57      D Z_BEST_SPEED    C                   1
58      D Z_BEST_COMPRESSION...
59      D                 C                   9
60      D Z_DEFAULT_COMPRESSION...
61      D                 C                   -1
62       *
63      D Z_FILTERED      C                   1
64      D Z_HUFFMAN_ONLY  C                   2
65      D Z_RLE           C                   3
66      D Z_DEFAULT_STRATEGY...
67      D                 C                   0
68       *
69      D Z_BINARY        C                   0
70      D Z_ASCII         C                   1
71      D Z_UNKNOWN       C                   2
72       *
73      D Z_DEFLATED      C                   8
74       *
75      D Z_NULL          C                   0
76       *
77       **************************************************************************
78       *                                 Types
79       **************************************************************************
80       *
81      D z_streamp       S               *                                        Stream struct ptr
82      D gzFile          S               *                                        File pointer
83      D z_off_t         S             10i 0                                      Stream offsets
84      D z_off64_t       S             20i 0                                      Stream offsets
85       *
86       **************************************************************************
87       *                               Structures
88       **************************************************************************
89       *
90       *  The GZIP encode/decode stream support structure.
91       *
92      D z_stream        DS                  align based(z_streamp)
93      D  zs_next_in                     *                                        Next input byte
94      D  zs_avail_in                  10U 0                                      Byte cnt at next_in
95      D  zs_total_in                  10U 0                                      Total bytes read
96      D  zs_next_out                    *                                        Output buffer ptr
97      D  zs_avail_out                 10U 0                                      Room left @ next_out
98      D  zs_total_out                 10U 0                                      Total bytes written
99      D  zs_msg                         *                                        Last errmsg or null
100      D  zs_state                       *                                        Internal state
101      D  zs_zalloc                      *   procptr                              Int. state allocator
102      D  zs_free                        *   procptr                              Int. state dealloc.
103      D  zs_opaque                      *                                        Private alloc. data
104      D  zs_data_type                 10i 0                                      ASC/BIN best guess
105      D  zs_adler                     10u 0                                      Uncompr. adler32 val
106      D                               10U 0                                      Reserved
107      D                               10U 0                                      Ptr. alignment
108       *
109       **************************************************************************
110       *                     Utility function prototypes
111       **************************************************************************
112       *
113      D compress        PR            10I 0 extproc('compress')
114      D  dest                      32767    options(*varsize)                    Destination buffer
115      D  destLen                      10U 0                                      Destination length
116      D  source                    32767    const options(*varsize)              Source buffer
117      D  sourceLen                    10u 0 value                                Source length
118       *
119      D compress2       PR            10I 0 extproc('compress2')
120      D  dest                      32767    options(*varsize)                    Destination buffer
121      D  destLen                      10U 0                                      Destination length
122      D  source                    32767    const options(*varsize)              Source buffer
123      D  sourceLen                    10U 0 value                                Source length
124      D  level                        10I 0 value                                Compression level
125       *
126      D compressBound   PR            10U 0 extproc('compressBound')
127      D  sourceLen                    10U 0 value
128       *
129      D uncompress      PR            10I 0 extproc('uncompress')
130      D  dest                      32767    options(*varsize)                    Destination buffer
131      D  destLen                      10U 0                                      Destination length
132      D  source                    32767    const options(*varsize)              Source buffer
133      D  sourceLen                    10U 0 value                                Source length
134       *
135       /if not defined(LARGE_FILES)
136      D gzopen          PR                  extproc('gzopen')
137      D                                     like(gzFile)
138      D  path                           *   value options(*string)               File pathname
139      D  mode                           *   value options(*string)               Open mode
140       /else
141      D gzopen          PR                  extproc('gzopen64')
142      D                                     like(gzFile)
143      D  path                           *   value options(*string)               File pathname
144      D  mode                           *   value options(*string)               Open mode
145       *
146      D gzopen64        PR                  extproc('gzopen64')
147      D                                     like(gzFile)
148      D  path                           *   value options(*string)               File pathname
149      D  mode                           *   value options(*string)               Open mode
150       /endif
151       *
152      D gzdopen         PR                  extproc('gzdopen')
153      D                                     like(gzFile)
154      D  fd                           10I 0 value                                File descriptor
155      D  mode                           *   value options(*string)               Open mode
156       *
157      D gzbuffer        PR            10I 0 extproc('gzbuffer')
158      D  file                               value like(gzFile)                   File pointer
159      D  size                         10U 0 value
160       *
161      D gzsetparams     PR            10I 0 extproc('gzsetparams')
162      D  file                               value like(gzFile)                   File pointer
163      D  level                        10I 0 value
164      D  strategy                     10I 0 value
165       *
166      D gzread          PR            10I 0 extproc('gzread')
167      D  file                               value like(gzFile)                   File pointer
168      D  buf                       32767    options(*varsize)                    Buffer
169      D  len                          10u 0 value                                Buffer length
170       *
171      D gzwrite         PR            10I 0 extproc('gzwrite')
172      D  file                               value like(gzFile)                   File pointer
173      D  buf                       32767    const options(*varsize)              Buffer
174      D  len                          10u 0 value                                Buffer length
175       *
176      D gzputs          PR            10I 0 extproc('gzputs')
177      D  file                               value like(gzFile)                   File pointer
178      D  s                              *   value options(*string)               String to output
179       *
180      D gzgets          PR              *   extproc('gzgets')
181      D  file                               value like(gzFile)                   File pointer
182      D  buf                       32767    options(*varsize)                    Read buffer
183      D  len                          10i 0 value                                Buffer length
184       *
185      D gzputc          PR            10i 0 extproc('gzputc')
186      D  file                               value like(gzFile)                   File pointer
187      D  c                            10I 0 value                                Character to write
188       *
189      D gzgetc_         PR            10i 0 extproc('gzgetc_')
190      D  file                               value like(gzFile)                   File pointer
191       *
192      D gzungetc        PR            10i 0 extproc('gzungetc')
193      D  c                            10I 0 value                                Character to push
194      D  file                               value like(gzFile)                   File pointer
195       *
196      D gzflush         PR            10i 0 extproc('gzflush')
197      D  file                               value like(gzFile)                   File pointer
198      D  flush                        10I 0 value                                Type of flush
199       *
200       /if not defined(LARGE_FILES)
201      D gzseek          PR                  extproc('gzseek')
202      D                                     like(z_off_t)
203      D  file                               value like(gzFile)                   File pointer
204      D  offset                             value like(z_off_t)                  Offset
205      D  whence                       10i 0 value                                Origin
206       /else
207      D gzseek          PR                  extproc('gzseek64')
208      D                                     like(z_off_t)
209      D  file                               value like(gzFile)                   File pointer
210      D  offset                             value like(z_off_t)                  Offset
211      D  whence                       10i 0 value                                Origin
212       *
213      D gzseek64        PR                  extproc('gzseek64')
214      D                                     like(z_off64_t)
215      D  file                               value like(gzFile)                   File pointer
216      D  offset                             value like(z_off64_t)                Offset
217      D  whence                       10i 0 value                                Origin
218       /endif
219       *
220      D gzrewind        PR            10i 0 extproc('gzrewind')
221      D  file                               value like(gzFile)                   File pointer
222       *
223       /if not defined(LARGE_FILES)
224      D gztell          PR                  extproc('gztell')
225      D                                     like(z_off_t)
226      D  file                               value like(gzFile)                   File pointer
227       /else
228      D gztell          PR                  extproc('gztell64')
229      D                                     like(z_off_t)
230      D  file                               value like(gzFile)                   File pointer
231       *
232      D gztell64        PR                  extproc('gztell64')
233      D                                     like(z_off64_t)
234      D  file                               value like(gzFile)                   File pointer
235       /endif
236       *
237       /if not defined(LARGE_FILES)
238      D gzoffset        PR                  extproc('gzoffset')
239      D                                     like(z_off_t)
240      D  file                               value like(gzFile)                   File pointer
241       /else
242      D gzoffset        PR                  extproc('gzoffset64')
243      D                                     like(z_off_t)
244      D  file                               value like(gzFile)                   File pointer
245       *
246      D gzoffset64      PR                  extproc('gzoffset64')
247      D                                     like(z_off64_t)
248      D  file                               value like(gzFile)                   File pointer
249       /endif
250       *
251      D gzeof           PR            10i 0 extproc('gzeof')
252      D  file                               value like(gzFile)                   File pointer
253       *
254      D gzclose_r       PR            10i 0 extproc('gzclose_r')
255      D  file                               value like(gzFile)                   File pointer
256       *
257      D gzclose_w       PR            10i 0 extproc('gzclose_w')
258      D  file                               value like(gzFile)                   File pointer
259       *
260      D gzclose         PR            10i 0 extproc('gzclose')
261      D  file                               value like(gzFile)                   File pointer
262       *
263      D gzerror         PR              *   extproc('gzerror')                   Error string
264      D  file                               value like(gzFile)                   File pointer
265      D  errnum                       10I 0                                      Error code
266       *
267      D gzclearerr      PR                  extproc('gzclearerr')
268      D  file                               value like(gzFile)                   File pointer
269       *
270       **************************************************************************
271       *                        Basic function prototypes
272       **************************************************************************
273       *
274      D zlibVersion     PR              *   extproc('zlibVersion')               Version string
275       *
276      D deflateInit     PR            10I 0 extproc('deflateInit_')              Init. compression
277      D  strm                               like(z_stream)                       Compression stream
278      D  level                        10I 0 value                                Compression level
279      D  version                        *   value options(*string)               Version string
280      D  stream_size                  10i 0 value                                Stream struct. size
281       *
282      D deflate         PR            10I 0 extproc('deflate')                   Compress data
283      D  strm                               like(z_stream)                       Compression stream
284      D  flush                        10I 0 value                                Flush type required
285       *
286      D deflateEnd      PR            10I 0 extproc('deflateEnd')                Termin. compression
287      D  strm                               like(z_stream)                       Compression stream
288       *
289      D inflateInit     PR            10I 0 extproc('inflateInit_')              Init. expansion
290      D  strm                               like(z_stream)                       Expansion stream
291      D  version                        *   value options(*string)               Version string
292      D  stream_size                  10i 0 value                                Stream struct. size
293       *
294      D inflate         PR            10I 0 extproc('inflate')                   Expand data
295      D  strm                               like(z_stream)                       Expansion stream
296      D  flush                        10I 0 value                                Flush type required
297       *
298      D inflateEnd      PR            10I 0 extproc('inflateEnd')                Termin. expansion
299      D  strm                               like(z_stream)                       Expansion stream
300       *
301       **************************************************************************
302       *                        Advanced function prototypes
303       **************************************************************************
304       *
305      D deflateInit2    PR            10I 0 extproc('deflateInit2_')             Init. compression
306      D  strm                               like(z_stream)                       Compression stream
307      D  level                        10I 0 value                                Compression level
308      D  method                       10I 0 value                                Compression method
309      D  windowBits                   10I 0 value                                log2(window size)
310      D  memLevel                     10I 0 value                                Mem/cmpress tradeoff
311      D  strategy                     10I 0 value                                Compression stategy
312      D  version                        *   value options(*string)               Version string
313      D  stream_size                  10i 0 value                                Stream struct. size
314       *
315      D deflateSetDictionary...
316      D                 PR            10I 0 extproc('deflateSetDictionary')      Init. dictionary
317      D  strm                               like(z_stream)                       Compression stream
318      D  dictionary                32767    const options(*varsize)              Dictionary bytes
319      D  dictLength                   10U 0 value                                Dictionary length
320       *
321      D deflateCopy     PR            10I 0 extproc('deflateCopy')               Compress strm 2 strm
322      D  dest                               like(z_stream)                       Destination stream
323      D  source                             like(z_stream)                       Source stream
324       *
325      D deflateReset    PR            10I 0 extproc('deflateReset')              End and init. stream
326      D  strm                               like(z_stream)                       Compression stream
327       *
328      D deflateParams   PR            10I 0 extproc('deflateParams')             Change level & strat
329      D  strm                               like(z_stream)                       Compression stream
330      D  level                        10I 0 value                                Compression level
331      D  strategy                     10I 0 value                                Compression stategy
332       *
333      D deflateBound    PR            10U 0 extproc('deflateBound')              Change level & strat
334      D  strm                               like(z_stream)                       Compression stream
335      D  sourcelen                    10U 0 value                                Compression level
336       *
337      D deflatePending  PR            10I 0 extproc('deflatePending')            Change level & strat
338      D  strm                               like(z_stream)                       Compression stream
339      D  pending                      10U 0                                      Pending bytes
340      D  bits                         10I 0                                      Pending bits
341       *
342      D deflatePrime    PR            10I 0 extproc('deflatePrime')              Change level & strat
343      D  strm                               like(z_stream)                       Compression stream
344      D  bits                         10I 0 value                                Number of bits to insert
345      D  value                        10I 0 value                                Bits to insert
346       *
347      D inflateInit2    PR            10I 0 extproc('inflateInit2_')             Init. expansion
348      D  strm                               like(z_stream)                       Expansion stream
349      D  windowBits                   10I 0 value                                log2(window size)
350      D  version                        *   value options(*string)               Version string
351      D  stream_size                  10i 0 value                                Stream struct. size
352       *
353      D inflateSetDictionary...
354      D                 PR            10I 0 extproc('inflateSetDictionary')      Init. dictionary
355      D  strm                               like(z_stream)                       Expansion stream
356      D  dictionary                32767    const options(*varsize)              Dictionary bytes
357      D  dictLength                   10U 0 value                                Dictionary length
358       *
359      D inflateSync     PR            10I 0 extproc('inflateSync')               Sync. expansion
360      D  strm                               like(z_stream)                       Expansion stream
361       *
362      D inflateCopy     PR            10I 0 extproc('inflateCopy')
363      D  dest                               like(z_stream)                       Destination stream
364      D  source                             like(z_stream)                       Source stream
365       *
366      D inflateReset    PR            10I 0 extproc('inflateReset')              End and init. stream
367      D  strm                               like(z_stream)                       Expansion stream
368       *
369      D inflateReset2   PR            10I 0 extproc('inflateReset2')             End and init. stream
370      D  strm                               like(z_stream)                       Expansion stream
371      D  windowBits                   10I 0 value                                Log2(buffer size)
372       *
373      D inflatePrime    PR            10I 0 extproc('inflatePrime')              Insert bits
374      D  strm                               like(z_stream)                       Expansion stream
375      D  bits                         10I 0 value                                Bit count
376      D  value                        10I 0 value                                Bits to insert
377       *
378      D inflateMark     PR            10I 0 extproc('inflateMark')               Get inflate info
379      D  strm                               like(z_stream)                       Expansion stream
380       *
381      D inflateBackInit...
382      D                 PR            10I 0 extproc('inflateBackInit_')
383      D  strm                               like(z_stream)                       Expansion stream
384      D  windowBits                   10I 0 value                                Log2(buffer size)
385      D  window                    32767    options(*varsize)                    Buffer
386      D  version                        *   value options(*string)               Version string
387      D  stream_size                  10i 0 value                                Stream struct. size
388       *
389      D inflateBack     PR            10I 0 extproc('inflateBack')
390      D  strm                               like(z_stream)                       Expansion stream
391      D  in                             *   value procptr                        Input function
392      D  in_desc                        *   value                                Input descriptor
393      D  out                            *   value procptr                        Output function
394      D  out_desc                       *   value                                Output descriptor
395       *
396      D inflateBackEnd  PR            10I 0 extproc('inflateBackEnd')
397      D  strm                               like(z_stream)                       Expansion stream
398       *
399      D zlibCompileFlags...
400      D                 PR            10U 0 extproc('zlibCompileFlags')
401       *
402       **************************************************************************
403       *                        Checksum function prototypes
404       **************************************************************************
405       *
406      D adler32         PR            10U 0 extproc('adler32')                   New checksum
407      D  adler                        10U 0 value                                Old checksum
408      D  buf                       32767    const options(*varsize)              Bytes to accumulate
409      D  len                          10U 0 value                                Buffer length
410       *
411      D crc32           PR            10U 0 extproc('crc32')                     New checksum
412      D  crc                          10U 0 value                                Old checksum
413      D  buf                       32767    const options(*varsize)              Bytes to accumulate
414      D  len                          10U 0 value                                Buffer length
415       *
416       **************************************************************************
417       *                     Miscellaneous function prototypes
418       **************************************************************************
419       *
420      D zError          PR              *   extproc('zError')                    Error string
421      D  err                          10I 0 value                                Error code
422       *
423      D inflateSyncPoint...
424      D                 PR            10I 0 extproc('inflateSyncPoint')
425      D  strm                               like(z_stream)                       Expansion stream
426       *
427      D get_crc_table   PR              *   extproc('get_crc_table')             Ptr to ulongs
428       *
429      D inflateUndermine...
430      D                 PR            10I 0 extproc('inflateUndermine')
431      D  strm                               like(z_stream)                       Expansion stream
432      D  arg                          10I 0 value                                Error code
433       *
434      D inflateResetKeep...
435      D                 PR            10I 0 extproc('inflateResetKeep')          End and init. stream
436      D  strm                               like(z_stream)                       Expansion stream
437       *
438      D deflateResetKeep...
439      D                 PR            10I 0 extproc('deflateResetKeep')          End and init. stream
440      D  strm                               like(z_stream)                       Expansion stream
441       *
442      D gzflags         PR            10U 0 extproc('gzflags')
443       *
444       /endif