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. --- as400/bndsrc | 1 + as400/zlib.inc | 4 ++++ contrib/vstudio/vc10/zlibvc.def | 9 +++++---- contrib/vstudio/vc9/zlibvc.def | 9 +++++---- inflate.c | 18 ++++++++++++++---- win32/zlib.def | 1 + zconf.h | 1 + zconf.h.cmakein | 1 + zconf.h.in | 1 + zlib.h | 1 + zlib.map | 1 + 11 files changed, 35 insertions(+), 12 deletions(-) diff --git a/as400/bndsrc b/as400/bndsrc index dad2bc9b..036cd63a 100644 --- a/as400/bndsrc +++ b/as400/bndsrc @@ -180,5 +180,6 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB') EXPORT SYMBOL("inflatePrime") EXPORT SYMBOL("inflateReset2") EXPORT SYMBOL("inflateUndermine") + EXPORT SYMBOL("inflateResetKeep") ENDPGMEXP diff --git a/as400/zlib.inc b/as400/zlib.inc index 41ff616b..976dca2a 100644 --- a/as400/zlib.inc +++ b/as400/zlib.inc @@ -431,6 +431,10 @@ D strm like(z_stream) Expansion stream D arg 10I 0 value Error code * + D inflateResetKeep... + D PR 10I 0 extproc('inflateResetKeep') End and init. stream + D strm like(z_stream) Expansion stream + * D gzflags PR 10U 0 extproc('gzflags') * /endif diff --git a/contrib/vstudio/vc10/zlibvc.def b/contrib/vstudio/vc10/zlibvc.def index 0d6dc38f..d6ab1c1b 100644 --- a/contrib/vstudio/vc10/zlibvc.def +++ b/contrib/vstudio/vc10/zlibvc.def @@ -128,7 +128,8 @@ EXPORTS inflatePrime @158 inflateReset2 @159 inflateUndermine @160 - -; zlib1 v1.2.6 added: - gzgetc_ @30 - gzflags @162 + +; zlib1 v1.2.6 added: + gzgetc_ @30 + gzflags @162 + inflateResetKeep @163 diff --git a/contrib/vstudio/vc9/zlibvc.def b/contrib/vstudio/vc9/zlibvc.def index 0d6dc38f..d6ab1c1b 100644 --- a/contrib/vstudio/vc9/zlibvc.def +++ b/contrib/vstudio/vc9/zlibvc.def @@ -128,7 +128,8 @@ EXPORTS inflatePrime @158 inflateReset2 @159 inflateUndermine @160 - -; zlib1 v1.2.6 added: - gzgetc_ @30 - gzflags @162 + +; zlib1 v1.2.6 added: + gzgetc_ @30 + gzflags @162 + inflateResetKeep @163 diff --git a/inflate.c b/inflate.c index cf10b01c..e14b361e 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; diff --git a/win32/zlib.def b/win32/zlib.def index 93ea8bf3..c420d8b9 100644 --- a/win32/zlib.def +++ b/win32/zlib.def @@ -77,5 +77,6 @@ EXPORTS inflateSyncPoint get_crc_table inflateUndermine + inflateResetKeep gzgetc_ gzflags diff --git a/zconf.h b/zconf.h index ed16b063..df7ff61a 100644 --- a/zconf.h +++ b/zconf.h @@ -103,6 +103,7 @@ # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine +# define inflateResetKeep z_inflateResetKeep # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table diff --git a/zconf.h.cmakein b/zconf.h.cmakein index 84e46805..84505470 100644 --- a/zconf.h.cmakein +++ b/zconf.h.cmakein @@ -105,6 +105,7 @@ # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine +# define inflateResetKeep z_inflateResetKeep # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table diff --git a/zconf.h.in b/zconf.h.in index ed16b063..df7ff61a 100644 --- a/zconf.h.in +++ b/zconf.h.in @@ -103,6 +103,7 @@ # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine +# define inflateResetKeep z_inflateResetKeep # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table diff --git a/zlib.h b/zlib.h index 96c2c140..99cd0583 100644 --- a/zlib.h +++ b/zlib.h @@ -1687,6 +1687,7 @@ ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); +ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); #ifndef Z_SOLO ZEXTERN unsigned long ZEXPORT gzflags OF((void)); #endif diff --git a/zlib.map b/zlib.map index 627133df..dd27591b 100644 --- a/zlib.map +++ b/zlib.map @@ -74,4 +74,5 @@ ZLIB_1.2.5.1 { ZLIB_1.2.5.2 { gzflags; gzgetc_; + inflateResetKeep; } ZLIB_1.2.5.1; -- cgit v1.2.3-55-g6feb