33 stream_size != (
int)(
sizeof(
z_stream)))
36 windowBits < 8 || windowBits > 15)
39 if (strm->zalloc == (alloc_func)0) {
44 strm->opaque = (voidpf)0;
47 if (strm->zfree == (free_func)0)
56 Tracev((stderr,
"inflate: allocated\n"));
59 state->
wbits = windowBits;
60 state->
wsize = 1U << windowBits;
80 static int virgin = 1;
81 static code *lenfix, *distfix;
82 static code fixed[544];
91 while (sym < 144) state->lens[sym++] = 8;
92 while (sym < 256) state->lens[sym++] = 9;
93 while (sym < 280) state->lens[sym++] = 7;
94 while (sym < 288) state->lens[sym++] = 8;
102 while (sym < 32) state->lens[sym++] = 5;
113 state->lencode = lenfix;
115 state->distcode = distfix;
124 put = strm->next_out; \
125 left = strm->avail_out; \
126 next = strm->next_in; \
127 have = strm->avail_in; \
128 hold = state->hold; \
129 bits = state->bits; \
135 strm->next_out = put; \
136 strm->avail_out = left; \
137 strm->next_in = next; \
138 strm->avail_in = have; \
139 state->hold = hold; \
140 state->bits = bits; \
155 have = in(in_desc, &next); \
170 hold += (unsigned long)(*next++) << bits; \
177 #define NEEDBITS(n) \
179 while (bits < (unsigned)(n)) \
185 ((unsigned)hold & ((1U << (n)) - 1))
188 #define DROPBITS(n) \
191 bits -= (unsigned)(n); \
207 put = state->window; \
208 left = state->wsize; \
209 state->whave = left; \
210 if (out(out_desc, put, left)) { \
247 unsigned char FAR *
next;
248 unsigned char FAR *put;
253 unsigned char FAR *from;
258 static const unsigned short order[19] =
259 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
271 next = strm->next_in;
272 have = next !=
Z_NULL ? strm->avail_in : 0;
280 switch (state->
mode) {
293 Tracev((stderr,
"inflate: stored block%s\n",
294 state->
last ?
" (last)" :
""));
299 Tracev((stderr,
"inflate: fixed codes block%s\n",
300 state->
last ?
" (last)" :
""));
304 Tracev((stderr,
"inflate: dynamic codes block%s\n",
305 state->
last ?
" (last)" :
""));
309 strm->msg = (
char *)
"invalid block type";
319 if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
320 strm->msg = (
char *)
"invalid stored block lengths";
324 state->
length = (unsigned)hold & 0xffff;
325 Tracev((stderr,
"inflate: stored length %u\n",
330 while (state->
length != 0) {
334 if (copy > have) copy =
have;
335 if (copy > left) copy =
left;
343 Tracev((stderr,
"inflate: stored end\n"));
356 #ifndef PKZIP_BUG_WORKAROUND
357 if (state->
nlen > 286 || state->
ndist > 30) {
358 strm->msg = (
char *)
"too many length or distance symbols";
363 Tracev((stderr,
"inflate: table sizes ok\n"));
369 state->
lens[order[state->
have++]] = (
unsigned short)
BITS(3);
372 while (state->
have < 19)
373 state->
lens[order[state->
have++]] = 0;
380 strm->msg = (
char *)
"invalid code lengths set";
384 Tracev((stderr,
"inflate: code lengths ok\n"));
391 if ((
unsigned)(here.
bits) <= bits)
break;
399 if (here.
val == 16) {
402 if (state->
have == 0) {
403 strm->msg = (
char *)
"invalid bit length repeat";
407 len = (unsigned)(state->
lens[state->
have - 1]);
411 else if (here.
val == 17) {
426 strm->msg = (
char *)
"invalid bit length repeat";
431 state->
lens[state->
have++] = (
unsigned short)len;
439 if (state->
lens[256] == 0) {
440 strm->msg = (
char *)
"invalid code -- missing end-of-block";
454 strm->msg = (
char *)
"invalid literal/lengths set";
463 strm->msg = (
char *)
"invalid distances set";
467 Tracev((stderr,
"inflate: codes ok\n"));
472 if (have >= 6 && left >= 258) {
484 if ((
unsigned)(here.
bits) <= bits)
break;
487 if (here.
op && (here.
op & 0xf0) == 0) {
492 if ((
unsigned)(last.
bits + here.
bits) <= bits)
break;
503 "inflate: literal '%c'\n" :
504 "inflate: literal 0x%02x\n", here.
val));
506 *put++ = (
unsigned char)(state->
length);
514 Tracevv((stderr,
"inflate: end of block\n"));
521 strm->msg = (
char *)
"invalid literal/length code";
527 state->
extra = (unsigned)(here.
op) & 15;
528 if (state->
extra != 0) {
538 if ((
unsigned)(here.
bits) <= bits)
break;
541 if ((here.
op & 0xf0) == 0) {
546 if ((
unsigned)(last.
bits + here.
bits) <= bits)
break;
553 strm->msg = (
char *)
"invalid distance code";
560 state->
extra = (
unsigned)(here.
op) & 15;
561 if (state->
extra != 0) {
568 strm->msg = (
char *)
"invalid distance too far back";
583 from = put - state->
offset;
592 }
while (state->
length != 0);
598 if (left < state->
wsize) {
599 if (out(out_desc, state->
window, state->
wsize - left))
615 strm->next_in =
next;
616 strm->avail_in =
have;
622 if (strm ==
Z_NULL || strm->state ==
Z_NULL || strm->zfree == (free_func)0)
624 ZFREE(strm, strm->state);
626 Tracev((stderr,
"inflate: end\n"));
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start)
for(Int_t i=0;i< nentries;i++)
code const FAR * distcode
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
#define ZALLOC(strm, items, size)
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)
void copy(std::vector< T > &main, const std::vector< T > &data)
#define ZFREE(strm, addr)
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
local void fixedtables(struct inflate_state FAR *state)
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size)
unsigned char FAR * window
int ZEXPORT inflateBackEnd(z_streamp strm)
voidpf alloc_func OF((voidpf opaque, uInt items, uInt size))