annotate lib/zlib/infcodes.c @ 185:48f9a1ac8376

Слияние
author Ritor1
date Thu, 20 Dec 2012 09:26:47 +0600
parents 8b8875f5b359
children
rev   line source
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
1 /* infcodes.c -- process literals and length/distance pairs
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
2 * Copyright (C) 1995-1998 Mark Adler
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
3 * For conditions of distribution and use, see copyright notice in zlib.h
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
4 */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
5
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
6 #include "zutil.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
7 #include "inftrees.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
8 #include "infblock.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
9 #include "infcodes.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
10 #include "infutil.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
11 #include "inffast.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
12
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
13 /* simplify the use of the inflate_huft type with some defines */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
14 #define exop word.what.Exop
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
15 #define bits word.what.Bits
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
16
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
17 typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
18 START, /* x: set up for LEN */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
19 LEN, /* i: get length/literal/eob next */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
20 LENEXT, /* i: getting length extra (have base) */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
21 DIST, /* i: get distance next */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
22 DISTEXT, /* i: getting distance extra */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
23 COPY, /* o: copying bytes in window, waiting for space */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
24 LIT, /* o: got literal, waiting for output space */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
25 WASH, /* o: got eob, possibly still output waiting */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
26 END, /* x: got eob and all data flushed */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
27 BADCODE} /* x: got error */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
28 inflate_codes_mode;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
29
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
30 /* inflate codes private state */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
31 struct inflate_codes_state {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
32
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
33 /* mode */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
34 inflate_codes_mode mode; /* current inflate_codes mode */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
35
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
36 /* mode dependent information */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
37 uInt len;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
38 union {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
39 struct {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
40 inflate_huft *tree; /* pointer into tree */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
41 uInt need; /* bits needed */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
42 } code; /* if LEN or DIST, where in tree */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
43 uInt lit; /* if LIT, literal */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
44 struct {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
45 uInt get; /* bits to get for extra */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
46 uInt dist; /* distance back to copy from */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
47 } copy; /* if EXT or COPY, where and how much */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
48 } sub; /* submode */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
49
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
50 /* mode independent information */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
51 Byte lbits; /* ltree bits decoded per branch */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
52 Byte dbits; /* dtree bits decoder per branch */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
53 inflate_huft *ltree; /* literal/length/eob tree */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
54 inflate_huft *dtree; /* distance tree */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
55
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
56 };
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
57
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
58
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
59 inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
60 uInt bl, bd;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
61 inflate_huft *tl;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
62 inflate_huft *td; /* need separate declaration for Borland C++ */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
63 z_streamp z;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
64 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
65 inflate_codes_statef *c;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
66
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
67 if ((c = (inflate_codes_statef *)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
68 ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
69 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
70 c->mode = START;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
71 c->lbits = (Byte)bl;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
72 c->dbits = (Byte)bd;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
73 c->ltree = tl;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
74 c->dtree = td;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
75 Tracev((stderr, "inflate: codes new\n"));
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
76 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
77 return c;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
78 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
79
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
80
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
81 int inflate_codes(s, z, r)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
82 inflate_blocks_statef *s;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
83 z_streamp z;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
84 int r;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
85 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
86 uInt j; /* temporary storage */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
87 inflate_huft *t; /* temporary pointer */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
88 uInt e; /* extra bits or operation */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
89 uLong b; /* bit buffer */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
90 uInt k; /* bits in bit buffer */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
91 Bytef *p; /* input data pointer */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
92 uInt n; /* bytes available there */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
93 Bytef *q; /* output window write pointer */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
94 uInt m; /* bytes to end of window or read pointer */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
95 Bytef *f; /* pointer to copy strings from */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
96 inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
97
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
98 /* copy input/output information to locals (UPDATE macro restores) */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
99 LOAD
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
100
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
101 /* process input and output based on current state */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
102 while (1) switch (c->mode)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
103 { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
104 case START: /* x: set up for LEN */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
105 #ifndef SLOW
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
106 if (m >= 258 && n >= 10)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
107 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
108 UPDATE
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
109 r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
110 LOAD
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
111 if (r != Z_OK)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
112 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
113 c->mode = r == Z_STREAM_END ? WASH : BADCODE;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
114 break;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
115 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
116 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
117 #endif /* !SLOW */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
118 c->sub.code.need = c->lbits;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
119 c->sub.code.tree = c->ltree;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
120 c->mode = LEN;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
121 case LEN: /* i: get length/literal/eob next */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
122 j = c->sub.code.need;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
123 NEEDBITS(j)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
124 t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
125 DUMPBITS(t->bits)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
126 e = (uInt)(t->exop);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
127 if (e == 0) /* literal */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
128 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
129 c->sub.lit = t->base;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
130 Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
131 "inflate: literal '%c'\n" :
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
132 "inflate: literal 0x%02x\n", t->base));
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
133 c->mode = LIT;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
134 break;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
135 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
136 if (e & 16) /* length */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
137 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
138 c->sub.copy.get = e & 15;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
139 c->len = t->base;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
140 c->mode = LENEXT;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
141 break;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
142 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
143 if ((e & 64) == 0) /* next table */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
144 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
145 c->sub.code.need = e;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
146 c->sub.code.tree = t + t->base;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
147 break;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
148 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
149 if (e & 32) /* end of block */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
150 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
151 Tracevv((stderr, "inflate: end of block\n"));
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
152 c->mode = WASH;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
153 break;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
154 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
155 c->mode = BADCODE; /* invalid code */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
156 z->msg = (char*)"invalid literal/length code";
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
157 r = Z_DATA_ERROR;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
158 LEAVE
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
159 case LENEXT: /* i: getting length extra (have base) */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
160 j = c->sub.copy.get;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
161 NEEDBITS(j)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
162 c->len += (uInt)b & inflate_mask[j];
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
163 DUMPBITS(j)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
164 c->sub.code.need = c->dbits;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
165 c->sub.code.tree = c->dtree;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
166 Tracevv((stderr, "inflate: length %u\n", c->len));
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
167 c->mode = DIST;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
168 case DIST: /* i: get distance next */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
169 j = c->sub.code.need;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
170 NEEDBITS(j)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
171 t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
172 DUMPBITS(t->bits)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
173 e = (uInt)(t->exop);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
174 if (e & 16) /* distance */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
175 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
176 c->sub.copy.get = e & 15;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
177 c->sub.copy.dist = t->base;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
178 c->mode = DISTEXT;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
179 break;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
180 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
181 if ((e & 64) == 0) /* next table */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
182 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
183 c->sub.code.need = e;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
184 c->sub.code.tree = t + t->base;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
185 break;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
186 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
187 c->mode = BADCODE; /* invalid code */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
188 z->msg = (char*)"invalid distance code";
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
189 r = Z_DATA_ERROR;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
190 LEAVE
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
191 case DISTEXT: /* i: getting distance extra */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
192 j = c->sub.copy.get;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
193 NEEDBITS(j)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
194 c->sub.copy.dist += (uInt)b & inflate_mask[j];
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
195 DUMPBITS(j)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
196 Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist));
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
197 c->mode = COPY;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
198 case COPY: /* o: copying bytes in window, waiting for space */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
199 #ifndef __TURBOC__ /* Turbo C bug for following expression */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
200 f = (uInt)(q - s->window) < c->sub.copy.dist ?
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
201 s->end - (c->sub.copy.dist - (q - s->window)) :
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
202 q - c->sub.copy.dist;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
203 #else
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
204 f = q - c->sub.copy.dist;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
205 if ((uInt)(q - s->window) < c->sub.copy.dist)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
206 f = s->end - (c->sub.copy.dist - (uInt)(q - s->window));
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
207 #endif
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
208 while (c->len)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
209 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
210 NEEDOUT
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
211 OUTBYTE(*f++)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
212 if (f == s->end)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
213 f = s->window;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
214 c->len--;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
215 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
216 c->mode = START;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
217 break;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
218 case LIT: /* o: got literal, waiting for output space */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
219 NEEDOUT
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
220 OUTBYTE(c->sub.lit)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
221 c->mode = START;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
222 break;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
223 case WASH: /* o: got eob, possibly more output */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
224 if (k > 7) /* return unused byte, if any */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
225 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
226 Assert(k < 16, "inflate_codes grabbed too many bytes")
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
227 k -= 8;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
228 n++;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
229 p--; /* can always return one */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
230 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
231 FLUSH
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
232 if (s->read != s->write)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
233 LEAVE
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
234 c->mode = END;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
235 case END:
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
236 r = Z_STREAM_END;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
237 LEAVE
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
238 case BADCODE: /* x: got error */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
239 r = Z_DATA_ERROR;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
240 LEAVE
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
241 default:
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
242 r = Z_STREAM_ERROR;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
243 LEAVE
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
244 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
245 #ifdef NEED_DUMMY_RETURN
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
246 return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
247 #endif
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
248 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
249
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
250
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
251 void inflate_codes_free(c, z)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
252 inflate_codes_statef *c;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
253 z_streamp z;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
254 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
255 ZFREE(z, c);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
256 Tracev((stderr, "inflate: codes free\n"));
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
257 }