From: Mark Adler Date: Sat, 8 Oct 2011 06:00:42 +0000 (-0700) Subject: Add undocumented inflateResetKeep() function for CAB file decoding. X-Git-Tag: v1.2.5.2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77b47d55f14be032c0ee10da44bbe7591be0abd8;p=thirdparty%2Fzlib-ng.git 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. --- diff --git a/as400/bndsrc b/as400/bndsrc index dad2bc9b0..036cd63ab 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 41ff616b9..976dca2a6 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 0d6dc38fb..d6ab1c1b0 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 0d6dc38fb..d6ab1c1b0 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 cf10b01ca..e14b361e0 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 93ea8bf38..c420d8b91 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 ed16b0631..df7ff61a1 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 84e46805a..845054702 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 ed16b0631..df7ff61a1 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 96c2c1400..99cd0583d 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 627133dfb..dd27591bb 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;