annotate src/zlib-1.2.8/inflate.h @ 56:af97cad61ff0

Add updated build of PortAudio for OSX
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 03 Jan 2017 15:10:52 +0000
parents 5ea0608b923f
children
rev   line source
Chris@43 1 /* inflate.h -- internal inflate state definition
Chris@43 2 * Copyright (C) 1995-2009 Mark Adler
Chris@43 3 * For conditions of distribution and use, see copyright notice in zlib.h
Chris@43 4 */
Chris@43 5
Chris@43 6 /* WARNING: this file should *not* be used by applications. It is
Chris@43 7 part of the implementation of the compression library and is
Chris@43 8 subject to change. Applications should only use zlib.h.
Chris@43 9 */
Chris@43 10
Chris@43 11 /* define NO_GZIP when compiling if you want to disable gzip header and
Chris@43 12 trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
Chris@43 13 the crc code when it is not needed. For shared libraries, gzip decoding
Chris@43 14 should be left enabled. */
Chris@43 15 #ifndef NO_GZIP
Chris@43 16 # define GUNZIP
Chris@43 17 #endif
Chris@43 18
Chris@43 19 /* Possible inflate modes between inflate() calls */
Chris@43 20 typedef enum {
Chris@43 21 HEAD, /* i: waiting for magic header */
Chris@43 22 FLAGS, /* i: waiting for method and flags (gzip) */
Chris@43 23 TIME, /* i: waiting for modification time (gzip) */
Chris@43 24 OS, /* i: waiting for extra flags and operating system (gzip) */
Chris@43 25 EXLEN, /* i: waiting for extra length (gzip) */
Chris@43 26 EXTRA, /* i: waiting for extra bytes (gzip) */
Chris@43 27 NAME, /* i: waiting for end of file name (gzip) */
Chris@43 28 COMMENT, /* i: waiting for end of comment (gzip) */
Chris@43 29 HCRC, /* i: waiting for header crc (gzip) */
Chris@43 30 DICTID, /* i: waiting for dictionary check value */
Chris@43 31 DICT, /* waiting for inflateSetDictionary() call */
Chris@43 32 TYPE, /* i: waiting for type bits, including last-flag bit */
Chris@43 33 TYPEDO, /* i: same, but skip check to exit inflate on new block */
Chris@43 34 STORED, /* i: waiting for stored size (length and complement) */
Chris@43 35 COPY_, /* i/o: same as COPY below, but only first time in */
Chris@43 36 COPY, /* i/o: waiting for input or output to copy stored block */
Chris@43 37 TABLE, /* i: waiting for dynamic block table lengths */
Chris@43 38 LENLENS, /* i: waiting for code length code lengths */
Chris@43 39 CODELENS, /* i: waiting for length/lit and distance code lengths */
Chris@43 40 LEN_, /* i: same as LEN below, but only first time in */
Chris@43 41 LEN, /* i: waiting for length/lit/eob code */
Chris@43 42 LENEXT, /* i: waiting for length extra bits */
Chris@43 43 DIST, /* i: waiting for distance code */
Chris@43 44 DISTEXT, /* i: waiting for distance extra bits */
Chris@43 45 MATCH, /* o: waiting for output space to copy string */
Chris@43 46 LIT, /* o: waiting for output space to write literal */
Chris@43 47 CHECK, /* i: waiting for 32-bit check value */
Chris@43 48 LENGTH, /* i: waiting for 32-bit length (gzip) */
Chris@43 49 DONE, /* finished check, done -- remain here until reset */
Chris@43 50 BAD, /* got a data error -- remain here until reset */
Chris@43 51 MEM, /* got an inflate() memory error -- remain here until reset */
Chris@43 52 SYNC /* looking for synchronization bytes to restart inflate() */
Chris@43 53 } inflate_mode;
Chris@43 54
Chris@43 55 /*
Chris@43 56 State transitions between above modes -
Chris@43 57
Chris@43 58 (most modes can go to BAD or MEM on error -- not shown for clarity)
Chris@43 59
Chris@43 60 Process header:
Chris@43 61 HEAD -> (gzip) or (zlib) or (raw)
Chris@43 62 (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
Chris@43 63 HCRC -> TYPE
Chris@43 64 (zlib) -> DICTID or TYPE
Chris@43 65 DICTID -> DICT -> TYPE
Chris@43 66 (raw) -> TYPEDO
Chris@43 67 Read deflate blocks:
Chris@43 68 TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
Chris@43 69 STORED -> COPY_ -> COPY -> TYPE
Chris@43 70 TABLE -> LENLENS -> CODELENS -> LEN_
Chris@43 71 LEN_ -> LEN
Chris@43 72 Read deflate codes in fixed or dynamic block:
Chris@43 73 LEN -> LENEXT or LIT or TYPE
Chris@43 74 LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
Chris@43 75 LIT -> LEN
Chris@43 76 Process trailer:
Chris@43 77 CHECK -> LENGTH -> DONE
Chris@43 78 */
Chris@43 79
Chris@43 80 /* state maintained between inflate() calls. Approximately 10K bytes. */
Chris@43 81 struct inflate_state {
Chris@43 82 inflate_mode mode; /* current inflate mode */
Chris@43 83 int last; /* true if processing last block */
Chris@43 84 int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
Chris@43 85 int havedict; /* true if dictionary provided */
Chris@43 86 int flags; /* gzip header method and flags (0 if zlib) */
Chris@43 87 unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
Chris@43 88 unsigned long check; /* protected copy of check value */
Chris@43 89 unsigned long total; /* protected copy of output count */
Chris@43 90 gz_headerp head; /* where to save gzip header information */
Chris@43 91 /* sliding window */
Chris@43 92 unsigned wbits; /* log base 2 of requested window size */
Chris@43 93 unsigned wsize; /* window size or zero if not using window */
Chris@43 94 unsigned whave; /* valid bytes in the window */
Chris@43 95 unsigned wnext; /* window write index */
Chris@43 96 unsigned char FAR *window; /* allocated sliding window, if needed */
Chris@43 97 /* bit accumulator */
Chris@43 98 unsigned long hold; /* input bit accumulator */
Chris@43 99 unsigned bits; /* number of bits in "in" */
Chris@43 100 /* for string and stored block copying */
Chris@43 101 unsigned length; /* literal or length of data to copy */
Chris@43 102 unsigned offset; /* distance back to copy string from */
Chris@43 103 /* for table and code decoding */
Chris@43 104 unsigned extra; /* extra bits needed */
Chris@43 105 /* fixed and dynamic code tables */
Chris@43 106 code const FAR *lencode; /* starting table for length/literal codes */
Chris@43 107 code const FAR *distcode; /* starting table for distance codes */
Chris@43 108 unsigned lenbits; /* index bits for lencode */
Chris@43 109 unsigned distbits; /* index bits for distcode */
Chris@43 110 /* dynamic table building */
Chris@43 111 unsigned ncode; /* number of code length code lengths */
Chris@43 112 unsigned nlen; /* number of length code lengths */
Chris@43 113 unsigned ndist; /* number of distance code lengths */
Chris@43 114 unsigned have; /* number of code lengths in lens[] */
Chris@43 115 code FAR *next; /* next available space in codes[] */
Chris@43 116 unsigned short lens[320]; /* temporary storage for code lengths */
Chris@43 117 unsigned short work[288]; /* work area for code table building */
Chris@43 118 code codes[ENOUGH]; /* space for code tables */
Chris@43 119 int sane; /* if false, allow invalid distance too far */
Chris@43 120 int back; /* bits back of last unprocessed length/lit */
Chris@43 121 unsigned was; /* initial length of match */
Chris@43 122 };