Add deflateGetDictionary() function.

Per request, but its utility is likely to be very limited. See the
comments in zlib.h.
This commit is contained in:
Mark Adler
2016-12-30 16:29:56 -08:00
parent feafcfaa05
commit ee7d7b5dda
2 changed files with 43 additions and 0 deletions

View File

@@ -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;