From dca9e1d6f3ee32f26c1831a0a9b3a6a8aa775509 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Sat, 26 May 2012 10:37:17 -0700 Subject: Add inflateGetDictionary() function. --- inflate.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'inflate.c') diff --git a/inflate.c b/inflate.c index 47418a1..d1efdb8 100644 --- a/inflate.c +++ b/inflate.c @@ -1264,6 +1264,29 @@ z_streamp strm; return Z_OK; } +int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) +z_streamp strm; +Bytef *dictionary; +uInt *dictLength; +{ + struct inflate_state FAR *state; + + /* check state */ + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* copy dictionary */ + if (state->whave && dictionary != Z_NULL) { + zmemcpy(dictionary, state->window + state->wnext, + state->whave - state->wnext); + zmemcpy(dictionary + state->whave - state->wnext, + state->window, state->wnext); + } + if (dictLength != Z_NULL) + *dictLength = state->whave; + return Z_OK; +} + int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) z_streamp strm; const Bytef *dictionary; -- cgit v1.2.3-55-g6feb