![]() |
|
|||
File indexing completed on 2025-05-11 08:24:11
0001 /* inflate.h -- internal inflate state definition 0002 * Copyright (C) 1995-2019 Mark Adler 0003 * For conditions of distribution and use, see copyright notice in zlib.h 0004 */ 0005 0006 /* WARNING: this file should *not* be used by applications. It is 0007 part of the implementation of the compression library and is 0008 subject to change. Applications should only use zlib.h. 0009 */ 0010 0011 /* define NO_GZIP when compiling if you want to disable gzip header and 0012 trailer decoding by inflate(). NO_GZIP would be used to avoid linking in 0013 the crc code when it is not needed. For shared libraries, gzip decoding 0014 should be left enabled. */ 0015 #ifndef NO_GZIP 0016 # define GUNZIP 0017 #endif 0018 0019 /* Possible inflate modes between inflate() calls */ 0020 typedef enum { 0021 HEAD = 16180, /* i: waiting for magic header */ 0022 FLAGS, /* i: waiting for method and flags (gzip) */ 0023 TIME, /* i: waiting for modification time (gzip) */ 0024 OS, /* i: waiting for extra flags and operating system (gzip) */ 0025 EXLEN, /* i: waiting for extra length (gzip) */ 0026 EXTRA, /* i: waiting for extra bytes (gzip) */ 0027 NAME, /* i: waiting for end of file name (gzip) */ 0028 COMMENT, /* i: waiting for end of comment (gzip) */ 0029 HCRC, /* i: waiting for header crc (gzip) */ 0030 DICTID, /* i: waiting for dictionary check value */ 0031 DICT, /* waiting for inflateSetDictionary() call */ 0032 TYPE, /* i: waiting for type bits, including last-flag bit */ 0033 TYPEDO, /* i: same, but skip check to exit inflate on new block */ 0034 STORED, /* i: waiting for stored size (length and complement) */ 0035 COPY_, /* i/o: same as COPY below, but only first time in */ 0036 COPY, /* i/o: waiting for input or output to copy stored block */ 0037 TABLE, /* i: waiting for dynamic block table lengths */ 0038 LENLENS, /* i: waiting for code length code lengths */ 0039 CODELENS, /* i: waiting for length/lit and distance code lengths */ 0040 LEN_, /* i: same as LEN below, but only first time in */ 0041 LEN, /* i: waiting for length/lit/eob code */ 0042 LENEXT, /* i: waiting for length extra bits */ 0043 DIST, /* i: waiting for distance code */ 0044 DISTEXT, /* i: waiting for distance extra bits */ 0045 MATCH, /* o: waiting for output space to copy string */ 0046 LIT, /* o: waiting for output space to write literal */ 0047 CHECK, /* i: waiting for 32-bit check value */ 0048 LENGTH, /* i: waiting for 32-bit length (gzip) */ 0049 DONE, /* finished check, done -- remain here until reset */ 0050 BAD, /* got a data error -- remain here until reset */ 0051 MEM, /* got an inflate() memory error -- remain here until reset */ 0052 SYNC /* looking for synchronization bytes to restart inflate() */ 0053 } inflate_mode; 0054 0055 /* 0056 State transitions between above modes - 0057 0058 (most modes can go to BAD or MEM on error -- not shown for clarity) 0059 0060 Process header: 0061 HEAD -> (gzip) or (zlib) or (raw) 0062 (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> 0063 HCRC -> TYPE 0064 (zlib) -> DICTID or TYPE 0065 DICTID -> DICT -> TYPE 0066 (raw) -> TYPEDO 0067 Read deflate blocks: 0068 TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK 0069 STORED -> COPY_ -> COPY -> TYPE 0070 TABLE -> LENLENS -> CODELENS -> LEN_ 0071 LEN_ -> LEN 0072 Read deflate codes in fixed or dynamic block: 0073 LEN -> LENEXT or LIT or TYPE 0074 LENEXT -> DIST -> DISTEXT -> MATCH -> LEN 0075 LIT -> LEN 0076 Process trailer: 0077 CHECK -> LENGTH -> DONE 0078 */ 0079 0080 /* State maintained between inflate() calls -- approximately 7K bytes, not 0081 including the allocated sliding window, which is up to 32K bytes. */ 0082 struct inflate_state { 0083 z_streamp strm; /* pointer back to this zlib stream */ 0084 inflate_mode mode; /* current inflate mode */ 0085 int last; /* true if processing last block */ 0086 int wrap; /* bit 0 true for zlib, bit 1 true for gzip, 0087 bit 2 true to validate check value */ 0088 int havedict; /* true if dictionary provided */ 0089 int flags; /* gzip header method and flags, 0 if zlib, or 0090 -1 if raw or no header yet */ 0091 unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ 0092 unsigned long check; /* protected copy of check value */ 0093 unsigned long total; /* protected copy of output count */ 0094 gz_headerp head; /* where to save gzip header information */ 0095 /* sliding window */ 0096 unsigned wbits; /* log base 2 of requested window size */ 0097 unsigned wsize; /* window size or zero if not using window */ 0098 unsigned whave; /* valid bytes in the window */ 0099 unsigned wnext; /* window write index */ 0100 unsigned char FAR *window; /* allocated sliding window, if needed */ 0101 /* bit accumulator */ 0102 unsigned long hold; /* input bit accumulator */ 0103 unsigned bits; /* number of bits in "in" */ 0104 /* for string and stored block copying */ 0105 unsigned length; /* literal or length of data to copy */ 0106 unsigned offset; /* distance back to copy string from */ 0107 /* for table and code decoding */ 0108 unsigned extra; /* extra bits needed */ 0109 /* fixed and dynamic code tables */ 0110 code const FAR *lencode; /* starting table for length/literal codes */ 0111 code const FAR *distcode; /* starting table for distance codes */ 0112 unsigned lenbits; /* index bits for lencode */ 0113 unsigned distbits; /* index bits for distcode */ 0114 /* dynamic table building */ 0115 unsigned ncode; /* number of code length code lengths */ 0116 unsigned nlen; /* number of length code lengths */ 0117 unsigned ndist; /* number of distance code lengths */ 0118 unsigned have; /* number of code lengths in lens[] */ 0119 code FAR *next; /* next available space in codes[] */ 0120 unsigned short lens[320]; /* temporary storage for code lengths */ 0121 unsigned short work[288]; /* work area for code table building */ 0122 code codes[ENOUGH]; /* space for code tables */ 0123 int sane; /* if false, allow invalid distance too far */ 0124 int back; /* bits back of last unprocessed length/lit */ 0125 unsigned was; /* initial length of match */ 0126 };
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |