core/zlib/inftrees.h
author David Anderson <dvander@alliedmods.net>
Tue Dec 04 01:08:03 2007 +0000 (2007-12-04)
changeset 1756 33f9fa5adfe3
parent 159 43c471413f70
permissions -rw-r--r--
added @t, @ts, @ct, @cts target patterns
dvander@159
     1
/* inftrees.h -- header to use inftrees.c
dvander@159
     2
 * Copyright (C) 1995-2005 Mark Adler
dvander@159
     3
 * For conditions of distribution and use, see copyright notice in zlib.h
dvander@159
     4
 */
dvander@159
     5
dvander@159
     6
/* WARNING: this file should *not* be used by applications. It is
dvander@159
     7
   part of the implementation of the compression library and is
dvander@159
     8
   subject to change. Applications should only use zlib.h.
dvander@159
     9
 */
dvander@159
    10
dvander@159
    11
/* Structure for decoding tables.  Each entry provides either the
dvander@159
    12
   information needed to do the operation requested by the code that
dvander@159
    13
   indexed that table entry, or it provides a pointer to another
dvander@159
    14
   table that indexes more bits of the code.  op indicates whether
dvander@159
    15
   the entry is a pointer to another table, a literal, a length or
dvander@159
    16
   distance, an end-of-block, or an invalid code.  For a table
dvander@159
    17
   pointer, the low four bits of op is the number of index bits of
dvander@159
    18
   that table.  For a length or distance, the low four bits of op
dvander@159
    19
   is the number of extra bits to get after the code.  bits is
dvander@159
    20
   the number of bits in this code or part of the code to drop off
dvander@159
    21
   of the bit buffer.  val is the actual byte to output in the case
dvander@159
    22
   of a literal, the base length or distance, or the offset from
dvander@159
    23
   the current table to the next table.  Each entry is four bytes. */
dvander@159
    24
typedef struct {
dvander@159
    25
    unsigned char op;           /* operation, extra bits, table bits */
dvander@159
    26
    unsigned char bits;         /* bits in this part of the code */
dvander@159
    27
    unsigned short val;         /* offset in table or code value */
dvander@159
    28
} code;
dvander@159
    29
dvander@159
    30
/* op values as set by inflate_table():
dvander@159
    31
    00000000 - literal
dvander@159
    32
    0000tttt - table link, tttt != 0 is the number of table index bits
dvander@159
    33
    0001eeee - length or distance, eeee is the number of extra bits
dvander@159
    34
    01100000 - end of block
dvander@159
    35
    01000000 - invalid code
dvander@159
    36
 */
dvander@159
    37
dvander@159
    38
/* Maximum size of dynamic tree.  The maximum found in a long but non-
dvander@159
    39
   exhaustive search was 1444 code structures (852 for length/literals
dvander@159
    40
   and 592 for distances, the latter actually the result of an
dvander@159
    41
   exhaustive search).  The true maximum is not known, but the value
dvander@159
    42
   below is more than safe. */
dvander@159
    43
#define ENOUGH 2048
dvander@159
    44
#define MAXD 592
dvander@159
    45
dvander@159
    46
/* Type of code to build for inftable() */
dvander@159
    47
typedef enum {
dvander@159
    48
    CODES,
dvander@159
    49
    LENS,
dvander@159
    50
    DISTS
dvander@159
    51
} codetype;
dvander@159
    52
dvander@159
    53
extern int inflate_table OF((codetype type, unsigned short FAR *lens,
dvander@159
    54
                             unsigned codes, code FAR * FAR *table,
dvander@159
    55
                             unsigned FAR *bits, unsigned short FAR *work));