From ee7d7b5dda25c111e61e19ac7b476c26aa6f3020 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Fri, 30 Dec 2016 16:29:56 -0800 Subject: Add deflateGetDictionary() function. Per request, but its utility is likely to be very limited. See the comments in zlib.h. --- deflate.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'deflate.c') diff --git a/deflate.c b/deflate.c index 47d55af..cf4c056 100644 --- a/deflate.c +++ b/deflate.c @@ -440,6 +440,27 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) return Z_OK; } +/* ========================================================================= */ +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; -- cgit v1.2.3-55-g6feb