xref: /titanic_50/usr/src/uts/common/zmod/inftrees.h (revision c9431fa1e59a88c2f0abf611f25b97af964449e5)
1*c9431fa1Sahl /* inftrees.h -- header to use inftrees.c
2*c9431fa1Sahl  * Copyright (C) 1995-2005 Mark Adler
37c478bd9Sstevel@tonic-gate  * For conditions of distribution and use, see copyright notice in zlib.h
47c478bd9Sstevel@tonic-gate  */
57c478bd9Sstevel@tonic-gate 
67c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
77c478bd9Sstevel@tonic-gate 
8*c9431fa1Sahl /* WARNING: this file should *not* be used by applications. It is
9*c9431fa1Sahl    part of the implementation of the compression library and is
10*c9431fa1Sahl    subject to change. Applications should only use zlib.h.
11*c9431fa1Sahl  */
127c478bd9Sstevel@tonic-gate 
13*c9431fa1Sahl /* Structure for decoding tables.  Each entry provides either the
14*c9431fa1Sahl    information needed to do the operation requested by the code that
15*c9431fa1Sahl    indexed that table entry, or it provides a pointer to another
16*c9431fa1Sahl    table that indexes more bits of the code.  op indicates whether
17*c9431fa1Sahl    the entry is a pointer to another table, a literal, a length or
18*c9431fa1Sahl    distance, an end-of-block, or an invalid code.  For a table
19*c9431fa1Sahl    pointer, the low four bits of op is the number of index bits of
20*c9431fa1Sahl    that table.  For a length or distance, the low four bits of op
21*c9431fa1Sahl    is the number of extra bits to get after the code.  bits is
22*c9431fa1Sahl    the number of bits in this code or part of the code to drop off
23*c9431fa1Sahl    of the bit buffer.  val is the actual byte to output in the case
24*c9431fa1Sahl    of a literal, the base length or distance, or the offset from
25*c9431fa1Sahl    the current table to the next table.  Each entry is four bytes. */
26*c9431fa1Sahl typedef struct {
27*c9431fa1Sahl     unsigned char op;           /* operation, extra bits, table bits */
28*c9431fa1Sahl     unsigned char bits;         /* bits in this part of the code */
29*c9431fa1Sahl     unsigned short val;         /* offset in table or code value */
30*c9431fa1Sahl } code;
317c478bd9Sstevel@tonic-gate 
32*c9431fa1Sahl /* op values as set by inflate_table():
33*c9431fa1Sahl     00000000 - literal
34*c9431fa1Sahl     0000tttt - table link, tttt != 0 is the number of table index bits
35*c9431fa1Sahl     0001eeee - length or distance, eeee is the number of extra bits
36*c9431fa1Sahl     01100000 - end of block
37*c9431fa1Sahl     01000000 - invalid code
38*c9431fa1Sahl  */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /* Maximum size of dynamic tree.  The maximum found in a long but non-
41*c9431fa1Sahl    exhaustive search was 1444 code structures (852 for length/literals
42*c9431fa1Sahl    and 592 for distances, the latter actually the result of an
43*c9431fa1Sahl    exhaustive search).  The true maximum is not known, but the value
44*c9431fa1Sahl    below is more than safe. */
45*c9431fa1Sahl #define ENOUGH 2048
46*c9431fa1Sahl #define MAXD 592
477c478bd9Sstevel@tonic-gate 
48*c9431fa1Sahl /* Type of code to build for inftable() */
49*c9431fa1Sahl typedef enum {
50*c9431fa1Sahl     CODES,
51*c9431fa1Sahl     LENS,
52*c9431fa1Sahl     DISTS
53*c9431fa1Sahl } codetype;
547c478bd9Sstevel@tonic-gate 
55*c9431fa1Sahl extern int inflate_table OF((codetype type, unsigned short FAR *lens,
56*c9431fa1Sahl                              unsigned codes, code FAR * FAR *table,
57*c9431fa1Sahl                              unsigned FAR *bits, unsigned short FAR *work));
58