|
@@ -93,11 +93,12 @@
|
|
|
|
|
|
/* function prototypes */
|
|
/* function prototypes */
|
|
local void fixedtables OF((struct inflate_state FAR *state));
|
|
local void fixedtables OF((struct inflate_state FAR *state));
|
|
-local int updatewindow OF((z_streamp strm, unsigned out));
|
|
|
|
|
|
+local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
|
|
|
|
+ unsigned copy));
|
|
#ifdef BUILDFIXED
|
|
#ifdef BUILDFIXED
|
|
void makefixed OF((void));
|
|
void makefixed OF((void));
|
|
#endif
|
|
#endif
|
|
-local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
|
|
|
|
|
|
+local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
|
|
unsigned len));
|
|
unsigned len));
|
|
|
|
|
|
int ZEXPORT inflateResetKeep(strm)
|
|
int ZEXPORT inflateResetKeep(strm)
|
|
@@ -375,12 +376,13 @@ void makefixed()
|
|
output will fall in the output data, making match copies simpler and faster.
|
|
output will fall in the output data, making match copies simpler and faster.
|
|
The advantage may be dependent on the size of the processor's data caches.
|
|
The advantage may be dependent on the size of the processor's data caches.
|
|
*/
|
|
*/
|
|
-local int updatewindow(strm, out)
|
|
|
|
|
|
+local int updatewindow(strm, end, copy)
|
|
z_streamp strm;
|
|
z_streamp strm;
|
|
-unsigned out;
|
|
|
|
|
|
+const Bytef *end;
|
|
|
|
+unsigned copy;
|
|
{
|
|
{
|
|
struct inflate_state FAR *state;
|
|
struct inflate_state FAR *state;
|
|
- unsigned copy, dist;
|
|
|
|
|
|
+ unsigned dist;
|
|
|
|
|
|
state = (struct inflate_state FAR *)strm->state;
|
|
state = (struct inflate_state FAR *)strm->state;
|
|
|
|
|
|
@@ -400,19 +402,18 @@ unsigned out;
|
|
}
|
|
}
|
|
|
|
|
|
/* copy state->wsize or less output bytes into the circular window */
|
|
/* copy state->wsize or less output bytes into the circular window */
|
|
- copy = out - strm->avail_out;
|
|
|
|
if (copy >= state->wsize) {
|
|
if (copy >= state->wsize) {
|
|
- zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
|
|
|
|
|
|
+ zmemcpy(state->window, end - state->wsize, state->wsize);
|
|
state->wnext = 0;
|
|
state->wnext = 0;
|
|
state->whave = state->wsize;
|
|
state->whave = state->wsize;
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
dist = state->wsize - state->wnext;
|
|
dist = state->wsize - state->wnext;
|
|
if (dist > copy) dist = copy;
|
|
if (dist > copy) dist = copy;
|
|
- zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
|
|
|
|
|
|
+ zmemcpy(state->window + state->wnext, end - copy, dist);
|
|
copy -= dist;
|
|
copy -= dist;
|
|
if (copy) {
|
|
if (copy) {
|
|
- zmemcpy(state->window, strm->next_out - copy, copy);
|
|
|
|
|
|
+ zmemcpy(state->window, end - copy, copy);
|
|
state->wnext = copy;
|
|
state->wnext = copy;
|
|
state->whave = state->wsize;
|
|
state->whave = state->wsize;
|
|
}
|
|
}
|
|
@@ -606,7 +607,7 @@ z_streamp strm;
|
|
int flush;
|
|
int flush;
|
|
{
|
|
{
|
|
struct inflate_state FAR *state;
|
|
struct inflate_state FAR *state;
|
|
- unsigned char FAR *next; /* next input */
|
|
|
|
|
|
+ z_const unsigned char FAR *next; /* next input */
|
|
unsigned char FAR *put; /* next output */
|
|
unsigned char FAR *put; /* next output */
|
|
unsigned have, left; /* available input and output */
|
|
unsigned have, left; /* available input and output */
|
|
unsigned long hold; /* bit buffer */
|
|
unsigned long hold; /* bit buffer */
|
|
@@ -920,7 +921,7 @@ int flush;
|
|
while (state->have < 19)
|
|
while (state->have < 19)
|
|
state->lens[order[state->have++]] = 0;
|
|
state->lens[order[state->have++]] = 0;
|
|
state->next = state->codes;
|
|
state->next = state->codes;
|
|
- state->lencode = (code const FAR *)(state->next);
|
|
|
|
|
|
+ state->lencode = (const code FAR *)(state->next);
|
|
state->lenbits = 7;
|
|
state->lenbits = 7;
|
|
ret = inflate_table(CODES, state->lens, 19, &(state->next),
|
|
ret = inflate_table(CODES, state->lens, 19, &(state->next),
|
|
&(state->lenbits), state->work);
|
|
&(state->lenbits), state->work);
|
|
@@ -994,7 +995,7 @@ int flush;
|
|
values here (9 and 6) without reading the comments in inftrees.h
|
|
values here (9 and 6) without reading the comments in inftrees.h
|
|
concerning the ENOUGH constants, which depend on those values */
|
|
concerning the ENOUGH constants, which depend on those values */
|
|
state->next = state->codes;
|
|
state->next = state->codes;
|
|
- state->lencode = (code const FAR *)(state->next);
|
|
|
|
|
|
+ state->lencode = (const code FAR *)(state->next);
|
|
state->lenbits = 9;
|
|
state->lenbits = 9;
|
|
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
|
|
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
|
|
&(state->lenbits), state->work);
|
|
&(state->lenbits), state->work);
|
|
@@ -1003,7 +1004,7 @@ int flush;
|
|
state->mode = BAD;
|
|
state->mode = BAD;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- state->distcode = (code const FAR *)(state->next);
|
|
|
|
|
|
+ state->distcode = (const code FAR *)(state->next);
|
|
state->distbits = 6;
|
|
state->distbits = 6;
|
|
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
|
|
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
|
|
&(state->next), &(state->distbits), state->work);
|
|
&(state->next), &(state->distbits), state->work);
|
|
@@ -1230,7 +1231,7 @@ int flush;
|
|
RESTORE();
|
|
RESTORE();
|
|
if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
|
|
if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
|
|
(state->mode < CHECK || flush != Z_FINISH)))
|
|
(state->mode < CHECK || flush != Z_FINISH)))
|
|
- if (updatewindow(strm, out)) {
|
|
|
|
|
|
+ if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
|
|
state->mode = MEM;
|
|
state->mode = MEM;
|
|
return Z_MEM_ERROR;
|
|
return Z_MEM_ERROR;
|
|
}
|
|
}
|
|
@@ -1264,6 +1265,29 @@ z_streamp strm;
|
|
return Z_OK;
|
|
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)
|
|
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
|
|
z_streamp strm;
|
|
z_streamp strm;
|
|
const Bytef *dictionary;
|
|
const Bytef *dictionary;
|
|
@@ -1271,8 +1295,6 @@ uInt dictLength;
|
|
{
|
|
{
|
|
struct inflate_state FAR *state;
|
|
struct inflate_state FAR *state;
|
|
unsigned long dictid;
|
|
unsigned long dictid;
|
|
- unsigned char *next;
|
|
|
|
- unsigned avail;
|
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
/* check state */
|
|
/* check state */
|
|
@@ -1291,13 +1313,7 @@ uInt dictLength;
|
|
|
|
|
|
/* copy dictionary to window using updatewindow(), which will amend the
|
|
/* copy dictionary to window using updatewindow(), which will amend the
|
|
existing dictionary if appropriate */
|
|
existing dictionary if appropriate */
|
|
- next = strm->next_out;
|
|
|
|
- avail = strm->avail_out;
|
|
|
|
- strm->next_out = (Bytef *)dictionary + dictLength;
|
|
|
|
- strm->avail_out = 0;
|
|
|
|
- ret = updatewindow(strm, dictLength);
|
|
|
|
- strm->avail_out = avail;
|
|
|
|
- strm->next_out = next;
|
|
|
|
|
|
+ ret = updatewindow(strm, dictionary + dictLength, dictLength);
|
|
if (ret) {
|
|
if (ret) {
|
|
state->mode = MEM;
|
|
state->mode = MEM;
|
|
return Z_MEM_ERROR;
|
|
return Z_MEM_ERROR;
|
|
@@ -1337,7 +1353,7 @@ gz_headerp head;
|
|
*/
|
|
*/
|
|
local unsigned syncsearch(have, buf, len)
|
|
local unsigned syncsearch(have, buf, len)
|
|
unsigned FAR *have;
|
|
unsigned FAR *have;
|
|
-unsigned char FAR *buf;
|
|
|
|
|
|
+const unsigned char FAR *buf;
|
|
unsigned len;
|
|
unsigned len;
|
|
{
|
|
{
|
|
unsigned got;
|
|
unsigned got;
|