Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
inflate.h
00001 /* inflate.h -- internal inflate state definition 00002 * Copyright (C) 1995-2009 Mark Adler 00003 * For conditions of distribution and use, see copyright notice in zlib.h 00004 */ 00005 00006 /* WARNING: this file should *not* be used by applications. It is 00007 part of the implementation of the compression library and is 00008 subject to change. Applications should only use zlib.h. 00009 */ 00010 00011 /* define NO_GZIP when compiling if you want to disable gzip header and 00012 trailer decoding by inflate(). NO_GZIP would be used to avoid linking in 00013 the crc code when it is not needed. For shared libraries, gzip decoding 00014 should be left enabled. */ 00015 #ifndef NO_GZIP 00016 # define GUNZIP 00017 #endif 00018 00019 /* Possible inflate modes between inflate() calls */ 00020 typedef enum { 00021 HEAD, /* i: waiting for magic header */ 00022 FLAGS, /* i: waiting for method and flags (gzip) */ 00023 TIME, /* i: waiting for modification time (gzip) */ 00024 OS, /* i: waiting for extra flags and operating system (gzip) */ 00025 EXLEN, /* i: waiting for extra length (gzip) */ 00026 EXTRA, /* i: waiting for extra bytes (gzip) */ 00027 NAME, /* i: waiting for end of file name (gzip) */ 00028 COMMENT, /* i: waiting for end of comment (gzip) */ 00029 HCRC, /* i: waiting for header crc (gzip) */ 00030 DICTID, /* i: waiting for dictionary check value */ 00031 DICT, /* waiting for inflateSetDictionary() call */ 00032 TYPE, /* i: waiting for type bits, including last-flag bit */ 00033 TYPEDO, /* i: same, but skip check to exit inflate on new block */ 00034 STORED, /* i: waiting for stored size (length and complement) */ 00035 COPY_, /* i/o: same as COPY below, but only first time in */ 00036 COPY, /* i/o: waiting for input or output to copy stored block */ 00037 TABLE, /* i: waiting for dynamic block table lengths */ 00038 LENLENS, /* i: waiting for code length code lengths */ 00039 CODELENS, /* i: waiting for length/lit and distance code lengths */ 00040 LEN_, /* i: same as LEN below, but only first time in */ 00041 LEN, /* i: waiting for length/lit/eob code */ 00042 LENEXT, /* i: waiting for length extra bits */ 00043 DIST, /* i: waiting for distance code */ 00044 DISTEXT, /* i: waiting for distance extra bits */ 00045 MATCH, /* o: waiting for output space to copy string */ 00046 LIT, /* o: waiting for output space to write literal */ 00047 CHECK, /* i: waiting for 32-bit check value */ 00048 LENGTH, /* i: waiting for 32-bit length (gzip) */ 00049 DONE, /* finished check, done -- remain here until reset */ 00050 BAD, /* got a data error -- remain here until reset */ 00051 MEM, /* got an inflate() memory error -- remain here until reset */ 00052 SYNC /* looking for synchronization bytes to restart inflate() */ 00053 } inflate_mode; 00054 00055 /* 00056 State transitions between above modes - 00057 00058 (most modes can go to BAD or MEM on error -- not shown for clarity) 00059 00060 Process header: 00061 HEAD -> (gzip) or (zlib) or (raw) 00062 (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> 00063 HCRC -> TYPE 00064 (zlib) -> DICTID or TYPE 00065 DICTID -> DICT -> TYPE 00066 (raw) -> TYPEDO 00067 Read deflate blocks: 00068 TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK 00069 STORED -> COPY_ -> COPY -> TYPE 00070 TABLE -> LENLENS -> CODELENS -> LEN_ 00071 LEN_ -> LEN 00072 Read deflate codes in fixed or dynamic block: 00073 LEN -> LENEXT or LIT or TYPE 00074 LENEXT -> DIST -> DISTEXT -> MATCH -> LEN 00075 LIT -> LEN 00076 Process trailer: 00077 CHECK -> LENGTH -> DONE 00078 */ 00079 00080 /* state maintained between inflate() calls. Approximately 10K bytes. */ 00081 struct inflate_state { 00082 inflate_mode mode; /* current inflate mode */ 00083 int last; /* true if processing last block */ 00084 int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ 00085 int havedict; /* true if dictionary provided */ 00086 int flags; /* gzip header method and flags (0 if zlib) */ 00087 unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ 00088 unsigned long check; /* protected copy of check value */ 00089 unsigned long total; /* protected copy of output count */ 00090 gz_headerp head; /* where to save gzip header information */ 00091 /* sliding window */ 00092 unsigned wbits; /* log base 2 of requested window size */ 00093 unsigned wsize; /* window size or zero if not using window */ 00094 unsigned whave; /* valid bytes in the window */ 00095 unsigned wnext; /* window write index */ 00096 unsigned char FAR *window; /* allocated sliding window, if needed */ 00097 /* bit accumulator */ 00098 unsigned long hold; /* input bit accumulator */ 00099 unsigned bits; /* number of bits in "in" */ 00100 /* for string and stored block copying */ 00101 unsigned length; /* literal or length of data to copy */ 00102 unsigned offset; /* distance back to copy string from */ 00103 /* for table and code decoding */ 00104 unsigned extra; /* extra bits needed */ 00105 /* fixed and dynamic code tables */ 00106 code const FAR *lencode; /* starting table for length/literal codes */ 00107 code const FAR *distcode; /* starting table for distance codes */ 00108 unsigned lenbits; /* index bits for lencode */ 00109 unsigned distbits; /* index bits for distcode */ 00110 /* dynamic table building */ 00111 unsigned ncode; /* number of code length code lengths */ 00112 unsigned nlen; /* number of length code lengths */ 00113 unsigned ndist; /* number of distance code lengths */ 00114 unsigned have; /* number of code lengths in lens[] */ 00115 code FAR *next; /* next available space in codes[] */ 00116 unsigned short lens[320]; /* temporary storage for code lengths */ 00117 unsigned short work[288]; /* work area for code table building */ 00118 code codes[ENOUGH]; /* space for code tables */ 00119 int sane; /* if false, allow invalid distance too far */ 00120 int back; /* bits back of last unprocessed length/lit */ 00121 unsigned was; /* initial length of match */ 00122 };
Generated on Wed Jul 13 2022 09:05:31 by
1.7.2