]> git.saurik.com Git - apple/xnu.git/blame - libkern/zlib/inftrees.h
xnu-1456.1.26.tar.gz
[apple/xnu.git] / libkern / zlib / inftrees.h
CommitLineData
b0d623f7
A
1/*
2 * Copyright (c) 2008 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/* inftrees.h -- header to use inftrees.c
29 * Copyright (C) 1995-2005 Mark Adler
30 * For conditions of distribution and use, see copyright notice in zlib.h
31 */
32
33/* WARNING: this file should *not* be used by applications. It is
34 part of the implementation of the compression library and is
35 subject to change. Applications should only use zlib.h.
36 */
37
38/* Structure for decoding tables. Each entry provides either the
39 information needed to do the operation requested by the code that
40 indexed that table entry, or it provides a pointer to another
41 table that indexes more bits of the code. op indicates whether
42 the entry is a pointer to another table, a literal, a length or
43 distance, an end-of-block, or an invalid code. For a table
44 pointer, the low four bits of op is the number of index bits of
45 that table. For a length or distance, the low four bits of op
46 is the number of extra bits to get after the code. bits is
47 the number of bits in this code or part of the code to drop off
48 of the bit buffer. val is the actual byte to output in the case
49 of a literal, the base length or distance, or the offset from
50 the current table to the next table. Each entry is four bytes. */
51typedef struct {
52 unsigned char op; /* operation, extra bits, table bits */
53 unsigned char bits; /* bits in this part of the code */
54 unsigned short val; /* offset in table or code value */
55} code;
56
57/* op values as set by inflate_table():
58 00000000 - literal
59 0000tttt - table link, tttt != 0 is the number of table index bits
60 0001eeee - length or distance, eeee is the number of extra bits
61 01100000 - end of block
62 01000000 - invalid code
63 */
64
65/* Maximum size of dynamic tree. The maximum found in a long but non-
66 exhaustive search was 1444 code structures (852 for length/literals
67 and 592 for distances, the latter actually the result of an
68 exhaustive search). The true maximum is not known, but the value
69 below is more than safe. */
70#define ENOUGH 2048
71#define MAXD 592
72
73/* Type of code to build for inftable() */
74typedef enum {
75 CODES,
76 LENS,
77 DISTS
78} codetype;
79
80extern int inflate_table OF((codetype type, unsigned short FAR *lens,
81 unsigned codes, code FAR * FAR *table,
82 unsigned FAR *bits, unsigned short FAR *work));