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