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