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