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