Lines Matching refs:state
97 local void fixedtables OF((struct inflate_state FAR *state));
109 struct inflate_state FAR *state; local
113 state = (struct inflate_state FAR *)strm->state;
114 if (state == Z_NULL || state->strm != strm ||
115 state->mode < HEAD || state->mode > SYNC)
123 struct inflate_state FAR *state; local
126 state = (struct inflate_state FAR *)strm->state;
127 strm->total_in = strm->total_out = state->total = 0;
129 if (state->wrap) /* to support ill-conceived Java test suite */
130 strm->adler = state->wrap & 1;
131 state->mode = HEAD;
132 state->last = 0;
133 state->havedict = 0;
134 state->dmax = 32768U;
135 state->head = Z_NULL;
136 state->hold = 0;
137 state->bits = 0;
138 state->lencode = state->distcode = state->next = state->codes;
139 state->sane = 1;
140 state->back = -1;
148 struct inflate_state FAR *state; local
151 state = (struct inflate_state FAR *)strm->state;
152 state->wsize = 0;
153 state->whave = 0;
154 state->wnext = 0;
163 struct inflate_state FAR *state; local
167 state = (struct inflate_state FAR *)strm->state;
185 if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
186 ZFREE(strm, state->window);
187 state->window = Z_NULL;
191 state->wrap = wrap;
192 state->wbits = (unsigned)windowBits;
203 struct inflate_state FAR *state; local
224 state = (struct inflate_state FAR *)
226 if (state == Z_NULL) return Z_MEM_ERROR;
228 strm->state = (struct internal_state FAR *)state;
229 state->strm = strm;
230 state->window = Z_NULL;
231 state->mode = HEAD; /* to pass state test in inflateReset2() */
232 state->check = 1L; /* 1L is the result of adler32() zero length data */
235 ZFREE(strm, state);
236 strm->state = Z_NULL;
254 struct inflate_state FAR *state; local
257 state = (struct inflate_state FAR *)strm->state;
259 state->hold = 0;
260 state->bits = 0;
263 if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
265 state->hold += (unsigned)value << state->bits;
266 state->bits += (uInt)bits;
280 local void fixedtables(state) in fixedtables() argument
281 struct inflate_state FAR *state; in fixedtables()
295 while (sym < 144) state->lens[sym++] = 8;
296 while (sym < 256) state->lens[sym++] = 9;
297 while (sym < 280) state->lens[sym++] = 7;
298 while (sym < 288) state->lens[sym++] = 8;
302 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
306 while (sym < 32) state->lens[sym++] = 5;
309 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
317 state->lencode = lenfix;
318 state->lenbits = 9;
319 state->distcode = distfix;
320 state->distbits = 5;
347 struct inflate_state state; in makefixed() local
349 fixedtables(&state); in makefixed()
364 printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, in makefixed()
365 state.lencode[low].bits, state.lencode[low].val); in makefixed()
375 printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, in makefixed()
376 state.distcode[low].val); in makefixed()
403 struct inflate_state FAR *state; local
406 state = (struct inflate_state FAR *)strm->state;
409 if (state->window == Z_NULL) {
410 unsigned wsize = 1U << state->wbits;
411 state->window = (unsigned char FAR *)
414 if (state->window == Z_NULL) return 1;
422 zmemzero(state->window + wsize, CHUNKCOPY_CHUNK_SIZE);
427 if (state->wsize == 0) {
428 state->wsize = 1U << state->wbits;
429 state->wnext = 0;
430 state->whave = 0;
434 if (copy >= state->wsize) {
435 zmemcpy(state->window, end - state->wsize, state->wsize);
436 state->wnext = 0;
437 state->whave = state->wsize;
440 dist = state->wsize - state->wnext;
442 zmemcpy(state->window + state->wnext, end - copy, dist);
445 zmemcpy(state->window, end - copy, copy);
446 state->wnext = copy;
447 state->whave = state->wsize;
450 state->wnext += dist;
451 if (state->wnext == state->wsize) state->wnext = 0;
452 if (state->whave < state->wsize) state->whave += dist;
463 (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
494 hold = state->hold; \
495 bits = state->bits; \
505 state->hold = hold; \
506 state->bits = bits; \
638 struct inflate_state FAR *state; local
661 state = (struct inflate_state FAR *)strm->state;
662 if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
668 switch (state->mode) {
670 if (state->wrap == 0) {
671 state->mode = TYPEDO;
676 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
677 if (state->wbits == 0)
678 state->wbits = 15;
679 state->check = crc32(0L, Z_NULL, 0);
680 CRC2(state->check, hold);
682 state->mode = FLAGS;
685 state->flags = 0; /* expect zlib header */
686 if (state->head != Z_NULL)
687 state->head->done = -1;
688 if (!(state->wrap & 1) || /* check if zlib header allowed */
694 state->mode = BAD;
699 state->mode = BAD;
704 if (state->wbits == 0)
705 state->wbits = len;
706 if (len > 15 || len > state->wbits) {
708 state->mode = BAD;
711 state->dmax = 1U << len;
713 strm->adler = state->check = adler32(0L, Z_NULL, 0);
714 state->mode = hold & 0x200 ? DICTID : TYPE;
720 state->flags = (int)(hold);
721 if ((state->flags & 0xff) != Z_DEFLATED) {
723 state->mode = BAD;
726 if (state->flags & 0xe000) {
728 state->mode = BAD;
731 if (state->head != Z_NULL)
732 state->head->text = (int)((hold >> 8) & 1);
733 if ((state->flags & 0x0200) && (state->wrap & 4))
734 CRC2(state->check, hold);
736 state->mode = TIME;
739 if (state->head != Z_NULL)
740 state->head->time = hold;
741 if ((state->flags & 0x0200) && (state->wrap & 4))
742 CRC4(state->check, hold);
744 state->mode = OS;
747 if (state->head != Z_NULL) {
748 state->head->xflags = (int)(hold & 0xff);
749 state->head->os = (int)(hold >> 8);
751 if ((state->flags & 0x0200) && (state->wrap & 4))
752 CRC2(state->check, hold);
754 state->mode = EXLEN;
756 if (state->flags & 0x0400) {
758 state->length = (unsigned)(hold);
759 if (state->head != Z_NULL)
760 state->head->extra_len = (unsigned)hold;
761 if ((state->flags & 0x0200) && (state->wrap & 4))
762 CRC2(state->check, hold);
765 else if (state->head != Z_NULL)
766 state->head->extra = Z_NULL;
767 state->mode = EXTRA;
769 if (state->flags & 0x0400) {
770 copy = state->length;
773 if (state->head != Z_NULL &&
774 state->head->extra != Z_NULL) {
775 len = state->head->extra_len - state->length;
776 zmemcpy(state->head->extra + len, next,
777 len + copy > state->head->extra_max ?
778 state->head->extra_max - len : copy);
780 if ((state->flags & 0x0200) && (state->wrap & 4))
781 state->check = crc32(state->check, next, copy);
784 state->length -= copy;
786 if (state->length) goto inf_leave;
788 state->length = 0;
789 state->mode = NAME;
791 if (state->flags & 0x0800) {
796 if (state->head != Z_NULL &&
797 state->head->name != Z_NULL &&
798 state->length < state->head->name_max)
799 state->head->name[state->length++] = (Bytef)len;
801 if ((state->flags & 0x0200) && (state->wrap & 4))
802 state->check = crc32(state->check, next, copy);
807 else if (state->head != Z_NULL)
808 state->head->name = Z_NULL;
809 state->length = 0;
810 state->mode = COMMENT;
812 if (state->flags & 0x1000) {
817 if (state->head != Z_NULL &&
818 state->head->comment != Z_NULL &&
819 state->length < state->head->comm_max)
820 state->head->comment[state->length++] = (Bytef)len;
822 if ((state->flags & 0x0200) && (state->wrap & 4))
823 state->check = crc32(state->check, next, copy);
828 else if (state->head != Z_NULL)
829 state->head->comment = Z_NULL;
830 state->mode = HCRC;
832 if (state->flags & 0x0200) {
834 if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
836 state->mode = BAD;
841 if (state->head != Z_NULL) {
842 state->head->hcrc = (int)((state->flags >> 9) & 1);
843 state->head->done = 1;
845 strm->adler = state->check = crc32(0L, Z_NULL, 0);
846 state->mode = TYPE;
851 strm->adler = state->check = ZSWAP32(hold);
853 state->mode = DICT;
855 if (state->havedict == 0) {
859 strm->adler = state->check = adler32(0L, Z_NULL, 0);
860 state->mode = TYPE;
864 if (state->last) {
866 state->mode = CHECK;
870 state->last = BITS(1);
875 state->last ? " (last)" : ""));
876 state->mode = STORED;
879 fixedtables(state);
881 state->last ? " (last)" : ""));
882 state->mode = LEN_; /* decode codes */
890 state->last ? " (last)" : ""));
891 state->mode = TABLE;
895 state->mode = BAD;
904 state->mode = BAD;
907 state->length = (unsigned)hold & 0xffff;
909 state->length));
911 state->mode = COPY_;
914 state->mode = COPY;
916 copy = state->length;
926 state->length -= copy;
930 state->mode = TYPE;
934 state->nlen = BITS(5) + 257;
936 state->ndist = BITS(5) + 1;
938 state->ncode = BITS(4) + 4;
941 if (state->nlen > 286 || state->ndist > 30) {
943 state->mode = BAD;
948 state->have = 0;
949 state->mode = LENLENS;
951 while (state->have < state->ncode) {
953 state->lens[order[state->have++]] = (unsigned short)BITS(3);
956 while (state->have < 19)
957 state->lens[order[state->have++]] = 0;
958 state->next = state->codes;
959 state->lencode = (const code FAR *)(state->next);
960 state->lenbits = 7;
961 ret = inflate_table(CODES, state->lens, 19, &(state->next),
962 &(state->lenbits), state->work);
965 state->mode = BAD;
969 state->have = 0;
970 state->mode = CODELENS;
972 while (state->have < state->nlen + state->ndist) {
974 here = state->lencode[BITS(state->lenbits)];
980 state->lens[state->have++] = here.val;
986 if (state->have == 0) {
988 state->mode = BAD;
991 len = state->lens[state->have - 1];
1009 if (state->have + copy > state->nlen + state->ndist) {
1011 state->mode = BAD;
1015 state->lens[state->have++] = (unsigned short)len;
1020 if (state->mode == BAD) break;
1023 if (state->lens[256] == 0) {
1025 state->mode = BAD;
1032 state->next = state->codes;
1033 state->lencode = (const code FAR *)(state->next);
1034 state->lenbits = 9;
1035 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
1036 &(state->lenbits), state->work);
1039 state->mode = BAD;
1042 state->distcode = (const code FAR *)(state->next);
1043 state->distbits = 6;
1044 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
1045 &(state->next), &(state->distbits), state->work);
1048 state->mode = BAD;
1052 state->mode = LEN_;
1055 state->mode = LEN;
1062 if (state->mode == TYPE)
1063 state->back = -1;
1066 state->back = 0;
1068 here = state->lencode[BITS(state->lenbits)];
1075 here = state->lencode[last.val +
1081 state->back += last.bits;
1084 state->back += here.bits;
1085 state->length = (unsigned)here.val;
1090 state->mode = LIT;
1095 state->back = -1;
1096 state->mode = TYPE;
1101 state->mode = BAD;
1104 state->extra = (unsigned)(here.op) & 15;
1105 state->mode = LENEXT;
1107 if (state->extra) {
1108 NEEDBITS(state->extra);
1109 state->length += BITS(state->extra);
1110 DROPBITS(state->extra);
1111 state->back += state->extra;
1113 Tracevv((stderr, "inflate: length %u\n", state->length));
1114 state->was = state->length;
1115 state->mode = DIST;
1118 here = state->distcode[BITS(state->distbits)];
1125 here = state->distcode[last.val +
1131 state->back += last.bits;
1134 state->back += here.bits;
1137 state->mode = BAD;
1140 state->offset = (unsigned)here.val;
1141 state->extra = (unsigned)(here.op) & 15;
1142 state->mode = DISTEXT;
1144 if (state->extra) {
1145 NEEDBITS(state->extra);
1146 state->offset += BITS(state->extra);
1147 DROPBITS(state->extra);
1148 state->back += state->extra;
1151 if (state->offset > state->dmax) {
1153 state->mode = BAD;
1157 Tracevv((stderr, "inflate: distance %u\n", state->offset));
1158 state->mode = MATCH;
1162 if (state->offset > copy) { /* copy from window */
1163 copy = state->offset - copy;
1164 if (copy > state->whave) {
1165 if (state->sane) {
1167 state->mode = BAD;
1172 copy -= state->whave;
1173 if (copy > state->length) copy = state->length;
1176 state->length -= copy;
1180 if (state->length == 0) state->mode = LEN;
1184 if (copy > state->wnext) {
1185 copy -= state->wnext;
1186 from = state->window + (state->wsize - copy);
1189 from = state->window + (state->wnext - copy);
1190 if (copy > state->length) copy = state->length;
1195 copy = state->length;
1197 put = chunkcopy_lapped_safe(put, state->offset, copy, put + left);
1200 state->length -= copy;
1201 if (state->length == 0) state->mode = LEN;
1205 *put++ = (unsigned char)(state->length);
1207 state->mode = LEN;
1210 if (state->wrap) {
1214 state->total += out;
1215 if ((state->wrap & 4) && out)
1216 strm->adler = state->check =
1217 UPDATE(state->check, put - out, out);
1219 if ((state->wrap & 4) && (
1221 state->flags ? hold :
1223 ZSWAP32(hold)) != state->check) {
1225 state->mode = BAD;
1232 state->mode = LENGTH;
1234 if (state->wrap && state->flags) {
1236 if (hold != (state->total & 0xffffffffUL)) {
1238 state->mode = BAD;
1245 state->mode = DONE;
1277 if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
1278 (state->mode < CHECK || flush != Z_FINISH)))
1280 state->mode = MEM;
1287 state->total += out;
1288 if ((state->wrap & 4) && out)
1289 strm->adler = state->check =
1290 UPDATE(state->check, strm->next_out - out, out);
1291 strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
1292 (state->mode == TYPE ? 128 : 0) +
1293 (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
1302 struct inflate_state FAR *state; local
1305 state = (struct inflate_state FAR *)strm->state;
1306 if (state->window != Z_NULL) ZFREE(strm, state->window);
1307 ZFREE(strm, strm->state);
1308 strm->state = Z_NULL;
1318 struct inflate_state FAR *state; local
1322 state = (struct inflate_state FAR *)strm->state;
1325 if (state->whave && dictionary != Z_NULL) {
1326 zmemcpy(dictionary, state->window + state->wnext,
1327 state->whave - state->wnext);
1328 zmemcpy(dictionary + state->whave - state->wnext,
1329 state->window, state->wnext);
1332 *dictLength = state->whave;
1341 struct inflate_state FAR *state; local
1347 state = (struct inflate_state FAR *)strm->state;
1348 if (state->wrap != 0 && state->mode != DICT)
1352 if (state->mode == DICT) {
1355 if (dictid != state->check)
1363 state->mode = MEM;
1366 state->havedict = 1;
1375 struct inflate_state FAR *state; local
1379 state = (struct inflate_state FAR *)strm->state;
1380 if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
1383 state->head = head;
1428 struct inflate_state FAR *state; local
1432 state = (struct inflate_state FAR *)strm->state;
1433 if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
1436 if (state->mode != SYNC) {
1437 state->mode = SYNC;
1438 state->hold <<= state->bits & 7;
1439 state->bits -= state->bits & 7;
1441 while (state->bits >= 8) {
1442 buf[len++] = (unsigned char)(state->hold);
1443 state->hold >>= 8;
1444 state->bits -= 8;
1446 state->have = 0;
1447 syncsearch(&(state->have), buf, len);
1451 len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
1457 if (state->have != 4) return Z_DATA_ERROR;
1461 state->mode = TYPE;
1476 struct inflate_state FAR *state; local
1479 state = (struct inflate_state FAR *)strm->state;
1480 return state->mode == STORED && state->bits == 0;
1487 struct inflate_state FAR *state; local
1495 state = (struct inflate_state FAR *)source->state;
1502 if (state->window != Z_NULL) {
1504 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
1513 zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
1515 if (state->lencode >= state->codes &&
1516 state->lencode <= state->codes + ENOUGH - 1) {
1517 copy->lencode = copy->codes + (state->lencode - state->codes);
1518 copy->distcode = copy->codes + (state->distcode - state->codes);
1520 copy->next = copy->codes + (state->next - state->codes);
1522 wsize = 1U << state->wbits;
1523 zmemcpy(window, state->window, wsize);
1526 dest->state = (struct internal_state FAR *)copy;
1534 struct inflate_state FAR *state; local
1537 state = (struct inflate_state FAR *)strm->state;
1539 state->sane = !subvert;
1543 state->sane = 1;
1552 struct inflate_state FAR *state; local
1555 state = (struct inflate_state FAR *)strm->state;
1557 state->wrap |= 4;
1559 state->wrap &= ~4;
1566 struct inflate_state FAR *state; local
1570 state = (struct inflate_state FAR *)strm->state;
1571 return (long)(((unsigned long)((long)state->back)) << 16) +
1572 (state->mode == COPY ? state->length :
1573 (state->mode == MATCH ? state->was - state->length : 0));
1579 struct inflate_state FAR *state; local
1581 state = (struct inflate_state FAR *)strm->state;
1582 return (unsigned long)(state->next - state->codes);