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