• Home
  • Raw
  • Download

Lines Matching refs:state

25     struct inflate_state *state;  in zlib_inflateReset()  local
27 if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR; in zlib_inflateReset()
28 state = (struct inflate_state *)strm->state; in zlib_inflateReset()
29 strm->total_in = strm->total_out = state->total = 0; in zlib_inflateReset()
32 state->mode = HEAD; in zlib_inflateReset()
33 state->last = 0; in zlib_inflateReset()
34 state->havedict = 0; in zlib_inflateReset()
35 state->dmax = 32768U; in zlib_inflateReset()
36 state->hold = 0; in zlib_inflateReset()
37 state->bits = 0; in zlib_inflateReset()
38 state->lencode = state->distcode = state->next = state->codes; in zlib_inflateReset()
41 state->wsize = 1U << state->wbits; in zlib_inflateReset()
42 state->write = 0; in zlib_inflateReset()
43 state->whave = 0; in zlib_inflateReset()
51 struct inflate_state *state;
53 if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR;
54 state = (struct inflate_state *)strm->state;
55 if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
57 state->hold += value << state->bits;
58 state->bits += bits;
65 struct inflate_state *state; in zlib_inflateInit2() local
70 state = &WS(strm)->inflate_state; in zlib_inflateInit2()
71 strm->state = (struct internal_state *)state; in zlib_inflateInit2()
74 state->wrap = 0; in zlib_inflateInit2()
78 state->wrap = (windowBits >> 4) + 1; in zlib_inflateInit2()
83 state->wbits = (unsigned)windowBits; in zlib_inflateInit2()
84 state->window = &WS(strm)->working_window[0]; in zlib_inflateInit2()
93 static void zlib_fixedtables(struct inflate_state *state) in zlib_fixedtables() argument
96 state->lencode = lenfix; in zlib_fixedtables()
97 state->lenbits = 9; in zlib_fixedtables()
98 state->distcode = distfix; in zlib_fixedtables()
99 state->distbits = 5; in zlib_fixedtables()
118 struct inflate_state *state; in zlib_updatewindow() local
121 state = (struct inflate_state *)strm->state; in zlib_updatewindow()
125 if (copy >= state->wsize) { in zlib_updatewindow()
126 memcpy(state->window, strm->next_out - state->wsize, state->wsize); in zlib_updatewindow()
127 state->write = 0; in zlib_updatewindow()
128 state->whave = state->wsize; in zlib_updatewindow()
131 dist = state->wsize - state->write; in zlib_updatewindow()
133 memcpy(state->window + state->write, strm->next_out - copy, dist); in zlib_updatewindow()
136 memcpy(state->window, strm->next_out - copy, copy); in zlib_updatewindow()
137 state->write = copy; in zlib_updatewindow()
138 state->whave = state->wsize; in zlib_updatewindow()
141 state->write += dist; in zlib_updatewindow()
142 if (state->write == state->wsize) state->write = 0; in zlib_updatewindow()
143 if (state->whave < state->wsize) state->whave += dist; in zlib_updatewindow()
163 struct inflate_state *state; in zlib_inflateSyncPacket() local
165 if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR; in zlib_inflateSyncPacket()
166 state = (struct inflate_state *)strm->state; in zlib_inflateSyncPacket()
168 if (state->mode == STORED && state->bits == 0) { in zlib_inflateSyncPacket()
169 state->mode = TYPE; in zlib_inflateSyncPacket()
187 hold = state->hold; \
188 bits = state->bits; \
198 state->hold = hold; \
199 state->bits = bits; \
334 struct inflate_state *state; in zlib_inflate() local
353 if (strm == NULL || strm->state == NULL || in zlib_inflate()
357 state = (struct inflate_state *)strm->state; in zlib_inflate()
359 if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ in zlib_inflate()
365 switch (state->mode) { in zlib_inflate()
367 if (state->wrap == 0) { in zlib_inflate()
368 state->mode = TYPEDO; in zlib_inflate()
375 state->mode = BAD; in zlib_inflate()
380 state->mode = BAD; in zlib_inflate()
385 if (len > state->wbits) { in zlib_inflate()
387 state->mode = BAD; in zlib_inflate()
390 state->dmax = 1U << len; in zlib_inflate()
391 strm->adler = state->check = zlib_adler32(0L, NULL, 0); in zlib_inflate()
392 state->mode = hold & 0x200 ? DICTID : TYPE; in zlib_inflate()
397 strm->adler = state->check = REVERSE(hold); in zlib_inflate()
399 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()
410 if (state->last) { in zlib_inflate()
412 state->mode = CHECK; in zlib_inflate()
416 state->last = BITS(1); in zlib_inflate()
420 state->mode = STORED; in zlib_inflate()
423 zlib_fixedtables(state); in zlib_inflate()
424 state->mode = LEN; /* decode codes */ in zlib_inflate()
427 state->mode = TABLE; in zlib_inflate()
431 state->mode = BAD; in zlib_inflate()
440 state->mode = BAD; in zlib_inflate()
443 state->length = (unsigned)hold & 0xffff; in zlib_inflate()
445 state->mode = COPY; in zlib_inflate()
447 copy = state->length; in zlib_inflate()
457 state->length -= copy; in zlib_inflate()
460 state->mode = TYPE; in zlib_inflate()
464 state->nlen = BITS(5) + 257; in zlib_inflate()
466 state->ndist = BITS(5) + 1; in zlib_inflate()
468 state->ncode = BITS(4) + 4; in zlib_inflate()
471 if (state->nlen > 286 || state->ndist > 30) { in zlib_inflate()
473 state->mode = BAD; in zlib_inflate()
477 state->have = 0; in zlib_inflate()
478 state->mode = LENLENS; in zlib_inflate()
480 while (state->have < state->ncode) { in zlib_inflate()
482 state->lens[order[state->have++]] = (unsigned short)BITS(3); in zlib_inflate()
485 while (state->have < 19) in zlib_inflate()
486 state->lens[order[state->have++]] = 0; in zlib_inflate()
487 state->next = state->codes; in zlib_inflate()
488 state->lencode = (code const *)(state->next); in zlib_inflate()
489 state->lenbits = 7; in zlib_inflate()
490 ret = zlib_inflate_table(CODES, state->lens, 19, &(state->next), in zlib_inflate()
491 &(state->lenbits), state->work); in zlib_inflate()
494 state->mode = BAD; in zlib_inflate()
497 state->have = 0; in zlib_inflate()
498 state->mode = CODELENS; in zlib_inflate()
500 while (state->have < state->nlen + state->ndist) { in zlib_inflate()
502 this = state->lencode[BITS(state->lenbits)]; in zlib_inflate()
509 state->lens[state->have++] = this.val; in zlib_inflate()
515 if (state->have == 0) { in zlib_inflate()
517 state->mode = BAD; in zlib_inflate()
520 len = state->lens[state->have - 1]; in zlib_inflate()
538 if (state->have + copy > state->nlen + state->ndist) { in zlib_inflate()
540 state->mode = BAD; in zlib_inflate()
544 state->lens[state->have++] = (unsigned short)len; in zlib_inflate()
549 if (state->mode == BAD) break; in zlib_inflate()
552 state->next = state->codes; in zlib_inflate()
553 state->lencode = (code const *)(state->next); in zlib_inflate()
554 state->lenbits = 9; in zlib_inflate()
555 ret = zlib_inflate_table(LENS, state->lens, state->nlen, &(state->next), in zlib_inflate()
556 &(state->lenbits), state->work); in zlib_inflate()
559 state->mode = BAD; in zlib_inflate()
562 state->distcode = (code const *)(state->next); in zlib_inflate()
563 state->distbits = 6; in zlib_inflate()
564 ret = zlib_inflate_table(DISTS, state->lens + state->nlen, state->ndist, in zlib_inflate()
565 &(state->next), &(state->distbits), state->work); in zlib_inflate()
568 state->mode = BAD; in zlib_inflate()
571 state->mode = LEN; in zlib_inflate()
580 this = state->lencode[BITS(state->lenbits)]; in zlib_inflate()
587 this = state->lencode[last.val + in zlib_inflate()
595 state->length = (unsigned)this.val; in zlib_inflate()
597 state->mode = LIT; in zlib_inflate()
601 state->mode = TYPE; in zlib_inflate()
606 state->mode = BAD; in zlib_inflate()
609 state->extra = (unsigned)(this.op) & 15; in zlib_inflate()
610 state->mode = LENEXT; in zlib_inflate()
612 if (state->extra) { in zlib_inflate()
613 NEEDBITS(state->extra); in zlib_inflate()
614 state->length += BITS(state->extra); in zlib_inflate()
615 DROPBITS(state->extra); in zlib_inflate()
617 state->mode = DIST; in zlib_inflate()
620 this = state->distcode[BITS(state->distbits)]; in zlib_inflate()
627 this = state->distcode[last.val + in zlib_inflate()
637 state->mode = BAD; in zlib_inflate()
640 state->offset = (unsigned)this.val; in zlib_inflate()
641 state->extra = (unsigned)(this.op) & 15; in zlib_inflate()
642 state->mode = DISTEXT; in zlib_inflate()
644 if (state->extra) { in zlib_inflate()
645 NEEDBITS(state->extra); in zlib_inflate()
646 state->offset += BITS(state->extra); in zlib_inflate()
647 DROPBITS(state->extra); in zlib_inflate()
650 if (state->offset > state->dmax) { in zlib_inflate()
652 state->mode = BAD; in zlib_inflate()
656 if (state->offset > state->whave + out - left) { in zlib_inflate()
658 state->mode = BAD; in zlib_inflate()
661 state->mode = MATCH; in zlib_inflate()
665 if (state->offset > copy) { /* copy from window */ in zlib_inflate()
666 copy = state->offset - copy; in zlib_inflate()
667 if (copy > state->write) { in zlib_inflate()
668 copy -= state->write; in zlib_inflate()
669 from = state->window + (state->wsize - copy); in zlib_inflate()
672 from = state->window + (state->write - copy); in zlib_inflate()
673 if (copy > state->length) copy = state->length; in zlib_inflate()
676 from = put - state->offset; in zlib_inflate()
677 copy = state->length; in zlib_inflate()
681 state->length -= copy; in zlib_inflate()
685 if (state->length == 0) state->mode = LEN; in zlib_inflate()
689 *put++ = (unsigned char)(state->length); in zlib_inflate()
691 state->mode = LEN; in zlib_inflate()
694 if (state->wrap) { in zlib_inflate()
698 state->total += out; in zlib_inflate()
700 strm->adler = state->check = in zlib_inflate()
701 UPDATE(state->check, put - out, out); in zlib_inflate()
704 REVERSE(hold)) != state->check) { in zlib_inflate()
706 state->mode = BAD; in zlib_inflate()
711 state->mode = DONE; in zlib_inflate()
732 if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) in zlib_inflate()
739 state->total += out; in zlib_inflate()
740 if (state->wrap && out) in zlib_inflate()
741 strm->adler = state->check = in zlib_inflate()
742 UPDATE(state->check, strm->next_out - out, out); in zlib_inflate()
744 strm->data_type = state->bits + (state->last ? 64 : 0) + in zlib_inflate()
745 (state->mode == TYPE ? 128 : 0); in zlib_inflate()
759 if (strm == NULL || strm->state == NULL) in zlib_inflateEnd()
768 struct inflate_state *state;
772 if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR;
773 state = (struct inflate_state *)strm->state;
774 if (state->wrap != 0 && state->mode != DICT)
778 if (state->mode == DICT) {
781 if (id != state->check)
788 if (dictLength > state->wsize) {
789 memcpy(state->window, dictionary + dictLength - state->wsize,
790 state->wsize);
791 state->whave = state->wsize;
794 memcpy(state->window + state->wsize - dictLength, dictionary,
796 state->whave = dictLength;
798 state->havedict = 1;
843 struct inflate_state *state;
846 if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR;
847 state = (struct inflate_state *)strm->state;
848 if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
851 if (state->mode != SYNC) {
852 state->mode = SYNC;
853 state->hold <<= state->bits & 7;
854 state->bits -= state->bits & 7;
856 while (state->bits >= 8) {
857 buf[len++] = (unsigned char)(state->hold);
858 state->hold >>= 8;
859 state->bits -= 8;
861 state->have = 0;
862 zlib_syncsearch(&(state->have), buf, len);
866 len = zlib_syncsearch(&(state->have), strm->next_in, strm->avail_in);
872 if (state->have != 4) return Z_DATA_ERROR;
876 state->mode = TYPE;
891 struct inflate_state *state = (struct inflate_state *)z->state; in zlib_inflateIncomp() local
895 if (state->mode != TYPE && state->mode != HEAD) in zlib_inflateIncomp()
908 z->adler = state->check = in zlib_inflateIncomp()
909 UPDATE(state->check, z->next_in, z->avail_in); in zlib_inflateIncomp()
914 state->total += z->avail_in; in zlib_inflateIncomp()