xref: /minix3/common/dist/zlib/contrib/infback9/inftree9.h (revision 44bedb31d842b4b0444105519bcf929a69fe2dc1)
1*44bedb31SLionel Sambuc /*	$NetBSD: inftree9.h,v 1.1.1.1 2006/01/14 20:10:52 christos Exp $	*/
2*44bedb31SLionel Sambuc 
3*44bedb31SLionel Sambuc /* inftree9.h -- header to use inftree9.c
4*44bedb31SLionel Sambuc  * Copyright (C) 1995-2003 Mark Adler
5*44bedb31SLionel Sambuc  * For conditions of distribution and use, see copyright notice in zlib.h
6*44bedb31SLionel Sambuc  */
7*44bedb31SLionel Sambuc 
8*44bedb31SLionel Sambuc /* WARNING: this file should *not* be used by applications. It is
9*44bedb31SLionel Sambuc    part of the implementation of the compression library and is
10*44bedb31SLionel Sambuc    subject to change. Applications should only use zlib.h.
11*44bedb31SLionel Sambuc  */
12*44bedb31SLionel Sambuc 
13*44bedb31SLionel Sambuc /* Structure for decoding tables.  Each entry provides either the
14*44bedb31SLionel Sambuc    information needed to do the operation requested by the code that
15*44bedb31SLionel Sambuc    indexed that table entry, or it provides a pointer to another
16*44bedb31SLionel Sambuc    table that indexes more bits of the code.  op indicates whether
17*44bedb31SLionel Sambuc    the entry is a pointer to another table, a literal, a length or
18*44bedb31SLionel Sambuc    distance, an end-of-block, or an invalid code.  For a table
19*44bedb31SLionel Sambuc    pointer, the low four bits of op is the number of index bits of
20*44bedb31SLionel Sambuc    that table.  For a length or distance, the low four bits of op
21*44bedb31SLionel Sambuc    is the number of extra bits to get after the code.  bits is
22*44bedb31SLionel Sambuc    the number of bits in this code or part of the code to drop off
23*44bedb31SLionel Sambuc    of the bit buffer.  val is the actual byte to output in the case
24*44bedb31SLionel Sambuc    of a literal, the base length or distance, or the offset from
25*44bedb31SLionel Sambuc    the current table to the next table.  Each entry is four bytes. */
26*44bedb31SLionel Sambuc typedef struct {
27*44bedb31SLionel Sambuc     unsigned char op;           /* operation, extra bits, table bits */
28*44bedb31SLionel Sambuc     unsigned char bits;         /* bits in this part of the code */
29*44bedb31SLionel Sambuc     unsigned short val;         /* offset in table or code value */
30*44bedb31SLionel Sambuc } code;
31*44bedb31SLionel Sambuc 
32*44bedb31SLionel Sambuc /* op values as set by inflate_table():
33*44bedb31SLionel Sambuc     00000000 - literal
34*44bedb31SLionel Sambuc     0000tttt - table link, tttt != 0 is the number of table index bits
35*44bedb31SLionel Sambuc     100eeeee - length or distance, eeee is the number of extra bits
36*44bedb31SLionel Sambuc     01100000 - end of block
37*44bedb31SLionel Sambuc     01000000 - invalid code
38*44bedb31SLionel Sambuc  */
39*44bedb31SLionel Sambuc 
40*44bedb31SLionel Sambuc /* Maximum size of dynamic tree.  The maximum found in a long but non-
41*44bedb31SLionel Sambuc    exhaustive search was 1444 code structures (852 for length/literals
42*44bedb31SLionel Sambuc    and 592 for distances, the latter actually the result of an
43*44bedb31SLionel Sambuc    exhaustive search).  The true maximum is not known, but the value
44*44bedb31SLionel Sambuc    below is more than safe. */
45*44bedb31SLionel Sambuc #define ENOUGH 2048
46*44bedb31SLionel Sambuc #define MAXD 592
47*44bedb31SLionel Sambuc 
48*44bedb31SLionel Sambuc /* Type of code to build for inftable() */
49*44bedb31SLionel Sambuc typedef enum {
50*44bedb31SLionel Sambuc     CODES,
51*44bedb31SLionel Sambuc     LENS,
52*44bedb31SLionel Sambuc     DISTS
53*44bedb31SLionel Sambuc } codetype;
54*44bedb31SLionel Sambuc 
55*44bedb31SLionel Sambuc extern int inflate_table9 OF((codetype type, unsigned short FAR *lens,
56*44bedb31SLionel Sambuc                              unsigned codes, code FAR * FAR *table,
57*44bedb31SLionel Sambuc                              unsigned FAR *bits, unsigned short FAR *work));
58