1*bc22c17eSAlain Knaff #ifndef INFTREES_H 2*bc22c17eSAlain Knaff #define INFTREES_H 3*bc22c17eSAlain Knaff 41da177e4SLinus Torvalds /* inftrees.h -- header to use inftrees.c 54f3865fbSRichard Purdie * Copyright (C) 1995-2005 Mark Adler 61da177e4SLinus Torvalds * For conditions of distribution and use, see copyright notice in zlib.h 71da177e4SLinus Torvalds */ 81da177e4SLinus Torvalds 91da177e4SLinus Torvalds /* WARNING: this file should *not* be used by applications. It is 101da177e4SLinus Torvalds part of the implementation of the compression library and is 111da177e4SLinus Torvalds subject to change. Applications should only use zlib.h. 121da177e4SLinus Torvalds */ 131da177e4SLinus Torvalds 144f3865fbSRichard Purdie /* Structure for decoding tables. Each entry provides either the 154f3865fbSRichard Purdie information needed to do the operation requested by the code that 164f3865fbSRichard Purdie indexed that table entry, or it provides a pointer to another 174f3865fbSRichard Purdie table that indexes more bits of the code. op indicates whether 184f3865fbSRichard Purdie the entry is a pointer to another table, a literal, a length or 194f3865fbSRichard Purdie distance, an end-of-block, or an invalid code. For a table 204f3865fbSRichard Purdie pointer, the low four bits of op is the number of index bits of 214f3865fbSRichard Purdie that table. For a length or distance, the low four bits of op 224f3865fbSRichard Purdie is the number of extra bits to get after the code. bits is 234f3865fbSRichard Purdie the number of bits in this code or part of the code to drop off 244f3865fbSRichard Purdie of the bit buffer. val is the actual byte to output in the case 254f3865fbSRichard Purdie of a literal, the base length or distance, or the offset from 264f3865fbSRichard Purdie the current table to the next table. Each entry is four bytes. */ 274f3865fbSRichard Purdie typedef struct { 284f3865fbSRichard Purdie unsigned char op; /* operation, extra bits, table bits */ 294f3865fbSRichard Purdie unsigned char bits; /* bits in this part of the code */ 304f3865fbSRichard Purdie unsigned short val; /* offset in table or code value */ 314f3865fbSRichard Purdie } code; 321da177e4SLinus Torvalds 334f3865fbSRichard Purdie /* op values as set by inflate_table(): 344f3865fbSRichard Purdie 00000000 - literal 354f3865fbSRichard Purdie 0000tttt - table link, tttt != 0 is the number of table index bits 364f3865fbSRichard Purdie 0001eeee - length or distance, eeee is the number of extra bits 374f3865fbSRichard Purdie 01100000 - end of block 384f3865fbSRichard Purdie 01000000 - invalid code 394f3865fbSRichard Purdie */ 401da177e4SLinus Torvalds 411da177e4SLinus Torvalds /* Maximum size of dynamic tree. The maximum found in a long but non- 424f3865fbSRichard Purdie exhaustive search was 1444 code structures (852 for length/literals 434f3865fbSRichard Purdie and 592 for distances, the latter actually the result of an 444f3865fbSRichard Purdie exhaustive search). The true maximum is not known, but the value 454f3865fbSRichard Purdie below is more than safe. */ 464f3865fbSRichard Purdie #define ENOUGH 2048 474f3865fbSRichard Purdie #define MAXD 592 481da177e4SLinus Torvalds 494f3865fbSRichard Purdie /* Type of code to build for inftable() */ 504f3865fbSRichard Purdie typedef enum { 514f3865fbSRichard Purdie CODES, 524f3865fbSRichard Purdie LENS, 534f3865fbSRichard Purdie DISTS 544f3865fbSRichard Purdie } codetype; 551da177e4SLinus Torvalds 564f3865fbSRichard Purdie extern int zlib_inflate_table (codetype type, unsigned short *lens, 574f3865fbSRichard Purdie unsigned codes, code **table, 584f3865fbSRichard Purdie unsigned *bits, unsigned short *work); 59*bc22c17eSAlain Knaff #endif 60