Rename CONFIG_EHCI_IS_TDI to CONFIG_USB_EHCI_IS_TDI
[platform/kernel/u-boot.git] / include / u-boot / zlib.h
1 /*
2  * This file is derived from zlib.h and zconf.h from the zlib-1.2.3
3  * distribution by Jean-loup Gailly and Mark Adler, with some additions
4  * by Paul Mackerras to aid in implementing Deflate compression and
5  * decompression for PPP packets.
6  */
7
8  /*
9   * ==FILEVERSION 960122==
10   *
11   * This marker is used by the Linux installation script to determine
12   * whether an up-to-date version of this file is already installed.
13   */
14
15 /* zlib.h -- interface of the 'zlib' general purpose compression library
16   version 1.2.3, July 18th, 2005
17
18   Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
19
20   This software is provided 'as-is', without any express or implied
21   warranty.  In no event will the authors be held liable for any damages
22   arising from the use of this software.
23
24   Permission is granted to anyone to use this software for any purpose,
25   including commercial applications, and to alter it and redistribute it
26   freely, subject to the following restrictions:
27
28   1. The origin of this software must not be misrepresented; you must not
29      claim that you wrote the original software. If you use this software
30      in a product, an acknowledgment in the product documentation would be
31      appreciated but is not required.
32   2. Altered source versions must be plainly marked as such, and must not be
33      misrepresented as being the original software.
34   3. This notice may not be removed or altered from any source distribution.
35
36   Jean-loup Gailly        Mark Adler
37   jloup@gzip.org          madler@alumni.caltech.edu
38
39
40   The data format used by the zlib library is described by RFCs (Request for
41   Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
42   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
43 */
44
45 #ifndef ZLIB_H
46 #define ZLIB_H
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52 #define ZLIB_VERSION "1.2.3"
53 #define ZLIB_VERNUM 0x1230
54
55 /* #include "zconf.h" */        /* included directly here */
56 /* zconf.h -- configuration of the zlib compression library
57  * Copyright (C) 1995-2005 Jean-loup Gailly.
58  * For conditions of distribution and use, see copyright notice in zlib.h
59  */
60
61 /* Begin of new zconf.h */
62 /*
63  * If you *really* need a unique prefix for all types and library functions,
64  * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
65  */
66 #ifdef Z_PREFIX
67 #  define deflateInit_          z_deflateInit_
68 #  define deflate               z_deflate
69 #  define deflateEnd            z_deflateEnd
70 #  define inflateInit_          z_inflateInit_
71 #  define inflate               z_inflate
72 #  define inflateEnd            z_inflateEnd
73 #  define deflateInit2_         z_deflateInit2_
74 #  define deflateSetDictionary  z_deflateSetDictionary
75 #  define deflateCopy           z_deflateCopy
76 #  define deflateReset          z_deflateReset
77 #  define deflateParams         z_deflateParams
78 #  define deflateBound          z_deflateBound
79 #  define deflatePrime          z_deflatePrime
80 #  define inflateInit2_         z_inflateInit2_
81 #  define inflateSetDictionary  z_inflateSetDictionary
82 #  define inflateSync           z_inflateSync
83 #  define inflateSyncPoint      z_inflateSyncPoint
84 #  define inflateCopy           z_inflateCopy
85 #  define inflateReset          z_inflateReset
86 #  define inflateBack           z_inflateBack
87 #  define inflateBackEnd        z_inflateBackEnd
88 #  define compress              z_compress
89 #  define compress2             z_compress2
90 #  define compressBound         z_compressBound
91 #  define uncompress            z_uncompress
92 #  define adler32               z_adler32
93 #  define crc32                 z_crc32
94 #  define get_crc_table         z_get_crc_table
95 #  define zError                z_zError
96
97 #  define alloc_func            z_alloc_func
98 #  define free_func             z_free_func
99 #  define in_func               z_in_func
100 #  define out_func              z_out_func
101 #  define Byte                  z_Byte
102 #  define uInt                  z_uInt
103 #  define uLong                 z_uLong
104 #  define Bytef                 z_Bytef
105 #  define charf                 z_charf
106 #  define intf                  z_intf
107 #  define uIntf                 z_uIntf
108 #  define uLongf                z_uLongf
109 #  define voidpf                z_voidpf
110 #  define voidp                 z_voidp
111 #endif
112
113 #if defined(ZLIB_CONST) && !defined(z_const)
114 #  define z_const const
115 #else
116 #  define z_const
117 #endif
118
119 #if defined(__MSDOS__) && !defined(MSDOS)
120 #  define MSDOS
121 #endif
122 #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
123 #  define OS2
124 #endif
125 #if defined(_WINDOWS) && !defined(WINDOWS)
126 #  define WINDOWS
127 #endif
128 #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
129 #  ifndef WIN32
130 #    define WIN32
131 #  endif
132 #endif
133 #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
134 #  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
135 #    ifndef SYS16BIT
136 #      define SYS16BIT
137 #    endif
138 #  endif
139 #endif
140
141 /*
142  * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
143  * than 64k bytes at a time (needed on systems with 16-bit int).
144  */
145 #ifdef SYS16BIT
146 #  define MAXSEG_64K
147 #endif
148 #ifdef MSDOS
149 #  define UNALIGNED_OK
150 #endif
151
152 #ifdef __STDC_VERSION__
153 #  ifndef STDC
154 #    define STDC
155 #  endif
156 #  if __STDC_VERSION__ >= 199901L
157 #    ifndef STDC99
158 #      define STDC99
159 #    endif
160 #  endif
161 #endif
162 #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
163 #  define STDC
164 #endif
165 #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
166 #  define STDC
167 #endif
168 #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
169 #  define STDC
170 #endif
171 #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
172 #  define STDC
173 #endif
174
175 #if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
176 #  define STDC
177 #endif
178
179 #ifndef STDC
180 #  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
181 #    define const       /* note: need a more gentle solution here */
182 #  endif
183 #endif
184
185 /* Some Mac compilers merge all .h files incorrectly: */
186 #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
187 #  define NO_DUMMY_DECL
188 #endif
189
190 /* Maximum value for memLevel in deflateInit2 */
191 #ifndef MAX_MEM_LEVEL
192 #  ifdef MAXSEG_64K
193 #    define MAX_MEM_LEVEL 8
194 #  else
195 #    define MAX_MEM_LEVEL 9
196 #  endif
197 #endif
198
199 /* Maximum value for windowBits in deflateInit2 and inflateInit2.
200  * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
201  * created by gzip. (Files created by minigzip can still be extracted by
202  * gzip.)
203  */
204 #ifndef MAX_WBITS
205 #  define MAX_WBITS   15 /* 32K LZ77 window */
206 #endif
207
208 /* The memory requirements for deflate are (in bytes):
209             (1 << (windowBits+2)) +  (1 << (memLevel+9))
210  that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
211  plus a few kilobytes for small objects. For example, if you want to reduce
212  the default memory requirements from 256K to 128K, compile with
213      make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
214  Of course this will generally degrade compression (there's no free lunch).
215
216    The memory requirements for inflate are (in bytes) 1 << windowBits
217  that is, 32K for windowBits=15 (default value) plus a few kilobytes
218  for small objects.
219 */
220
221                         /* Type declarations */
222
223 #ifndef OF /* function prototypes */
224 #  ifdef STDC
225 #    define OF(args)  args
226 #  else
227 #    define OF(args)  ()
228 #  endif
229 #endif
230
231 /* The following definitions for FAR are needed only for MSDOS mixed
232  * model programming (small or medium model with some far allocations).
233  * This was tested only with MSC; for other MSDOS compilers you may have
234  * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
235  * just define FAR to be empty.
236  */
237 #ifdef SYS16BIT
238 #  if defined(M_I86SM) || defined(M_I86MM)
239      /* MSC small or medium model */
240 #    define SMALL_MEDIUM
241 #    ifdef _MSC_VER
242 #      define FAR _far
243 #    else
244 #      define FAR far
245 #    endif
246 #  endif
247 #  if (defined(__SMALL__) || defined(__MEDIUM__))
248      /* Turbo C small or medium model */
249 #    define SMALL_MEDIUM
250 #    ifdef __BORLANDC__
251 #      define FAR _far
252 #    else
253 #      define FAR far
254 #    endif
255 #  endif
256 #endif
257
258 #if defined(WINDOWS) || defined(WIN32)
259    /* If building or using zlib as a DLL, define ZLIB_DLL.
260     * This is not mandatory, but it offers a little performance increase.
261     */
262 #  ifdef ZLIB_DLL
263 #    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
264 #      ifdef ZLIB_INTERNAL
265 #        define ZEXTERN extern __declspec(dllexport)
266 #      else
267 #        define ZEXTERN extern __declspec(dllimport)
268 #      endif
269 #    endif
270 #  endif  /* ZLIB_DLL */
271    /* If building or using zlib with the WINAPI/WINAPIV calling convention,
272     * define ZLIB_WINAPI.
273     * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
274     */
275 #  ifdef ZLIB_WINAPI
276 #    ifdef FAR
277 #      undef FAR
278 #    endif
279 #    include <windows.h>
280      /* No need for _export, use ZLIB.DEF instead. */
281      /* For complete Windows compatibility, use WINAPI, not __stdcall. */
282 #    define ZEXPORT WINAPI
283 #    ifdef WIN32
284 #      define ZEXPORTVA WINAPIV
285 #    else
286 #      define ZEXPORTVA FAR CDECL
287 #    endif
288 #  endif
289 #endif
290
291 #if defined (__BEOS__)
292 #  ifdef ZLIB_DLL
293 #    ifdef ZLIB_INTERNAL
294 #      define ZEXPORT   __declspec(dllexport)
295 #      define ZEXPORTVA __declspec(dllexport)
296 #    else
297 #      define ZEXPORT   __declspec(dllimport)
298 #      define ZEXPORTVA __declspec(dllimport)
299 #    endif
300 #  endif
301 #endif
302
303 #ifndef ZEXTERN
304 #  define ZEXTERN extern
305 #endif
306 #ifndef ZEXPORT
307 #  define ZEXPORT
308 #endif
309 #ifndef ZEXPORTVA
310 #  define ZEXPORTVA
311 #endif
312
313 #ifndef FAR
314 #  define FAR
315 #endif
316
317 #if !defined(__MACTYPES__)
318 typedef unsigned char  Byte;  /* 8 bits */
319 #endif
320 typedef unsigned int   uInt;  /* 16 bits or more */
321 typedef unsigned long  uLong; /* 32 bits or more */
322
323 #ifdef SMALL_MEDIUM
324    /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
325 #  define Bytef Byte FAR
326 #else
327    typedef Byte  FAR Bytef;
328 #endif
329 typedef char  FAR charf;
330 typedef int   FAR intf;
331 typedef uInt  FAR uIntf;
332 typedef uLong FAR uLongf;
333
334 #ifdef STDC
335    typedef void const *voidpc;
336    typedef void FAR   *voidpf;
337    typedef void       *voidp;
338 #else
339    typedef Byte const *voidpc;
340    typedef Byte FAR   *voidpf;
341    typedef Byte       *voidp;
342 #endif
343
344 #  ifdef VMS
345 #    include <unixio.h>   /* for off_t */
346 #  endif
347 #  define z_off_t off_t
348 #ifndef SEEK_SET
349 #  define SEEK_SET        0       /* Seek from beginning of file.  */
350 #  define SEEK_CUR        1       /* Seek from current position.  */
351 #  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
352 #endif
353 #ifndef z_off_t
354 #  define z_off_t long
355 #endif
356
357 #if defined(__OS400__)
358 #  define NO_vsnprintf
359 #endif
360
361 #if defined(__MVS__)
362 #  define NO_vsnprintf
363 #  ifdef FAR
364 #    undef FAR
365 #  endif
366 #endif
367
368 /* MVS linker does not support external names larger than 8 bytes */
369 #if defined(__MVS__)
370 #   pragma map(deflateInit_,"DEIN")
371 #   pragma map(deflateInit2_,"DEIN2")
372 #   pragma map(deflateEnd,"DEEND")
373 #   pragma map(deflateBound,"DEBND")
374 #   pragma map(inflateInit_,"ININ")
375 #   pragma map(inflateInit2_,"ININ2")
376 #   pragma map(inflateEnd,"INEND")
377 #   pragma map(inflateSync,"INSY")
378 #   pragma map(inflateSetDictionary,"INSEDI")
379 #   pragma map(compressBound,"CMBND")
380 #   pragma map(inflate_table,"INTABL")
381 #   pragma map(inflate_fast,"INFA")
382 #   pragma map(inflate_copyright,"INCOPY")
383 #endif
384 /* End of new zconf.h */
385
386 /*
387      The 'zlib' compression library provides in-memory compression and
388   decompression functions, including integrity checks of the uncompressed
389   data.  This version of the library supports only one compression method
390   (deflation) but other algorithms will be added later and will have the same
391   stream interface.
392
393      Compression can be done in a single step if the buffers are large
394   enough (for example if an input file is mmap'ed), or can be done by
395   repeated calls of the compression function.  In the latter case, the
396   application must provide more input and/or consume the output
397   (providing more output space) before each call.
398
399      The compressed data format used by default by the in-memory functions is
400   the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
401   around a deflate stream, which is itself documented in RFC 1951.
402
403      The library also supports reading and writing files in gzip (.gz) format
404   with an interface similar to that of stdio using the functions that start
405   with "gz".  The gzip format is different from the zlib format.  gzip is a
406   gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
407
408      This library can optionally read and write gzip streams in memory as well.
409
410      The zlib format was designed to be compact and fast for use in memory
411   and on communications channels.  The gzip format was designed for single-
412   file compression on file systems, has a larger header than zlib to maintain
413   directory information, and uses a different, slower check method than zlib.
414
415      The library does not install any signal handler. The decoder checks
416   the consistency of the compressed data, so the library should never
417   crash even in case of corrupted input.
418 */
419
420 typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
421 typedef void   (*free_func)  OF((voidpf opaque, voidpf address, uInt size));
422 typedef void   (*cb_func)    OF((Bytef *buf, uInt len));
423
424 struct internal_state;
425
426 typedef struct z_stream_s {
427         Bytef   *next_in; /* next input byte */
428         uInt    avail_in; /* number of bytes available at next_in */
429         uLong   total_in; /* total nb of input bytes read so far */
430         Bytef   *next_out; /* next output byte should be put there */
431         uInt    avail_out; /* remaining free space at next_out */
432         uLong   total_out; /* total nb of bytes output so far */
433         char    *msg;   /* last error message, NULL if no error */
434         struct  internal_state FAR *state; /* not visible by applications */
435         alloc_func      zalloc; /* used to allocate the internal state */
436         free_func       zfree;  /* used to free the internal state */
437         voidpf  opaque; /* private data object passed to zalloc and zfree */
438         int     data_type;      /* best guess about the data type:
439                                         binary or text */
440         cb_func outcb;  /* called regularly just before blocks of output */
441         uLong   adler;  /* adler32 value of the uncompressed data */
442         uLong   reserved;       /* reserved for future use */
443 } z_stream;
444
445 typedef z_stream FAR *z_streamp;
446
447 /*
448      gzip header information passed to and from zlib routines.  See RFC 1952
449   for more details on the meanings of these fields.
450 */
451 typedef struct gz_header_s {
452         int     text;   /* true if compressed data believed to be text */
453         uLong   time;   /* modification time */
454         int     xflags; /* extra flags (not used when writing a gzip file) */
455         int     os;     /* operating system */
456         Bytef   *extra; /* pointer to extra field or Z_NULL if none */
457         uInt    extra_len; /* extra field length (valid if extra != Z_NULL) */
458         uInt    extra_max; /* space at extra (only when reading header) */
459         Bytef   *name; /* pointer to zero-terminated file name or Z_NULL */
460         uInt    name_max; /* space at name (only when reading header) */
461         Bytef   *comment; /* pointer to zero-terminated comment or Z_NULL */
462         uInt    comm_max; /* space at comment (only when reading header) */
463         int     hcrc; /* true if there was or will be a header crc */
464         int     done; /* true when done reading gzip header (not used
465                         when writing a gzip file) */
466 } gz_header;
467
468 typedef gz_header FAR *gz_headerp;
469
470                         /* constants */
471 #define Z_NO_FLUSH      0
472 #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
473 #define Z_SYNC_FLUSH    2
474 #define Z_FULL_FLUSH    3
475 #define Z_FINISH        4
476 #define Z_BLOCK         5
477 /* Allowed flush values; see deflate() and inflate() below for details */
478
479 #define Z_OK            0
480 #define Z_STREAM_END    1
481 #define Z_NEED_DICT     2
482 #define Z_ERRNO        (-1)
483 #define Z_STREAM_ERROR (-2)
484 #define Z_DATA_ERROR   (-3)
485 #define Z_MEM_ERROR    (-4)
486 #define Z_BUF_ERROR    (-5)
487 #define Z_VERSION_ERROR (-6)
488 /* Return codes for the compression/decompression functions. Negative
489  * values are errors, positive values are used for special but normal events.
490  */
491
492 #define Z_NO_COMPRESSION         0
493 #define Z_BEST_SPEED             1
494 #define Z_BEST_COMPRESSION       9
495 #define Z_DEFAULT_COMPRESSION  (-1)
496 /* compression levels */
497
498 #define Z_FILTERED            1
499 #define Z_HUFFMAN_ONLY        2
500 #define Z_RLE                 3
501 #define Z_FIXED               4
502 #define Z_DEFAULT_STRATEGY    0
503 /* compression strategy; see deflateInit2() below for details */
504
505 #define Z_BINARY   0
506 #define Z_TEXT     1
507 #define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */
508 #define Z_UNKNOWN  2
509 /* Possible values of the data_type field (though see inflate()) */
510
511 #define Z_DEFLATED   8
512 /* The deflate compression method (the only one supported in this version) */
513
514 #define Z_NULL  (void *)0  /* for initializing zalloc, zfree, opaque */
515
516                         /* basic functions */
517
518 /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
519    If the first character differs, the library code actually used is
520    not compatible with the zlib.h header file used by the application.
521    This check is automatically made by deflateInit and inflateInit.
522    */
523
524 ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
525 ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
526                         const char *version, int stream_size));
527 ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
528 ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
529                         int windowBits, int memLevel,
530                         int strategy, const char *version,
531                         int stream_size));
532 ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
533 ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
534                         const Bytef *dictionary,
535                         uInt  dictLength));
536 ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
537                         gz_headerp head));
538 ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
539                         int bits,
540                         int value));
541 ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
542                         int level,
543                         int strategy));
544 ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
545                         int good_length,
546                         int max_lazy,
547                         int nice_length,
548                         int max_chain));
549 ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
550                         uLong sourceLen));
551 ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
552                         z_streamp source));
553
554
555 ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
556                         const char *version, int stream_size));
557 ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
558 /*
559     inflate decompresses as much data as possible, and stops when the input
560   buffer becomes empty or the output buffer becomes full. It may introduce
561   some output latency (reading input without producing any output) except when
562   forced to flush.
563
564   The detailed semantics are as follows. inflate performs one or both of the
565   following actions:
566
567   - Decompress more input starting at next_in and update next_in and avail_in
568     accordingly. If not all input can be processed (because there is not
569     enough room in the output buffer), next_in is updated and processing
570     will resume at this point for the next call of inflate().
571
572   - Provide more output starting at next_out and update next_out and avail_out
573     accordingly.  inflate() provides as much output as possible, until there
574     is no more input data or no more space in the output buffer (see below
575     about the flush parameter).
576
577   Before the call of inflate(), the application should ensure that at least
578   one of the actions is possible, by providing more input and/or consuming
579   more output, and updating the next_* and avail_* values accordingly.
580   The application can consume the uncompressed output when it wants, for
581   example when the output buffer is full (avail_out == 0), or after each
582   call of inflate(). If inflate returns Z_OK and with zero avail_out, it
583   must be called again after making room in the output buffer because there
584   might be more output pending.
585
586     The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
587   Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
588   output as possible to the output buffer. Z_BLOCK requests that inflate() stop
589   if and when it gets to the next deflate block boundary. When decoding the
590   zlib or gzip format, this will cause inflate() to return immediately after
591   the header and before the first block. When doing a raw inflate, inflate()
592   will go ahead and process the first block, and will return when it gets to
593   the end of that block, or when it runs out of data.
594
595     The Z_BLOCK option assists in appending to or combining deflate streams.
596   Also to assist in this, on return inflate() will set strm->data_type to the
597   number of unused bits in the last byte taken from strm->next_in, plus 64
598   if inflate() is currently decoding the last block in the deflate stream,
599   plus 128 if inflate() returned immediately after decoding an end-of-block
600   code or decoding the complete header up to just before the first byte of the
601   deflate stream. The end-of-block will not be indicated until all of the
602   uncompressed data from that block has been written to strm->next_out.  The
603   number of unused bits may in general be greater than seven, except when
604   bit 7 of data_type is set, in which case the number of unused bits will be
605   less than eight.
606
607     inflate() should normally be called until it returns Z_STREAM_END or an
608   error. However if all decompression is to be performed in a single step
609   (a single call of inflate), the parameter flush should be set to
610   Z_FINISH. In this case all pending input is processed and all pending
611   output is flushed; avail_out must be large enough to hold all the
612   uncompressed data. (The size of the uncompressed data may have been saved
613   by the compressor for this purpose.) The next operation on this stream must
614   be inflateEnd to deallocate the decompression state. The use of Z_FINISH
615   is never required, but can be used to inform inflate that a faster approach
616   may be used for the single inflate() call.
617
618      In this implementation, inflate() always flushes as much output as
619   possible to the output buffer, and always uses the faster approach on the
620   first call. So the only effect of the flush parameter in this implementation
621   is on the return value of inflate(), as noted below, or when it returns early
622   because Z_BLOCK is used.
623
624      If a preset dictionary is needed after this call (see inflateSetDictionary
625   below), inflate sets strm->adler to the adler32 checksum of the dictionary
626   chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
627   strm->adler to the adler32 checksum of all output produced so far (that is,
628   total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
629   below. At the end of the stream, inflate() checks that its computed adler32
630   checksum is equal to that saved by the compressor and returns Z_STREAM_END
631   only if the checksum is correct.
632
633     inflate() will decompress and check either zlib-wrapped or gzip-wrapped
634   deflate data.  The header type is detected automatically.  Any information
635   contained in the gzip header is not retained, so applications that need that
636   information should instead use raw inflate, see inflateInit2() below, or
637   inflateBack() and perform their own processing of the gzip header and
638   trailer.
639
640     inflate() returns Z_OK if some progress has been made (more input processed
641   or more output produced), Z_STREAM_END if the end of the compressed data has
642   been reached and all uncompressed output has been produced, Z_NEED_DICT if a
643   preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
644   corrupted (input stream not conforming to the zlib format or incorrect check
645   value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
646   if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
647   Z_BUF_ERROR if no progress is possible or if there was not enough room in the
648   output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
649   inflate() can be called again with more input and more output space to
650   continue decompressing. If Z_DATA_ERROR is returned, the application may then
651   call inflateSync() to look for a good compression block if a partial recovery
652   of the data is desired.
653 */
654
655 ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
656 /*
657      All dynamically allocated data structures for this stream are freed.
658    This function discards any unprocessed input and does not flush any
659    pending output.
660
661      inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
662    was inconsistent. In the error case, msg may be set but then points to a
663    static string (which must not be deallocated).
664 */
665
666                         /* Advanced functions */
667
668 ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
669
670                         /* utility functions */
671
672 /*
673      The following utility functions are implemented on top of the
674    basic stream-oriented functions. To simplify the interface, some
675    default options are assumed (compression level and memory usage,
676    standard memory allocation functions). The source code of these
677    utility functions can easily be modified if you need special options.
678 */
679
680 ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
681 /*
682      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
683    return the updated checksum. If buf is NULL, this function returns
684    the required initial value for the checksum.
685    An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
686    much faster. Usage example:
687
688      uLong adler = adler32(0L, Z_NULL, 0);
689
690      while (read_buffer(buffer, length) != EOF) {
691        adler = adler32(adler, buffer, length);
692      }
693      if (adler != original_adler) error();
694 */
695
696 /*
697      Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1
698    and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
699    each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of
700    seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
701 */
702
703 ZEXTERN  uInt ZEXPORT crc32  OF((uInt crc, const Bytef *buf, uInt len));
704 /*
705      Update a running CRC-32 with the bytes buf[0..len-1] and return the
706    updated CRC-32. If buf is NULL, this function returns the required initial
707    value for the for the crc. Pre- and post-conditioning (one's complement) is
708    performed within this function so it shouldn't be done by the application.
709    Usage example:
710
711      uLong crc = crc32(0L, Z_NULL, 0);
712
713      while (read_buffer(buffer, length) != EOF) {
714        crc = crc32(crc, buffer, length);
715      }
716      if (crc != original_crc) error();
717 */
718
719 ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
720                                    const Bytef *source, uLong sourceLen));
721 /*
722      Decompresses the source buffer into the destination buffer.  sourceLen is
723    the byte length of the source buffer.  Upon entry, destLen is the total size
724    of the destination buffer, which must be large enough to hold the entire
725    uncompressed data.  (The size of the uncompressed data must have been saved
726    previously by the compressor and transmitted to the decompressor by some
727    mechanism outside the scope of this compression library.) Upon exit, destLen
728    is the actual size of the uncompressed data.
729
730      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
731    enough memory, Z_BUF_ERROR if there was not enough room in the output
732    buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.  In
733    the case where there is not enough room, uncompress() will fill the output
734    buffer with the uncompressed data up to that point.
735 */
736
737 ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen,
738                                     const Bytef *source, uLong *sourceLen));
739 /*
740      Same as uncompress, except that sourceLen is a pointer, where the
741    length of the source is *sourceLen.  On return, *sourceLen is the number of
742    source bytes consumed.
743 */
744
745 ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
746                                       const char *version, int stream_size));
747 #define inflateInit(strm) \
748         inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
749 #define inflateInit2(strm, windowBits) \
750         inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
751
752 #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
753         struct internal_state {int dummy;}; /* hack for buggy compilers */
754 #endif
755
756 extern void *gzalloc(void *, unsigned, unsigned);
757 extern void gzfree(void *, void *, unsigned);
758
759 #ifdef __cplusplus
760 }
761 #endif
762
763 #endif /* ZLIB_H */