From 77b47d55f14be032c0ee10da44bbe7591be0abd8 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Fri, 7 Oct 2011 23:00:42 -0700 Subject: Add undocumented inflateResetKeep() function for CAB file decoding. The Microsoft CAB file format compresses each block with completed deflate streams that depend on the sliding window history of the previous block in order to decode. inflateResetKeep() does what inflateReset() does, except the sliding window history from the previous inflate operation is retained. --- inflate.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'inflate.c') diff --git a/inflate.c b/inflate.c index cf10b01..e14b361 100644 --- a/inflate.c +++ b/inflate.c @@ -100,7 +100,7 @@ local int updatewindow OF((z_streamp strm, unsigned out)); local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, unsigned len)); -int ZEXPORT inflateReset(strm) +int ZEXPORT inflateResetKeep(strm) z_streamp strm; { struct inflate_state FAR *state; @@ -115,9 +115,6 @@ z_streamp strm; state->havedict = 0; state->dmax = 32768U; state->head = Z_NULL; - state->wsize = 0; - state->whave = 0; - state->wnext = 0; state->hold = 0; state->bits = 0; state->lencode = state->distcode = state->next = state->codes; @@ -127,6 +124,19 @@ z_streamp strm; return Z_OK; } +int ZEXPORT inflateReset(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + state->wsize = 0; + state->whave = 0; + state->wnext = 0; + return inflateResetKeep(strm); +} + int ZEXPORT inflateReset2(strm, windowBits) z_streamp strm; int windowBits; -- cgit v1.2.3-55-g6feb