20 var zip_WSIZE = 32768;
21 var zip_STORED_BLOCK = 0;
22 var zip_STATIC_TREES = 1;
23 var zip_DYN_TREES = 2;
28 var zip_INBUFSIZ = 32768;
29 var zip_INBUF_EXTRA = 64;
34 var zip_fixed_tl = null;
36 var zip_fixed_bl, fixed_bd;
50 var zip_MASK_BITS =
new Array(
52 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
53 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff);
55 var zip_cplens =
new Array(
56 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
57 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0);
59 var zip_cplext =
new Array(
60 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
61 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99);
62 var zip_cpdist =
new Array(
63 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
64 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
65 8193, 12289, 16385, 24577);
66 var zip_cpdext =
new Array(
67 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
68 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
70 var zip_border =
new Array(
71 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15);
74 var zip_HuftList =
function() {
79 var zip_HuftNode =
function() {
88 var zip_HuftBuild =
function(b,
111 var c =
new Array(this.BMAX+1);
119 var lx =
new Array(this.BMAX+1);
123 var r =
new zip_HuftNode();
124 var u =
new Array(this.BMAX);
125 var v =
new Array(this.N_MAX);
127 var x =
new Array(this.BMAX+1);
134 tail = this.root = null;
135 for (i = 0; i < c.length; ++i)
137 for (i = 0; i < lx.length; ++i)
139 for (i = 0; i < u.length; ++i)
141 for (i = 0; i < v.length; ++i)
143 for (i = 0; i < x.length; ++i)
147 el = n > 256 ? b[256] : this.BMAX;
163 for (j = 1; j <= this.BMAX; ++j)
169 for (i = this.BMAX; i != 0; i--)
177 for (y = 1 << j; j < i; ++j, y <<= 1) {
178 if ((y -= c[j]) < 0) {
184 if ((y -= c[i]) < 0) {
197 x[xp++] = (j += p[pidx++]);
203 if ((j = p[pidx++]) != 0)
217 for (; k <= g; ++k) {
222 while (k > w + lx[1 + h]) {
227 z = (z = g - w) > mm ? mm : z;
228 if ((f = 1 << (j = k - w)) > a + 1) {
233 if ((f <<= 1) <= c[++xp])
238 if (w + j > el && w < el)
245 for (o = 0; o < z; o++) {
246 q[o] =
new zip_HuftNode();
250 tail = this.root =
new zip_HuftList();
252 tail = tail.next =
new zip_HuftList();
263 j = (i & ((1 << w) - 1)) >> (w - lx[h]);
275 else if (p[pidx] < s) {
276 r.e = (p[pidx] < 256 ? 16 : 15);
279 r.e = e[p[pidx] - s];
280 r.n = d[p[pidx++] - s];
285 for (j = i >> w; j < z; j += f) {
293 for (j = 1 << (k - 1); (i & j) != 0; j >>= 1)
298 while ((i & ((1 << w) - 1)) != x[h]) {
309 this.status = ((y != 0 && g != 1) ? 1 : 0);
316 var zip_GET_BYTE =
function() {
317 if (zip_inflate_data.length == zip_inflate_pos)
319 return zip_inflate_data.charCodeAt(zip_inflate_pos++) & 0xff;
321 var zip_NEEDBITS_DFLT =
function(n) {
322 while (zip_bit_len < n) {
323 zip_bit_buf |= zip_GET_BYTE() << zip_bit_len;
328 var zip_NEEDBITS_ARR =
function(n) {
329 while (zip_bit_len < n) {
330 if (zip_inflate_pos < zip_inflate_data.byteLength)
331 zip_bit_buf |= zip_inflate_data[zip_inflate_pos++] << zip_bit_len;
336 var zip_NEEDBITS = zip_NEEDBITS_DFLT;
338 var zip_GETBITS =
function(n) {
339 return zip_bit_buf & zip_MASK_BITS[n];
342 var zip_DUMPBITS =
function(n) {
347 var zip_inflate_codes =
function(buff, off, size) {
360 zip_NEEDBITS(zip_bl);
361 t = zip_tl.list[zip_GETBITS(zip_bl)];
369 t = t.t[zip_GETBITS(e)];
375 zip_wp &= zip_WSIZE - 1;
376 buff[off + n++] = zip_slide[zip_wp++] = t.n;
390 zip_copy_leng = t.n + zip_GETBITS(e);
394 zip_NEEDBITS(zip_bd);
395 t = zip_td.list[zip_GETBITS(zip_bd)];
404 t = t.t[zip_GETBITS(e)];
409 zip_copy_dist = zip_wp - t.n - zip_GETBITS(e);
413 while (zip_copy_leng > 0 && n < size) {
415 zip_copy_dist &= zip_WSIZE - 1;
416 zip_wp &= zip_WSIZE - 1;
417 buff[off + n++] = zip_slide[zip_wp++] = zip_slide[zip_copy_dist++];
428 var zip_inflate_stored =
function(buff, off, size) {
441 if (n != ((~zip_bit_buf) & 0xffff))
449 while (zip_copy_leng > 0 && n < size) {
451 zip_wp &= zip_WSIZE - 1;
453 buff[off + n++] = zip_slide[zip_wp++] = zip_GETBITS(8);
457 if (zip_copy_leng == 0)
462 var zip_inflate_fixed =
function(buff, off, size) {
468 if (zip_fixed_tl == null) {
470 var l =
new Array(288);
474 for (i = 0; i < 144; ++i)
484 h =
new zip_HuftBuild(l, 288, 257, zip_cplens, zip_cplext,
487 alert(
"HufBuild error: "+h.status);
490 zip_fixed_tl = h.root;
494 for (i = 0; i < 30; ++i)
498 h =
new zip_HuftBuild(l, 30, 0, zip_cpdist, zip_cpdext,
502 alert(
"HufBuild error: "+h.status);
505 zip_fixed_td = h.root;
509 zip_tl = zip_fixed_tl;
510 zip_td = zip_fixed_td;
511 zip_bl = zip_fixed_bl;
512 zip_bd = zip_fixed_bd;
513 return zip_inflate_codes(buff, off, size);
516 var zip_inflate_dynamic =
function(buff, off, size) {
526 var ll =
new Array(286+30);
529 for (i = 0; i < ll.length; ++i)
534 nl = 257 + zip_GETBITS(5);
537 nd = 1 + zip_GETBITS(5);
540 nb = 4 + zip_GETBITS(4);
542 if (nl > 286 || nd > 30)
546 for (j = 0; j < nb; ++j) {
548 ll[zip_border[j]] = zip_GETBITS(3);
552 ll[zip_border[j]] = 0;
556 h =
new zip_HuftBuild(ll, 19, 19, null, null, zip_bl);
567 zip_NEEDBITS(zip_bl);
568 t = zip_tl.list[zip_GETBITS(zip_bl)];
576 j = 3 + zip_GETBITS(2);
582 }
else if (j == 17) {
584 j = 3 + zip_GETBITS(3);
593 j = 11 + zip_GETBITS(7);
605 h =
new zip_HuftBuild(ll, nl, 257, zip_cplens, zip_cplext, zip_bl);
616 for (i = 0; i < nd; ++i)
619 h =
new zip_HuftBuild(ll, nd, 0, zip_cpdist, zip_cpdext, zip_bd);
623 if (zip_bd == 0 && nl > 257) {
635 return zip_inflate_codes(buff, off, size);
638 var zip_inflate_start =
function() {
642 if (zip_slide == null)
643 zip_slide =
new Array(2 * zip_WSIZE);
649 zip_copy_leng = zip_copy_dist = 0;
653 var zip_inflate_internal =
function(buff, off, size) {
659 if (zip_eof && zip_method == -1)
662 if (zip_copy_leng > 0) {
663 if (zip_method != zip_STORED_BLOCK) {
665 while (zip_copy_leng > 0 && n < size) {
667 zip_copy_dist &= zip_WSIZE - 1;
668 zip_wp &= zip_WSIZE - 1;
669 buff[off + n++] = zip_slide[zip_wp++] =
670 zip_slide[zip_copy_dist++];
673 while (zip_copy_leng > 0 && n < size) {
675 zip_wp &= zip_WSIZE - 1;
677 buff[off + n++] = zip_slide[zip_wp++] = zip_GETBITS(8);
680 if (zip_copy_leng == 0)
687 if (zip_method == -1) {
693 if (zip_GETBITS(1) != 0)
699 zip_method = zip_GETBITS(2);
705 switch (zip_method) {
707 i = zip_inflate_stored(buff, off + n, size - n);
712 i = zip_inflate_codes(buff, off + n, size - n);
714 i = zip_inflate_fixed(buff, off + n, size - n);
719 i = zip_inflate_codes(buff, off + n, size - n);
721 i = zip_inflate_dynamic(buff, off + n, size - n);
739 var zip_inflate =
function(str)
744 zip_inflate_data = str;
747 zip_NEEDBITS = zip_NEEDBITS_DFLT;
749 var buff =
new Array(1024);
751 while ((i = zip_inflate_internal(buff, 0, buff.length)) > 0) {
752 var cbuf =
new Array(i);
753 for (j = 0; j < i; ++j) {
754 cbuf[j] = String.fromCharCode(buff[j]);
756 aout[aout.length] = cbuf.join(
"");
758 zip_inflate_data = null;
759 return aout.join(
"");
762 var zip_inflate_arr =
function(arr, tgt)
767 zip_inflate_data = arr;
769 zip_NEEDBITS = zip_NEEDBITS_ARR;
772 while ((i = zip_inflate_internal(tgt, cnt, Math.min(1024, tgt.byteLength-cnt))) > 0) {
775 zip_inflate_data = null;
781 if (! window.RawInflate) RawInflate = {};
783 RawInflate.inflate = zip_inflate;
784 RawInflate.arr_inflate = zip_inflate_arr;