summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-08-07 16:20:11 +0000
committerStefan Metzmacher <metze@samba.org>2008-08-07 19:16:00 +0200
commited3bdf38d721d1f20aef9017b32e14acc0e56192 (patch)
treefd264c62c0c41508051cbf5df76686408ccaee82
parent05235802f7ae8fb1df952d28629dea26af5f1436 (diff)
downloadsamba-ed3bdf38d721d1f20aef9017b32e14acc0e56192.tar.gz
samba-ed3bdf38d721d1f20aef9017b32e14acc0e56192.tar.bz2
samba-ed3bdf38d721d1f20aef9017b32e14acc0e56192.zip
zlib: add inflateReset2()...
metze (This used to be commit 2a4fb661d7e3d601a5eb9ccecb4d4f2b07073097)
-rw-r--r--source4/lib/zlib/inflate.c15
-rw-r--r--source4/lib/zlib/zconf.h1
-rw-r--r--source4/lib/zlib/zlib.h15
3 files changed, 28 insertions, 3 deletions
diff --git a/source4/lib/zlib/inflate.c b/source4/lib/zlib/inflate.c
index 792fdee8e9..0c1ff17951 100644
--- a/source4/lib/zlib/inflate.c
+++ b/source4/lib/zlib/inflate.c
@@ -100,8 +100,9 @@ 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 inflateReset2(strm, flags)
z_streamp strm;
+unsigned flags;
{
struct inflate_state FAR *state;
@@ -115,8 +116,10 @@ z_streamp strm;
state->havedict = 0;
state->dmax = 32768U;
state->head = Z_NULL;
- state->wsize = 0;
- state->whave = 0;
+ if (!(flags & Z_RESET_KEEP_WINDOW)) {
+ state->wsize = 0;
+ state->whave = 0;
+ }
state->write = 0;
state->hold = 0;
state->bits = 0;
@@ -125,6 +128,12 @@ z_streamp strm;
return Z_OK;
}
+int ZEXPORT inflateReset(strm)
+z_streamp strm;
+{
+ return inflateReset2(strm, 0);
+}
+
int ZEXPORT inflatePrime(strm, bits, value)
z_streamp strm;
int bits;
diff --git a/source4/lib/zlib/zconf.h b/source4/lib/zlib/zconf.h
index 03a9431c8b..b65f30ee51 100644
--- a/source4/lib/zlib/zconf.h
+++ b/source4/lib/zlib/zconf.h
@@ -32,6 +32,7 @@
# define inflateSyncPoint z_inflateSyncPoint
# define inflateCopy z_inflateCopy
# define inflateReset z_inflateReset
+# define inflateReset2 z_inflateReset2
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
# define compress z_compress
diff --git a/source4/lib/zlib/zlib.h b/source4/lib/zlib/zlib.h
index 022817927c..20a16d9588 100644
--- a/source4/lib/zlib/zlib.h
+++ b/source4/lib/zlib/zlib.h
@@ -204,6 +204,9 @@ typedef gz_header FAR *gz_headerp;
#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
+#define Z_RESET_KEEP_WINDOW 0x0001
+/* This flag can be passed to inflateReset2 and deflateReset2 */
+
#define zlib_version zlibVersion()
/* for compatibility with versions < 1.0.2 */
@@ -786,6 +789,8 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
destination.
*/
+ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, unsigned flags));
+
ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
/*
This function is equivalent to inflateEnd followed by inflateInit,
@@ -796,6 +801,16 @@ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
stream state was inconsistent (such as zalloc or state being NULL).
*/
+ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, unsigned flags));
+/*
+ This function is like inflateReset, but you can pass some flags
+ to have further control over the behavior. If you pass Z_RESET_KEEP_WINDOW
+ the window will be untouched and will be reused in the next runs of inflate()
+
+ inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being NULL).
+*/
+
ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
int bits,
int value));