Lines Matching defs:state
55 /* To be used only when the state is known to be valid */
132 /* deflate.h -- internal compression state
147 * Internal compression state.
620 strm->state = (struct internal_state FAR *)s;
669 if (strm == Z_NULL || strm->state == Z_NULL ||
676 s = (deflate_state *)strm->state;
694 * IN assertion: the stream state is correct and there is enough room in
711 deflate_state *state = (deflate_state *) strm->state;
712 unsigned len = state->pending;
718 zmemcpy(strm->next_out, state->pending_out, len);
721 state->pending_out += len;
724 state->pending -= len;
725 if (state->pending == 0) {
726 state->pending_out = state->pending_buf;
735 deflate_state *state = (deflate_state *) strm->state;
737 if (strm == Z_NULL || state == Z_NULL) return Z_STREAM_ERROR;
744 state->strm = strm; /* just in case */
747 if (state->status == INIT_STATE) {
749 uInt header = (DEFLATED + ((state->w_bits-8)<<4)) << 8;
750 uInt level_flags = (state->level-1) >> 1;
756 state->status = BUSY_STATE;
757 putShortMSB(state, header);
761 if (state->pending != 0) {
769 if (state->status == FLUSH_STATE) {
770 state->status = BUSY_STATE;
776 if (state->status == FINISH_STATE && strm->avail_in != 0) {
782 if (strm->avail_in != 0 || state->lookahead != 0 ||
783 (flush == Z_FINISH && state->status != FINISH_STATE)) {
787 state->status = FINISH_STATE;
789 if (state->level <= 3) {
790 quit = deflate_fast(state, flush);
792 quit = deflate_slow(state, flush);
807 && state->status != FINISH_STATE) {
810 ct_align(state);
815 ct_stored_type_only(state);
818 ct_stored_block(state, (char*)0, 0L, 0);
823 CLEAR_HASH(state); /* forget history */
832 state->status = FLUSH_STATE;
840 if (state->noheader) return Z_STREAM_END;
843 putShortMSB(state, (uInt)(state->adler >> 16));
844 putShortMSB(state, (uInt)(state->adler & 0xffff));
849 state->noheader = -1; /* write the trailer only once! */
850 return state->pending != 0 ? Z_OK : Z_STREAM_END;
857 deflate_state *state = (deflate_state *) strm->state;
859 if (strm == Z_NULL || state == Z_NULL) return Z_STREAM_ERROR;
861 TRY_FREE(strm, state->window, state->w_size * 2 * sizeof(Byte));
862 TRY_FREE(strm, state->prev, state->w_size * sizeof(Pos));
863 TRY_FREE(strm, state->head, state->hash_size * sizeof(Pos));
864 TRY_FREE(strm, state->pending_buf, state->lit_bufsize * 2 * sizeof(ush));
866 ZFREE(strm, state, sizeof(deflate_state));
867 strm->state = Z_NULL;
882 deflate_state *state = (deflate_state *) strm->state;
889 if (!state->noheader) {
890 state->adler = adler32(state->adler, strm->next_in, len);
2735 /* inflate private state */
2765 *blocks; /* current inflate_blocks state */
2775 if (z == Z_NULL || z->state == Z_NULL)
2779 z->state->mode = z->state->nowrap ? BLOCKS : METHOD;
2780 inflate_blocks_reset(z->state->blocks, z, &c);
2791 if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
2793 if (z->state->blocks != Z_NULL)
2794 inflate_blocks_free(z->state->blocks, z, &c);
2795 ZFREE(z, z->state, sizeof(struct internal_state));
2796 z->state = Z_NULL;
2806 /* initialize state */
2811 if ((z->state = (struct internal_state FAR *)
2814 z->state->blocks = Z_NULL;
2817 z->state->nowrap = 0;
2821 z->state->nowrap = 1;
2830 z->state->wbits = (uInt)w;
2832 /* create inflate_blocks state */
2833 if ((z->state->blocks =
2834 inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, 1 << w))
2842 /* reset state */
2868 while (1) switch (z->state->mode)
2872 if (((z->state->sub.method = NEXTBYTE) & 0xf) != DEFLATED)
2874 z->state->mode = BAD;
2876 z->state->sub.marker = 5; /* can't try inflateSync */
2879 if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
2881 z->state->mode = BAD;
2883 z->state->sub.marker = 5; /* can't try inflateSync */
2886 z->state->mode = FLAG;
2891 z->state->mode = BAD;
2893 z->state->sub.marker = 5; /* can't try inflateSync */
2896 if (((z->state->sub.method << 8) + b) % 31)
2898 z->state->mode = BAD;
2900 z->state->sub.marker = 5; /* can't try inflateSync */
2904 z->state->mode = BLOCKS;
2906 r = inflate_blocks(z->state->blocks, z, r);
2908 r = inflate_packet_flush(z->state->blocks);
2911 z->state->mode = BAD;
2912 z->state->sub.marker = 0; /* can try inflateSync */
2918 inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
2919 if (z->state->nowrap)
2921 z->state->mode = DONE;
2924 z->state->mode = CHECK4;
2927 z->state->sub.check.need = (uLong)NEXTBYTE << 24;
2928 z->state->mode = CHECK3;
2931 z->state->sub.check.need += (uLong)NEXTBYTE << 16;
2932 z->state->mode = CHECK2;
2935 z->state->sub.check.need += (uLong)NEXTBYTE << 8;
2936 z->state->mode = CHECK1;
2939 z->state->sub.check.need += (uLong)NEXTBYTE;
2941 if (z->state->sub.check.was != z->state->sub.check.need)
2943 z->state->mode = BAD;
2945 z->state->sub.marker = 5; /* can't try inflateSync */
2949 z->state->mode = DONE;
2961 z->state->mode = BAD;
2962 z->state->sub.marker = 0; /* can try inflateSync */
2969 * i.e. no pending output (hence s->read equals s->write), and the state must
2978 if (z->state->mode != BLOCKS)
2980 return inflate_addhistory(z->state->blocks, z);
2993 if (z == Z_NULL || z->state == Z_NULL)
2995 if (z->state->mode != BAD)
2997 z->state->mode = BAD;
2998 z->state->sub.marker = 0;
3003 m = z->state->sub.marker;
3021 z->state->sub.marker = m;
3029 z->state->mode = BLOCKS;
3047 /* inflate blocks semi-private state */
3079 } decode; /* if CODES, current state */
3273 /* process input based on current state */
3535 * i.e. no pending output (hence s->read equals s->write), and the state must
4082 /* inflate codes private state */
4158 inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
4163 /* process input and output based on current state */