32#define DEF_WBITS MAX_WBITS
34#define zmemzero(dest, len) memset(dest, 0, len)
36#define Assert(cond,msg)
44#define ZALLOC(strm, items, size) \
45 (*((strm)->zalloc))((strm)->opaque, (items), (size))
46#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
47#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
50#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
51 (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
57#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
58#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
59#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
60#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
61#define DO16(buf) DO8(buf,0); DO8(buf,8);
63#define MOD(a) a %= BASE
64#define MOD28(a) a %= BASE
65#define MOD63(a) a %= BASE
73 sum2 = (adler >> 16) & 0xffff;
84 return adler | (sum2 << 16);
100 return adler | (sum2 << 16);
131 return adler | (sum2 << 16);
140#define ENOUGH_LENS 852
141#define ENOUGH_DISTS 592
142#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
226 unsigned short lens[320];
227 unsigned short work[288];
275 unsigned char FAR *beg;
313 lcode =
state->lencode;
314 dcode =
state->distcode;
315 lmask = (1U <<
state->lenbits) - 1;
316 dmask = (1U <<
state->distbits) - 1;
327 here = lcode[
hold & lmask];
335 "inflate: literal '%c'\n" :
336 "inflate: literal 0x%02x\n", here.
val));
358 here = dcode[
hold & dmask];
378 strm->msg = (
char *)
"invalid distance too far back";
392 (
char *)
"invalid distance too far back";
396#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
483 else if ((
op & 64) == 0) {
484 here = dcode[here.
val + (
hold & ((1U <<
op) - 1))];
488 strm->msg = (
char *)
"invalid distance code";
493 else if ((
op & 64) == 0) {
494 here = lcode[here.
val + (
hold & ((1U <<
op) - 1))];
503 strm->msg = (
char *)
"invalid literal/length code";
546 const unsigned short FAR *
base;
550 unsigned short offs[
MAXBITS+1];
551 static const unsigned short lbase[31] = {
552 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
553 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
554 static const unsigned short lext[31] = {
555 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
556 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202};
557 static const unsigned short dbase[32] = {
558 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
559 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
560 8193, 12289, 16385, 24577, 0, 0};
561 static const unsigned short dext[32] = {
562 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
563 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
564 28, 28, 29, 29, 64, 64};
600 for (sym = 0; sym <
codes; sym++)
609 here.
op = (
unsigned char)64;
626 if (
left < 0)
return -1;
637 for (sym = 0; sym <
codes; sym++)
709 here.
op = (
unsigned char)0;
717 here.
op = (
unsigned char)(32 + 64);
722 incr = 1U << (
len - drop);
731 incr = 1U << (
len - 1);
760 while (curr + drop <
max) {
762 if (
left <= 0)
break;
775 (*table)[low].op = (
unsigned char)curr;
776 (*table)[low].bits = (
unsigned char)
root;
785 here.
op = (
unsigned char)64;
823 state->dmax = 32768U;
869 if (
windowBits && (windowBits < 8 || windowBits > 15))
922 {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
923 {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
924 {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
925 {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
926 {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
927 {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
928 {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
929 {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
930 {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
931 {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
932 {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
933 {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
934 {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
935 {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
936 {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
937 {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
938 {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
939 {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
940 {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
941 {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
942 {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
943 {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
944 {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
945 {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
946 {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
947 {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
948 {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
949 {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
950 {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
951 {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
952 {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
953 {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
954 {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
955 {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
956 {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
957 {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
958 {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
959 {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
960 {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
961 {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
962 {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
963 {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
964 {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
965 {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
966 {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
967 {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
968 {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
969 {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
970 {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
971 {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
972 {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
973 {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
974 {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
975 {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
976 {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
977 {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
978 {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
979 {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
980 {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
981 {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
982 {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
983 {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
984 {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
985 {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
986 {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
987 {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
988 {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
989 {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
990 {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
991 {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
992 {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
993 {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
994 {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
999 {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
1000 {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
1001 {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
1002 {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
1003 {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
1010 state->distbits = 5;
1036 state->window = (
unsigned char FAR *)
1038 sizeof(
unsigned char));
1043 if (
state->wsize == 0) {
1066 state->wnext += dist;
1076#define crc32(crc,buf,len) RtlComputeCrc32(crc,buf,len)
1080# define UPDATE(check, buf, len) \
1081 (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
1083# define UPDATE(check, buf, len) adler32(check, buf, len)
1088# define CRC2(check, word) \
1090 hbuf[0] = (unsigned char)(word); \
1091 hbuf[1] = (unsigned char)((word) >> 8); \
1092 check = crc32(check, hbuf, 2); \
1095# define CRC4(check, word) \
1097 hbuf[0] = (unsigned char)(word); \
1098 hbuf[1] = (unsigned char)((word) >> 8); \
1099 hbuf[2] = (unsigned char)((word) >> 16); \
1100 hbuf[3] = (unsigned char)((word) >> 24); \
1101 check = crc32(check, hbuf, 4); \
1108 put = strm->next_out; \
1109 left = strm->avail_out; \
1110 next = strm->next_in; \
1111 have = strm->avail_in; \
1112 hold = state->hold; \
1113 bits = state->bits; \
1119 strm->next_out = put; \
1120 strm->avail_out = left; \
1121 strm->next_in = next; \
1122 strm->avail_in = have; \
1123 state->hold = hold; \
1124 state->bits = bits; \
1138 if (have == 0) goto inf_leave; \
1140 hold += (unsigned long)(*next++) << bits; \
1146#define NEEDBITS(n) \
1148 while (bits < (unsigned)(n)) \
1154 ((unsigned)hold & ((1U << (n)) - 1))
1157#define DROPBITS(n) \
1160 bits -= (unsigned)(n); \
1166 hold >>= bits & 7; \
1268 unsigned char hbuf[4];
1270 static const unsigned short order[19] =
1271 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
1284 switch (
state->mode) {
1286 if (
state->wrap == 0) {
1292 if ((
state->wrap & 2) &&
hold == 0x8b1f) {
1293 if (
state->wbits == 0)
1303 state->head->done = -1;
1304 if (!(
state->wrap & 1) ||
1308 ((
BITS(8) << 8) + (
hold >> 8)) % 31) {
1309 strm->msg = (
char *)
"incorrect header check";
1314 strm->msg = (
char *)
"unknown compression method";
1320 if (
state->wbits == 0)
1323 strm->msg = (
char *)
"invalid window size";
1338 strm->msg = (
char *)
"unknown compression method";
1342 if (
state->flags & 0xe000) {
1343 strm->msg = (
char *)
"unknown header flags set";
1349 if ((
state->flags & 0x0200) && (
state->wrap & 4))
1357 if ((
state->flags & 0x0200) && (
state->wrap & 4))
1367 if ((
state->flags & 0x0200) && (
state->wrap & 4))
1372 if (
state->flags & 0x0400) {
1377 if ((
state->flags & 0x0200) && (
state->wrap & 4))
1385 if (
state->flags & 0x0400) {
1396 if ((
state->flags & 0x0200) && (
state->wrap & 4))
1402 if (
state->length)
goto inf_leave;
1407 if (
state->flags & 0x0800) {
1408 if (
have == 0)
goto inf_leave;
1417 if ((
state->flags & 0x0200) && (
state->wrap & 4))
1421 if (
len)
goto inf_leave;
1428 if (
state->flags & 0x1000) {
1429 if (
have == 0)
goto inf_leave;
1438 if ((
state->flags & 0x0200) && (
state->wrap & 4))
1442 if (
len)
goto inf_leave;
1448 if (
state->flags & 0x0200) {
1451 strm->msg = (
char *)
"header crc mismatch";
1459 state->head->done = 1;
1471 if (
state->havedict == 0) {
1491 state->last ?
" (last)" :
""));
1497 state->last ?
" (last)" :
""));
1506 state->last ?
" (last)" :
""));
1510 strm->msg = (
char *)
"invalid block type";
1518 if ((
hold & 0xffff) != ((
hold >> 16) ^ 0xffff)) {
1519 strm->msg = (
char *)
"invalid stored block lengths";
1536 if (
copy == 0)
goto inf_leave;
1556#ifndef PKZIP_BUG_WORKAROUND
1557 if (
state->nlen > 286 ||
state->ndist > 30) {
1558 strm->msg = (
char *)
"too many length or distance symbols";
1572 while (
state->have < 19)
1580 strm->msg = (
char *)
"invalid code lengths set";
1591 if ((
unsigned)(here.
bits) <=
bits)
break;
1594 if (here.
val < 16) {
1599 if (here.
val == 16) {
1602 if (
state->have == 0) {
1603 strm->msg = (
char *)
"invalid bit length repeat";
1611 else if (here.
val == 17) {
1626 strm->msg = (
char *)
"invalid bit length repeat";
1639 if (
state->lens[256] == 0) {
1640 strm->msg = (
char *)
"invalid code -- missing end-of-block";
1654 strm->msg = (
char *)
"invalid literal/lengths set";
1659 state->distbits = 6;
1663 strm->msg = (
char *)
"invalid distances set";
1684 if ((
unsigned)(here.
bits) <=
bits)
break;
1687 if (here.
op && (here.
op & 0xf0) == 0) {
1701 if ((
int)(here.
op) == 0) {
1703 "inflate: literal '%c'\n" :
1704 "inflate: literal 0x%02x\n", here.
val));
1715 strm->msg = (
char *)
"invalid literal/length code";
1734 if ((
unsigned)(here.
bits) <=
bits)
break;
1737 if ((here.
op & 0xf0) == 0) {
1751 strm->msg = (
char *)
"invalid distance code";
1756 state->extra = (
unsigned)(here.
op) & 15;
1765#ifdef INFLATE_STRICT
1767 strm->msg = (
char *)
"invalid distance too far back";
1775 if (
left == 0)
goto inf_leave;
1781 strm->msg = (
char *)
"invalid distance too far back";
1785#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1820 if (
left == 0)
goto inf_leave;
1835 if ((
state->wrap & 4) && (
1840 strm->msg = (
char *)
"incorrect data check";
1852 if (
hold != (
state->total & 0xffffffffUL)) {
1853 strm->msg = (
char *)
"incorrect length check";
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
#define crc32(crc, buf, len)
#define CRC2(check, word)
static int inflateReset2(z_streamp strm, int windowBits)
static int inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
#define ZALLOC(strm, items, size)
static int inflateReset(z_streamp strm)
static int inflateResetKeep(z_streamp strm)
#define CRC4(check, word)
static void inflate_fast(z_streamp strm, unsigned start)
#define UPDATE(check, buf, len)
static int inflateStateCheck(z_streamp strm)
static void fixedtables(struct inflate_state FAR *state)
#define ZFREE(strm, addr)
int inflate(z_streamp strm, int flush)
static uLong adler32(uLong adler, const Bytef *buf, uInt len)
int inflateEnd(z_streamp strm)
static int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)
void(* free_func)(voidpf opaque, voidpf address)
gz_header FAR * gz_headerp
voidpf(* alloc_func)(voidpf opaque, uInt items, uInt size)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
#define wrap(journal, var)
GLuint GLuint GLsizei GLenum type
GLuint GLuint GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
GLuint GLdouble GLdouble GLint GLint order
static IHTMLWindow2 * window
static unsigned(__cdecl *hash_bstr)(bstr_t s)
static unsigned __int64 next
#define inflateInit2(strm, windowBits)
#define inflateInit(strm)
unsigned char FAR * window
code const FAR * distcode
static const code distfix[32]
static const code lenfix[512]