246 unsigned char FAR *put;
251 unsigned char FAR *from;
256 static const unsigned short order[19] =
257 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
269 next = strm->next_in;
270 have = next !=
Z_NULL ? strm->avail_in : 0;
278 switch (state->
mode) {
291 Tracev((stderr,
"inflate: stored block%s\n",
292 state->
last ?
" (last)" :
""));
297 Tracev((stderr,
"inflate: fixed codes block%s\n",
298 state->
last ?
" (last)" :
""));
302 Tracev((stderr,
"inflate: dynamic codes block%s\n",
303 state->
last ?
" (last)" :
""));
307 strm->msg = (
char *)
"invalid block type";
317 if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
318 strm->msg = (
char *)
"invalid stored block lengths";
322 state->
length = (unsigned)hold & 0xffff;
323 Tracev((stderr,
"inflate: stored length %u\n",
328 while (state->
length != 0) {
332 if (copy > have) copy =
have;
333 if (copy > left) copy = left;
341 Tracev((stderr,
"inflate: stored end\n"));
354 #ifndef PKZIP_BUG_WORKAROUND
355 if (state->
nlen > 286 || state->
ndist > 30) {
356 strm->msg = (
char *)
"too many length or distance symbols";
361 Tracev((stderr,
"inflate: table sizes ok\n"));
367 state->
lens[order[state->
have++]] = (
unsigned short)
BITS(3);
370 while (state->
have < 19)
371 state->
lens[order[state->
have++]] = 0;
378 strm->msg = (
char *)
"invalid code lengths set";
382 Tracev((stderr,
"inflate: code lengths ok\n"));
389 if ((
unsigned)(here.
bits) <= bits)
break;
398 if (here.
val == 16) {
401 if (state->
have == 0) {
402 strm->msg = (
char *)
"invalid bit length repeat";
406 len = (unsigned)(state->
lens[state->
have - 1]);
410 else if (here.
val == 17) {
425 strm->msg = (
char *)
"invalid bit length repeat";
430 state->
lens[state->
have++] = (
unsigned short)len;
438 if (state->
lens[256] == 0) {
439 strm->msg = (
char *)
"invalid code -- missing end-of-block";
453 strm->msg = (
char *)
"invalid literal/lengths set";
462 strm->msg = (
char *)
"invalid distances set";
466 Tracev((stderr,
"inflate: codes ok\n"));
471 if (have >= 6 && left >= 258) {
483 if ((
unsigned)(here.
bits) <= bits)
break;
486 if (here.
op && (here.
op & 0xf0) == 0) {
491 if ((
unsigned)(last.
bits + here.
bits) <= bits)
break;
502 "inflate: literal '%c'\n" :
503 "inflate: literal 0x%02x\n", here.
val));
505 *put++ = (
unsigned char)(state->
length);
513 Tracevv((stderr,
"inflate: end of block\n"));
520 strm->msg = (
char *)
"invalid literal/length code";
526 state->
extra = (unsigned)(here.
op) & 15;
527 if (state->
extra != 0) {
537 if ((
unsigned)(here.
bits) <= bits)
break;
540 if ((here.
op & 0xf0) == 0) {
545 if ((
unsigned)(last.
bits + here.
bits) <= bits)
break;
552 strm->msg = (
char *)
"invalid distance code";
559 state->
extra = (
unsigned)(here.
op) & 15;
560 if (state->
extra != 0) {
567 strm->msg = (
char *)
"invalid distance too far back";
582 from = put - state->
offset;
591 }
while (state->
length != 0);
597 if (left < state->
wsize) {
598 if (out(out_desc, state->
window, state->
wsize - left))
614 strm->next_in =
next;
615 strm->avail_in =
have;
static void copy(const T &from, T &to)
code const FAR * distcode
for(p=first;p->value< newval;p=p->next)
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)
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
local void fixedtables(struct inflate_state FAR *state)
unsigned char FAR * window
static char * bits(int n)