26 # define PUP(a) *(a)++
29 # define PUP(a) *++(a)
69 struct inflate_state FAR *state;
70 z_const
unsigned char FAR *in;
71 z_const
unsigned char FAR *last;
72 unsigned char FAR *out;
73 unsigned char FAR *beg;
74 unsigned char FAR *end;
81 unsigned char FAR *window;
84 code
const FAR *lcode;
85 code
const FAR *dcode;
93 unsigned char FAR *from;
96 state = (
struct inflate_state FAR *)strm->state;
97 in = strm->next_in -
OFF;
98 last = in + (strm->avail_in - 5);
99 out = strm->next_out -
OFF;
100 beg = out - (start - strm->avail_out);
101 end = out + (strm->avail_out - 257);
102 #ifdef INFLATE_STRICT
105 wsize = state->wsize;
106 whave = state->whave;
107 wnext = state->wnext;
108 window = state->window;
111 lcode = state->lencode;
112 dcode = state->distcode;
113 lmask = (1U << state->lenbits) - 1;
114 dmask = (1U << state->distbits) - 1;
120 hold += (
unsigned long)(
PUP(in)) << bits;
122 hold += (
unsigned long)(
PUP(in)) << bits;
125 here = lcode[hold & lmask];
127 op = (unsigned)(here.bits);
130 op = (unsigned)(here.op);
132 Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
133 "inflate: literal '%c'\n" :
134 "inflate: literal 0x%02x\n", here.val));
135 PUP(out) = (
unsigned char)(here.val);
138 len = (unsigned)(here.val);
142 hold += (
unsigned long)(
PUP(in)) << bits;
145 len += (unsigned)hold & ((1U << op) - 1);
149 Tracevv((stderr,
"inflate: length %u\n", len));
151 hold += (
unsigned long)(
PUP(in)) << bits;
153 hold += (
unsigned long)(
PUP(in)) << bits;
156 here = dcode[hold & dmask];
158 op = (unsigned)(here.bits);
161 op = (unsigned)(here.op);
163 dist = (unsigned)(here.val);
166 hold += (
unsigned long)(
PUP(in)) << bits;
169 hold += (
unsigned long)(
PUP(in)) << bits;
173 dist += (unsigned)hold & ((1U << op) - 1);
174 #ifdef INFLATE_STRICT
176 strm->msg = (
char *)
"invalid distance too far back";
183 Tracevv((stderr,
"inflate: distance %u\n", dist));
184 op = (unsigned)(out - beg);
190 (
char *)
"invalid distance too far back";
194 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
195 if (len <= op - whave) {
204 }
while (--op > whave);
225 else if (wnext < op) {
226 from += wsize + wnext - op;
281 else if ((op & 64) == 0) {
282 here = dcode[here.val + (hold & ((1U << op) - 1))];
286 strm->msg = (
char *)
"invalid distance code";
291 else if ((op & 64) == 0) {
292 here = lcode[here.val + (hold & ((1U << op) - 1))];
296 Tracevv((stderr,
"inflate: end of block\n"));
301 strm->msg = (
char *)
"invalid literal/length code";
305 }
while (in < last && out < end);
311 hold &= (1U << bits) - 1;
314 strm->next_in = in +
OFF;
315 strm->next_out = out +
OFF;
316 strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
317 strm->avail_out = (unsigned)(out < end ?
318 257 + (end - out) : 257 - (out - end));
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start)