24 #pragma warning(disable:4127) // conditional expression is constant
25 #pragma warning(disable:4131) // uses old-style declarator
26 #pragma warning(disable:4244) // conversion from 'int ' to 'unsigned short ', possible loss of data
59 #if defined(__MSDOS__) && !defined(MSDOS)
62 #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
65 #if defined(_WINDOWS) && !defined(WINDOWS)
68 #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
73 #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
74 # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
92 #ifdef __STDC_VERSION__
96 # if __STDC_VERSION__ >= 199901L
102 #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
105 #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
108 #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
111 #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
115 #if defined(__OS400__) && !defined(STDC)
126 #ifndef MAX_MEM_LEVEL
128 # define MAX_MEM_LEVEL 8
130 # define MAX_MEM_LEVEL 9
140 # define MAX_WBITS 15
158 # define OF(args) args
171 # if defined(M_I86SM) || defined(M_I86MM)
173 # define SMALL_MEDIUM
180 # if (defined(__SMALL__) || defined(__MEDIUM__))
182 # define SMALL_MEDIUM
195 #if !defined(__MACTYPES__)
196 typedef unsigned char Byte;
198 typedef unsigned int uInt;
199 typedef unsigned long uLong;
203 # define Bytef Byte FAR
205 typedef Byte FAR Bytef;
207 typedef char FAR charf;
208 typedef int FAR intf;
209 typedef uInt FAR uIntf;
210 typedef uLong FAR uLongf;
213 typedef void const *voidpc;
214 typedef void FAR *voidpf;
217 typedef Byte
const *voidpc;
218 typedef Byte FAR *voidpf;
223 # include <sys/types.h>
228 # define z_off_t off_t
236 # define z_off_t long
239 #if defined(__OS400__)
240 # define NO_vsnprintf
244 # define NO_vsnprintf
254 #define ZLIB_VERSION "1.2.3"
255 #define ZLIB_VERNUM 0x1230
291 typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
292 typedef
void (*free_func) OF((voidpf opaque, voidpf address));
294 struct internal_state;
296 typedef struct z_stream_s {
306 struct internal_state FAR *state;
317 typedef z_stream FAR *z_streamp;
323 typedef struct gz_header_s {
340 typedef gz_header FAR *gz_headerp;
375 #define Z_PARTIAL_FLUSH 1
376 #define Z_SYNC_FLUSH 2
377 #define Z_FULL_FLUSH 3
383 #define Z_STREAM_END 1
384 #define Z_NEED_DICT 2
386 #define Z_STREAM_ERROR (-2)
387 #define Z_DATA_ERROR (-3)
388 #define Z_MEM_ERROR (-4)
389 #define Z_BUF_ERROR (-5)
390 #define Z_VERSION_ERROR (-6)
395 #define Z_NO_COMPRESSION 0
396 #define Z_BEST_SPEED 1
397 #define Z_BEST_COMPRESSION 9
398 #define Z_DEFAULT_COMPRESSION (-1)
402 #define Z_HUFFMAN_ONLY 2
405 #define Z_DEFAULT_STRATEGY 0
410 #define Z_ASCII Z_TEXT
442 int deflate OF((z_streamp strm,
int flush));
528 int deflateEnd OF((z_streamp strm));
563 int inflate OF((z_streamp strm,
int flush));
662 int inflateEnd OF((z_streamp strm));
732 int deflateSetDictionary OF((z_streamp strm,
733 const Bytef *dictionary,
771 int deflateCopy OF((z_streamp dest,
789 int deflateReset OF((z_streamp strm));
800 int deflateParams OF((z_streamp strm,
821 int deflateTune OF((z_streamp strm,
838 uLong deflateBound OF((z_streamp strm,
847 int deflatePrime OF((z_streamp strm,
863 int deflateSetHeader OF((z_streamp strm,
930 int inflateSetDictionary OF((z_streamp strm,
931 const Bytef *dictionary,
952 int inflateSync OF((z_streamp strm));
967 int inflateCopy OF((z_streamp dest,
983 int inflateReset OF((z_streamp strm));
993 int inflatePrime OF((z_streamp strm,
1009 int inflateGetHeader OF((z_streamp strm,
1071 typedef unsigned (*in_func) OF((
void FAR *,
unsigned char FAR * FAR *));
1072 typedef
int (*out_func) OF((
void FAR *,
unsigned char FAR *,
unsigned));
1074 int inflateBack OF((z_streamp strm,
1075 in_func in,
void FAR *in_desc,
1076 out_func out,
void FAR *out_desc));
1143 int inflateBackEnd OF((z_streamp strm));
1161 int compress OF((Bytef *dest, uLongf *destLen,
1162 const Bytef *source, uLong sourceLen));
1176 int compress2 OF((Bytef *dest, uLongf *destLen,
1177 const Bytef *source, uLong sourceLen,
1192 uLong compressBound OF((uLong sourceLen));
1199 int uncompress OF((Bytef *dest, uLongf *destLen,
1200 const Bytef *source, uLong sourceLen));
1223 uLong adler32 OF((uLong adler, const Bytef *buf, uInt len));
1239 uLong adler32_combine OF((uLong adler1, uLong adler2,
1248 uLong crc32 OF((uLong crc, const Bytef *buf, uInt len));
1264 uLong crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
1280 int deflateInit_ OF((z_streamp strm,
int level,
1281 const
char *version,
int stream_size));
1282 int inflateInit_ OF((z_streamp strm,
1283 const
char *version,
int stream_size));
1284 int deflateInit2_ OF((z_streamp strm,
int level,
int method,
1285 int windowBits,
int memLevel,
1286 int strategy, const
char *version,
1288 int inflateInit2_ OF((z_streamp strm,
int windowBits,
1289 const
char *version,
int stream_size));
1290 int inflateBackInit_ OF((z_streamp strm,
int windowBits,
1291 unsigned char FAR *window,
1292 const
char *version,
1294 #define deflateInit(strm, level) \
1295 deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
1296 #define inflateInit(strm) \
1297 inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
1298 #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
1299 deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
1300 (strategy), ZLIB_VERSION, sizeof(z_stream))
1301 #define inflateInit2(strm, windowBits) \
1302 inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
1303 #define inflateBackInit(strm, windowBits, window) \
1304 inflateBackInit_((strm), (windowBits), (window), \
1305 ZLIB_VERSION, sizeof(z_stream))
1308 const char * zError OF((
int));
1309 int inflateSyncPoint OF((z_streamp z));
1310 const uLongf * get_crc_table OF((
void));
1324 # include <stddef.h>
1326 # include <string.h>
1327 # include <stdlib.h>
1336 # define errno z_errno
1346 # define local static
1350 typedef unsigned char uch;
1351 typedef uch FAR uchf;
1352 typedef unsigned short ush;
1353 typedef ush FAR ushf;
1354 typedef unsigned long ulg;
1356 extern const char *
const z_errmsg[10];
1359 #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
1361 #define ERR_RETURN(strm,err) \
1362 return (strm->msg = (char*)ERR_MSG(err), (err))
1368 # define DEF_WBITS MAX_WBITS
1372 #if MAX_MEM_LEVEL >= 8
1373 # define DEF_MEM_LEVEL 8
1375 # define DEF_MEM_LEVEL MAX_MEM_LEVEL
1379 #define STORED_BLOCK 0
1380 #define STATIC_TREES 1
1385 #define MAX_MATCH 258
1388 #define PRESET_DICT 0x20
1392 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
1393 # define OS_CODE 0x00
1394 # if defined(__TURBOC__) || defined(__BORLANDC__)
1395 # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
1397 void _Cdecl farfree(
void *block );
1398 void *_Cdecl farmalloc(
unsigned long nbytes );
1403 # include <malloc.h>
1408 # define OS_CODE 0x01
1411 #if defined(VAXC) || defined(VMS)
1412 # define OS_CODE 0x02
1413 # define F_OPEN(name, mode) \
1414 fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
1417 #if defined(ATARI) || defined(atarist)
1418 # define OS_CODE 0x05
1422 # define OS_CODE 0x06
1428 #if defined(MACOS) || defined(TARGET_OS_MAC)
1429 # define OS_CODE 0x07
1430 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
1434 # define fdopen(fd,mode) NULL
1440 # define OS_CODE 0x0a
1445 # define OS_CODE 0x0b
1450 # define OS_CODE 0x0f
1453 #if defined(_BEOS_) || defined(RISCOS)
1454 # define fdopen(fd,mode) NULL
1457 #if (defined(_MSC_VER) && (_MSC_VER > 600))
1458 # if defined(_WIN32_WCE)
1459 # define fdopen(fd,mode) NULL
1460 # ifndef _PTRDIFF_T_DEFINED
1461 typedef int ptrdiff_t;
1462 # define _PTRDIFF_T_DEFINED
1465 # define fdopen(fd,type) _fdopen(fd,type)
1472 # define OS_CODE 0x03
1476 # define F_OPEN(name, mode) fopen((name), (mode))
1481 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
1482 # ifndef HAVE_VSNPRINTF
1483 # define HAVE_VSNPRINTF
1486 #if defined(__CYGWIN__)
1487 # ifndef HAVE_VSNPRINTF
1488 # define HAVE_VSNPRINTF
1491 #ifndef HAVE_VSNPRINTF
1495 # define NO_vsnprintf
1498 # define NO_vsnprintf
1502 # if !defined(vsnprintf) && !defined(NO_vsnprintf)
1503 # define vsnprintf _vsnprintf
1507 # define NO_vsnprintf
1511 # define NO_vsnprintf
1517 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
1524 #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
1525 # define HAVE_MEMCPY
1528 # ifdef SMALL_MEDIUM
1529 # define zmemcpy _fmemcpy
1530 # define zmemcmp _fmemcmp
1531 # define zmemzero(dest, len) _fmemset(dest, 0, len)
1533 # define zmemcpy memcpy
1534 # define zmemcmp memcmp
1535 # define zmemzero(dest, len) memset(dest, 0, len)
1538 extern void zmemcpy OF((Bytef* dest,
const Bytef* source, uInt len));
1539 extern int zmemcmp OF((
const Bytef* s1,
const Bytef* s2, uInt len));
1540 extern void zmemzero OF((Bytef* dest, uInt len));
1546 extern int z_verbose;
1547 extern void z_error OF((
char *m));
1548 # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
1549 # define Trace(x) {if (z_verbose>=0) fprintf x ;}
1550 # define Tracev(x) {if (z_verbose>0) fprintf x ;}
1551 # define Tracevv(x) {if (z_verbose>1) fprintf x ;}
1552 # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
1553 # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
1555 # define Assert(cond,msg)
1559 # define Tracec(c,x)
1560 # define Tracecv(c,x)
1564 voidpf zcalloc OF((voidpf opaque,
unsigned items,
unsigned size));
1565 void zcfree OF((voidpf opaque, voidpf ptr));
1567 #define ZALLOC(strm, items, size) \
1568 (*((strm)->zalloc))((strm)->opaque, (items), (size))
1569 #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
1570 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
1578 const char *
const z_errmsg[10] = {
1585 "insufficient memory",
1587 "incompatible version",
1595 int z_verbose = verbose;
1600 fprintf(stderr,
"%s\n", m);
1608 const char * zError(err)
1611 return ERR_MSG(err);
1614 #if defined(_WIN32_WCE)
1624 void zmemcpy(dest, source, len)
1626 const Bytef* source;
1629 if (len == 0)
return;
1631 *dest++ = *source++;
1632 }
while (--len != 0);
1635 int zmemcmp(s1, s2, len)
1642 for (j = 0; j < len; j++) {
1643 if (s1[j] != s2[j])
return 2*(s1[j] > s2[j])-1;
1648 void zmemzero(dest, len)
1652 if (len == 0)
return;
1655 }
while (--len != 0);
1676 local
int next_ptr = 0;
1678 typedef struct ptr_table_s {
1683 local ptr_table table[MAX_PTR];
1691 voidpf zcalloc (voidpf opaque,
unsigned items,
unsigned size)
1693 voidpf buf = opaque;
1694 ulg bsize = (ulg)items*size;
1699 if (bsize < 65520L) {
1700 buf = farmalloc(bsize);
1701 if (*(ush*)&buf != 0)
return buf;
1703 buf = farmalloc(bsize + 16L);
1705 if (buf == NULL || next_ptr >= MAX_PTR)
return NULL;
1706 table[next_ptr].org_ptr = buf;
1709 *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
1711 table[next_ptr++].new_ptr = buf;
1715 void zcfree (voidpf opaque, voidpf ptr)
1718 if (*(ush*)&ptr != 0) {
1723 for (n = 0; n < next_ptr; n++) {
1724 if (ptr != table[n].new_ptr)
continue;
1726 farfree(table[n].org_ptr);
1727 while (++n < next_ptr) {
1728 table[n-1] = table[n];
1734 Assert(0,
"zcfree: ptr not found");
1745 #if (!defined(_MSC_VER) || (_MSC_VER <= 600))
1746 # define _halloc halloc
1747 # define _hfree hfree
1750 voidpf zcalloc (voidpf opaque,
unsigned items,
unsigned size)
1752 if (opaque) opaque = 0;
1753 return _halloc((
long)items, size);
1756 void zcfree (voidpf opaque, voidpf ptr)
1758 if (opaque) opaque = 0;
1770 extern voidp malloc OF((uInt size));
1771 extern voidp calloc OF((uInt items, uInt size));
1772 extern void free OF((voidpf ptr));
1775 voidpf zcalloc (opaque, items, size)
1780 if (opaque) items += size - size;
1781 return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
1782 (voidpf)calloc(items, size);
1785 void zcfree (opaque, ptr)
1804 #define LENGTH_CODES 29
1807 #define LITERALS 256
1810 #define L_CODES (LITERALS+1+LENGTH_CODES)
1819 #define HEAP_SIZE (2*L_CODES+1)
1825 #define INIT_STATE 42
1826 #define EXTRA_STATE 69
1827 #define NAME_STATE 73
1828 #define COMMENT_STATE 91
1829 #define HCRC_STATE 103
1830 #define BUSY_STATE 113
1831 #define FINISH_STATE 666
1836 typedef struct ct_data_s {
1847 #define Freq fc.freq
1848 #define Code fc.code
1852 typedef struct static_tree_desc_s static_tree_desc;
1854 typedef struct tree_desc_s {
1857 static_tree_desc *stat_desc;
1861 typedef Pos FAR Posf;
1862 typedef unsigned IPos;
1868 typedef struct internal_state {
1872 ulg pending_buf_size;
1929 int match_available;
1939 uInt max_chain_length;
1945 uInt max_lazy_match;
1950 # define max_insert_length max_lazy_match
1966 struct ct_data_s dyn_ltree[HEAP_SIZE];
1967 struct ct_data_s dyn_dtree[2*D_CODES+1];
1968 struct ct_data_s bl_tree[2*BL_CODES+1];
1970 struct tree_desc_s l_desc;
1971 struct tree_desc_s d_desc;
1972 struct tree_desc_s bl_desc;
1974 ush bl_count[MAX_BITS+1];
1977 int heap[2*L_CODES+1];
1984 uch depth[2*L_CODES+1];
2037 } FAR deflate_state;
2042 #define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
2045 #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
2050 #define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
2056 void _tr_init OF((deflate_state *s));
2057 int _tr_tally OF((deflate_state *s,
unsigned dist,
unsigned lc));
2058 void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
2060 void _tr_align OF((deflate_state *s));
2061 void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
2064 #define d_code(dist) \
2065 ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
2075 extern uch _length_code[];
2076 extern uch _dist_code[];
2078 extern const uch _length_code[];
2079 extern const uch _dist_code[];
2082 # define _tr_tally_lit(s, c, flush) \
2084 s->d_buf[s->last_lit] = 0; \
2085 s->l_buf[s->last_lit++] = cc; \
2086 s->dyn_ltree[cc].Freq++; \
2087 flush = (s->last_lit == s->lit_bufsize-1); \
2089 # define _tr_tally_dist(s, distance, length, flush) \
2090 { uch len = (length); \
2091 ush dist = (distance); \
2092 s->d_buf[s->last_lit] = dist; \
2093 s->l_buf[s->last_lit++] = len; \
2095 s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
2096 s->dyn_dtree[d_code(dist)].Freq++; \
2097 flush = (s->last_lit == s->lit_bufsize-1); \
2100 # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
2101 # define _tr_tally_dist(s, distance, length, flush) \
2102 flush = _tr_tally(s, distance, length)
2145 #define MAX_BL_BITS 7
2148 #define END_BLOCK 256
2154 #define REPZ_3_10 17
2157 #define REPZ_11_138 18
2160 local
const int extra_lbits[LENGTH_CODES]
2161 = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
2163 local
const int extra_dbits[D_CODES]
2164 = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
2166 local
const int extra_blbits[BL_CODES]
2167 = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
2169 local
const uch bl_order[BL_CODES]
2170 = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
2175 #define Buf_size (8 * 2*sizeof(char))
2184 #define DIST_CODE_LEN 512
2189 local ct_data static_ltree[L_CODES+2];
2196 local ct_data static_dtree[D_CODES];
2201 uch _dist_code[DIST_CODE_LEN];
2207 uch _length_code[MAX_MATCH-MIN_MATCH+1];
2210 local
int base_length[LENGTH_CODES];
2213 local
int base_dist[D_CODES];
2218 local
const ct_data static_ltree[L_CODES+2] = {
2219 {{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
2220 {{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
2221 {{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
2222 {{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
2223 {{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
2224 {{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
2225 {{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
2226 {{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
2227 {{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
2228 {{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
2229 {{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
2230 {{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
2231 {{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
2232 {{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
2233 {{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
2234 {{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
2235 {{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
2236 {{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
2237 {{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
2238 {{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
2239 {{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
2240 {{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
2241 {{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
2242 {{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
2243 {{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
2244 {{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
2245 {{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
2246 {{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
2247 {{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
2248 {{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
2249 {{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
2250 {{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
2251 {{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
2252 {{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
2253 {{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
2254 {{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
2255 {{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
2256 {{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
2257 {{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
2258 {{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
2259 {{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
2260 {{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
2261 {{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
2262 {{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
2263 {{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
2264 {{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
2265 {{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
2266 {{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
2267 {{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
2268 {{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
2269 {{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
2270 {{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
2271 {{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
2272 {{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
2273 {{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
2274 {{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
2275 {{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
2276 {{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
2279 local
const ct_data static_dtree[D_CODES] = {
2280 {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
2281 {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
2282 {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
2283 {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
2284 {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
2285 {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
2288 const uch _dist_code[DIST_CODE_LEN] = {
2289 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
2290 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
2291 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
2292 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
2293 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
2294 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
2295 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
2296 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
2297 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
2298 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
2299 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
2300 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
2301 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
2302 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
2303 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
2304 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
2305 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
2306 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
2307 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
2308 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
2309 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
2310 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
2311 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
2312 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
2313 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
2314 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
2317 const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
2318 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
2319 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
2320 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
2321 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
2322 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
2323 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
2324 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
2325 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
2326 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
2327 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
2328 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
2329 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
2330 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
2333 local
const int base_length[LENGTH_CODES] = {
2334 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
2335 64, 80, 96, 112, 128, 160, 192, 224, 0
2338 local
const int base_dist[D_CODES] = {
2339 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
2340 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
2341 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
2346 struct static_tree_desc_s {
2347 const ct_data *static_tree;
2348 const intf *extra_bits;
2354 local static_tree_desc static_l_desc =
2355 {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
2357 local static_tree_desc static_d_desc =
2358 {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
2360 local static_tree_desc static_bl_desc =
2361 {(
const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
2367 local
void tr_static_init OF((
void));
2368 local
void init_block OF((deflate_state *s));
2369 local
void pqdownheap OF((deflate_state *s, ct_data *tree,
int k));
2370 local
void gen_bitlen OF((deflate_state *s, tree_desc *desc));
2371 local
void gen_codes OF((ct_data *tree,
int max_code, ushf *bl_count));
2372 local
void build_tree OF((deflate_state *s, tree_desc *desc));
2373 local
void scan_tree OF((deflate_state *s, ct_data *tree,
int max_code));
2374 local
void send_tree OF((deflate_state *s, ct_data *tree,
int max_code));
2375 local
int build_bl_tree OF((deflate_state *s));
2376 local
void send_all_trees OF((deflate_state *s,
int lcodes,
int dcodes,
2378 local
void compress_block OF((deflate_state *s, ct_data *ltree,
2380 local
void set_data_type OF((deflate_state *s));
2381 local
unsigned bi_reverse OF((
unsigned value,
int length));
2382 local
void bi_windup OF((deflate_state *s));
2383 local
void bi_flush OF((deflate_state *s));
2384 local
void copy_block OF((deflate_state *s, charf *buf,
unsigned len,
2388 # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
2392 # define send_code(s, c, tree) \
2393 { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
2394 send_bits(s, tree[c].Code, tree[c].Len); }
2401 #define put_short(s, w) { \
2402 put_byte(s, (uch)((w) & 0xff)); \
2403 put_byte(s, (uch)((ush)(w) >> 8)); \
2411 local
void send_bits OF((deflate_state *s,
int value,
int length));
2413 local
void send_bits(s, value, length)
2418 Tracevv((stderr,
" l %2d v %4x ", length, value));
2419 Assert(length > 0 && length <= 15,
"invalid length");
2420 s->bits_sent += (ulg)length;
2426 if (s->bi_valid > (
int)Buf_size - length) {
2427 s->bi_buf |= (value << s->bi_valid);
2428 put_short(s, s->bi_buf);
2429 s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
2430 s->bi_valid += length - Buf_size;
2432 s->bi_buf |= value << s->bi_valid;
2433 s->bi_valid += length;
2438 #define send_bits(s, value, length) \
2439 { int len = length;\
2440 if (s->bi_valid > (int)Buf_size - len) {\
2442 s->bi_buf |= (val << s->bi_valid);\
2443 put_short(s, s->bi_buf);\
2444 s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
2445 s->bi_valid += len - Buf_size;\
2447 s->bi_buf |= (value) << s->bi_valid;\
2448 s->bi_valid += len;\
2459 local
void tr_static_init()
2462 static int static_init_done = 0;
2468 ush bl_count[MAX_BITS+1];
2471 if (static_init_done)
return;
2474 static_l_desc.static_tree = static_ltree;
2475 static_l_desc.extra_bits = extra_lbits;
2476 static_d_desc.static_tree = static_dtree;
2477 static_d_desc.extra_bits = extra_dbits;
2478 static_bl_desc.extra_bits = extra_blbits;
2482 for (code = 0; code < LENGTH_CODES-1; code++) {
2483 base_length[code] = length;
2484 for (n = 0; n < (1<<extra_lbits[code]); n++) {
2485 _length_code[length++] = (uch)code;
2488 Assert (length == 256,
"tr_static_init: length != 256");
2493 _length_code[length-1] = (uch)code;
2497 for (code = 0 ; code < 16; code++) {
2498 base_dist[code] = dist;
2499 for (n = 0; n < (1<<extra_dbits[code]); n++) {
2500 _dist_code[dist++] = (uch)code;
2503 Assert (dist == 256,
"tr_static_init: dist != 256");
2505 for ( ; code < D_CODES; code++) {
2506 base_dist[code] = dist << 7;
2507 for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
2508 _dist_code[256 + dist++] = (uch)code;
2511 Assert (dist == 256,
"tr_static_init: 256+dist != 512");
2514 for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
2516 while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
2517 while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
2518 while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
2519 while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
2524 gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
2527 for (n = 0; n < D_CODES; n++) {
2528 static_dtree[n].Len = 5;
2529 static_dtree[n].Code = bi_reverse((
unsigned)n, 5);
2531 static_init_done = 1;
2544 s->l_desc.dyn_tree = s->dyn_ltree;
2545 s->l_desc.stat_desc = &static_l_desc;
2547 s->d_desc.dyn_tree = s->dyn_dtree;
2548 s->d_desc.stat_desc = &static_d_desc;
2550 s->bl_desc.dyn_tree = s->bl_tree;
2551 s->bl_desc.stat_desc = &static_bl_desc;
2555 s->last_eob_len = 8;
2557 s->compressed_len = 0L;
2568 local
void init_block(s)
2574 for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
2575 for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
2576 for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
2578 s->dyn_ltree[END_BLOCK].Freq = 1;
2579 s->opt_len = s->static_len = 0L;
2580 s->last_lit = s->matches = 0;
2591 #define pqremove(s, tree, top) \
2593 top = s->heap[SMALLEST]; \
2594 s->heap[SMALLEST] = s->heap[s->heap_len--]; \
2595 pqdownheap(s, tree, SMALLEST); \
2602 #define smaller(tree, n, m, depth) \
2603 (tree[n].Freq < tree[m].Freq || \
2604 (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
2612 local
void pqdownheap(s, tree, k)
2619 while (j <= s->heap_len) {
2621 if (j < s->heap_len &&
2622 smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
2626 if (smaller(tree, v, s->heap[j], s->depth))
break;
2629 s->heap[k] = s->heap[j]; k = j;
2647 local
void gen_bitlen(s, desc)
2651 ct_data *tree = desc->dyn_tree;
2652 int max_code = desc->max_code;
2653 const ct_data *stree = desc->stat_desc->static_tree;
2654 const intf *extra = desc->stat_desc->extra_bits;
2655 int base = desc->stat_desc->extra_base;
2656 int max_length = desc->stat_desc->max_length;
2664 for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
2669 tree[s->heap[s->heap_max]].Len = 0;
2671 for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
2673 bits = tree[tree[n].Dad].Len + 1;
2674 if (bits > max_length) bits = max_length, overflow++;
2675 tree[n].Len = (ush)bits;
2678 if (n > max_code)
continue;
2680 s->bl_count[bits]++;
2682 if (n >= base) xbits = extra[n-base];
2684 s->opt_len += (ulg)f * (bits + xbits);
2685 if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
2687 if (overflow == 0)
return;
2689 Trace((stderr,
"\nbit length overflow\n"));
2694 bits = max_length-1;
2695 #pragma warning(suppress: 6385)
2696 while (s->bl_count[bits] == 0) bits--;
2697 s->bl_count[bits]--;
2698 s->bl_count[bits+1] += 2;
2699 s->bl_count[max_length]--;
2704 }
while (overflow > 0);
2711 for (bits = max_length; bits != 0; bits--) {
2712 n = s->bl_count[bits];
2715 if (m > max_code)
continue;
2716 if ((
unsigned) tree[m].Len != (
unsigned) bits) {
2717 Trace((stderr,
"code %d bits %d->%d\n", m, tree[m].Len, bits));
2718 s->opt_len += ((long)bits - (
long)tree[m].Len)
2719 *(
long)tree[m].Freq;
2720 tree[m].Len = (ush)bits;
2735 local
void gen_codes (tree, max_code, bl_count)
2740 ush next_code[MAX_BITS+1];
2748 for (bits = 1; bits <= MAX_BITS; bits++) {
2749 next_code[bits] = code = (code + bl_count[bits-1]) << 1;
2754 Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
2755 "inconsistent bit counts");
2756 Tracev((stderr,
"\ngen_codes: max_code %d ", max_code));
2758 for (n = 0; n <= max_code; n++) {
2759 int len = tree[n].Len;
2760 if (len == 0)
continue;
2762 tree[n].Code = bi_reverse(next_code[len]++, len);
2764 Tracecv(tree != static_ltree, (stderr,
"\nn %3d %c l %2d c %4x (%x) ",
2765 n, (isgraph(n) ? n :
' '), len, tree[n].Code, next_code[len]-1));
2777 local
void build_tree(s, desc)
2781 ct_data *tree = desc->dyn_tree;
2782 const ct_data *stree = desc->stat_desc->static_tree;
2783 int elems = desc->stat_desc->elems;
2792 s->heap_len = 0, s->heap_max = HEAP_SIZE;
2794 for (n = 0; n < elems; n++) {
2795 if (tree[n].Freq != 0) {
2796 s->heap[++(s->heap_len)] = max_code = n;
2808 while (s->heap_len < 2) {
2809 node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
2810 tree[node].Freq = 1;
2812 s->opt_len--;
if (stree) s->static_len -= stree[node].Len;
2815 desc->max_code = max_code;
2820 for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
2827 pqremove(s, tree, n);
2828 m = s->heap[SMALLEST];
2830 s->heap[--(s->heap_max)] = n;
2831 s->heap[--(s->heap_max)] = m;
2834 tree[node].Freq = tree[n].Freq + tree[m].Freq;
2835 s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
2836 s->depth[n] : s->depth[m]) + 1);
2837 tree[n].Dad = tree[m].Dad = (ush)node;
2839 if (tree == s->bl_tree) {
2840 fprintf(stderr,
"\nnode %d(%d), sons %d(%d) %d(%d)",
2841 node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
2845 s->heap[SMALLEST] = node++;
2846 pqdownheap(s, tree, SMALLEST);
2848 }
while (s->heap_len >= 2);
2850 s->heap[--(s->heap_max)] = s->heap[SMALLEST];
2855 gen_bitlen(s, (tree_desc *)desc);
2858 gen_codes ((ct_data *)tree, max_code, s->bl_count);
2865 local
void scan_tree (s, tree, max_code)
2873 int nextlen = tree[0].Len;
2878 if (nextlen == 0) max_count = 138, min_count = 3;
2879 tree[max_code+1].Len = (ush)0xffff;
2881 for (n = 0; n <= max_code; n++) {
2882 curlen = nextlen; nextlen = tree[n+1].Len;
2883 if (++count < max_count && curlen == nextlen) {
2885 }
else if (count < min_count) {
2886 s->bl_tree[curlen].Freq += count;
2887 }
else if (curlen != 0) {
2888 if (curlen != prevlen) s->bl_tree[curlen].Freq++;
2889 s->bl_tree[REP_3_6].Freq++;
2890 }
else if (count <= 10) {
2891 s->bl_tree[REPZ_3_10].Freq++;
2893 s->bl_tree[REPZ_11_138].Freq++;
2895 count = 0; prevlen = curlen;
2897 max_count = 138, min_count = 3;
2898 }
else if (curlen == nextlen) {
2899 max_count = 6, min_count = 3;
2901 max_count = 7, min_count = 4;
2910 local
void send_tree (s, tree, max_code)
2918 int nextlen = tree[0].Len;
2924 if (nextlen == 0) max_count = 138, min_count = 3;
2926 for (n = 0; n <= max_code; n++) {
2927 curlen = nextlen; nextlen = tree[n+1].Len;
2928 if (++count < max_count && curlen == nextlen) {
2930 }
else if (count < min_count) {
2931 do { send_code(s, curlen, s->bl_tree); }
while (--count != 0);
2933 }
else if (curlen != 0) {
2934 if (curlen != prevlen) {
2935 send_code(s, curlen, s->bl_tree); count--;
2937 Assert(count >= 3 && count <= 6,
" 3_6?");
2938 send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
2940 }
else if (count <= 10) {
2941 send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
2944 send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
2946 count = 0; prevlen = curlen;
2948 max_count = 138, min_count = 3;
2949 }
else if (curlen == nextlen) {
2950 max_count = 6, min_count = 3;
2952 max_count = 7, min_count = 4;
2961 local
int build_bl_tree(s)
2967 scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
2968 scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
2971 build_tree(s, (tree_desc *)(&(s->bl_desc)));
2980 for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
2981 if (s->bl_tree[bl_order[max_blindex]].Len != 0)
break;
2984 s->opt_len += 3*(max_blindex+1) + 5+5+4;
2985 Tracev((stderr,
"\ndyn trees: dyn %ld, stat %ld",
2986 s->opt_len, s->static_len));
2996 local
void send_all_trees(s, lcodes, dcodes, blcodes)
2998 int lcodes, dcodes, blcodes;
3002 Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4,
"not enough codes");
3003 Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
3005 Tracev((stderr,
"\nbl counts: "));
3006 send_bits(s, lcodes-257, 5);
3007 send_bits(s, dcodes-1, 5);
3008 send_bits(s, blcodes-4, 4);
3009 for (rank = 0; rank < blcodes; rank++) {
3010 Tracev((stderr,
"\nbl code %2d ", bl_order[rank]));
3011 send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
3013 Tracev((stderr,
"\nbl tree: sent %ld", s->bits_sent));
3015 send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1);
3016 Tracev((stderr,
"\nlit tree: sent %ld", s->bits_sent));
3018 send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1);
3019 Tracev((stderr,
"\ndist tree: sent %ld", s->bits_sent));
3025 void _tr_stored_block(s, buf, stored_len, eof)
3031 send_bits(s, (STORED_BLOCK<<1)+eof, 3);
3033 s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
3034 s->compressed_len += (stored_len + 4) << 3;
3036 copy_block(s, buf, (
unsigned)stored_len, 1);
3053 send_bits(s, STATIC_TREES<<1, 3);
3054 send_code(s, END_BLOCK, static_ltree);
3056 s->compressed_len += 10L;
3064 if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
3065 send_bits(s, STATIC_TREES<<1, 3);
3066 send_code(s, END_BLOCK, static_ltree);
3068 s->compressed_len += 10L;
3072 s->last_eob_len = 7;
3079 void _tr_flush_block(s, buf, stored_len, eof)
3085 ulg opt_lenb, static_lenb;
3086 int max_blindex = 0;
3092 if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
3096 build_tree(s, (tree_desc *)(&(s->l_desc)));
3097 Tracev((stderr,
"\nlit data: dyn %ld, stat %ld", s->opt_len,
3100 build_tree(s, (tree_desc *)(&(s->d_desc)));
3101 Tracev((stderr,
"\ndist data: dyn %ld, stat %ld", s->opt_len,
3110 max_blindex = build_bl_tree(s);
3113 opt_lenb = (s->opt_len+3+7)>>3;
3114 static_lenb = (s->static_len+3+7)>>3;
3116 Tracev((stderr,
"\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
3117 opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
3120 if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
3123 Assert(buf != (
char*)0,
"lost buf");
3124 opt_lenb = static_lenb = stored_len + 5;
3128 if (buf != (
char*)0) {
3130 if (stored_len+4 <= opt_lenb && buf != (
char*)0) {
3139 _tr_stored_block(s, buf, stored_len, eof);
3142 }
else if (static_lenb >= 0) {
3144 }
else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
3146 send_bits(s, (STATIC_TREES<<1)+eof, 3);
3147 compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
3149 s->compressed_len += 3 + s->static_len;
3152 send_bits(s, (DYN_TREES<<1)+eof, 3);
3153 send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
3155 compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
3157 s->compressed_len += 3 + s->opt_len;
3160 Assert (s->compressed_len == s->bits_sent,
"bad compressed size");
3169 s->compressed_len += 7;
3172 Tracev((stderr,
"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
3173 s->compressed_len-7*eof));
3180 int _tr_tally (s, dist, lc)
3185 s->d_buf[s->last_lit] = (ush)dist;
3186 s->l_buf[s->last_lit++] = (uch)lc;
3189 s->dyn_ltree[lc].Freq++;
3194 Assert((ush)dist < (ush)MAX_DIST(s) &&
3195 (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
3196 (ush)d_code(dist) < (ush)D_CODES,
"_tr_tally: bad match");
3198 s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
3199 s->dyn_dtree[d_code(dist)].Freq++;
3202 #ifdef TRUNCATE_BLOCK
3204 if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
3206 ulg out_length = (ulg)s->last_lit*8L;
3207 ulg in_length = (ulg)((long)s->strstart - s->block_start);
3209 for (dcode = 0; dcode < D_CODES; dcode++) {
3210 out_length += (ulg)s->dyn_dtree[dcode].Freq *
3211 (5L+extra_dbits[dcode]);
3214 Tracev((stderr,
"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
3215 s->last_lit, in_length, out_length,
3216 100L - out_length*100L/in_length));
3217 if (s->matches < s->last_lit/2 && out_length < in_length/2)
return 1;
3220 return (s->last_lit == s->lit_bufsize-1);
3230 local
void compress_block(s, ltree, dtree)
3241 if (s->last_lit != 0)
do {
3242 dist = s->d_buf[lx];
3243 lc = s->l_buf[lx++];
3245 send_code(s, lc, ltree);
3246 Tracecv(isgraph(lc), (stderr,
" '%c' ", lc));
3249 code = _length_code[lc];
3250 send_code(s, code+LITERALS+1, ltree);
3251 extra = extra_lbits[code];
3253 lc -= base_length[code];
3254 send_bits(s, lc, extra);
3257 code = d_code(dist);
3258 Assert (code < D_CODES,
"bad d_code");
3260 send_code(s, code, dtree);
3261 extra = extra_dbits[code];
3263 dist -= base_dist[code];
3264 send_bits(s, dist, extra);
3269 Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
3270 "pendingBuf overflow");
3272 }
while (lx < s->last_lit);
3274 send_code(s, END_BLOCK, ltree);
3275 s->last_eob_len = ltree[END_BLOCK].Len;
3284 local
void set_data_type(s)
3289 for (n = 0; n < 9; n++)
3290 if (s->dyn_ltree[n].Freq != 0)
3293 for (n = 14; n < 32; n++)
3294 if (s->dyn_ltree[n].Freq != 0)
3296 s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
3304 local
unsigned bi_reverse(code, len)
3308 register unsigned res = 0;
3311 code >>= 1, res <<= 1;
3312 }
while (--len > 0);
3319 local
void bi_flush(s)
3322 if (s->bi_valid == 16) {
3323 put_short(s, s->bi_buf);
3326 }
else if (s->bi_valid >= 8) {
3327 put_byte(s, (Byte)s->bi_buf);
3336 local
void bi_windup(s)
3339 if (s->bi_valid > 8) {
3340 put_short(s, s->bi_buf);
3341 }
else if (s->bi_valid > 0) {
3342 put_byte(s, (Byte)s->bi_buf);
3347 s->bits_sent = (s->bits_sent+7) & ~7;
3355 local
void copy_block(s, buf, len, header)
3362 s->last_eob_len = 8;
3365 put_short(s, (ush)len);
3366 put_short(s, (ush)~len);
3368 s->bits_sent += 2*16;
3372 s->bits_sent += (ulg)len<<3;
3375 put_byte(s, *buf++);
3428 const char deflate_copyright[] =
3429 " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
3447 typedef block_state (*compress_func) OF((deflate_state *s,
int flush));
3450 local
void fill_window OF((deflate_state *s));
3451 local block_state deflate_stored OF((deflate_state *s,
int flush));
3452 local block_state deflate_fast OF((deflate_state *s,
int flush));
3454 local block_state deflate_slow OF((deflate_state *s,
int flush));
3456 local
void lm_init OF((deflate_state *s));
3457 local
void putShortMSB OF((deflate_state *s, uInt b));
3458 local
void flush_pending OF((z_streamp strm));
3459 local
int read_buf OF((z_streamp strm, Bytef *buf,
unsigned size));
3462 void match_init OF((
void));
3463 uInt longest_match OF((deflate_state *s, IPos cur_match));
3465 local uInt longest_match OF((deflate_state *s, IPos cur_match));
3468 local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
3471 local
void check_match OF((deflate_state *s, IPos start, IPos match,
3483 # define TOO_FAR 4096
3487 #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
3497 typedef struct config_s {
3506 local
const config configuration_table[2] = {
3508 {0, 0, 0, 0, deflate_stored},
3509 {4, 4, 8, 4, deflate_fast}};
3511 local
const config configuration_table[10] = {
3513 {0, 0, 0, 0, deflate_stored},
3514 {4, 4, 8, 4, deflate_fast},
3515 {4, 5, 16, 8, deflate_fast},
3516 {4, 6, 32, 32, deflate_fast},
3518 {4, 4, 16, 16, deflate_slow},
3519 {8, 16, 32, 32, deflate_slow},
3520 {8, 16, 128, 128, deflate_slow},
3521 {8, 32, 128, 256, deflate_slow},
3522 {32, 128, 258, 1024, deflate_slow},
3523 {32, 258, 258, 4096, deflate_slow}};
3540 #define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
3554 #define INSERT_STRING(s, str, match_head) \
3555 (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
3556 match_head = s->head[s->ins_h], \
3557 s->head[s->ins_h] = (Pos)(str))
3559 #define INSERT_STRING(s, str, match_head) \
3560 (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
3561 match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
3562 s->head[s->ins_h] = (Pos)(str))
3569 #define CLEAR_HASH(s) \
3570 s->head[s->hash_size-1] = NIL; \
3571 zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
3574 int deflateInit_(strm, level, version, stream_size)
3577 const
char *version;
3580 return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
3581 Z_DEFAULT_STRATEGY, version, stream_size);
3586 int deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
3587 version, stream_size)
3594 const
char *version;
3599 static const char my_version[] = ZLIB_VERSION;
3606 if (version == Z_NULL || version[0] != my_version[0] ||
3607 stream_size !=
sizeof(z_stream)) {
3608 return Z_VERSION_ERROR;
3610 if (strm == Z_NULL)
return Z_STREAM_ERROR;
3613 if (strm->zalloc == (alloc_func)0) {
3614 strm->zalloc = zcalloc;
3615 strm->opaque = (voidpf)0;
3617 if (strm->zfree == (free_func)0) strm->zfree = zcfree;
3620 if (level != 0) level = 1;
3622 if (level == Z_DEFAULT_COMPRESSION) level = 6;
3625 if (windowBits < 0) {
3627 windowBits = -windowBits;
3629 if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
3630 windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
3631 strategy < 0 || strategy > Z_FIXED) {
3632 return Z_STREAM_ERROR;
3634 if (windowBits == 8) windowBits = 9;
3635 s = (deflate_state *) ZALLOC(strm, 1,
sizeof(deflate_state));
3636 if (s == Z_NULL)
return Z_MEM_ERROR;
3637 strm->state = (
struct internal_state FAR *)s;
3642 s->w_bits = windowBits;
3643 s->w_size = 1 << s->w_bits;
3644 s->w_mask = s->w_size - 1;
3646 s->hash_bits = memLevel + 7;
3647 s->hash_size = 1 << s->hash_bits;
3648 s->hash_mask = s->hash_size - 1;
3649 s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
3651 s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*
sizeof(Byte));
3652 s->prev = (Posf *) ZALLOC(strm, s->w_size,
sizeof(Pos));
3653 s->head = (Posf *) ZALLOC(strm, s->hash_size,
sizeof(Pos));
3655 s->lit_bufsize = 1 << (memLevel + 6);
3657 overlay = (ushf *) ZALLOC(strm, s->lit_bufsize,
sizeof(ush)+2);
3658 s->pending_buf = (uchf *) overlay;
3659 s->pending_buf_size = (ulg)s->lit_bufsize * (
sizeof(ush)+2L);
3661 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
3662 s->pending_buf == Z_NULL) {
3663 s->status = FINISH_STATE;
3664 strm->msg = (
char*)ERR_MSG(Z_MEM_ERROR);
3668 s->d_buf = overlay + s->lit_bufsize/
sizeof(ush);
3669 s->l_buf = s->pending_buf + (1+
sizeof(ush))*s->lit_bufsize;
3672 s->strategy = strategy;
3673 s->method = (Byte)method;
3675 return deflateReset(strm);
3679 int deflateSetDictionary (strm, dictionary, dictLength)
3681 const Bytef *dictionary;
3685 uInt length = dictLength;
3689 if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
3690 strm->state->wrap == 2 ||
3691 (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
3692 return Z_STREAM_ERROR;
3696 strm->adler = adler32(strm->adler, dictionary, dictLength);
3698 if (length < MIN_MATCH)
return Z_OK;
3699 if (length > MAX_DIST(s)) {
3700 length = MAX_DIST(s);
3701 dictionary += dictLength - length;
3703 zmemcpy(s->window, dictionary, length);
3704 s->strstart = length;
3705 s->block_start = (long)length;
3711 s->ins_h = s->window[0];
3712 UPDATE_HASH(s, s->ins_h, s->window[1]);
3713 for (n = 0; n <= length - MIN_MATCH; n++) {
3714 #pragma warning(suppress: 6385)
3715 INSERT_STRING(s, n, hash_head);
3717 if (hash_head) hash_head = 0;
3722 int deflateReset (strm)
3727 if (strm == Z_NULL || strm->state == Z_NULL ||
3728 strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
3729 return Z_STREAM_ERROR;
3732 strm->total_in = strm->total_out = 0;
3734 strm->data_type = Z_UNKNOWN;
3736 s = (deflate_state *)strm->state;
3738 s->pending_out = s->pending_buf;
3743 s->status = s->wrap ? INIT_STATE : BUSY_STATE;
3745 adler32(0L, Z_NULL, 0);
3746 s->last_flush = Z_NO_FLUSH;
3755 int deflateSetHeader (strm, head)
3759 if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
3760 if (strm->state->wrap != 2)
return Z_STREAM_ERROR;
3761 strm->state->gzhead = head;
3766 int deflatePrime (strm, bits, value)
3771 if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
3772 strm->state->bi_valid = bits;
3773 strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
3778 int deflateParams(strm, level, strategy)
3787 if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
3791 if (level != 0) level = 1;
3793 if (level == Z_DEFAULT_COMPRESSION) level = 6;
3795 if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
3796 return Z_STREAM_ERROR;
3798 func = configuration_table[s->level].func;
3800 if (func != configuration_table[level].func && strm->total_in != 0) {
3802 err = deflate(strm, Z_PARTIAL_FLUSH);
3804 if (s->level != level) {
3806 s->max_lazy_match = configuration_table[level].max_lazy;
3807 s->good_match = configuration_table[level].good_length;
3808 s->nice_match = configuration_table[level].nice_length;
3809 s->max_chain_length = configuration_table[level].max_chain;
3811 s->strategy = strategy;
3816 int deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
3825 if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
3827 s->good_match = good_length;
3828 s->max_lazy_match = max_lazy;
3829 s->nice_match = nice_length;
3830 s->max_chain_length = max_chain;
3851 uLong deflateBound(strm, sourceLen)
3859 destLen = sourceLen +
3860 ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
3863 if (strm == Z_NULL || strm->state == Z_NULL)
3868 if (s->w_bits != 15 || s->hash_bits != 8 + 7)
3872 return compressBound(sourceLen);
3880 local
void putShortMSB (s, b)
3884 put_byte(s, (Byte)(b >> 8));
3885 put_byte(s, (Byte)(b & 0xff));
3894 local
void flush_pending(strm)
3897 unsigned len = strm->state->pending;
3899 if (len > strm->avail_out) len = strm->avail_out;
3900 if (len == 0)
return;
3902 zmemcpy(strm->next_out, strm->state->pending_out, len);
3903 strm->next_out += len;
3904 strm->state->pending_out += len;
3905 strm->total_out += len;
3906 strm->avail_out -= len;
3907 strm->state->pending -= len;
3908 if (strm->state->pending == 0) {
3909 strm->state->pending_out = strm->state->pending_buf;
3914 int deflate (strm, flush)
3921 if (strm == Z_NULL || strm->state == Z_NULL ||
3922 flush > Z_FINISH || flush < 0) {
3923 return Z_STREAM_ERROR;
3927 if (strm->next_out == Z_NULL ||
3928 (strm->next_in == Z_NULL && strm->avail_in != 0) ||
3929 (s->status == FINISH_STATE && flush != Z_FINISH)) {
3930 ERR_RETURN(strm, Z_STREAM_ERROR);
3932 if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
3935 old_flush = s->last_flush;
3936 s->last_flush = flush;
3939 if (s->status == INIT_STATE) {
3941 uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
3944 if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
3946 else if (s->level < 6)
3948 else if (s->level == 6)
3952 header |= (level_flags << 6);
3953 if (s->strstart != 0) header |= PRESET_DICT;
3954 header += 31 - (header % 31);
3956 s->status = BUSY_STATE;
3957 putShortMSB(s, header);
3960 if (s->strstart != 0) {
3961 putShortMSB(s, (uInt)(strm->adler >> 16));
3962 putShortMSB(s, (uInt)(strm->adler & 0xffff));
3964 strm->adler = adler32(0L, Z_NULL, 0);
3969 if (s->pending != 0) {
3970 flush_pending(strm);
3971 if (strm->avail_out == 0) {
3986 }
else if (strm->avail_in == 0 && flush <= old_flush &&
3987 flush != Z_FINISH) {
3988 ERR_RETURN(strm, Z_BUF_ERROR);
3992 if (s->status == FINISH_STATE && strm->avail_in != 0) {
3993 ERR_RETURN(strm, Z_BUF_ERROR);
3998 if (strm->avail_in != 0 || s->lookahead != 0 ||
3999 (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
4002 bstate = (*(configuration_table[s->level].func))(s, flush);
4004 if (bstate == finish_started || bstate == finish_done) {
4005 s->status = FINISH_STATE;
4007 if (bstate == need_more || bstate == finish_started) {
4008 if (strm->avail_out == 0) {
4020 if (bstate == block_done) {
4021 if (flush == Z_PARTIAL_FLUSH) {
4024 _tr_stored_block(s, (
char*)0, 0L, 0);
4028 if (flush == Z_FULL_FLUSH) {
4032 flush_pending(strm);
4033 if (strm->avail_out == 0) {
4039 Assert(strm->avail_out > 0,
"bug2");
4041 if (flush != Z_FINISH)
return Z_OK;
4042 if (s->wrap <= 0)
return Z_STREAM_END;
4046 putShortMSB(s, (uInt)(strm->adler >> 16));
4047 putShortMSB(s, (uInt)(strm->adler & 0xffff));
4049 flush_pending(strm);
4053 if (s->wrap > 0) s->wrap = -s->wrap;
4054 return s->pending != 0 ? Z_OK : Z_STREAM_END;
4058 int deflateEnd (strm)
4063 if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
4065 status = strm->state->status;
4066 if (status != INIT_STATE &&
4067 status != EXTRA_STATE &&
4068 status != NAME_STATE &&
4069 status != COMMENT_STATE &&
4070 status != HCRC_STATE &&
4071 status != BUSY_STATE &&
4072 status != FINISH_STATE) {
4073 return Z_STREAM_ERROR;
4077 TRY_FREE(strm, strm->state->pending_buf);
4078 TRY_FREE(strm, strm->state->head);
4079 TRY_FREE(strm, strm->state->prev);
4080 TRY_FREE(strm, strm->state->window);
4082 ZFREE(strm, strm->state);
4083 strm->state = Z_NULL;
4085 return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
4093 int deflateCopy (dest, source)
4098 return Z_STREAM_ERROR;
4105 if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
4106 return Z_STREAM_ERROR;
4111 zmemcpy(dest, source,
sizeof(z_stream));
4113 ds = (deflate_state *) ZALLOC(dest, 1,
sizeof(deflate_state));
4114 if (ds == Z_NULL)
return Z_MEM_ERROR;
4115 dest->state = (
struct internal_state FAR *) ds;
4116 zmemcpy(ds, ss,
sizeof(deflate_state));
4119 ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*
sizeof(Byte));
4120 ds->prev = (Posf *) ZALLOC(dest, ds->w_size,
sizeof(Pos));
4121 ds->head = (Posf *) ZALLOC(dest, ds->hash_size,
sizeof(Pos));
4122 overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize,
sizeof(ush)+2);
4123 ds->pending_buf = (uchf *) overlay;
4125 if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
4126 ds->pending_buf == Z_NULL) {
4131 zmemcpy(ds->window, ss->window, ds->w_size * 2 *
sizeof(Byte));
4132 zmemcpy(ds->prev, ss->prev, ds->w_size *
sizeof(Pos));
4133 zmemcpy(ds->head, ss->head, ds->hash_size *
sizeof(Pos));
4134 zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
4136 ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
4137 ds->d_buf = overlay + ds->lit_bufsize/
sizeof(ush);
4138 ds->l_buf = ds->pending_buf + (1+
sizeof(ush))*ds->lit_bufsize;
4140 ds->l_desc.dyn_tree = ds->dyn_ltree;
4141 ds->d_desc.dyn_tree = ds->dyn_dtree;
4142 ds->bl_desc.dyn_tree = ds->bl_tree;
4155 local
int read_buf(strm, buf, size)
4160 unsigned len = strm->avail_in;
4162 if (len > size) len = size;
4163 if (len == 0)
return 0;
4165 strm->avail_in -= len;
4167 if (strm->state->wrap == 1) {
4168 strm->adler = adler32(strm->adler, strm->next_in, len);
4170 zmemcpy(buf, strm->next_in, len);
4171 strm->next_in += len;
4172 strm->total_in += len;
4180 local
void lm_init (s)
4183 s->window_size = (ulg)2L*s->w_size;
4189 s->max_lazy_match = configuration_table[s->level].max_lazy;
4190 s->good_match = configuration_table[s->level].good_length;
4191 s->nice_match = configuration_table[s->level].nice_length;
4192 s->max_chain_length = configuration_table[s->level].max_chain;
4195 s->block_start = 0L;
4197 s->match_length = s->prev_length = MIN_MATCH-1;
4198 s->match_available = 0;
4221 local uInt longest_match(s, cur_match)
4225 unsigned chain_length = s->max_chain_length;
4226 register Bytef *scan = s->window + s->strstart;
4227 register Bytef *match;
4229 int best_len = s->prev_length;
4230 int nice_match = s->nice_match;
4231 IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
4232 s->strstart - (IPos)MAX_DIST(s) : NIL;
4236 Posf *prev = s->prev;
4237 uInt wmask = s->w_mask;
4243 register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
4244 register ush scan_start = *(ushf*)scan;
4245 register ush scan_end = *(ushf*)(scan+best_len-1);
4247 register Bytef *strend = s->window + s->strstart + MAX_MATCH;
4248 register Byte scan_end1 = scan[best_len-1];
4249 register Byte scan_end = scan[best_len];
4255 Assert(s->hash_bits >= 8 && MAX_MATCH == 258,
"Code too clever");
4258 if (s->prev_length >= s->good_match) {
4264 if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
4266 Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD,
"need lookahead");
4269 Assert(cur_match < s->strstart,
"no future");
4270 match = s->window + cur_match;
4280 #if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
4284 if (*(ushf*)(match+best_len-1) != scan_end ||
4285 *(ushf*)match != scan_start)
continue;
4296 Assert(scan[2] == match[2],
"scan[2]?");
4299 }
while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
4300 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
4301 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
4302 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
4307 Assert(scan <= s->window+(
unsigned)(s->window_size-1),
"wild scan");
4308 if (*scan == *match) scan++;
4310 len = (MAX_MATCH - 1) - (
int)(strend-scan);
4311 scan = strend - (MAX_MATCH-1);
4315 if (match[best_len] != scan_end ||
4316 match[best_len-1] != scan_end1 ||
4318 *++match != scan[1])
continue;
4327 Assert(*scan == *match,
"match[2]?");
4333 }
while (*++scan == *++match && *++scan == *++match &&
4334 *++scan == *++match && *++scan == *++match &&
4335 *++scan == *++match && *++scan == *++match &&
4336 *++scan == *++match && *++scan == *++match &&
4339 Assert(scan <= s->window+(
unsigned)(s->window_size-1),
"wild scan");
4341 len = MAX_MATCH - (int)(strend - scan);
4342 scan = strend - MAX_MATCH;
4346 if (len > best_len) {
4347 s->match_start = cur_match;
4349 if (len >= nice_match)
break;
4351 scan_end = *(ushf*)(scan+best_len-1);
4353 scan_end1 = scan[best_len-1];
4354 scan_end = scan[best_len];
4357 }
while ((cur_match = prev[cur_match & wmask]) > limit
4358 && --chain_length != 0);
4360 if ((uInt)best_len <= s->lookahead)
return (uInt)best_len;
4361 return s->lookahead;
4369 local uInt longest_match_fast(s, cur_match)
4373 register Bytef *scan = s->window + s->strstart;
4374 register Bytef *match;
4376 register Bytef *strend = s->window + s->strstart + MAX_MATCH;
4381 Assert(s->hash_bits >= 8 && MAX_MATCH == 258,
"Code too clever");
4383 Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD,
"need lookahead");
4385 Assert(cur_match < s->strstart,
"no future");
4387 match = s->window + cur_match;
4391 if (match[0] != scan[0] || match[1] != scan[1])
return MIN_MATCH-1;
4399 scan += 2, match += 2;
4400 Assert(*scan == *match,
"match[2]?");
4406 }
while (*++scan == *++match && *++scan == *++match &&
4407 *++scan == *++match && *++scan == *++match &&
4408 *++scan == *++match && *++scan == *++match &&
4409 *++scan == *++match && *++scan == *++match &&
4412 Assert(scan <= s->window+(
unsigned)(s->window_size-1),
"wild scan");
4414 len = MAX_MATCH - (int)(strend - scan);
4416 if (len < MIN_MATCH)
return MIN_MATCH - 1;
4418 s->match_start = cur_match;
4419 return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
4426 local
void check_match(s, start, match, length)
4432 if (zmemcmp(s->window + match,
4433 s->window + start, length) != EQUAL) {
4434 fprintf(stderr,
" start %u, match %u, length %d\n",
4435 start, match, length);
4437 fprintf(stderr,
"%c%c", s->window[match++], s->window[start++]);
4438 }
while (--length != 0);
4439 z_error(
"invalid match");
4441 if (z_verbose > 1) {
4442 fprintf(stderr,
"\\[%d,%d]", start-match, length);
4443 do { putc(s->window[start++], stderr); }
while (--length != 0);
4447 # define check_match(s, start, match, length)
4460 local
void fill_window(s)
4463 register unsigned n, m;
4466 uInt wsize = s->w_size;
4469 more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
4472 if (
sizeof(
int) <= 2) {
4473 if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
4476 }
else if (more == (
unsigned)(-1)) {
4487 if (s->strstart >= wsize+MAX_DIST(s)) {
4489 zmemcpy(s->window, s->window+wsize, (
unsigned)wsize);
4490 s->match_start -= wsize;
4491 s->strstart -= wsize;
4492 s->block_start -= (long) wsize;
4505 *p = (Pos)(m >= wsize ? m-wsize : NIL);
4513 *p = (Pos)(m >= wsize ? m-wsize : NIL);
4521 if (s->strm->avail_in == 0)
return;
4534 Assert(more >= 2,
"more < 2");
4536 n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
4540 if (s->lookahead >= MIN_MATCH) {
4541 s->ins_h = s->window[s->strstart];
4542 UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
4544 Call UPDATE_HASH() MIN_MATCH-3 more times
4551 }
while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
4558 #define FLUSH_BLOCK_ONLY(s, eof) { \
4559 _tr_flush_block(s, (s->block_start >= 0L ? \
4560 (charf *)&s->window[(unsigned)s->block_start] : \
4562 (ulg)((long)s->strstart - s->block_start), \
4564 s->block_start = s->strstart; \
4565 flush_pending(s->strm); \
4566 Tracev((stderr,"[FLUSH]")); \
4570 #define FLUSH_BLOCK(s, eof) { \
4571 FLUSH_BLOCK_ONLY(s, eof); \
4572 if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
4584 local block_state deflate_stored(s, flush)
4591 ulg max_block_size = 0xffff;
4594 if (max_block_size > s->pending_buf_size - 5) {
4595 max_block_size = s->pending_buf_size - 5;
4601 if (s->lookahead <= 1) {
4603 Assert(s->strstart < s->w_size+MAX_DIST(s) ||
4604 s->block_start >= (
long)s->w_size,
"slide too late");
4607 if (s->lookahead == 0 && flush == Z_NO_FLUSH)
return need_more;
4609 if (s->lookahead == 0)
break;
4611 Assert(s->block_start >= 0L,
"block gone");
4613 s->strstart += s->lookahead;
4617 max_start = s->block_start + max_block_size;
4618 if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
4620 s->lookahead = (uInt)(s->strstart - max_start);
4621 s->strstart = (uInt)max_start;
4627 if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
4631 FLUSH_BLOCK(s, flush == Z_FINISH);
4632 return flush == Z_FINISH ? finish_done : block_done;
4642 local block_state deflate_fast(s, flush)
4646 IPos hash_head = NIL;
4655 if (s->lookahead < MIN_LOOKAHEAD) {
4657 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
4660 if (s->lookahead == 0)
break;
4666 if (s->lookahead >= MIN_MATCH) {
4667 INSERT_STRING(s, s->strstart, hash_head);
4673 if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
4679 if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) ||
4680 (s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
4681 s->match_length = longest_match_fast (s, hash_head);
4684 if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
4685 s->match_length = longest_match (s, hash_head);
4686 }
else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
4687 s->match_length = longest_match_fast (s, hash_head);
4692 if (s->match_length >= MIN_MATCH) {
4693 check_match(s, s->strstart, s->match_start, s->match_length);
4695 _tr_tally_dist(s, s->strstart - s->match_start,
4696 s->match_length - MIN_MATCH, bflush);
4698 s->lookahead -= s->match_length;
4704 if (s->match_length <= s->max_insert_length &&
4705 s->lookahead >= MIN_MATCH) {
4709 INSERT_STRING(s, s->strstart, hash_head);
4713 }
while (--s->match_length != 0);
4718 s->strstart += s->match_length;
4719 s->match_length = 0;
4720 s->ins_h = s->window[s->strstart];
4721 UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
4723 Call UPDATE_HASH() MIN_MATCH-3 more times
4731 Tracevv((stderr,
"%c", s->window[s->strstart]));
4732 _tr_tally_lit (s, s->window[s->strstart], bflush);
4736 if (bflush) FLUSH_BLOCK(s, 0);
4738 FLUSH_BLOCK(s, flush == Z_FINISH);
4739 return flush == Z_FINISH ? finish_done : block_done;
4748 local block_state deflate_slow(s, flush)
4752 IPos hash_head = NIL;
4762 if (s->lookahead < MIN_LOOKAHEAD) {
4764 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
4767 if (s->lookahead == 0)
break;
4773 if (s->lookahead >= MIN_MATCH) {
4774 INSERT_STRING(s, s->strstart, hash_head);
4779 s->prev_length = s->match_length, s->prev_match = s->match_start;
4780 s->match_length = MIN_MATCH-1;
4782 if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
4783 s->strstart - hash_head <= MAX_DIST(s)) {
4788 if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
4789 s->match_length = longest_match (s, hash_head);
4790 }
else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
4791 s->match_length = longest_match_fast (s, hash_head);
4795 if (s->match_length <= 5 && (s->strategy == Z_FILTERED
4796 #
if TOO_FAR <= 32767
4797 || (s->match_length == MIN_MATCH &&
4798 s->strstart - s->match_start > TOO_FAR)
4805 s->match_length = MIN_MATCH-1;
4811 if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
4812 uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
4815 check_match(s, s->strstart-1, s->prev_match, s->prev_length);
4817 _tr_tally_dist(s, s->strstart -1 - s->prev_match,
4818 s->prev_length - MIN_MATCH, bflush);
4825 s->lookahead -= s->prev_length-1;
4826 s->prev_length -= 2;
4828 if (++s->strstart <= max_insert) {
4829 INSERT_STRING(s, s->strstart, hash_head);
4831 }
while (--s->prev_length != 0);
4832 s->match_available = 0;
4833 s->match_length = MIN_MATCH-1;
4836 if (bflush) FLUSH_BLOCK(s, 0);
4838 }
else if (s->match_available) {
4843 Tracevv((stderr,
"%c", s->window[s->strstart-1]));
4844 _tr_tally_lit(s, s->window[s->strstart-1], bflush);
4846 FLUSH_BLOCK_ONLY(s, 0);
4850 if (s->strm->avail_out == 0)
return need_more;
4855 s->match_available = 1;
4860 Assert (flush != Z_NO_FLUSH,
"no flush?");
4861 if (s->match_available) {
4862 Tracevv((stderr,
"%c", s->window[s->strstart-1]));
4863 _tr_tally_lit(s, s->window[s->strstart-1], bflush);
4864 s->match_available = 0;
4866 FLUSH_BLOCK(s, flush == Z_FINISH);
4867 return flush == Z_FINISH ? finish_done : block_done;
4918 int inflate_table OF((codetype type,
unsigned short FAR *lens,
4919 unsigned codes, code FAR * FAR *table,
4920 unsigned FAR *bits,
unsigned short FAR *work));
4986 struct inflate_state {
4993 unsigned long check;
4994 unsigned long total;
5001 unsigned char FAR *window;
5011 code
const FAR *lencode;
5012 code
const FAR *distcode;
5021 unsigned short lens[320];
5022 unsigned short work[288];
5031 void inflate_fast OF((z_streamp strm,
unsigned start));
5117 const char inflate_copyright[] =
5118 " inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
5138 int inflate_table(type, lens, codes, table, bits, work)
5140 unsigned short FAR *lens;
5142 code FAR * FAR *table;
5144 unsigned short FAR *work;
5161 const unsigned short FAR *base;
5162 const unsigned short FAR *extra;
5164 unsigned short count[MAXBITS+1];
5165 unsigned short offs[MAXBITS+1];
5166 static const unsigned short lbase[31] = {
5167 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
5168 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
5169 static const unsigned short lext[31] = {
5170 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
5171 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
5172 static const unsigned short dbase[32] = {
5173 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
5174 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
5175 8193, 12289, 16385, 24577, 0, 0};
5176 static const unsigned short dext[32] = {
5177 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
5178 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
5179 28, 28, 29, 29, 64, 64};
5213 for (len = 0; len <= MAXBITS; len++)
5215 for (sym = 0; sym < codes; sym++)
5220 for (max = MAXBITS; max >= 1; max--)
5221 if (count[max] != 0)
break;
5222 if (root > max) root = max;
5224 this.op = (
unsigned char)64;
5225 this.bits = (
unsigned char)1;
5226 this.val = (
unsigned short)0;
5232 for (min = 1; min <= MAXBITS; min++)
5233 if (count[min] != 0)
break;
5234 if (root < min) root = min;
5238 for (len = 1; len <= MAXBITS; len++) {
5241 if (left < 0)
return -1;
5243 if (left > 0 && (type == CODES || max != 1))
5248 for (len = 1; len < MAXBITS; len++)
5249 offs[len + 1] = offs[len] + count[len];
5252 for (sym = 0; sym < codes; sym++)
5253 if (lens[sym] != 0) work[offs[lens[sym]]++] = (
unsigned short)sym;
5290 base = extra = work;
5313 low = (unsigned)(-1);
5318 if (type == LENS && used >= ENOUGH - MAXD)
5324 this.bits = (
unsigned char)(len - drop);
5325 if ((
int)(work[sym]) < end) {
5326 this.op = (
unsigned char)0;
5327 this.val = work[sym];
5329 else if ((
int)(work[sym]) > end) {
5330 this.op = (
unsigned char)(extra[work[sym]]);
5331 this.val = base[work[sym]];
5334 this.op = (
unsigned char)(32 + 64);
5339 incr = 1U << (len - drop);
5344 next[(huff >> drop) + fill] =
this;
5345 }
while (fill != 0);
5348 incr = 1U << (len - 1);
5360 if (--(count[len]) == 0) {
5361 if (len == max)
break;
5362 len = lens[work[sym]];
5366 if (len > root && (huff & mask) != low) {
5376 left = (int)(1 << curr);
5377 while (curr + drop < max) {
5378 left -= count[curr + drop];
5379 if (left <= 0)
break;
5386 if (type == LENS && used >= ENOUGH - MAXD)
5391 (*table)[low].op = (
unsigned char)curr;
5392 (*table)[low].bits = (
unsigned char)root;
5393 (*table)[low].val = (
unsigned short)(next - *table);
5404 this.op = (
unsigned char)64;
5405 this.bits = (
unsigned char)(len - drop);
5406 this.val = (
unsigned short)0;
5409 if (drop != 0 && (huff & mask) != low) {
5413 this.bits = (
unsigned char)len;
5417 next[huff >> drop] =
this;
5420 incr = 1U << (len - 1);
5452 # define PUP(a) *(a)++
5455 # define PUP(a) *++(a)
5493 void inflate_fast(strm, start)
5497 struct inflate_state FAR *state;
5498 unsigned char FAR *in;
5499 unsigned char FAR *last;
5500 unsigned char FAR *out;
5501 unsigned char FAR *beg;
5502 unsigned char FAR *end;
5503 #ifdef INFLATE_STRICT
5509 unsigned char FAR *window;
5512 code
const FAR *lcode;
5513 code
const FAR *dcode;
5521 unsigned char FAR *from;
5524 state = (
struct inflate_state FAR *)strm->state;
5525 in = strm->next_in - OFF;
5526 last = in + (strm->avail_in - 5);
5527 out = strm->next_out - OFF;
5528 beg = out - (start - strm->avail_out);
5529 end = out + (strm->avail_out - 257);
5530 #ifdef INFLATE_STRICT
5533 wsize = state->wsize;
5534 whave = state->whave;
5535 write = state->write;
5536 window = state->window;
5539 lcode = state->lencode;
5540 dcode = state->distcode;
5541 lmask = (1U << state->lenbits) - 1;
5542 dmask = (1U << state->distbits) - 1;
5548 hold += (
unsigned long)(PUP(in)) << bits;
5550 hold += (
unsigned long)(PUP(in)) << bits;
5553 this = lcode[hold & lmask];
5555 op = (unsigned)(this.bits);
5558 op = (unsigned)(this.op);
5560 Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
5561 "inflate: literal '%c'\n" :
5562 "inflate: literal 0x%02x\n", this.val));
5563 PUP(out) = (
unsigned char)(this.val);
5566 len = (unsigned)(this.val);
5570 hold += (
unsigned long)(PUP(in)) << bits;
5573 len += (unsigned)hold & ((1U << op) - 1);
5577 Tracevv((stderr,
"inflate: length %u\n", len));
5579 hold += (
unsigned long)(PUP(in)) << bits;
5581 hold += (
unsigned long)(PUP(in)) << bits;
5584 this = dcode[hold & dmask];
5586 op = (unsigned)(this.bits);
5589 op = (unsigned)(this.op);
5591 dist = (unsigned)(this.val);
5594 hold += (
unsigned long)(PUP(in)) << bits;
5597 hold += (
unsigned long)(PUP(in)) << bits;
5601 dist += (unsigned)hold & ((1U << op) - 1);
5602 #ifdef INFLATE_STRICT
5604 strm->msg = (
char *)
"invalid distance too far back";
5611 Tracevv((stderr,
"inflate: distance %u\n", dist));
5612 op = (unsigned)(out - beg);
5616 strm->msg = (
char *)
"invalid distance too far back";
5620 from = window - OFF;
5626 PUP(out) = PUP(from);
5631 else if (write < op) {
5632 from += wsize + write - op;
5637 PUP(out) = PUP(from);
5639 from = window - OFF;
5644 PUP(out) = PUP(from);
5655 PUP(out) = PUP(from);
5661 PUP(out) = PUP(from);
5662 PUP(out) = PUP(from);
5663 PUP(out) = PUP(from);
5667 PUP(out) = PUP(from);
5669 PUP(out) = PUP(from);
5675 PUP(out) = PUP(from);
5676 PUP(out) = PUP(from);
5677 PUP(out) = PUP(from);
5681 PUP(out) = PUP(from);
5683 PUP(out) = PUP(from);
5687 else if ((op & 64) == 0) {
5688 this = dcode[this.val + (hold & ((1U << op) - 1))];
5692 strm->msg = (
char *)
"invalid distance code";
5697 else if ((op & 64) == 0) {
5698 this = lcode[this.val + (hold & ((1U << op) - 1))];
5702 Tracevv((stderr,
"inflate: end of block\n"));
5707 strm->msg = (
char *)
"invalid literal/length code";
5711 }
while (in < last && out < end);
5717 hold &= (1U << bits) - 1;
5720 strm->next_in = in + OFF;
5721 strm->next_out = out + OFF;
5722 strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
5723 strm->avail_out = (unsigned)(out < end ?
5724 257 + (end - out) : 257 - (out - end));
5747 local
void fixedtables OF((
struct inflate_state FAR *state));
5748 local
int updatewindow OF((z_streamp strm,
unsigned out));
5749 local
unsigned syncsearch OF((
unsigned FAR *have,
unsigned char FAR *buf,
5752 int inflateReset(strm)
5755 struct inflate_state FAR *state;
5757 if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
5758 state = (
struct inflate_state FAR *)strm->state;
5759 strm->total_in = strm->total_out = state->total = 0;
5764 state->havedict = 0;
5765 state->dmax = 32768U;
5766 state->head = Z_NULL;
5772 state->lencode = state->distcode = state->next = state->codes;
5773 Tracev((stderr,
"inflate: reset\n"));
5777 int inflatePrime(strm, bits, value)
5782 struct inflate_state FAR *state;
5784 if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
5785 state = (
struct inflate_state FAR *)strm->state;
5786 if (bits > 16 || state->bits + bits > 32)
return Z_STREAM_ERROR;
5787 value &= (1L << bits) - 1;
5788 state->hold += value << state->bits;
5789 state->bits += bits;
5793 int inflateInit2_(strm, windowBits, version, stream_size)
5796 const
char *version;
5799 struct inflate_state FAR *state;
5801 if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
5802 stream_size != (
int)(
sizeof(z_stream)))
5803 return Z_VERSION_ERROR;
5804 if (strm == Z_NULL)
return Z_STREAM_ERROR;
5806 if (strm->zalloc == (alloc_func)0) {
5807 strm->zalloc = zcalloc;
5808 strm->opaque = (voidpf)0;
5810 if (strm->zfree == (free_func)0) strm->zfree = zcfree;
5811 state = (
struct inflate_state FAR *)
5812 ZALLOC(strm, 1,
sizeof(
struct inflate_state));
5813 if (state == Z_NULL)
return Z_MEM_ERROR;
5814 Tracev((stderr,
"inflate: allocated\n"));
5815 strm->state = (
struct internal_state FAR *)state;
5816 if (windowBits < 0) {
5818 windowBits = -windowBits;
5821 state->wrap = (windowBits >> 4) + 1;
5823 if (windowBits < 48) windowBits &= 15;
5826 if (windowBits < 8 || windowBits > 15) {
5828 strm->state = Z_NULL;
5829 return Z_STREAM_ERROR;
5831 state->wbits = (unsigned)windowBits;
5832 state->window = Z_NULL;
5833 return inflateReset(strm);
5836 int inflateInit_(strm, version, stream_size)
5838 const
char *version;
5841 return inflateInit2_(strm, DEF_WBITS, version, stream_size);
5848 local
void fixedtables(state)
5849 struct inflate_state FAR *state;
5851 static const code lenfix[512] = {
5852 {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
5853 {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
5854 {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
5855 {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
5856 {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
5857 {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
5858 {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
5859 {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
5860 {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
5861 {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
5862 {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
5863 {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
5864 {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
5865 {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
5866 {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
5867 {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
5868 {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
5869 {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
5870 {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
5871 {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
5872 {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
5873 {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
5874 {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
5875 {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
5876 {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
5877 {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
5878 {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
5879 {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
5880 {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
5881 {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
5882 {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
5883 {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
5884 {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
5885 {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
5886 {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
5887 {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
5888 {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
5889 {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
5890 {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
5891 {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
5892 {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
5893 {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
5894 {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
5895 {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
5896 {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
5897 {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
5898 {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
5899 {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
5900 {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
5901 {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
5902 {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
5903 {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
5904 {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
5905 {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
5906 {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
5907 {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
5908 {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
5909 {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
5910 {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
5911 {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
5912 {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
5913 {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
5914 {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
5915 {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
5916 {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
5917 {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
5918 {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
5919 {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
5920 {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
5921 {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
5922 {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
5923 {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
5924 {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
5928 static const code distfix[32] = {
5929 {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
5930 {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
5931 {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
5932 {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
5933 {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
5936 state->lencode = lenfix;
5938 state->distcode = distfix;
5939 state->distbits = 5;
5957 local
int updatewindow(strm, out)
5961 struct inflate_state FAR *state;
5962 unsigned copy, dist;
5964 state = (
struct inflate_state FAR *)strm->state;
5967 if (state->window == Z_NULL) {
5968 state->window = (
unsigned char FAR *)
5969 ZALLOC(strm, 1U << state->wbits,
5970 sizeof(
unsigned char));
5971 if (state->window == Z_NULL)
return 1;
5975 if (state->wsize == 0) {
5976 state->wsize = 1U << state->wbits;
5982 copy = out - strm->avail_out;
5983 if (copy >= state->wsize) {
5984 zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
5986 state->whave = state->wsize;
5989 dist = state->wsize - state->write;
5990 if (dist > copy) dist = copy;
5991 zmemcpy(state->window + state->write, strm->next_out - copy, dist);
5994 zmemcpy(state->window, strm->next_out - copy, copy);
5995 state->write = copy;
5996 state->whave = state->wsize;
5999 state->write += dist;
6000 if (state->write == state->wsize) state->write = 0;
6001 if (state->whave < state->wsize) state->whave += dist;
6011 # define UPDATE(check, buf, len) \
6012 (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
6014 # define UPDATE(check, buf, len) adler32(check, buf, len)
6019 # define CRC2(check, word) \
6021 hbuf[0] = (unsigned char)(word); \
6022 hbuf[1] = (unsigned char)((word) >> 8); \
6023 check = crc32(check, hbuf, 2); \
6026 # define CRC4(check, word) \
6028 hbuf[0] = (unsigned char)(word); \
6029 hbuf[1] = (unsigned char)((word) >> 8); \
6030 hbuf[2] = (unsigned char)((word) >> 16); \
6031 hbuf[3] = (unsigned char)((word) >> 24); \
6032 check = crc32(check, hbuf, 4); \
6039 put = strm->next_out; \
6040 left = strm->avail_out; \
6041 next = strm->next_in; \
6042 have = strm->avail_in; \
6043 hold = state->hold; \
6044 bits = state->bits; \
6050 strm->next_out = put; \
6051 strm->avail_out = left; \
6052 strm->next_in = next; \
6053 strm->avail_in = have; \
6054 state->hold = hold; \
6055 state->bits = bits; \
6059 #define INITBITS() \
6067 #define PULLBYTE() \
6069 if (have == 0) goto inf_leave; \
6071 hold += (unsigned long)(*next++) << bits; \
6077 #define NEEDBITS(n) \
6079 while (bits < (unsigned)(n)) \
6085 ((unsigned)hold & ((1U << (n)) - 1))
6088 #define DROPBITS(n) \
6091 bits -= (unsigned)(n); \
6095 #define BYTEBITS() \
6097 hold >>= bits & 7; \
6102 #define REVERSE(q) \
6103 ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
6104 (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
6188 int inflate(strm, flush)
6192 struct inflate_state FAR *state;
6193 unsigned char FAR *next;
6194 unsigned char FAR *put;
6195 unsigned have, left;
6200 unsigned char FAR *from;
6206 unsigned char hbuf[4];
6208 static const unsigned short order[19] =
6209 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
6211 if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
6212 (strm->next_in == Z_NULL && strm->avail_in != 0))
6213 return Z_STREAM_ERROR;
6215 state = (
struct inflate_state FAR *)strm->state;
6216 if (state->mode == TYPE) state->mode = TYPEDO;
6222 switch (state->mode) {
6224 if (state->wrap == 0) {
6225 state->mode = TYPEDO;
6230 if ((state->wrap & 2) && hold == 0x8b1f) {
6231 state->check = crc32(0L, Z_NULL, 0);
6232 CRC2(state->check, hold);
6234 state->mode = FLAGS;
6238 if (state->head != Z_NULL)
6239 state->head->done = -1;
6240 if (!(state->wrap & 1) ||
6244 ((BITS(8) << 8) + (hold >> 8)) % 31) {
6245 strm->msg = (
char *)
"incorrect header check";
6249 if (BITS(4) != Z_DEFLATED) {
6250 strm->msg = (
char *)
"unknown compression method";
6256 if (len > state->wbits) {
6257 strm->msg = (
char *)
"invalid window size";
6261 state->dmax = 1U << len;
6262 Tracev((stderr,
"inflate: zlib header ok\n"));
6263 strm->adler = state->check = adler32(0L, Z_NULL, 0);
6264 state->mode = hold & 0x200 ? DICTID : TYPE;
6270 state->flags = (int)(hold);
6271 if ((state->flags & 0xff) != Z_DEFLATED) {
6272 strm->msg = (
char *)
"unknown compression method";
6276 if (state->flags & 0xe000) {
6277 strm->msg = (
char *)
"unknown header flags set";
6281 if (state->head != Z_NULL)
6282 state->head->text = (int)((hold >> 8) & 1);
6283 if (state->flags & 0x0200) CRC2(state->check, hold);
6288 if (state->head != Z_NULL)
6289 state->head->time = hold;
6290 if (state->flags & 0x0200) CRC4(state->check, hold);
6295 if (state->head != Z_NULL) {
6296 state->head->xflags = (int)(hold & 0xff);
6297 state->head->os = (int)(hold >> 8);
6299 if (state->flags & 0x0200) CRC2(state->check, hold);
6301 state->mode = EXLEN;
6303 if (state->flags & 0x0400) {
6305 state->length = (unsigned)(hold);
6306 if (state->head != Z_NULL)
6307 state->head->extra_len = (unsigned)hold;
6308 if (state->flags & 0x0200) CRC2(state->check, hold);
6311 else if (state->head != Z_NULL)
6312 state->head->extra = Z_NULL;
6313 state->mode = EXTRA;
6315 if (state->flags & 0x0400) {
6316 copy = state->length;
6317 if (copy > have) copy = have;
6319 if (state->head != Z_NULL &&
6320 state->head->extra != Z_NULL) {
6321 len = state->head->extra_len - state->length;
6322 zmemcpy(state->head->extra + len, next,
6323 len + copy > state->head->extra_max ?
6324 state->head->extra_max - len : copy);
6326 if (state->flags & 0x0200)
6327 state->check = crc32(state->check, next, copy);
6330 state->length -= copy;
6332 if (state->length)
goto inf_leave;
6337 if (state->flags & 0x0800) {
6338 if (have == 0)
goto inf_leave;
6341 len = (unsigned)(next[copy++]);
6342 if (state->head != Z_NULL &&
6343 state->head->name != Z_NULL &&
6344 state->length < state->head->name_max)
6345 state->head->name[state->length++] = len;
6346 }
while (len && copy < have);
6347 if (state->flags & 0x0200)
6348 state->check = crc32(state->check, next, copy);
6351 if (len)
goto inf_leave;
6353 else if (state->head != Z_NULL)
6354 state->head->name = Z_NULL;
6356 state->mode = COMMENT;
6358 if (state->flags & 0x1000) {
6359 if (have == 0)
goto inf_leave;
6362 len = (unsigned)(next[copy++]);
6363 if (state->head != Z_NULL &&
6364 state->head->comment != Z_NULL &&
6365 state->length < state->head->comm_max)
6366 state->head->comment[state->length++] = len;
6367 }
while (len && copy < have);
6368 if (state->flags & 0x0200)
6369 state->check = crc32(state->check, next, copy);
6372 if (len)
goto inf_leave;
6374 else if (state->head != Z_NULL)
6375 state->head->comment = Z_NULL;
6378 if (state->flags & 0x0200) {
6380 if (hold != (state->check & 0xffff)) {
6381 strm->msg = (
char *)
"header crc mismatch";
6387 if (state->head != Z_NULL) {
6388 state->head->hcrc = (int)((state->flags >> 9) & 1);
6389 state->head->done = 1;
6391 strm->adler = state->check = crc32(0L, Z_NULL, 0);
6397 strm->adler = state->check = REVERSE(hold);
6401 if (state->havedict == 0) {
6405 strm->adler = state->check = adler32(0L, Z_NULL, 0);
6408 if (flush == Z_BLOCK)
goto inf_leave;
6412 state->mode = CHECK;
6416 state->last = BITS(1);
6420 Tracev((stderr,
"inflate: stored block%s\n",
6421 state->last ?
" (last)" :
""));
6422 state->mode = STORED;
6426 Tracev((stderr,
"inflate: fixed codes block%s\n",
6427 state->last ?
" (last)" :
""));
6431 Tracev((stderr,
"inflate: dynamic codes block%s\n",
6432 state->last ?
" (last)" :
""));
6433 state->mode = TABLE;
6436 strm->msg = (
char *)
"invalid block type";
6444 if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
6445 strm->msg = (
char *)
"invalid stored block lengths";
6449 state->length = (unsigned)hold & 0xffff;
6450 Tracev((stderr,
"inflate: stored length %u\n",
6455 copy = state->length;
6457 if (copy > have) copy = have;
6458 if (copy > left) copy = left;
6459 if (copy == 0)
goto inf_leave;
6460 zmemcpy(put, next, copy);
6465 state->length -= copy;
6468 Tracev((stderr,
"inflate: stored end\n"));
6473 state->nlen = BITS(5) + 257;
6475 state->ndist = BITS(5) + 1;
6477 state->ncode = BITS(4) + 4;
6479 #ifndef PKZIP_BUG_WORKAROUND
6480 if (state->nlen > 286 || state->ndist > 30) {
6481 strm->msg = (
char *)
"too many length or distance symbols";
6486 Tracev((stderr,
"inflate: table sizes ok\n"));
6488 state->mode = LENLENS;
6490 while (state->have < state->ncode) {
6492 state->lens[order[state->have++]] = (
unsigned short)BITS(3);
6495 while (state->have < 19)
6496 state->lens[order[state->have++]] = 0;
6497 state->next = state->codes;
6498 state->lencode = (code
const FAR *)(state->next);
6500 ret = inflate_table(CODES, state->lens, 19, &(state->next),
6501 &(state->lenbits), state->work);
6503 strm->msg = (
char *)
"invalid code lengths set";
6507 Tracev((stderr,
"inflate: code lengths ok\n"));
6509 state->mode = CODELENS;
6511 while (state->have < state->nlen + state->ndist) {
6513 this = state->lencode[BITS(state->lenbits)];
6514 if ((
unsigned)(this.bits) <= bits)
break;
6517 if (this.val < 16) {
6518 NEEDBITS(this.bits);
6519 DROPBITS(this.bits);
6520 state->lens[state->have++] = this.val;
6523 if (this.val == 16) {
6524 NEEDBITS(this.bits + 2);
6525 DROPBITS(this.bits);
6526 if (state->have == 0) {
6527 strm->msg = (
char *)
"invalid bit length repeat";
6531 len = state->lens[state->have - 1];
6535 else if (this.val == 17) {
6536 NEEDBITS(this.bits + 3);
6537 DROPBITS(this.bits);
6543 NEEDBITS(this.bits + 7);
6544 DROPBITS(this.bits);
6546 copy = 11 + BITS(7);
6549 if (state->have + copy > state->nlen + state->ndist) {
6550 strm->msg = (
char *)
"invalid bit length repeat";
6555 state->lens[state->have++] = (
unsigned short)len;
6560 if (state->mode == BAD)
break;
6563 state->next = state->codes;
6564 state->lencode = (code
const FAR *)(state->next);
6566 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
6567 &(state->lenbits), state->work);
6569 strm->msg = (
char *)
"invalid literal/lengths set";
6573 state->distcode = (code
const FAR *)(state->next);
6574 state->distbits = 6;
6575 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
6576 &(state->next), &(state->distbits), state->work);
6578 strm->msg = (
char *)
"invalid distances set";
6582 Tracev((stderr,
"inflate: codes ok\n"));
6585 if (have >= 6 && left >= 258) {
6587 inflate_fast(strm, out);
6592 this = state->lencode[BITS(state->lenbits)];
6593 if ((
unsigned)(this.bits) <= bits)
break;
6596 if (this.op && (this.op & 0xf0) == 0) {
6599 this = state->lencode[last.val +
6600 (BITS(last.bits + last.op) >> last.bits)];
6601 if ((
unsigned)(last.bits + this.bits) <= bits)
break;
6604 DROPBITS(last.bits);
6606 DROPBITS(this.bits);
6607 state->length = (unsigned)this.val;
6608 if ((
int)(this.op) == 0) {
6609 Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
6610 "inflate: literal '%c'\n" :
6611 "inflate: literal 0x%02x\n", this.val));
6616 Tracevv((stderr,
"inflate: end of block\n"));
6621 strm->msg = (
char *)
"invalid literal/length code";
6625 state->extra = (unsigned)(this.op) & 15;
6626 state->mode = LENEXT;
6629 NEEDBITS(state->extra);
6630 state->length += BITS(state->extra);
6631 DROPBITS(state->extra);
6633 Tracevv((stderr,
"inflate: length %u\n", state->length));
6637 this = state->distcode[BITS(state->distbits)];
6638 if ((
unsigned)(this.bits) <= bits)
break;
6641 if ((this.op & 0xf0) == 0) {
6644 this = state->distcode[last.val +
6645 (BITS(last.bits + last.op) >> last.bits)];
6646 if ((
unsigned)(last.bits + this.bits) <= bits)
break;
6649 DROPBITS(last.bits);
6651 DROPBITS(this.bits);
6653 strm->msg = (
char *)
"invalid distance code";
6657 state->offset = (unsigned)this.val;
6658 state->extra = (unsigned)(this.op) & 15;
6659 state->mode = DISTEXT;
6662 NEEDBITS(state->extra);
6663 state->offset += BITS(state->extra);
6664 DROPBITS(state->extra);
6666 #ifdef INFLATE_STRICT
6667 if (state->offset > state->dmax) {
6668 strm->msg = (
char *)
"invalid distance too far back";
6673 if (state->offset > state->whave + out - left) {
6674 strm->msg = (
char *)
"invalid distance too far back";
6678 Tracevv((stderr,
"inflate: distance %u\n", state->offset));
6679 state->mode = MATCH;
6681 if (left == 0)
goto inf_leave;
6683 if (state->offset > copy) {
6684 copy = state->offset - copy;
6685 if (copy > state->write) {
6686 copy -= state->write;
6687 from = state->window + (state->wsize - copy);
6690 from = state->window + (state->write - copy);
6691 if (copy > state->length) copy = state->length;
6694 from = put - state->offset;
6695 copy = state->length;
6697 if (copy > left) copy = left;
6699 state->length -= copy;
6703 if (state->length == 0) state->mode = LEN;
6706 if (left == 0)
goto inf_leave;
6707 *put++ = (
unsigned char)(state->length);
6715 strm->total_out += out;
6716 state->total += out;
6718 strm->adler = state->check =
6719 UPDATE(state->check, put - out, out);
6723 state->flags ? hold :
6725 REVERSE(hold)) != state->check) {
6726 strm->msg = (
char *)
"incorrect data check";
6731 Tracev((stderr,
"inflate: check matches trailer\n"));
6734 state->mode = LENGTH;
6736 if (state->wrap && state->flags) {
6738 if (hold != (state->total & 0xffffffffUL)) {
6739 strm->msg = (
char *)
"incorrect length check";
6744 Tracev((stderr,
"inflate: length matches trailer\n"));
6758 return Z_STREAM_ERROR;
6769 if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
6770 if (updatewindow(strm, out)) {
6774 in -= strm->avail_in;
6775 out -= strm->avail_out;
6776 strm->total_in += in;
6777 strm->total_out += out;
6778 state->total += out;
6779 if (state->wrap && out)
6780 strm->adler = state->check =
6781 UPDATE(state->check, strm->next_out - out, out);
6782 strm->data_type = state->bits + (state->last ? 64 : 0) +
6783 (state->mode == TYPE ? 128 : 0);
6784 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
6789 int inflateEnd(strm)
6792 struct inflate_state FAR *state;
6793 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
6794 return Z_STREAM_ERROR;
6795 state = (
struct inflate_state FAR *)strm->state;
6796 if (state->window != Z_NULL) ZFREE(strm, state->window);
6797 ZFREE(strm, strm->state);
6798 strm->state = Z_NULL;
6799 Tracev((stderr,
"inflate: end\n"));
6803 int inflateSetDictionary(strm, dictionary, dictLength)
6805 const Bytef *dictionary;
6808 struct inflate_state FAR *state;
6812 if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
6813 state = (
struct inflate_state FAR *)strm->state;
6814 if (state->wrap != 0 && state->mode != DICT)
6815 return Z_STREAM_ERROR;
6818 if (state->mode == DICT) {
6819 id = adler32(0L, Z_NULL, 0);
6820 id = adler32(
id, dictionary, dictLength);
6821 if (
id != state->check)
6822 return Z_DATA_ERROR;
6826 if (updatewindow(strm, strm->avail_out)) {
6830 if (dictLength > state->wsize) {
6831 zmemcpy(state->window, dictionary + dictLength - state->wsize,
6833 state->whave = state->wsize;
6836 zmemcpy(state->window + state->wsize - dictLength, dictionary,
6838 state->whave = dictLength;
6840 state->havedict = 1;
6841 Tracev((stderr,
"inflate: dictionary set\n"));
6845 int inflateGetHeader(strm, head)
6849 struct inflate_state FAR *state;
6852 if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
6853 state = (
struct inflate_state FAR *)strm->state;
6854 if ((state->wrap & 2) == 0)
return Z_STREAM_ERROR;
6873 local
unsigned syncsearch(have, buf, len)
6875 unsigned char FAR *buf;
6883 while (next < len && got < 4) {
6884 if ((
int)(buf[next]) == (got < 2 ? 0 : 0xff))
6896 int inflateSync(strm)
6900 unsigned long in, out;
6901 unsigned char buf[4];
6902 struct inflate_state FAR *state;
6905 if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
6906 state = (
struct inflate_state FAR *)strm->state;
6907 if (strm->avail_in == 0 && state->bits < 8)
return Z_BUF_ERROR;
6910 if (state->mode != SYNC) {
6912 state->hold <<= state->bits & 7;
6913 state->bits -= state->bits & 7;
6915 while (state->bits >= 8) {
6916 buf[len++] = (
unsigned char)(state->hold);
6921 syncsearch(&(state->have), buf, len);
6925 len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
6926 strm->avail_in -= len;
6927 strm->next_in += len;
6928 strm->total_in += len;
6931 if (state->have != 4)
return Z_DATA_ERROR;
6932 in = strm->total_in; out = strm->total_out;
6934 strm->total_in = in; strm->total_out = out;
6947 int inflateSyncPoint(strm)
6950 struct inflate_state FAR *state;
6952 if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR;
6953 state = (
struct inflate_state FAR *)strm->state;
6954 return state->mode == STORED && state->bits == 0;
6957 int inflateCopy(dest, source)
6961 struct inflate_state FAR *state;
6962 struct inflate_state FAR *copy;
6963 unsigned char FAR *window;
6967 if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
6968 source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
6969 return Z_STREAM_ERROR;
6970 state = (
struct inflate_state FAR *)source->state;
6973 copy = (
struct inflate_state FAR *)
6974 ZALLOC(source, 1,
sizeof(
struct inflate_state));
6975 if (copy == Z_NULL)
return Z_MEM_ERROR;
6977 if (state->window != Z_NULL) {
6978 window = (
unsigned char FAR *)
6979 ZALLOC(source, 1U << state->wbits,
sizeof(
unsigned char));
6980 if (window == Z_NULL) {
6981 ZFREE(source, copy);
6987 zmemcpy(dest, source,
sizeof(z_stream));
6988 zmemcpy(copy, state,
sizeof(
struct inflate_state));
6989 if (state->lencode >= state->codes &&
6990 state->lencode <= state->codes + ENOUGH - 1) {
6991 copy->lencode = copy->codes + (state->lencode - state->codes);
6992 copy->distcode = copy->codes + (state->distcode - state->codes);
6994 copy->next = copy->codes + (state->next - state->codes);
6995 if (window != Z_NULL) {
6996 wsize = 1U << state->wbits;
6997 zmemcpy(window, state->window, wsize);
6999 copy->window = window;
7000 dest->state = (
struct internal_state FAR *)copy;
7015 #define local static
7020 # include <limits.h>
7022 # if (UINT_MAX == 0xffffffffUL)
7023 typedef unsigned int u4;
7025 # if (ULONG_MAX == 0xffffffffUL)
7026 typedef unsigned long u4;
7028 # if (USHRT_MAX == 0xffffffffUL)
7029 typedef unsigned short u4;
7040 # define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
7041 (((w)&0xff00)<<8)+(((w)&0xff)<<24))
7042 local
unsigned long crc32_little OF((
unsigned long,
7043 const unsigned char FAR *,
unsigned));
7044 local
unsigned long crc32_big OF((
unsigned long,
7045 const unsigned char FAR *,
unsigned));
7052 local
unsigned long gf2_matrix_times OF((
unsigned long *mat,
7053 unsigned long vec));
7054 local
void gf2_matrix_square OF((
unsigned long *square,
unsigned long *mat));
7063 local
const unsigned long FAR crc_table[TBLS][256] =
7066 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
7067 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
7068 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
7069 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
7070 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
7071 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
7072 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
7073 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
7074 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
7075 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
7076 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
7077 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
7078 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
7079 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
7080 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
7081 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
7082 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
7083 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
7084 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
7085 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
7086 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
7087 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
7088 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
7089 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
7090 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
7091 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
7092 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
7093 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
7094 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
7095 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
7096 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
7097 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
7098 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
7099 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
7100 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
7101 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
7102 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
7103 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
7104 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
7105 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
7106 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
7107 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
7108 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
7109 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
7110 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
7111 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
7112 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
7113 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
7114 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
7115 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
7116 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
7121 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
7122 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
7123 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
7124 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
7125 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
7126 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
7127 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
7128 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
7129 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
7130 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
7131 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
7132 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
7133 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
7134 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
7135 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
7136 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
7137 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
7138 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
7139 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
7140 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
7141 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
7142 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
7143 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
7144 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
7145 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
7146 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
7147 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
7148 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
7149 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
7150 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
7151 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
7152 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
7153 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
7154 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
7155 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
7156 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
7157 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
7158 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
7159 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
7160 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
7161 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
7162 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
7163 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
7164 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
7165 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
7166 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
7167 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
7168 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
7169 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
7170 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
7171 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
7175 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
7176 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
7177 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
7178 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
7179 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
7180 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
7181 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
7182 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
7183 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
7184 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
7185 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
7186 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
7187 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
7188 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
7189 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
7190 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
7191 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
7192 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
7193 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
7194 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
7195 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
7196 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
7197 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
7198 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
7199 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
7200 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
7201 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
7202 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
7203 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
7204 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
7205 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
7206 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
7207 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
7208 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
7209 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
7210 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
7211 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
7212 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
7213 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
7214 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
7215 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
7216 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
7217 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
7218 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
7219 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
7220 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
7221 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
7222 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
7223 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
7224 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
7225 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
7229 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
7230 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
7231 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
7232 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
7233 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
7234 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
7235 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
7236 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
7237 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
7238 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
7239 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
7240 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
7241 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
7242 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
7243 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
7244 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
7245 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
7246 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
7247 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
7248 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
7249 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
7250 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
7251 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
7252 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
7253 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
7254 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
7255 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
7256 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
7257 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
7258 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
7259 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
7260 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
7261 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
7262 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
7263 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
7264 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
7265 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
7266 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
7267 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
7268 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
7269 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
7270 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
7271 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
7272 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
7273 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
7274 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
7275 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
7276 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
7277 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
7278 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
7279 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
7283 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
7284 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
7285 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
7286 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
7287 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
7288 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
7289 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
7290 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
7291 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
7292 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
7293 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
7294 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
7295 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
7296 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
7297 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
7298 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
7299 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
7300 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
7301 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
7302 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
7303 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
7304 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
7305 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
7306 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
7307 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
7308 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
7309 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
7310 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
7311 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
7312 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
7313 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
7314 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
7315 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
7316 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
7317 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
7318 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
7319 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
7320 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
7321 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
7322 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
7323 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
7324 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
7325 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
7326 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
7327 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
7328 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
7329 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
7330 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
7331 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
7332 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
7333 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
7337 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
7338 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
7339 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
7340 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
7341 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
7342 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
7343 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
7344 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
7345 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
7346 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
7347 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
7348 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
7349 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
7350 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
7351 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
7352 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
7353 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
7354 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
7355 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
7356 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
7357 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
7358 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
7359 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
7360 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
7361 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
7362 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
7363 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
7364 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
7365 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
7366 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
7367 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
7368 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
7369 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
7370 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
7371 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
7372 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
7373 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
7374 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
7375 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
7376 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
7377 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
7378 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
7379 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
7380 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
7381 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
7382 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
7383 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
7384 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
7385 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
7386 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
7387 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
7391 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
7392 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
7393 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
7394 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
7395 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
7396 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
7397 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
7398 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
7399 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
7400 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
7401 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
7402 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
7403 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
7404 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
7405 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
7406 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
7407 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
7408 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
7409 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
7410 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
7411 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
7412 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
7413 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
7414 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
7415 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
7416 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
7417 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
7418 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
7419 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
7420 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
7421 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
7422 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
7423 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
7424 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
7425 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
7426 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
7427 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
7428 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
7429 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
7430 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
7431 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
7432 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
7433 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
7434 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
7435 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
7436 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
7437 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
7438 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
7439 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
7440 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
7441 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
7445 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
7446 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
7447 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
7448 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
7449 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
7450 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
7451 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
7452 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
7453 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
7454 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
7455 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
7456 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
7457 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
7458 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
7459 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
7460 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
7461 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
7462 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
7463 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
7464 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
7465 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
7466 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
7467 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
7468 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
7469 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
7470 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
7471 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
7472 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
7473 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
7474 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
7475 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
7476 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
7477 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
7478 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
7479 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
7480 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
7481 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
7482 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
7483 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
7484 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
7485 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
7486 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
7487 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
7488 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
7489 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
7490 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
7491 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
7492 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
7493 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
7494 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
7495 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
7504 const unsigned long FAR * get_crc_table()
7506 return (
const unsigned long FAR *)crc_table;
7510 #define CRC_DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
7511 #define CRC_DO8 CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1
7514 unsigned long crc32(crc, buf, len)
7516 const
unsigned char FAR *buf;
7519 if (buf == Z_NULL)
return 0UL;
7522 if (
sizeof(
void *) ==
sizeof(ptrdiff_t)) {
7526 if (*((
unsigned char *)(&endian)))
7527 return crc32_little(crc, buf, len);
7529 return crc32_big(crc, buf, len);
7532 crc = crc ^ 0xffffffffUL;
7540 return crc ^ 0xffffffffUL;
7546 #define DOLIT4 c ^= *buf4++; \
7547 c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
7548 crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
7549 #define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
7552 local
unsigned long crc32_little(crc, buf, len)
7554 const
unsigned char FAR *buf;
7558 register const u4 FAR *buf4;
7562 while (len && ((ptrdiff_t)buf & 3)) {
7563 c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
7567 buf4 = (
const u4 FAR *)(
const void FAR *)buf;
7576 buf = (
const unsigned char FAR *)buf4;
7579 c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
7582 return (
unsigned long)c;
7586 #define DOBIG4 c ^= *++buf4; \
7587 c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
7588 crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
7589 #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
7592 local
unsigned long crc32_big(crc, buf, len)
7594 const
unsigned char FAR *buf;
7598 register const u4 FAR *buf4;
7602 while (len && ((ptrdiff_t)buf & 3)) {
7603 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
7607 buf4 = (
const u4 FAR *)(
const void FAR *)buf;
7618 buf = (
const unsigned char FAR *)buf4;
7621 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
7624 return (
unsigned long)(REV(c));
7632 local
unsigned long gf2_matrix_times(mat, vec)
7649 local
void gf2_matrix_square(square, mat)
7650 unsigned
long *square;
7655 for (n = 0; n < GF2_DIM; n++)
7656 square[n] = gf2_matrix_times(mat, mat[n]);
7660 uLong crc32_combine(crc1, crc2, len2)
7667 unsigned long even[GF2_DIM];
7668 unsigned long odd[GF2_DIM];
7675 odd[0] = 0xedb88320L;
7677 for (n = 1; n < GF2_DIM; n++) {
7683 gf2_matrix_square(even, odd);
7686 gf2_matrix_square(odd, even);
7692 gf2_matrix_square(even, odd);
7694 crc1 = gf2_matrix_times(even, crc1);
7702 gf2_matrix_square(odd, even);
7704 crc1 = gf2_matrix_times(odd, crc1);
7708 }
while (len2 != 0);
7726 int compress2 (dest, destLen, source, sourceLen, level)
7729 const Bytef *source;
7736 stream.next_in = (Bytef*)source;
7737 stream.avail_in = (uInt)sourceLen;
7740 if ((uLong)stream.avail_in != sourceLen)
return Z_BUF_ERROR;
7742 stream.next_out = dest;
7743 stream.avail_out = (uInt)*destLen;
7744 if ((uLong)stream.avail_out != *destLen)
return Z_BUF_ERROR;
7746 stream.zalloc = (alloc_func)0;
7747 stream.zfree = (free_func)0;
7748 stream.opaque = (voidpf)0;
7750 err = deflateInit(&stream, level);
7751 if (err != Z_OK)
return err;
7753 err = deflate(&stream, Z_FINISH);
7754 if (err != Z_STREAM_END) {
7755 deflateEnd(&stream);
7756 return err == Z_OK ? Z_BUF_ERROR : err;
7758 *destLen = stream.total_out;
7760 err = deflateEnd(&stream);
7766 int compress (dest, destLen, source, sourceLen)
7769 const Bytef *source;
7772 return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
7779 uLong compressBound (sourceLen)
7782 return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
7800 int uncompress (dest, destLen, source, sourceLen)
7803 const Bytef *source;
7809 stream.next_in = (Bytef*)source;
7810 stream.avail_in = (uInt)sourceLen;
7812 if ((uLong)stream.avail_in != sourceLen)
return Z_BUF_ERROR;
7814 stream.next_out = dest;
7815 stream.avail_out = (uInt)*destLen;
7816 if ((uLong)stream.avail_out != *destLen)
return Z_BUF_ERROR;
7818 stream.zalloc = (alloc_func)0;
7819 stream.zfree = (free_func)0;
7821 err = inflateInit(&stream);
7822 if (err != Z_OK)
return err;
7824 err = inflate(&stream, Z_FINISH);
7825 if (err != Z_STREAM_END) {
7826 inflateEnd(&stream);
7827 if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
7828 return Z_DATA_ERROR;
7831 *destLen = stream.total_out;
7833 err = inflateEnd(&stream);
7837 #define BASE 65521UL
7841 #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
7842 #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
7843 #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
7844 #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
7845 #define DO16(buf) DO8(buf,0); DO8(buf,8);
7851 if (a >= (BASE << 16)) a -= (BASE << 16); \
7852 if (a >= (BASE << 15)) a -= (BASE << 15); \
7853 if (a >= (BASE << 14)) a -= (BASE << 14); \
7854 if (a >= (BASE << 13)) a -= (BASE << 13); \
7855 if (a >= (BASE << 12)) a -= (BASE << 12); \
7856 if (a >= (BASE << 11)) a -= (BASE << 11); \
7857 if (a >= (BASE << 10)) a -= (BASE << 10); \
7858 if (a >= (BASE << 9)) a -= (BASE << 9); \
7859 if (a >= (BASE << 8)) a -= (BASE << 8); \
7860 if (a >= (BASE << 7)) a -= (BASE << 7); \
7861 if (a >= (BASE << 6)) a -= (BASE << 6); \
7862 if (a >= (BASE << 5)) a -= (BASE << 5); \
7863 if (a >= (BASE << 4)) a -= (BASE << 4); \
7864 if (a >= (BASE << 3)) a -= (BASE << 3); \
7865 if (a >= (BASE << 2)) a -= (BASE << 2); \
7866 if (a >= (BASE << 1)) a -= (BASE << 1); \
7867 if (a >= BASE) a -= BASE; \
7871 if (a >= (BASE << 4)) a -= (BASE << 4); \
7872 if (a >= (BASE << 3)) a -= (BASE << 3); \
7873 if (a >= (BASE << 2)) a -= (BASE << 2); \
7874 if (a >= (BASE << 1)) a -= (BASE << 1); \
7875 if (a >= BASE) a -= BASE; \
7878 # define MOD(a) a %= BASE
7879 # define MOD4(a) a %= BASE
7883 uLong adler32(adler, buf, len)
7892 sum2 = (adler >> 16) & 0xffff;
7903 return adler | (sum2 << 16);
7919 return adler | (sum2 << 16);
7923 while (len >= NMAX) {
7950 return adler | (sum2 << 16);
7954 uLong adler32_combine(adler1, adler2, len2)
7964 rem = (unsigned)(len2 % BASE);
7965 sum1 = adler1 & 0xffff;
7968 sum1 += (adler2 & 0xffff) + BASE - 1;
7969 sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
7970 if (sum1 > BASE) sum1 -= BASE;
7971 if (sum1 > BASE) sum1 -= BASE;
7972 if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
7973 if (sum2 > BASE) sum2 -= BASE;
7974 return sum1 | (sum2 << 16);
7980 int ezcompress(
unsigned char* pDest,
long* pnDestLen,
const unsigned char* pSrc,
long nSrcLen )
7988 stream.next_in = (Bytef*)pSrc;
7989 stream.avail_in = (uInt)nSrcLen;
7992 if ((uLong)stream.avail_in != nSrcLen)
return Z_BUF_ERROR;
7994 destlen = (uInt)*pnDestLen;
7995 if ((uLong)destlen != (uLong)*pnDestLen)
return Z_BUF_ERROR;
7997 stream.zalloc = (alloc_func)0;
7998 stream.zfree = (free_func)0;
7999 stream.opaque = (voidpf)0;
8001 err = deflateInit(&stream, Z_DEFAULT_COMPRESSION);
8002 if (err != Z_OK)
return err;
8006 stream.next_out = pDest;
8007 stream.avail_out = destlen;
8008 err = deflate(&stream, Z_FINISH);
8009 if (err == Z_STREAM_END )
8012 deflateEnd(&stream);
8016 }
while (stream.avail_out == 0);
8018 *pnDestLen = stream.total_out;
8020 err = deflateEnd(&stream);
8021 if (err != Z_OK)
return err;
8023 return nExtraChunks ? Z_BUF_ERROR : Z_OK;
8026 int ezuncompress(
unsigned char* pDest,
long* pnDestLen,
const unsigned char* pSrc,
long nSrcLen )
8034 stream.next_in = (Bytef*)pSrc;
8035 stream.avail_in = (uInt)nSrcLen;
8037 if ((uLong)stream.avail_in != (uLong)nSrcLen)
return Z_BUF_ERROR;
8039 destlen = (uInt)*pnDestLen;
8040 if ((uLong)destlen != (uLong)*pnDestLen)
return Z_BUF_ERROR;
8042 stream.zalloc = (alloc_func)0;
8043 stream.zfree = (free_func)0;
8045 err = inflateInit(&stream);
8046 if (err != Z_OK)
return err;
8050 stream.next_out = pDest;
8051 stream.avail_out = destlen;
8052 err = inflate(&stream, Z_FINISH);
8053 if (err == Z_STREAM_END )
8055 if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
8057 if (err != Z_BUF_ERROR) {
8058 inflateEnd(&stream);
8062 }
while (stream.avail_out == 0);
8064 *pnDestLen = stream.total_out;
8066 err = inflateEnd(&stream);
8067 if (err != Z_OK)
return err;
8069 return nExtraChunks ? Z_BUF_ERROR : Z_OK;