• Home
  • Raw
  • Download

Lines Matching refs:state

96 local void fixedtables OF((struct inflate_state FAR *state));
108 struct inflate_state FAR *state; local
112 state = (struct inflate_state FAR *)strm->state;
113 if (state == Z_NULL || state->strm != strm ||
114 state->mode < HEAD || state->mode > SYNC)
122 struct inflate_state FAR *state; local
125 state = (struct inflate_state FAR *)strm->state;
126 strm->total_in = strm->total_out = state->total = 0;
128 if (state->wrap) /* to support ill-conceived Java test suite */
129 strm->adler = state->wrap & 1;
130 state->mode = HEAD;
131 state->last = 0;
132 state->havedict = 0;
133 state->dmax = 32768U;
134 state->head = Z_NULL;
135 state->hold = 0;
136 state->bits = 0;
137 state->lencode = state->distcode = state->next = state->codes;
138 state->sane = 1;
139 state->back = -1;
147 struct inflate_state FAR *state; local
150 state = (struct inflate_state FAR *)strm->state;
151 state->wsize = 0;
152 state->whave = 0;
153 state->wnext = 0;
162 struct inflate_state FAR *state; local
166 state = (struct inflate_state FAR *)strm->state;
184 if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
185 ZFREE(strm, state->window);
186 state->window = Z_NULL;
190 state->wrap = wrap;
191 state->wbits = (unsigned)windowBits;
202 struct inflate_state FAR *state; local
223 state = (struct inflate_state FAR *)
225 if (state == Z_NULL) return Z_MEM_ERROR;
227 strm->state = (struct internal_state FAR *)state;
228 state->strm = strm;
229 state->window = Z_NULL;
230 state->mode = HEAD; /* to pass state test in inflateReset2() */
231 state->check = 1L; /* 1L is the result of adler32() zero length data */
234 ZFREE(strm, state);
235 strm->state = Z_NULL;
253 struct inflate_state FAR *state; local
256 state = (struct inflate_state FAR *)strm->state;
258 state->hold = 0;
259 state->bits = 0;
262 if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
264 state->hold += (unsigned)value << state->bits;
265 state->bits += (uInt)bits;
279 local void fixedtables(state) in fixedtables() argument
280 struct inflate_state FAR *state; in fixedtables()
294 while (sym < 144) state->lens[sym++] = 8;
295 while (sym < 256) state->lens[sym++] = 9;
296 while (sym < 280) state->lens[sym++] = 7;
297 while (sym < 288) state->lens[sym++] = 8;
301 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
305 while (sym < 32) state->lens[sym++] = 5;
308 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
316 state->lencode = lenfix;
317 state->lenbits = 9;
318 state->distcode = distfix;
319 state->distbits = 5;
346 struct inflate_state state; in makefixed() local
348 fixedtables(&state); in makefixed()
363 printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, in makefixed()
364 state.lencode[low].bits, state.lencode[low].val); in makefixed()
374 printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, in makefixed()
375 state.distcode[low].val); in makefixed()
402 struct inflate_state FAR *state; local
405 state = (struct inflate_state FAR *)strm->state;
408 if (state->window == Z_NULL) {
409 state->window = (unsigned char FAR *)
410 ZALLOC(strm, 1U << state->wbits,
412 if (state->window == Z_NULL) return 1;
416 if (state->wsize == 0) {
417 state->wsize = 1U << state->wbits;
418 state->wnext = 0;
419 state->whave = 0;
423 if (copy >= state->wsize) {
424 zmemcpy(state->window, end - state->wsize, state->wsize);
425 state->wnext = 0;
426 state->whave = state->wsize;
429 dist = state->wsize - state->wnext;
431 zmemcpy(state->window + state->wnext, end - copy, dist);
434 zmemcpy(state->window, end - copy, copy);
435 state->wnext = copy;
436 state->whave = state->wsize;
439 state->wnext += dist;
440 if (state->wnext == state->wsize) state->wnext = 0;
441 if (state->whave < state->wsize) state->whave += dist;
452 (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
483 hold = state->hold; \
484 bits = state->bits; \
494 state->hold = hold; \
495 state->bits = bits; \
627 struct inflate_state FAR *state; local
650 state = (struct inflate_state FAR *)strm->state;
651 if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
657 switch (state->mode) {
659 if (state->wrap == 0) {
660 state->mode = TYPEDO;
665 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
666 if (state->wbits == 0)
667 state->wbits = 15;
668 state->check = crc32(0L, Z_NULL, 0);
669 CRC2(state->check, hold);
671 state->mode = FLAGS;
674 state->flags = 0; /* expect zlib header */
675 if (state->head != Z_NULL)
676 state->head->done = -1;
677 if (!(state->wrap & 1) || /* check if zlib header allowed */
683 state->mode = BAD;
688 state->mode = BAD;
693 if (state->wbits == 0)
694 state->wbits = len;
695 if (len > 15 || len > state->wbits) {
697 state->mode = BAD;
700 state->dmax = 1U << len;
702 strm->adler = state->check = adler32(0L, Z_NULL, 0);
703 state->mode = hold & 0x200 ? DICTID : TYPE;
709 state->flags = (int)(hold);
710 if ((state->flags & 0xff) != Z_DEFLATED) {
712 state->mode = BAD;
715 if (state->flags & 0xe000) {
717 state->mode = BAD;
720 if (state->head != Z_NULL)
721 state->head->text = (int)((hold >> 8) & 1);
722 if ((state->flags & 0x0200) && (state->wrap & 4))
723 CRC2(state->check, hold);
725 state->mode = TIME;
728 if (state->head != Z_NULL)
729 state->head->time = hold;
730 if ((state->flags & 0x0200) && (state->wrap & 4))
731 CRC4(state->check, hold);
733 state->mode = OS;
736 if (state->head != Z_NULL) {
737 state->head->xflags = (int)(hold & 0xff);
738 state->head->os = (int)(hold >> 8);
740 if ((state->flags & 0x0200) && (state->wrap & 4))
741 CRC2(state->check, hold);
743 state->mode = EXLEN;
745 if (state->flags & 0x0400) {
747 state->length = (unsigned)(hold);
748 if (state->head != Z_NULL)
749 state->head->extra_len = (unsigned)hold;
750 if ((state->flags & 0x0200) && (state->wrap & 4))
751 CRC2(state->check, hold);
754 else if (state->head != Z_NULL)
755 state->head->extra = Z_NULL;
756 state->mode = EXTRA;
758 if (state->flags & 0x0400) {
759 copy = state->length;
762 if (state->head != Z_NULL &&
763 state->head->extra != Z_NULL) {
764 len = state->head->extra_len - state->length;
765 zmemcpy(state->head->extra + len, next,
766 len + copy > state->head->extra_max ?
767 state->head->extra_max - len : copy);
769 if ((state->flags & 0x0200) && (state->wrap & 4))
770 state->check = crc32(state->check, next, copy);
773 state->length -= copy;
775 if (state->length) goto inf_leave;
777 state->length = 0;
778 state->mode = NAME;
780 if (state->flags & 0x0800) {
785 if (state->head != Z_NULL &&
786 state->head->name != Z_NULL &&
787 state->length < state->head->name_max)
788 state->head->name[state->length++] = (Bytef)len;
790 if ((state->flags & 0x0200) && (state->wrap & 4))
791 state->check = crc32(state->check, next, copy);
796 else if (state->head != Z_NULL)
797 state->head->name = Z_NULL;
798 state->length = 0;
799 state->mode = COMMENT;
801 if (state->flags & 0x1000) {
806 if (state->head != Z_NULL &&
807 state->head->comment != Z_NULL &&
808 state->length < state->head->comm_max)
809 state->head->comment[state->length++] = (Bytef)len;
811 if ((state->flags & 0x0200) && (state->wrap & 4))
812 state->check = crc32(state->check, next, copy);
817 else if (state->head != Z_NULL)
818 state->head->comment = Z_NULL;
819 state->mode = HCRC;
821 if (state->flags & 0x0200) {
823 if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
825 state->mode = BAD;
830 if (state->head != Z_NULL) {
831 state->head->hcrc = (int)((state->flags >> 9) & 1);
832 state->head->done = 1;
834 strm->adler = state->check = crc32(0L, Z_NULL, 0);
835 state->mode = TYPE;
840 strm->adler = state->check = ZSWAP32(hold);
842 state->mode = DICT;
844 if (state->havedict == 0) {
848 strm->adler = state->check = adler32(0L, Z_NULL, 0);
849 state->mode = TYPE;
853 if (state->last) {
855 state->mode = CHECK;
859 state->last = BITS(1);
864 state->last ? " (last)" : ""));
865 state->mode = STORED;
868 fixedtables(state);
870 state->last ? " (last)" : ""));
871 state->mode = LEN_; /* decode codes */
879 state->last ? " (last)" : ""));
880 state->mode = TABLE;
884 state->mode = BAD;
893 state->mode = BAD;
896 state->length = (unsigned)hold & 0xffff;
898 state->length));
900 state->mode = COPY_;
903 state->mode = COPY;
905 copy = state->length;
915 state->length -= copy;
919 state->mode = TYPE;
923 state->nlen = BITS(5) + 257;
925 state->ndist = BITS(5) + 1;
927 state->ncode = BITS(4) + 4;
930 if (state->nlen > 286 || state->ndist > 30) {
932 state->mode = BAD;
937 state->have = 0;
938 state->mode = LENLENS;
940 while (state->have < state->ncode) {
942 state->lens[order[state->have++]] = (unsigned short)BITS(3);
945 while (state->have < 19)
946 state->lens[order[state->have++]] = 0;
947 state->next = state->codes;
948 state->lencode = (const code FAR *)(state->next);
949 state->lenbits = 7;
950 ret = inflate_table(CODES, state->lens, 19, &(state->next),
951 &(state->lenbits), state->work);
954 state->mode = BAD;
958 state->have = 0;
959 state->mode = CODELENS;
961 while (state->have < state->nlen + state->ndist) {
963 here = state->lencode[BITS(state->lenbits)];
969 state->lens[state->have++] = here.val;
975 if (state->have == 0) {
977 state->mode = BAD;
980 len = state->lens[state->have - 1];
998 if (state->have + copy > state->nlen + state->ndist) {
1000 state->mode = BAD;
1004 state->lens[state->have++] = (unsigned short)len;
1009 if (state->mode == BAD) break;
1012 if (state->lens[256] == 0) {
1014 state->mode = BAD;
1021 state->next = state->codes;
1022 state->lencode = (const code FAR *)(state->next);
1023 state->lenbits = 9;
1024 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
1025 &(state->lenbits), state->work);
1028 state->mode = BAD;
1031 state->distcode = (const code FAR *)(state->next);
1032 state->distbits = 6;
1033 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
1034 &(state->next), &(state->distbits), state->work);
1037 state->mode = BAD;
1041 state->mode = LEN_;
1044 state->mode = LEN;
1051 if (state->mode == TYPE)
1052 state->back = -1;
1055 state->back = 0;
1057 here = state->lencode[BITS(state->lenbits)];
1064 here = state->lencode[last.val +
1070 state->back += last.bits;
1073 state->back += here.bits;
1074 state->length = (unsigned)here.val;
1079 state->mode = LIT;
1084 state->back = -1;
1085 state->mode = TYPE;
1090 state->mode = BAD;
1093 state->extra = (unsigned)(here.op) & 15;
1094 state->mode = LENEXT;
1096 if (state->extra) {
1097 NEEDBITS(state->extra);
1098 state->length += BITS(state->extra);
1099 DROPBITS(state->extra);
1100 state->back += state->extra;
1102 Tracevv((stderr, "inflate: length %u\n", state->length));
1103 state->was = state->length;
1104 state->mode = DIST;
1107 here = state->distcode[BITS(state->distbits)];
1114 here = state->distcode[last.val +
1120 state->back += last.bits;
1123 state->back += here.bits;
1126 state->mode = BAD;
1129 state->offset = (unsigned)here.val;
1130 state->extra = (unsigned)(here.op) & 15;
1131 state->mode = DISTEXT;
1133 if (state->extra) {
1134 NEEDBITS(state->extra);
1135 state->offset += BITS(state->extra);
1136 DROPBITS(state->extra);
1137 state->back += state->extra;
1140 if (state->offset > state->dmax) {
1142 state->mode = BAD;
1146 Tracevv((stderr, "inflate: distance %u\n", state->offset));
1147 state->mode = MATCH;
1151 if (state->offset > copy) { /* copy from window */
1152 copy = state->offset - copy;
1153 if (copy > state->whave) {
1154 if (state->sane) {
1156 state->mode = BAD;
1161 copy -= state->whave;
1162 if (copy > state->length) copy = state->length;
1165 state->length -= copy;
1169 if (state->length == 0) state->mode = LEN;
1173 if (copy > state->wnext) {
1174 copy -= state->wnext;
1175 from = state->window + (state->wsize - copy);
1178 from = state->window + (state->wnext - copy);
1179 if (copy > state->length) copy = state->length;
1182 from = put - state->offset;
1183 copy = state->length;
1187 state->length -= copy;
1191 if (state->length == 0) state->mode = LEN;
1195 *put++ = (unsigned char)(state->length);
1197 state->mode = LEN;
1200 if (state->wrap) {
1204 state->total += out;
1205 if ((state->wrap & 4) && out)
1206 strm->adler = state->check =
1207 UPDATE(state->check, put - out, out);
1209 if ((state->wrap & 4) && (
1211 state->flags ? hold :
1213 ZSWAP32(hold)) != state->check) {
1215 state->mode = BAD;
1222 state->mode = LENGTH;
1224 if (state->wrap && state->flags) {
1226 if (hold != (state->total & 0xffffffffUL)) {
1228 state->mode = BAD;
1235 state->mode = DONE;
1257 if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
1258 (state->mode < CHECK || flush != Z_FINISH)))
1260 state->mode = MEM;
1267 state->total += out;
1268 if ((state->wrap & 4) && out)
1269 strm->adler = state->check =
1270 UPDATE(state->check, strm->next_out - out, out);
1271 strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
1272 (state->mode == TYPE ? 128 : 0) +
1273 (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
1282 struct inflate_state FAR *state; local
1285 state = (struct inflate_state FAR *)strm->state;
1286 if (state->window != Z_NULL) ZFREE(strm, state->window);
1287 ZFREE(strm, strm->state);
1288 strm->state = Z_NULL;
1298 struct inflate_state FAR *state; local
1302 state = (struct inflate_state FAR *)strm->state;
1305 if (state->whave && dictionary != Z_NULL) {
1306 zmemcpy(dictionary, state->window + state->wnext,
1307 state->whave - state->wnext);
1308 zmemcpy(dictionary + state->whave - state->wnext,
1309 state->window, state->wnext);
1312 *dictLength = state->whave;
1321 struct inflate_state FAR *state; local
1327 state = (struct inflate_state FAR *)strm->state;
1328 if (state->wrap != 0 && state->mode != DICT)
1332 if (state->mode == DICT) {
1335 if (dictid != state->check)
1343 state->mode = MEM;
1346 state->havedict = 1;
1355 struct inflate_state FAR *state; local
1359 state = (struct inflate_state FAR *)strm->state;
1360 if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
1363 state->head = head;
1408 struct inflate_state FAR *state; local
1412 state = (struct inflate_state FAR *)strm->state;
1413 if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
1416 if (state->mode != SYNC) {
1417 state->mode = SYNC;
1418 state->hold <<= state->bits & 7;
1419 state->bits -= state->bits & 7;
1421 while (state->bits >= 8) {
1422 buf[len++] = (unsigned char)(state->hold);
1423 state->hold >>= 8;
1424 state->bits -= 8;
1426 state->have = 0;
1427 syncsearch(&(state->have), buf, len);
1431 len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
1437 if (state->have != 4) return Z_DATA_ERROR;
1441 state->mode = TYPE;
1456 struct inflate_state FAR *state; local
1459 state = (struct inflate_state FAR *)strm->state;
1460 return state->mode == STORED && state->bits == 0;
1467 struct inflate_state FAR *state; local
1475 state = (struct inflate_state FAR *)source->state;
1482 if (state->window != Z_NULL) {
1484 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
1493 zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
1495 if (state->lencode >= state->codes &&
1496 state->lencode <= state->codes + ENOUGH - 1) {
1497 copy->lencode = copy->codes + (state->lencode - state->codes);
1498 copy->distcode = copy->codes + (state->distcode - state->codes);
1500 copy->next = copy->codes + (state->next - state->codes);
1502 wsize = 1U << state->wbits;
1503 zmemcpy(window, state->window, wsize);
1506 dest->state = (struct internal_state FAR *)copy;
1514 struct inflate_state FAR *state; local
1517 state = (struct inflate_state FAR *)strm->state;
1519 state->sane = !subvert;
1523 state->sane = 1;
1532 struct inflate_state FAR *state; local
1535 state = (struct inflate_state FAR *)strm->state;
1537 state->wrap |= 4;
1539 state->wrap &= ~4;
1546 struct inflate_state FAR *state; local
1550 state = (struct inflate_state FAR *)strm->state;
1551 return (long)(((unsigned long)((long)state->back)) << 16) +
1552 (state->mode == COPY ? state->length :
1553 (state->mode == MATCH ? state->was - state->length : 0));
1559 struct inflate_state FAR *state; local
1561 state = (struct inflate_state FAR *)strm->state;
1562 return (unsigned long)(state->next - state->codes);