Lines Matching refs:state

19 local void fixedtables OF((struct inflate_state FAR *state));
35 struct inflate_state FAR *state; local
58 state = (struct inflate_state FAR *)ZALLOC(strm, 1,
60 if (state == Z_NULL) return Z_MEM_ERROR;
62 strm->state = (struct internal_state FAR *)state;
63 state->dmax = 32768U;
64 state->wbits = windowBits;
65 state->wsize = 1U << windowBits;
66 state->window = window;
67 state->wnext = 0;
68 state->whave = 0;
82 local void fixedtables(state) in fixedtables() argument
83 struct inflate_state FAR *state; in fixedtables()
97 while (sym < 144) state->lens[sym++] = 8;
98 while (sym < 256) state->lens[sym++] = 9;
99 while (sym < 280) state->lens[sym++] = 7;
100 while (sym < 288) state->lens[sym++] = 8;
104 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
108 while (sym < 32) state->lens[sym++] = 5;
111 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
119 state->lencode = lenfix;
120 state->lenbits = 9;
121 state->distcode = distfix;
122 state->distbits = 5;
134 hold = state->hold; \
135 bits = state->bits; \
145 state->hold = hold; \
146 state->bits = bits; \
213 put = state->window; \
214 left = state->wsize; \
215 state->whave = left; \
257 struct inflate_state FAR *state; local
273 if (strm == Z_NULL || strm->state == Z_NULL)
275 state = (struct inflate_state FAR *)strm->state;
279 state->mode = TYPE;
280 state->last = 0;
281 state->whave = 0;
286 put = state->window;
287 left = state->wsize;
291 switch (state->mode) {
294 if (state->last) {
296 state->mode = DONE;
300 state->last = BITS(1);
305 state->last ? " (last)" : ""));
306 state->mode = STORED;
309 fixedtables(state);
311 state->last ? " (last)" : ""));
312 state->mode = LEN; /* decode codes */
316 state->last ? " (last)" : ""));
317 state->mode = TABLE;
321 state->mode = BAD;
332 state->mode = BAD;
335 state->length = (unsigned)hold & 0xffff;
337 state->length));
341 while (state->length != 0) {
342 copy = state->length;
352 state->length -= copy;
355 state->mode = TYPE;
361 state->nlen = BITS(5) + 257;
363 state->ndist = BITS(5) + 1;
365 state->ncode = BITS(4) + 4;
368 if (state->nlen > 286 || state->ndist > 30) {
370 state->mode = BAD;
377 state->have = 0;
378 while (state->have < state->ncode) {
380 state->lens[order[state->have++]] = (unsigned short)BITS(3);
383 while (state->have < 19)
384 state->lens[order[state->have++]] = 0;
385 state->next = state->codes;
386 state->lencode = (code const FAR *)(state->next);
387 state->lenbits = 7;
388 ret = inflate_table(CODES, state->lens, 19, &(state->next),
389 &(state->lenbits), state->work);
392 state->mode = BAD;
398 state->have = 0;
399 while (state->have < state->nlen + state->ndist) {
401 here = state->lencode[BITS(state->lenbits)];
407 state->lens[state->have++] = here.val;
413 if (state->have == 0) {
415 state->mode = BAD;
418 len = (unsigned)(state->lens[state->have - 1]);
436 if (state->have + copy > state->nlen + state->ndist) {
438 state->mode = BAD;
442 state->lens[state->have++] = (unsigned short)len;
447 if (state->mode == BAD) break;
450 if (state->lens[256] == 0) {
452 state->mode = BAD;
459 state->next = state->codes;
460 state->lencode = (code const FAR *)(state->next);
461 state->lenbits = 9;
462 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
463 &(state->lenbits), state->work);
466 state->mode = BAD;
469 state->distcode = (code const FAR *)(state->next);
470 state->distbits = 6;
471 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
472 &(state->next), &(state->distbits), state->work);
475 state->mode = BAD;
479 state->mode = LEN;
485 if (state->whave < state->wsize)
486 state->whave = state->wsize - left;
487 inflate_fast(strm, state->wsize);
494 here = state->lencode[BITS(state->lenbits)];
501 here = state->lencode[last.val +
509 state->length = (unsigned)here.val;
517 *put++ = (unsigned char)(state->length);
519 state->mode = LEN;
526 state->mode = TYPE;
533 state->mode = BAD;
538 state->extra = (unsigned)(here.op) & 15;
539 if (state->extra != 0) {
540 NEEDBITS(state->extra);
541 state->length += BITS(state->extra);
542 DROPBITS(state->extra);
544 Tracevv((stderr, "inflate: length %u\n", state->length));
548 here = state->distcode[BITS(state->distbits)];
555 here = state->distcode[last.val +
565 state->mode = BAD;
568 state->offset = (unsigned)here.val;
571 state->extra = (unsigned)(here.op) & 15;
572 if (state->extra != 0) {
573 NEEDBITS(state->extra);
574 state->offset += BITS(state->extra);
575 DROPBITS(state->extra);
577 if (state->offset > state->wsize - (state->whave < state->wsize ?
580 state->mode = BAD;
583 Tracevv((stderr, "inflate: distance %u\n", state->offset));
588 copy = state->wsize - state->offset;
594 from = put - state->offset;
597 if (copy > state->length) copy = state->length;
598 state->length -= copy;
603 } while (state->length != 0);
609 if (left < state->wsize) {
610 if (out(out_desc, state->window, state->wsize - left))
634 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
636 ZFREE(strm, strm->state);
637 strm->state = Z_NULL;