ZLIB
Loading...
Searching...
No Matches
inflate.h
Go to the documentation of this file.
1
13/* define NO_GZIP when compiling if you want to disable gzip header and
14 trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
15 the crc code when it is not needed. For shared libraries, gzip decoding
16 should be left enabled. */
17#ifndef NO_GZIP
18# define GUNZIP
19#endif
20
22typedef enum {
23 HEAD = 16180,
49 CHECK, /*<! i: waiting for 32-bit check value */
50 LENGTH, /*<! i: waiting for 32-bit length (gzip) */
51 DONE, /*<! finished check, done -- remain here until reset */
52 BAD, /*<! got a data error -- remain here until reset */
53 MEM, /*<! got an inflate() memory error -- remain here until reset */
54 SYNC /*<! looking for synchronization bytes to restart inflate() */
56
57/*
58 State transitions between above modes -
59
60 (most modes can go to BAD or MEM on error -- not shown for clarity)
61
62 Process header:
63 HEAD -> (gzip) or (zlib) or (raw)
64 (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
65 HCRC -> TYPE
66 (zlib) -> DICTID or TYPE
67 DICTID -> DICT -> TYPE
68 (raw) -> TYPEDO
69 Read deflate blocks:
70 TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
71 STORED -> COPY_ -> COPY -> TYPE
72 TABLE -> LENLENS -> CODELENS -> LEN_
73 LEN_ -> LEN
74 Read deflate codes in fixed or dynamic block:
75 LEN -> LENEXT or LIT or TYPE
76 LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
77 LIT -> LEN
78 Process trailer:
79 CHECK -> LENGTH -> DONE
80 */
81
87 int last;
88 int wrap;
91 int flags;
93 unsigned dmax;
94 unsigned long check;
95 unsigned long total;
99 unsigned wbits;
100 unsigned wsize;
101 unsigned whave;
102 unsigned wnext;
103 unsigned char FAR *window;
106 unsigned long hold;
107 unsigned bits;
110 unsigned length;
111 unsigned offset;
114 unsigned extra;
117 code const FAR *lencode;
118 code const FAR *distcode;
119 unsigned lenbits;
120 unsigned distbits;
123 unsigned ncode;
124 unsigned nlen;
125 unsigned ndist;
126 unsigned have;
127 code FAR *next;
128 unsigned short lens[320];
129 unsigned short work[288];
130 code codes[ENOUGH];
131 int sane;
132 int back;
133 unsigned was;
134};
inflate_mode
Possible inflate modes between inflate() calls.
Definition inflate.h:22
@ HEAD
i: waiting for magic header
Definition inflate.h:23
@ MATCH
o: waiting for output space to copy string
Definition inflate.h:47
@ DICT
waiting for inflateSetDictionary() call
Definition inflate.h:33
@ TABLE
i: waiting for dynamic block table lengths
Definition inflate.h:39
@ FLAGS
i: waiting for method and flags (gzip)
Definition inflate.h:24
@ LIT
o: waiting for output space to write literal
Definition inflate.h:48
@ OS
i: waiting for extra flags and operating system (gzip)
Definition inflate.h:26
@ EXLEN
i: waiting for extra length (gzip)
Definition inflate.h:27
@ NAME
i: waiting for end of file name (gzip)
Definition inflate.h:29
@ STORED
i: waiting for stored size (length and complement)
Definition inflate.h:36
@ CODELENS
i: waiting for length/lit and distance code lengths
Definition inflate.h:41
@ DICTID
i: waiting for dictionary check value
Definition inflate.h:32
@ TYPEDO
i: same, but skip check to exit inflate on new block
Definition inflate.h:35
@ COMMENT
i: waiting for end of comment (gzip)
Definition inflate.h:30
@ LENLENS
i: waiting for code length code lengths
Definition inflate.h:40
@ TYPE
i: waiting for type bits, including last-flag bit
Definition inflate.h:34
@ COPY
i/o: waiting for input or output to copy stored block
Definition inflate.h:38
@ LEN_
i: same as LEN below, but only first time in
Definition inflate.h:42
@ COPY_
i/o: same as COPY below, but only first time in
Definition inflate.h:37
@ DIST
i: waiting for distance code
Definition inflate.h:45
@ LENEXT
i: waiting for length extra bits
Definition inflate.h:44
@ HCRC
i: waiting for header crc (gzip)
Definition inflate.h:31
@ TIME
i: waiting for modification time (gzip)
Definition inflate.h:25
@ DISTEXT
i: waiting for distance extra bits
Definition inflate.h:46
@ LEN
i: waiting for length/lit/eob code
Definition inflate.h:43
@ EXTRA
i: waiting for extra bytes (gzip)
Definition inflate.h:28
Structure for decoding tables.
Definition inftrees.h:28
gzip header information passed to and from zlib routines.
Definition zlib.h:164
State maintained between inflate() calls – approximately 7K bytes, not including the allocated slidin...
Definition inflate.h:84
code const FAR * distcode
{ starting table for length/literal codes
Definition inflate.h:118
unsigned wnext
window write index
Definition inflate.h:102
int havedict
true if dictionary provided
Definition inflate.h:90
unsigned lenbits
{ starting table for distance codes
Definition inflate.h:119
unsigned ndist
number of distance code lengths
Definition inflate.h:125
unsigned nlen
number of length code lengths
Definition inflate.h:124
unsigned have
number of code lengths in lens[]
Definition inflate.h:126
unsigned length
literal or length of data to copy
Definition inflate.h:110
unsigned long hold
input bit accumulator
Definition inflate.h:106
unsigned ncode
number of code length code lengths
Definition inflate.h:123
z_streamp strm
pointer back to this zlib stream
Definition inflate.h:85
unsigned whave
valid bytes in the window
Definition inflate.h:101
unsigned wbits
log base 2 of requested window size
Definition inflate.h:99
unsigned short work[288]
work area for code table building
Definition inflate.h:129
code FAR * next
next available space in codes[]
Definition inflate.h:127
unsigned distbits
{ index bits for lencode
Definition inflate.h:120
int sane
if false, allow invalid distance too far
Definition inflate.h:131
int wrap
bit 0 true for zlib, bit 1 true for gzip, bit 2 true to validate check value
Definition inflate.h:88
inflate_mode mode
current inflate mode
Definition inflate.h:86
int flags
gzip header method and flags, 0 if zlib, or -1 if raw or no header yet
Definition inflate.h:91
unsigned short lens[320]
temporary storage for code lengths
Definition inflate.h:128
gz_headerp head
where to save gzip header information
Definition inflate.h:96
int last
true if processing last block
Definition inflate.h:87
int back
bits back of last unprocessed length/lit
Definition inflate.h:132
unsigned wsize
window size or zero if not using window
Definition inflate.h:100
unsigned dmax
zlib header max distance (INFLATE_STRICT)
Definition inflate.h:93
unsigned long check
protected copy of check value
Definition inflate.h:94
code codes[ENOUGH]
space for code tables
Definition inflate.h:130
unsigned long total
protected copy of output count
Definition inflate.h:95
Compressed stream state information.
Definition zlib.h:136