Home | History | Annotate | Line # | Download | only in net
zlib.h revision 1.12
      1  1.12  christos /* $NetBSD: zlib.h,v 1.12 2006/01/14 20:17:12 christos Exp $ */
      2   1.1    paulus 
      3   1.1    paulus /* zlib.h -- interface of the 'zlib' general purpose compression library
      4   1.6      fvdl   version 1.1.4, March 11th, 2002
      5   1.1    paulus 
      6   1.6      fvdl   Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler
      7   1.1    paulus 
      8   1.1    paulus   This software is provided 'as-is', without any express or implied
      9   1.1    paulus   warranty.  In no event will the authors be held liable for any damages
     10   1.1    paulus   arising from the use of this software.
     11   1.1    paulus 
     12   1.1    paulus   Permission is granted to anyone to use this software for any purpose,
     13   1.1    paulus   including commercial applications, and to alter it and redistribute it
     14   1.1    paulus   freely, subject to the following restrictions:
     15   1.1    paulus 
     16   1.1    paulus   1. The origin of this software must not be misrepresented; you must not
     17   1.1    paulus      claim that you wrote the original software. If you use this software
     18   1.1    paulus      in a product, an acknowledgment in the product documentation would be
     19   1.1    paulus      appreciated but is not required.
     20   1.1    paulus   2. Altered source versions must be plainly marked as such, and must not be
     21   1.1    paulus      misrepresented as being the original software.
     22   1.1    paulus   3. This notice may not be removed or altered from any source distribution.
     23   1.1    paulus 
     24   1.1    paulus   Jean-loup Gailly        Mark Adler
     25   1.6      fvdl   jloup (at) gzip.org          madler (at) alumni.caltech.edu
     26   1.4  christos 
     27   1.4  christos 
     28   1.4  christos   The data format used by the zlib library is described by RFCs (Request for
     29   1.4  christos   Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
     30   1.4  christos   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
     31   1.4  christos */
     32   1.1    paulus 
     33  1.10      elad #ifndef _NET_ZLIB_H_
     34  1.10      elad #define _NET_ZLIB_H_
     35   1.1    paulus 
     36   1.6      fvdl #ifdef __NetBSD__
     37   1.6      fvdl #include <sys/cdefs.h>
     38   1.4  christos #endif
     39   1.4  christos 
     40   1.4  christos /* +++ zconf.h */
     41   1.1    paulus /* zconf.h -- configuration of the zlib compression library
     42   1.6      fvdl  * Copyright (C) 1995-2002 Jean-loup Gailly.
     43   1.8     perry  * For conditions of distribution and use, see copyright notice in zlib.h
     44   1.1    paulus  */
     45   1.1    paulus 
     46  1.12  christos /* @(#) $Id: zlib.h,v 1.12 2006/01/14 20:17:12 christos Exp $ */
     47   1.4  christos 
     48  1.12  christos #ifndef ZCONF_H
     49  1.12  christos #define ZCONF_H
     50   1.1    paulus 
     51   1.1    paulus /*
     52   1.6      fvdl  * Warning:  This file pollutes the user's namespace with:
     53   1.6      fvdl  * 	Byte Bytef EXPORT FAR OF STDC
     54   1.6      fvdl  *  charf intf uInt uIntf uLong uLonf
     55   1.6      fvdl  * Programs using this library appear to expect those...
     56   1.6      fvdl  */
     57   1.6      fvdl 
     58   1.6      fvdl #include <sys/types.h>
     59   1.6      fvdl 
     60   1.6      fvdl /*
     61   1.4  christos  * If you *really* need a unique prefix for all types and library functions,
     62   1.4  christos  * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
     63   1.1    paulus  */
     64   1.4  christos #ifdef Z_PREFIX
     65   1.4  christos #  define deflateInit_	z_deflateInit_
     66   1.4  christos #  define deflate	z_deflate
     67   1.4  christos #  define deflateEnd	z_deflateEnd
     68   1.4  christos #  define inflateInit_ 	z_inflateInit_
     69   1.4  christos #  define inflate	z_inflate
     70   1.4  christos #  define inflateEnd	z_inflateEnd
     71   1.4  christos #  define deflateInit2_	z_deflateInit2_
     72   1.4  christos #  define deflateSetDictionary z_deflateSetDictionary
     73   1.4  christos #  define deflateCopy	z_deflateCopy
     74   1.4  christos #  define deflateReset	z_deflateReset
     75   1.4  christos #  define deflateParams	z_deflateParams
     76   1.4  christos #  define inflateInit2_	z_inflateInit2_
     77   1.4  christos #  define inflateSetDictionary z_inflateSetDictionary
     78   1.4  christos #  define inflateSync	z_inflateSync
     79   1.6      fvdl #  define inflateSyncPoint z_inflateSyncPoint
     80   1.4  christos #  define inflateReset	z_inflateReset
     81   1.4  christos #  define compress	z_compress
     82   1.6      fvdl #  define compress2	z_compress2
     83   1.4  christos #  define uncompress	z_uncompress
     84   1.4  christos #  define adler32	z_adler32
     85   1.4  christos #  define crc32		z_crc32
     86   1.4  christos #  define get_crc_table z_get_crc_table
     87   1.4  christos 
     88   1.4  christos #  define Byte		z_Byte
     89   1.4  christos #  define uInt		z_uInt
     90   1.4  christos #  define uLong		z_uLong
     91   1.4  christos #  define Bytef	        z_Bytef
     92   1.4  christos #  define charf		z_charf
     93   1.4  christos #  define intf		z_intf
     94   1.4  christos #  define uIntf		z_uIntf
     95   1.4  christos #  define uLongf	z_uLongf
     96   1.4  christos #  define voidpf	z_voidpf
     97   1.4  christos #  define voidp		z_voidp
     98   1.4  christos #endif
     99   1.4  christos 
    100   1.6      fvdl #ifndef __32BIT__
    101   1.6      fvdl /* Don't be alarmed; this just means we have at least 32-bits */
    102   1.6      fvdl #  define __32BIT__
    103   1.4  christos #endif
    104   1.1    paulus 
    105   1.1    paulus /*
    106   1.1    paulus  * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
    107   1.1    paulus  * than 64k bytes at a time (needed on systems with 16-bit int).
    108   1.1    paulus  */
    109   1.4  christos #if defined(MSDOS) && !defined(__32BIT__)
    110   1.4  christos #  define MAXSEG_64K
    111   1.4  christos #endif
    112   1.6      fvdl 
    113   1.6      fvdl #if 0
    114   1.6      fvdl /* XXX: Are there machines where we should define this?  m68k? */
    115   1.4  christos #  define UNALIGNED_OK
    116   1.4  christos #endif
    117   1.4  christos 
    118   1.6      fvdl #if (defined(__STDC__) || defined(__cplusplus)) && !defined(STDC)
    119   1.6      fvdl /* XXX: Look out - this is used in zutil.h and elsewhere... */
    120   1.4  christos #  define STDC
    121   1.4  christos #endif
    122   1.6      fvdl #if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__)
    123   1.6      fvdl #  ifndef STDC
    124   1.6      fvdl #    define STDC
    125   1.6      fvdl #  endif
    126   1.4  christos #endif
    127   1.1    paulus 
    128   1.1    paulus #ifndef STDC
    129   1.6      fvdl #  ifndef const
    130   1.4  christos #    define const
    131   1.1    paulus #  endif
    132   1.1    paulus #endif
    133   1.1    paulus 
    134   1.4  christos /* Some Mac compilers merge all .h files incorrectly: */
    135   1.4  christos #if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__)
    136   1.4  christos #  define NO_DUMMY_DECL
    137   1.1    paulus #endif
    138   1.1    paulus 
    139   1.6      fvdl /* Old Borland C incorrectly complains about missing returns: */
    140   1.6      fvdl #if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
    141   1.6      fvdl #  define NEED_DUMMY_RETURN
    142   1.6      fvdl #endif
    143   1.6      fvdl 
    144   1.6      fvdl 
    145   1.1    paulus /* Maximum value for memLevel in deflateInit2 */
    146   1.1    paulus #ifndef MAX_MEM_LEVEL
    147   1.1    paulus #  ifdef MAXSEG_64K
    148   1.1    paulus #    define MAX_MEM_LEVEL 8
    149   1.1    paulus #  else
    150   1.1    paulus #    define MAX_MEM_LEVEL 9
    151   1.1    paulus #  endif
    152   1.1    paulus #endif
    153   1.1    paulus 
    154   1.6      fvdl /* Maximum value for windowBits in deflateInit2 and inflateInit2.
    155   1.6      fvdl  * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
    156   1.6      fvdl  * created by gzip. (Files created by minigzip can still be extracted by
    157   1.6      fvdl  * gzip.)
    158   1.6      fvdl  */
    159   1.1    paulus #ifndef MAX_WBITS
    160   1.1    paulus #  define MAX_WBITS   15 /* 32K LZ77 window */
    161   1.1    paulus #endif
    162   1.1    paulus 
    163   1.1    paulus /* The memory requirements for deflate are (in bytes):
    164   1.6      fvdl             (1 << (windowBits+2)) +  (1 << (memLevel+9))
    165   1.1    paulus  that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
    166   1.1    paulus  plus a few kilobytes for small objects. For example, if you want to reduce
    167   1.1    paulus  the default memory requirements from 256K to 128K, compile with
    168   1.1    paulus      make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
    169   1.1    paulus  Of course this will generally degrade compression (there's no free lunch).
    170   1.1    paulus 
    171   1.1    paulus    The memory requirements for inflate are (in bytes) 1 << windowBits
    172   1.1    paulus  that is, 32K for windowBits=15 (default value) plus a few kilobytes
    173   1.1    paulus  for small objects.
    174   1.1    paulus */
    175   1.1    paulus 
    176   1.1    paulus                         /* Type declarations */
    177   1.1    paulus 
    178   1.6      fvdl #ifndef __P /* function prototypes */
    179   1.1    paulus #  ifdef STDC
    180   1.6      fvdl #    define __P(args)  args
    181   1.1    paulus #  else
    182   1.6      fvdl #    define __P(args)  ()
    183   1.1    paulus #  endif
    184   1.1    paulus #endif
    185   1.1    paulus 
    186   1.4  christos /* The following definitions for FAR are needed only for MSDOS mixed
    187   1.4  christos  * model programming (small or medium model with some far allocations).
    188   1.4  christos  * This was tested only with MSC; for other MSDOS compilers you may have
    189   1.4  christos  * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
    190   1.4  christos  * just define FAR to be empty.
    191   1.4  christos  */
    192   1.4  christos #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__)
    193   1.4  christos    /* MSC small or medium model */
    194   1.4  christos #  define SMALL_MEDIUM
    195   1.4  christos #  ifdef _MSC_VER
    196   1.6      fvdl #    define FAR _far
    197   1.4  christos #  else
    198   1.4  christos #    define FAR far
    199   1.4  christos #  endif
    200   1.4  christos #endif
    201   1.4  christos #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
    202   1.4  christos #  ifndef __32BIT__
    203   1.4  christos #    define SMALL_MEDIUM
    204   1.6      fvdl #    define FAR _far
    205   1.6      fvdl #  endif
    206   1.6      fvdl #endif
    207   1.6      fvdl 
    208   1.6      fvdl /* Compile with -DZLIB_DLL for Windows DLL support */
    209   1.6      fvdl #if defined(ZLIB_DLL)
    210   1.6      fvdl #  if defined(_WINDOWS) || defined(WINDOWS)
    211   1.6      fvdl #    ifdef FAR
    212   1.6      fvdl #      undef FAR
    213   1.6      fvdl #    endif
    214   1.6      fvdl #    include <windows.h>
    215   1.6      fvdl #    define ZEXPORT  WINAPI
    216   1.6      fvdl #    ifdef WIN32
    217   1.6      fvdl #      define ZEXPORTVA  WINAPIV
    218   1.6      fvdl #    else
    219   1.6      fvdl #      define ZEXPORTVA  FAR _cdecl _export
    220   1.6      fvdl #    endif
    221   1.6      fvdl #  endif
    222   1.6      fvdl #  if defined (__BORLANDC__)
    223   1.6      fvdl #    if (__BORLANDC__ >= 0x0500) && defined (WIN32)
    224   1.6      fvdl #      include <windows.h>
    225   1.6      fvdl #      define ZEXPORT __declspec(dllexport) WINAPI
    226   1.6      fvdl #      define ZEXPORTRVA __declspec(dllexport) WINAPIV
    227   1.6      fvdl #    else
    228   1.6      fvdl #      if defined (_Windows) && defined (__DLL__)
    229   1.6      fvdl #        define ZEXPORT _export
    230   1.6      fvdl #        define ZEXPORTVA _export
    231   1.6      fvdl #      endif
    232   1.6      fvdl #    endif
    233   1.4  christos #  endif
    234   1.4  christos #endif
    235   1.6      fvdl 
    236   1.6      fvdl #if defined (__BEOS__)
    237   1.6      fvdl #  if defined (ZLIB_DLL)
    238   1.6      fvdl #    define ZEXTERN extern __declspec(dllexport)
    239   1.6      fvdl #  else
    240   1.6      fvdl #    define ZEXTERN extern __declspec(dllimport)
    241   1.6      fvdl #  endif
    242   1.6      fvdl #endif
    243   1.6      fvdl 
    244   1.6      fvdl #ifndef ZEXPORT
    245   1.6      fvdl #  define ZEXPORT
    246   1.6      fvdl #endif
    247   1.6      fvdl #ifndef ZEXPORTVA
    248   1.6      fvdl #  define ZEXPORTVA
    249   1.6      fvdl #endif
    250   1.6      fvdl #ifndef ZEXTERN
    251   1.6      fvdl #  define ZEXTERN extern
    252   1.6      fvdl #endif
    253   1.6      fvdl 
    254   1.4  christos #ifndef FAR
    255   1.4  christos #   define FAR
    256   1.4  christos #endif
    257   1.4  christos 
    258   1.6      fvdl #if !defined(MACOS) && !defined(TARGET_OS_MAC)
    259   1.1    paulus typedef unsigned char  Byte;  /* 8 bits */
    260   1.6      fvdl #endif
    261   1.1    paulus typedef unsigned int   uInt;  /* 16 bits or more */
    262   1.1    paulus typedef unsigned long  uLong; /* 32 bits or more */
    263   1.1    paulus 
    264   1.6      fvdl #ifdef SMALL_MEDIUM
    265   1.6      fvdl    /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
    266   1.4  christos #  define Bytef Byte FAR
    267   1.4  christos #else
    268   1.4  christos    typedef Byte  FAR Bytef;
    269   1.4  christos #endif
    270   1.4  christos typedef char  FAR charf;
    271   1.4  christos typedef int   FAR intf;
    272   1.4  christos typedef uInt  FAR uIntf;
    273   1.1    paulus typedef uLong FAR uLongf;
    274   1.1    paulus 
    275   1.1    paulus #ifdef STDC
    276   1.1    paulus    typedef void FAR *voidpf;
    277   1.1    paulus    typedef void     *voidp;
    278   1.1    paulus #else
    279   1.1    paulus    typedef Byte FAR *voidpf;
    280   1.1    paulus    typedef Byte     *voidp;
    281   1.1    paulus #endif
    282   1.1    paulus 
    283   1.6      fvdl #if (defined(HAVE_UNISTD_H) || defined(__NetBSD__)) && !defined(_KERNEL)
    284   1.6      fvdl #  include <sys/types.h> /* for off_t */
    285   1.6      fvdl #  include <unistd.h>    /* for SEEK_* and off_t */
    286   1.6      fvdl #  define z_off_t  off_t
    287   1.6      fvdl #endif
    288   1.6      fvdl #ifndef SEEK_SET
    289   1.6      fvdl #  define SEEK_SET        0       /* Seek from beginning of file.  */
    290   1.6      fvdl #  define SEEK_CUR        1       /* Seek from current position.  */
    291   1.6      fvdl #  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
    292   1.6      fvdl #endif
    293   1.6      fvdl #ifndef z_off_t
    294   1.6      fvdl #  define  z_off_t long
    295   1.6      fvdl #endif
    296   1.6      fvdl 
    297   1.6      fvdl /* MVS linker does not support external names larger than 8 bytes */
    298   1.6      fvdl #if defined(__MVS__)
    299   1.6      fvdl #   pragma map(deflateInit_,"DEIN")
    300   1.6      fvdl #   pragma map(deflateInit2_,"DEIN2")
    301   1.6      fvdl #   pragma map(deflateEnd,"DEEND")
    302   1.6      fvdl #   pragma map(inflateInit_,"ININ")
    303   1.6      fvdl #   pragma map(inflateInit2_,"ININ2")
    304   1.6      fvdl #   pragma map(inflateEnd,"INEND")
    305   1.6      fvdl #   pragma map(inflateSync,"INSY")
    306   1.6      fvdl #   pragma map(inflateSetDictionary,"INSEDI")
    307   1.6      fvdl #   pragma map(inflate_blocks,"INBL")
    308   1.6      fvdl #   pragma map(inflate_blocks_new,"INBLNE")
    309   1.6      fvdl #   pragma map(inflate_blocks_free,"INBLFR")
    310   1.6      fvdl #   pragma map(inflate_blocks_reset,"INBLRE")
    311   1.6      fvdl #   pragma map(inflate_codes_free,"INCOFR")
    312   1.6      fvdl #   pragma map(inflate_codes,"INCO")
    313   1.6      fvdl #   pragma map(inflate_fast,"INFA")
    314   1.6      fvdl #   pragma map(inflate_flush,"INFLU")
    315   1.6      fvdl #   pragma map(inflate_mask,"INMA")
    316   1.6      fvdl #   pragma map(inflate_set_dictionary,"INSEDI2")
    317   1.6      fvdl #   pragma map(inflate_copyright,"INCOPY")
    318   1.6      fvdl #   pragma map(inflate_trees_bits,"INTRBI")
    319   1.6      fvdl #   pragma map(inflate_trees_dynamic,"INTRDY")
    320   1.6      fvdl #   pragma map(inflate_trees_fixed,"INTRFI")
    321   1.6      fvdl #   pragma map(inflate_trees_free,"INTRFR")
    322   1.4  christos #endif
    323   1.4  christos 
    324  1.12  christos #endif /* !ZCONF_H */
    325   1.4  christos /* --- zconf.h */
    326   1.4  christos 
    327  1.12  christos #ifndef ZLIB_H
    328  1.12  christos #define ZLIB_H
    329   1.6      fvdl #ifdef __cplusplus
    330   1.6      fvdl extern "C" {
    331   1.6      fvdl #endif
    332   1.6      fvdl 
    333   1.6      fvdl #define ZLIB_VERSION "1.1.4"
    334   1.1    paulus 
    335   1.8     perry /*
    336   1.1    paulus      The 'zlib' compression library provides in-memory compression and
    337   1.1    paulus   decompression functions, including integrity checks of the uncompressed
    338   1.1    paulus   data.  This version of the library supports only one compression method
    339   1.6      fvdl   (deflation) but other algorithms will be added later and will have the same
    340   1.1    paulus   stream interface.
    341   1.1    paulus 
    342   1.1    paulus      Compression can be done in a single step if the buffers are large
    343   1.1    paulus   enough (for example if an input file is mmap'ed), or can be done by
    344   1.1    paulus   repeated calls of the compression function.  In the latter case, the
    345   1.1    paulus   application must provide more input and/or consume the output
    346   1.1    paulus   (providing more output space) before each call.
    347   1.4  christos 
    348   1.6      fvdl      The library also supports reading and writing files in gzip (.gz) format
    349   1.6      fvdl   with an interface similar to that of stdio.
    350   1.6      fvdl 
    351   1.6      fvdl      The library does not install any signal handler. The decoder checks
    352   1.6      fvdl   the consistency of the compressed data, so the library should never
    353   1.6      fvdl   crash even in case of corrupted input.
    354   1.1    paulus */
    355   1.1    paulus 
    356   1.7    itojun typedef voidpf (*alloc_func) __P((voidpf, uInt, uInt));
    357   1.7    itojun typedef void   (*free_func)  __P((voidpf, voidpf));
    358   1.1    paulus 
    359   1.1    paulus struct internal_state;
    360   1.1    paulus 
    361   1.1    paulus typedef struct z_stream_s {
    362   1.1    paulus     Bytef    *next_in;  /* next input byte */
    363   1.1    paulus     uInt     avail_in;  /* number of bytes available at next_in */
    364   1.1    paulus     uLong    total_in;  /* total nb of input bytes read so far */
    365   1.1    paulus 
    366   1.1    paulus     Bytef    *next_out; /* next output byte should be put there */
    367   1.1    paulus     uInt     avail_out; /* remaining free space at next_out */
    368   1.1    paulus     uLong    total_out; /* total nb of bytes output so far */
    369   1.1    paulus 
    370   1.9  christos     const char *msg;      /* last error message, NULL if no error */
    371   1.1    paulus     struct internal_state FAR *state; /* not visible by applications */
    372   1.1    paulus 
    373   1.1    paulus     alloc_func zalloc;  /* used to allocate the internal state */
    374   1.1    paulus     free_func  zfree;   /* used to free the internal state */
    375   1.4  christos     voidpf     opaque;  /* private data object passed to zalloc and zfree */
    376   1.1    paulus 
    377   1.4  christos     int     data_type;  /* best guess about the data type: ascii or binary */
    378   1.4  christos     uLong   adler;      /* adler32 value of the uncompressed data */
    379   1.4  christos     uLong   reserved;   /* reserved for future use */
    380   1.4  christos } z_stream;
    381   1.1    paulus 
    382   1.4  christos typedef z_stream FAR *z_streamp;
    383   1.1    paulus 
    384   1.1    paulus /*
    385   1.1    paulus    The application must update next_in and avail_in when avail_in has
    386   1.1    paulus    dropped to zero. It must update next_out and avail_out when avail_out
    387   1.1    paulus    has dropped to zero. The application must initialize zalloc, zfree and
    388   1.1    paulus    opaque before calling the init function. All other fields are set by the
    389   1.1    paulus    compression library and must not be updated by the application.
    390   1.1    paulus 
    391   1.1    paulus    The opaque value provided by the application will be passed as the first
    392   1.1    paulus    parameter for calls of zalloc and zfree. This can be useful for custom
    393   1.1    paulus    memory management. The compression library attaches no meaning to the
    394   1.1    paulus    opaque value.
    395   1.1    paulus 
    396   1.1    paulus    zalloc must return Z_NULL if there is not enough memory for the object.
    397   1.6      fvdl    If zlib is used in a multi-threaded application, zalloc and zfree must be
    398   1.6      fvdl    thread safe.
    399   1.6      fvdl 
    400   1.1    paulus    On 16-bit systems, the functions zalloc and zfree must be able to allocate
    401   1.1    paulus    exactly 65536 bytes, but will not be required to allocate more than this
    402   1.1    paulus    if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
    403   1.1    paulus    pointers returned by zalloc for objects of exactly 65536 bytes *must*
    404   1.1    paulus    have their offset normalized to zero. The default allocation function
    405   1.1    paulus    provided by this library ensures this (see zutil.c). To reduce memory
    406   1.1    paulus    requirements and avoid any allocation of 64K objects, at the expense of
    407   1.1    paulus    compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
    408   1.1    paulus 
    409   1.1    paulus    The fields total_in and total_out can be used for statistics or
    410   1.1    paulus    progress reports. After compression, total_in holds the total size of
    411   1.1    paulus    the uncompressed data and may be saved for use in the decompressor
    412   1.1    paulus    (particularly if the decompressor wants to decompress everything in
    413   1.1    paulus    a single step).
    414   1.1    paulus */
    415   1.1    paulus 
    416   1.1    paulus                         /* constants */
    417   1.1    paulus 
    418   1.1    paulus #define Z_NO_FLUSH      0
    419   1.6      fvdl #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
    420   1.6      fvdl #define Z_PACKET_FLUSH  2
    421   1.4  christos #define Z_SYNC_FLUSH    3
    422   1.4  christos #define Z_FULL_FLUSH    4
    423   1.4  christos #define Z_FINISH        5
    424   1.4  christos /* Allowed flush values; see deflate() below for details */
    425   1.1    paulus 
    426   1.1    paulus #define Z_OK            0
    427   1.1    paulus #define Z_STREAM_END    1
    428   1.4  christos #define Z_NEED_DICT     2
    429   1.1    paulus #define Z_ERRNO        (-1)
    430   1.1    paulus #define Z_STREAM_ERROR (-2)
    431   1.1    paulus #define Z_DATA_ERROR   (-3)
    432   1.1    paulus #define Z_MEM_ERROR    (-4)
    433   1.1    paulus #define Z_BUF_ERROR    (-5)
    434   1.4  christos #define Z_VERSION_ERROR (-6)
    435   1.4  christos /* Return codes for the compression/decompression functions. Negative
    436   1.4  christos  * values are errors, positive values are used for special but normal events.
    437   1.4  christos  */
    438   1.1    paulus 
    439   1.4  christos #define Z_NO_COMPRESSION         0
    440   1.1    paulus #define Z_BEST_SPEED             1
    441   1.1    paulus #define Z_BEST_COMPRESSION       9
    442   1.1    paulus #define Z_DEFAULT_COMPRESSION  (-1)
    443   1.1    paulus /* compression levels */
    444   1.1    paulus 
    445   1.1    paulus #define Z_FILTERED            1
    446   1.1    paulus #define Z_HUFFMAN_ONLY        2
    447   1.1    paulus #define Z_DEFAULT_STRATEGY    0
    448   1.4  christos /* compression strategy; see deflateInit2() below for details */
    449   1.1    paulus 
    450   1.1    paulus #define Z_BINARY   0
    451   1.1    paulus #define Z_ASCII    1
    452   1.1    paulus #define Z_UNKNOWN  2
    453   1.4  christos /* Possible values of the data_type field */
    454   1.4  christos 
    455   1.4  christos #define Z_DEFLATED   8
    456   1.4  christos /* The deflate compression method (the only one supported in this version) */
    457   1.1    paulus 
    458   1.1    paulus #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
    459   1.1    paulus 
    460   1.4  christos #define zlib_version zlibVersion()
    461   1.4  christos /* for compatibility with versions < 1.0.2 */
    462   1.4  christos 
    463   1.4  christos                         /* basic functions */
    464   1.4  christos 
    465   1.6      fvdl ZEXTERN const char * ZEXPORT zlibVersion __P((void));
    466   1.4  christos /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
    467   1.1    paulus    If the first character differs, the library code actually used is
    468   1.1    paulus    not compatible with the zlib.h header file used by the application.
    469   1.4  christos    This check is automatically made by deflateInit and inflateInit.
    470   1.1    paulus  */
    471   1.1    paulus 
    472   1.8     perry /*
    473   1.7    itojun ZEXTERN int ZEXPORT deflateInit __P((z_streamp, int));
    474   1.1    paulus 
    475   1.1    paulus      Initializes the internal stream state for compression. The fields
    476   1.1    paulus    zalloc, zfree and opaque must be initialized before by the caller.
    477   1.1    paulus    If zalloc and zfree are set to Z_NULL, deflateInit updates them to
    478   1.1    paulus    use default allocation functions.
    479   1.1    paulus 
    480   1.4  christos      The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
    481   1.4  christos    1 gives best speed, 9 gives best compression, 0 gives no compression at
    482   1.4  christos    all (the input data is simply copied a block at a time).
    483   1.4  christos    Z_DEFAULT_COMPRESSION requests a default compromise between speed and
    484   1.4  christos    compression (currently equivalent to level 6).
    485   1.1    paulus 
    486   1.1    paulus      deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
    487   1.4  christos    enough memory, Z_STREAM_ERROR if level is not a valid compression level,
    488   1.4  christos    Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
    489   1.4  christos    with the version assumed by the caller (ZLIB_VERSION).
    490   1.1    paulus    msg is set to null if there is no error message.  deflateInit does not
    491   1.1    paulus    perform any compression: this will be done by deflate().
    492   1.1    paulus */
    493   1.1    paulus 
    494   1.1    paulus 
    495   1.7    itojun ZEXTERN int ZEXPORT deflate __P((z_streamp, int));
    496   1.1    paulus /*
    497   1.6      fvdl     deflate compresses as much data as possible, and stops when the input
    498   1.6      fvdl   buffer becomes empty or the output buffer becomes full. It may introduce some
    499   1.6      fvdl   output latency (reading input without producing any output) except when
    500   1.6      fvdl   forced to flush.
    501   1.6      fvdl 
    502   1.6      fvdl     The detailed semantics are as follows. deflate performs one or both of the
    503   1.6      fvdl   following actions:
    504   1.1    paulus 
    505   1.1    paulus   - Compress more input starting at next_in and update next_in and avail_in
    506   1.1    paulus     accordingly. If not all input can be processed (because there is not
    507   1.1    paulus     enough room in the output buffer), next_in and avail_in are updated and
    508   1.1    paulus     processing will resume at this point for the next call of deflate().
    509   1.1    paulus 
    510   1.1    paulus   - Provide more output starting at next_out and update next_out and avail_out
    511   1.1    paulus     accordingly. This action is forced if the parameter flush is non zero.
    512   1.1    paulus     Forcing flush frequently degrades the compression ratio, so this parameter
    513   1.1    paulus     should be set only when necessary (in interactive applications).
    514   1.1    paulus     Some output may be provided even if flush is not set.
    515   1.1    paulus 
    516   1.1    paulus   Before the call of deflate(), the application should ensure that at least
    517   1.1    paulus   one of the actions is possible, by providing more input and/or consuming
    518   1.1    paulus   more output, and updating avail_in or avail_out accordingly; avail_out
    519   1.1    paulus   should never be zero before the call. The application can consume the
    520   1.1    paulus   compressed output when it wants, for example when the output buffer is full
    521   1.4  christos   (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
    522   1.4  christos   and with zero avail_out, it must be called again after making room in the
    523   1.4  christos   output buffer because there might be more output pending.
    524   1.1    paulus 
    525   1.6      fvdl     If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
    526   1.6      fvdl   flushed to the output buffer and the output is aligned on a byte boundary, so
    527   1.6      fvdl   that the decompressor can get all input data available so far. (In particular
    528   1.6      fvdl   avail_in is zero after the call if enough output space has been provided
    529   1.6      fvdl   before the call.)  Flushing may degrade compression for some compression
    530   1.6      fvdl   algorithms and so it should be used only when necessary.
    531   1.6      fvdl 
    532   1.6      fvdl     If flush is set to Z_FULL_FLUSH, all output is flushed as with
    533   1.6      fvdl   Z_SYNC_FLUSH, and the compression state is reset so that decompression can
    534   1.6      fvdl   restart from this point if previous compressed data has been damaged or if
    535   1.6      fvdl   random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
    536   1.6      fvdl   the compression.
    537   1.6      fvdl 
    538   1.6      fvdl     If deflate returns with avail_out == 0, this function must be called again
    539   1.6      fvdl   with the same value of the flush parameter and more output space (updated
    540   1.6      fvdl   avail_out), until the flush is complete (deflate returns with non-zero
    541   1.6      fvdl   avail_out).
    542   1.1    paulus 
    543   1.1    paulus     If the parameter flush is set to Z_PACKET_FLUSH, the compression
    544   1.1    paulus   block is terminated, and a zero-length stored block is output,
    545   1.1    paulus   omitting the length bytes (the effect of this is that the 3-bit type
    546   1.1    paulus   code 000 for a stored block is output, and the output is then
    547   1.1    paulus   byte-aligned).  This is designed for use at the end of a PPP packet.
    548   1.1    paulus 
    549   1.6      fvdl 
    550   1.4  christos     If the parameter flush is set to Z_FINISH, pending input is processed,
    551   1.4  christos   pending output is flushed and deflate returns with Z_STREAM_END if there
    552   1.1    paulus   was enough output space; if deflate returns with Z_OK, this function must be
    553   1.1    paulus   called again with Z_FINISH and more output space (updated avail_out) but no
    554   1.1    paulus   more input data, until it returns with Z_STREAM_END or an error. After
    555   1.1    paulus   deflate has returned Z_STREAM_END, the only possible operations on the
    556   1.1    paulus   stream are deflateReset or deflateEnd.
    557   1.8     perry 
    558   1.1    paulus     Z_FINISH can be used immediately after deflateInit if all the compression
    559   1.1    paulus   is to be done in a single step. In this case, avail_out must be at least
    560   1.1    paulus   0.1% larger than avail_in plus 12 bytes.  If deflate does not return
    561   1.1    paulus   Z_STREAM_END, then it must be called again as described above.
    562   1.1    paulus 
    563   1.6      fvdl     deflate() sets strm->adler to the adler32 checksum of all input read
    564   1.6      fvdl   so far (that is, total_in bytes).
    565   1.6      fvdl 
    566   1.1    paulus     deflate() may update data_type if it can make a good guess about
    567   1.1    paulus   the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
    568   1.1    paulus   binary. This field is only for information purposes and does not affect
    569   1.1    paulus   the compression algorithm in any manner.
    570   1.1    paulus 
    571   1.1    paulus     deflate() returns Z_OK if some progress has been made (more input
    572   1.1    paulus   processed or more output produced), Z_STREAM_END if all input has been
    573   1.1    paulus   consumed and all output has been produced (only when flush is set to
    574   1.1    paulus   Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
    575   1.6      fvdl   if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
    576   1.6      fvdl   (for example avail_in or avail_out was zero).
    577   1.1    paulus */
    578   1.1    paulus 
    579   1.1    paulus 
    580   1.7    itojun ZEXTERN int ZEXPORT deflateEnd __P((z_streamp));
    581   1.1    paulus /*
    582   1.1    paulus      All dynamically allocated data structures for this stream are freed.
    583   1.1    paulus    This function discards any unprocessed input and does not flush any
    584   1.1    paulus    pending output.
    585   1.1    paulus 
    586   1.1    paulus      deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
    587   1.4  christos    stream state was inconsistent, Z_DATA_ERROR if the stream was freed
    588   1.4  christos    prematurely (some input or output was discarded). In the error case,
    589   1.4  christos    msg may be set but then points to a static string (which must not be
    590   1.4  christos    deallocated).
    591   1.1    paulus */
    592   1.1    paulus 
    593   1.1    paulus 
    594   1.8     perry /*
    595   1.7    itojun ZEXTERN int ZEXPORT inflateInit __P((z_streamp));
    596   1.4  christos 
    597   1.1    paulus      Initializes the internal stream state for decompression. The fields
    598   1.6      fvdl    next_in, avail_in, zalloc, zfree and opaque must be initialized before by
    599   1.6      fvdl    the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
    600   1.6      fvdl    value depends on the compression method), inflateInit determines the
    601   1.6      fvdl    compression method from the zlib header and allocates all data structures
    602   1.6      fvdl    accordingly; otherwise the allocation will be deferred to the first call of
    603   1.6      fvdl    inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
    604   1.6      fvdl    use default allocation functions.
    605   1.1    paulus 
    606   1.6      fvdl      inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
    607   1.6      fvdl    memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
    608   1.6      fvdl    version assumed by the caller.  msg is set to null if there is no error
    609   1.6      fvdl    message. inflateInit does not perform any decompression apart from reading
    610   1.6      fvdl    the zlib header if present: this will be done by inflate().  (So next_in and
    611   1.6      fvdl    avail_in may be modified, but next_out and avail_out are unchanged.)
    612   1.1    paulus */
    613   1.1    paulus 
    614   1.2  christos 
    615   1.7    itojun ZEXTERN int ZEXPORT inflate __P((z_streamp, int));
    616   1.1    paulus /*
    617   1.6      fvdl     inflate decompresses as much data as possible, and stops when the input
    618   1.6      fvdl   buffer becomes empty or the output buffer becomes full. It may some
    619   1.6      fvdl   introduce some output latency (reading input without producing any output)
    620   1.6      fvdl   except when forced to flush.
    621   1.6      fvdl 
    622   1.6      fvdl   The detailed semantics are as follows. inflate performs one or both of the
    623   1.6      fvdl   following actions:
    624   1.1    paulus 
    625   1.1    paulus   - Decompress more input starting at next_in and update next_in and avail_in
    626   1.1    paulus     accordingly. If not all input can be processed (because there is not
    627   1.1    paulus     enough room in the output buffer), next_in is updated and processing
    628   1.1    paulus     will resume at this point for the next call of inflate().
    629   1.1    paulus 
    630   1.1    paulus   - Provide more output starting at next_out and update next_out and avail_out
    631   1.4  christos     accordingly.  inflate() provides as much output as possible, until there
    632   1.4  christos     is no more input data or no more space in the output buffer (see below
    633   1.4  christos     about the flush parameter).
    634   1.1    paulus 
    635   1.1    paulus   Before the call of inflate(), the application should ensure that at least
    636   1.1    paulus   one of the actions is possible, by providing more input and/or consuming
    637   1.1    paulus   more output, and updating the next_* and avail_* values accordingly.
    638   1.1    paulus   The application can consume the uncompressed output when it wants, for
    639   1.1    paulus   example when the output buffer is full (avail_out == 0), or after each
    640   1.4  christos   call of inflate(). If inflate returns Z_OK and with zero avail_out, it
    641   1.4  christos   must be called again after making room in the output buffer because there
    642   1.4  christos   might be more output pending.
    643   1.1    paulus 
    644   1.6      fvdl     If the parameter flush is set to Z_SYNC_FLUSH or Z_PACKET_FLUSH,
    645   1.1    paulus   inflate flushes as much output as possible to the output buffer. The
    646   1.1    paulus   flushing behavior of inflate is not specified for values of the flush
    647   1.6      fvdl   parameter other than Z_SYNC_FLUSH, Z_PACKET_FLUSH or Z_FINISH, but the
    648   1.1    paulus   current implementation actually flushes as much output as possible
    649   1.6      fvdl   anyway. For Z_PACKET_FLUSH, inflate checks that once all the input data
    650   1.1    paulus   has been consumed, it is expecting to see the length field of a stored
    651   1.1    paulus   block; if not, it returns Z_DATA_ERROR.
    652   1.1    paulus 
    653   1.1    paulus     inflate() should normally be called until it returns Z_STREAM_END or an
    654   1.1    paulus   error. However if all decompression is to be performed in a single step
    655   1.1    paulus   (a single call of inflate), the parameter flush should be set to
    656   1.1    paulus   Z_FINISH. In this case all pending input is processed and all pending
    657   1.1    paulus   output is flushed; avail_out must be large enough to hold all the
    658   1.1    paulus   uncompressed data. (The size of the uncompressed data may have been saved
    659   1.1    paulus   by the compressor for this purpose.) The next operation on this stream must
    660   1.1    paulus   be inflateEnd to deallocate the decompression state. The use of Z_FINISH
    661   1.1    paulus   is never required, but can be used to inform inflate that a faster routine
    662   1.1    paulus   may be used for the single inflate() call.
    663   1.1    paulus 
    664   1.6      fvdl      If a preset dictionary is needed at this point (see inflateSetDictionary
    665   1.6      fvdl   below), inflate sets strm-adler to the adler32 checksum of the
    666   1.8     perry   dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
    667   1.6      fvdl   it sets strm->adler to the adler32 checksum of all output produced
    668   1.6      fvdl   so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
    669   1.6      fvdl   an error code as described below. At the end of the stream, inflate()
    670   1.6      fvdl   checks that its computed adler32 checksum is equal to that saved by the
    671   1.6      fvdl   compressor and returns Z_STREAM_END only if the checksum is correct.
    672   1.6      fvdl 
    673   1.6      fvdl     inflate() returns Z_OK if some progress has been made (more input processed
    674   1.6      fvdl   or more output produced), Z_STREAM_END if the end of the compressed data has
    675   1.6      fvdl   been reached and all uncompressed output has been produced, Z_NEED_DICT if a
    676   1.6      fvdl   preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
    677   1.6      fvdl   corrupted (input stream not conforming to the zlib format or incorrect
    678   1.6      fvdl   adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
    679   1.6      fvdl   (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
    680   1.6      fvdl   enough memory, Z_BUF_ERROR if no progress is possible or if there was not
    681   1.6      fvdl   enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
    682   1.6      fvdl   case, the application may then call inflateSync to look for a good
    683   1.6      fvdl   compression block.
    684   1.4  christos */
    685   1.1    paulus 
    686   1.1    paulus 
    687   1.7    itojun ZEXTERN int ZEXPORT inflateEnd __P((z_streamp));
    688   1.1    paulus /*
    689   1.1    paulus      All dynamically allocated data structures for this stream are freed.
    690   1.1    paulus    This function discards any unprocessed input and does not flush any
    691   1.1    paulus    pending output.
    692   1.1    paulus 
    693   1.1    paulus      inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
    694   1.1    paulus    was inconsistent. In the error case, msg may be set but then points to a
    695   1.1    paulus    static string (which must not be deallocated).
    696   1.1    paulus */
    697   1.1    paulus 
    698   1.4  christos                         /* Advanced functions */
    699   1.1    paulus 
    700   1.1    paulus /*
    701   1.1    paulus     The following functions are needed only in some special applications.
    702   1.1    paulus */
    703   1.1    paulus 
    704   1.8     perry /*
    705   1.7    itojun ZEXTERN int ZEXPORT deflateInit2 __P((z_streamp, int, int, int, int, int));
    706   1.4  christos 
    707   1.1    paulus      This is another version of deflateInit with more compression options. The
    708   1.4  christos    fields next_in, zalloc, zfree and opaque must be initialized before by
    709   1.4  christos    the caller.
    710   1.1    paulus 
    711   1.4  christos      The method parameter is the compression method. It must be Z_DEFLATED in
    712   1.6      fvdl    this version of the library.
    713   1.1    paulus 
    714   1.1    paulus      The windowBits parameter is the base two logarithm of the window size
    715   1.1    paulus    (the size of the history buffer).  It should be in the range 8..15 for this
    716   1.6      fvdl    version of the library. Larger values of this parameter result in better
    717   1.6      fvdl    compression at the expense of memory usage. The default value is 15 if
    718   1.6      fvdl    deflateInit is used instead.
    719   1.1    paulus 
    720   1.4  christos      The memLevel parameter specifies how much memory should be allocated
    721   1.1    paulus    for the internal compression state. memLevel=1 uses minimum memory but
    722   1.1    paulus    is slow and reduces compression ratio; memLevel=9 uses maximum memory
    723   1.1    paulus    for optimal speed. The default value is 8. See zconf.h for total memory
    724   1.1    paulus    usage as a function of windowBits and memLevel.
    725   1.1    paulus 
    726   1.4  christos      The strategy parameter is used to tune the compression algorithm. Use the
    727   1.4  christos    value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
    728   1.4  christos    filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
    729   1.4  christos    string match).  Filtered data consists mostly of small values with a
    730   1.4  christos    somewhat random distribution. In this case, the compression algorithm is
    731   1.4  christos    tuned to compress them better. The effect of Z_FILTERED is to force more
    732   1.4  christos    Huffman coding and less string matching; it is somewhat intermediate
    733   1.4  christos    between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
    734   1.4  christos    the compression ratio but not the correctness of the compressed output even
    735   1.4  christos    if it is not set appropriately.
    736   1.1    paulus 
    737   1.6      fvdl       deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    738   1.6      fvdl    memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
    739   1.6      fvdl    method). msg is set to null if there is no error message.  deflateInit2 does
    740   1.6      fvdl    not perform any compression: this will be done by deflate().
    741   1.1    paulus */
    742   1.8     perry 
    743   1.7    itojun ZEXTERN int ZEXPORT deflateSetDictionary __P((z_streamp, const Bytef *, uInt));
    744   1.6      fvdl /*
    745   1.6      fvdl      Initializes the compression dictionary from the given byte sequence
    746   1.6      fvdl    without producing any compressed output. This function must be called
    747   1.6      fvdl    immediately after deflateInit, deflateInit2 or deflateReset, before any
    748   1.6      fvdl    call of deflate. The compressor and decompressor must use exactly the same
    749   1.4  christos    dictionary (see inflateSetDictionary).
    750   1.6      fvdl 
    751   1.4  christos      The dictionary should consist of strings (byte sequences) that are likely
    752   1.4  christos    to be encountered later in the data to be compressed, with the most commonly
    753   1.4  christos    used strings preferably put towards the end of the dictionary. Using a
    754   1.6      fvdl    dictionary is most useful when the data to be compressed is short and can be
    755   1.6      fvdl    predicted with good accuracy; the data can then be compressed better than
    756   1.6      fvdl    with the default empty dictionary.
    757   1.6      fvdl 
    758   1.6      fvdl      Depending on the size of the compression data structures selected by
    759   1.6      fvdl    deflateInit or deflateInit2, a part of the dictionary may in effect be
    760   1.6      fvdl    discarded, for example if the dictionary is larger than the window size in
    761   1.6      fvdl    deflate or deflate2. Thus the strings most likely to be useful should be
    762   1.6      fvdl    put at the end of the dictionary, not at the front.
    763   1.6      fvdl 
    764   1.4  christos      Upon return of this function, strm->adler is set to the Adler32 value
    765   1.4  christos    of the dictionary; the decompressor may later use this value to determine
    766   1.4  christos    which dictionary has been used by the compressor. (The Adler32 value
    767   1.4  christos    applies to the whole dictionary even if only a subset of the dictionary is
    768   1.4  christos    actually used by the compressor.)
    769   1.4  christos 
    770   1.4  christos      deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
    771   1.6      fvdl    parameter is invalid (such as NULL dictionary) or the stream state is
    772   1.6      fvdl    inconsistent (for example if deflate has already been called for this stream
    773   1.6      fvdl    or if the compression method is bsort). deflateSetDictionary does not
    774   1.6      fvdl    perform any compression: this will be done by deflate().
    775   1.4  christos */
    776   1.4  christos 
    777   1.7    itojun ZEXTERN int ZEXPORT deflateCopy __P((z_streamp, z_streamp));
    778   1.6      fvdl /*
    779   1.6      fvdl      Sets the destination stream as a complete copy of the source stream.
    780   1.1    paulus 
    781   1.4  christos      This function can be useful when several compression strategies will be
    782   1.1    paulus    tried, for example when there are several ways of pre-processing the input
    783   1.1    paulus    data with a filter. The streams that will be discarded should then be freed
    784   1.1    paulus    by calling deflateEnd.  Note that deflateCopy duplicates the internal
    785   1.1    paulus    compression state which can be quite large, so this strategy is slow and
    786   1.1    paulus    can consume lots of memory.
    787   1.1    paulus 
    788   1.4  christos      deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
    789   1.1    paulus    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
    790   1.1    paulus    (such as zalloc being NULL). msg is left unchanged in both source and
    791   1.1    paulus    destination.
    792   1.1    paulus */
    793   1.1    paulus 
    794   1.7    itojun extern int inflateIncomp __P((z_stream *));
    795   1.6      fvdl /*
    796   1.6      fvdl      This function adds the data at next_in (avail_in bytes) to the output
    797   1.6      fvdl    history without performing any output.  There must be no pending output,
    798   1.6      fvdl    and the decompressor must be expecting to see the start of a block.
    799   1.6      fvdl    Calling this function is equivalent to decompressing a stored block
    800   1.6      fvdl    containing the data at next_in (except that the data is not output).
    801   1.6      fvdl */
    802   1.6      fvdl 
    803   1.7    itojun ZEXTERN int ZEXPORT deflateReset __P((z_streamp));
    804   1.1    paulus /*
    805   1.1    paulus      This function is equivalent to deflateEnd followed by deflateInit,
    806   1.1    paulus    but does not free and reallocate all the internal compression state.
    807   1.1    paulus    The stream will keep the same compression level and any other attributes
    808   1.1    paulus    that may have been set by deflateInit2.
    809   1.1    paulus 
    810   1.1    paulus       deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
    811   1.1    paulus    stream state was inconsistent (such as zalloc or state being NULL).
    812   1.1    paulus */
    813   1.1    paulus 
    814   1.7    itojun ZEXTERN int ZEXPORT deflateParams __P((z_streamp, int, int));
    815   1.6      fvdl /*
    816   1.6      fvdl      Dynamically update the compression level and compression strategy.  The
    817   1.6      fvdl    interpretation of level and strategy is as in deflateInit2.  This can be
    818   1.6      fvdl    used to switch between compression and straight copy of the input data, or
    819   1.6      fvdl    to switch to a different kind of input data requiring a different
    820   1.6      fvdl    strategy. If the compression level is changed, the input available so far
    821   1.6      fvdl    is compressed with the old level (and may be flushed); the new level will
    822   1.6      fvdl    take effect only at the next call of deflate().
    823   1.4  christos 
    824   1.4  christos      Before the call of deflateParams, the stream state must be set as for
    825   1.4  christos    a call of deflate(), since the currently available input may have to
    826   1.4  christos    be compressed and flushed. In particular, strm->avail_out must be non-zero.
    827   1.4  christos 
    828   1.4  christos      deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
    829   1.4  christos    stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
    830   1.4  christos    if strm->avail_out was zero.
    831   1.4  christos */
    832   1.4  christos 
    833   1.7    itojun ZEXTERN int ZEXPORT deflateOutputPending __P((z_streamp));
    834   1.4  christos /*
    835   1.4  christos      Returns the number of bytes of output which are immediately
    836   1.4  christos    available from the compressor (i.e. without any further input
    837   1.4  christos    or flush).
    838   1.4  christos */
    839   1.4  christos 
    840   1.8     perry /*
    841   1.7    itojun ZEXTERN int ZEXPORT inflateInit2 __P((z_streamp, int));
    842   1.4  christos 
    843   1.6      fvdl      This is another version of inflateInit with an extra parameter. The
    844   1.6      fvdl    fields next_in, avail_in, zalloc, zfree and opaque must be initialized
    845   1.6      fvdl    before by the caller.
    846   1.1    paulus 
    847   1.1    paulus      The windowBits parameter is the base two logarithm of the maximum window
    848   1.1    paulus    size (the size of the history buffer).  It should be in the range 8..15 for
    849   1.6      fvdl    this version of the library. The default value is 15 if inflateInit is used
    850   1.6      fvdl    instead. If a compressed stream with a larger window size is given as
    851   1.6      fvdl    input, inflate() will return with the error code Z_DATA_ERROR instead of
    852   1.6      fvdl    trying to allocate a larger window.
    853   1.6      fvdl 
    854   1.6      fvdl       inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    855   1.6      fvdl    memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
    856   1.6      fvdl    memLevel). msg is set to null if there is no error message.  inflateInit2
    857   1.6      fvdl    does not perform any decompression apart from reading the zlib header if
    858   1.6      fvdl    present: this will be done by inflate(). (So next_in and avail_in may be
    859   1.6      fvdl    modified, but next_out and avail_out are unchanged.)
    860   1.6      fvdl */
    861   1.6      fvdl 
    862   1.7    itojun ZEXTERN int ZEXPORT inflateSetDictionary __P((z_streamp, const Bytef *, uInt));
    863   1.6      fvdl /*
    864   1.6      fvdl      Initializes the decompression dictionary from the given uncompressed byte
    865   1.6      fvdl    sequence. This function must be called immediately after a call of inflate
    866   1.6      fvdl    if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
    867   1.6      fvdl    can be determined from the Adler32 value returned by this call of
    868   1.6      fvdl    inflate. The compressor and decompressor must use exactly the same
    869   1.4  christos    dictionary (see deflateSetDictionary).
    870   1.4  christos 
    871   1.4  christos      inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
    872   1.4  christos    parameter is invalid (such as NULL dictionary) or the stream state is
    873   1.4  christos    inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
    874   1.4  christos    expected one (incorrect Adler32 value). inflateSetDictionary does not
    875   1.4  christos    perform any decompression: this will be done by subsequent calls of
    876   1.4  christos    inflate().
    877   1.4  christos */
    878   1.4  christos 
    879   1.7    itojun ZEXTERN int ZEXPORT inflateSync __P((z_streamp));
    880   1.8     perry /*
    881   1.6      fvdl     Skips invalid compressed data until a full flush point (see above the
    882   1.6      fvdl   description of deflate with Z_FULL_FLUSH) can be found, or until all
    883   1.6      fvdl   available input is skipped. No output is provided.
    884   1.1    paulus 
    885   1.6      fvdl     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
    886   1.6      fvdl   if no more input was provided, Z_DATA_ERROR if no flush point has been found,
    887   1.1    paulus   or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
    888   1.1    paulus   case, the application may save the current current value of total_in which
    889   1.1    paulus   indicates where valid compressed data was found. In the error case, the
    890   1.1    paulus   application may repeatedly call inflateSync, providing more input each time,
    891   1.1    paulus   until success or end of the input data.
    892   1.1    paulus */
    893   1.1    paulus 
    894   1.7    itojun ZEXTERN int ZEXPORT inflateReset __P((z_streamp));
    895   1.1    paulus /*
    896   1.1    paulus      This function is equivalent to inflateEnd followed by inflateInit,
    897   1.1    paulus    but does not free and reallocate all the internal decompression state.
    898   1.1    paulus    The stream will keep attributes that may have been set by inflateInit2.
    899   1.1    paulus 
    900   1.1    paulus       inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
    901   1.1    paulus    stream state was inconsistent (such as zalloc or state being NULL).
    902   1.1    paulus */
    903   1.1    paulus 
    904   1.1    paulus 
    905   1.4  christos                         /* utility functions */
    906   1.4  christos 
    907   1.4  christos /*
    908   1.4  christos      The following utility functions are implemented on top of the
    909   1.4  christos    basic stream-oriented functions. To simplify the interface, some
    910   1.6      fvdl    default options are assumed (compression level and memory usage,
    911   1.4  christos    standard memory allocation functions). The source code of these
    912   1.4  christos    utility functions can easily be modified if you need special options.
    913   1.4  christos */
    914   1.4  christos 
    915   1.7    itojun ZEXTERN int ZEXPORT compress __P((Bytef *, uLongf *, const Bytef *, uLong));
    916   1.4  christos /*
    917   1.4  christos      Compresses the source buffer into the destination buffer.  sourceLen is
    918   1.4  christos    the byte length of the source buffer. Upon entry, destLen is the total
    919   1.4  christos    size of the destination buffer, which must be at least 0.1% larger than
    920   1.4  christos    sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
    921   1.4  christos    compressed buffer.
    922   1.4  christos      This function can be used to compress a whole file at once if the
    923   1.4  christos    input file is mmap'ed.
    924   1.4  christos      compress returns Z_OK if success, Z_MEM_ERROR if there was not
    925   1.4  christos    enough memory, Z_BUF_ERROR if there was not enough room in the output
    926   1.4  christos    buffer.
    927   1.4  christos */
    928   1.4  christos 
    929   1.7    itojun ZEXTERN int ZEXPORT compress2 __P((Bytef *, uLongf *, const Bytef *,
    930   1.7    itojun 	    uLong, int));
    931   1.6      fvdl /*
    932   1.6      fvdl      Compresses the source buffer into the destination buffer. The level
    933   1.6      fvdl    parameter has the same meaning as in deflateInit.  sourceLen is the byte
    934   1.6      fvdl    length of the source buffer. Upon entry, destLen is the total size of the
    935   1.6      fvdl    destination buffer, which must be at least 0.1% larger than sourceLen plus
    936   1.6      fvdl    12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
    937   1.6      fvdl 
    938   1.6      fvdl      compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    939   1.6      fvdl    memory, Z_BUF_ERROR if there was not enough room in the output buffer,
    940   1.6      fvdl    Z_STREAM_ERROR if the level parameter is invalid.
    941   1.6      fvdl */
    942   1.6      fvdl 
    943   1.7    itojun ZEXTERN int ZEXPORT uncompress __P((Bytef *, uLongf *, const Bytef *, uLong));
    944   1.4  christos /*
    945   1.4  christos      Decompresses the source buffer into the destination buffer.  sourceLen is
    946   1.4  christos    the byte length of the source buffer. Upon entry, destLen is the total
    947   1.4  christos    size of the destination buffer, which must be large enough to hold the
    948   1.4  christos    entire uncompressed data. (The size of the uncompressed data must have
    949   1.4  christos    been saved previously by the compressor and transmitted to the decompressor
    950   1.4  christos    by some mechanism outside the scope of this compression library.)
    951   1.4  christos    Upon exit, destLen is the actual size of the compressed buffer.
    952   1.4  christos      This function can be used to decompress a whole file at once if the
    953   1.4  christos    input file is mmap'ed.
    954   1.4  christos 
    955   1.4  christos      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
    956   1.4  christos    enough memory, Z_BUF_ERROR if there was not enough room in the output
    957   1.4  christos    buffer, or Z_DATA_ERROR if the input data was corrupted.
    958   1.4  christos */
    959   1.4  christos 
    960   1.4  christos 
    961   1.4  christos typedef voidp gzFile;
    962   1.4  christos 
    963   1.7    itojun ZEXTERN gzFile ZEXPORT gzopen  __P((const char *, const char *));
    964   1.4  christos /*
    965   1.4  christos      Opens a gzip (.gz) file for reading or writing. The mode parameter
    966   1.4  christos    is as in fopen ("rb" or "wb") but can also include a compression level
    967   1.6      fvdl    ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
    968   1.6      fvdl    Huffman only compression as in "wb1h". (See the description
    969   1.6      fvdl    of deflateInit2 for more information about the strategy parameter.)
    970   1.6      fvdl 
    971   1.6      fvdl      gzopen can be used to read a file which is not in gzip format; in this
    972   1.6      fvdl    case gzread will directly read from the file without decompression.
    973   1.6      fvdl 
    974   1.4  christos      gzopen returns NULL if the file could not be opened or if there was
    975   1.4  christos    insufficient memory to allocate the (de)compression state; errno
    976   1.4  christos    can be checked to distinguish the two cases (if errno is zero, the
    977   1.6      fvdl    zlib error is Z_MEM_ERROR).  */
    978   1.4  christos 
    979   1.7    itojun ZEXTERN gzFile ZEXPORT gzdopen  __P((int, const char *));
    980   1.4  christos /*
    981   1.4  christos      gzdopen() associates a gzFile with the file descriptor fd.  File
    982   1.4  christos    descriptors are obtained from calls like open, dup, creat, pipe or
    983   1.4  christos    fileno (in the file has been previously opened with fopen).
    984   1.4  christos    The mode parameter is as in gzopen.
    985   1.4  christos      The next call of gzclose on the returned gzFile will also close the
    986   1.4  christos    file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
    987   1.4  christos    descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
    988   1.4  christos      gzdopen returns NULL if there was insufficient memory to allocate
    989   1.4  christos    the (de)compression state.
    990   1.4  christos */
    991   1.4  christos 
    992   1.7    itojun ZEXTERN int ZEXPORT gzsetparams __P((gzFile, int, int));
    993   1.6      fvdl /*
    994   1.6      fvdl      Dynamically update the compression level or strategy. See the description
    995   1.6      fvdl    of deflateInit2 for the meaning of these parameters.
    996   1.6      fvdl      gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
    997   1.6      fvdl    opened for writing.
    998   1.6      fvdl */
    999   1.6      fvdl 
   1000   1.7    itojun ZEXTERN int ZEXPORT    gzread  __P((gzFile, voidp, unsigned));
   1001   1.4  christos /*
   1002   1.4  christos      Reads the given number of uncompressed bytes from the compressed file.
   1003   1.4  christos    If the input file was not in gzip format, gzread copies the given number
   1004   1.4  christos    of bytes into the buffer.
   1005   1.4  christos      gzread returns the number of uncompressed bytes actually read (0 for
   1006   1.4  christos    end of file, -1 for error). */
   1007   1.4  christos 
   1008   1.7    itojun ZEXTERN int ZEXPORT    gzwrite __P((gzFile, const voidp, unsigned));
   1009   1.4  christos /*
   1010   1.4  christos      Writes the given number of uncompressed bytes into the compressed file.
   1011   1.4  christos    gzwrite returns the number of uncompressed bytes actually written
   1012   1.4  christos    (0 in case of error).
   1013   1.4  christos */
   1014   1.4  christos 
   1015   1.7    itojun ZEXTERN int ZEXPORTVA   gzprintf __P((gzFile, const char *, ...))
   1016   1.6      fvdl 		__attribute__((__format__(__printf__, 2, 3)));
   1017   1.6      fvdl /*
   1018   1.6      fvdl      Converts, formats, and writes the args to the compressed file under
   1019   1.6      fvdl    control of the format string, as in fprintf. gzprintf returns the number of
   1020   1.6      fvdl    uncompressed bytes actually written (0 in case of error).
   1021   1.6      fvdl */
   1022   1.6      fvdl 
   1023   1.7    itojun ZEXTERN int ZEXPORT gzputs __P((gzFile, const char *));
   1024   1.6      fvdl /*
   1025   1.6      fvdl       Writes the given null-terminated string to the compressed file, excluding
   1026   1.6      fvdl    the terminating null character.
   1027   1.6      fvdl       gzputs returns the number of characters written, or -1 in case of error.
   1028   1.6      fvdl */
   1029   1.6      fvdl 
   1030   1.7    itojun ZEXTERN char * ZEXPORT gzgets __P((gzFile, char *, int));
   1031   1.6      fvdl /*
   1032   1.6      fvdl       Reads bytes from the compressed file until len-1 characters are read, or
   1033   1.6      fvdl    a newline character is read and transferred to buf, or an end-of-file
   1034   1.6      fvdl    condition is encountered.  The string is then terminated with a null
   1035   1.6      fvdl    character.
   1036   1.6      fvdl       gzgets returns buf, or Z_NULL in case of error.
   1037   1.6      fvdl */
   1038   1.6      fvdl 
   1039   1.7    itojun ZEXTERN int ZEXPORT    gzputc __P((gzFile, int));
   1040   1.6      fvdl /*
   1041   1.6      fvdl       Writes c, converted to an unsigned char, into the compressed file.
   1042   1.6      fvdl    gzputc returns the value that was written, or -1 in case of error.
   1043   1.6      fvdl */
   1044   1.6      fvdl 
   1045   1.7    itojun ZEXTERN int ZEXPORT    gzgetc __P((gzFile));
   1046   1.6      fvdl /*
   1047   1.6      fvdl       Reads one byte from the compressed file. gzgetc returns this byte
   1048   1.6      fvdl    or -1 in case of end of file or error.
   1049   1.6      fvdl */
   1050   1.6      fvdl 
   1051   1.7    itojun ZEXTERN int ZEXPORT    gzflush __P((gzFile, int));
   1052   1.4  christos /*
   1053   1.4  christos      Flushes all pending output into the compressed file. The parameter
   1054   1.4  christos    flush is as in the deflate() function. The return value is the zlib
   1055   1.4  christos    error number (see function gzerror below). gzflush returns Z_OK if
   1056   1.4  christos    the flush parameter is Z_FINISH and all output could be flushed.
   1057   1.4  christos      gzflush should be called only when strictly necessary because it can
   1058   1.4  christos    degrade compression.
   1059   1.6      fvdl 
   1060   1.4  christos */
   1061   1.4  christos 
   1062   1.8     perry /*
   1063   1.6      fvdl  * NetBSD note:
   1064   1.6      fvdl  * "long" gzseek has been there till Oct 1999 (1.4L), which was wrong.
   1065   1.6      fvdl  */
   1066   1.7    itojun ZEXTERN z_off_t ZEXPORT    gzseek __P((gzFile, z_off_t, int));
   1067   1.8     perry /*
   1068   1.6      fvdl       Sets the starting position for the next gzread or gzwrite on the
   1069   1.6      fvdl    given compressed file. The offset represents a number of bytes in the
   1070   1.6      fvdl    uncompressed data stream. The whence parameter is defined as in lseek(2);
   1071   1.6      fvdl    the value SEEK_END is not supported.
   1072   1.6      fvdl      If the file is opened for reading, this function is emulated but can be
   1073   1.6      fvdl    extremely slow. If the file is opened for writing, only forward seeks are
   1074   1.6      fvdl    supported; gzseek then compresses a sequence of zeroes up to the new
   1075   1.6      fvdl    starting position.
   1076   1.6      fvdl 
   1077   1.6      fvdl       gzseek returns the resulting offset location as measured in bytes from
   1078   1.6      fvdl    the beginning of the uncompressed stream, or -1 in case of error, in
   1079   1.6      fvdl    particular if the file is opened for writing and the new starting position
   1080   1.6      fvdl    would be before the current position.
   1081   1.6      fvdl */
   1082   1.6      fvdl 
   1083   1.7    itojun ZEXTERN int ZEXPORT    gzrewind __P((gzFile));
   1084   1.6      fvdl /*
   1085   1.6      fvdl      Rewinds the given file. This function is supported only for reading.
   1086   1.6      fvdl 
   1087   1.6      fvdl    gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
   1088   1.6      fvdl */
   1089   1.6      fvdl 
   1090   1.8     perry /*
   1091   1.6      fvdl  * NetBSD note:
   1092   1.6      fvdl  * "long" gztell has been there till Oct 1999 (1.4L), which was wrong.
   1093   1.6      fvdl  */
   1094   1.7    itojun ZEXTERN z_off_t ZEXPORT    gztell __P((gzFile));
   1095   1.6      fvdl /*
   1096   1.6      fvdl      Returns the starting position for the next gzread or gzwrite on the
   1097   1.6      fvdl    given compressed file. This position represents a number of bytes in the
   1098   1.6      fvdl    uncompressed data stream.
   1099   1.6      fvdl 
   1100   1.6      fvdl    gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
   1101   1.6      fvdl */
   1102   1.6      fvdl 
   1103   1.7    itojun ZEXTERN int ZEXPORT gzeof __P((gzFile));
   1104   1.6      fvdl /*
   1105   1.6      fvdl      Returns 1 when EOF has previously been detected reading the given
   1106   1.6      fvdl    input stream, otherwise zero.
   1107   1.6      fvdl */
   1108   1.6      fvdl 
   1109   1.7    itojun ZEXTERN int ZEXPORT    gzclose __P((gzFile));
   1110   1.4  christos /*
   1111   1.4  christos      Flushes all pending output if necessary, closes the compressed file
   1112   1.4  christos    and deallocates all the (de)compression state. The return value is the zlib
   1113   1.4  christos    error number (see function gzerror below).
   1114   1.4  christos */
   1115   1.4  christos 
   1116   1.7    itojun ZEXTERN const char * ZEXPORT gzerror __P((gzFile, int *));
   1117   1.4  christos /*
   1118   1.4  christos      Returns the error message for the last error which occurred on the
   1119   1.4  christos    given compressed file. errnum is set to zlib error number. If an
   1120   1.4  christos    error occurred in the file system and not in the compression library,
   1121   1.4  christos    errnum is set to Z_ERRNO and the application may consult errno
   1122   1.4  christos    to get the exact error code.
   1123   1.4  christos */
   1124   1.4  christos 
   1125   1.1    paulus                         /* checksum functions */
   1126   1.1    paulus 
   1127   1.1    paulus /*
   1128   1.4  christos      These functions are not related to compression but are exported
   1129   1.4  christos    anyway because they might be useful in applications using the
   1130   1.1    paulus    compression library.
   1131   1.1    paulus */
   1132   1.1    paulus 
   1133   1.7    itojun ZEXTERN uLong ZEXPORT adler32 __P((uLong, const Bytef *, uInt));
   1134   1.1    paulus 
   1135   1.1    paulus /*
   1136   1.1    paulus      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
   1137   1.1    paulus    return the updated checksum. If buf is NULL, this function returns
   1138   1.1    paulus    the required initial value for the checksum.
   1139   1.1    paulus    An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
   1140   1.1    paulus    much faster. Usage example:
   1141   1.1    paulus 
   1142   1.1    paulus      uLong adler = adler32(0L, Z_NULL, 0);
   1143   1.1    paulus 
   1144   1.1    paulus      while (read_buffer(buffer, length) != EOF) {
   1145   1.1    paulus        adler = adler32(adler, buffer, length);
   1146   1.1    paulus      }
   1147   1.1    paulus      if (adler != original_adler) error();
   1148   1.1    paulus */
   1149   1.1    paulus 
   1150   1.7    itojun ZEXTERN uLong ZEXPORT crc32   __P((uLong, const Bytef *, uInt));
   1151   1.4  christos /*
   1152   1.4  christos      Update a running crc with the bytes buf[0..len-1] and return the updated
   1153   1.4  christos    crc. If buf is NULL, this function returns the required initial value
   1154   1.4  christos    for the crc. Pre- and post-conditioning (one's complement) is performed
   1155   1.4  christos    within this function so it shouldn't be done by the application.
   1156   1.4  christos    Usage example:
   1157   1.4  christos 
   1158   1.4  christos      uLong crc = crc32(0L, Z_NULL, 0);
   1159   1.4  christos 
   1160   1.4  christos      while (read_buffer(buffer, length) != EOF) {
   1161   1.4  christos        crc = crc32(crc, buffer, length);
   1162   1.4  christos      }
   1163   1.4  christos      if (crc != original_crc) error();
   1164   1.4  christos */
   1165   1.4  christos 
   1166   1.4  christos 
   1167   1.4  christos                         /* various hacks, don't look :) */
   1168   1.4  christos 
   1169   1.4  christos /* deflateInit and inflateInit are macros to allow checking the zlib version
   1170   1.4  christos  * and the compiler's view of z_stream:
   1171   1.4  christos  */
   1172   1.7    itojun ZEXTERN int ZEXPORT deflateInit_ __P((z_streamp, int, const char *, int));
   1173   1.7    itojun ZEXTERN int ZEXPORT inflateInit_ __P((z_streamp, const char *, int));
   1174   1.7    itojun ZEXTERN int ZEXPORT deflateInit2_ __P((z_streamp, int, int, int, int,
   1175   1.7    itojun                                       int, const char *, int));
   1176   1.7    itojun ZEXTERN int ZEXPORT inflateInit2_ __P((z_streamp, int, const char *, int));
   1177   1.4  christos #define deflateInit(strm, level) \
   1178   1.4  christos         deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
   1179   1.4  christos #define inflateInit(strm) \
   1180   1.4  christos         inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
   1181   1.4  christos #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
   1182   1.4  christos         deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
   1183   1.6      fvdl                       (strategy),           ZLIB_VERSION, sizeof(z_stream))
   1184   1.4  christos #define inflateInit2(strm, windowBits) \
   1185   1.4  christos         inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
   1186   1.4  christos 
   1187   1.6      fvdl 
   1188  1.12  christos #if !defined(Z_UTIL_H) && !defined(NO_DUMMY_DECL)
   1189   1.1    paulus     struct internal_state {int dummy;}; /* hack for buggy compilers */
   1190   1.1    paulus #endif
   1191   1.1    paulus 
   1192   1.7    itojun ZEXTERN const char   * ZEXPORT zError           __P((int));
   1193   1.7    itojun ZEXTERN int            ZEXPORT inflateSyncPoint __P((z_streamp));
   1194   1.6      fvdl ZEXTERN const uLongf * ZEXPORT get_crc_table    __P((void));
   1195   1.4  christos 
   1196   1.4  christos #ifdef __cplusplus
   1197   1.4  christos }
   1198   1.4  christos #endif
   1199  1.12  christos #endif /* !ZLIB_H */
   1200   1.4  christos 
   1201  1.10      elad #endif /* !_NET_ZLIB_H_ */
   1202   1.6      fvdl /* -- zlib.h */
   1203