modules/zlib/src/inftrees.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* inftrees.h -- header to use inftrees.c
michael@0 2 * Copyright (C) 1995-2005, 2010 Mark Adler
michael@0 3 * For conditions of distribution and use, see copyright notice in zlib.h
michael@0 4 */
michael@0 5
michael@0 6 /* WARNING: this file should *not* be used by applications. It is
michael@0 7 part of the implementation of the compression library and is
michael@0 8 subject to change. Applications should only use zlib.h.
michael@0 9 */
michael@0 10
michael@0 11 /* Structure for decoding tables. Each entry provides either the
michael@0 12 information needed to do the operation requested by the code that
michael@0 13 indexed that table entry, or it provides a pointer to another
michael@0 14 table that indexes more bits of the code. op indicates whether
michael@0 15 the entry is a pointer to another table, a literal, a length or
michael@0 16 distance, an end-of-block, or an invalid code. For a table
michael@0 17 pointer, the low four bits of op is the number of index bits of
michael@0 18 that table. For a length or distance, the low four bits of op
michael@0 19 is the number of extra bits to get after the code. bits is
michael@0 20 the number of bits in this code or part of the code to drop off
michael@0 21 of the bit buffer. val is the actual byte to output in the case
michael@0 22 of a literal, the base length or distance, or the offset from
michael@0 23 the current table to the next table. Each entry is four bytes. */
michael@0 24 typedef struct {
michael@0 25 unsigned char op; /* operation, extra bits, table bits */
michael@0 26 unsigned char bits; /* bits in this part of the code */
michael@0 27 unsigned short val; /* offset in table or code value */
michael@0 28 } code;
michael@0 29
michael@0 30 /* op values as set by inflate_table():
michael@0 31 00000000 - literal
michael@0 32 0000tttt - table link, tttt != 0 is the number of table index bits
michael@0 33 0001eeee - length or distance, eeee is the number of extra bits
michael@0 34 01100000 - end of block
michael@0 35 01000000 - invalid code
michael@0 36 */
michael@0 37
michael@0 38 /* Maximum size of the dynamic table. The maximum number of code structures is
michael@0 39 1444, which is the sum of 852 for literal/length codes and 592 for distance
michael@0 40 codes. These values were found by exhaustive searches using the program
michael@0 41 examples/enough.c found in the zlib distribtution. The arguments to that
michael@0 42 program are the number of symbols, the initial root table size, and the
michael@0 43 maximum bit length of a code. "enough 286 9 15" for literal/length codes
michael@0 44 returns returns 852, and "enough 30 6 15" for distance codes returns 592.
michael@0 45 The initial root table size (9 or 6) is found in the fifth argument of the
michael@0 46 inflate_table() calls in inflate.c and infback.c. If the root table size is
michael@0 47 changed, then these maximum sizes would be need to be recalculated and
michael@0 48 updated. */
michael@0 49 #define ENOUGH_LENS 852
michael@0 50 #define ENOUGH_DISTS 592
michael@0 51 #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
michael@0 52
michael@0 53 /* Type of code to build for inflate_table() */
michael@0 54 typedef enum {
michael@0 55 CODES,
michael@0 56 LENS,
michael@0 57 DISTS
michael@0 58 } codetype;
michael@0 59
michael@0 60 int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
michael@0 61 unsigned codes, code FAR * FAR *table,
michael@0 62 unsigned FAR *bits, unsigned short FAR *work));

mercurial