1275793eaSopenharmony_ci/* zlib.h -- interface of the 'zlib' general purpose compression library
2275793eaSopenharmony_ci  version 1.3.1, January 22nd, 2024
3275793eaSopenharmony_ci
4275793eaSopenharmony_ci  Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
5275793eaSopenharmony_ci
6275793eaSopenharmony_ci  This software is provided 'as-is', without any express or implied
7275793eaSopenharmony_ci  warranty.  In no event will the authors be held liable for any damages
8275793eaSopenharmony_ci  arising from the use of this software.
9275793eaSopenharmony_ci
10275793eaSopenharmony_ci  Permission is granted to anyone to use this software for any purpose,
11275793eaSopenharmony_ci  including commercial applications, and to alter it and redistribute it
12275793eaSopenharmony_ci  freely, subject to the following restrictions:
13275793eaSopenharmony_ci
14275793eaSopenharmony_ci  1. The origin of this software must not be misrepresented; you must not
15275793eaSopenharmony_ci     claim that you wrote the original software. If you use this software
16275793eaSopenharmony_ci     in a product, an acknowledgment in the product documentation would be
17275793eaSopenharmony_ci     appreciated but is not required.
18275793eaSopenharmony_ci  2. Altered source versions must be plainly marked as such, and must not be
19275793eaSopenharmony_ci     misrepresented as being the original software.
20275793eaSopenharmony_ci  3. This notice may not be removed or altered from any source distribution.
21275793eaSopenharmony_ci
22275793eaSopenharmony_ci  Jean-loup Gailly        Mark Adler
23275793eaSopenharmony_ci  jloup@gzip.org          madler@alumni.caltech.edu
24275793eaSopenharmony_ci
25275793eaSopenharmony_ci
26275793eaSopenharmony_ci  The data format used by the zlib library is described by RFCs (Request for
27275793eaSopenharmony_ci  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
28275793eaSopenharmony_ci  (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
29275793eaSopenharmony_ci*/
30275793eaSopenharmony_ci
31275793eaSopenharmony_ci#ifndef ZLIB_H
32275793eaSopenharmony_ci#define ZLIB_H
33275793eaSopenharmony_ci
34275793eaSopenharmony_ci#include "zconf.h"
35275793eaSopenharmony_ci
36275793eaSopenharmony_ci#ifdef __cplusplus
37275793eaSopenharmony_ciextern "C" {
38275793eaSopenharmony_ci#endif
39275793eaSopenharmony_ci
40275793eaSopenharmony_ci#define ZLIB_VERSION "1.3.1"
41275793eaSopenharmony_ci#define ZLIB_VERNUM 0x1310
42275793eaSopenharmony_ci#define ZLIB_VER_MAJOR 1
43275793eaSopenharmony_ci#define ZLIB_VER_MINOR 3
44275793eaSopenharmony_ci#define ZLIB_VER_REVISION 1
45275793eaSopenharmony_ci#define ZLIB_VER_SUBREVISION 0
46275793eaSopenharmony_ci
47275793eaSopenharmony_ci/*
48275793eaSopenharmony_ci    The 'zlib' compression library provides in-memory compression and
49275793eaSopenharmony_ci  decompression functions, including integrity checks of the uncompressed data.
50275793eaSopenharmony_ci  This version of the library supports only one compression method (deflation)
51275793eaSopenharmony_ci  but other algorithms will be added later and will have the same stream
52275793eaSopenharmony_ci  interface.
53275793eaSopenharmony_ci
54275793eaSopenharmony_ci    Compression can be done in a single step if the buffers are large enough,
55275793eaSopenharmony_ci  or can be done by repeated calls of the compression function.  In the latter
56275793eaSopenharmony_ci  case, the application must provide more input and/or consume the output
57275793eaSopenharmony_ci  (providing more output space) before each call.
58275793eaSopenharmony_ci
59275793eaSopenharmony_ci    The compressed data format used by default by the in-memory functions is
60275793eaSopenharmony_ci  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
61275793eaSopenharmony_ci  around a deflate stream, which is itself documented in RFC 1951.
62275793eaSopenharmony_ci
63275793eaSopenharmony_ci    The library also supports reading and writing files in gzip (.gz) format
64275793eaSopenharmony_ci  with an interface similar to that of stdio using the functions that start
65275793eaSopenharmony_ci  with "gz".  The gzip format is different from the zlib format.  gzip is a
66275793eaSopenharmony_ci  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
67275793eaSopenharmony_ci
68275793eaSopenharmony_ci    This library can optionally read and write gzip and raw deflate streams in
69275793eaSopenharmony_ci  memory as well.
70275793eaSopenharmony_ci
71275793eaSopenharmony_ci    The zlib format was designed to be compact and fast for use in memory
72275793eaSopenharmony_ci  and on communications channels.  The gzip format was designed for single-
73275793eaSopenharmony_ci  file compression on file systems, has a larger header than zlib to maintain
74275793eaSopenharmony_ci  directory information, and uses a different, slower check method than zlib.
75275793eaSopenharmony_ci
76275793eaSopenharmony_ci    The library does not install any signal handler.  The decoder checks
77275793eaSopenharmony_ci  the consistency of the compressed data, so the library should never crash
78275793eaSopenharmony_ci  even in the case of corrupted input.
79275793eaSopenharmony_ci*/
80275793eaSopenharmony_ci
81275793eaSopenharmony_citypedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size);
82275793eaSopenharmony_citypedef void   (*free_func)(voidpf opaque, voidpf address);
83275793eaSopenharmony_ci
84275793eaSopenharmony_cistruct internal_state;
85275793eaSopenharmony_ci
86275793eaSopenharmony_citypedef struct z_stream_s {
87275793eaSopenharmony_ci    z_const Bytef *next_in;     /* next input byte */
88275793eaSopenharmony_ci    uInt     avail_in;  /* number of bytes available at next_in */
89275793eaSopenharmony_ci    uLong    total_in;  /* total number of input bytes read so far */
90275793eaSopenharmony_ci
91275793eaSopenharmony_ci    Bytef    *next_out; /* next output byte will go here */
92275793eaSopenharmony_ci    uInt     avail_out; /* remaining free space at next_out */
93275793eaSopenharmony_ci    uLong    total_out; /* total number of bytes output so far */
94275793eaSopenharmony_ci
95275793eaSopenharmony_ci    z_const char *msg;  /* last error message, NULL if no error */
96275793eaSopenharmony_ci    struct internal_state FAR *state; /* not visible by applications */
97275793eaSopenharmony_ci
98275793eaSopenharmony_ci    alloc_func zalloc;  /* used to allocate the internal state */
99275793eaSopenharmony_ci    free_func  zfree;   /* used to free the internal state */
100275793eaSopenharmony_ci    voidpf     opaque;  /* private data object passed to zalloc and zfree */
101275793eaSopenharmony_ci
102275793eaSopenharmony_ci    int     data_type;  /* best guess about the data type: binary or text
103275793eaSopenharmony_ci                           for deflate, or the decoding state for inflate */
104275793eaSopenharmony_ci    uLong   adler;      /* Adler-32 or CRC-32 value of the uncompressed data */
105275793eaSopenharmony_ci    uLong   reserved;   /* reserved for future use */
106275793eaSopenharmony_ci} z_stream;
107275793eaSopenharmony_ci
108275793eaSopenharmony_citypedef z_stream FAR *z_streamp;
109275793eaSopenharmony_ci
110275793eaSopenharmony_ci/*
111275793eaSopenharmony_ci     gzip header information passed to and from zlib routines.  See RFC 1952
112275793eaSopenharmony_ci  for more details on the meanings of these fields.
113275793eaSopenharmony_ci*/
114275793eaSopenharmony_citypedef struct gz_header_s {
115275793eaSopenharmony_ci    int     text;       /* true if compressed data believed to be text */
116275793eaSopenharmony_ci    uLong   time;       /* modification time */
117275793eaSopenharmony_ci    int     xflags;     /* extra flags (not used when writing a gzip file) */
118275793eaSopenharmony_ci    int     os;         /* operating system */
119275793eaSopenharmony_ci    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */
120275793eaSopenharmony_ci    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */
121275793eaSopenharmony_ci    uInt    extra_max;  /* space at extra (only when reading header) */
122275793eaSopenharmony_ci    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */
123275793eaSopenharmony_ci    uInt    name_max;   /* space at name (only when reading header) */
124275793eaSopenharmony_ci    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */
125275793eaSopenharmony_ci    uInt    comm_max;   /* space at comment (only when reading header) */
126275793eaSopenharmony_ci    int     hcrc;       /* true if there was or will be a header crc */
127275793eaSopenharmony_ci    int     done;       /* true when done reading gzip header (not used
128275793eaSopenharmony_ci                           when writing a gzip file) */
129275793eaSopenharmony_ci} gz_header;
130275793eaSopenharmony_ci
131275793eaSopenharmony_citypedef gz_header FAR *gz_headerp;
132275793eaSopenharmony_ci
133275793eaSopenharmony_ci/*
134275793eaSopenharmony_ci     The application must update next_in and avail_in when avail_in has dropped
135275793eaSopenharmony_ci   to zero.  It must update next_out and avail_out when avail_out has dropped
136275793eaSopenharmony_ci   to zero.  The application must initialize zalloc, zfree and opaque before
137275793eaSopenharmony_ci   calling the init function.  All other fields are set by the compression
138275793eaSopenharmony_ci   library and must not be updated by the application.
139275793eaSopenharmony_ci
140275793eaSopenharmony_ci     The opaque value provided by the application will be passed as the first
141275793eaSopenharmony_ci   parameter for calls of zalloc and zfree.  This can be useful for custom
142275793eaSopenharmony_ci   memory management.  The compression library attaches no meaning to the
143275793eaSopenharmony_ci   opaque value.
144275793eaSopenharmony_ci
145275793eaSopenharmony_ci     zalloc must return Z_NULL if there is not enough memory for the object.
146275793eaSopenharmony_ci   If zlib is used in a multi-threaded application, zalloc and zfree must be
147275793eaSopenharmony_ci   thread safe.  In that case, zlib is thread-safe.  When zalloc and zfree are
148275793eaSopenharmony_ci   Z_NULL on entry to the initialization function, they are set to internal
149275793eaSopenharmony_ci   routines that use the standard library functions malloc() and free().
150275793eaSopenharmony_ci
151275793eaSopenharmony_ci     On 16-bit systems, the functions zalloc and zfree must be able to allocate
152275793eaSopenharmony_ci   exactly 65536 bytes, but will not be required to allocate more than this if
153275793eaSopenharmony_ci   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers
154275793eaSopenharmony_ci   returned by zalloc for objects of exactly 65536 bytes *must* have their
155275793eaSopenharmony_ci   offset normalized to zero.  The default allocation function provided by this
156275793eaSopenharmony_ci   library ensures this (see zutil.c).  To reduce memory requirements and avoid
157275793eaSopenharmony_ci   any allocation of 64K objects, at the expense of compression ratio, compile
158275793eaSopenharmony_ci   the library with -DMAX_WBITS=14 (see zconf.h).
159275793eaSopenharmony_ci
160275793eaSopenharmony_ci     The fields total_in and total_out can be used for statistics or progress
161275793eaSopenharmony_ci   reports.  After compression, total_in holds the total size of the
162275793eaSopenharmony_ci   uncompressed data and may be saved for use by the decompressor (particularly
163275793eaSopenharmony_ci   if the decompressor wants to decompress everything in a single step).
164275793eaSopenharmony_ci*/
165275793eaSopenharmony_ci
166275793eaSopenharmony_ci                        /* constants */
167275793eaSopenharmony_ci
168275793eaSopenharmony_ci#define Z_NO_FLUSH      0
169275793eaSopenharmony_ci#define Z_PARTIAL_FLUSH 1
170275793eaSopenharmony_ci#define Z_SYNC_FLUSH    2
171275793eaSopenharmony_ci#define Z_FULL_FLUSH    3
172275793eaSopenharmony_ci#define Z_FINISH        4
173275793eaSopenharmony_ci#define Z_BLOCK         5
174275793eaSopenharmony_ci#define Z_TREES         6
175275793eaSopenharmony_ci/* Allowed flush values; see deflate() and inflate() below for details */
176275793eaSopenharmony_ci
177275793eaSopenharmony_ci#define Z_OK            0
178275793eaSopenharmony_ci#define Z_STREAM_END    1
179275793eaSopenharmony_ci#define Z_NEED_DICT     2
180275793eaSopenharmony_ci#define Z_ERRNO        (-1)
181275793eaSopenharmony_ci#define Z_STREAM_ERROR (-2)
182275793eaSopenharmony_ci#define Z_DATA_ERROR   (-3)
183275793eaSopenharmony_ci#define Z_MEM_ERROR    (-4)
184275793eaSopenharmony_ci#define Z_BUF_ERROR    (-5)
185275793eaSopenharmony_ci#define Z_VERSION_ERROR (-6)
186275793eaSopenharmony_ci/* Return codes for the compression/decompression functions. Negative values
187275793eaSopenharmony_ci * are errors, positive values are used for special but normal events.
188275793eaSopenharmony_ci */
189275793eaSopenharmony_ci
190275793eaSopenharmony_ci#define Z_NO_COMPRESSION         0
191275793eaSopenharmony_ci#define Z_BEST_SPEED             1
192275793eaSopenharmony_ci#define Z_BEST_COMPRESSION       9
193275793eaSopenharmony_ci#define Z_DEFAULT_COMPRESSION  (-1)
194275793eaSopenharmony_ci/* compression levels */
195275793eaSopenharmony_ci
196275793eaSopenharmony_ci#define Z_FILTERED            1
197275793eaSopenharmony_ci#define Z_HUFFMAN_ONLY        2
198275793eaSopenharmony_ci#define Z_RLE                 3
199275793eaSopenharmony_ci#define Z_FIXED               4
200275793eaSopenharmony_ci#define Z_DEFAULT_STRATEGY    0
201275793eaSopenharmony_ci/* compression strategy; see deflateInit2() below for details */
202275793eaSopenharmony_ci
203275793eaSopenharmony_ci#define Z_BINARY   0
204275793eaSopenharmony_ci#define Z_TEXT     1
205275793eaSopenharmony_ci#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */
206275793eaSopenharmony_ci#define Z_UNKNOWN  2
207275793eaSopenharmony_ci/* Possible values of the data_type field for deflate() */
208275793eaSopenharmony_ci
209275793eaSopenharmony_ci#define Z_DEFLATED   8
210275793eaSopenharmony_ci/* The deflate compression method (the only one supported in this version) */
211275793eaSopenharmony_ci
212275793eaSopenharmony_ci#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
213275793eaSopenharmony_ci
214275793eaSopenharmony_ci#define zlib_version zlibVersion()
215275793eaSopenharmony_ci/* for compatibility with versions < 1.0.2 */
216275793eaSopenharmony_ci
217275793eaSopenharmony_ci
218275793eaSopenharmony_ci                        /* basic functions */
219275793eaSopenharmony_ci
220275793eaSopenharmony_ciZEXTERN const char * ZEXPORT zlibVersion(void);
221275793eaSopenharmony_ci/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
222275793eaSopenharmony_ci   If the first character differs, the library code actually used is not
223275793eaSopenharmony_ci   compatible with the zlib.h header file used by the application.  This check
224275793eaSopenharmony_ci   is automatically made by deflateInit and inflateInit.
225275793eaSopenharmony_ci */
226275793eaSopenharmony_ci
227275793eaSopenharmony_ci/*
228275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level);
229275793eaSopenharmony_ci
230275793eaSopenharmony_ci     Initializes the internal stream state for compression.  The fields
231275793eaSopenharmony_ci   zalloc, zfree and opaque must be initialized before by the caller.  If
232275793eaSopenharmony_ci   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
233275793eaSopenharmony_ci   allocation functions.  total_in, total_out, adler, and msg are initialized.
234275793eaSopenharmony_ci
235275793eaSopenharmony_ci     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
236275793eaSopenharmony_ci   1 gives best speed, 9 gives best compression, 0 gives no compression at all
237275793eaSopenharmony_ci   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION
238275793eaSopenharmony_ci   requests a default compromise between speed and compression (currently
239275793eaSopenharmony_ci   equivalent to level 6).
240275793eaSopenharmony_ci
241275793eaSopenharmony_ci     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
242275793eaSopenharmony_ci   memory, Z_STREAM_ERROR if level is not a valid compression level, or
243275793eaSopenharmony_ci   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
244275793eaSopenharmony_ci   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null
245275793eaSopenharmony_ci   if there is no error message.  deflateInit does not perform any compression:
246275793eaSopenharmony_ci   this will be done by deflate().
247275793eaSopenharmony_ci*/
248275793eaSopenharmony_ci
249275793eaSopenharmony_ci
250275793eaSopenharmony_ciZEXTERN int ZEXPORT deflate(z_streamp strm, int flush);
251275793eaSopenharmony_ci/*
252275793eaSopenharmony_ci    deflate compresses as much data as possible, and stops when the input
253275793eaSopenharmony_ci  buffer becomes empty or the output buffer becomes full.  It may introduce
254275793eaSopenharmony_ci  some output latency (reading input without producing any output) except when
255275793eaSopenharmony_ci  forced to flush.
256275793eaSopenharmony_ci
257275793eaSopenharmony_ci    The detailed semantics are as follows.  deflate performs one or both of the
258275793eaSopenharmony_ci  following actions:
259275793eaSopenharmony_ci
260275793eaSopenharmony_ci  - Compress more input starting at next_in and update next_in and avail_in
261275793eaSopenharmony_ci    accordingly.  If not all input can be processed (because there is not
262275793eaSopenharmony_ci    enough room in the output buffer), next_in and avail_in are updated and
263275793eaSopenharmony_ci    processing will resume at this point for the next call of deflate().
264275793eaSopenharmony_ci
265275793eaSopenharmony_ci  - Generate more output starting at next_out and update next_out and avail_out
266275793eaSopenharmony_ci    accordingly.  This action is forced if the parameter flush is non zero.
267275793eaSopenharmony_ci    Forcing flush frequently degrades the compression ratio, so this parameter
268275793eaSopenharmony_ci    should be set only when necessary.  Some output may be provided even if
269275793eaSopenharmony_ci    flush is zero.
270275793eaSopenharmony_ci
271275793eaSopenharmony_ci    Before the call of deflate(), the application should ensure that at least
272275793eaSopenharmony_ci  one of the actions is possible, by providing more input and/or consuming more
273275793eaSopenharmony_ci  output, and updating avail_in or avail_out accordingly; avail_out should
274275793eaSopenharmony_ci  never be zero before the call.  The application can consume the compressed
275275793eaSopenharmony_ci  output when it wants, for example when the output buffer is full (avail_out
276275793eaSopenharmony_ci  == 0), or after each call of deflate().  If deflate returns Z_OK and with
277275793eaSopenharmony_ci  zero avail_out, it must be called again after making room in the output
278275793eaSopenharmony_ci  buffer because there might be more output pending. See deflatePending(),
279275793eaSopenharmony_ci  which can be used if desired to determine whether or not there is more output
280275793eaSopenharmony_ci  in that case.
281275793eaSopenharmony_ci
282275793eaSopenharmony_ci    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
283275793eaSopenharmony_ci  decide how much data to accumulate before producing output, in order to
284275793eaSopenharmony_ci  maximize compression.
285275793eaSopenharmony_ci
286275793eaSopenharmony_ci    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
287275793eaSopenharmony_ci  flushed to the output buffer and the output is aligned on a byte boundary, so
288275793eaSopenharmony_ci  that the decompressor can get all input data available so far.  (In
289275793eaSopenharmony_ci  particular avail_in is zero after the call if enough output space has been
290275793eaSopenharmony_ci  provided before the call.) Flushing may degrade compression for some
291275793eaSopenharmony_ci  compression algorithms and so it should be used only when necessary.  This
292275793eaSopenharmony_ci  completes the current deflate block and follows it with an empty stored block
293275793eaSopenharmony_ci  that is three bits plus filler bits to the next byte, followed by four bytes
294275793eaSopenharmony_ci  (00 00 ff ff).
295275793eaSopenharmony_ci
296275793eaSopenharmony_ci    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
297275793eaSopenharmony_ci  output buffer, but the output is not aligned to a byte boundary.  All of the
298275793eaSopenharmony_ci  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
299275793eaSopenharmony_ci  This completes the current deflate block and follows it with an empty fixed
300275793eaSopenharmony_ci  codes block that is 10 bits long.  This assures that enough bytes are output
301275793eaSopenharmony_ci  in order for the decompressor to finish the block before the empty fixed
302275793eaSopenharmony_ci  codes block.
303275793eaSopenharmony_ci
304275793eaSopenharmony_ci    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
305275793eaSopenharmony_ci  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
306275793eaSopenharmony_ci  seven bits of the current block are held to be written as the next byte after
307275793eaSopenharmony_ci  the next deflate block is completed.  In this case, the decompressor may not
308275793eaSopenharmony_ci  be provided enough bits at this point in order to complete decompression of
309275793eaSopenharmony_ci  the data provided so far to the compressor.  It may need to wait for the next
310275793eaSopenharmony_ci  block to be emitted.  This is for advanced applications that need to control
311275793eaSopenharmony_ci  the emission of deflate blocks.
312275793eaSopenharmony_ci
313275793eaSopenharmony_ci    If flush is set to Z_FULL_FLUSH, all output is flushed as with
314275793eaSopenharmony_ci  Z_SYNC_FLUSH, and the compression state is reset so that decompression can
315275793eaSopenharmony_ci  restart from this point if previous compressed data has been damaged or if
316275793eaSopenharmony_ci  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade
317275793eaSopenharmony_ci  compression.
318275793eaSopenharmony_ci
319275793eaSopenharmony_ci    If deflate returns with avail_out == 0, this function must be called again
320275793eaSopenharmony_ci  with the same value of the flush parameter and more output space (updated
321275793eaSopenharmony_ci  avail_out), until the flush is complete (deflate returns with non-zero
322275793eaSopenharmony_ci  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
323275793eaSopenharmony_ci  avail_out is greater than six when the flush marker begins, in order to avoid
324275793eaSopenharmony_ci  repeated flush markers upon calling deflate() again when avail_out == 0.
325275793eaSopenharmony_ci
326275793eaSopenharmony_ci    If the parameter flush is set to Z_FINISH, pending input is processed,
327275793eaSopenharmony_ci  pending output is flushed and deflate returns with Z_STREAM_END if there was
328275793eaSopenharmony_ci  enough output space.  If deflate returns with Z_OK or Z_BUF_ERROR, this
329275793eaSopenharmony_ci  function must be called again with Z_FINISH and more output space (updated
330275793eaSopenharmony_ci  avail_out) but no more input data, until it returns with Z_STREAM_END or an
331275793eaSopenharmony_ci  error.  After deflate has returned Z_STREAM_END, the only possible operations
332275793eaSopenharmony_ci  on the stream are deflateReset or deflateEnd.
333275793eaSopenharmony_ci
334275793eaSopenharmony_ci    Z_FINISH can be used in the first deflate call after deflateInit if all the
335275793eaSopenharmony_ci  compression is to be done in a single step.  In order to complete in one
336275793eaSopenharmony_ci  call, avail_out must be at least the value returned by deflateBound (see
337275793eaSopenharmony_ci  below).  Then deflate is guaranteed to return Z_STREAM_END.  If not enough
338275793eaSopenharmony_ci  output space is provided, deflate will not return Z_STREAM_END, and it must
339275793eaSopenharmony_ci  be called again as described above.
340275793eaSopenharmony_ci
341275793eaSopenharmony_ci    deflate() sets strm->adler to the Adler-32 checksum of all input read
342275793eaSopenharmony_ci  so far (that is, total_in bytes).  If a gzip stream is being generated, then
343275793eaSopenharmony_ci  strm->adler will be the CRC-32 checksum of the input read so far.  (See
344275793eaSopenharmony_ci  deflateInit2 below.)
345275793eaSopenharmony_ci
346275793eaSopenharmony_ci    deflate() may update strm->data_type if it can make a good guess about
347275793eaSopenharmony_ci  the input data type (Z_BINARY or Z_TEXT).  If in doubt, the data is
348275793eaSopenharmony_ci  considered binary.  This field is only for information purposes and does not
349275793eaSopenharmony_ci  affect the compression algorithm in any manner.
350275793eaSopenharmony_ci
351275793eaSopenharmony_ci    deflate() returns Z_OK if some progress has been made (more input
352275793eaSopenharmony_ci  processed or more output produced), Z_STREAM_END if all input has been
353275793eaSopenharmony_ci  consumed and all output has been produced (only when flush is set to
354275793eaSopenharmony_ci  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
355275793eaSopenharmony_ci  if next_in or next_out was Z_NULL or the state was inadvertently written over
356275793eaSopenharmony_ci  by the application), or Z_BUF_ERROR if no progress is possible (for example
357275793eaSopenharmony_ci  avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not fatal, and
358275793eaSopenharmony_ci  deflate() can be called again with more input and more output space to
359275793eaSopenharmony_ci  continue compressing.
360275793eaSopenharmony_ci*/
361275793eaSopenharmony_ci
362275793eaSopenharmony_ci
363275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateEnd(z_streamp strm);
364275793eaSopenharmony_ci/*
365275793eaSopenharmony_ci     All dynamically allocated data structures for this stream are freed.
366275793eaSopenharmony_ci   This function discards any unprocessed input and does not flush any pending
367275793eaSopenharmony_ci   output.
368275793eaSopenharmony_ci
369275793eaSopenharmony_ci     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
370275793eaSopenharmony_ci   stream state was inconsistent, Z_DATA_ERROR if the stream was freed
371275793eaSopenharmony_ci   prematurely (some input or output was discarded).  In the error case, msg
372275793eaSopenharmony_ci   may be set but then points to a static string (which must not be
373275793eaSopenharmony_ci   deallocated).
374275793eaSopenharmony_ci*/
375275793eaSopenharmony_ci
376275793eaSopenharmony_ci
377275793eaSopenharmony_ci/*
378275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateInit(z_streamp strm);
379275793eaSopenharmony_ci
380275793eaSopenharmony_ci     Initializes the internal stream state for decompression.  The fields
381275793eaSopenharmony_ci   next_in, avail_in, zalloc, zfree and opaque must be initialized before by
382275793eaSopenharmony_ci   the caller.  In the current version of inflate, the provided input is not
383275793eaSopenharmony_ci   read or consumed.  The allocation of a sliding window will be deferred to
384275793eaSopenharmony_ci   the first call of inflate (if the decompression does not complete on the
385275793eaSopenharmony_ci   first call).  If zalloc and zfree are set to Z_NULL, inflateInit updates
386275793eaSopenharmony_ci   them to use default allocation functions.  total_in, total_out, adler, and
387275793eaSopenharmony_ci   msg are initialized.
388275793eaSopenharmony_ci
389275793eaSopenharmony_ci     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
390275793eaSopenharmony_ci   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
391275793eaSopenharmony_ci   version assumed by the caller, or Z_STREAM_ERROR if the parameters are
392275793eaSopenharmony_ci   invalid, such as a null pointer to the structure.  msg is set to null if
393275793eaSopenharmony_ci   there is no error message.  inflateInit does not perform any decompression.
394275793eaSopenharmony_ci   Actual decompression will be done by inflate().  So next_in, and avail_in,
395275793eaSopenharmony_ci   next_out, and avail_out are unused and unchanged.  The current
396275793eaSopenharmony_ci   implementation of inflateInit() does not process any header information --
397275793eaSopenharmony_ci   that is deferred until inflate() is called.
398275793eaSopenharmony_ci*/
399275793eaSopenharmony_ci
400275793eaSopenharmony_ci
401275793eaSopenharmony_ciZEXTERN int ZEXPORT inflate(z_streamp strm, int flush);
402275793eaSopenharmony_ci/*
403275793eaSopenharmony_ci    inflate decompresses as much data as possible, and stops when the input
404275793eaSopenharmony_ci  buffer becomes empty or the output buffer becomes full.  It may introduce
405275793eaSopenharmony_ci  some output latency (reading input without producing any output) except when
406275793eaSopenharmony_ci  forced to flush.
407275793eaSopenharmony_ci
408275793eaSopenharmony_ci  The detailed semantics are as follows.  inflate performs one or both of the
409275793eaSopenharmony_ci  following actions:
410275793eaSopenharmony_ci
411275793eaSopenharmony_ci  - Decompress more input starting at next_in and update next_in and avail_in
412275793eaSopenharmony_ci    accordingly.  If not all input can be processed (because there is not
413275793eaSopenharmony_ci    enough room in the output buffer), then next_in and avail_in are updated
414275793eaSopenharmony_ci    accordingly, and processing will resume at this point for the next call of
415275793eaSopenharmony_ci    inflate().
416275793eaSopenharmony_ci
417275793eaSopenharmony_ci  - Generate more output starting at next_out and update next_out and avail_out
418275793eaSopenharmony_ci    accordingly.  inflate() provides as much output as possible, until there is
419275793eaSopenharmony_ci    no more input data or no more space in the output buffer (see below about
420275793eaSopenharmony_ci    the flush parameter).
421275793eaSopenharmony_ci
422275793eaSopenharmony_ci    Before the call of inflate(), the application should ensure that at least
423275793eaSopenharmony_ci  one of the actions is possible, by providing more input and/or consuming more
424275793eaSopenharmony_ci  output, and updating the next_* and avail_* values accordingly.  If the
425275793eaSopenharmony_ci  caller of inflate() does not provide both available input and available
426275793eaSopenharmony_ci  output space, it is possible that there will be no progress made.  The
427275793eaSopenharmony_ci  application can consume the uncompressed output when it wants, for example
428275793eaSopenharmony_ci  when the output buffer is full (avail_out == 0), or after each call of
429275793eaSopenharmony_ci  inflate().  If inflate returns Z_OK and with zero avail_out, it must be
430275793eaSopenharmony_ci  called again after making room in the output buffer because there might be
431275793eaSopenharmony_ci  more output pending.
432275793eaSopenharmony_ci
433275793eaSopenharmony_ci    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
434275793eaSopenharmony_ci  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much
435275793eaSopenharmony_ci  output as possible to the output buffer.  Z_BLOCK requests that inflate()
436275793eaSopenharmony_ci  stop if and when it gets to the next deflate block boundary.  When decoding
437275793eaSopenharmony_ci  the zlib or gzip format, this will cause inflate() to return immediately
438275793eaSopenharmony_ci  after the header and before the first block.  When doing a raw inflate,
439275793eaSopenharmony_ci  inflate() will go ahead and process the first block, and will return when it
440275793eaSopenharmony_ci  gets to the end of that block, or when it runs out of data.
441275793eaSopenharmony_ci
442275793eaSopenharmony_ci    The Z_BLOCK option assists in appending to or combining deflate streams.
443275793eaSopenharmony_ci  To assist in this, on return inflate() always sets strm->data_type to the
444275793eaSopenharmony_ci  number of unused bits in the last byte taken from strm->next_in, plus 64 if
445275793eaSopenharmony_ci  inflate() is currently decoding the last block in the deflate stream, plus
446275793eaSopenharmony_ci  128 if inflate() returned immediately after decoding an end-of-block code or
447275793eaSopenharmony_ci  decoding the complete header up to just before the first byte of the deflate
448275793eaSopenharmony_ci  stream.  The end-of-block will not be indicated until all of the uncompressed
449275793eaSopenharmony_ci  data from that block has been written to strm->next_out.  The number of
450275793eaSopenharmony_ci  unused bits may in general be greater than seven, except when bit 7 of
451275793eaSopenharmony_ci  data_type is set, in which case the number of unused bits will be less than
452275793eaSopenharmony_ci  eight.  data_type is set as noted here every time inflate() returns for all
453275793eaSopenharmony_ci  flush options, and so can be used to determine the amount of currently
454275793eaSopenharmony_ci  consumed input in bits.
455275793eaSopenharmony_ci
456275793eaSopenharmony_ci    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
457275793eaSopenharmony_ci  end of each deflate block header is reached, before any actual data in that
458275793eaSopenharmony_ci  block is decoded.  This allows the caller to determine the length of the
459275793eaSopenharmony_ci  deflate block header for later use in random access within a deflate block.
460275793eaSopenharmony_ci  256 is added to the value of strm->data_type when inflate() returns
461275793eaSopenharmony_ci  immediately after reaching the end of the deflate block header.
462275793eaSopenharmony_ci
463275793eaSopenharmony_ci    inflate() should normally be called until it returns Z_STREAM_END or an
464275793eaSopenharmony_ci  error.  However if all decompression is to be performed in a single step (a
465275793eaSopenharmony_ci  single call of inflate), the parameter flush should be set to Z_FINISH.  In
466275793eaSopenharmony_ci  this case all pending input is processed and all pending output is flushed;
467275793eaSopenharmony_ci  avail_out must be large enough to hold all of the uncompressed data for the
468275793eaSopenharmony_ci  operation to complete.  (The size of the uncompressed data may have been
469275793eaSopenharmony_ci  saved by the compressor for this purpose.)  The use of Z_FINISH is not
470275793eaSopenharmony_ci  required to perform an inflation in one step.  However it may be used to
471275793eaSopenharmony_ci  inform inflate that a faster approach can be used for the single inflate()
472275793eaSopenharmony_ci  call.  Z_FINISH also informs inflate to not maintain a sliding window if the
473275793eaSopenharmony_ci  stream completes, which reduces inflate's memory footprint.  If the stream
474275793eaSopenharmony_ci  does not complete, either because not all of the stream is provided or not
475275793eaSopenharmony_ci  enough output space is provided, then a sliding window will be allocated and
476275793eaSopenharmony_ci  inflate() can be called again to continue the operation as if Z_NO_FLUSH had
477275793eaSopenharmony_ci  been used.
478275793eaSopenharmony_ci
479275793eaSopenharmony_ci     In this implementation, inflate() always flushes as much output as
480275793eaSopenharmony_ci  possible to the output buffer, and always uses the faster approach on the
481275793eaSopenharmony_ci  first call.  So the effects of the flush parameter in this implementation are
482275793eaSopenharmony_ci  on the return value of inflate() as noted below, when inflate() returns early
483275793eaSopenharmony_ci  when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
484275793eaSopenharmony_ci  memory for a sliding window when Z_FINISH is used.
485275793eaSopenharmony_ci
486275793eaSopenharmony_ci     If a preset dictionary is needed after this call (see inflateSetDictionary
487275793eaSopenharmony_ci  below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
488275793eaSopenharmony_ci  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
489275793eaSopenharmony_ci  strm->adler to the Adler-32 checksum of all output produced so far (that is,
490275793eaSopenharmony_ci  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
491275793eaSopenharmony_ci  below.  At the end of the stream, inflate() checks that its computed Adler-32
492275793eaSopenharmony_ci  checksum is equal to that saved by the compressor and returns Z_STREAM_END
493275793eaSopenharmony_ci  only if the checksum is correct.
494275793eaSopenharmony_ci
495275793eaSopenharmony_ci    inflate() can decompress and check either zlib-wrapped or gzip-wrapped
496275793eaSopenharmony_ci  deflate data.  The header type is detected automatically, if requested when
497275793eaSopenharmony_ci  initializing with inflateInit2().  Any information contained in the gzip
498275793eaSopenharmony_ci  header is not retained unless inflateGetHeader() is used.  When processing
499275793eaSopenharmony_ci  gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
500275793eaSopenharmony_ci  produced so far.  The CRC-32 is checked against the gzip trailer, as is the
501275793eaSopenharmony_ci  uncompressed length, modulo 2^32.
502275793eaSopenharmony_ci
503275793eaSopenharmony_ci    inflate() returns Z_OK if some progress has been made (more input processed
504275793eaSopenharmony_ci  or more output produced), Z_STREAM_END if the end of the compressed data has
505275793eaSopenharmony_ci  been reached and all uncompressed output has been produced, Z_NEED_DICT if a
506275793eaSopenharmony_ci  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
507275793eaSopenharmony_ci  corrupted (input stream not conforming to the zlib format or incorrect check
508275793eaSopenharmony_ci  value, in which case strm->msg points to a string with a more specific
509275793eaSopenharmony_ci  error), Z_STREAM_ERROR if the stream structure was inconsistent (for example
510275793eaSopenharmony_ci  next_in or next_out was Z_NULL, or the state was inadvertently written over
511275793eaSopenharmony_ci  by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR
512275793eaSopenharmony_ci  if no progress was possible or if there was not enough room in the output
513275793eaSopenharmony_ci  buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and
514275793eaSopenharmony_ci  inflate() can be called again with more input and more output space to
515275793eaSopenharmony_ci  continue decompressing.  If Z_DATA_ERROR is returned, the application may
516275793eaSopenharmony_ci  then call inflateSync() to look for a good compression block if a partial
517275793eaSopenharmony_ci  recovery of the data is to be attempted.
518275793eaSopenharmony_ci*/
519275793eaSopenharmony_ci
520275793eaSopenharmony_ci
521275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateEnd(z_streamp strm);
522275793eaSopenharmony_ci/*
523275793eaSopenharmony_ci     All dynamically allocated data structures for this stream are freed.
524275793eaSopenharmony_ci   This function discards any unprocessed input and does not flush any pending
525275793eaSopenharmony_ci   output.
526275793eaSopenharmony_ci
527275793eaSopenharmony_ci     inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state
528275793eaSopenharmony_ci   was inconsistent.
529275793eaSopenharmony_ci*/
530275793eaSopenharmony_ci
531275793eaSopenharmony_ci
532275793eaSopenharmony_ci                        /* Advanced functions */
533275793eaSopenharmony_ci
534275793eaSopenharmony_ci/*
535275793eaSopenharmony_ci    The following functions are needed only in some special applications.
536275793eaSopenharmony_ci*/
537275793eaSopenharmony_ci
538275793eaSopenharmony_ci/*
539275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateInit2(z_streamp strm,
540275793eaSopenharmony_ci                                 int level,
541275793eaSopenharmony_ci                                 int method,
542275793eaSopenharmony_ci                                 int windowBits,
543275793eaSopenharmony_ci                                 int memLevel,
544275793eaSopenharmony_ci                                 int strategy);
545275793eaSopenharmony_ci
546275793eaSopenharmony_ci     This is another version of deflateInit with more compression options.  The
547275793eaSopenharmony_ci   fields zalloc, zfree and opaque must be initialized before by the caller.
548275793eaSopenharmony_ci
549275793eaSopenharmony_ci     The method parameter is the compression method.  It must be Z_DEFLATED in
550275793eaSopenharmony_ci   this version of the library.
551275793eaSopenharmony_ci
552275793eaSopenharmony_ci     The windowBits parameter is the base two logarithm of the window size
553275793eaSopenharmony_ci   (the size of the history buffer).  It should be in the range 8..15 for this
554275793eaSopenharmony_ci   version of the library.  Larger values of this parameter result in better
555275793eaSopenharmony_ci   compression at the expense of memory usage.  The default value is 15 if
556275793eaSopenharmony_ci   deflateInit is used instead.
557275793eaSopenharmony_ci
558275793eaSopenharmony_ci     For the current implementation of deflate(), a windowBits value of 8 (a
559275793eaSopenharmony_ci   window size of 256 bytes) is not supported.  As a result, a request for 8
560275793eaSopenharmony_ci   will result in 9 (a 512-byte window).  In that case, providing 8 to
561275793eaSopenharmony_ci   inflateInit2() will result in an error when the zlib header with 9 is
562275793eaSopenharmony_ci   checked against the initialization of inflate().  The remedy is to not use 8
563275793eaSopenharmony_ci   with deflateInit2() with this initialization, or at least in that case use 9
564275793eaSopenharmony_ci   with inflateInit2().
565275793eaSopenharmony_ci
566275793eaSopenharmony_ci     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits
567275793eaSopenharmony_ci   determines the window size.  deflate() will then generate raw deflate data
568275793eaSopenharmony_ci   with no zlib header or trailer, and will not compute a check value.
569275793eaSopenharmony_ci
570275793eaSopenharmony_ci     windowBits can also be greater than 15 for optional gzip encoding.  Add
571275793eaSopenharmony_ci   16 to windowBits to write a simple gzip header and trailer around the
572275793eaSopenharmony_ci   compressed data instead of a zlib wrapper.  The gzip header will have no
573275793eaSopenharmony_ci   file name, no extra data, no comment, no modification time (set to zero), no
574275793eaSopenharmony_ci   header crc, and the operating system will be set to the appropriate value,
575275793eaSopenharmony_ci   if the operating system was determined at compile time.  If a gzip stream is
576275793eaSopenharmony_ci   being written, strm->adler is a CRC-32 instead of an Adler-32.
577275793eaSopenharmony_ci
578275793eaSopenharmony_ci     For raw deflate or gzip encoding, a request for a 256-byte window is
579275793eaSopenharmony_ci   rejected as invalid, since only the zlib header provides a means of
580275793eaSopenharmony_ci   transmitting the window size to the decompressor.
581275793eaSopenharmony_ci
582275793eaSopenharmony_ci     The memLevel parameter specifies how much memory should be allocated
583275793eaSopenharmony_ci   for the internal compression state.  memLevel=1 uses minimum memory but is
584275793eaSopenharmony_ci   slow and reduces compression ratio; memLevel=9 uses maximum memory for
585275793eaSopenharmony_ci   optimal speed.  The default value is 8.  See zconf.h for total memory usage
586275793eaSopenharmony_ci   as a function of windowBits and memLevel.
587275793eaSopenharmony_ci
588275793eaSopenharmony_ci     The strategy parameter is used to tune the compression algorithm.  Use the
589275793eaSopenharmony_ci   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
590275793eaSopenharmony_ci   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
591275793eaSopenharmony_ci   string match), or Z_RLE to limit match distances to one (run-length
592275793eaSopenharmony_ci   encoding).  Filtered data consists mostly of small values with a somewhat
593275793eaSopenharmony_ci   random distribution.  In this case, the compression algorithm is tuned to
594275793eaSopenharmony_ci   compress them better.  The effect of Z_FILTERED is to force more Huffman
595275793eaSopenharmony_ci   coding and less string matching; it is somewhat intermediate between
596275793eaSopenharmony_ci   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as
597275793eaSopenharmony_ci   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The
598275793eaSopenharmony_ci   strategy parameter only affects the compression ratio but not the
599275793eaSopenharmony_ci   correctness of the compressed output even if it is not set appropriately.
600275793eaSopenharmony_ci   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
601275793eaSopenharmony_ci   decoder for special applications.
602275793eaSopenharmony_ci
603275793eaSopenharmony_ci     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
604275793eaSopenharmony_ci   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
605275793eaSopenharmony_ci   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
606275793eaSopenharmony_ci   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is
607275793eaSopenharmony_ci   set to null if there is no error message.  deflateInit2 does not perform any
608275793eaSopenharmony_ci   compression: this will be done by deflate().
609275793eaSopenharmony_ci*/
610275793eaSopenharmony_ci
611275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm,
612275793eaSopenharmony_ci                                         const Bytef *dictionary,
613275793eaSopenharmony_ci                                         uInt  dictLength);
614275793eaSopenharmony_ci/*
615275793eaSopenharmony_ci     Initializes the compression dictionary from the given byte sequence
616275793eaSopenharmony_ci   without producing any compressed output.  When using the zlib format, this
617275793eaSopenharmony_ci   function must be called immediately after deflateInit, deflateInit2 or
618275793eaSopenharmony_ci   deflateReset, and before any call of deflate.  When doing raw deflate, this
619275793eaSopenharmony_ci   function must be called either before any call of deflate, or immediately
620275793eaSopenharmony_ci   after the completion of a deflate block, i.e. after all input has been
621275793eaSopenharmony_ci   consumed and all output has been delivered when using any of the flush
622275793eaSopenharmony_ci   options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH.  The
623275793eaSopenharmony_ci   compressor and decompressor must use exactly the same dictionary (see
624275793eaSopenharmony_ci   inflateSetDictionary).
625275793eaSopenharmony_ci
626275793eaSopenharmony_ci     The dictionary should consist of strings (byte sequences) that are likely
627275793eaSopenharmony_ci   to be encountered later in the data to be compressed, with the most commonly
628275793eaSopenharmony_ci   used strings preferably put towards the end of the dictionary.  Using a
629275793eaSopenharmony_ci   dictionary is most useful when the data to be compressed is short and can be
630275793eaSopenharmony_ci   predicted with good accuracy; the data can then be compressed better than
631275793eaSopenharmony_ci   with the default empty dictionary.
632275793eaSopenharmony_ci
633275793eaSopenharmony_ci     Depending on the size of the compression data structures selected by
634275793eaSopenharmony_ci   deflateInit or deflateInit2, a part of the dictionary may in effect be
635275793eaSopenharmony_ci   discarded, for example if the dictionary is larger than the window size
636275793eaSopenharmony_ci   provided in deflateInit or deflateInit2.  Thus the strings most likely to be
637275793eaSopenharmony_ci   useful should be put at the end of the dictionary, not at the front.  In
638275793eaSopenharmony_ci   addition, the current implementation of deflate will use at most the window
639275793eaSopenharmony_ci   size minus 262 bytes of the provided dictionary.
640275793eaSopenharmony_ci
641275793eaSopenharmony_ci     Upon return of this function, strm->adler is set to the Adler-32 value
642275793eaSopenharmony_ci   of the dictionary; the decompressor may later use this value to determine
643275793eaSopenharmony_ci   which dictionary has been used by the compressor.  (The Adler-32 value
644275793eaSopenharmony_ci   applies to the whole dictionary even if only a subset of the dictionary is
645275793eaSopenharmony_ci   actually used by the compressor.) If a raw deflate was requested, then the
646275793eaSopenharmony_ci   Adler-32 value is not computed and strm->adler is not set.
647275793eaSopenharmony_ci
648275793eaSopenharmony_ci     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
649275793eaSopenharmony_ci   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
650275793eaSopenharmony_ci   inconsistent (for example if deflate has already been called for this stream
651275793eaSopenharmony_ci   or if not at a block boundary for raw deflate).  deflateSetDictionary does
652275793eaSopenharmony_ci   not perform any compression: this will be done by deflate().
653275793eaSopenharmony_ci*/
654275793eaSopenharmony_ci
655275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm,
656275793eaSopenharmony_ci                                         Bytef *dictionary,
657275793eaSopenharmony_ci                                         uInt  *dictLength);
658275793eaSopenharmony_ci/*
659275793eaSopenharmony_ci     Returns the sliding dictionary being maintained by deflate.  dictLength is
660275793eaSopenharmony_ci   set to the number of bytes in the dictionary, and that many bytes are copied
661275793eaSopenharmony_ci   to dictionary.  dictionary must have enough space, where 32768 bytes is
662275793eaSopenharmony_ci   always enough.  If deflateGetDictionary() is called with dictionary equal to
663275793eaSopenharmony_ci   Z_NULL, then only the dictionary length is returned, and nothing is copied.
664275793eaSopenharmony_ci   Similarly, if dictLength is Z_NULL, then it is not set.
665275793eaSopenharmony_ci
666275793eaSopenharmony_ci     deflateGetDictionary() may return a length less than the window size, even
667275793eaSopenharmony_ci   when more than the window size in input has been provided. It may return up
668275793eaSopenharmony_ci   to 258 bytes less in that case, due to how zlib's implementation of deflate
669275793eaSopenharmony_ci   manages the sliding window and lookahead for matches, where matches can be
670275793eaSopenharmony_ci   up to 258 bytes long. If the application needs the last window-size bytes of
671275793eaSopenharmony_ci   input, then that would need to be saved by the application outside of zlib.
672275793eaSopenharmony_ci
673275793eaSopenharmony_ci     deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
674275793eaSopenharmony_ci   stream state is inconsistent.
675275793eaSopenharmony_ci*/
676275793eaSopenharmony_ci
677275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateCopy(z_streamp dest,
678275793eaSopenharmony_ci                                z_streamp source);
679275793eaSopenharmony_ci/*
680275793eaSopenharmony_ci     Sets the destination stream as a complete copy of the source stream.
681275793eaSopenharmony_ci
682275793eaSopenharmony_ci     This function can be useful when several compression strategies will be
683275793eaSopenharmony_ci   tried, for example when there are several ways of pre-processing the input
684275793eaSopenharmony_ci   data with a filter.  The streams that will be discarded should then be freed
685275793eaSopenharmony_ci   by calling deflateEnd.  Note that deflateCopy duplicates the internal
686275793eaSopenharmony_ci   compression state which can be quite large, so this strategy is slow and can
687275793eaSopenharmony_ci   consume lots of memory.
688275793eaSopenharmony_ci
689275793eaSopenharmony_ci     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
690275793eaSopenharmony_ci   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
691275793eaSopenharmony_ci   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
692275793eaSopenharmony_ci   destination.
693275793eaSopenharmony_ci*/
694275793eaSopenharmony_ci
695275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateReset(z_streamp strm);
696275793eaSopenharmony_ci/*
697275793eaSopenharmony_ci     This function is equivalent to deflateEnd followed by deflateInit, but
698275793eaSopenharmony_ci   does not free and reallocate the internal compression state.  The stream
699275793eaSopenharmony_ci   will leave the compression level and any other attributes that may have been
700275793eaSopenharmony_ci   set unchanged.  total_in, total_out, adler, and msg are initialized.
701275793eaSopenharmony_ci
702275793eaSopenharmony_ci     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
703275793eaSopenharmony_ci   stream state was inconsistent (such as zalloc or state being Z_NULL).
704275793eaSopenharmony_ci*/
705275793eaSopenharmony_ci
706275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateParams(z_streamp strm,
707275793eaSopenharmony_ci                                  int level,
708275793eaSopenharmony_ci                                  int strategy);
709275793eaSopenharmony_ci/*
710275793eaSopenharmony_ci     Dynamically update the compression level and compression strategy.  The
711275793eaSopenharmony_ci   interpretation of level and strategy is as in deflateInit2().  This can be
712275793eaSopenharmony_ci   used to switch between compression and straight copy of the input data, or
713275793eaSopenharmony_ci   to switch to a different kind of input data requiring a different strategy.
714275793eaSopenharmony_ci   If the compression approach (which is a function of the level) or the
715275793eaSopenharmony_ci   strategy is changed, and if there have been any deflate() calls since the
716275793eaSopenharmony_ci   state was initialized or reset, then the input available so far is
717275793eaSopenharmony_ci   compressed with the old level and strategy using deflate(strm, Z_BLOCK).
718275793eaSopenharmony_ci   There are three approaches for the compression levels 0, 1..3, and 4..9
719275793eaSopenharmony_ci   respectively.  The new level and strategy will take effect at the next call
720275793eaSopenharmony_ci   of deflate().
721275793eaSopenharmony_ci
722275793eaSopenharmony_ci     If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
723275793eaSopenharmony_ci   not have enough output space to complete, then the parameter change will not
724275793eaSopenharmony_ci   take effect.  In this case, deflateParams() can be called again with the
725275793eaSopenharmony_ci   same parameters and more output space to try again.
726275793eaSopenharmony_ci
727275793eaSopenharmony_ci     In order to assure a change in the parameters on the first try, the
728275793eaSopenharmony_ci   deflate stream should be flushed using deflate() with Z_BLOCK or other flush
729275793eaSopenharmony_ci   request until strm.avail_out is not zero, before calling deflateParams().
730275793eaSopenharmony_ci   Then no more input data should be provided before the deflateParams() call.
731275793eaSopenharmony_ci   If this is done, the old level and strategy will be applied to the data
732275793eaSopenharmony_ci   compressed before deflateParams(), and the new level and strategy will be
733275793eaSopenharmony_ci   applied to the data compressed after deflateParams().
734275793eaSopenharmony_ci
735275793eaSopenharmony_ci     deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream
736275793eaSopenharmony_ci   state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if
737275793eaSopenharmony_ci   there was not enough output space to complete the compression of the
738275793eaSopenharmony_ci   available input data before a change in the strategy or approach.  Note that
739275793eaSopenharmony_ci   in the case of a Z_BUF_ERROR, the parameters are not changed.  A return
740275793eaSopenharmony_ci   value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be
741275793eaSopenharmony_ci   retried with more output space.
742275793eaSopenharmony_ci*/
743275793eaSopenharmony_ci
744275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateTune(z_streamp strm,
745275793eaSopenharmony_ci                                int good_length,
746275793eaSopenharmony_ci                                int max_lazy,
747275793eaSopenharmony_ci                                int nice_length,
748275793eaSopenharmony_ci                                int max_chain);
749275793eaSopenharmony_ci/*
750275793eaSopenharmony_ci     Fine tune deflate's internal compression parameters.  This should only be
751275793eaSopenharmony_ci   used by someone who understands the algorithm used by zlib's deflate for
752275793eaSopenharmony_ci   searching for the best matching string, and even then only by the most
753275793eaSopenharmony_ci   fanatic optimizer trying to squeeze out the last compressed bit for their
754275793eaSopenharmony_ci   specific input data.  Read the deflate.c source code for the meaning of the
755275793eaSopenharmony_ci   max_lazy, good_length, nice_length, and max_chain parameters.
756275793eaSopenharmony_ci
757275793eaSopenharmony_ci     deflateTune() can be called after deflateInit() or deflateInit2(), and
758275793eaSopenharmony_ci   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
759275793eaSopenharmony_ci */
760275793eaSopenharmony_ci
761275793eaSopenharmony_ciZEXTERN uLong ZEXPORT deflateBound(z_streamp strm,
762275793eaSopenharmony_ci                                   uLong sourceLen);
763275793eaSopenharmony_ci/*
764275793eaSopenharmony_ci     deflateBound() returns an upper bound on the compressed size after
765275793eaSopenharmony_ci   deflation of sourceLen bytes.  It must be called after deflateInit() or
766275793eaSopenharmony_ci   deflateInit2(), and after deflateSetHeader(), if used.  This would be used
767275793eaSopenharmony_ci   to allocate an output buffer for deflation in a single pass, and so would be
768275793eaSopenharmony_ci   called before deflate().  If that first deflate() call is provided the
769275793eaSopenharmony_ci   sourceLen input bytes, an output buffer allocated to the size returned by
770275793eaSopenharmony_ci   deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
771275793eaSopenharmony_ci   to return Z_STREAM_END.  Note that it is possible for the compressed size to
772275793eaSopenharmony_ci   be larger than the value returned by deflateBound() if flush options other
773275793eaSopenharmony_ci   than Z_FINISH or Z_NO_FLUSH are used.
774275793eaSopenharmony_ci*/
775275793eaSopenharmony_ci
776275793eaSopenharmony_ciZEXTERN int ZEXPORT deflatePending(z_streamp strm,
777275793eaSopenharmony_ci                                   unsigned *pending,
778275793eaSopenharmony_ci                                   int *bits);
779275793eaSopenharmony_ci/*
780275793eaSopenharmony_ci     deflatePending() returns the number of bytes and bits of output that have
781275793eaSopenharmony_ci   been generated, but not yet provided in the available output.  The bytes not
782275793eaSopenharmony_ci   provided would be due to the available output space having being consumed.
783275793eaSopenharmony_ci   The number of bits of output not provided are between 0 and 7, where they
784275793eaSopenharmony_ci   await more bits to join them in order to fill out a full byte.  If pending
785275793eaSopenharmony_ci   or bits are Z_NULL, then those values are not set.
786275793eaSopenharmony_ci
787275793eaSopenharmony_ci     deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
788275793eaSopenharmony_ci   stream state was inconsistent.
789275793eaSopenharmony_ci */
790275793eaSopenharmony_ci
791275793eaSopenharmony_ciZEXTERN int ZEXPORT deflatePrime(z_streamp strm,
792275793eaSopenharmony_ci                                 int bits,
793275793eaSopenharmony_ci                                 int value);
794275793eaSopenharmony_ci/*
795275793eaSopenharmony_ci     deflatePrime() inserts bits in the deflate output stream.  The intent
796275793eaSopenharmony_ci   is that this function is used to start off the deflate output with the bits
797275793eaSopenharmony_ci   leftover from a previous deflate stream when appending to it.  As such, this
798275793eaSopenharmony_ci   function can only be used for raw deflate, and must be used before the first
799275793eaSopenharmony_ci   deflate() call after a deflateInit2() or deflateReset().  bits must be less
800275793eaSopenharmony_ci   than or equal to 16, and that many of the least significant bits of value
801275793eaSopenharmony_ci   will be inserted in the output.
802275793eaSopenharmony_ci
803275793eaSopenharmony_ci     deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough
804275793eaSopenharmony_ci   room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the
805275793eaSopenharmony_ci   source stream state was inconsistent.
806275793eaSopenharmony_ci*/
807275793eaSopenharmony_ci
808275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm,
809275793eaSopenharmony_ci                                     gz_headerp head);
810275793eaSopenharmony_ci/*
811275793eaSopenharmony_ci     deflateSetHeader() provides gzip header information for when a gzip
812275793eaSopenharmony_ci   stream is requested by deflateInit2().  deflateSetHeader() may be called
813275793eaSopenharmony_ci   after deflateInit2() or deflateReset() and before the first call of
814275793eaSopenharmony_ci   deflate().  The text, time, os, extra field, name, and comment information
815275793eaSopenharmony_ci   in the provided gz_header structure are written to the gzip header (xflag is
816275793eaSopenharmony_ci   ignored -- the extra flags are set according to the compression level).  The
817275793eaSopenharmony_ci   caller must assure that, if not Z_NULL, name and comment are terminated with
818275793eaSopenharmony_ci   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
819275793eaSopenharmony_ci   available there.  If hcrc is true, a gzip header crc is included.  Note that
820275793eaSopenharmony_ci   the current versions of the command-line version of gzip (up through version
821275793eaSopenharmony_ci   1.3.x) do not support header crc's, and will report that it is a "multi-part
822275793eaSopenharmony_ci   gzip file" and give up.
823275793eaSopenharmony_ci
824275793eaSopenharmony_ci     If deflateSetHeader is not used, the default gzip header has text false,
825275793eaSopenharmony_ci   the time set to zero, and os set to the current operating system, with no
826275793eaSopenharmony_ci   extra, name, or comment fields.  The gzip header is returned to the default
827275793eaSopenharmony_ci   state by deflateReset().
828275793eaSopenharmony_ci
829275793eaSopenharmony_ci     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
830275793eaSopenharmony_ci   stream state was inconsistent.
831275793eaSopenharmony_ci*/
832275793eaSopenharmony_ci
833275793eaSopenharmony_ci/*
834275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateInit2(z_streamp strm,
835275793eaSopenharmony_ci                                 int windowBits);
836275793eaSopenharmony_ci
837275793eaSopenharmony_ci     This is another version of inflateInit with an extra parameter.  The
838275793eaSopenharmony_ci   fields next_in, avail_in, zalloc, zfree and opaque must be initialized
839275793eaSopenharmony_ci   before by the caller.
840275793eaSopenharmony_ci
841275793eaSopenharmony_ci     The windowBits parameter is the base two logarithm of the maximum window
842275793eaSopenharmony_ci   size (the size of the history buffer).  It should be in the range 8..15 for
843275793eaSopenharmony_ci   this version of the library.  The default value is 15 if inflateInit is used
844275793eaSopenharmony_ci   instead.  windowBits must be greater than or equal to the windowBits value
845275793eaSopenharmony_ci   provided to deflateInit2() while compressing, or it must be equal to 15 if
846275793eaSopenharmony_ci   deflateInit2() was not used.  If a compressed stream with a larger window
847275793eaSopenharmony_ci   size is given as input, inflate() will return with the error code
848275793eaSopenharmony_ci   Z_DATA_ERROR instead of trying to allocate a larger window.
849275793eaSopenharmony_ci
850275793eaSopenharmony_ci     windowBits can also be zero to request that inflate use the window size in
851275793eaSopenharmony_ci   the zlib header of the compressed stream.
852275793eaSopenharmony_ci
853275793eaSopenharmony_ci     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits
854275793eaSopenharmony_ci   determines the window size.  inflate() will then process raw deflate data,
855275793eaSopenharmony_ci   not looking for a zlib or gzip header, not generating a check value, and not
856275793eaSopenharmony_ci   looking for any check values for comparison at the end of the stream.  This
857275793eaSopenharmony_ci   is for use with other formats that use the deflate compressed data format
858275793eaSopenharmony_ci   such as zip.  Those formats provide their own check values.  If a custom
859275793eaSopenharmony_ci   format is developed using the raw deflate format for compressed data, it is
860275793eaSopenharmony_ci   recommended that a check value such as an Adler-32 or a CRC-32 be applied to
861275793eaSopenharmony_ci   the uncompressed data as is done in the zlib, gzip, and zip formats.  For
862275793eaSopenharmony_ci   most applications, the zlib format should be used as is.  Note that comments
863275793eaSopenharmony_ci   above on the use in deflateInit2() applies to the magnitude of windowBits.
864275793eaSopenharmony_ci
865275793eaSopenharmony_ci     windowBits can also be greater than 15 for optional gzip decoding.  Add
866275793eaSopenharmony_ci   32 to windowBits to enable zlib and gzip decoding with automatic header
867275793eaSopenharmony_ci   detection, or add 16 to decode only the gzip format (the zlib format will
868275793eaSopenharmony_ci   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a
869275793eaSopenharmony_ci   CRC-32 instead of an Adler-32.  Unlike the gunzip utility and gzread() (see
870275793eaSopenharmony_ci   below), inflate() will *not* automatically decode concatenated gzip members.
871275793eaSopenharmony_ci   inflate() will return Z_STREAM_END at the end of the gzip member.  The state
872275793eaSopenharmony_ci   would need to be reset to continue decoding a subsequent gzip member.  This
873275793eaSopenharmony_ci   *must* be done if there is more data after a gzip member, in order for the
874275793eaSopenharmony_ci   decompression to be compliant with the gzip standard (RFC 1952).
875275793eaSopenharmony_ci
876275793eaSopenharmony_ci     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
877275793eaSopenharmony_ci   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
878275793eaSopenharmony_ci   version assumed by the caller, or Z_STREAM_ERROR if the parameters are
879275793eaSopenharmony_ci   invalid, such as a null pointer to the structure.  msg is set to null if
880275793eaSopenharmony_ci   there is no error message.  inflateInit2 does not perform any decompression
881275793eaSopenharmony_ci   apart from possibly reading the zlib header if present: actual decompression
882275793eaSopenharmony_ci   will be done by inflate().  (So next_in and avail_in may be modified, but
883275793eaSopenharmony_ci   next_out and avail_out are unused and unchanged.) The current implementation
884275793eaSopenharmony_ci   of inflateInit2() does not process any header information -- that is
885275793eaSopenharmony_ci   deferred until inflate() is called.
886275793eaSopenharmony_ci*/
887275793eaSopenharmony_ci
888275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm,
889275793eaSopenharmony_ci                                         const Bytef *dictionary,
890275793eaSopenharmony_ci                                         uInt  dictLength);
891275793eaSopenharmony_ci/*
892275793eaSopenharmony_ci     Initializes the decompression dictionary from the given uncompressed byte
893275793eaSopenharmony_ci   sequence.  This function must be called immediately after a call of inflate,
894275793eaSopenharmony_ci   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor
895275793eaSopenharmony_ci   can be determined from the Adler-32 value returned by that call of inflate.
896275793eaSopenharmony_ci   The compressor and decompressor must use exactly the same dictionary (see
897275793eaSopenharmony_ci   deflateSetDictionary).  For raw inflate, this function can be called at any
898275793eaSopenharmony_ci   time to set the dictionary.  If the provided dictionary is smaller than the
899275793eaSopenharmony_ci   window and there is already data in the window, then the provided dictionary
900275793eaSopenharmony_ci   will amend what's there.  The application must insure that the dictionary
901275793eaSopenharmony_ci   that was used for compression is provided.
902275793eaSopenharmony_ci
903275793eaSopenharmony_ci     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
904275793eaSopenharmony_ci   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
905275793eaSopenharmony_ci   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
906275793eaSopenharmony_ci   expected one (incorrect Adler-32 value).  inflateSetDictionary does not
907275793eaSopenharmony_ci   perform any decompression: this will be done by subsequent calls of
908275793eaSopenharmony_ci   inflate().
909275793eaSopenharmony_ci*/
910275793eaSopenharmony_ci
911275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm,
912275793eaSopenharmony_ci                                         Bytef *dictionary,
913275793eaSopenharmony_ci                                         uInt  *dictLength);
914275793eaSopenharmony_ci/*
915275793eaSopenharmony_ci     Returns the sliding dictionary being maintained by inflate.  dictLength is
916275793eaSopenharmony_ci   set to the number of bytes in the dictionary, and that many bytes are copied
917275793eaSopenharmony_ci   to dictionary.  dictionary must have enough space, where 32768 bytes is
918275793eaSopenharmony_ci   always enough.  If inflateGetDictionary() is called with dictionary equal to
919275793eaSopenharmony_ci   Z_NULL, then only the dictionary length is returned, and nothing is copied.
920275793eaSopenharmony_ci   Similarly, if dictLength is Z_NULL, then it is not set.
921275793eaSopenharmony_ci
922275793eaSopenharmony_ci     inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
923275793eaSopenharmony_ci   stream state is inconsistent.
924275793eaSopenharmony_ci*/
925275793eaSopenharmony_ci
926275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateSync(z_streamp strm);
927275793eaSopenharmony_ci/*
928275793eaSopenharmony_ci     Skips invalid compressed data until a possible full flush point (see above
929275793eaSopenharmony_ci   for the description of deflate with Z_FULL_FLUSH) can be found, or until all
930275793eaSopenharmony_ci   available input is skipped.  No output is provided.
931275793eaSopenharmony_ci
932275793eaSopenharmony_ci     inflateSync searches for a 00 00 FF FF pattern in the compressed data.
933275793eaSopenharmony_ci   All full flush points have this pattern, but not all occurrences of this
934275793eaSopenharmony_ci   pattern are full flush points.
935275793eaSopenharmony_ci
936275793eaSopenharmony_ci     inflateSync returns Z_OK if a possible full flush point has been found,
937275793eaSopenharmony_ci   Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
938275793eaSopenharmony_ci   has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
939275793eaSopenharmony_ci   In the success case, the application may save the current value of total_in
940275793eaSopenharmony_ci   which indicates where valid compressed data was found.  In the error case,
941275793eaSopenharmony_ci   the application may repeatedly call inflateSync, providing more input each
942275793eaSopenharmony_ci   time, until success or end of the input data.
943275793eaSopenharmony_ci*/
944275793eaSopenharmony_ci
945275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateCopy(z_streamp dest,
946275793eaSopenharmony_ci                                z_streamp source);
947275793eaSopenharmony_ci/*
948275793eaSopenharmony_ci     Sets the destination stream as a complete copy of the source stream.
949275793eaSopenharmony_ci
950275793eaSopenharmony_ci     This function can be useful when randomly accessing a large stream.  The
951275793eaSopenharmony_ci   first pass through the stream can periodically record the inflate state,
952275793eaSopenharmony_ci   allowing restarting inflate at those points when randomly accessing the
953275793eaSopenharmony_ci   stream.
954275793eaSopenharmony_ci
955275793eaSopenharmony_ci     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
956275793eaSopenharmony_ci   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
957275793eaSopenharmony_ci   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
958275793eaSopenharmony_ci   destination.
959275793eaSopenharmony_ci*/
960275793eaSopenharmony_ci
961275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateReset(z_streamp strm);
962275793eaSopenharmony_ci/*
963275793eaSopenharmony_ci     This function is equivalent to inflateEnd followed by inflateInit,
964275793eaSopenharmony_ci   but does not free and reallocate the internal decompression state.  The
965275793eaSopenharmony_ci   stream will keep attributes that may have been set by inflateInit2.
966275793eaSopenharmony_ci   total_in, total_out, adler, and msg are initialized.
967275793eaSopenharmony_ci
968275793eaSopenharmony_ci     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
969275793eaSopenharmony_ci   stream state was inconsistent (such as zalloc or state being Z_NULL).
970275793eaSopenharmony_ci*/
971275793eaSopenharmony_ci
972275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateReset2(z_streamp strm,
973275793eaSopenharmony_ci                                  int windowBits);
974275793eaSopenharmony_ci/*
975275793eaSopenharmony_ci     This function is the same as inflateReset, but it also permits changing
976275793eaSopenharmony_ci   the wrap and window size requests.  The windowBits parameter is interpreted
977275793eaSopenharmony_ci   the same as it is for inflateInit2.  If the window size is changed, then the
978275793eaSopenharmony_ci   memory allocated for the window is freed, and the window will be reallocated
979275793eaSopenharmony_ci   by inflate() if needed.
980275793eaSopenharmony_ci
981275793eaSopenharmony_ci     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
982275793eaSopenharmony_ci   stream state was inconsistent (such as zalloc or state being Z_NULL), or if
983275793eaSopenharmony_ci   the windowBits parameter is invalid.
984275793eaSopenharmony_ci*/
985275793eaSopenharmony_ci
986275793eaSopenharmony_ciZEXTERN int ZEXPORT inflatePrime(z_streamp strm,
987275793eaSopenharmony_ci                                 int bits,
988275793eaSopenharmony_ci                                 int value);
989275793eaSopenharmony_ci/*
990275793eaSopenharmony_ci     This function inserts bits in the inflate input stream.  The intent is
991275793eaSopenharmony_ci   that this function is used to start inflating at a bit position in the
992275793eaSopenharmony_ci   middle of a byte.  The provided bits will be used before any bytes are used
993275793eaSopenharmony_ci   from next_in.  This function should only be used with raw inflate, and
994275793eaSopenharmony_ci   should be used before the first inflate() call after inflateInit2() or
995275793eaSopenharmony_ci   inflateReset().  bits must be less than or equal to 16, and that many of the
996275793eaSopenharmony_ci   least significant bits of value will be inserted in the input.
997275793eaSopenharmony_ci
998275793eaSopenharmony_ci     If bits is negative, then the input stream bit buffer is emptied.  Then
999275793eaSopenharmony_ci   inflatePrime() can be called again to put bits in the buffer.  This is used
1000275793eaSopenharmony_ci   to clear out bits leftover after feeding inflate a block description prior
1001275793eaSopenharmony_ci   to feeding inflate codes.
1002275793eaSopenharmony_ci
1003275793eaSopenharmony_ci     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
1004275793eaSopenharmony_ci   stream state was inconsistent.
1005275793eaSopenharmony_ci*/
1006275793eaSopenharmony_ci
1007275793eaSopenharmony_ciZEXTERN long ZEXPORT inflateMark(z_streamp strm);
1008275793eaSopenharmony_ci/*
1009275793eaSopenharmony_ci     This function returns two values, one in the lower 16 bits of the return
1010275793eaSopenharmony_ci   value, and the other in the remaining upper bits, obtained by shifting the
1011275793eaSopenharmony_ci   return value down 16 bits.  If the upper value is -1 and the lower value is
1012275793eaSopenharmony_ci   zero, then inflate() is currently decoding information outside of a block.
1013275793eaSopenharmony_ci   If the upper value is -1 and the lower value is non-zero, then inflate is in
1014275793eaSopenharmony_ci   the middle of a stored block, with the lower value equaling the number of
1015275793eaSopenharmony_ci   bytes from the input remaining to copy.  If the upper value is not -1, then
1016275793eaSopenharmony_ci   it is the number of bits back from the current bit position in the input of
1017275793eaSopenharmony_ci   the code (literal or length/distance pair) currently being processed.  In
1018275793eaSopenharmony_ci   that case the lower value is the number of bytes already emitted for that
1019275793eaSopenharmony_ci   code.
1020275793eaSopenharmony_ci
1021275793eaSopenharmony_ci     A code is being processed if inflate is waiting for more input to complete
1022275793eaSopenharmony_ci   decoding of the code, or if it has completed decoding but is waiting for
1023275793eaSopenharmony_ci   more output space to write the literal or match data.
1024275793eaSopenharmony_ci
1025275793eaSopenharmony_ci     inflateMark() is used to mark locations in the input data for random
1026275793eaSopenharmony_ci   access, which may be at bit positions, and to note those cases where the
1027275793eaSopenharmony_ci   output of a code may span boundaries of random access blocks.  The current
1028275793eaSopenharmony_ci   location in the input stream can be determined from avail_in and data_type
1029275793eaSopenharmony_ci   as noted in the description for the Z_BLOCK flush parameter for inflate.
1030275793eaSopenharmony_ci
1031275793eaSopenharmony_ci     inflateMark returns the value noted above, or -65536 if the provided
1032275793eaSopenharmony_ci   source stream state was inconsistent.
1033275793eaSopenharmony_ci*/
1034275793eaSopenharmony_ci
1035275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm,
1036275793eaSopenharmony_ci                                     gz_headerp head);
1037275793eaSopenharmony_ci/*
1038275793eaSopenharmony_ci     inflateGetHeader() requests that gzip header information be stored in the
1039275793eaSopenharmony_ci   provided gz_header structure.  inflateGetHeader() may be called after
1040275793eaSopenharmony_ci   inflateInit2() or inflateReset(), and before the first call of inflate().
1041275793eaSopenharmony_ci   As inflate() processes the gzip stream, head->done is zero until the header
1042275793eaSopenharmony_ci   is completed, at which time head->done is set to one.  If a zlib stream is
1043275793eaSopenharmony_ci   being decoded, then head->done is set to -1 to indicate that there will be
1044275793eaSopenharmony_ci   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be
1045275793eaSopenharmony_ci   used to force inflate() to return immediately after header processing is
1046275793eaSopenharmony_ci   complete and before any actual data is decompressed.
1047275793eaSopenharmony_ci
1048275793eaSopenharmony_ci     The text, time, xflags, and os fields are filled in with the gzip header
1049275793eaSopenharmony_ci   contents.  hcrc is set to true if there is a header CRC.  (The header CRC
1050275793eaSopenharmony_ci   was valid if done is set to one.) If extra is not Z_NULL, then extra_max
1051275793eaSopenharmony_ci   contains the maximum number of bytes to write to extra.  Once done is true,
1052275793eaSopenharmony_ci   extra_len contains the actual extra field length, and extra contains the
1053275793eaSopenharmony_ci   extra field, or that field truncated if extra_max is less than extra_len.
1054275793eaSopenharmony_ci   If name is not Z_NULL, then up to name_max characters are written there,
1055275793eaSopenharmony_ci   terminated with a zero unless the length is greater than name_max.  If
1056275793eaSopenharmony_ci   comment is not Z_NULL, then up to comm_max characters are written there,
1057275793eaSopenharmony_ci   terminated with a zero unless the length is greater than comm_max.  When any
1058275793eaSopenharmony_ci   of extra, name, or comment are not Z_NULL and the respective field is not
1059275793eaSopenharmony_ci   present in the header, then that field is set to Z_NULL to signal its
1060275793eaSopenharmony_ci   absence.  This allows the use of deflateSetHeader() with the returned
1061275793eaSopenharmony_ci   structure to duplicate the header.  However if those fields are set to
1062275793eaSopenharmony_ci   allocated memory, then the application will need to save those pointers
1063275793eaSopenharmony_ci   elsewhere so that they can be eventually freed.
1064275793eaSopenharmony_ci
1065275793eaSopenharmony_ci     If inflateGetHeader is not used, then the header information is simply
1066275793eaSopenharmony_ci   discarded.  The header is always checked for validity, including the header
1067275793eaSopenharmony_ci   CRC if present.  inflateReset() will reset the process to discard the header
1068275793eaSopenharmony_ci   information.  The application would need to call inflateGetHeader() again to
1069275793eaSopenharmony_ci   retrieve the header from the next gzip stream.
1070275793eaSopenharmony_ci
1071275793eaSopenharmony_ci     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
1072275793eaSopenharmony_ci   stream state was inconsistent.
1073275793eaSopenharmony_ci*/
1074275793eaSopenharmony_ci
1075275793eaSopenharmony_ci/*
1076275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits,
1077275793eaSopenharmony_ci                                    unsigned char FAR *window);
1078275793eaSopenharmony_ci
1079275793eaSopenharmony_ci     Initialize the internal stream state for decompression using inflateBack()
1080275793eaSopenharmony_ci   calls.  The fields zalloc, zfree and opaque in strm must be initialized
1081275793eaSopenharmony_ci   before the call.  If zalloc and zfree are Z_NULL, then the default library-
1082275793eaSopenharmony_ci   derived memory allocation routines are used.  windowBits is the base two
1083275793eaSopenharmony_ci   logarithm of the window size, in the range 8..15.  window is a caller
1084275793eaSopenharmony_ci   supplied buffer of that size.  Except for special applications where it is
1085275793eaSopenharmony_ci   assured that deflate was used with small window sizes, windowBits must be 15
1086275793eaSopenharmony_ci   and a 32K byte window must be supplied to be able to decompress general
1087275793eaSopenharmony_ci   deflate streams.
1088275793eaSopenharmony_ci
1089275793eaSopenharmony_ci     See inflateBack() for the usage of these routines.
1090275793eaSopenharmony_ci
1091275793eaSopenharmony_ci     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
1092275793eaSopenharmony_ci   the parameters are invalid, Z_MEM_ERROR if the internal state could not be
1093275793eaSopenharmony_ci   allocated, or Z_VERSION_ERROR if the version of the library does not match
1094275793eaSopenharmony_ci   the version of the header file.
1095275793eaSopenharmony_ci*/
1096275793eaSopenharmony_ci
1097275793eaSopenharmony_citypedef unsigned (*in_func)(void FAR *,
1098275793eaSopenharmony_ci                            z_const unsigned char FAR * FAR *);
1099275793eaSopenharmony_citypedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned);
1100275793eaSopenharmony_ci
1101275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateBack(z_streamp strm,
1102275793eaSopenharmony_ci                                in_func in, void FAR *in_desc,
1103275793eaSopenharmony_ci                                out_func out, void FAR *out_desc);
1104275793eaSopenharmony_ci/*
1105275793eaSopenharmony_ci     inflateBack() does a raw inflate with a single call using a call-back
1106275793eaSopenharmony_ci   interface for input and output.  This is potentially more efficient than
1107275793eaSopenharmony_ci   inflate() for file i/o applications, in that it avoids copying between the
1108275793eaSopenharmony_ci   output and the sliding window by simply making the window itself the output
1109275793eaSopenharmony_ci   buffer.  inflate() can be faster on modern CPUs when used with large
1110275793eaSopenharmony_ci   buffers.  inflateBack() trusts the application to not change the output
1111275793eaSopenharmony_ci   buffer passed by the output function, at least until inflateBack() returns.
1112275793eaSopenharmony_ci
1113275793eaSopenharmony_ci     inflateBackInit() must be called first to allocate the internal state
1114275793eaSopenharmony_ci   and to initialize the state with the user-provided window buffer.
1115275793eaSopenharmony_ci   inflateBack() may then be used multiple times to inflate a complete, raw
1116275793eaSopenharmony_ci   deflate stream with each call.  inflateBackEnd() is then called to free the
1117275793eaSopenharmony_ci   allocated state.
1118275793eaSopenharmony_ci
1119275793eaSopenharmony_ci     A raw deflate stream is one with no zlib or gzip header or trailer.
1120275793eaSopenharmony_ci   This routine would normally be used in a utility that reads zip or gzip
1121275793eaSopenharmony_ci   files and writes out uncompressed files.  The utility would decode the
1122275793eaSopenharmony_ci   header and process the trailer on its own, hence this routine expects only
1123275793eaSopenharmony_ci   the raw deflate stream to decompress.  This is different from the default
1124275793eaSopenharmony_ci   behavior of inflate(), which expects a zlib header and trailer around the
1125275793eaSopenharmony_ci   deflate stream.
1126275793eaSopenharmony_ci
1127275793eaSopenharmony_ci     inflateBack() uses two subroutines supplied by the caller that are then
1128275793eaSopenharmony_ci   called by inflateBack() for input and output.  inflateBack() calls those
1129275793eaSopenharmony_ci   routines until it reads a complete deflate stream and writes out all of the
1130275793eaSopenharmony_ci   uncompressed data, or until it encounters an error.  The function's
1131275793eaSopenharmony_ci   parameters and return types are defined above in the in_func and out_func
1132275793eaSopenharmony_ci   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the
1133275793eaSopenharmony_ci   number of bytes of provided input, and a pointer to that input in buf.  If
1134275793eaSopenharmony_ci   there is no input available, in() must return zero -- buf is ignored in that
1135275793eaSopenharmony_ci   case -- and inflateBack() will return a buffer error.  inflateBack() will
1136275793eaSopenharmony_ci   call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].
1137275793eaSopenharmony_ci   out() should return zero on success, or non-zero on failure.  If out()
1138275793eaSopenharmony_ci   returns non-zero, inflateBack() will return with an error.  Neither in() nor
1139275793eaSopenharmony_ci   out() are permitted to change the contents of the window provided to
1140275793eaSopenharmony_ci   inflateBackInit(), which is also the buffer that out() uses to write from.
1141275793eaSopenharmony_ci   The length written by out() will be at most the window size.  Any non-zero
1142275793eaSopenharmony_ci   amount of input may be provided by in().
1143275793eaSopenharmony_ci
1144275793eaSopenharmony_ci     For convenience, inflateBack() can be provided input on the first call by
1145275793eaSopenharmony_ci   setting strm->next_in and strm->avail_in.  If that input is exhausted, then
1146275793eaSopenharmony_ci   in() will be called.  Therefore strm->next_in must be initialized before
1147275793eaSopenharmony_ci   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called
1148275793eaSopenharmony_ci   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in
1149275793eaSopenharmony_ci   must also be initialized, and then if strm->avail_in is not zero, input will
1150275793eaSopenharmony_ci   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].
1151275793eaSopenharmony_ci
1152275793eaSopenharmony_ci     The in_desc and out_desc parameters of inflateBack() is passed as the
1153275793eaSopenharmony_ci   first parameter of in() and out() respectively when they are called.  These
1154275793eaSopenharmony_ci   descriptors can be optionally used to pass any information that the caller-
1155275793eaSopenharmony_ci   supplied in() and out() functions need to do their job.
1156275793eaSopenharmony_ci
1157275793eaSopenharmony_ci     On return, inflateBack() will set strm->next_in and strm->avail_in to
1158275793eaSopenharmony_ci   pass back any unused input that was provided by the last in() call.  The
1159275793eaSopenharmony_ci   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
1160275793eaSopenharmony_ci   if in() or out() returned an error, Z_DATA_ERROR if there was a format error
1161275793eaSopenharmony_ci   in the deflate stream (in which case strm->msg is set to indicate the nature
1162275793eaSopenharmony_ci   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
1163275793eaSopenharmony_ci   In the case of Z_BUF_ERROR, an input or output error can be distinguished
1164275793eaSopenharmony_ci   using strm->next_in which will be Z_NULL only if in() returned an error.  If
1165275793eaSopenharmony_ci   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
1166275793eaSopenharmony_ci   non-zero.  (in() will always be called before out(), so strm->next_in is
1167275793eaSopenharmony_ci   assured to be defined if out() returns non-zero.)  Note that inflateBack()
1168275793eaSopenharmony_ci   cannot return Z_OK.
1169275793eaSopenharmony_ci*/
1170275793eaSopenharmony_ci
1171275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm);
1172275793eaSopenharmony_ci/*
1173275793eaSopenharmony_ci     All memory allocated by inflateBackInit() is freed.
1174275793eaSopenharmony_ci
1175275793eaSopenharmony_ci     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
1176275793eaSopenharmony_ci   state was inconsistent.
1177275793eaSopenharmony_ci*/
1178275793eaSopenharmony_ci
1179275793eaSopenharmony_ciZEXTERN uLong ZEXPORT zlibCompileFlags(void);
1180275793eaSopenharmony_ci/* Return flags indicating compile-time options.
1181275793eaSopenharmony_ci
1182275793eaSopenharmony_ci    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
1183275793eaSopenharmony_ci     1.0: size of uInt
1184275793eaSopenharmony_ci     3.2: size of uLong
1185275793eaSopenharmony_ci     5.4: size of voidpf (pointer)
1186275793eaSopenharmony_ci     7.6: size of z_off_t
1187275793eaSopenharmony_ci
1188275793eaSopenharmony_ci    Compiler, assembler, and debug options:
1189275793eaSopenharmony_ci     8: ZLIB_DEBUG
1190275793eaSopenharmony_ci     9: ASMV or ASMINF -- use ASM code
1191275793eaSopenharmony_ci     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
1192275793eaSopenharmony_ci     11: 0 (reserved)
1193275793eaSopenharmony_ci
1194275793eaSopenharmony_ci    One-time table building (smaller code, but not thread-safe if true):
1195275793eaSopenharmony_ci     12: BUILDFIXED -- build static block decoding tables when needed
1196275793eaSopenharmony_ci     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
1197275793eaSopenharmony_ci     14,15: 0 (reserved)
1198275793eaSopenharmony_ci
1199275793eaSopenharmony_ci    Library content (indicates missing functionality):
1200275793eaSopenharmony_ci     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
1201275793eaSopenharmony_ci                          deflate code when not needed)
1202275793eaSopenharmony_ci     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
1203275793eaSopenharmony_ci                    and decode gzip streams (to avoid linking crc code)
1204275793eaSopenharmony_ci     18-19: 0 (reserved)
1205275793eaSopenharmony_ci
1206275793eaSopenharmony_ci    Operation variations (changes in library functionality):
1207275793eaSopenharmony_ci     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
1208275793eaSopenharmony_ci     21: FASTEST -- deflate algorithm with only one, lowest compression level
1209275793eaSopenharmony_ci     22,23: 0 (reserved)
1210275793eaSopenharmony_ci
1211275793eaSopenharmony_ci    The sprintf variant used by gzprintf (zero is best):
1212275793eaSopenharmony_ci     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
1213275793eaSopenharmony_ci     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
1214275793eaSopenharmony_ci     26: 0 = returns value, 1 = void -- 1 means inferred string length returned
1215275793eaSopenharmony_ci
1216275793eaSopenharmony_ci    Remainder:
1217275793eaSopenharmony_ci     27-31: 0 (reserved)
1218275793eaSopenharmony_ci */
1219275793eaSopenharmony_ci
1220275793eaSopenharmony_ci#ifndef Z_SOLO
1221275793eaSopenharmony_ci
1222275793eaSopenharmony_ci                        /* utility functions */
1223275793eaSopenharmony_ci
1224275793eaSopenharmony_ci/*
1225275793eaSopenharmony_ci     The following utility functions are implemented on top of the basic
1226275793eaSopenharmony_ci   stream-oriented functions.  To simplify the interface, some default options
1227275793eaSopenharmony_ci   are assumed (compression level and memory usage, standard memory allocation
1228275793eaSopenharmony_ci   functions).  The source code of these utility functions can be modified if
1229275793eaSopenharmony_ci   you need special options.
1230275793eaSopenharmony_ci*/
1231275793eaSopenharmony_ci
1232275793eaSopenharmony_ciZEXTERN int ZEXPORT compress(Bytef *dest,   uLongf *destLen,
1233275793eaSopenharmony_ci                             const Bytef *source, uLong sourceLen);
1234275793eaSopenharmony_ci/*
1235275793eaSopenharmony_ci     Compresses the source buffer into the destination buffer.  sourceLen is
1236275793eaSopenharmony_ci   the byte length of the source buffer.  Upon entry, destLen is the total size
1237275793eaSopenharmony_ci   of the destination buffer, which must be at least the value returned by
1238275793eaSopenharmony_ci   compressBound(sourceLen).  Upon exit, destLen is the actual size of the
1239275793eaSopenharmony_ci   compressed data.  compress() is equivalent to compress2() with a level
1240275793eaSopenharmony_ci   parameter of Z_DEFAULT_COMPRESSION.
1241275793eaSopenharmony_ci
1242275793eaSopenharmony_ci     compress returns Z_OK if success, Z_MEM_ERROR if there was not
1243275793eaSopenharmony_ci   enough memory, Z_BUF_ERROR if there was not enough room in the output
1244275793eaSopenharmony_ci   buffer.
1245275793eaSopenharmony_ci*/
1246275793eaSopenharmony_ci
1247275793eaSopenharmony_ciZEXTERN int ZEXPORT compress2(Bytef *dest,   uLongf *destLen,
1248275793eaSopenharmony_ci                              const Bytef *source, uLong sourceLen,
1249275793eaSopenharmony_ci                              int level);
1250275793eaSopenharmony_ci/*
1251275793eaSopenharmony_ci     Compresses the source buffer into the destination buffer.  The level
1252275793eaSopenharmony_ci   parameter has the same meaning as in deflateInit.  sourceLen is the byte
1253275793eaSopenharmony_ci   length of the source buffer.  Upon entry, destLen is the total size of the
1254275793eaSopenharmony_ci   destination buffer, which must be at least the value returned by
1255275793eaSopenharmony_ci   compressBound(sourceLen).  Upon exit, destLen is the actual size of the
1256275793eaSopenharmony_ci   compressed data.
1257275793eaSopenharmony_ci
1258275793eaSopenharmony_ci     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
1259275793eaSopenharmony_ci   memory, Z_BUF_ERROR if there was not enough room in the output buffer,
1260275793eaSopenharmony_ci   Z_STREAM_ERROR if the level parameter is invalid.
1261275793eaSopenharmony_ci*/
1262275793eaSopenharmony_ci
1263275793eaSopenharmony_ciZEXTERN uLong ZEXPORT compressBound(uLong sourceLen);
1264275793eaSopenharmony_ci/*
1265275793eaSopenharmony_ci     compressBound() returns an upper bound on the compressed size after
1266275793eaSopenharmony_ci   compress() or compress2() on sourceLen bytes.  It would be used before a
1267275793eaSopenharmony_ci   compress() or compress2() call to allocate the destination buffer.
1268275793eaSopenharmony_ci*/
1269275793eaSopenharmony_ci
1270275793eaSopenharmony_ciZEXTERN int ZEXPORT uncompress(Bytef *dest,   uLongf *destLen,
1271275793eaSopenharmony_ci                               const Bytef *source, uLong sourceLen);
1272275793eaSopenharmony_ci/*
1273275793eaSopenharmony_ci     Decompresses the source buffer into the destination buffer.  sourceLen is
1274275793eaSopenharmony_ci   the byte length of the source buffer.  Upon entry, destLen is the total size
1275275793eaSopenharmony_ci   of the destination buffer, which must be large enough to hold the entire
1276275793eaSopenharmony_ci   uncompressed data.  (The size of the uncompressed data must have been saved
1277275793eaSopenharmony_ci   previously by the compressor and transmitted to the decompressor by some
1278275793eaSopenharmony_ci   mechanism outside the scope of this compression library.) Upon exit, destLen
1279275793eaSopenharmony_ci   is the actual size of the uncompressed data.
1280275793eaSopenharmony_ci
1281275793eaSopenharmony_ci     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
1282275793eaSopenharmony_ci   enough memory, Z_BUF_ERROR if there was not enough room in the output
1283275793eaSopenharmony_ci   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.  In
1284275793eaSopenharmony_ci   the case where there is not enough room, uncompress() will fill the output
1285275793eaSopenharmony_ci   buffer with the uncompressed data up to that point.
1286275793eaSopenharmony_ci*/
1287275793eaSopenharmony_ci
1288275793eaSopenharmony_ciZEXTERN int ZEXPORT uncompress2(Bytef *dest,   uLongf *destLen,
1289275793eaSopenharmony_ci                                const Bytef *source, uLong *sourceLen);
1290275793eaSopenharmony_ci/*
1291275793eaSopenharmony_ci     Same as uncompress, except that sourceLen is a pointer, where the
1292275793eaSopenharmony_ci   length of the source is *sourceLen.  On return, *sourceLen is the number of
1293275793eaSopenharmony_ci   source bytes consumed.
1294275793eaSopenharmony_ci*/
1295275793eaSopenharmony_ci
1296275793eaSopenharmony_ci                        /* gzip file access functions */
1297275793eaSopenharmony_ci
1298275793eaSopenharmony_ci/*
1299275793eaSopenharmony_ci     This library supports reading and writing files in gzip (.gz) format with
1300275793eaSopenharmony_ci   an interface similar to that of stdio, using the functions that start with
1301275793eaSopenharmony_ci   "gz".  The gzip format is different from the zlib format.  gzip is a gzip
1302275793eaSopenharmony_ci   wrapper, documented in RFC 1952, wrapped around a deflate stream.
1303275793eaSopenharmony_ci*/
1304275793eaSopenharmony_ci
1305275793eaSopenharmony_citypedef struct gzFile_s *gzFile;    /* semi-opaque gzip file descriptor */
1306275793eaSopenharmony_ci
1307275793eaSopenharmony_ci/*
1308275793eaSopenharmony_ciZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode);
1309275793eaSopenharmony_ci
1310275793eaSopenharmony_ci     Open the gzip (.gz) file at path for reading and decompressing, or
1311275793eaSopenharmony_ci   compressing and writing.  The mode parameter is as in fopen ("rb" or "wb")
1312275793eaSopenharmony_ci   but can also include a compression level ("wb9") or a strategy: 'f' for
1313275793eaSopenharmony_ci   filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h",
1314275793eaSopenharmony_ci   'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression
1315275793eaSopenharmony_ci   as in "wb9F".  (See the description of deflateInit2 for more information
1316275793eaSopenharmony_ci   about the strategy parameter.)  'T' will request transparent writing or
1317275793eaSopenharmony_ci   appending with no compression and not using the gzip format.
1318275793eaSopenharmony_ci
1319275793eaSopenharmony_ci     "a" can be used instead of "w" to request that the gzip stream that will
1320275793eaSopenharmony_ci   be written be appended to the file.  "+" will result in an error, since
1321275793eaSopenharmony_ci   reading and writing to the same gzip file is not supported.  The addition of
1322275793eaSopenharmony_ci   "x" when writing will create the file exclusively, which fails if the file
1323275793eaSopenharmony_ci   already exists.  On systems that support it, the addition of "e" when
1324275793eaSopenharmony_ci   reading or writing will set the flag to close the file on an execve() call.
1325275793eaSopenharmony_ci
1326275793eaSopenharmony_ci     These functions, as well as gzip, will read and decode a sequence of gzip
1327275793eaSopenharmony_ci   streams in a file.  The append function of gzopen() can be used to create
1328275793eaSopenharmony_ci   such a file.  (Also see gzflush() for another way to do this.)  When
1329275793eaSopenharmony_ci   appending, gzopen does not test whether the file begins with a gzip stream,
1330275793eaSopenharmony_ci   nor does it look for the end of the gzip streams to begin appending.  gzopen
1331275793eaSopenharmony_ci   will simply append a gzip stream to the existing file.
1332275793eaSopenharmony_ci
1333275793eaSopenharmony_ci     gzopen can be used to read a file which is not in gzip format; in this
1334275793eaSopenharmony_ci   case gzread will directly read from the file without decompression.  When
1335275793eaSopenharmony_ci   reading, this will be detected automatically by looking for the magic two-
1336275793eaSopenharmony_ci   byte gzip header.
1337275793eaSopenharmony_ci
1338275793eaSopenharmony_ci     gzopen returns NULL if the file could not be opened, if there was
1339275793eaSopenharmony_ci   insufficient memory to allocate the gzFile state, or if an invalid mode was
1340275793eaSopenharmony_ci   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
1341275793eaSopenharmony_ci   errno can be checked to determine if the reason gzopen failed was that the
1342275793eaSopenharmony_ci   file could not be opened.
1343275793eaSopenharmony_ci*/
1344275793eaSopenharmony_ci
1345275793eaSopenharmony_ciZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode);
1346275793eaSopenharmony_ci/*
1347275793eaSopenharmony_ci     Associate a gzFile with the file descriptor fd.  File descriptors are
1348275793eaSopenharmony_ci   obtained from calls like open, dup, creat, pipe or fileno (if the file has
1349275793eaSopenharmony_ci   been previously opened with fopen).  The mode parameter is as in gzopen.
1350275793eaSopenharmony_ci
1351275793eaSopenharmony_ci     The next call of gzclose on the returned gzFile will also close the file
1352275793eaSopenharmony_ci   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
1353275793eaSopenharmony_ci   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
1354275793eaSopenharmony_ci   mode);.  The duplicated descriptor should be saved to avoid a leak, since
1355275793eaSopenharmony_ci   gzdopen does not close fd if it fails.  If you are using fileno() to get the
1356275793eaSopenharmony_ci   file descriptor from a FILE *, then you will have to use dup() to avoid
1357275793eaSopenharmony_ci   double-close()ing the file descriptor.  Both gzclose() and fclose() will
1358275793eaSopenharmony_ci   close the associated file descriptor, so they need to have different file
1359275793eaSopenharmony_ci   descriptors.
1360275793eaSopenharmony_ci
1361275793eaSopenharmony_ci     gzdopen returns NULL if there was insufficient memory to allocate the
1362275793eaSopenharmony_ci   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
1363275793eaSopenharmony_ci   provided, or '+' was provided), or if fd is -1.  The file descriptor is not
1364275793eaSopenharmony_ci   used until the next gz* read, write, seek, or close operation, so gzdopen
1365275793eaSopenharmony_ci   will not detect if fd is invalid (unless fd is -1).
1366275793eaSopenharmony_ci*/
1367275793eaSopenharmony_ci
1368275793eaSopenharmony_ciZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size);
1369275793eaSopenharmony_ci/*
1370275793eaSopenharmony_ci     Set the internal buffer size used by this library's functions for file to
1371275793eaSopenharmony_ci   size.  The default buffer size is 8192 bytes.  This function must be called
1372275793eaSopenharmony_ci   after gzopen() or gzdopen(), and before any other calls that read or write
1373275793eaSopenharmony_ci   the file.  The buffer memory allocation is always deferred to the first read
1374275793eaSopenharmony_ci   or write.  Three times that size in buffer space is allocated.  A larger
1375275793eaSopenharmony_ci   buffer size of, for example, 64K or 128K bytes will noticeably increase the
1376275793eaSopenharmony_ci   speed of decompression (reading).
1377275793eaSopenharmony_ci
1378275793eaSopenharmony_ci     The new buffer size also affects the maximum length for gzprintf().
1379275793eaSopenharmony_ci
1380275793eaSopenharmony_ci     gzbuffer() returns 0 on success, or -1 on failure, such as being called
1381275793eaSopenharmony_ci   too late.
1382275793eaSopenharmony_ci*/
1383275793eaSopenharmony_ci
1384275793eaSopenharmony_ciZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy);
1385275793eaSopenharmony_ci/*
1386275793eaSopenharmony_ci     Dynamically update the compression level and strategy for file.  See the
1387275793eaSopenharmony_ci   description of deflateInit2 for the meaning of these parameters. Previously
1388275793eaSopenharmony_ci   provided data is flushed before applying the parameter changes.
1389275793eaSopenharmony_ci
1390275793eaSopenharmony_ci     gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
1391275793eaSopenharmony_ci   opened for writing, Z_ERRNO if there is an error writing the flushed data,
1392275793eaSopenharmony_ci   or Z_MEM_ERROR if there is a memory allocation error.
1393275793eaSopenharmony_ci*/
1394275793eaSopenharmony_ci
1395275793eaSopenharmony_ciZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len);
1396275793eaSopenharmony_ci/*
1397275793eaSopenharmony_ci     Read and decompress up to len uncompressed bytes from file into buf.  If
1398275793eaSopenharmony_ci   the input file is not in gzip format, gzread copies the given number of
1399275793eaSopenharmony_ci   bytes into the buffer directly from the file.
1400275793eaSopenharmony_ci
1401275793eaSopenharmony_ci     After reaching the end of a gzip stream in the input, gzread will continue
1402275793eaSopenharmony_ci   to read, looking for another gzip stream.  Any number of gzip streams may be
1403275793eaSopenharmony_ci   concatenated in the input file, and will all be decompressed by gzread().
1404275793eaSopenharmony_ci   If something other than a gzip stream is encountered after a gzip stream,
1405275793eaSopenharmony_ci   that remaining trailing garbage is ignored (and no error is returned).
1406275793eaSopenharmony_ci
1407275793eaSopenharmony_ci     gzread can be used to read a gzip file that is being concurrently written.
1408275793eaSopenharmony_ci   Upon reaching the end of the input, gzread will return with the available
1409275793eaSopenharmony_ci   data.  If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then
1410275793eaSopenharmony_ci   gzclearerr can be used to clear the end of file indicator in order to permit
1411275793eaSopenharmony_ci   gzread to be tried again.  Z_OK indicates that a gzip stream was completed
1412275793eaSopenharmony_ci   on the last gzread.  Z_BUF_ERROR indicates that the input file ended in the
1413275793eaSopenharmony_ci   middle of a gzip stream.  Note that gzread does not return -1 in the event
1414275793eaSopenharmony_ci   of an incomplete gzip stream.  This error is deferred until gzclose(), which
1415275793eaSopenharmony_ci   will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
1416275793eaSopenharmony_ci   stream.  Alternatively, gzerror can be used before gzclose to detect this
1417275793eaSopenharmony_ci   case.
1418275793eaSopenharmony_ci
1419275793eaSopenharmony_ci     gzread returns the number of uncompressed bytes actually read, less than
1420275793eaSopenharmony_ci   len for end of file, or -1 for error.  If len is too large to fit in an int,
1421275793eaSopenharmony_ci   then nothing is read, -1 is returned, and the error state is set to
1422275793eaSopenharmony_ci   Z_STREAM_ERROR.
1423275793eaSopenharmony_ci*/
1424275793eaSopenharmony_ci
1425275793eaSopenharmony_ciZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
1426275793eaSopenharmony_ci                                 gzFile file);
1427275793eaSopenharmony_ci/*
1428275793eaSopenharmony_ci     Read and decompress up to nitems items of size size from file into buf,
1429275793eaSopenharmony_ci   otherwise operating as gzread() does.  This duplicates the interface of
1430275793eaSopenharmony_ci   stdio's fread(), with size_t request and return types.  If the library
1431275793eaSopenharmony_ci   defines size_t, then z_size_t is identical to size_t.  If not, then z_size_t
1432275793eaSopenharmony_ci   is an unsigned integer type that can contain a pointer.
1433275793eaSopenharmony_ci
1434275793eaSopenharmony_ci     gzfread() returns the number of full items read of size size, or zero if
1435275793eaSopenharmony_ci   the end of the file was reached and a full item could not be read, or if
1436275793eaSopenharmony_ci   there was an error.  gzerror() must be consulted if zero is returned in
1437275793eaSopenharmony_ci   order to determine if there was an error.  If the multiplication of size and
1438275793eaSopenharmony_ci   nitems overflows, i.e. the product does not fit in a z_size_t, then nothing
1439275793eaSopenharmony_ci   is read, zero is returned, and the error state is set to Z_STREAM_ERROR.
1440275793eaSopenharmony_ci
1441275793eaSopenharmony_ci     In the event that the end of file is reached and only a partial item is
1442275793eaSopenharmony_ci   available at the end, i.e. the remaining uncompressed data length is not a
1443275793eaSopenharmony_ci   multiple of size, then the final partial item is nevertheless read into buf
1444275793eaSopenharmony_ci   and the end-of-file flag is set.  The length of the partial item read is not
1445275793eaSopenharmony_ci   provided, but could be inferred from the result of gztell().  This behavior
1446275793eaSopenharmony_ci   is the same as the behavior of fread() implementations in common libraries,
1447275793eaSopenharmony_ci   but it prevents the direct use of gzfread() to read a concurrently written
1448275793eaSopenharmony_ci   file, resetting and retrying on end-of-file, when size is not 1.
1449275793eaSopenharmony_ci*/
1450275793eaSopenharmony_ci
1451275793eaSopenharmony_ciZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len);
1452275793eaSopenharmony_ci/*
1453275793eaSopenharmony_ci     Compress and write the len uncompressed bytes at buf to file. gzwrite
1454275793eaSopenharmony_ci   returns the number of uncompressed bytes written or 0 in case of error.
1455275793eaSopenharmony_ci*/
1456275793eaSopenharmony_ci
1457275793eaSopenharmony_ciZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size,
1458275793eaSopenharmony_ci                                  z_size_t nitems, gzFile file);
1459275793eaSopenharmony_ci/*
1460275793eaSopenharmony_ci     Compress and write nitems items of size size from buf to file, duplicating
1461275793eaSopenharmony_ci   the interface of stdio's fwrite(), with size_t request and return types.  If
1462275793eaSopenharmony_ci   the library defines size_t, then z_size_t is identical to size_t.  If not,
1463275793eaSopenharmony_ci   then z_size_t is an unsigned integer type that can contain a pointer.
1464275793eaSopenharmony_ci
1465275793eaSopenharmony_ci     gzfwrite() returns the number of full items written of size size, or zero
1466275793eaSopenharmony_ci   if there was an error.  If the multiplication of size and nitems overflows,
1467275793eaSopenharmony_ci   i.e. the product does not fit in a z_size_t, then nothing is written, zero
1468275793eaSopenharmony_ci   is returned, and the error state is set to Z_STREAM_ERROR.
1469275793eaSopenharmony_ci*/
1470275793eaSopenharmony_ci
1471275793eaSopenharmony_ciZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...);
1472275793eaSopenharmony_ci/*
1473275793eaSopenharmony_ci     Convert, format, compress, and write the arguments (...) to file under
1474275793eaSopenharmony_ci   control of the string format, as in fprintf.  gzprintf returns the number of
1475275793eaSopenharmony_ci   uncompressed bytes actually written, or a negative zlib error code in case
1476275793eaSopenharmony_ci   of error.  The number of uncompressed bytes written is limited to 8191, or
1477275793eaSopenharmony_ci   one less than the buffer size given to gzbuffer().  The caller should assure
1478275793eaSopenharmony_ci   that this limit is not exceeded.  If it is exceeded, then gzprintf() will
1479275793eaSopenharmony_ci   return an error (0) with nothing written.  In this case, there may also be a
1480275793eaSopenharmony_ci   buffer overflow with unpredictable consequences, which is possible only if
1481275793eaSopenharmony_ci   zlib was compiled with the insecure functions sprintf() or vsprintf(),
1482275793eaSopenharmony_ci   because the secure snprintf() or vsnprintf() functions were not available.
1483275793eaSopenharmony_ci   This can be determined using zlibCompileFlags().
1484275793eaSopenharmony_ci*/
1485275793eaSopenharmony_ci
1486275793eaSopenharmony_ciZEXTERN int ZEXPORT gzputs(gzFile file, const char *s);
1487275793eaSopenharmony_ci/*
1488275793eaSopenharmony_ci     Compress and write the given null-terminated string s to file, excluding
1489275793eaSopenharmony_ci   the terminating null character.
1490275793eaSopenharmony_ci
1491275793eaSopenharmony_ci     gzputs returns the number of characters written, or -1 in case of error.
1492275793eaSopenharmony_ci*/
1493275793eaSopenharmony_ci
1494275793eaSopenharmony_ciZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len);
1495275793eaSopenharmony_ci/*
1496275793eaSopenharmony_ci     Read and decompress bytes from file into buf, until len-1 characters are
1497275793eaSopenharmony_ci   read, or until a newline character is read and transferred to buf, or an
1498275793eaSopenharmony_ci   end-of-file condition is encountered.  If any characters are read or if len
1499275793eaSopenharmony_ci   is one, the string is terminated with a null character.  If no characters
1500275793eaSopenharmony_ci   are read due to an end-of-file or len is less than one, then the buffer is
1501275793eaSopenharmony_ci   left untouched.
1502275793eaSopenharmony_ci
1503275793eaSopenharmony_ci     gzgets returns buf which is a null-terminated string, or it returns NULL
1504275793eaSopenharmony_ci   for end-of-file or in case of error.  If there was an error, the contents at
1505275793eaSopenharmony_ci   buf are indeterminate.
1506275793eaSopenharmony_ci*/
1507275793eaSopenharmony_ci
1508275793eaSopenharmony_ciZEXTERN int ZEXPORT gzputc(gzFile file, int c);
1509275793eaSopenharmony_ci/*
1510275793eaSopenharmony_ci     Compress and write c, converted to an unsigned char, into file.  gzputc
1511275793eaSopenharmony_ci   returns the value that was written, or -1 in case of error.
1512275793eaSopenharmony_ci*/
1513275793eaSopenharmony_ci
1514275793eaSopenharmony_ciZEXTERN int ZEXPORT gzgetc(gzFile file);
1515275793eaSopenharmony_ci/*
1516275793eaSopenharmony_ci     Read and decompress one byte from file.  gzgetc returns this byte or -1
1517275793eaSopenharmony_ci   in case of end of file or error.  This is implemented as a macro for speed.
1518275793eaSopenharmony_ci   As such, it does not do all of the checking the other functions do.  I.e.
1519275793eaSopenharmony_ci   it does not check to see if file is NULL, nor whether the structure file
1520275793eaSopenharmony_ci   points to has been clobbered or not.
1521275793eaSopenharmony_ci*/
1522275793eaSopenharmony_ci
1523275793eaSopenharmony_ciZEXTERN int ZEXPORT gzungetc(int c, gzFile file);
1524275793eaSopenharmony_ci/*
1525275793eaSopenharmony_ci     Push c back onto the stream for file to be read as the first character on
1526275793eaSopenharmony_ci   the next read.  At least one character of push-back is always allowed.
1527275793eaSopenharmony_ci   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will
1528275793eaSopenharmony_ci   fail if c is -1, and may fail if a character has been pushed but not read
1529275793eaSopenharmony_ci   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the
1530275793eaSopenharmony_ci   output buffer size of pushed characters is allowed.  (See gzbuffer above.)
1531275793eaSopenharmony_ci   The pushed character will be discarded if the stream is repositioned with
1532275793eaSopenharmony_ci   gzseek() or gzrewind().
1533275793eaSopenharmony_ci*/
1534275793eaSopenharmony_ci
1535275793eaSopenharmony_ciZEXTERN int ZEXPORT gzflush(gzFile file, int flush);
1536275793eaSopenharmony_ci/*
1537275793eaSopenharmony_ci     Flush all pending output to file.  The parameter flush is as in the
1538275793eaSopenharmony_ci   deflate() function.  The return value is the zlib error number (see function
1539275793eaSopenharmony_ci   gzerror below).  gzflush is only permitted when writing.
1540275793eaSopenharmony_ci
1541275793eaSopenharmony_ci     If the flush parameter is Z_FINISH, the remaining data is written and the
1542275793eaSopenharmony_ci   gzip stream is completed in the output.  If gzwrite() is called again, a new
1543275793eaSopenharmony_ci   gzip stream will be started in the output.  gzread() is able to read such
1544275793eaSopenharmony_ci   concatenated gzip streams.
1545275793eaSopenharmony_ci
1546275793eaSopenharmony_ci     gzflush should be called only when strictly necessary because it will
1547275793eaSopenharmony_ci   degrade compression if called too often.
1548275793eaSopenharmony_ci*/
1549275793eaSopenharmony_ci
1550275793eaSopenharmony_ci/*
1551275793eaSopenharmony_ciZEXTERN z_off_t ZEXPORT gzseek(gzFile file,
1552275793eaSopenharmony_ci                               z_off_t offset, int whence);
1553275793eaSopenharmony_ci
1554275793eaSopenharmony_ci     Set the starting position to offset relative to whence for the next gzread
1555275793eaSopenharmony_ci   or gzwrite on file.  The offset represents a number of bytes in the
1556275793eaSopenharmony_ci   uncompressed data stream.  The whence parameter is defined as in lseek(2);
1557275793eaSopenharmony_ci   the value SEEK_END is not supported.
1558275793eaSopenharmony_ci
1559275793eaSopenharmony_ci     If the file is opened for reading, this function is emulated but can be
1560275793eaSopenharmony_ci   extremely slow.  If the file is opened for writing, only forward seeks are
1561275793eaSopenharmony_ci   supported; gzseek then compresses a sequence of zeroes up to the new
1562275793eaSopenharmony_ci   starting position.
1563275793eaSopenharmony_ci
1564275793eaSopenharmony_ci     gzseek returns the resulting offset location as measured in bytes from
1565275793eaSopenharmony_ci   the beginning of the uncompressed stream, or -1 in case of error, in
1566275793eaSopenharmony_ci   particular if the file is opened for writing and the new starting position
1567275793eaSopenharmony_ci   would be before the current position.
1568275793eaSopenharmony_ci*/
1569275793eaSopenharmony_ci
1570275793eaSopenharmony_ciZEXTERN int ZEXPORT    gzrewind(gzFile file);
1571275793eaSopenharmony_ci/*
1572275793eaSopenharmony_ci     Rewind file. This function is supported only for reading.
1573275793eaSopenharmony_ci
1574275793eaSopenharmony_ci     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET).
1575275793eaSopenharmony_ci*/
1576275793eaSopenharmony_ci
1577275793eaSopenharmony_ci/*
1578275793eaSopenharmony_ciZEXTERN z_off_t ZEXPORT    gztell(gzFile file);
1579275793eaSopenharmony_ci
1580275793eaSopenharmony_ci     Return the starting position for the next gzread or gzwrite on file.
1581275793eaSopenharmony_ci   This position represents a number of bytes in the uncompressed data stream,
1582275793eaSopenharmony_ci   and is zero when starting, even if appending or reading a gzip stream from
1583275793eaSopenharmony_ci   the middle of a file using gzdopen().
1584275793eaSopenharmony_ci
1585275793eaSopenharmony_ci     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
1586275793eaSopenharmony_ci*/
1587275793eaSopenharmony_ci
1588275793eaSopenharmony_ci/*
1589275793eaSopenharmony_ciZEXTERN z_off_t ZEXPORT gzoffset(gzFile file);
1590275793eaSopenharmony_ci
1591275793eaSopenharmony_ci     Return the current compressed (actual) read or write offset of file.  This
1592275793eaSopenharmony_ci   offset includes the count of bytes that precede the gzip stream, for example
1593275793eaSopenharmony_ci   when appending or when using gzdopen() for reading.  When reading, the
1594275793eaSopenharmony_ci   offset does not include as yet unused buffered input.  This information can
1595275793eaSopenharmony_ci   be used for a progress indicator.  On error, gzoffset() returns -1.
1596275793eaSopenharmony_ci*/
1597275793eaSopenharmony_ci
1598275793eaSopenharmony_ciZEXTERN int ZEXPORT gzeof(gzFile file);
1599275793eaSopenharmony_ci/*
1600275793eaSopenharmony_ci     Return true (1) if the end-of-file indicator for file has been set while
1601275793eaSopenharmony_ci   reading, false (0) otherwise.  Note that the end-of-file indicator is set
1602275793eaSopenharmony_ci   only if the read tried to go past the end of the input, but came up short.
1603275793eaSopenharmony_ci   Therefore, just like feof(), gzeof() may return false even if there is no
1604275793eaSopenharmony_ci   more data to read, in the event that the last read request was for the exact
1605275793eaSopenharmony_ci   number of bytes remaining in the input file.  This will happen if the input
1606275793eaSopenharmony_ci   file size is an exact multiple of the buffer size.
1607275793eaSopenharmony_ci
1608275793eaSopenharmony_ci     If gzeof() returns true, then the read functions will return no more data,
1609275793eaSopenharmony_ci   unless the end-of-file indicator is reset by gzclearerr() and the input file
1610275793eaSopenharmony_ci   has grown since the previous end of file was detected.
1611275793eaSopenharmony_ci*/
1612275793eaSopenharmony_ci
1613275793eaSopenharmony_ciZEXTERN int ZEXPORT gzdirect(gzFile file);
1614275793eaSopenharmony_ci/*
1615275793eaSopenharmony_ci     Return true (1) if file is being copied directly while reading, or false
1616275793eaSopenharmony_ci   (0) if file is a gzip stream being decompressed.
1617275793eaSopenharmony_ci
1618275793eaSopenharmony_ci     If the input file is empty, gzdirect() will return true, since the input
1619275793eaSopenharmony_ci   does not contain a gzip stream.
1620275793eaSopenharmony_ci
1621275793eaSopenharmony_ci     If gzdirect() is used immediately after gzopen() or gzdopen() it will
1622275793eaSopenharmony_ci   cause buffers to be allocated to allow reading the file to determine if it
1623275793eaSopenharmony_ci   is a gzip file.  Therefore if gzbuffer() is used, it should be called before
1624275793eaSopenharmony_ci   gzdirect().
1625275793eaSopenharmony_ci
1626275793eaSopenharmony_ci     When writing, gzdirect() returns true (1) if transparent writing was
1627275793eaSopenharmony_ci   requested ("wT" for the gzopen() mode), or false (0) otherwise.  (Note:
1628275793eaSopenharmony_ci   gzdirect() is not needed when writing.  Transparent writing must be
1629275793eaSopenharmony_ci   explicitly requested, so the application already knows the answer.  When
1630275793eaSopenharmony_ci   linking statically, using gzdirect() will include all of the zlib code for
1631275793eaSopenharmony_ci   gzip file reading and decompression, which may not be desired.)
1632275793eaSopenharmony_ci*/
1633275793eaSopenharmony_ci
1634275793eaSopenharmony_ciZEXTERN int ZEXPORT    gzclose(gzFile file);
1635275793eaSopenharmony_ci/*
1636275793eaSopenharmony_ci     Flush all pending output for file, if necessary, close file and
1637275793eaSopenharmony_ci   deallocate the (de)compression state.  Note that once file is closed, you
1638275793eaSopenharmony_ci   cannot call gzerror with file, since its structures have been deallocated.
1639275793eaSopenharmony_ci   gzclose must not be called more than once on the same file, just as free
1640275793eaSopenharmony_ci   must not be called more than once on the same allocation.
1641275793eaSopenharmony_ci
1642275793eaSopenharmony_ci     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
1643275793eaSopenharmony_ci   file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the
1644275793eaSopenharmony_ci   last read ended in the middle of a gzip stream, or Z_OK on success.
1645275793eaSopenharmony_ci*/
1646275793eaSopenharmony_ci
1647275793eaSopenharmony_ciZEXTERN int ZEXPORT gzclose_r(gzFile file);
1648275793eaSopenharmony_ciZEXTERN int ZEXPORT gzclose_w(gzFile file);
1649275793eaSopenharmony_ci/*
1650275793eaSopenharmony_ci     Same as gzclose(), but gzclose_r() is only for use when reading, and
1651275793eaSopenharmony_ci   gzclose_w() is only for use when writing or appending.  The advantage to
1652275793eaSopenharmony_ci   using these instead of gzclose() is that they avoid linking in zlib
1653275793eaSopenharmony_ci   compression or decompression code that is not used when only reading or only
1654275793eaSopenharmony_ci   writing respectively.  If gzclose() is used, then both compression and
1655275793eaSopenharmony_ci   decompression code will be included the application when linking to a static
1656275793eaSopenharmony_ci   zlib library.
1657275793eaSopenharmony_ci*/
1658275793eaSopenharmony_ci
1659275793eaSopenharmony_ciZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum);
1660275793eaSopenharmony_ci/*
1661275793eaSopenharmony_ci     Return the error message for the last error which occurred on file.
1662275793eaSopenharmony_ci   errnum is set to zlib error number.  If an error occurred in the file system
1663275793eaSopenharmony_ci   and not in the compression library, errnum is set to Z_ERRNO and the
1664275793eaSopenharmony_ci   application may consult errno to get the exact error code.
1665275793eaSopenharmony_ci
1666275793eaSopenharmony_ci     The application must not modify the returned string.  Future calls to
1667275793eaSopenharmony_ci   this function may invalidate the previously returned string.  If file is
1668275793eaSopenharmony_ci   closed, then the string previously returned by gzerror will no longer be
1669275793eaSopenharmony_ci   available.
1670275793eaSopenharmony_ci
1671275793eaSopenharmony_ci     gzerror() should be used to distinguish errors from end-of-file for those
1672275793eaSopenharmony_ci   functions above that do not distinguish those cases in their return values.
1673275793eaSopenharmony_ci*/
1674275793eaSopenharmony_ci
1675275793eaSopenharmony_ciZEXTERN void ZEXPORT gzclearerr(gzFile file);
1676275793eaSopenharmony_ci/*
1677275793eaSopenharmony_ci     Clear the error and end-of-file flags for file.  This is analogous to the
1678275793eaSopenharmony_ci   clearerr() function in stdio.  This is useful for continuing to read a gzip
1679275793eaSopenharmony_ci   file that is being written concurrently.
1680275793eaSopenharmony_ci*/
1681275793eaSopenharmony_ci
1682275793eaSopenharmony_ci#endif /* !Z_SOLO */
1683275793eaSopenharmony_ci
1684275793eaSopenharmony_ci                        /* checksum functions */
1685275793eaSopenharmony_ci
1686275793eaSopenharmony_ci/*
1687275793eaSopenharmony_ci     These functions are not related to compression but are exported
1688275793eaSopenharmony_ci   anyway because they might be useful in applications using the compression
1689275793eaSopenharmony_ci   library.
1690275793eaSopenharmony_ci*/
1691275793eaSopenharmony_ci
1692275793eaSopenharmony_ciZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len);
1693275793eaSopenharmony_ci/*
1694275793eaSopenharmony_ci     Update a running Adler-32 checksum with the bytes buf[0..len-1] and
1695275793eaSopenharmony_ci   return the updated checksum. An Adler-32 value is in the range of a 32-bit
1696275793eaSopenharmony_ci   unsigned integer. If buf is Z_NULL, this function returns the required
1697275793eaSopenharmony_ci   initial value for the checksum.
1698275793eaSopenharmony_ci
1699275793eaSopenharmony_ci     An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
1700275793eaSopenharmony_ci   much faster.
1701275793eaSopenharmony_ci
1702275793eaSopenharmony_ci   Usage example:
1703275793eaSopenharmony_ci
1704275793eaSopenharmony_ci     uLong adler = adler32(0L, Z_NULL, 0);
1705275793eaSopenharmony_ci
1706275793eaSopenharmony_ci     while (read_buffer(buffer, length) != EOF) {
1707275793eaSopenharmony_ci       adler = adler32(adler, buffer, length);
1708275793eaSopenharmony_ci     }
1709275793eaSopenharmony_ci     if (adler != original_adler) error();
1710275793eaSopenharmony_ci*/
1711275793eaSopenharmony_ci
1712275793eaSopenharmony_ciZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf,
1713275793eaSopenharmony_ci                                z_size_t len);
1714275793eaSopenharmony_ci/*
1715275793eaSopenharmony_ci     Same as adler32(), but with a size_t length.
1716275793eaSopenharmony_ci*/
1717275793eaSopenharmony_ci
1718275793eaSopenharmony_ci/*
1719275793eaSopenharmony_ciZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2,
1720275793eaSopenharmony_ci                                      z_off_t len2);
1721275793eaSopenharmony_ci
1722275793eaSopenharmony_ci     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1
1723275793eaSopenharmony_ci   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
1724275793eaSopenharmony_ci   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of
1725275793eaSopenharmony_ci   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.  Note
1726275793eaSopenharmony_ci   that the z_off_t type (like off_t) is a signed integer.  If len2 is
1727275793eaSopenharmony_ci   negative, the result has no meaning or utility.
1728275793eaSopenharmony_ci*/
1729275793eaSopenharmony_ci
1730275793eaSopenharmony_ciZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len);
1731275793eaSopenharmony_ci/*
1732275793eaSopenharmony_ci     Update a running CRC-32 with the bytes buf[0..len-1] and return the
1733275793eaSopenharmony_ci   updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer.
1734275793eaSopenharmony_ci   If buf is Z_NULL, this function returns the required initial value for the
1735275793eaSopenharmony_ci   crc. Pre- and post-conditioning (one's complement) is performed within this
1736275793eaSopenharmony_ci   function so it shouldn't be done by the application.
1737275793eaSopenharmony_ci
1738275793eaSopenharmony_ci   Usage example:
1739275793eaSopenharmony_ci
1740275793eaSopenharmony_ci     uLong crc = crc32(0L, Z_NULL, 0);
1741275793eaSopenharmony_ci
1742275793eaSopenharmony_ci     while (read_buffer(buffer, length) != EOF) {
1743275793eaSopenharmony_ci       crc = crc32(crc, buffer, length);
1744275793eaSopenharmony_ci     }
1745275793eaSopenharmony_ci     if (crc != original_crc) error();
1746275793eaSopenharmony_ci*/
1747275793eaSopenharmony_ci
1748275793eaSopenharmony_ciZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf,
1749275793eaSopenharmony_ci                              z_size_t len);
1750275793eaSopenharmony_ci/*
1751275793eaSopenharmony_ci     Same as crc32(), but with a size_t length.
1752275793eaSopenharmony_ci*/
1753275793eaSopenharmony_ci
1754275793eaSopenharmony_ci/*
1755275793eaSopenharmony_ciZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2);
1756275793eaSopenharmony_ci
1757275793eaSopenharmony_ci     Combine two CRC-32 check values into one.  For two sequences of bytes,
1758275793eaSopenharmony_ci   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
1759275793eaSopenharmony_ci   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32
1760275793eaSopenharmony_ci   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
1761275793eaSopenharmony_ci   len2. len2 must be non-negative.
1762275793eaSopenharmony_ci*/
1763275793eaSopenharmony_ci
1764275793eaSopenharmony_ci/*
1765275793eaSopenharmony_ciZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2);
1766275793eaSopenharmony_ci
1767275793eaSopenharmony_ci     Return the operator corresponding to length len2, to be used with
1768275793eaSopenharmony_ci   crc32_combine_op(). len2 must be non-negative.
1769275793eaSopenharmony_ci*/
1770275793eaSopenharmony_ci
1771275793eaSopenharmony_ciZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op);
1772275793eaSopenharmony_ci/*
1773275793eaSopenharmony_ci     Give the same result as crc32_combine(), using op in place of len2. op is
1774275793eaSopenharmony_ci   is generated from len2 by crc32_combine_gen(). This will be faster than
1775275793eaSopenharmony_ci   crc32_combine() if the generated op is used more than once.
1776275793eaSopenharmony_ci*/
1777275793eaSopenharmony_ci
1778275793eaSopenharmony_ci
1779275793eaSopenharmony_ci                        /* various hacks, don't look :) */
1780275793eaSopenharmony_ci
1781275793eaSopenharmony_ci/* deflateInit and inflateInit are macros to allow checking the zlib version
1782275793eaSopenharmony_ci * and the compiler's view of z_stream:
1783275793eaSopenharmony_ci */
1784275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level,
1785275793eaSopenharmony_ci                                 const char *version, int stream_size);
1786275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateInit_(z_streamp strm,
1787275793eaSopenharmony_ci                                 const char *version, int stream_size);
1788275793eaSopenharmony_ciZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int  level, int  method,
1789275793eaSopenharmony_ci                                  int windowBits, int memLevel,
1790275793eaSopenharmony_ci                                  int strategy, const char *version,
1791275793eaSopenharmony_ci                                  int stream_size);
1792275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int  windowBits,
1793275793eaSopenharmony_ci                                  const char *version, int stream_size);
1794275793eaSopenharmony_ciZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
1795275793eaSopenharmony_ci                                     unsigned char FAR *window,
1796275793eaSopenharmony_ci                                     const char *version,
1797275793eaSopenharmony_ci                                     int stream_size);
1798275793eaSopenharmony_ci#ifdef Z_PREFIX_SET
1799275793eaSopenharmony_ci#  define z_deflateInit(strm, level) \
1800275793eaSopenharmony_ci          deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
1801275793eaSopenharmony_ci#  define z_inflateInit(strm) \
1802275793eaSopenharmony_ci          inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
1803275793eaSopenharmony_ci#  define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
1804275793eaSopenharmony_ci          deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
1805275793eaSopenharmony_ci                        (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
1806275793eaSopenharmony_ci#  define z_inflateInit2(strm, windowBits) \
1807275793eaSopenharmony_ci          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
1808275793eaSopenharmony_ci                        (int)sizeof(z_stream))
1809275793eaSopenharmony_ci#  define z_inflateBackInit(strm, windowBits, window) \
1810275793eaSopenharmony_ci          inflateBackInit_((strm), (windowBits), (window), \
1811275793eaSopenharmony_ci                           ZLIB_VERSION, (int)sizeof(z_stream))
1812275793eaSopenharmony_ci#else
1813275793eaSopenharmony_ci#  define deflateInit(strm, level) \
1814275793eaSopenharmony_ci          deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
1815275793eaSopenharmony_ci#  define inflateInit(strm) \
1816275793eaSopenharmony_ci          inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
1817275793eaSopenharmony_ci#  define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
1818275793eaSopenharmony_ci          deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
1819275793eaSopenharmony_ci                        (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
1820275793eaSopenharmony_ci#  define inflateInit2(strm, windowBits) \
1821275793eaSopenharmony_ci          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
1822275793eaSopenharmony_ci                        (int)sizeof(z_stream))
1823275793eaSopenharmony_ci#  define inflateBackInit(strm, windowBits, window) \
1824275793eaSopenharmony_ci          inflateBackInit_((strm), (windowBits), (window), \
1825275793eaSopenharmony_ci                           ZLIB_VERSION, (int)sizeof(z_stream))
1826275793eaSopenharmony_ci#endif
1827275793eaSopenharmony_ci
1828275793eaSopenharmony_ci#ifndef Z_SOLO
1829275793eaSopenharmony_ci
1830275793eaSopenharmony_ci/* gzgetc() macro and its supporting function and exposed data structure.  Note
1831275793eaSopenharmony_ci * that the real internal state is much larger than the exposed structure.
1832275793eaSopenharmony_ci * This abbreviated structure exposes just enough for the gzgetc() macro.  The
1833275793eaSopenharmony_ci * user should not mess with these exposed elements, since their names or
1834275793eaSopenharmony_ci * behavior could change in the future, perhaps even capriciously.  They can
1835275793eaSopenharmony_ci * only be used by the gzgetc() macro.  You have been warned.
1836275793eaSopenharmony_ci */
1837275793eaSopenharmony_cistruct gzFile_s {
1838275793eaSopenharmony_ci    unsigned have;
1839275793eaSopenharmony_ci    unsigned char *next;
1840275793eaSopenharmony_ci    z_off64_t pos;
1841275793eaSopenharmony_ci};
1842275793eaSopenharmony_ciZEXTERN int ZEXPORT gzgetc_(gzFile file);       /* backward compatibility */
1843275793eaSopenharmony_ci#ifdef Z_PREFIX_SET
1844275793eaSopenharmony_ci#  undef z_gzgetc
1845275793eaSopenharmony_ci#  define z_gzgetc(g) \
1846275793eaSopenharmony_ci          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
1847275793eaSopenharmony_ci#else
1848275793eaSopenharmony_ci#  define gzgetc(g) \
1849275793eaSopenharmony_ci          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
1850275793eaSopenharmony_ci#endif
1851275793eaSopenharmony_ci
1852275793eaSopenharmony_ci/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
1853275793eaSopenharmony_ci * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
1854275793eaSopenharmony_ci * both are true, the application gets the *64 functions, and the regular
1855275793eaSopenharmony_ci * functions are changed to 64 bits) -- in case these are set on systems
1856275793eaSopenharmony_ci * without large file support, _LFS64_LARGEFILE must also be true
1857275793eaSopenharmony_ci */
1858275793eaSopenharmony_ci#ifdef Z_LARGE64
1859275793eaSopenharmony_ci   ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
1860275793eaSopenharmony_ci   ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
1861275793eaSopenharmony_ci   ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
1862275793eaSopenharmony_ci   ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
1863275793eaSopenharmony_ci   ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
1864275793eaSopenharmony_ci   ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
1865275793eaSopenharmony_ci   ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
1866275793eaSopenharmony_ci#endif
1867275793eaSopenharmony_ci
1868275793eaSopenharmony_ci#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
1869275793eaSopenharmony_ci#  ifdef Z_PREFIX_SET
1870275793eaSopenharmony_ci#    define z_gzopen z_gzopen64
1871275793eaSopenharmony_ci#    define z_gzseek z_gzseek64
1872275793eaSopenharmony_ci#    define z_gztell z_gztell64
1873275793eaSopenharmony_ci#    define z_gzoffset z_gzoffset64
1874275793eaSopenharmony_ci#    define z_adler32_combine z_adler32_combine64
1875275793eaSopenharmony_ci#    define z_crc32_combine z_crc32_combine64
1876275793eaSopenharmony_ci#    define z_crc32_combine_gen z_crc32_combine_gen64
1877275793eaSopenharmony_ci#  else
1878275793eaSopenharmony_ci#    define gzopen gzopen64
1879275793eaSopenharmony_ci#    define gzseek gzseek64
1880275793eaSopenharmony_ci#    define gztell gztell64
1881275793eaSopenharmony_ci#    define gzoffset gzoffset64
1882275793eaSopenharmony_ci#    define adler32_combine adler32_combine64
1883275793eaSopenharmony_ci#    define crc32_combine crc32_combine64
1884275793eaSopenharmony_ci#    define crc32_combine_gen crc32_combine_gen64
1885275793eaSopenharmony_ci#  endif
1886275793eaSopenharmony_ci#  ifndef Z_LARGE64
1887275793eaSopenharmony_ci     ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
1888275793eaSopenharmony_ci     ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int);
1889275793eaSopenharmony_ci     ZEXTERN z_off_t ZEXPORT gztell64(gzFile);
1890275793eaSopenharmony_ci     ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile);
1891275793eaSopenharmony_ci     ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
1892275793eaSopenharmony_ci     ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
1893275793eaSopenharmony_ci     ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
1894275793eaSopenharmony_ci#  endif
1895275793eaSopenharmony_ci#else
1896275793eaSopenharmony_ci   ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *);
1897275793eaSopenharmony_ci   ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int);
1898275793eaSopenharmony_ci   ZEXTERN z_off_t ZEXPORT gztell(gzFile);
1899275793eaSopenharmony_ci   ZEXTERN z_off_t ZEXPORT gzoffset(gzFile);
1900275793eaSopenharmony_ci   ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t);
1901275793eaSopenharmony_ci   ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t);
1902275793eaSopenharmony_ci   ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t);
1903275793eaSopenharmony_ci#endif
1904275793eaSopenharmony_ci
1905275793eaSopenharmony_ci#else /* Z_SOLO */
1906275793eaSopenharmony_ci
1907275793eaSopenharmony_ci   ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t);
1908275793eaSopenharmony_ci   ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t);
1909275793eaSopenharmony_ci   ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t);
1910275793eaSopenharmony_ci
1911275793eaSopenharmony_ci#endif /* !Z_SOLO */
1912275793eaSopenharmony_ci
1913275793eaSopenharmony_ci/* undocumented functions */
1914275793eaSopenharmony_ciZEXTERN const char   * ZEXPORT zError(int);
1915275793eaSopenharmony_ciZEXTERN int            ZEXPORT inflateSyncPoint(z_streamp);
1916275793eaSopenharmony_ciZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void);
1917275793eaSopenharmony_ciZEXTERN int            ZEXPORT inflateUndermine(z_streamp, int);
1918275793eaSopenharmony_ciZEXTERN int            ZEXPORT inflateValidate(z_streamp, int);
1919275793eaSopenharmony_ciZEXTERN unsigned long  ZEXPORT inflateCodesUsed(z_streamp);
1920275793eaSopenharmony_ciZEXTERN int            ZEXPORT inflateResetKeep(z_streamp);
1921275793eaSopenharmony_ciZEXTERN int            ZEXPORT deflateResetKeep(z_streamp);
1922275793eaSopenharmony_ci#if defined(_WIN32) && !defined(Z_SOLO)
1923275793eaSopenharmony_ciZEXTERN gzFile         ZEXPORT gzopen_w(const wchar_t *path,
1924275793eaSopenharmony_ci                                        const char *mode);
1925275793eaSopenharmony_ci#endif
1926275793eaSopenharmony_ci#if defined(STDC) || defined(Z_HAVE_STDARG_H)
1927275793eaSopenharmony_ci#  ifndef Z_SOLO
1928275793eaSopenharmony_ciZEXTERN int            ZEXPORTVA gzvprintf(gzFile file,
1929275793eaSopenharmony_ci                                           const char *format,
1930275793eaSopenharmony_ci                                           va_list va);
1931275793eaSopenharmony_ci#  endif
1932275793eaSopenharmony_ci#endif
1933275793eaSopenharmony_ci
1934275793eaSopenharmony_ci#ifdef __cplusplus
1935275793eaSopenharmony_ci}
1936275793eaSopenharmony_ci#endif
1937275793eaSopenharmony_ci
1938275793eaSopenharmony_ci#endif /* ZLIB_H */
1939