VirtualBox

source: vbox/trunk/src/libs/zlib-1.2.1/inflate.h@ 33995

Last change on this file since 33995 was 6390, checked in by vboxsync, 17 years ago

export libpng and zlib so Windows and OS/2 builds cleanly.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette