Lines Matching refs:state
35 struct inflate_state *state; in zlib_inflateReset() local
37 if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR; in zlib_inflateReset()
38 state = (struct inflate_state *)strm->state; in zlib_inflateReset()
39 strm->total_in = strm->total_out = state->total = 0; in zlib_inflateReset()
42 state->mode = HEAD; in zlib_inflateReset()
43 state->last = 0; in zlib_inflateReset()
44 state->havedict = 0; in zlib_inflateReset()
45 state->dmax = 32768U; in zlib_inflateReset()
46 state->hold = 0; in zlib_inflateReset()
47 state->bits = 0; in zlib_inflateReset()
48 state->lencode = state->distcode = state->next = state->codes; in zlib_inflateReset()
51 state->wsize = 1U << state->wbits; in zlib_inflateReset()
52 state->write = 0; in zlib_inflateReset()
53 state->whave = 0; in zlib_inflateReset()
61 struct inflate_state *state; in zlib_inflateInit2() local
66 state = &WS(strm)->inflate_state; in zlib_inflateInit2()
67 strm->state = (struct internal_state *)state; in zlib_inflateInit2()
70 state->wrap = 0; in zlib_inflateInit2()
74 state->wrap = (windowBits >> 4) + 1; in zlib_inflateInit2()
79 state->wbits = (unsigned)windowBits; in zlib_inflateInit2()
85 state->window = PTR_ALIGN(&WS(strm)->working_window[0], PAGE_SIZE); in zlib_inflateInit2()
87 state->window = &WS(strm)->working_window[0]; in zlib_inflateInit2()
97 static void zlib_fixedtables(struct inflate_state *state) in zlib_fixedtables() argument
100 state->lencode = lenfix; in zlib_fixedtables()
101 state->lenbits = 9; in zlib_fixedtables()
102 state->distcode = distfix; in zlib_fixedtables()
103 state->distbits = 5; in zlib_fixedtables()
122 struct inflate_state *state; in zlib_updatewindow() local
125 state = (struct inflate_state *)strm->state; in zlib_updatewindow()
129 if (copy >= state->wsize) { in zlib_updatewindow()
130 memcpy(state->window, strm->next_out - state->wsize, state->wsize); in zlib_updatewindow()
131 state->write = 0; in zlib_updatewindow()
132 state->whave = state->wsize; in zlib_updatewindow()
135 dist = state->wsize - state->write; in zlib_updatewindow()
137 memcpy(state->window + state->write, strm->next_out - copy, dist); in zlib_updatewindow()
140 memcpy(state->window, strm->next_out - copy, copy); in zlib_updatewindow()
141 state->write = copy; in zlib_updatewindow()
142 state->whave = state->wsize; in zlib_updatewindow()
145 state->write += dist; in zlib_updatewindow()
146 if (state->write == state->wsize) state->write = 0; in zlib_updatewindow()
147 if (state->whave < state->wsize) state->whave += dist; in zlib_updatewindow()
167 struct inflate_state *state; in zlib_inflateSyncPacket() local
169 if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR; in zlib_inflateSyncPacket()
170 state = (struct inflate_state *)strm->state; in zlib_inflateSyncPacket()
172 if (state->mode == STORED && state->bits == 0) { in zlib_inflateSyncPacket()
173 state->mode = TYPE; in zlib_inflateSyncPacket()
191 hold = state->hold; \
192 bits = state->bits; \
202 state->hold = hold; \
203 state->bits = bits; \
333 struct inflate_state *state; in zlib_inflate() local
352 if (strm == NULL || strm->state == NULL || in zlib_inflate()
356 state = (struct inflate_state *)strm->state; in zlib_inflate()
358 if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ in zlib_inflate()
364 switch (state->mode) { in zlib_inflate()
366 if (state->wrap == 0) { in zlib_inflate()
367 state->mode = TYPEDO; in zlib_inflate()
374 state->mode = BAD; in zlib_inflate()
379 state->mode = BAD; in zlib_inflate()
384 if (len > state->wbits) { in zlib_inflate()
386 state->mode = BAD; in zlib_inflate()
389 state->dmax = 1U << len; in zlib_inflate()
390 strm->adler = state->check = zlib_adler32(0L, NULL, 0); in zlib_inflate()
391 state->mode = hold & 0x200 ? DICTID : TYPE; in zlib_inflate()
396 strm->adler = state->check = REVERSE(hold); in zlib_inflate()
398 state->mode = DICT; in zlib_inflate()
401 if (state->havedict == 0) { in zlib_inflate()
405 strm->adler = state->check = zlib_adler32(0L, NULL, 0); in zlib_inflate()
406 state->mode = TYPE; in zlib_inflate()
413 if (state->last) { in zlib_inflate()
415 state->mode = CHECK; in zlib_inflate()
419 state->last = BITS(1); in zlib_inflate()
423 state->mode = STORED; in zlib_inflate()
426 zlib_fixedtables(state); in zlib_inflate()
427 state->mode = LEN; /* decode codes */ in zlib_inflate()
430 state->mode = TABLE; in zlib_inflate()
434 state->mode = BAD; in zlib_inflate()
443 state->mode = BAD; in zlib_inflate()
446 state->length = (unsigned)hold & 0xffff; in zlib_inflate()
448 state->mode = COPY; in zlib_inflate()
451 copy = state->length; in zlib_inflate()
461 state->length -= copy; in zlib_inflate()
464 state->mode = TYPE; in zlib_inflate()
468 state->nlen = BITS(5) + 257; in zlib_inflate()
470 state->ndist = BITS(5) + 1; in zlib_inflate()
472 state->ncode = BITS(4) + 4; in zlib_inflate()
475 if (state->nlen > 286 || state->ndist > 30) { in zlib_inflate()
477 state->mode = BAD; in zlib_inflate()
481 state->have = 0; in zlib_inflate()
482 state->mode = LENLENS; in zlib_inflate()
485 while (state->have < state->ncode) { in zlib_inflate()
487 state->lens[order[state->have++]] = (unsigned short)BITS(3); in zlib_inflate()
490 while (state->have < 19) in zlib_inflate()
491 state->lens[order[state->have++]] = 0; in zlib_inflate()
492 state->next = state->codes; in zlib_inflate()
493 state->lencode = (code const *)(state->next); in zlib_inflate()
494 state->lenbits = 7; in zlib_inflate()
495 ret = zlib_inflate_table(CODES, state->lens, 19, &(state->next), in zlib_inflate()
496 &(state->lenbits), state->work); in zlib_inflate()
499 state->mode = BAD; in zlib_inflate()
502 state->have = 0; in zlib_inflate()
503 state->mode = CODELENS; in zlib_inflate()
506 while (state->have < state->nlen + state->ndist) { in zlib_inflate()
508 this = state->lencode[BITS(state->lenbits)]; in zlib_inflate()
515 state->lens[state->have++] = this.val; in zlib_inflate()
521 if (state->have == 0) { in zlib_inflate()
523 state->mode = BAD; in zlib_inflate()
526 len = state->lens[state->have - 1]; in zlib_inflate()
544 if (state->have + copy > state->nlen + state->ndist) { in zlib_inflate()
546 state->mode = BAD; in zlib_inflate()
550 state->lens[state->have++] = (unsigned short)len; in zlib_inflate()
555 if (state->mode == BAD) break; in zlib_inflate()
558 state->next = state->codes; in zlib_inflate()
559 state->lencode = (code const *)(state->next); in zlib_inflate()
560 state->lenbits = 9; in zlib_inflate()
561 ret = zlib_inflate_table(LENS, state->lens, state->nlen, &(state->next), in zlib_inflate()
562 &(state->lenbits), state->work); in zlib_inflate()
565 state->mode = BAD; in zlib_inflate()
568 state->distcode = (code const *)(state->next); in zlib_inflate()
569 state->distbits = 6; in zlib_inflate()
570 ret = zlib_inflate_table(DISTS, state->lens + state->nlen, state->ndist, in zlib_inflate()
571 &(state->next), &(state->distbits), state->work); in zlib_inflate()
574 state->mode = BAD; in zlib_inflate()
577 state->mode = LEN; in zlib_inflate()
587 this = state->lencode[BITS(state->lenbits)]; in zlib_inflate()
594 this = state->lencode[last.val + in zlib_inflate()
602 state->length = (unsigned)this.val; in zlib_inflate()
604 state->mode = LIT; in zlib_inflate()
608 state->mode = TYPE; in zlib_inflate()
613 state->mode = BAD; in zlib_inflate()
616 state->extra = (unsigned)(this.op) & 15; in zlib_inflate()
617 state->mode = LENEXT; in zlib_inflate()
620 if (state->extra) { in zlib_inflate()
621 NEEDBITS(state->extra); in zlib_inflate()
622 state->length += BITS(state->extra); in zlib_inflate()
623 DROPBITS(state->extra); in zlib_inflate()
625 state->mode = DIST; in zlib_inflate()
629 this = state->distcode[BITS(state->distbits)]; in zlib_inflate()
636 this = state->distcode[last.val + in zlib_inflate()
646 state->mode = BAD; in zlib_inflate()
649 state->offset = (unsigned)this.val; in zlib_inflate()
650 state->extra = (unsigned)(this.op) & 15; in zlib_inflate()
651 state->mode = DISTEXT; in zlib_inflate()
654 if (state->extra) { in zlib_inflate()
655 NEEDBITS(state->extra); in zlib_inflate()
656 state->offset += BITS(state->extra); in zlib_inflate()
657 DROPBITS(state->extra); in zlib_inflate()
660 if (state->offset > state->dmax) { in zlib_inflate()
662 state->mode = BAD; in zlib_inflate()
666 if (state->offset > state->whave + out - left) { in zlib_inflate()
668 state->mode = BAD; in zlib_inflate()
671 state->mode = MATCH; in zlib_inflate()
676 if (state->offset > copy) { /* copy from window */ in zlib_inflate()
677 copy = state->offset - copy; in zlib_inflate()
678 if (copy > state->write) { in zlib_inflate()
679 copy -= state->write; in zlib_inflate()
680 from = state->window + (state->wsize - copy); in zlib_inflate()
683 from = state->window + (state->write - copy); in zlib_inflate()
684 if (copy > state->length) copy = state->length; in zlib_inflate()
687 from = put - state->offset; in zlib_inflate()
688 copy = state->length; in zlib_inflate()
692 state->length -= copy; in zlib_inflate()
696 if (state->length == 0) state->mode = LEN; in zlib_inflate()
700 *put++ = (unsigned char)(state->length); in zlib_inflate()
702 state->mode = LEN; in zlib_inflate()
705 if (state->wrap) { in zlib_inflate()
709 state->total += out; in zlib_inflate()
711 strm->adler = state->check = in zlib_inflate()
712 UPDATE(state->check, put - out, out); in zlib_inflate()
715 REVERSE(hold)) != state->check) { in zlib_inflate()
717 state->mode = BAD; in zlib_inflate()
722 state->mode = DONE; in zlib_inflate()
745 (state->wsize || (state->mode < CHECK && out != strm->avail_out))) in zlib_inflate()
752 state->total += out; in zlib_inflate()
753 if (INFLATE_NEED_CHECKSUM(strm) && state->wrap && out) in zlib_inflate()
754 strm->adler = state->check = in zlib_inflate()
755 UPDATE(state->check, strm->next_out - out, out); in zlib_inflate()
757 strm->data_type = state->bits + (state->last ? 64 : 0) + in zlib_inflate()
758 (state->mode == TYPE ? 128 : 0); in zlib_inflate()
772 if (strm == NULL || strm->state == NULL) in zlib_inflateEnd()
787 struct inflate_state *state = (struct inflate_state *)z->state; in zlib_inflateIncomp() local
791 if (state->mode != TYPE && state->mode != HEAD) in zlib_inflateIncomp()
804 z->adler = state->check = in zlib_inflateIncomp()
805 UPDATE(state->check, z->next_in, z->avail_in); in zlib_inflateIncomp()
810 state->total += z->avail_in; in zlib_inflateIncomp()