Lines Matching refs:state
95 local void fixedtables OF((struct inflate_state FAR *state));
107 struct inflate_state FAR *state; in inflateResetKeep() local
109 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; in inflateResetKeep()
110 state = (struct inflate_state FAR *)strm->state; in inflateResetKeep()
111 strm->total_in = strm->total_out = state->total = 0; in inflateResetKeep()
113 if (state->wrap) /* to support ill-conceived Java test suite */ in inflateResetKeep()
114 strm->adler = state->wrap & 1; in inflateResetKeep()
115 state->mode = HEAD; in inflateResetKeep()
116 state->last = 0; in inflateResetKeep()
117 state->havedict = 0; in inflateResetKeep()
118 state->dmax = 32768U; in inflateResetKeep()
119 state->head = Z_NULL; in inflateResetKeep()
120 state->hold = 0; in inflateResetKeep()
121 state->bits = 0; in inflateResetKeep()
122 state->lencode = state->distcode = state->next = state->codes; in inflateResetKeep()
123 state->sane = 1; in inflateResetKeep()
124 state->back = -1; in inflateResetKeep()
132 struct inflate_state FAR *state; in inflateReset() local
134 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; in inflateReset()
135 state = (struct inflate_state FAR *)strm->state; in inflateReset()
136 state->wsize = 0; in inflateReset()
137 state->whave = 0; in inflateReset()
138 state->wnext = 0; in inflateReset()
147 struct inflate_state FAR *state; in inflateReset2() local
150 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; in inflateReset2()
151 state = (struct inflate_state FAR *)strm->state; in inflateReset2()
169 if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) { in inflateReset2()
170 ZFREE(strm, state->window); in inflateReset2()
171 state->window = Z_NULL; in inflateReset2()
175 state->wrap = wrap; in inflateReset2()
176 state->wbits = (unsigned)windowBits; in inflateReset2()
187 struct inflate_state FAR *state; in inflateInit2_() local
208 state = (struct inflate_state FAR *) in inflateInit2_()
210 if (state == Z_NULL) return Z_MEM_ERROR; in inflateInit2_()
212 strm->state = (struct internal_state FAR *)state; in inflateInit2_()
213 state->window = Z_NULL; in inflateInit2_()
216 ZFREE(strm, state); in inflateInit2_()
217 strm->state = Z_NULL; in inflateInit2_()
235 struct inflate_state FAR *state; in inflatePrime() local
237 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; in inflatePrime()
238 state = (struct inflate_state FAR *)strm->state; in inflatePrime()
240 state->hold = 0; in inflatePrime()
241 state->bits = 0; in inflatePrime()
244 if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; in inflatePrime()
246 state->hold += value << state->bits; in inflatePrime()
247 state->bits += bits; in inflatePrime()
262 struct inflate_state FAR *state) in fixedtables() argument
276 while (sym < 144) state->lens[sym++] = 8; in fixedtables()
277 while (sym < 256) state->lens[sym++] = 9; in fixedtables()
278 while (sym < 280) state->lens[sym++] = 7; in fixedtables()
279 while (sym < 288) state->lens[sym++] = 8; in fixedtables()
283 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); in fixedtables()
287 while (sym < 32) state->lens[sym++] = 5; in fixedtables()
290 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); in fixedtables()
298 state->lencode = lenfix; in fixedtables()
299 state->lenbits = 9; in fixedtables()
300 state->distcode = distfix; in fixedtables()
301 state->distbits = 5; in fixedtables()
328 struct inflate_state state; in makefixed() local
330 fixedtables(&state); in makefixed()
345 printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, in makefixed()
346 state.lencode[low].bits, state.lencode[low].val); in makefixed()
356 printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, in makefixed()
357 state.distcode[low].val); in makefixed()
384 struct inflate_state FAR *state; in updatewindow() local
387 state = (struct inflate_state FAR *)strm->state; in updatewindow()
390 if (state->window == Z_NULL) { in updatewindow()
391 state->window = (unsigned char FAR *) in updatewindow()
392 ZALLOC(strm, 1U << state->wbits, in updatewindow()
394 if (state->window == Z_NULL) return 1; in updatewindow()
398 if (state->wsize == 0) { in updatewindow()
399 state->wsize = 1U << state->wbits; in updatewindow()
400 state->wnext = 0; in updatewindow()
401 state->whave = 0; in updatewindow()
405 if (copy >= state->wsize) { in updatewindow()
406 zmemcpy(state->window, end - state->wsize, state->wsize); in updatewindow()
407 state->wnext = 0; in updatewindow()
408 state->whave = state->wsize; in updatewindow()
411 dist = state->wsize - state->wnext; in updatewindow()
413 zmemcpy(state->window + state->wnext, end - copy, dist); in updatewindow()
416 zmemcpy(state->window, end - copy, copy); in updatewindow()
417 state->wnext = copy; in updatewindow()
418 state->whave = state->wsize; in updatewindow()
421 state->wnext += dist; in updatewindow()
422 if (state->wnext == state->wsize) state->wnext = 0; in updatewindow()
423 if (state->whave < state->wsize) state->whave += dist; in updatewindow()
434 (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
465 hold = state->hold; \
466 bits = state->bits; \
476 state->hold = hold; \
477 state->bits = bits; \
609 struct inflate_state FAR *state; in inflate() local
628 if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || in inflate()
632 state = (struct inflate_state FAR *)strm->state; in inflate()
633 if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ in inflate()
639 switch (state->mode) { in inflate()
641 if (state->wrap == 0) { in inflate()
642 state->mode = TYPEDO; in inflate()
647 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ in inflate()
648 state->check = crc32(0L, Z_NULL, 0); in inflate()
649 CRC2(state->check, hold); in inflate()
651 state->mode = FLAGS; in inflate()
654 state->flags = 0; /* expect zlib header */ in inflate()
655 if (state->head != Z_NULL) in inflate()
656 state->head->done = -1; in inflate()
657 if (!(state->wrap & 1) || /* check if zlib header allowed */ in inflate()
663 state->mode = BAD; in inflate()
668 state->mode = BAD; in inflate()
673 if (state->wbits == 0) in inflate()
674 state->wbits = len; in inflate()
675 else if (len > state->wbits) { in inflate()
677 state->mode = BAD; in inflate()
680 state->dmax = 1U << len; in inflate()
682 strm->adler = state->check = adler32(0L, Z_NULL, 0); in inflate()
683 state->mode = hold & 0x200 ? DICTID : TYPE; in inflate()
689 state->flags = (int)(hold); in inflate()
690 if ((state->flags & 0xff) != Z_DEFLATED) { in inflate()
692 state->mode = BAD; in inflate()
695 if (state->flags & 0xe000) { in inflate()
697 state->mode = BAD; in inflate()
700 if (state->head != Z_NULL) in inflate()
701 state->head->text = (int)((hold >> 8) & 1); in inflate()
702 if (state->flags & 0x0200) CRC2(state->check, hold); in inflate()
704 state->mode = TIME; in inflate()
707 if (state->head != Z_NULL) in inflate()
708 state->head->time = hold; in inflate()
709 if (state->flags & 0x0200) CRC4(state->check, hold); in inflate()
711 state->mode = OS; in inflate()
714 if (state->head != Z_NULL) { in inflate()
715 state->head->xflags = (int)(hold & 0xff); in inflate()
716 state->head->os = (int)(hold >> 8); in inflate()
718 if (state->flags & 0x0200) CRC2(state->check, hold); in inflate()
720 state->mode = EXLEN; in inflate()
722 if (state->flags & 0x0400) { in inflate()
724 state->length = (unsigned)(hold); in inflate()
725 if (state->head != Z_NULL) in inflate()
726 state->head->extra_len = (unsigned)hold; in inflate()
727 if (state->flags & 0x0200) CRC2(state->check, hold); in inflate()
730 else if (state->head != Z_NULL) in inflate()
731 state->head->extra = Z_NULL; in inflate()
732 state->mode = EXTRA; in inflate()
734 if (state->flags & 0x0400) { in inflate()
735 copy = state->length; in inflate()
738 if (state->head != Z_NULL && in inflate()
739 state->head->extra != Z_NULL) { in inflate()
740 len = state->head->extra_len - state->length; in inflate()
741 zmemcpy(state->head->extra + len, next, in inflate()
742 len + copy > state->head->extra_max ? in inflate()
743 state->head->extra_max - len : copy); in inflate()
745 if (state->flags & 0x0200) in inflate()
746 state->check = crc32(state->check, next, copy); in inflate()
749 state->length -= copy; in inflate()
751 if (state->length) goto inf_leave; in inflate()
753 state->length = 0; in inflate()
754 state->mode = NAME; in inflate()
756 if (state->flags & 0x0800) { in inflate()
761 if (state->head != Z_NULL && in inflate()
762 state->head->name != Z_NULL && in inflate()
763 state->length < state->head->name_max) in inflate()
764 state->head->name[state->length++] = len; in inflate()
766 if (state->flags & 0x0200) in inflate()
767 state->check = crc32(state->check, next, copy); in inflate()
772 else if (state->head != Z_NULL) in inflate()
773 state->head->name = Z_NULL; in inflate()
774 state->length = 0; in inflate()
775 state->mode = COMMENT; in inflate()
777 if (state->flags & 0x1000) { in inflate()
782 if (state->head != Z_NULL && in inflate()
783 state->head->comment != Z_NULL && in inflate()
784 state->length < state->head->comm_max) in inflate()
785 state->head->comment[state->length++] = len; in inflate()
787 if (state->flags & 0x0200) in inflate()
788 state->check = crc32(state->check, next, copy); in inflate()
793 else if (state->head != Z_NULL) in inflate()
794 state->head->comment = Z_NULL; in inflate()
795 state->mode = HCRC; in inflate()
797 if (state->flags & 0x0200) { in inflate()
799 if (hold != (state->check & 0xffff)) { in inflate()
801 state->mode = BAD; in inflate()
806 if (state->head != Z_NULL) { in inflate()
807 state->head->hcrc = (int)((state->flags >> 9) & 1); in inflate()
808 state->head->done = 1; in inflate()
810 strm->adler = state->check = crc32(0L, Z_NULL, 0); in inflate()
811 state->mode = TYPE; in inflate()
816 strm->adler = state->check = ZSWAP32(hold); in inflate()
818 state->mode = DICT; in inflate()
820 if (state->havedict == 0) { in inflate()
824 strm->adler = state->check = adler32(0L, Z_NULL, 0); in inflate()
825 state->mode = TYPE; in inflate()
829 if (state->last) { in inflate()
831 state->mode = CHECK; in inflate()
835 state->last = BITS(1); in inflate()
840 state->last ? " (last)" : "")); in inflate()
841 state->mode = STORED; in inflate()
844 fixedtables(state); in inflate()
846 state->last ? " (last)" : "")); in inflate()
847 state->mode = LEN_; /* decode codes */ in inflate()
855 state->last ? " (last)" : "")); in inflate()
856 state->mode = TABLE; in inflate()
860 state->mode = BAD; in inflate()
869 state->mode = BAD; in inflate()
872 state->length = (unsigned)hold & 0xffff; in inflate()
874 state->length)); in inflate()
876 state->mode = COPY_; in inflate()
879 state->mode = COPY; in inflate()
881 copy = state->length; in inflate()
891 state->length -= copy; in inflate()
895 state->mode = TYPE; in inflate()
899 state->nlen = BITS(5) + 257; in inflate()
901 state->ndist = BITS(5) + 1; in inflate()
903 state->ncode = BITS(4) + 4; in inflate()
906 if (state->nlen > 286 || state->ndist > 30) { in inflate()
908 state->mode = BAD; in inflate()
913 state->have = 0; in inflate()
914 state->mode = LENLENS; in inflate()
916 while (state->have < state->ncode) { in inflate()
918 state->lens[order[state->have++]] = (unsigned short)BITS(3); in inflate()
921 while (state->have < 19) in inflate()
922 state->lens[order[state->have++]] = 0; in inflate()
923 state->next = state->codes; in inflate()
924 state->lencode = (const code FAR *)(state->next); in inflate()
925 state->lenbits = 7; in inflate()
926 ret = inflate_table(CODES, state->lens, 19, &(state->next), in inflate()
927 &(state->lenbits), state->work); in inflate()
930 state->mode = BAD; in inflate()
934 state->have = 0; in inflate()
935 state->mode = CODELENS; in inflate()
937 while (state->have < state->nlen + state->ndist) { in inflate()
939 here = state->lencode[BITS(state->lenbits)]; in inflate()
945 state->lens[state->have++] = here.val; in inflate()
951 if (state->have == 0) { in inflate()
953 state->mode = BAD; in inflate()
956 len = state->lens[state->have - 1]; in inflate()
974 if (state->have + copy > state->nlen + state->ndist) { in inflate()
976 state->mode = BAD; in inflate()
980 state->lens[state->have++] = (unsigned short)len; in inflate()
985 if (state->mode == BAD) break; in inflate()
988 if (state->lens[256] == 0) { in inflate()
990 state->mode = BAD; in inflate()
997 state->next = state->codes; in inflate()
998 state->lencode = (const code FAR *)(state->next); in inflate()
999 state->lenbits = 9; in inflate()
1000 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), in inflate()
1001 &(state->lenbits), state->work); in inflate()
1004 state->mode = BAD; in inflate()
1007 state->distcode = (const code FAR *)(state->next); in inflate()
1008 state->distbits = 6; in inflate()
1009 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, in inflate()
1010 &(state->next), &(state->distbits), state->work); in inflate()
1013 state->mode = BAD; in inflate()
1017 state->mode = LEN_; in inflate()
1020 state->mode = LEN; in inflate()
1026 if (state->mode == TYPE) in inflate()
1027 state->back = -1; in inflate()
1030 state->back = 0; in inflate()
1032 here = state->lencode[BITS(state->lenbits)]; in inflate()
1039 here = state->lencode[last.val + in inflate()
1045 state->back += last.bits; in inflate()
1048 state->back += here.bits; in inflate()
1049 state->length = (unsigned)here.val; in inflate()
1054 state->mode = LIT; in inflate()
1059 state->back = -1; in inflate()
1060 state->mode = TYPE; in inflate()
1065 state->mode = BAD; in inflate()
1068 state->extra = (unsigned)(here.op) & 15; in inflate()
1069 state->mode = LENEXT; in inflate()
1071 if (state->extra) { in inflate()
1072 NEEDBITS(state->extra); in inflate()
1073 state->length += BITS(state->extra); in inflate()
1074 DROPBITS(state->extra); in inflate()
1075 state->back += state->extra; in inflate()
1077 Tracevv((stderr, "inflate: length %u\n", state->length)); in inflate()
1078 state->was = state->length; in inflate()
1079 state->mode = DIST; in inflate()
1082 here = state->distcode[BITS(state->distbits)]; in inflate()
1089 here = state->distcode[last.val + in inflate()
1095 state->back += last.bits; in inflate()
1098 state->back += here.bits; in inflate()
1101 state->mode = BAD; in inflate()
1104 state->offset = (unsigned)here.val; in inflate()
1105 state->extra = (unsigned)(here.op) & 15; in inflate()
1106 state->mode = DISTEXT; in inflate()
1108 if (state->extra) { in inflate()
1109 NEEDBITS(state->extra); in inflate()
1110 state->offset += BITS(state->extra); in inflate()
1111 DROPBITS(state->extra); in inflate()
1112 state->back += state->extra; in inflate()
1115 if (state->offset > state->dmax) { in inflate()
1117 state->mode = BAD; in inflate()
1121 Tracevv((stderr, "inflate: distance %u\n", state->offset)); in inflate()
1122 state->mode = MATCH; in inflate()
1126 if (state->offset > copy) { /* copy from window */ in inflate()
1127 copy = state->offset - copy; in inflate()
1128 if (copy > state->whave) { in inflate()
1129 if (state->sane) { in inflate()
1131 state->mode = BAD; in inflate()
1136 copy -= state->whave; in inflate()
1137 if (copy > state->length) copy = state->length; in inflate()
1140 state->length -= copy; in inflate()
1144 if (state->length == 0) state->mode = LEN; in inflate()
1148 if (copy > state->wnext) { in inflate()
1149 copy -= state->wnext; in inflate()
1150 from = state->window + (state->wsize - copy); in inflate()
1153 from = state->window + (state->wnext - copy); in inflate()
1154 if (copy > state->length) copy = state->length; in inflate()
1157 from = put - state->offset; in inflate()
1158 copy = state->length; in inflate()
1162 state->length -= copy; in inflate()
1166 if (state->length == 0) state->mode = LEN; in inflate()
1170 *put++ = (unsigned char)(state->length); in inflate()
1172 state->mode = LEN; in inflate()
1175 if (state->wrap) { in inflate()
1179 state->total += out; in inflate()
1181 strm->adler = state->check = in inflate()
1182 UPDATE(state->check, put - out, out); in inflate()
1186 state->flags ? hold : in inflate()
1188 ZSWAP32(hold)) != state->check) { in inflate()
1190 state->mode = BAD; in inflate()
1197 state->mode = LENGTH; in inflate()
1199 if (state->wrap && state->flags) { in inflate()
1201 if (hold != (state->total & 0xffffffffUL)) { in inflate()
1203 state->mode = BAD; in inflate()
1210 state->mode = DONE; in inflate()
1232 if (state->wsize || (out != strm->avail_out && state->mode < BAD && in inflate()
1233 (state->mode < CHECK || flush != Z_FINISH))) in inflate()
1235 state->mode = MEM; in inflate()
1242 state->total += out; in inflate()
1243 if (state->wrap && out) in inflate()
1244 strm->adler = state->check = in inflate()
1245 UPDATE(state->check, strm->next_out - out, out); in inflate()
1246 strm->data_type = state->bits + (state->last ? 64 : 0) + in inflate()
1247 (state->mode == TYPE ? 128 : 0) + in inflate()
1248 (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); in inflate()
1257 struct inflate_state FAR *state; in inflateEnd() local
1258 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) in inflateEnd()
1260 state = (struct inflate_state FAR *)strm->state; in inflateEnd()
1261 if (state->window != Z_NULL) ZFREE(strm, state->window); in inflateEnd()
1262 ZFREE(strm, strm->state); in inflateEnd()
1263 strm->state = Z_NULL; in inflateEnd()
1273 struct inflate_state FAR *state; in inflateGetDictionary() local
1276 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; in inflateGetDictionary()
1277 state = (struct inflate_state FAR *)strm->state; in inflateGetDictionary()
1280 if (state->whave && dictionary != Z_NULL) { in inflateGetDictionary()
1281 zmemcpy(dictionary, state->window + state->wnext, in inflateGetDictionary()
1282 state->whave - state->wnext); in inflateGetDictionary()
1283 zmemcpy(dictionary + state->whave - state->wnext, in inflateGetDictionary()
1284 state->window, state->wnext); in inflateGetDictionary()
1287 *dictLength = state->whave; in inflateGetDictionary()
1296 struct inflate_state FAR *state; in inflateSetDictionary() local
1302 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; in inflateSetDictionary()
1303 state = (struct inflate_state FAR *)strm->state; in inflateSetDictionary()
1304 if (state->wrap != 0 && state->mode != DICT) in inflateSetDictionary()
1308 if (state->mode == DICT) { in inflateSetDictionary()
1311 if (dictid != state->check) in inflateSetDictionary()
1319 state->mode = MEM; in inflateSetDictionary()
1322 state->havedict = 1; in inflateSetDictionary()
1331 struct inflate_state FAR *state; in inflateGetHeader() local
1334 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; in inflateGetHeader()
1335 state = (struct inflate_state FAR *)strm->state; in inflateGetHeader()
1336 if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; in inflateGetHeader()
1339 state->head = head; in inflateGetHeader()
1384 struct inflate_state FAR *state; in inflateSync() local
1387 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; in inflateSync()
1388 state = (struct inflate_state FAR *)strm->state; in inflateSync()
1389 if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; in inflateSync()
1392 if (state->mode != SYNC) { in inflateSync()
1393 state->mode = SYNC; in inflateSync()
1394 state->hold <<= state->bits & 7; in inflateSync()
1395 state->bits -= state->bits & 7; in inflateSync()
1397 while (state->bits >= 8) { in inflateSync()
1398 buf[len++] = (unsigned char)(state->hold); in inflateSync()
1399 state->hold >>= 8; in inflateSync()
1400 state->bits -= 8; in inflateSync()
1402 state->have = 0; in inflateSync()
1403 syncsearch(&(state->have), buf, len); in inflateSync()
1407 len = syncsearch(&(state->have), strm->next_in, strm->avail_in); in inflateSync()
1413 if (state->have != 4) return Z_DATA_ERROR; in inflateSync()
1417 state->mode = TYPE; in inflateSync()
1432 struct inflate_state FAR *state; in inflateSyncPoint() local
1434 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; in inflateSyncPoint()
1435 state = (struct inflate_state FAR *)strm->state; in inflateSyncPoint()
1436 return state->mode == STORED && state->bits == 0; in inflateSyncPoint()
1443 struct inflate_state FAR *state; in inflateCopy() local
1449 if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || in inflateCopy()
1452 state = (struct inflate_state FAR *)source->state; in inflateCopy()
1459 if (state->window != Z_NULL) { in inflateCopy()
1461 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); in inflateCopy()
1470 zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); in inflateCopy()
1471 if (state->lencode >= state->codes && in inflateCopy()
1472 state->lencode <= state->codes + ENOUGH - 1) { in inflateCopy()
1473 copy->lencode = copy->codes + (state->lencode - state->codes); in inflateCopy()
1474 copy->distcode = copy->codes + (state->distcode - state->codes); in inflateCopy()
1476 copy->next = copy->codes + (state->next - state->codes); in inflateCopy()
1478 wsize = 1U << state->wbits; in inflateCopy()
1479 zmemcpy(window, state->window, wsize); in inflateCopy()
1482 dest->state = (struct internal_state FAR *)copy; in inflateCopy()
1490 struct inflate_state FAR *state; in inflateUndermine() local
1492 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; in inflateUndermine()
1493 state = (struct inflate_state FAR *)strm->state; in inflateUndermine()
1494 state->sane = !subvert; in inflateUndermine()
1498 state->sane = 1; in inflateUndermine()
1506 struct inflate_state FAR *state; in inflateMark() local
1508 if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16; in inflateMark()
1509 state = (struct inflate_state FAR *)strm->state; in inflateMark()
1510 return ((long)(state->back) << 16) + in inflateMark()
1511 (state->mode == COPY ? state->length : in inflateMark()
1512 (state->mode == MATCH ? state->was - state->length : 0)); in inflateMark()