OLD | NEW |
1 /* inflate.h -- internal inflate state definition | 1 /* inflate.h -- internal inflate state definition |
2 * Copyright (C) 1995-2009 Mark Adler | 2 * Copyright (C) 1995-2016 Mark Adler |
3 * For conditions of distribution and use, see copyright notice in zlib.h | 3 * For conditions of distribution and use, see copyright notice in zlib.h |
4 */ | 4 */ |
5 | 5 |
6 /* WARNING: this file should *not* be used by applications. It is | 6 /* WARNING: this file should *not* be used by applications. It is |
7 part of the implementation of the compression library and is | 7 part of the implementation of the compression library and is |
8 subject to change. Applications should only use zlib.h. | 8 subject to change. Applications should only use zlib.h. |
9 */ | 9 */ |
10 | 10 |
11 /* define NO_GZIP when compiling if you want to disable gzip header and | 11 /* define NO_GZIP when compiling if you want to disable gzip header and |
12 trailer decoding by inflate(). NO_GZIP would be used to avoid linking in | 12 trailer decoding by inflate(). NO_GZIP would be used to avoid linking in |
13 the crc code when it is not needed. For shared libraries, gzip decoding | 13 the crc code when it is not needed. For shared libraries, gzip decoding |
14 should be left enabled. */ | 14 should be left enabled. */ |
15 #ifndef NO_GZIP | 15 #ifndef NO_GZIP |
16 # define GUNZIP | 16 # define GUNZIP |
17 #endif | 17 #endif |
18 | 18 |
19 /* Possible inflate modes between inflate() calls */ | 19 /* Possible inflate modes between inflate() calls */ |
20 typedef enum { | 20 typedef enum { |
21 HEAD, /* i: waiting for magic header */ | 21 HEAD = 16180, /* i: waiting for magic header */ |
22 FLAGS, /* i: waiting for method and flags (gzip) */ | 22 FLAGS, /* i: waiting for method and flags (gzip) */ |
23 TIME, /* i: waiting for modification time (gzip) */ | 23 TIME, /* i: waiting for modification time (gzip) */ |
24 OS, /* i: waiting for extra flags and operating system (gzip) */ | 24 OS, /* i: waiting for extra flags and operating system (gzip) */ |
25 EXLEN, /* i: waiting for extra length (gzip) */ | 25 EXLEN, /* i: waiting for extra length (gzip) */ |
26 EXTRA, /* i: waiting for extra bytes (gzip) */ | 26 EXTRA, /* i: waiting for extra bytes (gzip) */ |
27 NAME, /* i: waiting for end of file name (gzip) */ | 27 NAME, /* i: waiting for end of file name (gzip) */ |
28 COMMENT, /* i: waiting for end of comment (gzip) */ | 28 COMMENT, /* i: waiting for end of comment (gzip) */ |
29 HCRC, /* i: waiting for header crc (gzip) */ | 29 HCRC, /* i: waiting for header crc (gzip) */ |
30 DICTID, /* i: waiting for dictionary check value */ | 30 DICTID, /* i: waiting for dictionary check value */ |
31 DICT, /* waiting for inflateSetDictionary() call */ | 31 DICT, /* waiting for inflateSetDictionary() call */ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 TABLE -> LENLENS -> CODELENS -> LEN_ | 70 TABLE -> LENLENS -> CODELENS -> LEN_ |
71 LEN_ -> LEN | 71 LEN_ -> LEN |
72 Read deflate codes in fixed or dynamic block: | 72 Read deflate codes in fixed or dynamic block: |
73 LEN -> LENEXT or LIT or TYPE | 73 LEN -> LENEXT or LIT or TYPE |
74 LENEXT -> DIST -> DISTEXT -> MATCH -> LEN | 74 LENEXT -> DIST -> DISTEXT -> MATCH -> LEN |
75 LIT -> LEN | 75 LIT -> LEN |
76 Process trailer: | 76 Process trailer: |
77 CHECK -> LENGTH -> DONE | 77 CHECK -> LENGTH -> DONE |
78 */ | 78 */ |
79 | 79 |
80 /* state maintained between inflate() calls. Approximately 10K bytes. */ | 80 /* State maintained between inflate() calls -- approximately 7K bytes, not |
| 81 including the allocated sliding window, which is up to 32K bytes. */ |
81 struct inflate_state { | 82 struct inflate_state { |
| 83 z_streamp strm; /* pointer back to this zlib stream */ |
82 inflate_mode mode; /* current inflate mode */ | 84 inflate_mode mode; /* current inflate mode */ |
83 int last; /* true if processing last block */ | 85 int last; /* true if processing last block */ |
84 int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ | 86 int wrap; /* bit 0 true for zlib, bit 1 true for gzip, |
| 87 bit 2 true to validate check value */ |
85 int havedict; /* true if dictionary provided */ | 88 int havedict; /* true if dictionary provided */ |
86 int flags; /* gzip header method and flags (0 if zlib) */ | 89 int flags; /* gzip header method and flags (0 if zlib) */ |
87 unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ | 90 unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ |
88 unsigned long check; /* protected copy of check value */ | 91 unsigned long check; /* protected copy of check value */ |
89 unsigned long total; /* protected copy of output count */ | 92 unsigned long total; /* protected copy of output count */ |
90 gz_headerp head; /* where to save gzip header information */ | 93 gz_headerp head; /* where to save gzip header information */ |
91 /* sliding window */ | 94 /* sliding window */ |
92 unsigned wbits; /* log base 2 of requested window size */ | 95 unsigned wbits; /* log base 2 of requested window size */ |
93 unsigned wsize; /* window size or zero if not using window */ | 96 unsigned wsize; /* window size or zero if not using window */ |
94 unsigned whave; /* valid bytes in the window */ | 97 unsigned whave; /* valid bytes in the window */ |
(...skipping 18 matching lines...) Expand all Loading... |
113 unsigned ndist; /* number of distance code lengths */ | 116 unsigned ndist; /* number of distance code lengths */ |
114 unsigned have; /* number of code lengths in lens[] */ | 117 unsigned have; /* number of code lengths in lens[] */ |
115 code FAR *next; /* next available space in codes[] */ | 118 code FAR *next; /* next available space in codes[] */ |
116 unsigned short lens[320]; /* temporary storage for code lengths */ | 119 unsigned short lens[320]; /* temporary storage for code lengths */ |
117 unsigned short work[288]; /* work area for code table building */ | 120 unsigned short work[288]; /* work area for code table building */ |
118 code codes[ENOUGH]; /* space for code tables */ | 121 code codes[ENOUGH]; /* space for code tables */ |
119 int sane; /* if false, allow invalid distance too far */ | 122 int sane; /* if false, allow invalid distance too far */ |
120 int back; /* bits back of last unprocessed length/lit */ | 123 int back; /* bits back of last unprocessed length/lit */ |
121 unsigned was; /* initial length of match */ | 124 unsigned was; /* initial length of match */ |
122 }; | 125 }; |
OLD | NEW |