kusano 7d535a
/* inftree9.h -- header to use inftree9.c
kusano 7d535a
 * Copyright (C) 1995-2008 Mark Adler
kusano 7d535a
 * For conditions of distribution and use, see copyright notice in zlib.h
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
/* WARNING: this file should *not* be used by applications. It is
kusano 7d535a
   part of the implementation of the compression library and is
kusano 7d535a
   subject to change. Applications should only use zlib.h.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
/* Structure for decoding tables.  Each entry provides either the
kusano 7d535a
   information needed to do the operation requested by the code that
kusano 7d535a
   indexed that table entry, or it provides a pointer to another
kusano 7d535a
   table that indexes more bits of the code.  op indicates whether
kusano 7d535a
   the entry is a pointer to another table, a literal, a length or
kusano 7d535a
   distance, an end-of-block, or an invalid code.  For a table
kusano 7d535a
   pointer, the low four bits of op is the number of index bits of
kusano 7d535a
   that table.  For a length or distance, the low four bits of op
kusano 7d535a
   is the number of extra bits to get after the code.  bits is
kusano 7d535a
   the number of bits in this code or part of the code to drop off
kusano 7d535a
   of the bit buffer.  val is the actual byte to output in the case
kusano 7d535a
   of a literal, the base length or distance, or the offset from
kusano 7d535a
   the current table to the next table.  Each entry is four bytes. */
kusano 7d535a
typedef struct {
kusano 7d535a
    unsigned char op;           /* operation, extra bits, table bits */
kusano 7d535a
    unsigned char bits;         /* bits in this part of the code */
kusano 7d535a
    unsigned short val;         /* offset in table or code value */
kusano 7d535a
} code;
kusano 7d535a
kusano 7d535a
/* op values as set by inflate_table():
kusano 7d535a
    00000000 - literal
kusano 7d535a
    0000tttt - table link, tttt != 0 is the number of table index bits
kusano 7d535a
    100eeeee - length or distance, eeee is the number of extra bits
kusano 7d535a
    01100000 - end of block
kusano 7d535a
    01000000 - invalid code
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
/* Maximum size of the dynamic table.  The maximum number of code structures is
kusano 7d535a
   1446, which is the sum of 852 for literal/length codes and 594 for distance
kusano 7d535a
   codes.  These values were found by exhaustive searches using the program
kusano 7d535a
   examples/enough.c found in the zlib distribtution.  The arguments to that
kusano 7d535a
   program are the number of symbols, the initial root table size, and the
kusano 7d535a
   maximum bit length of a code.  "enough 286 9 15" for literal/length codes
kusano 7d535a
   returns returns 852, and "enough 32 6 15" for distance codes returns 594.
kusano 7d535a
   The initial root table size (9 or 6) is found in the fifth argument of the
kusano 7d535a
   inflate_table() calls in infback9.c.  If the root table size is changed,
kusano 7d535a
   then these maximum sizes would be need to be recalculated and updated. */
kusano 7d535a
#define ENOUGH_LENS 852
kusano 7d535a
#define ENOUGH_DISTS 594
kusano 7d535a
#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
kusano 7d535a
kusano 7d535a
/* Type of code to build for inflate_table9() */
kusano 7d535a
typedef enum {
kusano 7d535a
    CODES,
kusano 7d535a
    LENS,
kusano 7d535a
    DISTS
kusano 7d535a
} codetype;
kusano 7d535a
kusano 7d535a
extern int inflate_table9 OF((codetype type, unsigned short FAR *lens,
kusano 7d535a
                             unsigned codes, code FAR * FAR *table,
kusano 7d535a
                             unsigned FAR *bits, unsigned short FAR *work));