Chris@43: /* infback9.c -- inflate deflate64 data using a call-back interface Chris@43: * Copyright (C) 1995-2008 Mark Adler Chris@43: * For conditions of distribution and use, see copyright notice in zlib.h Chris@43: */ Chris@43: Chris@43: #include "zutil.h" Chris@43: #include "infback9.h" Chris@43: #include "inftree9.h" Chris@43: #include "inflate9.h" Chris@43: Chris@43: #define WSIZE 65536UL Chris@43: Chris@43: /* Chris@43: strm provides memory allocation functions in zalloc and zfree, or Chris@43: Z_NULL to use the library memory allocation functions. Chris@43: Chris@43: window is a user-supplied window and output buffer that is 64K bytes. Chris@43: */ Chris@43: int ZEXPORT inflateBack9Init_(strm, window, version, stream_size) Chris@43: z_stream FAR *strm; Chris@43: unsigned char FAR *window; Chris@43: const char *version; Chris@43: int stream_size; Chris@43: { Chris@43: struct inflate_state FAR *state; Chris@43: Chris@43: if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || Chris@43: stream_size != (int)(sizeof(z_stream))) Chris@43: return Z_VERSION_ERROR; Chris@43: if (strm == Z_NULL || window == Z_NULL) Chris@43: return Z_STREAM_ERROR; Chris@43: strm->msg = Z_NULL; /* in case we return an error */ Chris@43: if (strm->zalloc == (alloc_func)0) { Chris@43: strm->zalloc = zcalloc; Chris@43: strm->opaque = (voidpf)0; Chris@43: } Chris@43: if (strm->zfree == (free_func)0) strm->zfree = zcfree; Chris@43: state = (struct inflate_state FAR *)ZALLOC(strm, 1, Chris@43: sizeof(struct inflate_state)); Chris@43: if (state == Z_NULL) return Z_MEM_ERROR; Chris@43: Tracev((stderr, "inflate: allocated\n")); Chris@43: strm->state = (voidpf)state; Chris@43: state->window = window; Chris@43: return Z_OK; Chris@43: } Chris@43: Chris@43: /* Chris@43: Build and output length and distance decoding tables for fixed code Chris@43: decoding. Chris@43: */ Chris@43: #ifdef MAKEFIXED Chris@43: #include Chris@43: Chris@43: void makefixed9(void) Chris@43: { Chris@43: unsigned sym, bits, low, size; Chris@43: code *next, *lenfix, *distfix; Chris@43: struct inflate_state state; Chris@43: code fixed[544]; Chris@43: Chris@43: /* literal/length table */ Chris@43: sym = 0; Chris@43: while (sym < 144) state.lens[sym++] = 8; Chris@43: while (sym < 256) state.lens[sym++] = 9; Chris@43: while (sym < 280) state.lens[sym++] = 7; Chris@43: while (sym < 288) state.lens[sym++] = 8; Chris@43: next = fixed; Chris@43: lenfix = next; Chris@43: bits = 9; Chris@43: inflate_table9(LENS, state.lens, 288, &(next), &(bits), state.work); Chris@43: Chris@43: /* distance table */ Chris@43: sym = 0; Chris@43: while (sym < 32) state.lens[sym++] = 5; Chris@43: distfix = next; Chris@43: bits = 5; Chris@43: inflate_table9(DISTS, state.lens, 32, &(next), &(bits), state.work); Chris@43: Chris@43: /* write tables */ Chris@43: puts(" /* inffix9.h -- table for decoding deflate64 fixed codes"); Chris@43: puts(" * Generated automatically by makefixed9()."); Chris@43: puts(" */"); Chris@43: puts(""); Chris@43: puts(" /* WARNING: this file should *not* be used by applications."); Chris@43: puts(" It is part of the implementation of this library and is"); Chris@43: puts(" subject to change. Applications should only use zlib.h."); Chris@43: puts(" */"); Chris@43: puts(""); Chris@43: size = 1U << 9; Chris@43: printf(" static const code lenfix[%u] = {", size); Chris@43: low = 0; Chris@43: for (;;) { Chris@43: if ((low % 6) == 0) printf("\n "); Chris@43: printf("{%u,%u,%d}", lenfix[low].op, lenfix[low].bits, Chris@43: lenfix[low].val); Chris@43: if (++low == size) break; Chris@43: putchar(','); Chris@43: } Chris@43: puts("\n };"); Chris@43: size = 1U << 5; Chris@43: printf("\n static const code distfix[%u] = {", size); Chris@43: low = 0; Chris@43: for (;;) { Chris@43: if ((low % 5) == 0) printf("\n "); Chris@43: printf("{%u,%u,%d}", distfix[low].op, distfix[low].bits, Chris@43: distfix[low].val); Chris@43: if (++low == size) break; Chris@43: putchar(','); Chris@43: } Chris@43: puts("\n };"); Chris@43: } Chris@43: #endif /* MAKEFIXED */ Chris@43: Chris@43: /* Macros for inflateBack(): */ Chris@43: Chris@43: /* Clear the input bit accumulator */ Chris@43: #define INITBITS() \ Chris@43: do { \ Chris@43: hold = 0; \ Chris@43: bits = 0; \ Chris@43: } while (0) Chris@43: Chris@43: /* Assure that some input is available. If input is requested, but denied, Chris@43: then return a Z_BUF_ERROR from inflateBack(). */ Chris@43: #define PULL() \ Chris@43: do { \ Chris@43: if (have == 0) { \ Chris@43: have = in(in_desc, &next); \ Chris@43: if (have == 0) { \ Chris@43: next = Z_NULL; \ Chris@43: ret = Z_BUF_ERROR; \ Chris@43: goto inf_leave; \ Chris@43: } \ Chris@43: } \ Chris@43: } while (0) Chris@43: Chris@43: /* Get a byte of input into the bit accumulator, or return from inflateBack() Chris@43: with an error if there is no input available. */ Chris@43: #define PULLBYTE() \ Chris@43: do { \ Chris@43: PULL(); \ Chris@43: have--; \ Chris@43: hold += (unsigned long)(*next++) << bits; \ Chris@43: bits += 8; \ Chris@43: } while (0) Chris@43: Chris@43: /* Assure that there are at least n bits in the bit accumulator. If there is Chris@43: not enough available input to do that, then return from inflateBack() with Chris@43: an error. */ Chris@43: #define NEEDBITS(n) \ Chris@43: do { \ Chris@43: while (bits < (unsigned)(n)) \ Chris@43: PULLBYTE(); \ Chris@43: } while (0) Chris@43: Chris@43: /* Return the low n bits of the bit accumulator (n <= 16) */ Chris@43: #define BITS(n) \ Chris@43: ((unsigned)hold & ((1U << (n)) - 1)) Chris@43: Chris@43: /* Remove n bits from the bit accumulator */ Chris@43: #define DROPBITS(n) \ Chris@43: do { \ Chris@43: hold >>= (n); \ Chris@43: bits -= (unsigned)(n); \ Chris@43: } while (0) Chris@43: Chris@43: /* Remove zero to seven bits as needed to go to a byte boundary */ Chris@43: #define BYTEBITS() \ Chris@43: do { \ Chris@43: hold >>= bits & 7; \ Chris@43: bits -= bits & 7; \ Chris@43: } while (0) Chris@43: Chris@43: /* Assure that some output space is available, by writing out the window Chris@43: if it's full. If the write fails, return from inflateBack() with a Chris@43: Z_BUF_ERROR. */ Chris@43: #define ROOM() \ Chris@43: do { \ Chris@43: if (left == 0) { \ Chris@43: put = window; \ Chris@43: left = WSIZE; \ Chris@43: wrap = 1; \ Chris@43: if (out(out_desc, put, (unsigned)left)) { \ Chris@43: ret = Z_BUF_ERROR; \ Chris@43: goto inf_leave; \ Chris@43: } \ Chris@43: } \ Chris@43: } while (0) Chris@43: Chris@43: /* Chris@43: strm provides the memory allocation functions and window buffer on input, Chris@43: and provides information on the unused input on return. For Z_DATA_ERROR Chris@43: returns, strm will also provide an error message. Chris@43: Chris@43: in() and out() are the call-back input and output functions. When Chris@43: inflateBack() needs more input, it calls in(). When inflateBack() has Chris@43: filled the window with output, or when it completes with data in the Chris@43: window, it calls out() to write out the data. The application must not Chris@43: change the provided input until in() is called again or inflateBack() Chris@43: returns. The application must not change the window/output buffer until Chris@43: inflateBack() returns. Chris@43: Chris@43: in() and out() are called with a descriptor parameter provided in the Chris@43: inflateBack() call. This parameter can be a structure that provides the Chris@43: information required to do the read or write, as well as accumulated Chris@43: information on the input and output such as totals and check values. Chris@43: Chris@43: in() should return zero on failure. out() should return non-zero on Chris@43: failure. If either in() or out() fails, than inflateBack() returns a Chris@43: Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it Chris@43: was in() or out() that caused in the error. Otherwise, inflateBack() Chris@43: returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format Chris@43: error, or Z_MEM_ERROR if it could not allocate memory for the state. Chris@43: inflateBack() can also return Z_STREAM_ERROR if the input parameters Chris@43: are not correct, i.e. strm is Z_NULL or the state was not initialized. Chris@43: */ Chris@43: int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc) Chris@43: z_stream FAR *strm; Chris@43: in_func in; Chris@43: void FAR *in_desc; Chris@43: out_func out; Chris@43: void FAR *out_desc; Chris@43: { Chris@43: struct inflate_state FAR *state; Chris@43: z_const unsigned char FAR *next; /* next input */ Chris@43: unsigned char FAR *put; /* next output */ Chris@43: unsigned have; /* available input */ Chris@43: unsigned long left; /* available output */ Chris@43: inflate_mode mode; /* current inflate mode */ Chris@43: int lastblock; /* true if processing last block */ Chris@43: int wrap; /* true if the window has wrapped */ Chris@43: unsigned char FAR *window; /* allocated sliding window, if needed */ Chris@43: unsigned long hold; /* bit buffer */ Chris@43: unsigned bits; /* bits in bit buffer */ Chris@43: unsigned extra; /* extra bits needed */ Chris@43: unsigned long length; /* literal or length of data to copy */ Chris@43: unsigned long offset; /* distance back to copy string from */ Chris@43: unsigned long copy; /* number of stored or match bytes to copy */ Chris@43: unsigned char FAR *from; /* where to copy match bytes from */ Chris@43: code const FAR *lencode; /* starting table for length/literal codes */ Chris@43: code const FAR *distcode; /* starting table for distance codes */ Chris@43: unsigned lenbits; /* index bits for lencode */ Chris@43: unsigned distbits; /* index bits for distcode */ Chris@43: code here; /* current decoding table entry */ Chris@43: code last; /* parent table entry */ Chris@43: unsigned len; /* length to copy for repeats, bits to drop */ Chris@43: int ret; /* return code */ Chris@43: static const unsigned short order[19] = /* permutation of code lengths */ Chris@43: {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; Chris@43: #include "inffix9.h" Chris@43: Chris@43: /* Check that the strm exists and that the state was initialized */ Chris@43: if (strm == Z_NULL || strm->state == Z_NULL) Chris@43: return Z_STREAM_ERROR; Chris@43: state = (struct inflate_state FAR *)strm->state; Chris@43: Chris@43: /* Reset the state */ Chris@43: strm->msg = Z_NULL; Chris@43: mode = TYPE; Chris@43: lastblock = 0; Chris@43: wrap = 0; Chris@43: window = state->window; Chris@43: next = strm->next_in; Chris@43: have = next != Z_NULL ? strm->avail_in : 0; Chris@43: hold = 0; Chris@43: bits = 0; Chris@43: put = window; Chris@43: left = WSIZE; Chris@43: lencode = Z_NULL; Chris@43: distcode = Z_NULL; Chris@43: Chris@43: /* Inflate until end of block marked as last */ Chris@43: for (;;) Chris@43: switch (mode) { Chris@43: case TYPE: Chris@43: /* determine and dispatch block type */ Chris@43: if (lastblock) { Chris@43: BYTEBITS(); Chris@43: mode = DONE; Chris@43: break; Chris@43: } Chris@43: NEEDBITS(3); Chris@43: lastblock = BITS(1); Chris@43: DROPBITS(1); Chris@43: switch (BITS(2)) { Chris@43: case 0: /* stored block */ Chris@43: Tracev((stderr, "inflate: stored block%s\n", Chris@43: lastblock ? " (last)" : "")); Chris@43: mode = STORED; Chris@43: break; Chris@43: case 1: /* fixed block */ Chris@43: lencode = lenfix; Chris@43: lenbits = 9; Chris@43: distcode = distfix; Chris@43: distbits = 5; Chris@43: Tracev((stderr, "inflate: fixed codes block%s\n", Chris@43: lastblock ? " (last)" : "")); Chris@43: mode = LEN; /* decode codes */ Chris@43: break; Chris@43: case 2: /* dynamic block */ Chris@43: Tracev((stderr, "inflate: dynamic codes block%s\n", Chris@43: lastblock ? " (last)" : "")); Chris@43: mode = TABLE; Chris@43: break; Chris@43: case 3: Chris@43: strm->msg = (char *)"invalid block type"; Chris@43: mode = BAD; Chris@43: } Chris@43: DROPBITS(2); Chris@43: break; Chris@43: Chris@43: case STORED: Chris@43: /* get and verify stored block length */ Chris@43: BYTEBITS(); /* go to byte boundary */ Chris@43: NEEDBITS(32); Chris@43: if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { Chris@43: strm->msg = (char *)"invalid stored block lengths"; Chris@43: mode = BAD; Chris@43: break; Chris@43: } Chris@43: length = (unsigned)hold & 0xffff; Chris@43: Tracev((stderr, "inflate: stored length %lu\n", Chris@43: length)); Chris@43: INITBITS(); Chris@43: Chris@43: /* copy stored block from input to output */ Chris@43: while (length != 0) { Chris@43: copy = length; Chris@43: PULL(); Chris@43: ROOM(); Chris@43: if (copy > have) copy = have; Chris@43: if (copy > left) copy = left; Chris@43: zmemcpy(put, next, copy); Chris@43: have -= copy; Chris@43: next += copy; Chris@43: left -= copy; Chris@43: put += copy; Chris@43: length -= copy; Chris@43: } Chris@43: Tracev((stderr, "inflate: stored end\n")); Chris@43: mode = TYPE; Chris@43: break; Chris@43: Chris@43: case TABLE: Chris@43: /* get dynamic table entries descriptor */ Chris@43: NEEDBITS(14); Chris@43: state->nlen = BITS(5) + 257; Chris@43: DROPBITS(5); Chris@43: state->ndist = BITS(5) + 1; Chris@43: DROPBITS(5); Chris@43: state->ncode = BITS(4) + 4; Chris@43: DROPBITS(4); Chris@43: if (state->nlen > 286) { Chris@43: strm->msg = (char *)"too many length symbols"; Chris@43: mode = BAD; Chris@43: break; Chris@43: } Chris@43: Tracev((stderr, "inflate: table sizes ok\n")); Chris@43: Chris@43: /* get code length code lengths (not a typo) */ Chris@43: state->have = 0; Chris@43: while (state->have < state->ncode) { Chris@43: NEEDBITS(3); Chris@43: state->lens[order[state->have++]] = (unsigned short)BITS(3); Chris@43: DROPBITS(3); Chris@43: } Chris@43: while (state->have < 19) Chris@43: state->lens[order[state->have++]] = 0; Chris@43: state->next = state->codes; Chris@43: lencode = (code const FAR *)(state->next); Chris@43: lenbits = 7; Chris@43: ret = inflate_table9(CODES, state->lens, 19, &(state->next), Chris@43: &(lenbits), state->work); Chris@43: if (ret) { Chris@43: strm->msg = (char *)"invalid code lengths set"; Chris@43: mode = BAD; Chris@43: break; Chris@43: } Chris@43: Tracev((stderr, "inflate: code lengths ok\n")); Chris@43: Chris@43: /* get length and distance code code lengths */ Chris@43: state->have = 0; Chris@43: while (state->have < state->nlen + state->ndist) { Chris@43: for (;;) { Chris@43: here = lencode[BITS(lenbits)]; Chris@43: if ((unsigned)(here.bits) <= bits) break; Chris@43: PULLBYTE(); Chris@43: } Chris@43: if (here.val < 16) { Chris@43: NEEDBITS(here.bits); Chris@43: DROPBITS(here.bits); Chris@43: state->lens[state->have++] = here.val; Chris@43: } Chris@43: else { Chris@43: if (here.val == 16) { Chris@43: NEEDBITS(here.bits + 2); Chris@43: DROPBITS(here.bits); Chris@43: if (state->have == 0) { Chris@43: strm->msg = (char *)"invalid bit length repeat"; Chris@43: mode = BAD; Chris@43: break; Chris@43: } Chris@43: len = (unsigned)(state->lens[state->have - 1]); Chris@43: copy = 3 + BITS(2); Chris@43: DROPBITS(2); Chris@43: } Chris@43: else if (here.val == 17) { Chris@43: NEEDBITS(here.bits + 3); Chris@43: DROPBITS(here.bits); Chris@43: len = 0; Chris@43: copy = 3 + BITS(3); Chris@43: DROPBITS(3); Chris@43: } Chris@43: else { Chris@43: NEEDBITS(here.bits + 7); Chris@43: DROPBITS(here.bits); Chris@43: len = 0; Chris@43: copy = 11 + BITS(7); Chris@43: DROPBITS(7); Chris@43: } Chris@43: if (state->have + copy > state->nlen + state->ndist) { Chris@43: strm->msg = (char *)"invalid bit length repeat"; Chris@43: mode = BAD; Chris@43: break; Chris@43: } Chris@43: while (copy--) Chris@43: state->lens[state->have++] = (unsigned short)len; Chris@43: } Chris@43: } Chris@43: Chris@43: /* handle error breaks in while */ Chris@43: if (mode == BAD) break; Chris@43: Chris@43: /* check for end-of-block code (better have one) */ Chris@43: if (state->lens[256] == 0) { Chris@43: strm->msg = (char *)"invalid code -- missing end-of-block"; Chris@43: mode = BAD; Chris@43: break; Chris@43: } Chris@43: Chris@43: /* build code tables -- note: do not change the lenbits or distbits Chris@43: values here (9 and 6) without reading the comments in inftree9.h Chris@43: concerning the ENOUGH constants, which depend on those values */ Chris@43: state->next = state->codes; Chris@43: lencode = (code const FAR *)(state->next); Chris@43: lenbits = 9; Chris@43: ret = inflate_table9(LENS, state->lens, state->nlen, Chris@43: &(state->next), &(lenbits), state->work); Chris@43: if (ret) { Chris@43: strm->msg = (char *)"invalid literal/lengths set"; Chris@43: mode = BAD; Chris@43: break; Chris@43: } Chris@43: distcode = (code const FAR *)(state->next); Chris@43: distbits = 6; Chris@43: ret = inflate_table9(DISTS, state->lens + state->nlen, Chris@43: state->ndist, &(state->next), &(distbits), Chris@43: state->work); Chris@43: if (ret) { Chris@43: strm->msg = (char *)"invalid distances set"; Chris@43: mode = BAD; Chris@43: break; Chris@43: } Chris@43: Tracev((stderr, "inflate: codes ok\n")); Chris@43: mode = LEN; Chris@43: Chris@43: case LEN: Chris@43: /* get a literal, length, or end-of-block code */ Chris@43: for (;;) { Chris@43: here = lencode[BITS(lenbits)]; Chris@43: if ((unsigned)(here.bits) <= bits) break; Chris@43: PULLBYTE(); Chris@43: } Chris@43: if (here.op && (here.op & 0xf0) == 0) { Chris@43: last = here; Chris@43: for (;;) { Chris@43: here = lencode[last.val + Chris@43: (BITS(last.bits + last.op) >> last.bits)]; Chris@43: if ((unsigned)(last.bits + here.bits) <= bits) break; Chris@43: PULLBYTE(); Chris@43: } Chris@43: DROPBITS(last.bits); Chris@43: } Chris@43: DROPBITS(here.bits); Chris@43: length = (unsigned)here.val; Chris@43: Chris@43: /* process literal */ Chris@43: if (here.op == 0) { Chris@43: Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? Chris@43: "inflate: literal '%c'\n" : Chris@43: "inflate: literal 0x%02x\n", here.val)); Chris@43: ROOM(); Chris@43: *put++ = (unsigned char)(length); Chris@43: left--; Chris@43: mode = LEN; Chris@43: break; Chris@43: } Chris@43: Chris@43: /* process end of block */ Chris@43: if (here.op & 32) { Chris@43: Tracevv((stderr, "inflate: end of block\n")); Chris@43: mode = TYPE; Chris@43: break; Chris@43: } Chris@43: Chris@43: /* invalid code */ Chris@43: if (here.op & 64) { Chris@43: strm->msg = (char *)"invalid literal/length code"; Chris@43: mode = BAD; Chris@43: break; Chris@43: } Chris@43: Chris@43: /* length code -- get extra bits, if any */ Chris@43: extra = (unsigned)(here.op) & 31; Chris@43: if (extra != 0) { Chris@43: NEEDBITS(extra); Chris@43: length += BITS(extra); Chris@43: DROPBITS(extra); Chris@43: } Chris@43: Tracevv((stderr, "inflate: length %lu\n", length)); Chris@43: Chris@43: /* get distance code */ Chris@43: for (;;) { Chris@43: here = distcode[BITS(distbits)]; Chris@43: if ((unsigned)(here.bits) <= bits) break; Chris@43: PULLBYTE(); Chris@43: } Chris@43: if ((here.op & 0xf0) == 0) { Chris@43: last = here; Chris@43: for (;;) { Chris@43: here = distcode[last.val + Chris@43: (BITS(last.bits + last.op) >> last.bits)]; Chris@43: if ((unsigned)(last.bits + here.bits) <= bits) break; Chris@43: PULLBYTE(); Chris@43: } Chris@43: DROPBITS(last.bits); Chris@43: } Chris@43: DROPBITS(here.bits); Chris@43: if (here.op & 64) { Chris@43: strm->msg = (char *)"invalid distance code"; Chris@43: mode = BAD; Chris@43: break; Chris@43: } Chris@43: offset = (unsigned)here.val; Chris@43: Chris@43: /* get distance extra bits, if any */ Chris@43: extra = (unsigned)(here.op) & 15; Chris@43: if (extra != 0) { Chris@43: NEEDBITS(extra); Chris@43: offset += BITS(extra); Chris@43: DROPBITS(extra); Chris@43: } Chris@43: if (offset > WSIZE - (wrap ? 0: left)) { Chris@43: strm->msg = (char *)"invalid distance too far back"; Chris@43: mode = BAD; Chris@43: break; Chris@43: } Chris@43: Tracevv((stderr, "inflate: distance %lu\n", offset)); Chris@43: Chris@43: /* copy match from window to output */ Chris@43: do { Chris@43: ROOM(); Chris@43: copy = WSIZE - offset; Chris@43: if (copy < left) { Chris@43: from = put + copy; Chris@43: copy = left - copy; Chris@43: } Chris@43: else { Chris@43: from = put - offset; Chris@43: copy = left; Chris@43: } Chris@43: if (copy > length) copy = length; Chris@43: length -= copy; Chris@43: left -= copy; Chris@43: do { Chris@43: *put++ = *from++; Chris@43: } while (--copy); Chris@43: } while (length != 0); Chris@43: break; Chris@43: Chris@43: case DONE: Chris@43: /* inflate stream terminated properly -- write leftover output */ Chris@43: ret = Z_STREAM_END; Chris@43: if (left < WSIZE) { Chris@43: if (out(out_desc, window, (unsigned)(WSIZE - left))) Chris@43: ret = Z_BUF_ERROR; Chris@43: } Chris@43: goto inf_leave; Chris@43: Chris@43: case BAD: Chris@43: ret = Z_DATA_ERROR; Chris@43: goto inf_leave; Chris@43: Chris@43: default: /* can't happen, but makes compilers happy */ Chris@43: ret = Z_STREAM_ERROR; Chris@43: goto inf_leave; Chris@43: } Chris@43: Chris@43: /* Return unused input */ Chris@43: inf_leave: Chris@43: strm->next_in = next; Chris@43: strm->avail_in = have; Chris@43: return ret; Chris@43: } Chris@43: Chris@43: int ZEXPORT inflateBack9End(strm) Chris@43: z_stream FAR *strm; Chris@43: { Chris@43: if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) Chris@43: return Z_STREAM_ERROR; Chris@43: ZFREE(strm, strm->state); Chris@43: strm->state = Z_NULL; Chris@43: Tracev((stderr, "inflate: end\n")); Chris@43: return Z_OK; Chris@43: }