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