Lines Matching refs:state

43 local void fixedtables OF((struct inflate_state FAR *state));
59 struct inflate_state FAR *state;
73 state = (struct inflate_state FAR *)ZALLOC(strm, 1,
75 if (state == Z_NULL) return Z_MEM_ERROR;
77 strm->state = (struct internal_state FAR *)state;
78 state->dmax = 32768U;
79 state->wbits = windowBits;
80 state->wsize = 1U << windowBits;
81 state->window = window;
82 state->write = 0;
83 state->whave = 0;
88 Return state with length and distance decoding tables and index sizes set to
97 local void fixedtables(state)
98 struct inflate_state FAR *state;
112 while (sym < 144) state->lens[sym++] = 8;
113 while (sym < 256) state->lens[sym++] = 9;
114 while (sym < 280) state->lens[sym++] = 7;
115 while (sym < 288) state->lens[sym++] = 8;
119 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
123 while (sym < 32) state->lens[sym++] = 5;
126 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
134 state->lencode = lenfix;
135 state->lenbits = 9;
136 state->distcode = distfix;
137 state->distbits = 5;
142 /* Load returned state from inflate_fast() */
149 hold = state->hold; \
150 bits = state->bits; \
153 /* Set state from registers for inflate_fast() */
160 state->hold = hold; \
161 state->bits = bits; \
228 put = state->window; \
229 left = state->wsize; \
230 state->whave = left; \
261 error, or Z_MEM_ERROR if it could not allocate memory for the state.
263 are not correct, i.e. strm is Z_NULL or the state was not initialized.
272 struct inflate_state FAR *state;
287 /* Check that the strm exists and that the state was initialized */
288 if (strm == Z_NULL || strm->state == Z_NULL)
290 state = (struct inflate_state FAR *)strm->state;
292 /* Reset the state */
294 state->mode = TYPE;
295 state->last = 0;
296 state->whave = 0;
301 put = state->window;
302 left = state->wsize;
306 switch (state->mode) {
309 if (state->last) {
311 state->mode = DONE;
315 state->last = BITS(1);
320 state->last ? " (last)" : ""));
321 state->mode = STORED;
324 fixedtables(state);
326 state->last ? " (last)" : ""));
327 state->mode = LEN; /* decode codes */
331 state->last ? " (last)" : ""));
332 state->mode = TABLE;
336 state->mode = BAD;
347 state->mode = BAD;
350 state->length = (unsigned)hold & 0xffff;
352 state->length));
356 while (state->length != 0) {
357 copy = state->length;
367 state->length -= copy;
370 state->mode = TYPE;
376 state->nlen = BITS(5) + 257;
378 state->ndist = BITS(5) + 1;
380 state->ncode = BITS(4) + 4;
383 if (state->nlen > 286 || state->ndist > 30) {
385 state->mode = BAD;
392 state->have = 0;
393 while (state->have < state->ncode) {
395 state->lens[order[state->have++]] = (unsigned short)BITS(3);
398 while (state->have < 19)
399 state->lens[order[state->have++]] = 0;
400 state->next = state->codes;
401 state->lencode = (code const FAR *)(state->next);
402 state->lenbits = 7;
403 ret = inflate_table(CODES, state->lens, 19, &(state->next),
404 &(state->lenbits), state->work);
407 state->mode = BAD;
413 state->have = 0;
414 while (state->have < state->nlen + state->ndist) {
416 this = state->lencode[BITS(state->lenbits)];
423 state->lens[state->have++] = this.val;
429 if (state->have == 0) {
431 state->mode = BAD;
434 len = (unsigned)(state->lens[state->have - 1]);
452 if (state->have + copy > state->nlen + state->ndist) {
454 state->mode = BAD;
458 state->lens[state->have++] = (unsigned short)len;
463 if (state->mode == BAD) break;
466 state->next = state->codes;
467 state->lencode = (code const FAR *)(state->next);
468 state->lenbits = 9;
469 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
470 &(state->lenbits), state->work);
473 state->mode = BAD;
476 state->distcode = (code const FAR *)(state->next);
477 state->distbits = 6;
478 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
479 &(state->next), &(state->distbits), state->work);
482 state->mode = BAD;
486 state->mode = LEN;
492 if (state->whave < state->wsize)
493 state->whave = state->wsize - left;
494 inflate_fast(strm, state->wsize);
501 this = state->lencode[BITS(state->lenbits)];
508 this = state->lencode[last.val +
516 state->length = (unsigned)this.val;
524 *put++ = (unsigned char)(state->length);
526 state->mode = LEN;
533 state->mode = TYPE;
540 state->mode = BAD;
545 state->extra = (unsigned)(this.op) & 15;
546 if (state->extra != 0) {
547 NEEDBITS(state->extra);
548 state->length += BITS(state->extra);
549 DROPBITS(state->extra);
551 Tracevv((stderr, "inflate: length %u\n", state->length));
555 this = state->distcode[BITS(state->distbits)];
562 this = state->distcode[last.val +
572 state->mode = BAD;
575 state->offset = (unsigned)this.val;
578 state->extra = (unsigned)(this.op) & 15;
579 if (state->extra != 0) {
580 NEEDBITS(state->extra);
581 state->offset += BITS(state->extra);
582 DROPBITS(state->extra);
584 if (state->offset > state->wsize - (state->whave < state->wsize ?
587 state->mode = BAD;
590 Tracevv((stderr, "inflate: distance %u\n", state->offset));
595 copy = state->wsize - state->offset;
601 from = put - state->offset;
604 if (copy > state->length) copy = state->length;
605 state->length -= copy;
610 } while (state->length != 0);
616 if (left < state->wsize) {
617 if (out(out_desc, state->window, state->wsize - left))
641 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
643 ZFREE(strm, strm->state);
644 strm->state = Z_NULL;