|
version 1.1, 2012/02/17 15:09:30
|
version 1.1.1.2, 2013/10/14 07:51:14
|
|
Line 1
|
Line 1
|
| /* inflate.h -- internal inflate state definition |
/* inflate.h -- internal inflate state definition |
| * Copyright (C) 1995-2004 Mark Adler | * Copyright (C) 1995-2009 Mark Adler |
| * For conditions of distribution and use, see copyright notice in zlib.h |
* For conditions of distribution and use, see copyright notice in zlib.h |
| */ |
*/ |
| |
|
|
Line 36 typedef enum {
|
Line 36 typedef enum {
|
| TYPE, /* i: waiting for type bits, including last-flag bit */ |
TYPE, /* i: waiting for type bits, including last-flag bit */ |
| TYPEDO, /* i: same, but skip check to exit inflate on new block */ |
TYPEDO, /* i: same, but skip check to exit inflate on new block */ |
| STORED, /* i: waiting for stored size (length and complement) */ |
STORED, /* i: waiting for stored size (length and complement) */ |
| |
COPY_, /* i/o: same as COPY below, but only first time in */ |
| COPY, /* i/o: waiting for input or output to copy stored block */ |
COPY, /* i/o: waiting for input or output to copy stored block */ |
| TABLE, /* i: waiting for dynamic block table lengths */ |
TABLE, /* i: waiting for dynamic block table lengths */ |
| LENLENS, /* i: waiting for code length code lengths */ |
LENLENS, /* i: waiting for code length code lengths */ |
| CODELENS, /* i: waiting for length/lit and distance code lengths */ |
CODELENS, /* i: waiting for length/lit and distance code lengths */ |
| LEN, /* i: waiting for length/lit code */ | LEN_, /* i: same as LEN below, but only first time in */ |
| | LEN, /* i: waiting for length/lit/eob code */ |
| LENEXT, /* i: waiting for length extra bits */ |
LENEXT, /* i: waiting for length extra bits */ |
| DIST, /* i: waiting for distance code */ |
DIST, /* i: waiting for distance code */ |
| DISTEXT, /* i: waiting for distance extra bits */ |
DISTEXT, /* i: waiting for distance extra bits */ |
|
Line 57 typedef enum {
|
Line 59 typedef enum {
|
| /* |
/* |
| State transitions between above modes - |
State transitions between above modes - |
| |
|
| (most modes can go to the BAD or MEM mode -- not shown for clarity) | (most modes can go to BAD or MEM on error -- not shown for clarity) |
| |
|
| Process header: |
Process header: |
| HEAD -> (gzip) or (zlib) | HEAD -> (gzip) or (zlib) or (raw) |
| (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME | (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> |
| NAME -> COMMENT -> HCRC -> TYPE | HCRC -> TYPE |
| (zlib) -> DICTID or TYPE |
(zlib) -> DICTID or TYPE |
| DICTID -> DICT -> TYPE |
DICTID -> DICT -> TYPE |
| |
(raw) -> TYPEDO |
| Read deflate blocks: |
Read deflate blocks: |
| TYPE -> STORED or TABLE or LEN or CHECK | TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK |
| STORED -> COPY -> TYPE | STORED -> COPY_ -> COPY -> TYPE |
| TABLE -> LENLENS -> CODELENS -> LEN | TABLE -> LENLENS -> CODELENS -> LEN_ |
| Read deflate codes: | LEN_ -> LEN |
| | Read deflate codes in fixed or dynamic block: |
| LEN -> LENEXT or LIT or TYPE |
LEN -> LENEXT or LIT or TYPE |
| LENEXT -> DIST -> DISTEXT -> MATCH -> LEN |
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN |
| LIT -> LEN |
LIT -> LEN |
|
Line 77 typedef enum {
|
Line 81 typedef enum {
|
| CHECK -> LENGTH -> DONE |
CHECK -> LENGTH -> DONE |
| */ |
*/ |
| |
|
| /* state maintained between inflate() calls. Approximately 7K bytes. */ | /* state maintained between inflate() calls. Approximately 10K bytes. */ |
| struct inflate_state { |
struct inflate_state { |
| inflate_mode mode; /* current inflate mode */ |
inflate_mode mode; /* current inflate mode */ |
| int last; /* true if processing last block */ |
int last; /* true if processing last block */ |
|
Line 92 struct inflate_state {
|
Line 96 struct inflate_state {
|
| unsigned wbits; /* log base 2 of requested window size */ |
unsigned wbits; /* log base 2 of requested window size */ |
| unsigned wsize; /* window size or zero if not using window */ |
unsigned wsize; /* window size or zero if not using window */ |
| unsigned whave; /* valid bytes in the window */ |
unsigned whave; /* valid bytes in the window */ |
| unsigned write; /* window write index */ | unsigned wnext; /* window write index */ |
| unsigned char FAR *window; /* allocated sliding window, if needed */ |
unsigned char FAR *window; /* allocated sliding window, if needed */ |
| /* bit accumulator */ |
/* bit accumulator */ |
| unsigned long hold; /* input bit accumulator */ |
unsigned long hold; /* input bit accumulator */ |
|
Line 116 struct inflate_state {
|
Line 120 struct inflate_state {
|
| unsigned short lens[320]; /* temporary storage for code lengths */ |
unsigned short lens[320]; /* temporary storage for code lengths */ |
| unsigned short work[288]; /* work area for code table building */ |
unsigned short work[288]; /* work area for code table building */ |
| code codes[ENOUGH]; /* space for code tables */ |
code codes[ENOUGH]; /* space for code tables */ |
| |
int sane; /* if false, allow invalid distance too far */ |
| |
int back; /* bits back of last unprocessed length/lit */ |
| |
unsigned was; /* initial length of match */ |
| }; |
}; |