lemon-project-template-glpk

annotate deps/glpk/src/zlib/inflate.h @ 11:4fc6ad2fb8a6

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