99 void makefixed
OF((
void));
111 strm->total_in = strm->total_out = state->
total = 0;
114 strm->adler = state->
wrap & 1;
118 state->
dmax = 32768U;
125 Tracev((stderr,
"inflate: reset\n"));
154 if (windowBits < 0) {
159 wrap = (windowBits >> 4) + 1;
167 if (windowBits && (windowBits < 8 || windowBits > 15))
176 state->
wbits = (unsigned)windowBits;
190 stream_size != (
int)(
sizeof(
z_stream)))
194 if (strm->zalloc == (alloc_func)0) {
202 if (strm->zfree == (free_func)0)
211 Tracev((stderr,
"inflate: allocated\n"));
212 strm->state = (
struct internal_state FAR *)state;
245 value &= (1L <<
bits) - 1;
246 state->
hold += value << state->
bits;
265 static int virgin = 1;
266 static code *lenfix, *distfix;
276 while (sym < 144) state->
lens[sym++] = 8;
277 while (sym < 256) state->
lens[sym++] = 9;
278 while (sym < 280) state->
lens[sym++] = 7;
279 while (sym < 288) state->
lens[sym++] = 8;
287 while (sym < 32) state->
lens[sym++] = 5;
331 puts(
" /* inffixed.h -- table for decoding fixed codes");
332 puts(
" * Generated automatically by makefixed().");
335 puts(
" /* WARNING: this file should *not* be used by applications.");
336 puts(
" It is part of the implementation of this library and is");
337 puts(
" subject to change. Applications should only use zlib.h.");
341 printf(
" static const code lenfix[%u] = {", size);
344 if ((low % 7) == 0) printf(
"\n ");
345 printf(
"{%u,%u,%d}", (low & 127) == 99 ? 64 : state.
lencode[low].
op,
347 if (++low == size)
break;
352 printf(
"\n static const code distfix[%u] = {", size);
355 if ((low % 6) == 0) printf(
"\n ");
358 if (++low == size)
break;
391 state->
window = (
unsigned char FAR *)
393 sizeof(
unsigned char));
398 if (state->
wsize == 0) {
405 if (copy >= state->
wsize) {
412 if (dist > copy) dist = copy;
421 state->
wnext += dist;
433 # define UPDATE(check, buf, len) \ 434 (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) 436 # define UPDATE(check, buf, len) adler32(check, buf, len) 441 # define CRC2(check, word) \ 443 hbuf[0] = (unsigned char)(word); \ 444 hbuf[1] = (unsigned char)((word) >> 8); \ 445 check = crc32(check, hbuf, 2); \ 448 # define CRC4(check, word) \ 450 hbuf[0] = (unsigned char)(word); \ 451 hbuf[1] = (unsigned char)((word) >> 8); \ 452 hbuf[2] = (unsigned char)((word) >> 16); \ 453 hbuf[3] = (unsigned char)((word) >> 24); \ 454 check = crc32(check, hbuf, 4); \ 461 put = strm->next_out; \ 462 left = strm->avail_out; \ 463 next = strm->next_in; \ 464 have = strm->avail_in; \ 465 hold = state->hold; \ 466 bits = state->bits; \ 472 strm->next_out = put; \ 473 strm->avail_out = left; \ 474 strm->next_in = next; \ 475 strm->avail_in = have; \ 476 state->hold = hold; \ 477 state->bits = bits; \ 491 if (have == 0) goto inf_leave; \ 493 hold += (unsigned long)(*next++) << bits; \ 499 #define NEEDBITS(n) \ 501 while (bits < (unsigned)(n)) \ 507 ((unsigned)hold & ((1U << (n)) - 1)) 510 #define DROPBITS(n) \ 513 bits -= (unsigned)(n); \ 611 unsigned char FAR *put;
617 unsigned char FAR *from;
623 unsigned char hbuf[4];
625 static const unsigned short order[19] =
626 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
629 (strm->next_in ==
Z_NULL && strm->avail_in != 0))
639 switch (state->
mode) {
641 if (state->
wrap == 0) {
647 if ((state->
wrap & 2) && hold == 0x8b1f) {
656 state->
head->done = -1;
657 if (!(state->
wrap & 1) ||
661 ((
BITS(8) << 8) + (hold >> 8)) % 31) {
662 strm->msg = (
char *)
"incorrect header check";
667 strm->msg = (
char *)
"unknown compression method";
673 if (state->
wbits == 0)
675 else if (len > state->
wbits) {
676 strm->msg = (
char *)
"invalid window size";
681 Tracev((stderr,
"inflate: zlib header ok\n"));
691 strm->msg = (
char *)
"unknown compression method";
695 if (state->
flags & 0xe000) {
696 strm->msg = (
char *)
"unknown header flags set";
701 state->
head->text = (
int)((hold >> 8) & 1);
715 state->
head->xflags = (
int)(hold & 0xff);
716 state->
head->os = (
int)(hold >> 8);
722 if (state->
flags & 0x0400) {
724 state->
length = (unsigned)(hold);
726 state->
head->extra_len = (unsigned)hold;
734 if (state->
flags & 0x0400) {
736 if (copy > have) copy =
have;
742 len + copy > state->
head->extra_max ?
743 state->
head->extra_max - len : copy);
745 if (state->
flags & 0x0200)
751 if (state->
length)
goto inf_leave;
756 if (state->
flags & 0x0800) {
757 if (have == 0)
goto inf_leave;
760 len = (unsigned)(next[copy++]);
765 }
while (len && copy < have);
766 if (state->
flags & 0x0200)
770 if (len)
goto inf_leave;
777 if (state->
flags & 0x1000) {
778 if (have == 0)
goto inf_leave;
781 len = (unsigned)(next[copy++]);
786 }
while (len && copy < have);
787 if (state->
flags & 0x0200)
791 if (len)
goto inf_leave;
797 if (state->
flags & 0x0200) {
799 if (hold != (state->
check & 0xffff)) {
800 strm->msg = (
char *)
"header crc mismatch";
808 state->
head->done = 1;
839 Tracev((stderr,
"inflate: stored block%s\n",
840 state->
last ?
" (last)" :
""));
845 Tracev((stderr,
"inflate: fixed codes block%s\n",
846 state->
last ?
" (last)" :
""));
854 Tracev((stderr,
"inflate: dynamic codes block%s\n",
855 state->
last ?
" (last)" :
""));
859 strm->msg = (
char *)
"invalid block type";
867 if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
868 strm->msg = (
char *)
"invalid stored block lengths";
872 state->
length = (unsigned)hold & 0xffff;
873 Tracev((stderr,
"inflate: stored length %u\n",
877 if (flush ==
Z_TREES)
goto inf_leave;
883 if (copy > have) copy =
have;
884 if (copy > left) copy =
left;
885 if (copy == 0)
goto inf_leave;
894 Tracev((stderr,
"inflate: stored end\n"));
905 #ifndef PKZIP_BUG_WORKAROUND 906 if (state->
nlen > 286 || state->
ndist > 30) {
907 strm->msg = (
char *)
"too many length or distance symbols";
912 Tracev((stderr,
"inflate: table sizes ok\n"));
918 state->
lens[order[state->
have++]] = (
unsigned short)
BITS(3);
921 while (state->
have < 19)
922 state->
lens[order[state->
have++]] = 0;
929 strm->msg = (
char *)
"invalid code lengths set";
933 Tracev((stderr,
"inflate: code lengths ok\n"));
940 if ((
unsigned)(here.
bits) <= bits)
break;
948 if (here.
val == 16) {
951 if (state->
have == 0) {
952 strm->msg = (
char *)
"invalid bit length repeat";
960 else if (here.
val == 17) {
975 strm->msg = (
char *)
"invalid bit length repeat";
980 state->
lens[state->
have++] = (
unsigned short)len;
988 if (state->
lens[256] == 0) {
989 strm->msg = (
char *)
"invalid code -- missing end-of-block";
1003 strm->msg = (
char *)
"invalid literal/lengths set";
1012 strm->msg = (
char *)
"invalid distances set";
1016 Tracev((stderr,
"inflate: codes ok\n"));
1018 if (flush ==
Z_TREES)
goto inf_leave;
1022 if (have >= 6 && left >= 258) {
1033 if ((
unsigned)(here.
bits) <= bits)
break;
1036 if (here.
op && (here.
op & 0xf0) == 0) {
1041 if ((
unsigned)(last.
bits + here.
bits) <= bits)
break;
1050 if ((
int)(here.
op) == 0) {
1052 "inflate: literal '%c'\n" :
1053 "inflate: literal 0x%02x\n", here.
val));
1058 Tracevv((stderr,
"inflate: end of block\n"));
1064 strm->msg = (
char *)
"invalid literal/length code";
1068 state->
extra = (unsigned)(here.
op) & 15;
1083 if ((
unsigned)(here.
bits) <= bits)
break;
1086 if ((here.
op & 0xf0) == 0) {
1091 if ((
unsigned)(last.
bits + here.
bits) <= bits)
break;
1100 strm->msg = (
char *)
"invalid distance code";
1105 state->
extra = (
unsigned)(here.
op) & 15;
1114 #ifdef INFLATE_STRICT 1116 strm->msg = (
char *)
"invalid distance too far back";
1124 if (left == 0)
goto inf_leave;
1126 if (state->
offset > copy) {
1127 copy = state->
offset - copy;
1128 if (copy > state->
whave) {
1130 strm->msg = (
char *)
"invalid distance too far back";
1134 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR 1135 Trace((stderr,
"inflate.c too far\n"));
1136 copy -= state->
whave;
1138 if (copy > left) copy =
left;
1148 if (copy > state->
wnext) {
1149 copy -= state->
wnext;
1157 from = put - state->
offset;
1160 if (copy > left) copy =
left;
1169 if (left == 0)
goto inf_leave;
1170 *put++ = (
unsigned char)(state->
length);
1178 strm->total_out +=
out;
1181 strm->adler = state->
check =
1186 state->
flags ? hold :
1189 strm->msg = (
char *)
"incorrect data check";
1194 Tracev((stderr,
"inflate: check matches trailer\n"));
1201 if (hold != (state->
total & 0xffffffffUL)) {
1202 strm->msg = (
char *)
"incorrect length check";
1207 Tracev((stderr,
"inflate: length matches trailer\n"));
1232 if (state->
wsize || (out != strm->avail_out && state->
mode <
BAD &&
1234 if (
updatewindow(strm, strm->next_out, out - strm->avail_out)) {
1238 in -= strm->avail_in;
1239 out -= strm->avail_out;
1240 strm->total_in +=
in;
1241 strm->total_out +=
out;
1243 if (state->
wrap && out)
1244 strm->adler = state->
check =
1246 strm->data_type = state->
bits + (state->
last ? 64 : 0) +
1249 if (((in == 0 && out == 0) || flush ==
Z_FINISH) && ret ==
Z_OK)
1258 if (strm ==
Z_NULL || strm->state ==
Z_NULL || strm->zfree == (free_func)0)
1262 ZFREE(strm, strm->state);
1264 Tracev((stderr,
"inflate: end\n"));
1286 if (dictLength !=
Z_NULL)
1287 *dictLength = state->
whave;
1297 unsigned long dictid;
1309 dictid =
adler32(dictid, dictionary, dictLength);
1310 if (dictid != state->
check)
1316 ret =
updatewindow(strm, dictionary + dictLength, dictLength);
1322 Tracev((stderr,
"inflate: dictionary set\n"));
1356 const unsigned char FAR *
buf;
1364 while (next < len && got < 4) {
1365 if ((
int)(buf[next]) == (got < 2 ? 0 : 0xff))
1381 unsigned long in,
out;
1382 unsigned char buf[4];
1396 while (state->
bits >= 8) {
1397 buf[len++] = (
unsigned char)(state->
hold);
1407 strm->avail_in -=
len;
1408 strm->next_in +=
len;
1409 strm->total_in +=
len;
1413 in = strm->total_in; out = strm->total_out;
1415 strm->total_in =
in; strm->total_out =
out;
1444 unsigned char FAR *
window;
1449 source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
1459 window = (
unsigned char FAR *)
1460 ZALLOC(source, 1U << state->
wbits,
sizeof(
unsigned char));
1462 ZFREE(source, copy);
1470 if (state->lencode >= state->codes &&
1471 state->lencode <= state->codes +
ENOUGH - 1) {
1472 copy->lencode = copy->codes + (state->lencode - state->codes);
1473 copy->distcode = copy->codes + (state->distcode - state->codes);
1475 copy->next = copy->codes + (state->next - state->codes);
1477 wsize = 1U << state->wbits;
1478 zmemcpy(window, state->window, wsize);
1481 dest->state = (
struct internal_state FAR *)copy;
1493 state->
sane = !subvert;
1494 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1507 if (strm ==
Z_NULL || strm->state ==
Z_NULL)
return -1L << 16;
1509 return ((
long)(state->
back) << 16) +
int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
int ZEXPORT inflateResetKeep(z_streamp strm)
local void fixedtables OF((struct inflate_state FAR *state))
#define ZALLOC(strm, items, size)
#define UPDATE(check, buf, len)
int ZEXPORT inflateEnd(z_streamp strm)
GLuint GLdouble GLdouble GLint GLint order
code const FAR * distcode
GLsizei GLsizei GLchar * source
#define CRC2(check, word)
void inflate_fast(z_streamp strm, unsigned start)
int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, uInt *dictLength)
GLenum GLuint GLenum GLsizei const GLchar * buf
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
int ZEXPORT inflateSyncPoint(z_streamp strm)
gz_header FAR * gz_headerp
local int out(void *out_desc, unsigned char *buf, unsigned len)
int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
int ZEXPORT inflateSync(z_streamp strm)
int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head)
void zmemcpy(Bytef *dest, const Bytef *source, uInt len)
local void fixedtables(struct inflate_state FAR *state)
#define ZFREE(strm, addr)
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
int ZEXPORT inflate(z_streamp strm, int flush)
GLsizei const GLfloat * value
#define CRC4(check, word)
int const char int stream_size
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size)
int ZEXPORT inflateReset(z_streamp strm)
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
unsigned char FAR * window
local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, unsigned len)
if(!abbox) return FT_THROW(Invalid_Argument)
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength)
void zcfree(voidpf opaque, voidpf ptr)
voidpf zcalloc(voidpf opaque, unsigned items, unsigned size)
int ZEXPORT inflateUndermine(z_streamp strm, int subvert)
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
long ZEXPORT inflateMark(z_streamp strm)
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
local int fixed(struct state *s)
local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)