Fossil SCM

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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button