Blame nss/lib/zlib/inftrees.h

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