Lines Matching refs:state

28     struct inflate_state FAR *state;
51 state = (struct inflate_state FAR *)ZALLOC(strm, 1,
53 if (state == Z_NULL) return Z_MEM_ERROR;
55 strm->state = (struct internal_state FAR *)state;
56 state->dmax = 32768U;
57 state->wbits = (uInt)windowBits;
58 state->wsize = 1U << windowBits;
59 state->window = window;
60 state->wnext = 0;
61 state->whave = 0;
62 state->sane = 1;
67 Return state with length and distance decoding tables and index sizes set to
76 local void fixedtables(struct inflate_state FAR *state) {
89 while (sym < 144) state->lens[sym++] = 8;
90 while (sym < 256) state->lens[sym++] = 9;
91 while (sym < 280) state->lens[sym++] = 7;
92 while (sym < 288) state->lens[sym++] = 8;
96 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
100 while (sym < 32) state->lens[sym++] = 5;
103 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
111 state->lencode = lenfix;
112 state->lenbits = 9;
113 state->distcode = distfix;
114 state->distbits = 5;
119 /* Load returned state from inflate_fast() */
126 hold = state->hold; \
127 bits = state->bits; \
130 /* Set state from registers for inflate_fast() */
137 state->hold = hold; \
138 state->bits = bits; \
205 put = state->window; \
206 left = state->wsize; \
207 state->whave = left; \
238 error, or Z_MEM_ERROR if it could not allocate memory for the state.
240 are not correct, i.e. strm is Z_NULL or the state was not initialized.
244 struct inflate_state FAR *state;
259 /* Check that the strm exists and that the state was initialized */
260 if (strm == Z_NULL || strm->state == Z_NULL)
262 state = (struct inflate_state FAR *)strm->state;
264 /* Reset the state */
266 state->mode = TYPE;
267 state->last = 0;
268 state->whave = 0;
273 put = state->window;
274 left = state->wsize;
278 switch (state->mode) {
281 if (state->last) {
283 state->mode = DONE;
287 state->last = BITS(1);
292 state->last ? " (last)" : ""));
293 state->mode = STORED;
296 fixedtables(state);
298 state->last ? " (last)" : ""));
299 state->mode = LEN; /* decode codes */
303 state->last ? " (last)" : ""));
304 state->mode = TABLE;
308 state->mode = BAD;
319 state->mode = BAD;
322 state->length = (unsigned)hold & 0xffff;
324 state->length));
328 while (state->length != 0) {
329 copy = state->length;
339 state->length -= copy;
342 state->mode = TYPE;
348 state->nlen = BITS(5) + 257;
350 state->ndist = BITS(5) + 1;
352 state->ncode = BITS(4) + 4;
355 if (state->nlen > 286 || state->ndist > 30) {
357 state->mode = BAD;
364 state->have = 0;
365 while (state->have < state->ncode) {
367 state->lens[order[state->have++]] = (unsigned short)BITS(3);
370 while (state->have < 19)
371 state->lens[order[state->have++]] = 0;
372 state->next = state->codes;
373 state->lencode = (code const FAR *)(state->next);
374 state->lenbits = 7;
375 ret = inflate_table(CODES, state->lens, 19, &(state->next),
376 &(state->lenbits), state->work);
379 state->mode = BAD;
385 state->have = 0;
386 while (state->have < state->nlen + state->ndist) {
388 here = state->lencode[BITS(state->lenbits)];
394 state->lens[state->have++] = here.val;
400 if (state->have == 0) {
402 state->mode = BAD;
405 len = (unsigned)(state->lens[state->have - 1]);
423 if (state->have + copy > state->nlen + state->ndist) {
425 state->mode = BAD;
429 state->lens[state->have++] = (unsigned short)len;
434 if (state->mode == BAD) break;
437 if (state->lens[256] == 0) {
439 state->mode = BAD;
446 state->next = state->codes;
447 state->lencode = (code const FAR *)(state->next);
448 state->lenbits = 10;
449 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
450 &(state->lenbits), state->work);
453 state->mode = BAD;
456 state->distcode = (code const FAR *)(state->next);
457 state->distbits = 9;
458 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
459 &(state->next), &(state->distbits), state->work);
462 state->mode = BAD;
466 state->mode = LEN;
474 if (state->whave < state->wsize)
475 state->whave = state->wsize - left;
476 inflate_fast(strm, state->wsize);
483 here = state->lencode[BITS(state->lenbits)];
490 here = state->lencode[last.val +
498 state->length = (unsigned)here.val;
506 *put++ = (unsigned char)(state->length);
508 state->mode = LEN;
515 state->mode = TYPE;
522 state->mode = BAD;
527 state->extra = (unsigned)(here.op) & 15;
528 if (state->extra != 0) {
529 NEEDBITS(state->extra);
530 state->length += BITS(state->extra);
531 DROPBITS(state->extra);
533 Tracevv((stderr, "inflate: length %u\n", state->length));
537 here = state->distcode[BITS(state->distbits)];
544 here = state->distcode[last.val +
554 state->mode = BAD;
557 state->offset = (unsigned)here.val;
560 state->extra = (unsigned)(here.op) & 15;
561 if (state->extra != 0) {
562 NEEDBITS(state->extra);
563 state->offset += BITS(state->extra);
564 DROPBITS(state->extra);
566 if (state->offset > state->wsize - (state->whave < state->wsize ?
569 state->mode = BAD;
572 Tracevv((stderr, "inflate: distance %u\n", state->offset));
577 copy = state->wsize - state->offset;
583 from = put - state->offset;
586 if (copy > state->length) copy = state->length;
587 state->length -= copy;
592 } while (state->length != 0);
612 if (left < state->wsize) {
613 if (out(out_desc, state->window, state->wsize - left) &&
623 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
625 ZFREE(strm, strm->state);
626 strm->state = Z_NULL;