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