home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Source / zlib / ZLIB.H < prev    next >
C/C++ Source or Header  |  2003-07-16  |  10KB  |  299 lines

  1. /*
  2.   Note: this version of zlib has been hacked up quite a bit in order to reduce
  3.   the size of the EXE header and to remove what we didn't need.
  4.   For the complete real thing, go to:
  5.  
  6.   http://www.info-zip.org/pub/infozip/zlib/
  7.  
  8.   Peace,
  9.  
  10.   -Justin
  11. */
  12.  
  13.  
  14.  
  15. /* zlib.h -- interface of the 'zlib' general purpose compression library
  16.   version 1.1.3, July 9th, 1998
  17.  
  18.   Copyright (C) 1995-1998 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. */
  41.  
  42. #ifndef _ZLIB_H
  43. #define _ZLIB_H
  44.  
  45. #include "zconf.h"
  46. #include "zutil.h"
  47.  
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51.  
  52.  
  53. #ifdef EXEHEAD
  54.  
  55. typedef struct inflate_huft_s FAR inflate_huft;
  56.  
  57.  
  58.  
  59. typedef enum {        /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
  60.       CODES_START,    /* x: set up for LEN */
  61.       CODES_LEN,      /* i: get length/literal/eob next */
  62.       CODES_LENEXT,   /* i: getting length extra (have base) */
  63.       CODES_DIST,     /* i: get distance next */
  64.       CODES_DISTEXT,  /* i: getting distance extra */
  65.       CODES_COPY,     /* o: copying bytes in window, waiting for space */
  66.       CODES_LIT,      /* o: got literal, waiting for output space */
  67.       CODES_WASH,     /* o: got eob, possibly still output waiting */
  68.       //CODES_END,      /* x: got eob and all data flushed */
  69.       //CODES_BADCODE,  /* x: got error */
  70.       
  71.       TYPE,     /* get type bits (3, including end bit) */
  72.       LENS,     /* get lengths for stored */
  73.       STORED,   /* processing stored block */
  74.       TABLE,    /* get table lengths */
  75.       BTREE,    /* get bit lengths tree for a dynamic block */
  76.       DTREE,    /* get length, distance trees for a dynamic block */
  77.       CODES,    /* processing fixed or dynamic block */
  78.       DRY,      /* output remaining window bytes */
  79.       DONE,     /* finished last block, done */
  80.       BAD       /* got a data error--stuck here */
  81. } inflate_mode;
  82.  
  83. /* inflate codes private state */
  84. struct inflate_codes_state {
  85.  
  86.   /* mode */
  87.   //inflate_mode mode;      /* current inflate_codes mode */
  88.  
  89.   /* mode dependent information */
  90.   uInt len;
  91.   union {
  92.     struct {
  93.       inflate_huft *tree;       /* pointer into tree */
  94.       uInt need;                /* bits needed */
  95.     } code;             /* if LEN or DIST, where in tree */
  96.     uInt lit;           /* if LIT, literal */
  97.     struct {
  98.       uInt get;                 /* bits to get for extra */
  99.       uInt dist;                /* distance back to copy from */
  100.     } copy;             /* if EXT or COPY, where and how much */
  101.   } sub;                /* submode */
  102.  
  103.   /* mode independent information */
  104.   Byte lbits;           /* ltree bits decoded per branch */
  105.   Byte dbits;           /* dtree bits decoder per branch */
  106.   inflate_huft *ltree;          /* literal/length/eob tree */
  107.   inflate_huft *dtree;          /* distance tree */
  108.  
  109. };
  110.  
  111. struct inflate_huft_s {
  112.   union {
  113.     struct {
  114.       Byte Exop;        /* number of extra bits or operation */
  115.       Byte Bits;        /* number of bits in this code or subcode */
  116.     } what;
  117.   } word;
  118.   unsigned short base;            /* literal, length base, distance base,
  119.                            or table offset */
  120. };
  121.  
  122. #define MANY 1440
  123.  
  124. typedef struct inflate_codes_state inflate_codes_statef;
  125.  
  126. struct inflate_blocks_state {
  127.  
  128.   /* mode */
  129.   inflate_mode  mode;    /* current inflate_block mode */
  130.  
  131.   /* mode dependent information */
  132.   union {
  133.     uInt left;          /* if STORED, bytes left to copy */
  134.     struct {
  135.       uInt table;               /* table lengths (14 bits) */
  136.       uInt index;               /* index into blens (or border) */
  137.       uIntf t_blens[258+31+31];             /* bit lengths of codes */
  138.       uInt bb;                  /* bit length tree depth */
  139.       inflate_huft *tb;         /* bit length decoding tree */
  140.     } trees;            /* if DTREE, decoding info for trees */
  141.     struct {
  142.       inflate_codes_statef t_codes;
  143.     } decode;           /* if CODES, current state */
  144.   } sub;                /* submode */
  145.  
  146.   uInt last;            /* DRY if this block is the last block, TYPE otherwise */
  147.  
  148.   /* mode independent information */
  149.   uInt bitk;            /* bits in bit buffer */
  150.   uLong bitb;           /* bit buffer */
  151.   inflate_huft hufts[MANY];  /* single malloc for tree space */
  152.   Bytef window[1 << MAX_WBITS];        /* sliding window */
  153.   Bytef *end;           /* one byte after sliding window */
  154.   Bytef *read;          /* window read pointer */
  155.   Bytef *write;         /* window write pointer */
  156.   uLong check;          /* check on output */
  157.  
  158. };
  159.  
  160.  
  161.  
  162. #else
  163. struct internal_state;
  164. #endif
  165.  
  166. typedef struct z_stream_s {
  167.     Bytef    *next_in;  /* next input byte */
  168.     uInt     avail_in;  /* number of bytes available at next_in */
  169. #ifndef EXEHEAD
  170.     uLong    total_in;  /* total nb of input bytes read so far */
  171. #endif
  172.  
  173.     Bytef    *next_out; /* next output byte should be put there */
  174.     uInt     avail_out; /* remaining free space at next_out */
  175. #ifndef EXEHEAD
  176.     uLong    total_out; /* total nb of bytes output so far */
  177. #endif
  178.  
  179. //    char     *msg;      /* last error message, NULL if no error */
  180.     //struct internal_state FAR *state; /* not visible by applications */
  181. #ifdef EXEHEAD
  182.     struct inflate_blocks_state blocks;            /* current inflate_blocks state */
  183. #else
  184.     struct internal_state *state;
  185. #endif
  186.  
  187. } z_stream;
  188.  
  189. typedef z_stream FAR *z_streamp;
  190.  
  191.  
  192. #define Z_NO_FLUSH      0
  193. #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
  194. #define Z_SYNC_FLUSH    2
  195. #define Z_FULL_FLUSH    3
  196. #define Z_FINISH        4
  197. /* Allowed flush values; see deflate() below for details */
  198.  
  199. #define Z_OK            0
  200. #define Z_STREAM_END    1
  201. #define Z_NEED_DICT     2
  202. #define Z_ERRNO        (-1)
  203.  
  204. #ifndef EXEHEAD
  205.  
  206. #define Z_STREAM_ERROR (-2)
  207. #define Z_DATA_ERROR   (-3)
  208. #define Z_MEM_ERROR    (-4)
  209. #define Z_BUF_ERROR    (-5)
  210. #define Z_VERSION_ERROR (-6)
  211.  
  212. #else
  213. // EXEHEAD doesn't need a specific return code, just < 0
  214.  
  215. #define Z_STREAM_ERROR  Z_ERRNO
  216. #define Z_DATA_ERROR    Z_ERRNO
  217. #define Z_MEM_ERROR     Z_ERRNO
  218. #define Z_BUF_ERROR     Z_ERRNO
  219. #define Z_VERSION_ERROR Z_ERRNO
  220.  
  221. #endif
  222. /* Return codes for the compression/decompression functions. Negative
  223.  * values are errors, positive values are used for special but normal events.
  224.  */
  225.  
  226. #define Z_NO_COMPRESSION         0
  227. #define Z_BEST_SPEED             1
  228. #define Z_BEST_COMPRESSION       9
  229. #define Z_DEFAULT_COMPRESSION  (-1)
  230. /* compression levels */
  231.  
  232. #define Z_FILTERED            1
  233. #define Z_HUFFMAN_ONLY        2
  234. #define Z_DEFAULT_STRATEGY    0
  235. /* compression strategy; see deflateInit2() below for details */
  236.  
  237. #define Z_BINARY   0
  238. #define Z_ASCII    1
  239. #define Z_UNKNOWN  2
  240. /* Possible values of the data_type field */
  241.  
  242. #define Z_DEFLATED   8
  243. /* The deflate compression method (the only one supported in this version) */
  244.  
  245. #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
  246.  
  247.  
  248. ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
  249.  
  250. ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
  251.  
  252.  
  253. #define inflateInit(x) inflateReset(x)
  254. int ZEXPORT inflate(z_streamp z);
  255. ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
  256. ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
  257.                                      int  level,
  258.                                      int  method,
  259.                                      int  windowBits,
  260.                                      int  memLevel,
  261.                                      int  strategy));
  262.  
  263.  
  264. ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
  265.  
  266. //void ZEXPORT inflateReset OF((
  267.   //  z_streamp));
  268. #define inflateReset(z) \
  269. { \
  270.   (z)->blocks.mode = TYPE; \
  271.   (z)->blocks.bitk = (z)->blocks.bitb = 0; \
  272.   (z)->blocks.read = (z)->blocks.write = (z)->blocks.window; \
  273.   (z)->blocks.end = (z)->blocks.window + (1 << DEF_WBITS); \
  274. }
  275.  
  276.                         /* various hacks, don't look :) */
  277.  
  278. /* deflateInit and inflateInit are macros to allow checking the zlib version
  279.  * and the compiler's view of z_stream:
  280.  */
  281. ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
  282.                                      const char *version, int stream_size));
  283. //ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
  284.   //                                   const char *version, int stream_size));
  285. ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
  286.                                       int windowBits, int memLevel,
  287.                                       int strategy, const char *version,
  288.                                       int stream_size));
  289.  
  290. #define deflateInit(strm, level) \
  291.         deflateInit_((strm), (level),       "", sizeof(z_stream))
  292.  
  293.  
  294. #ifdef __cplusplus
  295. }
  296. #endif
  297.  
  298. #endif /* _ZLIB_H */
  299.