99 void makefixed
OF((
void));
110 strm->total_in = strm->total_out = state->
total = 0;
113 strm->adler = state->
wrap & 1;
117 state->
dmax = 32768U;
124 Tracev((stderr,
"inflate: reset\n"));
150 if (windowBits < 0) {
152 windowBits = -windowBits;
155 wrap = (windowBits >> 4) + 1;
163 if (windowBits && (windowBits < 8 || windowBits > 15))
172 state->
wbits = (unsigned)windowBits;
182 stream_size != (
int)(
sizeof(
z_stream)))
186 if (strm->zalloc == (alloc_func)0) {
191 strm->opaque = (voidpf)0;
194 if (strm->zfree == (free_func)0)
203 Tracev((stderr,
"inflate: allocated\n"));
231 value &= (1
L <<
bits) - 1;
232 state->
hold += value << state->
bits;
250 static int virgin = 1;
252 static code fixed[544];
261 while (sym < 144) state->lens[sym++] = 8;
262 while (sym < 256) state->lens[sym++] = 9;
263 while (sym < 280) state->lens[sym++] = 7;
264 while (sym < 288) state->lens[sym++] = 8;
272 while (sym < 32) state->lens[sym++] = 5;
316 puts(
" /* inffixed.h -- table for decoding fixed codes");
317 puts(
" * Generated automatically by makefixed().");
320 puts(
" /* WARNING: this file should *not* be used by applications.");
321 puts(
" It is part of the implementation of this library and is");
322 puts(
" subject to change. Applications should only use zlib.h.");
326 printf(
" static const code lenfix[%u] = {", size);
329 if ((low % 7) == 0) printf(
"\n ");
330 printf(
"{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
331 state.lencode[low].bits, state.lencode[low].val);
332 if (++low == size)
break;
337 printf(
"\n static const code distfix[%u] = {", size);
340 if ((low % 6) == 0) printf(
"\n ");
341 printf(
"{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
342 state.distcode[low].val);
343 if (++low == size)
break;
373 state->
window = (
unsigned char FAR *)
375 sizeof(
unsigned char));
380 if (state->
wsize == 0) {
388 if (copy >= state->
wsize) {
395 if (dist > copy) dist = copy;
404 state->
wnext += dist;
415 # define UPDATE(check, buf, len) \
416 (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
418 # define UPDATE(check, buf, len) adler32(check, buf, len)
423 # define CRC2(check, word) \
425 hbuf[0] = (unsigned char)(word); \
426 hbuf[1] = (unsigned char)((word) >> 8); \
427 check = crc32(check, hbuf, 2); \
430 # define CRC4(check, word) \
432 hbuf[0] = (unsigned char)(word); \
433 hbuf[1] = (unsigned char)((word) >> 8); \
434 hbuf[2] = (unsigned char)((word) >> 16); \
435 hbuf[3] = (unsigned char)((word) >> 24); \
436 check = crc32(check, hbuf, 4); \
443 put = strm->next_out; \
444 left = strm->avail_out; \
445 next = strm->next_in; \
446 have = strm->avail_in; \
447 hold = state->hold; \
448 bits = state->bits; \
454 strm->next_out = put; \
455 strm->avail_out = left; \
456 strm->next_in = next; \
457 strm->avail_in = have; \
458 state->hold = hold; \
459 state->bits = bits; \
473 if (have == 0) goto inf_leave; \
475 hold += (unsigned long)(*next++) << bits; \
481 #define NEEDBITS(n) \
483 while (bits < (unsigned)(n)) \
489 ((unsigned)hold & ((1U << (n)) - 1))
492 #define DROPBITS(n) \
495 bits -= (unsigned)(n); \
590 z_const
unsigned char FAR *
next;
591 unsigned char FAR *put;
597 unsigned char FAR *from;
603 unsigned char hbuf[4];
605 static const unsigned short order[19] =
606 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
609 (strm->next_in ==
Z_NULL && strm->avail_in != 0))
619 switch (state->
mode) {
621 if (state->
wrap == 0) {
627 if ((state->
wrap & 2) && hold == 0x8b1f) {
636 state->
head->done = -1;
637 if (!(state->
wrap & 1) ||
641 ((
BITS(8) << 8) + (hold >> 8)) % 31) {
642 strm->msg = (
char *)
"incorrect header check";
647 strm->msg = (
char *)
"unknown compression method";
653 if (state->
wbits == 0)
655 else if (len > state->
wbits) {
656 strm->msg = (
char *)
"invalid window size";
661 Tracev((stderr,
"inflate: zlib header ok\n"));
671 strm->msg = (
char *)
"unknown compression method";
675 if (state->
flags & 0xe000) {
676 strm->msg = (
char *)
"unknown header flags set";
681 state->
head->text = (
int)((hold >> 8) & 1);
695 state->
head->xflags = (
int)(hold & 0xff);
696 state->
head->os = (
int)(hold >> 8);
702 if (state->
flags & 0x0400) {
704 state->
length = (unsigned)(hold);
706 state->
head->extra_len = (unsigned)hold;
714 if (state->
flags & 0x0400) {
716 if (copy > have) copy =
have;
722 len + copy > state->
head->extra_max ?
723 state->
head->extra_max - len : copy);
725 if (state->
flags & 0x0200)
731 if (state->
length)
goto inf_leave;
736 if (state->
flags & 0x0800) {
737 if (have == 0)
goto inf_leave;
740 len = (unsigned)(next[copy++]);
745 }
while (len && copy < have);
746 if (state->
flags & 0x0200)
750 if (len)
goto inf_leave;
757 if (state->
flags & 0x1000) {
758 if (have == 0)
goto inf_leave;
761 len = (unsigned)(next[copy++]);
766 }
while (len && copy < have);
767 if (state->
flags & 0x0200)
771 if (len)
goto inf_leave;
777 if (state->
flags & 0x0200) {
779 if (hold != (state->
check & 0xffff)) {
780 strm->msg = (
char *)
"header crc mismatch";
788 state->
head->done = 1;
819 Tracev((stderr,
"inflate: stored block%s\n",
820 state->
last ?
" (last)" :
""));
825 Tracev((stderr,
"inflate: fixed codes block%s\n",
826 state->
last ?
" (last)" :
""));
834 Tracev((stderr,
"inflate: dynamic codes block%s\n",
835 state->
last ?
" (last)" :
""));
839 strm->msg = (
char *)
"invalid block type";
847 if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
848 strm->msg = (
char *)
"invalid stored block lengths";
852 state->
length = (unsigned)hold & 0xffff;
853 Tracev((stderr,
"inflate: stored length %u\n",
857 if (flush ==
Z_TREES)
goto inf_leave;
863 if (copy > have) copy =
have;
864 if (copy > left) copy = left;
865 if (copy == 0)
goto inf_leave;
874 Tracev((stderr,
"inflate: stored end\n"));
885 #ifndef PKZIP_BUG_WORKAROUND
886 if (state->
nlen > 286 || state->
ndist > 30) {
887 strm->msg = (
char *)
"too many length or distance symbols";
892 Tracev((stderr,
"inflate: table sizes ok\n"));
898 state->
lens[order[state->
have++]] = (
unsigned short)
BITS(3);
901 while (state->
have < 19)
902 state->
lens[order[state->
have++]] = 0;
909 strm->msg = (
char *)
"invalid code lengths set";
913 Tracev((stderr,
"inflate: code lengths ok\n"));
920 if ((
unsigned)(here.
bits) <= bits)
break;
928 if (here.
val == 16) {
931 if (state->
have == 0) {
932 strm->msg = (
char *)
"invalid bit length repeat";
940 else if (here.
val == 17) {
955 strm->msg = (
char *)
"invalid bit length repeat";
960 state->
lens[state->
have++] = (
unsigned short)len;
968 if (state->
lens[256] == 0) {
969 strm->msg = (
char *)
"invalid code -- missing end-of-block";
983 strm->msg = (
char *)
"invalid literal/lengths set";
992 strm->msg = (
char *)
"invalid distances set";
996 Tracev((stderr,
"inflate: codes ok\n"));
998 if (flush ==
Z_TREES)
goto inf_leave;
1002 if (have >= 6 && left >= 258) {
1013 if ((
unsigned)(here.
bits) <= bits)
break;
1016 if (here.
op && (here.
op & 0xf0) == 0) {
1021 if ((
unsigned)(last.
bits + here.
bits) <= bits)
break;
1030 if ((
int)(here.
op) == 0) {
1032 "inflate: literal '%c'\n" :
1033 "inflate: literal 0x%02x\n", here.
val));
1038 Tracevv((stderr,
"inflate: end of block\n"));
1044 strm->msg = (
char *)
"invalid literal/length code";
1048 state->
extra = (unsigned)(here.
op) & 15;
1063 if ((
unsigned)(here.
bits) <= bits)
break;
1066 if ((here.
op & 0xf0) == 0) {
1071 if ((
unsigned)(last.
bits + here.
bits) <= bits)
break;
1080 strm->msg = (
char *)
"invalid distance code";
1085 state->
extra = (
unsigned)(here.
op) & 15;
1094 #ifdef INFLATE_STRICT
1096 strm->msg = (
char *)
"invalid distance too far back";
1104 if (left == 0)
goto inf_leave;
1106 if (state->
offset > copy) {
1107 copy = state->
offset - copy;
1108 if (copy > state->
whave) {
1110 strm->msg = (
char *)
"invalid distance too far back";
1114 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1115 Trace((stderr,
"inflate.c too far\n"));
1116 copy -= state->
whave;
1118 if (copy > left) copy = left;
1128 if (copy > state->
wnext) {
1129 copy -= state->
wnext;
1137 from = put - state->
offset;
1140 if (copy > left) copy = left;
1149 if (left == 0)
goto inf_leave;
1150 *put++ = (
unsigned char)(state->
length);
1158 strm->total_out += out;
1159 state->
total += out;
1161 strm->adler = state->
check =
1166 state->
flags ? hold :
1169 strm->msg = (
char *)
"incorrect data check";
1174 Tracev((stderr,
"inflate: check matches trailer\n"));
1181 if (hold != (state->
total & 0xffffffffUL)) {
1182 strm->msg = (
char *)
"incorrect length check";
1187 Tracev((stderr,
"inflate: length matches trailer\n"));
1212 if (state->
wsize || (out != strm->avail_out && state->
mode <
BAD &&
1214 if (
updatewindow(strm, strm->next_out, out - strm->avail_out)) {
1218 in -= strm->avail_in;
1219 out -= strm->avail_out;
1220 strm->total_in += in;
1221 strm->total_out += out;
1222 state->
total += out;
1223 if (state->
wrap && out)
1224 strm->adler = state->
check =
1226 strm->data_type = state->
bits + (state->
last ? 64 : 0) +
1229 if (((in == 0 && out == 0) || flush ==
Z_FINISH) && ret ==
Z_OK)
1237 if (strm ==
Z_NULL || strm->state ==
Z_NULL || strm->zfree == (free_func)0)
1241 ZFREE(strm, strm->state);
1243 Tracev((stderr,
"inflate: end\n"));
1262 if (dictLength !=
Z_NULL)
1263 *dictLength = state->
whave;
1270 unsigned long dictid;
1282 dictid =
adler32(dictid, dictionary, dictLength);
1283 if (dictid != state->
check)
1289 ret =
updatewindow(strm, dictionary + dictLength, dictLength);
1295 Tracev((stderr,
"inflate: dictionary set\n"));
1332 while (next < len && got < 4) {
1333 if ((
int)(buf[next]) == (got < 2 ? 0 : 0xff))
1348 unsigned long in, out;
1349 unsigned char buf[4];
1363 while (state->
bits >= 8) {
1364 buf[len++] = (
unsigned char)(state->
hold);
1374 strm->avail_in -=
len;
1375 strm->next_in +=
len;
1376 strm->total_in +=
len;
1380 in = strm->total_in; out = strm->total_out;
1382 strm->total_in = in; strm->total_out = out;
1408 unsigned char FAR *
window;
1413 source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
1423 window = (
unsigned char FAR *)
1424 ZALLOC(source, 1U << state->
wbits,
sizeof(
unsigned char));
1426 ZFREE(source, copy);
1434 if (state->lencode >= state->codes &&
1435 state->lencode <= state->codes +
ENOUGH - 1) {
1436 copy->lencode = copy->codes + (state->lencode - state->codes);
1437 copy->distcode = copy->codes + (state->distcode - state->codes);
1439 copy->next = copy->codes + (state->next - state->codes);
1441 wsize = 1U << state->wbits;
1442 zmemcpy(window, state->window, wsize);
1455 state->
sane = !subvert;
1456 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1468 if (strm ==
Z_NULL || strm->state ==
Z_NULL)
return 0xffffFFFFffff0000
L;
1471 return ((
long)(state->
back) << 16) +
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size)
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
int ZEXPORT inflateSync(z_streamp strm)
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, uInt *dictLength)
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start)
int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)
int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
int ZEXPORT inflateUndermine(z_streamp strm, int subvert)
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
code const FAR * distcode
local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, unsigned len)
static const code lenfix[512]
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
gz_header FAR * gz_headerp
#define CRC2(check, word)
#define ZALLOC(strm, items, size)
int ZEXPORT inflateResetKeep(z_streamp strm)
static const code distfix[32]
const XML_Char int const XML_Char * value
int ZEXPORT inflateSyncPoint(z_streamp strm)
#define ZFREE(strm, addr)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
#define UPDATE(check, buf, len)
local void fixedtables(struct inflate_state FAR *state)
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength)
#define CRC4(check, word)
unsigned char FAR * window
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
int ZEXPORT inflateEnd(z_streamp strm)
int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head)
static constexpr double L
int ZEXPORT inflate(z_streamp strm, int flush)
long ZEXPORT inflateMark(z_streamp strm)
voidpf alloc_func OF((voidpf opaque, uInt items, uInt size))
int ZEXPORT inflateReset(z_streamp strm)