summaryrefslogtreecommitdiff
path: root/deflate.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2016-12-30 16:29:56 -0800
committerMark Adler <madler@alumni.caltech.edu>2016-12-30 16:29:56 -0800
commitee7d7b5dda25c111e61e19ac7b476c26aa6f3020 (patch)
treecfc5d9b06269fb46f1c4d1dcab77ce71ae5143bd /deflate.c
parentfeafcfaa05537869bd128af5474f62b19df8b502 (diff)
downloadzlib-ee7d7b5dda25c111e61e19ac7b476c26aa6f3020.tar.gz
Add deflateGetDictionary() function.
Per request, but its utility is likely to be very limited. See the comments in zlib.h.
Diffstat (limited to 'deflate.c')
-rw-r--r--deflate.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/deflate.c b/deflate.c
index 47d55af..cf4c056 100644
--- a/deflate.c
+++ b/deflate.c
@@ -441,6 +441,27 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
}
/* ========================================================================= */
+int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength)
+ z_streamp strm;
+ Bytef *dictionary;
+ uInt *dictLength;
+{
+ deflate_state *s;
+
+ if (deflateStateCheck(strm))
+ return Z_STREAM_ERROR;
+ s = strm->state;
+ uInt len = s->strstart + s->lookahead;
+ if (len > s->w_size)
+ len = s->w_size;
+ if (dictionary != Z_NULL && len)
+ zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len);
+ if (dictLength != Z_NULL)
+ *dictLength = len;
+ return Z_OK;
+}
+
+/* ========================================================================= */
int ZEXPORT deflateResetKeep (strm)
z_streamp strm;
{