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