revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / z / os400 / zlib.inc
blobc6aca2cbd6ae6f95e75fd1628ea5d60cd67e148b
1       *  ZLIB.INC - Interface to the general purpose compression library
2       *
3       *  ILE RPG400 version by Patrick Monnerat, DATASPHERE.
4       *  Version 1.2.11
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.11'
26      D ZLIB_VERNUM     C                   X'12a0'
27      D ZLIB_VER_MAJOR  C                   1
28      D ZLIB_VER_MINOR  C                   2
29      D ZLIB_VER_REVISION...
30      D                 C                   11
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      D Z_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 gz_headerp      S               *
84      D z_off_t         S             10i 0                                      Stream offsets
85      D z_off64_t       S             20i 0                                      Stream offsets
86       *
87       **************************************************************************
88       *                               Structures
89       **************************************************************************
90       *
91       *  The GZIP encode/decode stream support structure.
92       *
93      D z_stream        DS                  align based(z_streamp)
94      D  zs_next_in                     *                                        Next input byte
95      D  zs_avail_in                  10U 0                                      Byte cnt at next_in
96      D  zs_total_in                  10U 0                                      Total bytes read
97      D  zs_next_out                    *                                        Output buffer ptr
98      D  zs_avail_out                 10U 0                                      Room left @ next_out
99      D  zs_total_out                 10U 0                                      Total bytes written
100      D  zs_msg                         *                                        Last errmsg or null
101      D  zs_state                       *                                        Internal state
102      D  zs_zalloc                      *   procptr                              Int. state allocator
103      D  zs_free                        *   procptr                              Int. state dealloc.
104      D  zs_opaque                      *                                        Private alloc. data
105      D  zs_data_type                 10i 0                                      ASC/BIN best guess
106      D  zs_adler                     10u 0                                      Uncompr. adler32 val
107      D                               10U 0                                      Reserved
108      D                               10U 0                                      Ptr. alignment
109       *
110       **************************************************************************
111       *                     Utility function prototypes
112       **************************************************************************
113       *
114      D compress        PR            10I 0 extproc('compress')
115      D  dest                      65535    options(*varsize)                    Destination buffer
116      D  destLen                      10U 0                                      Destination length
117      D  source                    65535    const options(*varsize)              Source buffer
118      D  sourceLen                    10u 0 value                                Source length
119       *
120      D compress2       PR            10I 0 extproc('compress2')
121      D  dest                      65535    options(*varsize)                    Destination buffer
122      D  destLen                      10U 0                                      Destination length
123      D  source                    65535    const options(*varsize)              Source buffer
124      D  sourceLen                    10U 0 value                                Source length
125      D  level                        10I 0 value                                Compression level
126       *
127      D compressBound   PR            10U 0 extproc('compressBound')
128      D  sourceLen                    10U 0 value
129       *
130      D uncompress      PR            10I 0 extproc('uncompress')
131      D  dest                      65535    options(*varsize)                    Destination buffer
132      D  destLen                      10U 0                                      Destination length
133      D  source                    65535    const options(*varsize)              Source buffer
134      D  sourceLen                    10U 0 value                                Source length
135       *
136      D uncompress2     PR            10I 0 extproc('uncompress2')
137      D  dest                      65535    options(*varsize)                    Destination buffer
138      D  destLen                      10U 0                                      Destination length
139      D  source                    65535    const options(*varsize)              Source buffer
140      D  sourceLen                    10U 0                                      Source length
141       *
142       /if not defined(LARGE_FILES)
143      D gzopen          PR                  extproc('gzopen')
144      D                                     like(gzFile)
145      D  path                           *   value options(*string)               File pathname
146      D  mode                           *   value options(*string)               Open mode
147       /else
148      D gzopen          PR                  extproc('gzopen64')
149      D                                     like(gzFile)
150      D  path                           *   value options(*string)               File pathname
151      D  mode                           *   value options(*string)               Open mode
152       *
153      D gzopen64        PR                  extproc('gzopen64')
154      D                                     like(gzFile)
155      D  path                           *   value options(*string)               File pathname
156      D  mode                           *   value options(*string)               Open mode
157       /endif
158       *
159      D gzdopen         PR                  extproc('gzdopen')
160      D                                     like(gzFile)
161      D  fd                           10I 0 value                                File descriptor
162      D  mode                           *   value options(*string)               Open mode
163       *
164      D gzbuffer        PR            10I 0 extproc('gzbuffer')
165      D  file                               value like(gzFile)                   File pointer
166      D  size                         10U 0 value
167       *
168      D gzsetparams     PR            10I 0 extproc('gzsetparams')
169      D  file                               value like(gzFile)                   File pointer
170      D  level                        10I 0 value
171      D  strategy                     10I 0 value
172       *
173      D gzread          PR            10I 0 extproc('gzread')
174      D  file                               value like(gzFile)                   File pointer
175      D  buf                       65535    options(*varsize)                    Buffer
176      D  len                          10u 0 value                                Buffer length
177       *
178      D gzfread          PR           20I 0 extproc('gzfread')
179      D  buf                       65535    options(*varsize)                    Buffer
180      D  size                         20u 0 value                                Buffer length
181      D  nitems                       20u 0 value                                Buffer length
182      D  file                               value like(gzFile)                   File pointer
183       *
184      D gzwrite         PR            10I 0 extproc('gzwrite')
185      D  file                               value like(gzFile)                   File pointer
186      D  buf                       65535    const options(*varsize)              Buffer
187      D  len                          10u 0 value                                Buffer length
188       *
189      D gzfwrite         PR           20I 0 extproc('gzfwrite')
190      D  buf                       65535    options(*varsize)                    Buffer
191      D  size                         20u 0 value                                Buffer length
192      D  nitems                       20u 0 value                                Buffer length
193      D  file                               value like(gzFile)                   File pointer
194       *
195      D gzputs          PR            10I 0 extproc('gzputs')
196      D  file                               value like(gzFile)                   File pointer
197      D  s                              *   value options(*string)               String to output
198       *
199      D gzgets          PR              *   extproc('gzgets')
200      D  file                               value like(gzFile)                   File pointer
201      D  buf                       65535    options(*varsize)                    Read buffer
202      D  len                          10i 0 value                                Buffer length
203       *
204      D gzputc          PR            10i 0 extproc('gzputc')
205      D  file                               value like(gzFile)                   File pointer
206      D  c                            10I 0 value                                Character to write
207       *
208      D gzgetc          PR            10i 0 extproc('gzgetc')
209      D  file                               value like(gzFile)                   File pointer
210       *
211      D gzgetc_         PR            10i 0 extproc('gzgetc_')
212      D  file                               value like(gzFile)                   File pointer
213       *
214      D gzungetc        PR            10i 0 extproc('gzungetc')
215      D  c                            10I 0 value                                Character to push
216      D  file                               value like(gzFile)                   File pointer
217       *
218      D gzflush         PR            10i 0 extproc('gzflush')
219      D  file                               value like(gzFile)                   File pointer
220      D  flush                        10I 0 value                                Type of flush
221       *
222       /if not defined(LARGE_FILES)
223      D gzseek          PR                  extproc('gzseek')
224      D                                     like(z_off_t)
225      D  file                               value like(gzFile)                   File pointer
226      D  offset                             value like(z_off_t)                  Offset
227      D  whence                       10i 0 value                                Origin
228       /else
229      D gzseek          PR                  extproc('gzseek64')
230      D                                     like(z_off_t)
231      D  file                               value like(gzFile)                   File pointer
232      D  offset                             value like(z_off_t)                  Offset
233      D  whence                       10i 0 value                                Origin
234       *
235      D gzseek64        PR                  extproc('gzseek64')
236      D                                     like(z_off64_t)
237      D  file                               value like(gzFile)                   File pointer
238      D  offset                             value like(z_off64_t)                Offset
239      D  whence                       10i 0 value                                Origin
240       /endif
241       *
242      D gzrewind        PR            10i 0 extproc('gzrewind')
243      D  file                               value like(gzFile)                   File pointer
244       *
245       /if not defined(LARGE_FILES)
246      D gztell          PR                  extproc('gztell')
247      D                                     like(z_off_t)
248      D  file                               value like(gzFile)                   File pointer
249       /else
250      D gztell          PR                  extproc('gztell64')
251      D                                     like(z_off_t)
252      D  file                               value like(gzFile)                   File pointer
253       *
254      D gztell64        PR                  extproc('gztell64')
255      D                                     like(z_off64_t)
256      D  file                               value like(gzFile)                   File pointer
257       /endif
258       *
259       /if not defined(LARGE_FILES)
260      D gzoffset        PR                  extproc('gzoffset')
261      D                                     like(z_off_t)
262      D  file                               value like(gzFile)                   File pointer
263       /else
264      D gzoffset        PR                  extproc('gzoffset64')
265      D                                     like(z_off_t)
266      D  file                               value like(gzFile)                   File pointer
267       *
268      D gzoffset64      PR                  extproc('gzoffset64')
269      D                                     like(z_off64_t)
270      D  file                               value like(gzFile)                   File pointer
271       /endif
272       *
273      D gzeof           PR            10i 0 extproc('gzeof')
274      D  file                               value like(gzFile)                   File pointer
275       *
276      D gzdirect        PR            10i 0 extproc('gzdirect')
277      D  file                               value like(gzFile)                   File pointer
278       *
279      D gzclose_r       PR            10i 0 extproc('gzclose_r')
280      D  file                               value like(gzFile)                   File pointer
281       *
282      D gzclose_w       PR            10i 0 extproc('gzclose_w')
283      D  file                               value like(gzFile)                   File pointer
284       *
285      D gzclose         PR            10i 0 extproc('gzclose')
286      D  file                               value like(gzFile)                   File pointer
287       *
288      D gzerror         PR              *   extproc('gzerror')                   Error string
289      D  file                               value like(gzFile)                   File pointer
290      D  errnum                       10I 0                                      Error code
291       *
292      D gzclearerr      PR                  extproc('gzclearerr')
293      D  file                               value like(gzFile)                   File pointer
294       *
295       **************************************************************************
296       *                        Basic function prototypes
297       **************************************************************************
298       *
299      D zlibVersion     PR              *   extproc('zlibVersion')               Version string
300       *
301      D deflateInit     PR            10I 0 extproc('deflateInit_')              Init. compression
302      D  strm                               like(z_stream)                       Compression stream
303      D  level                        10I 0 value                                Compression level
304      D  version                        *   value options(*string)               Version string
305      D  stream_size                  10i 0 value                                Stream struct. size
306       *
307      D deflate         PR            10I 0 extproc('deflate')                   Compress data
308      D  strm                               like(z_stream)                       Compression stream
309      D  flush                        10I 0 value                                Flush type required
310       *
311      D deflateEnd      PR            10I 0 extproc('deflateEnd')                Termin. compression
312      D  strm                               like(z_stream)                       Compression stream
313       *
314      D inflateInit     PR            10I 0 extproc('inflateInit_')              Init. expansion
315      D  strm                               like(z_stream)                       Expansion stream
316      D  version                        *   value options(*string)               Version string
317      D  stream_size                  10i 0 value                                Stream struct. size
318       *
319      D inflate         PR            10I 0 extproc('inflate')                   Expand data
320      D  strm                               like(z_stream)                       Expansion stream
321      D  flush                        10I 0 value                                Flush type required
322       *
323      D inflateEnd      PR            10I 0 extproc('inflateEnd')                Termin. expansion
324      D  strm                               like(z_stream)                       Expansion stream
325       *
326       **************************************************************************
327       *                        Advanced function prototypes
328       **************************************************************************
329       *
330      D deflateInit2    PR            10I 0 extproc('deflateInit2_')             Init. compression
331      D  strm                               like(z_stream)                       Compression stream
332      D  level                        10I 0 value                                Compression level
333      D  method                       10I 0 value                                Compression method
334      D  windowBits                   10I 0 value                                log2(window size)
335      D  memLevel                     10I 0 value                                Mem/cmpress tradeoff
336      D  strategy                     10I 0 value                                Compression strategy
337      D  version                        *   value options(*string)               Version string
338      D  stream_size                  10i 0 value                                Stream struct. size
339       *
340      D deflateSetDictionary...
341      D                 PR            10I 0 extproc('deflateSetDictionary')      Init. dictionary
342      D  strm                               like(z_stream)                       Compression stream
343      D  dictionary                65535    const options(*varsize)              Dictionary bytes
344      D  dictLength                   10U 0 value                                Dictionary length
345       *
346      D deflateCopy     PR            10I 0 extproc('deflateCopy')               Compress strm 2 strm
347      D  dest                               like(z_stream)                       Destination stream
348      D  source                             like(z_stream)                       Source stream
349       *
350      D deflateReset    PR            10I 0 extproc('deflateReset')              End and init. stream
351      D  strm                               like(z_stream)                       Compression stream
352       *
353      D deflateParams   PR            10I 0 extproc('deflateParams')             Change level & strat
354      D  strm                               like(z_stream)                       Compression stream
355      D  level                        10I 0 value                                Compression level
356      D  strategy                     10I 0 value                                Compression strategy
357       *
358      D deflateTune     PR            10I 0 extproc('deflateTune')
359      D  strm                               like(z_stream)                       Compression stream
360      D  good                         10I 0 value
361      D  lazy                         10I 0 value
362      D  nice                         10I 0 value
363      D  chain                        10I 0 value
364       *
365      D deflateBound    PR            10U 0 extproc('deflateBound')              Change level & strat
366      D  strm                               like(z_stream)                       Compression stream
367      D  sourcelen                    10U 0 value                                Compression level
368       *
369      D deflatePending  PR            10I 0 extproc('deflatePending')            Change level & strat
370      D  strm                               like(z_stream)                       Compression stream
371      D  pending                      10U 0                                      Pending bytes
372      D  bits                         10I 0                                      Pending bits
373       *
374      D deflatePrime    PR            10I 0 extproc('deflatePrime')              Change level & strat
375      D  strm                               like(z_stream)                       Compression stream
376      D  bits                         10I 0 value                                # of bits to insert
377      D  value                        10I 0 value                                Bits to insert
378       *
379      D inflateInit2    PR            10I 0 extproc('inflateInit2_')             Init. expansion
380      D  strm                               like(z_stream)                       Expansion stream
381      D  windowBits                   10I 0 value                                log2(window size)
382      D  version                        *   value options(*string)               Version string
383      D  stream_size                  10i 0 value                                Stream struct. size
384       *
385      D inflateSetDictionary...
386      D                 PR            10I 0 extproc('inflateSetDictionary')      Init. dictionary
387      D  strm                               like(z_stream)                       Expansion stream
388      D  dictionary                65535    const options(*varsize)              Dictionary bytes
389      D  dictLength                   10U 0 value                                Dictionary length
390       *
391      D inflateGetDictionary...
392      D                 PR            10I 0 extproc('inflateGetDictionary')      Get dictionary
393      D  strm                               like(z_stream)                       Expansion stream
394      D  dictionary                65535    options(*varsize)                    Dictionary bytes
395      D  dictLength                   10U 0                                      Dictionary length
396       *
397      D deflateGetDictionary...
398      D                 PR            10I 0 extproc('deflateGetDictionary')      Get dictionary
399      D  strm                               like(z_stream)                       Expansion stream
400      D  dictionary                65535    options(*varsize)                    Dictionary bytes
401      D  dictLength                   10U 0                                      Dictionary length
402       *
403      D inflateSync     PR            10I 0 extproc('inflateSync')               Sync. expansion
404      D  strm                               like(z_stream)                       Expansion stream
405       *
406      D inflateCopy     PR            10I 0 extproc('inflateCopy')
407      D  dest                               like(z_stream)                       Destination stream
408      D  source                             like(z_stream)                       Source stream
409       *
410      D inflateReset    PR            10I 0 extproc('inflateReset')              End and init. stream
411      D  strm                               like(z_stream)                       Expansion stream
412       *
413      D inflateReset2   PR            10I 0 extproc('inflateReset2')             End and init. stream
414      D  strm                               like(z_stream)                       Expansion stream
415      D  windowBits                   10I 0 value                                Log2(buffer size)
416       *
417      D inflatePrime    PR            10I 0 extproc('inflatePrime')              Insert bits
418      D  strm                               like(z_stream)                       Expansion stream
419      D  bits                         10I 0 value                                Bit count
420      D  value                        10I 0 value                                Bits to insert
421       *
422      D inflateMark     PR            10I 0 extproc('inflateMark')               Get inflate info
423      D  strm                               like(z_stream)                       Expansion stream
424       *
425      D inflateCodesUsed...
426                        PR            20U 0 extproc('inflateCodesUsed')
427      D  strm                               like(z_stream)                       Expansion stream
428       *
429      D inflateValidate...
430                        PR            20U 0 extproc('inflateValidate')
431      D  strm                               like(z_stream)                       Expansion stream
432      D  check                        10I 0 value
433       *
434      D inflateGetHeader...
435                        PR            10U 0 extproc('inflateGetHeader')
436      D  strm                               like(z_stream)                       Expansion stream
437      D  head                               like(gz_headerp)
438       *
439      D deflateSetHeader...
440                        PR            10U 0 extproc('deflateSetHeader')
441      D  strm                               like(z_stream)                       Expansion stream
442      D  head                               like(gz_headerp)
443       *
444      D inflateBackInit...
445      D                 PR            10I 0 extproc('inflateBackInit_')
446      D  strm                               like(z_stream)                       Expansion stream
447      D  windowBits                   10I 0 value                                Log2(buffer size)
448      D  window                    65535    options(*varsize)                    Buffer
449      D  version                        *   value options(*string)               Version string
450      D  stream_size                  10i 0 value                                Stream struct. size
451       *
452      D inflateBack     PR            10I 0 extproc('inflateBack')
453      D  strm                               like(z_stream)                       Expansion stream
454      D  in                             *   value procptr                        Input function
455      D  in_desc                        *   value                                Input descriptor
456      D  out                            *   value procptr                        Output function
457      D  out_desc                       *   value                                Output descriptor
458       *
459      D inflateBackEnd  PR            10I 0 extproc('inflateBackEnd')
460      D  strm                               like(z_stream)                       Expansion stream
461       *
462      D zlibCompileFlags...
463      D                 PR            10U 0 extproc('zlibCompileFlags')
464       *
465       **************************************************************************
466       *                        Checksum function prototypes
467       **************************************************************************
468       *
469      D adler32         PR            10U 0 extproc('adler32')                   New checksum
470      D  adler                        10U 0 value                                Old checksum
471      D  buf                       65535    const options(*varsize)              Bytes to accumulate
472      D  len                          10U 0 value                                Buffer length
473       *
474      D adler32_combine...
475                        PR            10U 0 extproc('adler32_combine')           New checksum
476      D  adler1                       10U 0 value                                Old checksum
477      D  adler2                       10U 0 value                                Old checksum
478      D  len2                         20U 0 value                                Buffer length
479       *
480      D adler32_z       PR            10U 0 extproc('adler32_z')                 New checksum
481      D  adler                        10U 0 value                                Old checksum
482      D  buf                       65535    const options(*varsize)              Bytes to accumulate
483      D  len                          20U 0 value                                Buffer length
484       *
485      D crc32           PR            10U 0 extproc('crc32')                     New checksum
486      D  crc                          10U 0 value                                Old checksum
487      D  buf                       65535    const options(*varsize)              Bytes to accumulate
488      D  len                          10U 0 value                                Buffer length
489       *
490      D crc32_combine...
491                        PR            10U 0 extproc('crc32_combine')             New checksum
492      D  crc1                         10U 0 value                                Old checksum
493      D  crc2                         10U 0 value                                Old checksum
494      D  len2                         20U 0 value                                Buffer length
495       *
496      D crc32_z         PR            10U 0 extproc('crc32_z')                   New checksum
497      D  crc                          10U 0 value                                Old checksum
498      D  buf                       65535    const options(*varsize)              Bytes to accumulate
499      D  len                          20U 0 value                                Buffer length
500       *
501       **************************************************************************
502       *                     Miscellaneous function prototypes
503       **************************************************************************
504       *
505      D zError          PR              *   extproc('zError')                    Error string
506      D  err                          10I 0 value                                Error code
507       *
508      D inflateSyncPoint...
509      D                 PR            10I 0 extproc('inflateSyncPoint')
510      D  strm                               like(z_stream)                       Expansion stream
511       *
512      D get_crc_table   PR              *   extproc('get_crc_table')             Ptr to ulongs
513       *
514      D inflateUndermine...
515      D                 PR            10I 0 extproc('inflateUndermine')
516      D  strm                               like(z_stream)                       Expansion stream
517      D  arg                          10I 0 value                                Error code
518       *
519      D inflateResetKeep...
520      D                 PR            10I 0 extproc('inflateResetKeep')          End and init. stream
521      D  strm                               like(z_stream)                       Expansion stream
522       *
523      D deflateResetKeep...
524      D                 PR            10I 0 extproc('deflateResetKeep')          End and init. stream
525      D  strm                               like(z_stream)                       Expansion stream
526       *
527       /endif