1 /* |
|
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
3 * |
|
4 * This code is free software; you can redistribute it and/or modify it |
|
5 * under the terms of the GNU General Public License version 2 only, as |
|
6 * published by the Free Software Foundation. Oracle designates this |
|
7 * particular file as subject to the "Classpath" exception as provided |
|
8 * by Oracle in the LICENSE file that accompanied this code. |
|
9 * |
|
10 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 * version 2 for more details (a copy is included in the LICENSE file that |
|
14 * accompanied this code). |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License version |
|
17 * 2 along with this work; if not, write to the Free Software Foundation, |
|
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 * |
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 * or visit www.oracle.com if you need additional information or have any |
|
22 * questions. |
|
23 */ |
|
24 |
|
25 /* inftrees.h -- header to use inftrees.c |
|
26 * Copyright (C) 1995-2005, 2010 Mark Adler |
|
27 * For conditions of distribution and use, see copyright notice in zlib.h |
|
28 */ |
|
29 |
|
30 /* WARNING: this file should *not* be used by applications. It is |
|
31 part of the implementation of the compression library and is |
|
32 subject to change. Applications should only use zlib.h. |
|
33 */ |
|
34 |
|
35 /* Structure for decoding tables. Each entry provides either the |
|
36 information needed to do the operation requested by the code that |
|
37 indexed that table entry, or it provides a pointer to another |
|
38 table that indexes more bits of the code. op indicates whether |
|
39 the entry is a pointer to another table, a literal, a length or |
|
40 distance, an end-of-block, or an invalid code. For a table |
|
41 pointer, the low four bits of op is the number of index bits of |
|
42 that table. For a length or distance, the low four bits of op |
|
43 is the number of extra bits to get after the code. bits is |
|
44 the number of bits in this code or part of the code to drop off |
|
45 of the bit buffer. val is the actual byte to output in the case |
|
46 of a literal, the base length or distance, or the offset from |
|
47 the current table to the next table. Each entry is four bytes. */ |
|
48 typedef struct { |
|
49 unsigned char op; /* operation, extra bits, table bits */ |
|
50 unsigned char bits; /* bits in this part of the code */ |
|
51 unsigned short val; /* offset in table or code value */ |
|
52 } code; |
|
53 |
|
54 /* op values as set by inflate_table(): |
|
55 00000000 - literal |
|
56 0000tttt - table link, tttt != 0 is the number of table index bits |
|
57 0001eeee - length or distance, eeee is the number of extra bits |
|
58 01100000 - end of block |
|
59 01000000 - invalid code |
|
60 */ |
|
61 |
|
62 /* Maximum size of the dynamic table. The maximum number of code structures is |
|
63 1444, which is the sum of 852 for literal/length codes and 592 for distance |
|
64 codes. These values were found by exhaustive searches using the program |
|
65 examples/enough.c found in the zlib distribtution. The arguments to that |
|
66 program are the number of symbols, the initial root table size, and the |
|
67 maximum bit length of a code. "enough 286 9 15" for literal/length codes |
|
68 returns returns 852, and "enough 30 6 15" for distance codes returns 592. |
|
69 The initial root table size (9 or 6) is found in the fifth argument of the |
|
70 inflate_table() calls in inflate.c and infback.c. If the root table size is |
|
71 changed, then these maximum sizes would be need to be recalculated and |
|
72 updated. */ |
|
73 #define ENOUGH_LENS 852 |
|
74 #define ENOUGH_DISTS 592 |
|
75 #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) |
|
76 |
|
77 /* Type of code to build for inflate_table() */ |
|
78 typedef enum { |
|
79 CODES, |
|
80 LENS, |
|
81 DISTS |
|
82 } codetype; |
|
83 |
|
84 int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, |
|
85 unsigned codes, code FAR * FAR *table, |
|
86 unsigned FAR *bits, unsigned short FAR *work)); |
|