Geant4 Cross Reference |
1 /* inflate.h -- internal inflate state definit 1 2 * Copyright (C) 1995-2019 Mark Adler 3 * For conditions of distribution and use, see 4 */ 5 6 /* WARNING: this file should *not* be used by 7 part of the implementation of the compressi 8 subject to change. Applications should only 9 */ 10 11 /* define NO_GZIP when compiling if you want t 12 trailer decoding by inflate(). NO_GZIP wou 13 the crc code when it is not needed. For sh 14 should be left enabled. */ 15 #ifndef NO_GZIP 16 # define GUNZIP 17 #endif 18 19 /* Possible inflate modes between inflate() ca 20 typedef enum { 21 HEAD = 16180, /* i: waiting for magic he 22 FLAGS, /* i: waiting for method and f 23 TIME, /* i: waiting for modification 24 OS, /* i: waiting for extra flags 25 EXLEN, /* i: waiting for extra length 26 EXTRA, /* i: waiting for extra bytes 27 NAME, /* i: waiting for end of file 28 COMMENT, /* i: waiting for end of comme 29 HCRC, /* i: waiting for header crc ( 30 DICTID, /* i: waiting for dictionary c 31 DICT, /* waiting for inflateSetDicti 32 TYPE, /* i: waiting for type bit 33 TYPEDO, /* i: same, but skip check 34 STORED, /* i: waiting for stored s 35 COPY_, /* i/o: same as COPY below 36 COPY, /* i/o: waiting for input 37 TABLE, /* i: waiting for dynamic 38 LENLENS, /* i: waiting for code len 39 CODELENS, /* i: waiting for length/l 40 LEN_, /* i: same as LEN belo 41 LEN, /* i: waiting for leng 42 LENEXT, /* i: waiting for leng 43 DIST, /* i: waiting for dist 44 DISTEXT, /* i: waiting for dist 45 MATCH, /* o: waiting for outp 46 LIT, /* o: waiting for outp 47 CHECK, /* i: waiting for 32-bit check 48 LENGTH, /* i: waiting for 32-bit lengt 49 DONE, /* finished check, done -- rem 50 BAD, /* got a data error -- remain 51 MEM, /* got an inflate() memory err 52 SYNC /* looking for synchronization 53 } inflate_mode; 54 55 /* 56 State transitions between above modes - 57 58 (most modes can go to BAD or MEM on error 59 60 Process header: 61 HEAD -> (gzip) or (zlib) or (raw) 62 (gzip) -> FLAGS -> TIME -> OS -> EXLEN 63 HCRC -> TYPE 64 (zlib) -> DICTID or TYPE 65 DICTID -> DICT -> TYPE 66 (raw) -> TYPEDO 67 Read deflate blocks: 68 TYPE -> TYPEDO -> STORED or TABLE 69 STORED -> COPY_ -> COPY -> TYPE 70 TABLE -> LENLENS -> CODELENS -> LE 71 LEN_ -> LEN 72 Read deflate codes in fixed or dynamic blo 73 LEN -> LENEXT or LIT or TYPE 74 LENEXT -> DIST -> DISTEXT -> M 75 LIT -> LEN 76 Process trailer: 77 CHECK -> LENGTH -> DONE 78 */ 79 80 /* State maintained between inflate() calls -- 81 including the allocated sliding window, whi 82 struct inflate_state { 83 z_streamp strm; /* pointer bac 84 inflate_mode mode; /* current inf 85 int last; /* true if pro 86 int wrap; /* bit 0 true 87 bit 2 true 88 int havedict; /* true if dic 89 int flags; /* gzip header 90 -1 if raw o 91 unsigned dmax; /* zlib header 92 unsigned long check; /* protected c 93 unsigned long total; /* protected c 94 gz_headerp head; /* where to sa 95 /* sliding window */ 96 unsigned wbits; /* log base 2 97 unsigned wsize; /* window size 98 unsigned whave; /* valid bytes 99 unsigned wnext; /* window writ 100 unsigned char FAR *window; /* allocated s 101 /* bit accumulator */ 102 unsigned long hold; /* input bit a 103 unsigned bits; /* number of b 104 /* for string and stored block copying 105 unsigned length; /* literal or 106 unsigned offset; /* distance ba 107 /* for table and code decoding */ 108 unsigned extra; /* extra bits 109 /* fixed and dynamic code tables */ 110 code const FAR *lencode; /* starting ta 111 code const FAR *distcode; /* starting ta 112 unsigned lenbits; /* index bits 113 unsigned distbits; /* index bits 114 /* dynamic table building */ 115 unsigned ncode; /* number of c 116 unsigned nlen; /* number of l 117 unsigned ndist; /* number of d 118 unsigned have; /* number of c 119 code FAR *next; /* next availa 120 unsigned short lens[320]; /* temporary s 121 unsigned short work[288]; /* work area f 122 code codes[ENOUGH]; /* space for c 123 int sane; /* if false, a 124 int back; /* bits back o 125 unsigned was; /* initial len 126 }; 127