xref: /titanic_44/usr/src/uts/common/zmod/inftrees.h (revision a1e4879402b1a0a7c410577cff81f1ce31ace7af)
1 /* inftrees.h -- header to use inftrees.c
2  * Copyright (C) 1995-2005 Mark Adler
3  * For conditions of distribution and use, see copyright notice in zlib.h
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
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 dynamic tree.  The maximum found in a long but non-
41    exhaustive search was 1444 code structures (852 for length/literals
42    and 592 for distances, the latter actually the result of an
43    exhaustive search).  The true maximum is not known, but the value
44    below is more than safe. */
45 #define ENOUGH 2048
46 #define MAXD 592
47 
48 /* Type of code to build for inftable() */
49 typedef enum {
50     CODES,
51     LENS,
52     DISTS
53 } codetype;
54 
55 extern int inflate_table OF((codetype type, unsigned short FAR *lens,
56                              unsigned codes, code FAR * FAR *table,
57                              unsigned FAR *bits, unsigned short FAR *work));
58