100 void makefixed
OF((
void));
110 strm->zalloc == (alloc_func)0 ||
strm->zfree == (free_func)0)
133 state->
dmax = 32768U;
140 Tracev((stderr,
"inflate: reset\n"));
169 if (windowBits < 0) {
171 windowBits = -windowBits;
174 wrap = (windowBits >> 4) + 5;
182 if (windowBits && (windowBits < 8 || windowBits > 15))
192 state->
wbits = (unsigned)windowBits;
206 stream_size != (
int)(
sizeof(
z_stream)))
210 if (
strm->zalloc == (alloc_func)0) {
218 if (
strm->zfree == (free_func)0)
266 value &= (1L <<
bits) - 1;
267 state->
hold += (unsigned)value << state->
bits;
286 static int virgin = 1;
288 static code fixed[544];
297 while (sym < 144) state->
lens[sym++] = 8;
298 while (sym < 256) state->
lens[sym++] = 9;
299 while (sym < 280) state->
lens[sym++] = 7;
300 while (sym < 288) state->
lens[sym++] = 8;
308 while (sym < 32) state->
lens[sym++] = 5;
352 puts(
" /* inffixed.h -- table for decoding fixed codes");
353 puts(
" * Generated automatically by makefixed().");
356 puts(
" /* WARNING: this file should *not* be used by applications.");
357 puts(
" It is part of the implementation of this library and is");
358 puts(
" subject to change. Applications should only use zlib.h.");
362 printf(
" static const code lenfix[%u] = {", size);
365 if ((low % 7) == 0) printf(
"\n ");
366 printf(
"{%u,%u,%d}", (low & 127) == 99 ? 64 : state.
lencode[low].op,
368 if (++low == size)
break;
373 printf(
"\n static const code distfix[%u] = {", size);
376 if ((low % 6) == 0) printf(
"\n ");
379 if (++low == size)
break;
420 if (state->
wsize == 0) {
427 if (copy >= state->
wsize) {
434 if (dist > copy) dist = copy;
443 state->
wnext += dist;
455# define UPDATE(check, buf, len) \
456 (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
458# define UPDATE(check, buf, len) adler32(check, buf, len)
463# define CRC2(check, word) \
465 hbuf[0] = (unsigned char)(word); \
466 hbuf[1] = (unsigned char)((word) >> 8); \
467 check = crc32(check, hbuf, 2); \
470# define CRC4(check, word) \
472 hbuf[0] = (unsigned char)(word); \
473 hbuf[1] = (unsigned char)((word) >> 8); \
474 hbuf[2] = (unsigned char)((word) >> 16); \
475 hbuf[3] = (unsigned char)((word) >> 24); \
476 check = crc32(check, hbuf, 4); \
483 put = strm->next_out; \
484 left = strm->avail_out; \
485 next = strm->next_in; \
486 have = strm->avail_in; \
487 hold = state->hold; \
488 bits = state->bits; \
494 strm->next_out = put; \
495 strm->avail_out = left; \
496 strm->next_in = next; \
497 strm->avail_in = have; \
498 state->hold = hold; \
499 state->bits = bits; \
513 if (have == 0) goto inf_leave; \
515 hold += (unsigned long)(*next++) << bits; \
523 while (bits < (unsigned)(n)) \
529 ((unsigned)hold & ((1U << (n)) - 1))
535 bits -= (unsigned)(n); \
634 unsigned char FAR *put;
640 unsigned char FAR *from;
646 unsigned char hbuf[4];
648 static const unsigned short order[19] =
649 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
662 switch (state->
mode) {
664 if (state->
wrap == 0) {
670 if ((state->
wrap & 2) &&
hold == 0x8b1f) {
671 if (state->
wbits == 0)
681 state->
head->done = -1;
682 if (!(state->
wrap & 1) ||
686 ((
BITS(8) << 8) + (
hold >> 8)) % 31) {
687 strm->msg = (
char *)
"incorrect header check";
692 strm->msg = (
char *)
"unknown compression method";
698 if (state->
wbits == 0)
700 if (len > 15 || len > state->
wbits) {
701 strm->msg = (
char *)
"invalid window size";
705 state->
dmax = 1U << len;
706 Tracev((stderr,
"inflate: zlib header ok\n"));
718 strm->msg = (
char *)
"unknown compression method";
722 if (state->
flags & 0xe000) {
723 strm->msg = (
char *)
"unknown header flags set";
728 state->
head->text = (int)((
hold >> 8) & 1);
729 if ((state->
flags & 0x0200) && (state->
wrap & 4))
737 if ((state->
flags & 0x0200) && (state->
wrap & 4))
744 state->
head->xflags = (int)(
hold & 0xff);
747 if ((state->
flags & 0x0200) && (state->
wrap & 4))
752 if (state->
flags & 0x0400) {
756 state->
head->extra_len = (unsigned)
hold;
757 if ((state->
flags & 0x0200) && (state->
wrap & 4))
765 if (state->
flags & 0x0400) {
773 len + copy > state->
head->extra_max ?
774 state->
head->extra_max - len : copy);
776 if ((state->
flags & 0x0200) && (state->
wrap & 4))
782 if (state->
length)
goto inf_leave;
787 if (state->
flags & 0x0800) {
788 if (
have == 0)
goto inf_leave;
791 len = (unsigned)(
next[copy++]);
796 }
while (len && copy <
have);
797 if ((state->
flags & 0x0200) && (state->
wrap & 4))
801 if (len)
goto inf_leave;
808 if (state->
flags & 0x1000) {
809 if (
have == 0)
goto inf_leave;
812 len = (unsigned)(
next[copy++]);
817 }
while (len && copy <
have);
818 if ((state->
flags & 0x0200) && (state->
wrap & 4))
822 if (len)
goto inf_leave;
828 if (state->
flags & 0x0200) {
831 strm->msg = (
char *)
"header crc mismatch";
838 state->
head->hcrc = (int)((state->
flags >> 9) & 1);
839 state->
head->done = 1;
870 Tracev((stderr,
"inflate: stored block%s\n",
871 state->
last ?
" (last)" :
""));
876 Tracev((stderr,
"inflate: fixed codes block%s\n",
877 state->
last ?
" (last)" :
""));
885 Tracev((stderr,
"inflate: dynamic codes block%s\n",
886 state->
last ?
" (last)" :
""));
890 strm->msg = (
char *)
"invalid block type";
898 if ((
hold & 0xffff) != ((
hold >> 16) ^ 0xffff)) {
899 strm->msg = (
char *)
"invalid stored block lengths";
904 Tracev((stderr,
"inflate: stored length %u\n",
908 if (flush ==
Z_TREES)
goto inf_leave;
915 if (copy > left) copy = left;
916 if (copy == 0)
goto inf_leave;
925 Tracev((stderr,
"inflate: stored end\n"));
936#ifndef PKZIP_BUG_WORKAROUND
937 if (state->
nlen > 286 || state->
ndist > 30) {
938 strm->msg = (
char *)
"too many length or distance symbols";
943 Tracev((stderr,
"inflate: table sizes ok\n"));
949 state->
lens[order[state->
have++]] = (
unsigned short)
BITS(3);
952 while (state->
have < 19)
953 state->
lens[order[state->
have++]] = 0;
960 strm->msg = (
char *)
"invalid code lengths set";
964 Tracev((stderr,
"inflate: code lengths ok\n"));
971 if ((
unsigned)(here.
bits) <=
bits)
break;
979 if (here.
val == 16) {
982 if (state->
have == 0) {
983 strm->msg = (
char *)
"invalid bit length repeat";
991 else if (here.
val == 17) {
1002 copy = 11 +
BITS(7);
1006 strm->msg = (
char *)
"invalid bit length repeat";
1011 state->
lens[state->
have++] = (
unsigned short)len;
1016 if (state->
mode ==
BAD)
break;
1019 if (state->
lens[256] == 0) {
1020 strm->msg = (
char *)
"invalid code -- missing end-of-block";
1034 strm->msg = (
char *)
"invalid literal/lengths set";
1043 strm->msg = (
char *)
"invalid distances set";
1047 Tracev((stderr,
"inflate: codes ok\n"));
1049 if (flush ==
Z_TREES)
goto inf_leave;
1053 if (
have >= 6 && left >= 258) {
1064 if ((
unsigned)(here.
bits) <=
bits)
break;
1067 if (here.
op && (here.
op & 0xf0) == 0) {
1081 if ((
int)(here.
op) == 0) {
1083 "inflate: literal '%c'\n" :
1084 "inflate: literal 0x%02x\n", here.
val));
1089 Tracevv((stderr,
"inflate: end of block\n"));
1095 strm->msg = (
char *)
"invalid literal/length code";
1099 state->
extra = (unsigned)(here.
op) & 15;
1114 if ((
unsigned)(here.
bits) <=
bits)
break;
1117 if ((here.
op & 0xf0) == 0) {
1131 strm->msg = (
char *)
"invalid distance code";
1136 state->
extra = (unsigned)(here.
op) & 15;
1145#ifdef INFLATE_STRICT
1147 strm->msg = (
char *)
"invalid distance too far back";
1155 if (left == 0)
goto inf_leave;
1157 if (state->
offset > copy) {
1158 copy = state->
offset - copy;
1159 if (copy > state->
whave) {
1161 strm->msg = (
char *)
"invalid distance too far back";
1165#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1166 Trace((stderr,
"inflate.c too far\n"));
1167 copy -= state->
whave;
1169 if (copy > left) copy = left;
1179 if (copy > state->
wnext) {
1180 copy -= state->
wnext;
1188 from = put - state->
offset;
1191 if (copy > left) copy = left;
1200 if (left == 0)
goto inf_leave;
1201 *put++ = (
unsigned char)(state->
length);
1218 if ((state->
wrap & 4) && (
1223 strm->msg = (
char *)
"incorrect data check";
1229 Tracev((stderr,
"inflate: check matches trailer\n"));
1236 if (
hold != (state->
total & 0xffffffffUL)) {
1237 strm->msg = (
char *)
"incorrect length check";
1242 Tracev((stderr,
"inflate: length matches trailer\n"));
1273 in -=
strm->avail_in;
1275 strm->total_in += in;
1283 strm->data_type = (int)state->
bits + (state->
last ? 64 : 0) +
1301 Tracev((stderr,
"inflate: end\n"));
1323 if (dictLength !=
Z_NULL)
1324 *dictLength = state->
whave;
1330const Bytef *dictionary;
1334 unsigned long dictid;
1346 dictid =
adler32(dictid, dictionary, dictLength);
1347 if (dictid != state->
check)
1359 Tracev((stderr,
"inflate: dictionary set\n"));
1393const unsigned char FAR *buf;
1401 while (
next < len && got < 4) {
1402 if ((
int)(buf[
next]) == (got < 2 ? 0 : 0xff))
1418 unsigned long in,
out;
1419 unsigned char buf[4];
1433 while (state->
bits >= 8) {
1434 buf[len++] = (
unsigned char)(state->
hold);
1444 strm->avail_in -= len;
1445 strm->next_in += len;
1446 strm->total_in += len;
1496 ZALLOC(source, 1U << state->
wbits,
sizeof(
unsigned char));
1498 ZFREE(source, copy);
1518 dest->state = (
struct internal_state
FAR *)copy;
1530#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1531 state->
sane = !subvert;
1563 return (
long)(((
unsigned long)((
long)state->
back)) << 16) +
1574 return (
unsigned long)(state->
next - state->
codes);
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start)
static const code distfix[32]
static const code lenfix[512]
unsigned long ZEXPORT inflateCodesUsed(z_streamp strm)
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength)
#define CRC2(check, word)
long ZEXPORT inflateMark(z_streamp strm)
int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, uInt *dictLength)
local int inflateStateCheck(z_streamp strm)
int ZEXPORT inflate(z_streamp strm, int flush, int check_crc)
local void fixedtables(struct inflate_state FAR *state)
int ZEXPORT inflateSyncPoint(z_streamp strm)
local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, unsigned len)
#define CRC4(check, word)
#define UPDATE(check, buf, len)
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head)
int ZEXPORT inflateUndermine(z_streamp strm, int subvert)
int ZEXPORT inflateSync(z_streamp strm)
int ZEXPORT inflateResetKeep(z_streamp strm)
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size)
local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)
int ZEXPORT inflateReset(z_streamp strm)
int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
int ZEXPORT inflateEnd(z_streamp strm)
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
int ZEXPORT inflateValidate(z_streamp strm, int check)
int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
code const FAR * distcode
unsigned char FAR * window
gz_header FAR * gz_headerp
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
#define ZALLOC(strm, items, size)
#define ZFREE(strm, addr)