inflate.h
Go to the documentation of this file.
00001 /* inflate.h -- internal inflate state definition
00002  * Copyright (C) 1995-2004 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: waiting for input or output to copy stored block */
00036         TABLE,      /* i: waiting for dynamic block table lengths */
00037         LENLENS,    /* i: waiting for code length code lengths */
00038         CODELENS,   /* i: waiting for length/lit and distance code lengths */
00039             LEN,        /* i: waiting for length/lit code */
00040             LENEXT,     /* i: waiting for length extra bits */
00041             DIST,       /* i: waiting for distance code */
00042             DISTEXT,    /* i: waiting for distance extra bits */
00043             MATCH,      /* o: waiting for output space to copy string */
00044             LIT,        /* o: waiting for output space to write literal */
00045     CHECK,      /* i: waiting for 32-bit check value */
00046     LENGTH,     /* i: waiting for 32-bit length (gzip) */
00047     DONE,       /* finished check, done -- remain here until reset */
00048     BAD,        /* got a data error -- remain here until reset */
00049     MEM,        /* got an inflate() memory error -- remain here until reset */
00050     SYNC        /* looking for synchronization bytes to restart inflate() */
00051 } inflate_mode;
00052 
00053 /*
00054     State transitions between above modes -
00055 
00056     (most modes can go to the BAD or MEM mode -- not shown for clarity)
00057 
00058     Process header:
00059         HEAD -> (gzip) or (zlib)
00060         (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
00061         NAME -> COMMENT -> HCRC -> TYPE
00062         (zlib) -> DICTID or TYPE
00063         DICTID -> DICT -> TYPE
00064     Read deflate blocks:
00065             TYPE -> STORED or TABLE or LEN or CHECK
00066             STORED -> COPY -> TYPE
00067             TABLE -> LENLENS -> CODELENS -> LEN
00068     Read deflate codes:
00069                 LEN -> LENEXT or LIT or TYPE
00070                 LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
00071                 LIT -> LEN
00072     Process trailer:
00073         CHECK -> LENGTH -> DONE
00074  */
00075 
00076 /* state maintained between inflate() calls.  Approximately 7K bytes. */
00077 struct inflate_state {
00078     inflate_mode mode;          /* current inflate mode */
00079     int last;                   /* true if processing last block */
00080     int wrap;                   /* bit 0 true for zlib, bit 1 true for gzip */
00081     int havedict;               /* true if dictionary provided */
00082     int flags;                  /* gzip header method and flags (0 if zlib) */
00083     unsigned dmax;              /* zlib header max distance (INFLATE_STRICT) */
00084     unsigned long check;        /* protected copy of check value */
00085     unsigned long total;        /* protected copy of output count */
00086     gz_headerp head;            /* where to save gzip header information */
00087         /* sliding window */
00088     unsigned wbits;             /* log base 2 of requested window size */
00089     unsigned wsize;             /* window size or zero if not using window */
00090     unsigned whave;             /* valid bytes in the window */
00091     unsigned write;             /* window write index */
00092     unsigned char FAR *window;  /* allocated sliding window, if needed */
00093         /* bit accumulator */
00094     unsigned long hold;         /* input bit accumulator */
00095     unsigned bits;              /* number of bits in "in" */
00096         /* for string and stored block copying */
00097     unsigned length;            /* literal or length of data to copy */
00098     unsigned offset;            /* distance back to copy string from */
00099         /* for table and code decoding */
00100     unsigned extra;             /* extra bits needed */
00101         /* fixed and dynamic code tables */
00102     code const FAR *lencode;    /* starting table for length/literal codes */
00103     code const FAR *distcode;   /* starting table for distance codes */
00104     unsigned lenbits;           /* index bits for lencode */
00105     unsigned distbits;          /* index bits for distcode */
00106         /* dynamic table building */
00107     unsigned ncode;             /* number of code length code lengths */
00108     unsigned nlen;              /* number of length code lengths */
00109     unsigned ndist;             /* number of distance code lengths */
00110     unsigned have;              /* number of code lengths in lens[] */
00111     code FAR *next;             /* next available space in codes[] */
00112     unsigned short lens[320];   /* temporary storage for code lengths */
00113     unsigned short work[288];   /* work area for code table building */
00114     code codes[ENOUGH];         /* space for code tables */
00115 };


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:54