Lines Matching full:state
19 local void fixedtables OF((struct inflate_state FAR *state));
35 struct inflate_state FAR *state;
49 state = (struct inflate_state FAR *)ZALLOC(strm, 1,
51 if (state == Z_NULL) return Z_MEM_ERROR;
53 strm->state = (struct internal_state FAR *)state;
54 state->dmax = 32768U;
55 state->wbits = windowBits;
56 state->wsize = 1U << windowBits;
57 state->window = window;
58 state->wnext = 0;
59 state->whave = 0;
64 Return state with length and distance decoding tables and index sizes set to
73 local void fixedtables(state)
74 struct inflate_state FAR *state;
88 while (sym < 144) state->lens[sym++] = 8;
89 while (sym < 256) state->lens[sym++] = 9;
90 while (sym < 280) state->lens[sym++] = 7;
91 while (sym < 288) state->lens[sym++] = 8;
95 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
99 while (sym < 32) state->lens[sym++] = 5;
102 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
110 state->lencode = lenfix;
111 state->lenbits = 9;
112 state->distcode = distfix;
113 state->distbits = 5;
118 /* Load returned state from inflate_fast() */
125 hold = state->hold; \
126 bits = state->bits; \
129 /* Set state from registers for inflate_fast() */
136 state->hold = hold; \
137 state->bits = bits; \
204 put = state->window; \
205 left = state->wsize; \
206 state->whave = left; \
237 error, or Z_MEM_ERROR if it could not allocate memory for the state.
239 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)];
399 state->lens[state->have++] = here.val;
405 if (state->have == 0) {
407 state->mode = BAD;
410 len = (unsigned)(state->lens[state->have - 1]);
428 if (state->have + copy > state->nlen + state->ndist) {
430 state->mode = BAD;
434 state->lens[state->have++] = (unsigned short)len;
439 if (state->mode == BAD) break;
442 if (state->lens[256] == 0) {
444 state->mode = BAD;
451 state->next = state->codes;
452 state->lencode = (code const FAR *)(state->next);
453 state->lenbits = 9;
454 ret = inflate_table(LENS, state->lens, statestate->next),
455 &(state->lenbits), state->work);
458 state->mode = BAD;
461 state->distcode = (code const FAR *)(state->next);
462 state->distbits = 6;
463 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
464 &(state->next), &(state->distbits), state->work);
467 state->mode = BAD;
471 state->mode = LEN;
477 if (state->whave < state->wsize)
478 state->whave = state->wsize - left;
479 inflate_fast(strm, state->wsize);
486 here = state->lencode[BITS(state->lenbits)];
493 here = state->lencode[last.val +
501 state->length = (unsigned)here.val;
509 *put++ = (unsigned char)(state->length);
511 state->mode = LEN;
518 state->mode = TYPE;
525 state->mode = BAD;
530 state->extra = (unsigned)(here.op) & 15;
531 if (state->extra != 0) {
532 NEEDBITS(state->extra);
533 state->length += BITS(state->extra);
534 DROPBITS(state->extra);
536 Tracevv((stderr, "inflate: length %u\n", state->length));
540 here = state->distcode[BITS(state->distbits)];
547 here = state->distcode[last.val +
557 state->mode = BAD;
560 state->offset = (unsigned)here.val;
563 state->extra = (unsigned)(here.op) & 15;
564 if (state->extra != 0) {
565 NEEDBITS(state->extra);
566 state->offset += BITS(state->extra);
567 DROPBITS(state->extra);
569 if (state->offset > state->wsize - (state->whave < state->wsize ?
572 state->mode = BAD;
575 Tracevv((stderr, "inflate: distance %u\n", state->offset));
580 copy = state->wsize - state->offset;
586 from = put - state->offset;
589 if (copy > state->length) copy = state->length;
590 state->length -= copy;
595 } while (state->length != 0);
601 if (left < state->wsize) {
602 if (out(out_desc, state->window, state->wsize - left))
626 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
628 ZFREE(strm, strm->state);
629 strm->state = Z_NULL;