1592N/A/*
1592N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1592N/A *
1592N/A * This code is free software; you can redistribute it and/or modify it
1592N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
1592N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
1592N/A *
1592N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1592N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1592N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1592N/A * version 2 for more details (a copy is included in the LICENSE file that
1592N/A * accompanied this code).
1592N/A *
1592N/A * You should have received a copy of the GNU General Public License version
1592N/A * 2 along with this work; if not, write to the Free Software Foundation,
1592N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1592N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1592N/A */
1592N/A
1592N/A/* inflate.h -- internal inflate state definition
1592N/A * Copyright (C) 1995-2004 Mark Adler
1592N/A * For conditions of distribution and use, see copyright notice in zlib.h
1592N/A */
1592N/A
1592N/A/* WARNING: this file should *not* be used by applications. It is
1592N/A part of the implementation of the compression library and is
1592N/A subject to change. Applications should only use zlib.h.
1592N/A */
1592N/A
1592N/A/* define NO_GZIP when compiling if you want to disable gzip header and
1592N/A trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
1592N/A the crc code when it is not needed. For shared libraries, gzip decoding
1592N/A should be left enabled. */
1592N/A#ifndef NO_GZIP
1592N/A# define GUNZIP
1592N/A#endif
1592N/A
1592N/A/* Possible inflate modes between inflate() calls */
1592N/Atypedef enum {
1592N/A HEAD, /* i: waiting for magic header */
1592N/A FLAGS, /* i: waiting for method and flags (gzip) */
1592N/A TIME, /* i: waiting for modification time (gzip) */
1592N/A OS, /* i: waiting for extra flags and operating system (gzip) */
1592N/A EXLEN, /* i: waiting for extra length (gzip) */
1592N/A EXTRA, /* i: waiting for extra bytes (gzip) */
1592N/A NAME, /* i: waiting for end of file name (gzip) */
1592N/A COMMENT, /* i: waiting for end of comment (gzip) */
1592N/A HCRC, /* i: waiting for header crc (gzip) */
1592N/A DICTID, /* i: waiting for dictionary check value */
1592N/A DICT, /* waiting for inflateSetDictionary() call */
1592N/A TYPE, /* i: waiting for type bits, including last-flag bit */
1592N/A TYPEDO, /* i: same, but skip check to exit inflate on new block */
1592N/A STORED, /* i: waiting for stored size (length and complement) */
1592N/A COPY, /* i/o: waiting for input or output to copy stored block */
1592N/A TABLE, /* i: waiting for dynamic block table lengths */
1592N/A LENLENS, /* i: waiting for code length code lengths */
1592N/A CODELENS, /* i: waiting for length/lit and distance code lengths */
1592N/A LEN, /* i: waiting for length/lit code */
1592N/A LENEXT, /* i: waiting for length extra bits */
1592N/A DIST, /* i: waiting for distance code */
1592N/A DISTEXT, /* i: waiting for distance extra bits */
1592N/A MATCH, /* o: waiting for output space to copy string */
1592N/A LIT, /* o: waiting for output space to write literal */
1592N/A CHECK, /* i: waiting for 32-bit check value */
1592N/A LENGTH, /* i: waiting for 32-bit length (gzip) */
1592N/A DONE, /* finished check, done -- remain here until reset */
1592N/A BAD, /* got a data error -- remain here until reset */
1592N/A MEM, /* got an inflate() memory error -- remain here until reset */
1592N/A SYNC /* looking for synchronization bytes to restart inflate() */
1592N/A} inflate_mode;
1592N/A
1592N/A/*
1592N/A State transitions between above modes -
1592N/A
1592N/A (most modes can go to the BAD or MEM mode -- not shown for clarity)
1592N/A
1592N/A Process header:
1592N/A HEAD -> (gzip) or (zlib)
1592N/A (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
1592N/A NAME -> COMMENT -> HCRC -> TYPE
1592N/A (zlib) -> DICTID or TYPE
1592N/A DICTID -> DICT -> TYPE
1592N/A Read deflate blocks:
1592N/A TYPE -> STORED or TABLE or LEN or CHECK
1592N/A STORED -> COPY -> TYPE
1592N/A TABLE -> LENLENS -> CODELENS -> LEN
1592N/A Read deflate codes:
1592N/A LEN -> LENEXT or LIT or TYPE
1592N/A LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
1592N/A LIT -> LEN
1592N/A Process trailer:
1592N/A CHECK -> LENGTH -> DONE
1592N/A */
1592N/A
1592N/A/* state maintained between inflate() calls. Approximately 7K bytes. */
1592N/Astruct inflate_state {
1592N/A inflate_mode mode; /* current inflate mode */
1592N/A int last; /* true if processing last block */
1592N/A int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
1592N/A int havedict; /* true if dictionary provided */
1592N/A int flags; /* gzip header method and flags (0 if zlib) */
1592N/A unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
1592N/A unsigned long check; /* protected copy of check value */
1592N/A unsigned long total; /* protected copy of output count */
1592N/A gz_headerp head; /* where to save gzip header information */
1592N/A /* sliding window */
1592N/A unsigned wbits; /* log base 2 of requested window size */
1592N/A unsigned wsize; /* window size or zero if not using window */
1592N/A unsigned whave; /* valid bytes in the window */
1592N/A unsigned write; /* window write index */
1592N/A unsigned char FAR *window; /* allocated sliding window, if needed */
1592N/A /* bit accumulator */
1592N/A unsigned long hold; /* input bit accumulator */
1592N/A unsigned bits; /* number of bits in "in" */
1592N/A /* for string and stored block copying */
1592N/A unsigned length; /* literal or length of data to copy */
1592N/A unsigned offset; /* distance back to copy string from */
1592N/A /* for table and code decoding */
1592N/A unsigned extra; /* extra bits needed */
1592N/A /* fixed and dynamic code tables */
1592N/A code const FAR *lencode; /* starting table for length/literal codes */
1592N/A code const FAR *distcode; /* starting table for distance codes */
1592N/A unsigned lenbits; /* index bits for lencode */
1592N/A unsigned distbits; /* index bits for distcode */
1592N/A /* dynamic table building */
1592N/A unsigned ncode; /* number of code length code lengths */
1592N/A unsigned nlen; /* number of length code lengths */
1592N/A unsigned ndist; /* number of distance code lengths */
1592N/A unsigned have; /* number of code lengths in lens[] */
1592N/A code FAR *next; /* next available space in codes[] */
1592N/A unsigned short lens[320]; /* temporary storage for code lengths */
1592N/A unsigned short work[288]; /* work area for code table building */
1592N/A code codes[ENOUGH]; /* space for code tables */
1592N/A};