• Home
  • Raw
  • Download

Lines Matching refs:state

95 local void fixedtables OF((struct inflate_state FAR *state));
106 struct inflate_state FAR *state; local
108 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
109 state = (struct inflate_state FAR *)strm->state;
110 strm->total_in = strm->total_out = state->total = 0;
112 if (state->wrap) /* to support ill-conceived Java test suite */
113 strm->adler = state->wrap & 1;
114 state->mode = HEAD;
115 state->last = 0;
116 state->havedict = 0;
117 state->dmax = 32768U;
118 state->head = Z_NULL;
119 state->hold = 0;
120 state->bits = 0;
121 state->lencode = state->distcode = state->next = state->codes;
122 state->sane = 1;
123 state->back = -1;
131 struct inflate_state FAR *state; local
133 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
134 state = (struct inflate_state FAR *)strm->state;
135 state->wsize = 0;
136 state->whave = 0;
137 state->wnext = 0;
146 struct inflate_state FAR *state; local
149 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
150 state = (struct inflate_state FAR *)strm->state;
168 if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
169 ZFREE(strm, state->window);
170 state->window = Z_NULL;
174 state->wrap = wrap;
175 state->wbits = (unsigned)windowBits;
186 struct inflate_state FAR *state; local
207 state = (struct inflate_state FAR *)
209 if (state == Z_NULL) return Z_MEM_ERROR;
211 strm->state = (struct internal_state FAR *)state;
212 state->window = Z_NULL;
215 ZFREE(strm, state);
216 strm->state = Z_NULL;
234 struct inflate_state FAR *state; local
236 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
237 state = (struct inflate_state FAR *)strm->state;
239 state->hold = 0;
240 state->bits = 0;
243 if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
245 state->hold += value << state->bits;
246 state->bits += bits;
260 local void fixedtables(state) in fixedtables() argument
261 struct inflate_state FAR *state; in fixedtables()
275 while (sym < 144) state->lens[sym++] = 8;
276 while (sym < 256) state->lens[sym++] = 9;
277 while (sym < 280) state->lens[sym++] = 7;
278 while (sym < 288) state->lens[sym++] = 8;
282 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
286 while (sym < 32) state->lens[sym++] = 5;
289 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
297 state->lencode = lenfix;
298 state->lenbits = 9;
299 state->distcode = distfix;
300 state->distbits = 5;
327 struct inflate_state state; in makefixed() local
329 fixedtables(&state); in makefixed()
344 printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, in makefixed()
345 state.lencode[low].bits, state.lencode[low].val); in makefixed()
355 printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, in makefixed()
356 state.distcode[low].val); in makefixed()
382 struct inflate_state FAR *state; local
385 state = (struct inflate_state FAR *)strm->state;
388 if (state->window == Z_NULL) {
389 state->window = (unsigned char FAR *)
390 ZALLOC(strm, 1U << state->wbits,
392 if (state->window == Z_NULL) return 1;
396 if (state->wsize == 0) {
397 state->wsize = 1U << state->wbits;
398 state->wnext = 0;
399 state->whave = 0;
404 if (copy >= state->wsize) {
405 zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
406 state->wnext = 0;
407 state->whave = state->wsize;
410 dist = state->wsize - state->wnext;
412 zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
415 zmemcpy(state->window, strm->next_out - copy, copy);
416 state->wnext = copy;
417 state->whave = state->wsize;
420 state->wnext += dist;
421 if (state->wnext == state->wsize) state->wnext = 0;
422 if (state->whave < state->wsize) state->whave += dist;
433 (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
464 hold = state->hold; \
465 bits = state->bits; \
475 state->hold = hold; \
476 state->bits = bits; \
608 struct inflate_state FAR *state; local
627 if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
631 state = (struct inflate_state FAR *)strm->state;
632 if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
638 switch (state->mode) {
640 if (state->wrap == 0) {
641 state->mode = TYPEDO;
646 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
647 state->check = crc32(0L, Z_NULL, 0);
648 CRC2(state->check, hold);
650 state->mode = FLAGS;
653 state->flags = 0; /* expect zlib header */
654 if (state->head != Z_NULL)
655 state->head->done = -1;
656 if (!(state->wrap & 1) || /* check if zlib header allowed */
662 state->mode = BAD;
667 state->mode = BAD;
672 if (state->wbits == 0)
673 state->wbits = len;
674 else if (len > state->wbits) {
676 state->mode = BAD;
679 state->dmax = 1U << len;
681 strm->adler = state->check = adler32(0L, Z_NULL, 0);
682 state->mode = hold & 0x200 ? DICTID : TYPE;
688 state->flags = (int)(hold);
689 if ((state->flags & 0xff) != Z_DEFLATED) {
691 state->mode = BAD;
694 if (state->flags & 0xe000) {
696 state->mode = BAD;
699 if (state->head != Z_NULL)
700 state->head->text = (int)((hold >> 8) & 1);
701 if (state->flags & 0x0200) CRC2(state->check, hold);
703 state->mode = TIME;
706 if (state->head != Z_NULL)
707 state->head->time = hold;
708 if (state->flags & 0x0200) CRC4(state->check, hold);
710 state->mode = OS;
713 if (state->head != Z_NULL) {
714 state->head->xflags = (int)(hold & 0xff);
715 state->head->os = (int)(hold >> 8);
717 if (state->flags & 0x0200) CRC2(state->check, hold);
719 state->mode = EXLEN;
721 if (state->flags & 0x0400) {
723 state->length = (unsigned)(hold);
724 if (state->head != Z_NULL)
725 state->head->extra_len = (unsigned)hold;
726 if (state->flags & 0x0200) CRC2(state->check, hold);
729 else if (state->head != Z_NULL)
730 state->head->extra = Z_NULL;
731 state->mode = EXTRA;
733 if (state->flags & 0x0400) {
734 copy = state->length;
737 if (state->head != Z_NULL &&
738 state->head->extra != Z_NULL) {
739 len = state->head->extra_len - state->length;
740 zmemcpy(state->head->extra + len, next,
741 len + copy > state->head->extra_max ?
742 state->head->extra_max - len : copy);
744 if (state->flags & 0x0200)
745 state->check = crc32(state->check, next, copy);
748 state->length -= copy;
750 if (state->length) goto inf_leave;
752 state->length = 0;
753 state->mode = NAME;
755 if (state->flags & 0x0800) {
760 if (state->head != Z_NULL &&
761 state->head->name != Z_NULL &&
762 state->length < state->head->name_max)
763 state->head->name[state->length++] = len;
765 if (state->flags & 0x0200)
766 state->check = crc32(state->check, next, copy);
771 else if (state->head != Z_NULL)
772 state->head->name = Z_NULL;
773 state->length = 0;
774 state->mode = COMMENT;
776 if (state->flags & 0x1000) {
781 if (state->head != Z_NULL &&
782 state->head->comment != Z_NULL &&
783 state->length < state->head->comm_max)
784 state->head->comment[state->length++] = len;
786 if (state->flags & 0x0200)
787 state->check = crc32(state->check, next, copy);
792 else if (state->head != Z_NULL)
793 state->head->comment = Z_NULL;
794 state->mode = HCRC;
796 if (state->flags & 0x0200) {
798 if (hold != (state->check & 0xffff)) {
800 state->mode = BAD;
805 if (state->head != Z_NULL) {
806 state->head->hcrc = (int)((state->flags >> 9) & 1);
807 state->head->done = 1;
809 strm->adler = state->check = crc32(0L, Z_NULL, 0);
810 state->mode = TYPE;
815 strm->adler = state->check = ZSWAP32(hold);
817 state->mode = DICT;
819 if (state->havedict == 0) {
823 strm->adler = state->check = adler32(0L, Z_NULL, 0);
824 state->mode = TYPE;
828 if (state->last) {
830 state->mode = CHECK;
834 state->last = BITS(1);
839 state->last ? " (last)" : ""));
840 state->mode = STORED;
843 fixedtables(state);
845 state->last ? " (last)" : ""));
846 state->mode = LEN_; /* decode codes */
854 state->last ? " (last)" : ""));
855 state->mode = TABLE;
859 state->mode = BAD;
868 state->mode = BAD;
871 state->length = (unsigned)hold & 0xffff;
873 state->length));
875 state->mode = COPY_;
878 state->mode = COPY;
880 copy = state->length;
890 state->length -= copy;
894 state->mode = TYPE;
898 state->nlen = BITS(5) + 257;
900 state->ndist = BITS(5) + 1;
902 state->ncode = BITS(4) + 4;
905 if (state->nlen > 286 || state->ndist > 30) {
907 state->mode = BAD;
912 state->have = 0;
913 state->mode = LENLENS;
915 while (state->have < state->ncode) {
917 state->lens[order[state->have++]] = (unsigned short)BITS(3);
920 while (state->have < 19)
921 state->lens[order[state->have++]] = 0;
922 state->next = state->codes;
923 state->lencode = (code const FAR *)(state->next);
924 state->lenbits = 7;
925 ret = inflate_table(CODES, state->lens, 19, &(state->next),
926 &(state->lenbits), state->work);
929 state->mode = BAD;
933 state->have = 0;
934 state->mode = CODELENS;
936 while (state->have < state->nlen + state->ndist) {
938 here = state->lencode[BITS(state->lenbits)];
944 state->lens[state->have++] = here.val;
950 if (state->have == 0) {
952 state->mode = BAD;
955 len = state->lens[state->have - 1];
973 if (state->have + copy > state->nlen + state->ndist) {
975 state->mode = BAD;
979 state->lens[state->have++] = (unsigned short)len;
984 if (state->mode == BAD) break;
987 if (state->lens[256] == 0) {
989 state->mode = BAD;
996 state->next = state->codes;
997 state->lencode = (code const FAR *)(state->next);
998 state->lenbits = 9;
999 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
1000 &(state->lenbits), state->work);
1003 state->mode = BAD;
1006 state->distcode = (code const FAR *)(state->next);
1007 state->distbits = 6;
1008 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
1009 &(state->next), &(state->distbits), state->work);
1012 state->mode = BAD;
1016 state->mode = LEN_;
1019 state->mode = LEN;
1025 if (state->mode == TYPE)
1026 state->back = -1;
1029 state->back = 0;
1031 here = state->lencode[BITS(state->lenbits)];
1038 here = state->lencode[last.val +
1044 state->back += last.bits;
1047 state->back += here.bits;
1048 state->length = (unsigned)here.val;
1053 state->mode = LIT;
1058 state->back = -1;
1059 state->mode = TYPE;
1064 state->mode = BAD;
1067 state->extra = (unsigned)(here.op) & 15;
1068 state->mode = LENEXT;
1070 if (state->extra) {
1071 NEEDBITS(state->extra);
1072 state->length += BITS(state->extra);
1073 DROPBITS(state->extra);
1074 state->back += state->extra;
1076 Tracevv((stderr, "inflate: length %u\n", state->length));
1077 state->was = state->length;
1078 state->mode = DIST;
1081 here = state->distcode[BITS(state->distbits)];
1088 here = state->distcode[last.val +
1094 state->back += last.bits;
1097 state->back += here.bits;
1100 state->mode = BAD;
1103 state->offset = (unsigned)here.val;
1104 state->extra = (unsigned)(here.op) & 15;
1105 state->mode = DISTEXT;
1107 if (state->extra) {
1108 NEEDBITS(state->extra);
1109 state->offset += BITS(state->extra);
1110 DROPBITS(state->extra);
1111 state->back += state->extra;
1114 if (state->offset > state->dmax) {
1116 state->mode = BAD;
1120 Tracevv((stderr, "inflate: distance %u\n", state->offset));
1121 state->mode = MATCH;
1125 if (state->offset > copy) { /* copy from window */
1126 copy = state->offset - copy;
1127 if (copy > state->whave) {
1128 if (state->sane) {
1130 state->mode = BAD;
1135 copy -= state->whave;
1136 if (copy > state->length) copy = state->length;
1139 state->length -= copy;
1143 if (state->length == 0) state->mode = LEN;
1147 if (copy > state->wnext) {
1148 copy -= state->wnext;
1149 from = state->window + (state->wsize - copy);
1152 from = state->window + (state->wnext - copy);
1153 if (copy > state->length) copy = state->length;
1156 from = put - state->offset;
1157 copy = state->length;
1161 state->length -= copy;
1165 if (state->length == 0) state->mode = LEN;
1169 *put++ = (unsigned char)(state->length);
1171 state->mode = LEN;
1174 if (state->wrap) {
1178 state->total += out;
1180 strm->adler = state->check =
1181 UPDATE(state->check, put - out, out);
1185 state->flags ? hold :
1187 ZSWAP32(hold)) != state->check) {
1189 state->mode = BAD;
1196 state->mode = LENGTH;
1198 if (state->wrap && state->flags) {
1200 if (hold != (state->total & 0xffffffffUL)) {
1202 state->mode = BAD;
1209 state->mode = DONE;
1231 if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
1232 (state->mode < CHECK || flush != Z_FINISH)))
1234 state->mode = MEM;
1241 state->total += out;
1242 if (state->wrap && out)
1243 strm->adler = state->check =
1244 UPDATE(state->check, strm->next_out - out, out);
1245 strm->data_type = state->bits + (state->last ? 64 : 0) +
1246 (state->mode == TYPE ? 128 : 0) +
1247 (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
1256 struct inflate_state FAR *state; local
1257 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
1259 state = (struct inflate_state FAR *)strm->state;
1260 if (state->window != Z_NULL) ZFREE(strm, state->window);
1261 ZFREE(strm, strm->state);
1262 strm->state = Z_NULL;
1272 struct inflate_state FAR *state; local
1279 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1280 state = (struct inflate_state FAR *)strm->state;
1281 if (state->wrap != 0 && state->mode != DICT)
1285 if (state->mode == DICT) {
1288 if (dictid != state->check)
1302 state->mode = MEM;
1305 state->havedict = 1;
1314 struct inflate_state FAR *state; local
1317 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1318 state = (struct inflate_state FAR *)strm->state;
1319 if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
1322 state->head = head;
1367 struct inflate_state FAR *state; local
1370 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1371 state = (struct inflate_state FAR *)strm->state;
1372 if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
1375 if (state->mode != SYNC) {
1376 state->mode = SYNC;
1377 state->hold <<= state->bits & 7;
1378 state->bits -= state->bits & 7;
1380 while (state->bits >= 8) {
1381 buf[len++] = (unsigned char)(state->hold);
1382 state->hold >>= 8;
1383 state->bits -= 8;
1385 state->have = 0;
1386 syncsearch(&(state->have), buf, len);
1390 len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
1396 if (state->have != 4) return Z_DATA_ERROR;
1400 state->mode = TYPE;
1415 struct inflate_state FAR *state; local
1417 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1418 state = (struct inflate_state FAR *)strm->state;
1419 return state->mode == STORED && state->bits == 0;
1426 struct inflate_state FAR *state; local
1432 if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
1435 state = (struct inflate_state FAR *)source->state;
1442 if (state->window != Z_NULL) {
1444 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
1453 zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
1454 if (state->lencode >= state->codes &&
1455 state->lencode <= state->codes + ENOUGH - 1) {
1456 copy->lencode = copy->codes + (state->lencode - state->codes);
1457 copy->distcode = copy->codes + (state->distcode - state->codes);
1459 copy->next = copy->codes + (state->next - state->codes);
1461 wsize = 1U << state->wbits;
1462 zmemcpy(window, state->window, wsize);
1465 dest->state = (struct internal_state FAR *)copy;
1473 struct inflate_state FAR *state; local
1475 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1476 state = (struct inflate_state FAR *)strm->state;
1477 state->sane = !subvert;
1481 state->sane = 1;
1489 struct inflate_state FAR *state; local
1491 if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
1492 state = (struct inflate_state FAR *)strm->state;
1493 return ((long)(state->back) << 16) +
1494 (state->mode == COPY ? state->length :
1495 (state->mode == MATCH ? state->was - state->length : 0));