inftree9.h revision 1.1.1.2 1 1.1 christos /* inftree9.h -- header to use inftree9.c
2 1.1.1.2 christos * Copyright (C) 1995-2008 Mark Adler
3 1.1 christos * For conditions of distribution and use, see copyright notice in zlib.h
4 1.1 christos */
5 1.1 christos
6 1.1 christos /* WARNING: this file should *not* be used by applications. It is
7 1.1 christos part of the implementation of the compression library and is
8 1.1 christos subject to change. Applications should only use zlib.h.
9 1.1 christos */
10 1.1 christos
11 1.1 christos /* Structure for decoding tables. Each entry provides either the
12 1.1 christos information needed to do the operation requested by the code that
13 1.1 christos indexed that table entry, or it provides a pointer to another
14 1.1 christos table that indexes more bits of the code. op indicates whether
15 1.1 christos the entry is a pointer to another table, a literal, a length or
16 1.1 christos distance, an end-of-block, or an invalid code. For a table
17 1.1 christos pointer, the low four bits of op is the number of index bits of
18 1.1 christos that table. For a length or distance, the low four bits of op
19 1.1 christos is the number of extra bits to get after the code. bits is
20 1.1 christos the number of bits in this code or part of the code to drop off
21 1.1 christos of the bit buffer. val is the actual byte to output in the case
22 1.1 christos of a literal, the base length or distance, or the offset from
23 1.1 christos the current table to the next table. Each entry is four bytes. */
24 1.1 christos typedef struct {
25 1.1 christos unsigned char op; /* operation, extra bits, table bits */
26 1.1 christos unsigned char bits; /* bits in this part of the code */
27 1.1 christos unsigned short val; /* offset in table or code value */
28 1.1 christos } code;
29 1.1 christos
30 1.1 christos /* op values as set by inflate_table():
31 1.1 christos 00000000 - literal
32 1.1 christos 0000tttt - table link, tttt != 0 is the number of table index bits
33 1.1 christos 100eeeee - length or distance, eeee is the number of extra bits
34 1.1 christos 01100000 - end of block
35 1.1 christos 01000000 - invalid code
36 1.1 christos */
37 1.1 christos
38 1.1.1.2 christos /* Maximum size of the dynamic table. The maximum number of code structures is
39 1.1.1.2 christos 1446, which is the sum of 852 for literal/length codes and 594 for distance
40 1.1.1.2 christos codes. These values were found by exhaustive searches using the program
41 1.1.1.2 christos examples/enough.c found in the zlib distribtution. The arguments to that
42 1.1.1.2 christos program are the number of symbols, the initial root table size, and the
43 1.1.1.2 christos maximum bit length of a code. "enough 286 9 15" for literal/length codes
44 1.1.1.2 christos returns returns 852, and "enough 32 6 15" for distance codes returns 594.
45 1.1.1.2 christos The initial root table size (9 or 6) is found in the fifth argument of the
46 1.1.1.2 christos inflate_table() calls in infback9.c. If the root table size is changed,
47 1.1.1.2 christos then these maximum sizes would be need to be recalculated and updated. */
48 1.1.1.2 christos #define ENOUGH_LENS 852
49 1.1.1.2 christos #define ENOUGH_DISTS 594
50 1.1.1.2 christos #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
51 1.1 christos
52 1.1.1.2 christos /* Type of code to build for inflate_table9() */
53 1.1 christos typedef enum {
54 1.1 christos CODES,
55 1.1 christos LENS,
56 1.1 christos DISTS
57 1.1 christos } codetype;
58 1.1 christos
59 1.1 christos extern int inflate_table9 OF((codetype type, unsigned short FAR *lens,
60 1.1 christos unsigned codes, code FAR * FAR *table,
61 1.1 christos unsigned FAR *bits, unsigned short FAR *work));
62