1146392Smarius/* inftree9.h -- header to use inftree9.c 2146392Smarius * Copyright (C) 1995-2008 Mark Adler 3146392Smarius * For conditions of distribution and use, see copyright notice in zlib.h 4146392Smarius */ 5146392Smarius 6146392Smarius/* WARNING: this file should *not* be used by applications. It is 7146392Smarius part of the implementation of the compression library and is 8146392Smarius subject to change. Applications should only use zlib.h. 9146392Smarius */ 10146392Smarius 11146392Smarius/* Structure for decoding tables. Each entry provides either the 12146392Smarius information needed to do the operation requested by the code that 13146392Smarius indexed that table entry, or it provides a pointer to another 14146392Smarius table that indexes more bits of the code. op indicates whether 15146392Smarius the entry is a pointer to another table, a literal, a length or 16146392Smarius distance, an end-of-block, or an invalid code. For a table 17146392Smarius pointer, the low four bits of op is the number of index bits of 18146392Smarius that table. For a length or distance, the low four bits of op 19146392Smarius is the number of extra bits to get after the code. bits is 20146392Smarius the number of bits in this code or part of the code to drop off 21146392Smarius of the bit buffer. val is the actual byte to output in the case 22146392Smarius of a literal, the base length or distance, or the offset from 23146392Smarius the current table to the next table. Each entry is four bytes. */ 24146392Smariustypedef struct { 25146392Smarius unsigned char op; /* operation, extra bits, table bits */ 26146392Smarius unsigned char bits; /* bits in this part of the code */ 27146392Smarius unsigned short val; /* offset in table or code value */ 28146392Smarius} code; 29146392Smarius 30146392Smarius/* op values as set by inflate_table(): 31146392Smarius 00000000 - literal 32146392Smarius 0000tttt - table link, tttt != 0 is the number of table index bits 33146392Smarius 100eeeee - length or distance, eeee is the number of extra bits 34146392Smarius 01100000 - end of block 35146392Smarius 01000000 - invalid code 36146392Smarius */ 37146392Smarius 38146392Smarius/* Maximum size of the dynamic table. The maximum number of code structures is 39146392Smarius 1446, which is the sum of 852 for literal/length codes and 594 for distance 40146392Smarius codes. These values were found by exhaustive searches using the program 41146392Smarius examples/enough.c found in the zlib distribtution. The arguments to that 42146392Smarius program are the number of symbols, the initial root table size, and the 43146392Smarius maximum bit length of a code. "enough 286 9 15" for literal/length codes 44146392Smarius returns returns 852, and "enough 32 6 15" for distance codes returns 594. 45146392Smarius The initial root table size (9 or 6) is found in the fifth argument of the 46146392Smarius inflate_table() calls in infback9.c. If the root table size is changed, 47146392Smarius then these maximum sizes would be need to be recalculated and updated. */ 48146392Smarius#define ENOUGH_LENS 852 49146392Smarius#define ENOUGH_DISTS 594 50146392Smarius#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 51146392Smarius 52146392Smarius/* Type of code to build for inflate_table9() */ 53146392Smariustypedef enum { 54146392Smarius CODES, 55146392Smarius LENS, 56146392Smarius DISTS 57146392Smarius} codetype; 58146392Smarius 59146392Smariusextern int inflate_table9 OF((codetype type, unsigned short FAR *lens, 60146392Smarius unsigned codes, code FAR * FAR *table, 61146392Smarius unsigned FAR *bits, unsigned short FAR *work)); 62146392Smarius