Lines Matching refs:state
19 local void fixedtables OF((struct inflate_state FAR *state));
31 struct inflate_state FAR *state;
54 state = (struct inflate_state FAR *)ZALLOC(strm, 1,
56 if (state == Z_NULL) return Z_MEM_ERROR;
58 strm->state = (struct internal_state FAR *)state;
59 state->dmax = 32768U;
60 state->wbits = (uInt)windowBits;
61 state->wsize = 1U << windowBits;
62 state->window = window;
63 state->wnext = 0;
64 state->whave = 0;
69 Return state with length and distance decoding tables and index sizes set to
78 local void fixedtables(struct inflate_state FAR *state)
92 while (sym < 144) state->lens[sym++] = 8;
93 while (sym < 256) state->lens[sym++] = 9;
94 while (sym < 280) state->lens[sym++] = 7;
95 while (sym < 288) state->lens[sym++] = 8;
99 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
103 while (sym < 32) state->lens[sym++] = 5;
106 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
114 state->lencode = lenfix;
115 state->lenbits = 9;
116 state->distcode = distfix;
117 state->distbits = 5;
122 /* Load returned state from inflate_fast() */
129 hold = state->hold; \
130 bits = state->bits; \
133 /* Set state from registers for inflate_fast() */
140 state->hold = hold; \
141 state->bits = bits; \
208 put = state->window; \
209 left = state->wsize; \
210 state->whave = left; \
241 error, or Z_MEM_ERROR if it could not allocate memory for the state.
243 are not correct, i.e. strm is Z_NULL or the state was not initialized.
248 struct inflate_state FAR *state;
263 /* Check that the strm exists and that the state was initialized */
264 if (strm == Z_NULL || strm->state == Z_NULL)
266 state = (struct inflate_state FAR *)strm->state;
268 /* Reset the state */
270 state->mode = TYPE;
271 state->last = 0;
272 state->whave = 0;
277 put = state->window;
278 left = state->wsize;
282 switch (state->mode) {
285 if (state->last) {
287 state->mode = DONE;
291 state->last = BITS(1);
296 state->last ? " (last)" : ""));
297 state->mode = STORED;
300 fixedtables(state);
302 state->last ? " (last)" : ""));
303 state->mode = LEN; /* decode codes */
307 state->last ? " (last)" : ""));
308 state->mode = TABLE;
312 state->mode = BAD;
323 state->mode = BAD;
326 state->length = (unsigned)hold & 0xffff;
328 state->length));
332 while (state->length != 0) {
333 copy = state->length;
343 state->length -= copy;
346 state->mode = TYPE;
352 state->nlen = BITS(5) + 257;
354 state->ndist = BITS(5) + 1;
356 state->ncode = BITS(4) + 4;
359 if (state->nlen > 286 || state->ndist > 30) {
361 state->mode = BAD;
368 state->have = 0;
369 while (state->have < state->ncode) {
371 state->lens[order[state->have++]] = (unsigned short)BITS(3);
374 while (state->have < 19)
375 state->lens[order[state->have++]] = 0;
376 state->next = state->codes;
377 state->lencode = (code const FAR *)(state->next);
378 state->lenbits = 7;
379 ret = inflate_table(CODES, state->lens, 19, &(state->next),
380 &(state->lenbits), state->work);
383 state->mode = BAD;
389 state->have = 0;
390 while (state->have < state->nlen + state->ndist) {
392 here = state->lencode[BITS(state->lenbits)];
398 state->lens[state->have++] = here.val;
404 if (state->have == 0) {
406 state->mode = BAD;
409 len = (unsigned)(state->lens[state->have - 1]);
427 if (state->have + copy > state->nlen + state->ndist) {
429 state->mode = BAD;
433 state->lens[state->have++] = (unsigned short)len;
438 if (state->mode == BAD) break;
441 if (state->lens[256] == 0) {
443 state->mode = BAD;
450 state->next = state->codes;
451 state->lencode = (code const FAR *)(state->next);
452 state->lenbits = 9;
453 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
454 &(state->lenbits), state->work);
457 state->mode = BAD;
460 state->distcode = (code const FAR *)(state->next);
461 state->distbits = 6;
462 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
463 &(state->next), &(state->distbits), state->work);
466 state->mode = BAD;
470 state->mode = LEN;
476 if (state->whave < state->wsize)
477 state->whave = state->wsize - left;
478 inflate_fast(strm, state->wsize);
485 here = state->lencode[BITS(state->lenbits)];
492 here = state->lencode[last.val +
500 state->length = (unsigned)here.val;
508 *put++ = (unsigned char)(state->length);
510 state->mode = LEN;
517 state->mode = TYPE;
524 state->mode = BAD;
529 state->extra = (unsigned)(here.op) & 15;
530 if (state->extra != 0) {
531 NEEDBITS(state->extra);
532 state->length += BITS(state->extra);
533 DROPBITS(state->extra);
535 Tracevv((stderr, "inflate: length %u\n", state->length));
539 here = state->distcode[BITS(state->distbits)];
546 here = state->distcode[last.val +
556 state->mode = BAD;
559 state->offset = (unsigned)here.val;
562 state->extra = (unsigned)(here.op) & 15;
563 if (state->extra != 0) {
564 NEEDBITS(state->extra);
565 state->offset += BITS(state->extra);
566 DROPBITS(state->extra);
568 if (state->offset > state->wsize - (state->whave < state->wsize ?
571 state->mode = BAD;
574 Tracevv((stderr, "inflate: distance %u\n", state->offset));
579 copy = state->wsize - state->offset;
585 from = put - state->offset;
588 if (copy > state->length) copy = state->length;
589 state->length -= copy;
594 } while (state->length != 0);
600 if (left < state->wsize) {
601 if (out(out_desc, state->window, state->wsize - left))
624 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
626 ZFREE(strm, strm->state);
627 strm->state = Z_NULL;