31unsigned char FAR *window;
38 stream_size != (
int)(
sizeof(
z_stream)))
41 windowBits < 8 || windowBits > 15)
44 if (
strm->zalloc == (alloc_func)0) {
49 strm->opaque = (voidpf)0;
52 if (
strm->zfree == (free_func)0)
61 Tracev((stderr,
"inflate: allocated\n"));
64 state->
wbits = (uInt)windowBits;
65 state->
wsize = 1U << windowBits;
87 static int virgin = 1;
88 static code *lenfix, *distfix;
89 static code fixed[544];
98 while (sym < 144) state->
lens[sym++] = 8;
99 while (sym < 256) state->
lens[sym++] = 9;
100 while (sym < 280) state->
lens[sym++] = 7;
101 while (sym < 288) state->
lens[sym++] = 8;
109 while (sym < 32) state->
lens[sym++] = 5;
131 put = strm->next_out; \
132 left = strm->avail_out; \
133 next = strm->next_in; \
134 have = strm->avail_in; \
135 hold = state->hold; \
136 bits = state->bits; \
142 strm->next_out = put; \
143 strm->avail_out = left; \
144 strm->next_in = next; \
145 strm->avail_in = have; \
146 state->hold = hold; \
147 state->bits = bits; \
162 have = in(in_desc, &next); \
177 hold += (unsigned long)(*next++) << bits; \
186 while (bits < (unsigned)(n)) \
192 ((unsigned)hold & ((1U << (n)) - 1))
198 bits -= (unsigned)(n); \
214 put = state->window; \
215 left = state->wsize; \
216 state->whave = left; \
217 if (out(out_desc, put, left)) { \
259 z_const
unsigned char FAR *
next;
260 unsigned char FAR *put;
265 unsigned char FAR *from;
270 static const unsigned short order[19] =
271 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
292 switch (state->
mode) {
305 Tracev((stderr,
"inflate: stored block%s\n",
306 state->
last ?
" (last)" :
""));
311 Tracev((stderr,
"inflate: fixed codes block%s\n",
312 state->
last ?
" (last)" :
""));
316 Tracev((stderr,
"inflate: dynamic codes block%s\n",
317 state->
last ?
" (last)" :
""));
321 strm->msg = (
char *)
"invalid block type";
331 if ((
hold & 0xffff) != ((
hold >> 16) ^ 0xffff)) {
332 strm->msg = (
char *)
"invalid stored block lengths";
337 Tracev((stderr,
"inflate: stored length %u\n",
342 while (state->
length != 0) {
347 if (copy > left) copy = left;
355 Tracev((stderr,
"inflate: stored end\n"));
368#ifndef PKZIP_BUG_WORKAROUND
369 if (state->
nlen > 286 || state->
ndist > 30) {
370 strm->msg = (
char *)
"too many length or distance symbols";
375 Tracev((stderr,
"inflate: table sizes ok\n"));
381 state->
lens[order[state->
have++]] = (
unsigned short)
BITS(3);
384 while (state->
have < 19)
385 state->
lens[order[state->
have++]] = 0;
392 strm->msg = (
char *)
"invalid code lengths set";
396 Tracev((stderr,
"inflate: code lengths ok\n"));
403 if ((
unsigned)(here.
bits) <=
bits)
break;
411 if (here.
val == 16) {
414 if (state->
have == 0) {
415 strm->msg = (
char *)
"invalid bit length repeat";
419 len = (unsigned)(state->
lens[state->
have - 1]);
423 else if (here.
val == 17) {
438 strm->msg = (
char *)
"invalid bit length repeat";
443 state->
lens[state->
have++] = (
unsigned short)len;
451 if (state->
lens[256] == 0) {
452 strm->msg = (
char *)
"invalid code -- missing end-of-block";
466 strm->msg = (
char *)
"invalid literal/lengths set";
475 strm->msg = (
char *)
"invalid distances set";
479 Tracev((stderr,
"inflate: codes ok\n"));
485 if (
have >= 6 && left >= 258) {
497 if ((
unsigned)(here.
bits) <=
bits)
break;
500 if (here.
op && (here.
op & 0xf0) == 0) {
516 "inflate: literal '%c'\n" :
517 "inflate: literal 0x%02x\n", here.
val));
519 *put++ = (
unsigned char)(state->
length);
527 Tracevv((stderr,
"inflate: end of block\n"));
534 strm->msg = (
char *)
"invalid literal/length code";
540 state->
extra = (unsigned)(here.
op) & 15;
541 if (state->
extra != 0) {
551 if ((
unsigned)(here.
bits) <=
bits)
break;
554 if ((here.
op & 0xf0) == 0) {
566 strm->msg = (
char *)
"invalid distance code";
573 state->
extra = (unsigned)(here.
op) & 15;
574 if (state->
extra != 0) {
581 strm->msg = (
char *)
"invalid distance too far back";
596 from = put - state->
offset;
605 }
while (state->
length != 0);
625 if (left < state->
wsize) {
626 if (out(out_desc, state->
window, state->
wsize - left) &&
642 Tracev((stderr,
"inflate: end\n"));
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size)
local void fixedtables(struct inflate_state FAR *state)
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)
int ZEXPORT inflateBackEnd(z_streamp strm)
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start)
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
code const FAR * distcode
unsigned char FAR * window
voidpf alloc_func OF((voidpf opaque, uInt items, uInt size))
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
#define ZALLOC(strm, items, size)
#define ZFREE(strm, addr)