Path: blob/master/src/java.base/share/native/libzip/zlib/inftrees.h
41153 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324/* inftrees.h -- header to use inftrees.c25* Copyright (C) 1995-2005, 2010 Mark Adler26* For conditions of distribution and use, see copyright notice in zlib.h27*/2829/* WARNING: this file should *not* be used by applications. It is30part of the implementation of the compression library and is31subject to change. Applications should only use zlib.h.32*/3334/* Structure for decoding tables. Each entry provides either the35information needed to do the operation requested by the code that36indexed that table entry, or it provides a pointer to another37table that indexes more bits of the code. op indicates whether38the entry is a pointer to another table, a literal, a length or39distance, an end-of-block, or an invalid code. For a table40pointer, the low four bits of op is the number of index bits of41that table. For a length or distance, the low four bits of op42is the number of extra bits to get after the code. bits is43the number of bits in this code or part of the code to drop off44of the bit buffer. val is the actual byte to output in the case45of a literal, the base length or distance, or the offset from46the current table to the next table. Each entry is four bytes. */47typedef struct {48unsigned char op; /* operation, extra bits, table bits */49unsigned char bits; /* bits in this part of the code */50unsigned short val; /* offset in table or code value */51} code;5253/* op values as set by inflate_table():5400000000 - literal550000tttt - table link, tttt != 0 is the number of table index bits560001eeee - length or distance, eeee is the number of extra bits5701100000 - end of block5801000000 - invalid code59*/6061/* Maximum size of the dynamic table. The maximum number of code structures is621444, which is the sum of 852 for literal/length codes and 592 for distance63codes. These values were found by exhaustive searches using the program64examples/enough.c found in the zlib distribtution. The arguments to that65program are the number of symbols, the initial root table size, and the66maximum bit length of a code. "enough 286 9 15" for literal/length codes67returns returns 852, and "enough 30 6 15" for distance codes returns 592.68The initial root table size (9 or 6) is found in the fifth argument of the69inflate_table() calls in inflate.c and infback.c. If the root table size is70changed, then these maximum sizes would be need to be recalculated and71updated. */72#define ENOUGH_LENS 85273#define ENOUGH_DISTS 59274#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)7576/* Type of code to build for inflate_table() */77typedef enum {78CODES,79LENS,80DISTS81} codetype;8283int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,84unsigned codes, code FAR * FAR *table,85unsigned FAR *bits, unsigned short FAR *work));868788