c9431fa1e59a88c2f0abf611f25b97af964449e5ahl/* inflate.h -- internal inflate state definition
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl * Copyright (C) 1995-2004 Mark Adler
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl * For conditions of distribution and use, see copyright notice in zlib.h
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl#pragma ident "%Z%%M% %I% %E% SMI"
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl/* WARNING: this file should *not* be used by applications. It is
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl part of the implementation of the compression library and is
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl subject to change. Applications should only use zlib.h.
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl/* define NO_GZIP when compiling if you want to disable gzip header and
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl the crc code when it is not needed. For shared libraries, gzip decoding
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl should be left enabled. */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl/* Possible inflate modes between inflate() calls */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahltypedef enum {
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl OS, /* i: waiting for extra flags and operating system (gzip) */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl TYPE, /* i: waiting for type bits, including last-flag bit */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl TYPEDO, /* i: same, but skip check to exit inflate on new block */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl STORED, /* i: waiting for stored size (length and complement) */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl COPY, /* i/o: waiting for input or output to copy stored block */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl CODELENS, /* i: waiting for length/lit and distance code lengths */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl DONE, /* finished check, done -- remain here until reset */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl MEM, /* got an inflate() memory error -- remain here until reset */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl SYNC /* looking for synchronization bytes to restart inflate() */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl State transitions between above modes -
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl (most modes can go to the BAD or MEM mode -- not shown for clarity)
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl Process header:
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl HEAD -> (gzip) or (zlib)
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl NAME -> COMMENT -> HCRC -> TYPE
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl (zlib) -> DICTID or TYPE
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl DICTID -> DICT -> TYPE
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl Read deflate blocks:
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl TYPE -> STORED or TABLE or LEN or CHECK
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl STORED -> COPY -> TYPE
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl TABLE -> LENLENS -> CODELENS -> LEN
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl Read deflate codes:
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl LEN -> LENEXT or LIT or TYPE
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl LIT -> LEN
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl Process trailer:
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl CHECK -> LENGTH -> DONE
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl/* state maintained between inflate() calls. Approximately 7K bytes. */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl int flags; /* gzip header method and flags (0 if zlib) */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl unsigned long check; /* protected copy of check value */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl unsigned long total; /* protected copy of output count */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl gz_headerp head; /* where to save gzip header information */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl /* sliding window */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl unsigned wbits; /* log base 2 of requested window size */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl unsigned wsize; /* window size or zero if not using window */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl unsigned char FAR *window; /* allocated sliding window, if needed */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl /* bit accumulator */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl /* for string and stored block copying */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl unsigned length; /* literal or length of data to copy */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl unsigned offset; /* distance back to copy string from */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl /* for table and code decoding */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl /* fixed and dynamic code tables */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl code const FAR *lencode; /* starting table for length/literal codes */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl code const FAR *distcode; /* starting table for distance codes */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl /* dynamic table building */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl unsigned ncode; /* number of code length code lengths */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl unsigned short lens[320]; /* temporary storage for code lengths */
c9431fa1e59a88c2f0abf611f25b97af964449e5ahl unsigned short work[288]; /* work area for code table building */