artdaq_node_server  v1_00_11
 All Classes Namespaces Files Variables
rawinflate.js
1 /*
2  * $Id$
3  *
4  * original:
5  * http://www.onicos.com/staff/iz/amuse/javascript/expert/inflate.txt
6  */
7 
8 (function(){
9 
10 /* Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp>
11  * Version: 1.0.0.1
12  * LastModified: Dec 25 1999
13  */
14 
15 /* Interface:
16  * data = zip_inflate(src);
17  */
18 
19 /* constant parameters */
20 var zip_WSIZE = 32768; // Sliding Window size
21 var zip_STORED_BLOCK = 0;
22 var zip_STATIC_TREES = 1;
23 var zip_DYN_TREES = 2;
24 
25 /* for inflate */
26 var zip_lbits = 9; // bits in base literal/length lookup table
27 var zip_dbits = 6; // bits in base distance lookup table
28 var zip_INBUFSIZ = 32768; // Input buffer size
29 var zip_INBUF_EXTRA = 64; // Extra buffer
30 
31 /* variables (inflate) */
32 var zip_slide;
33 var zip_wp; // current position in slide
34 var zip_fixed_tl = null; // inflate static
35 var zip_fixed_td; // inflate static
36 var zip_fixed_bl, fixed_bd; // inflate static
37 var zip_bit_buf; // bit buffer
38 var zip_bit_len; // bits in bit buffer
39 var zip_method;
40 var zip_eof;
41 var zip_copy_leng;
42 var zip_copy_dist;
43 var zip_tl, zip_td; // literal/length and distance decoder tables
44 var zip_bl, zip_bd; // number of bits decoded by tl and td
45 
46 var zip_inflate_data;
47 var zip_inflate_pos;
48 
49 /* constant tables (inflate) */
50 var zip_MASK_BITS = new Array(
51  0x0000,
52  0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
53  0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff);
54 // Tables for deflate from PKZIP's appnote.txt.
55 var zip_cplens = new Array( // Copy lengths for literal codes 257..285
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);
58 /* note: see note #13 above about the 258 in this list. */
59 var zip_cplext = new Array( // Extra bits for literal codes 257..285
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); // 99==invalid
62 var zip_cpdist = new Array( // Copy offsets for distance codes 0..29
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( // Extra bits for distance codes
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,
69  12, 12, 13, 13);
70 var zip_border = new Array( // Order of the bit length code lengths
71  16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15);
72 /* objects (inflate) */
73 
74 var zip_HuftList = function() {
75  this.next = null;
76  this.list = null;
77 }
78 
79 var zip_HuftNode = function() {
80  this.e = 0; // number of extra bits or operation
81  this.b = 0; // number of bits in this code or subcode
82 
83  // union
84  this.n = 0; // literal, length base, or distance base
85  this.t = null; // (zip_HuftNode) pointer to next level of table
86 }
87 
88 var zip_HuftBuild = function(b, // code lengths in bits (all assumed <= BMAX)
89  n, // number of codes (assumed <= N_MAX)
90  s, // number of simple-valued codes (0..s-1)
91  d, // list of base values for non-simple codes
92  e, // list of extra bits for non-simple codes
93  mm ) { // maximum lookup bits
94 
95  this.BMAX = 16; // maximum bit length of any code
96  this.N_MAX = 288; // maximum number of codes in any set
97  this.status = 0; // 0: success, 1: incomplete table, 2: bad input
98  this.root = null; // (zip_HuftList) starting table
99  this.m = 0; // maximum lookup bits, returns actual
100 
101 /* Given a list of code lengths and a maximum table size, make a set of
102  tables to decode that set of codes. Return zero on success, one if
103  the given code set is incomplete (the tables are still built in this
104  case), two if the input is invalid (all zero length codes or an
105  oversubscribed set of lengths), and three if not enough memory.
106  The code with value 256 is special, and the tables are constructed
107  so that no bits beyond that code are fetched when that code is
108  decoded. */
109 {
110  var a; // counter for codes of length k
111  var c = new Array(this.BMAX+1); // bit length count table
112  var el; // length of EOB code (value 256)
113  var f; // i repeats in table every f entries
114  var g; // maximum code length
115  var h; // table level
116  var i; // counter, current code
117  var j; // counter
118  var k; // number of bits in current code
119  var lx = new Array(this.BMAX+1); // stack of bits per table
120  var p; // pointer into c[], b[], or v[]
121  var pidx; // index of p
122  var q; // (zip_HuftNode) points to current table
123  var r = new zip_HuftNode(); // table entry for structure assignment
124  var u = new Array(this.BMAX); // zip_HuftNode[BMAX][] table stack
125  var v = new Array(this.N_MAX); // values in order of bit length
126  var w;
127  var x = new Array(this.BMAX+1);// bit offsets, then code stack
128  var xp; // pointer into x or c
129  var y; // number of dummy codes added
130  var z; // number of entries in current table
131  var o;
132  var tail; // (zip_HuftList)
133 
134  tail = this.root = null;
135  for (i = 0; i < c.length; i++)
136  c[i] = 0;
137  for (i = 0; i < lx.length; i++)
138  lx[i] = 0;
139  for (i = 0; i < u.length; i++)
140  u[i] = null;
141  for (i = 0; i < v.length; i++)
142  v[i] = 0;
143  for (i = 0; i < x.length; i++)
144  x[i] = 0;
145 
146  // Generate counts for each bit length
147  el = n > 256 ? b[256] : this.BMAX; // set length of EOB code, if any
148  p = b; pidx = 0;
149  i = n;
150  do {
151  c[p[pidx]]++; // assume all entries <= BMAX
152  pidx++;
153  } while (--i > 0);
154 
155  if (c[0] == n) { // null input--all zero length codes
156  this.root = null;
157  this.m = 0;
158  this.status = 0;
159  return;
160  }
161 
162  // Find minimum and maximum length, bound *m by those
163  for (j = 1; j <= this.BMAX; j++)
164  if (c[j] != 0)
165  break;
166  k = j; // minimum code length
167  if (mm < j)
168  mm = j;
169  for (i = this.BMAX; i != 0; i--)
170  if (c[i] != 0)
171  break;
172  g = i; // maximum code length
173  if (mm > i)
174  mm = i;
175 
176  // Adjust last length count to fill out codes, if needed
177  for (y = 1 << j; j < i; j++, y <<= 1) {
178  if ((y -= c[j]) < 0) {
179  this.status = 2; // bad input: more codes than bits
180  this.m = mm;
181  return;
182  }
183  }
184  if ((y -= c[i]) < 0) {
185  this.status = 2;
186  this.m = mm;
187  return;
188  }
189  c[i] += y;
190 
191  // Generate starting offsets into the value table for each length
192  x[1] = j = 0;
193  p = c;
194  pidx = 1;
195  xp = 2;
196  while (--i > 0) // note that i == g from above
197  x[xp++] = (j += p[pidx++]);
198 
199  // Make a table of values in order of bit lengths
200  p = b; pidx = 0;
201  i = 0;
202  do {
203  if ((j = p[pidx++]) != 0)
204  v[x[j]++] = i;
205  } while (++i < n);
206  n = x[g]; // set n to length of v
207 
208  // Generate the Huffman codes and for each, make the table entries
209  x[0] = i = 0; // first Huffman code is zero
210  p = v; pidx = 0; // grab values in bit order
211  h = -1; // no tables yet--level -1
212  w = lx[0] = 0; // no bits decoded yet
213  q = null; // ditto
214  z = 0; // ditto
215 
216  // go through the bit lengths (k already is bits in shortest code)
217  for (; k <= g; k++) {
218  a = c[k];
219  while (a-- > 0) {
220  // here i is the Huffman code of length k bits for value p[pidx]
221  // make tables up to required level
222  while (k > w + lx[1 + h]) {
223  w += lx[1 + h]; // add bits already decoded
224  h++;
225 
226  // compute minimum size table less than or equal to *m bits
227  z = (z = g - w) > mm ? mm : z; // upper limit
228  if ((f = 1 << (j = k - w)) > a + 1) { // try a k-w bit table
229  // too few codes for k-w bit table
230  f -= a + 1; // deduct codes from patterns left
231  xp = k;
232  while (++j < z) { // try smaller tables up to z bits
233  if ((f <<= 1) <= c[++xp])
234  break; // enough codes to use up j bits
235  f -= c[xp]; // else deduct codes from patterns
236  }
237  }
238  if (w + j > el && w < el)
239  j = el - w; // make EOB code end at table
240  z = 1 << j; // table entries for j-bit table
241  lx[1 + h] = j; // set table size in stack
242 
243  // allocate and link in new table
244  q = new Array(z);
245  for (o = 0; o < z; o++) {
246  q[o] = new zip_HuftNode();
247  }
248 
249  if (tail == null)
250  tail = this.root = new zip_HuftList();
251  else
252  tail = tail.next = new zip_HuftList();
253  tail.next = null;
254  tail.list = q;
255  u[h] = q; // table starts after link
256 
257  /* connect to last table, if there is one */
258  if (h > 0) {
259  x[h] = i; // save pattern for backing up
260  r.b = lx[h]; // bits to dump before this table
261  r.e = 16 + j; // bits in this table
262  r.t = q; // pointer to this table
263  j = (i & ((1 << w) - 1)) >> (w - lx[h]);
264  u[h-1][j].e = r.e;
265  u[h-1][j].b = r.b;
266  u[h-1][j].n = r.n;
267  u[h-1][j].t = r.t;
268  }
269  }
270 
271  // set up table entry in r
272  r.b = k - w;
273  if (pidx >= n)
274  r.e = 99; // out of values--invalid code
275  else if (p[pidx] < s) {
276  r.e = (p[pidx] < 256 ? 16 : 15); // 256 is end-of-block code
277  r.n = p[pidx++]; // simple code is just the value
278  } else {
279  r.e = e[p[pidx] - s]; // non-simple--look up in lists
280  r.n = d[p[pidx++] - s];
281  }
282 
283  // fill code-like entries with r //
284  f = 1 << (k - w);
285  for (j = i >> w; j < z; j += f) {
286  q[j].e = r.e;
287  q[j].b = r.b;
288  q[j].n = r.n;
289  q[j].t = r.t;
290  }
291 
292  // backwards increment the k-bit code i
293  for (j = 1 << (k - 1); (i & j) != 0; j >>= 1)
294  i ^= j;
295  i ^= j;
296 
297  // backup over finished tables
298  while ((i & ((1 << w) - 1)) != x[h]) {
299  w -= lx[h]; // don't need to update q
300  h--;
301  }
302  }
303  }
304 
305  /* return actual size of base table */
306  this.m = lx[1];
307 
308  /* Return true (1) if we were given an incomplete table */
309  this.status = ((y != 0 && g != 1) ? 1 : 0);
310 } /* end of constructor */
311 
312 }
313 
314 /* routines (inflate) */
315 
316 var zip_GET_BYTE = function() {
317  if (zip_inflate_data.length == zip_inflate_pos)
318  return -1;
319  return zip_inflate_data.charCodeAt(zip_inflate_pos++) & 0xff;
320 }
321 
322 var zip_NEEDBITS = function(n) {
323  while (zip_bit_len < n) {
324  zip_bit_buf |= zip_GET_BYTE() << zip_bit_len;
325  zip_bit_len += 8;
326  }
327 }
328 
329 var zip_GETBITS = function(n) {
330  return zip_bit_buf & zip_MASK_BITS[n];
331 }
332 
333 var zip_DUMPBITS = function(n) {
334  zip_bit_buf >>= n;
335  zip_bit_len -= n;
336 }
337 
338 var zip_inflate_codes = function(buff, off, size) {
339  /* inflate (decompress) the codes in a deflated (compressed) block.
340  Return an error code or zero if it all goes ok. */
341  var e; // table entry flag/number of extra bits
342  var t; // (zip_HuftNode) pointer to table entry
343  var n;
344 
345  if (size == 0)
346  return 0;
347 
348  // inflate the coded data
349  n = 0;
350  for (;;) { // do until end of block
351  zip_NEEDBITS(zip_bl);
352  t = zip_tl.list[zip_GETBITS(zip_bl)];
353  e = t.e;
354  while (e > 16) {
355  if (e == 99)
356  return -1;
357  zip_DUMPBITS(t.b);
358  e -= 16;
359  zip_NEEDBITS(e);
360  t = t.t[zip_GETBITS(e)];
361  e = t.e;
362  }
363  zip_DUMPBITS(t.b);
364 
365  if (e == 16) { // then it's a literal
366  zip_wp &= zip_WSIZE - 1;
367  buff[off + n++] = zip_slide[zip_wp++] = t.n;
368  if (n == size)
369  return size;
370  continue;
371  }
372 
373  // exit if end of block
374  if (e == 15)
375  break;
376 
377  // it's an EOB or a length
378 
379  // get length of block to copy
380  zip_NEEDBITS(e);
381  zip_copy_leng = t.n + zip_GETBITS(e);
382  zip_DUMPBITS(e);
383 
384  // decode distance of block to copy
385  zip_NEEDBITS(zip_bd);
386  t = zip_td.list[zip_GETBITS(zip_bd)];
387  e = t.e;
388 
389  while (e > 16) {
390  if (e == 99)
391  return -1;
392  zip_DUMPBITS(t.b);
393  e -= 16;
394  zip_NEEDBITS(e);
395  t = t.t[zip_GETBITS(e)];
396  e = t.e;
397  }
398  zip_DUMPBITS(t.b);
399  zip_NEEDBITS(e);
400  zip_copy_dist = zip_wp - t.n - zip_GETBITS(e);
401  zip_DUMPBITS(e);
402 
403  // do the copy
404  while (zip_copy_leng > 0 && n < size) {
405  zip_copy_leng--;
406  zip_copy_dist &= zip_WSIZE - 1;
407  zip_wp &= zip_WSIZE - 1;
408  buff[off + n++] = zip_slide[zip_wp++] = zip_slide[zip_copy_dist++];
409  }
410 
411  if (n == size)
412  return size;
413  }
414 
415  zip_method = -1; // done
416  return n;
417 }
418 
419 var zip_inflate_stored = function(buff, off, size) {
420  /* "decompress" an inflated type 0 (stored) block. */
421  var n;
422 
423  // go to byte boundary
424  n = zip_bit_len & 7;
425  zip_DUMPBITS(n);
426 
427  // get the length and its complement
428  zip_NEEDBITS(16);
429  n = zip_GETBITS(16);
430  zip_DUMPBITS(16);
431  zip_NEEDBITS(16);
432  if (n != ((~zip_bit_buf) & 0xffff))
433  return -1; // error in compressed data
434  zip_DUMPBITS(16);
435 
436  // read and output the compressed data
437  zip_copy_leng = n;
438 
439  n = 0;
440  while (zip_copy_leng > 0 && n < size) {
441  zip_copy_leng--;
442  zip_wp &= zip_WSIZE - 1;
443  zip_NEEDBITS(8);
444  buff[off + n++] = zip_slide[zip_wp++] = zip_GETBITS(8);
445  zip_DUMPBITS(8);
446  }
447 
448  if (zip_copy_leng == 0)
449  zip_method = -1; // done
450  return n;
451 }
452 
453 var zip_inflate_fixed = function(buff, off, size) {
454  /* decompress an inflated type 1 (fixed Huffman codes) block. We should
455  either replace this with a custom decoder, or at least precompute the
456  Huffman tables. */
457 
458  // if first time, set up tables for fixed blocks
459  if (zip_fixed_tl == null) {
460  var i; // temporary variable
461  var l = new Array(288); // length list for huft_build
462  var h; // zip_HuftBuild
463 
464  // literal table
465  for (i = 0; i < 144; i++)
466  l[i] = 8;
467  for (; i < 256; i++)
468  l[i] = 9;
469  for (; i < 280; i++)
470  l[i] = 7;
471  for (; i < 288; i++) // make a complete, but wrong code set
472  l[i] = 8;
473  zip_fixed_bl = 7;
474 
475  h = new zip_HuftBuild(l, 288, 257, zip_cplens, zip_cplext,
476  zip_fixed_bl);
477  if (h.status != 0) {
478  alert("HufBuild error: "+h.status);
479  return -1;
480  }
481  zip_fixed_tl = h.root;
482  zip_fixed_bl = h.m;
483 
484  // distance table
485  for (i = 0; i < 30; i++) // make an incomplete code set
486  l[i] = 5;
487  zip_fixed_bd = 5;
488 
489  h = new zip_HuftBuild(l, 30, 0, zip_cpdist, zip_cpdext,
490  zip_fixed_bd);
491  if (h.status > 1) {
492  zip_fixed_tl = null;
493  alert("HufBuild error: "+h.status);
494  return -1;
495  }
496  zip_fixed_td = h.root;
497  zip_fixed_bd = h.m;
498  }
499 
500  zip_tl = zip_fixed_tl;
501  zip_td = zip_fixed_td;
502  zip_bl = zip_fixed_bl;
503  zip_bd = zip_fixed_bd;
504  return zip_inflate_codes(buff, off, size);
505 }
506 
507 var zip_inflate_dynamic = function(buff, off, size) {
508  // decompress an inflated type 2 (dynamic Huffman codes) block.
509  var i; // temporary variables
510  var j;
511  var l; // last length
512  var n; // number of lengths to get
513  var t; // (zip_HuftNode) literal/length code table
514  var nb; // number of bit length codes
515  var nl; // number of literal/length codes
516  var nd; // number of distance codes
517  var ll = new Array(286+30); // literal/length and distance code lengths
518  var h; // (zip_HuftBuild)
519 
520  for (i = 0; i < ll.length; i++)
521  ll[i] = 0;
522 
523  // read in table lengths
524  zip_NEEDBITS(5);
525  nl = 257 + zip_GETBITS(5); // number of literal/length codes
526  zip_DUMPBITS(5);
527  zip_NEEDBITS(5);
528  nd = 1 + zip_GETBITS(5); // number of distance codes
529  zip_DUMPBITS(5);
530  zip_NEEDBITS(4);
531  nb = 4 + zip_GETBITS(4); // number of bit length codes
532  zip_DUMPBITS(4);
533  if (nl > 286 || nd > 30)
534  return -1; // bad lengths
535 
536  // read in bit-length-code lengths
537  for (j = 0; j < nb; j++) {
538  zip_NEEDBITS(3);
539  ll[zip_border[j]] = zip_GETBITS(3);
540  zip_DUMPBITS(3);
541  }
542  for (; j < 19; j++)
543  ll[zip_border[j]] = 0;
544 
545  // build decoding table for trees--single level, 7 bit lookup
546  zip_bl = 7;
547  h = new zip_HuftBuild(ll, 19, 19, null, null, zip_bl);
548  if (h.status != 0)
549  return -1; // incomplete code set
550 
551  zip_tl = h.root;
552  zip_bl = h.m;
553 
554  // read in literal and distance code lengths
555  n = nl + nd;
556  i = l = 0;
557  while (i < n) {
558  zip_NEEDBITS(zip_bl);
559  t = zip_tl.list[zip_GETBITS(zip_bl)];
560  j = t.b;
561  zip_DUMPBITS(j);
562  j = t.n;
563  if (j < 16) // length of code in bits (0..15)
564  ll[i++] = l = j; // save last length in l
565  else if (j == 16) { // repeat last length 3 to 6 times
566  zip_NEEDBITS(2);
567  j = 3 + zip_GETBITS(2);
568  zip_DUMPBITS(2);
569  if (i + j > n)
570  return -1;
571  while (j-- > 0)
572  ll[i++] = l;
573  } else if (j == 17) { // 3 to 10 zero length codes
574  zip_NEEDBITS(3);
575  j = 3 + zip_GETBITS(3);
576  zip_DUMPBITS(3);
577  if (i + j > n)
578  return -1;
579  while (j-- > 0)
580  ll[i++] = 0;
581  l = 0;
582  } else { // j == 18: 11 to 138 zero length codes
583  zip_NEEDBITS(7);
584  j = 11 + zip_GETBITS(7);
585  zip_DUMPBITS(7);
586  if (i + j > n)
587  return -1;
588  while (j-- > 0)
589  ll[i++] = 0;
590  l = 0;
591  }
592  }
593 
594  // build the decoding tables for literal/length and distance codes
595  zip_bl = zip_lbits;
596  h = new zip_HuftBuild(ll, nl, 257, zip_cplens, zip_cplext, zip_bl);
597  if (zip_bl == 0) // no literals or lengths
598  h.status = 1;
599  if (h.status != 0) {
600  if (h.status == 1)
601  ;// **incomplete literal tree**
602  return -1; // incomplete code set
603  }
604  zip_tl = h.root;
605  zip_bl = h.m;
606 
607  for (i = 0; i < nd; i++)
608  ll[i] = ll[i + nl];
609  zip_bd = zip_dbits;
610  h = new zip_HuftBuild(ll, nd, 0, zip_cpdist, zip_cpdext, zip_bd);
611  zip_td = h.root;
612  zip_bd = h.m;
613 
614  if (zip_bd == 0 && nl > 257) { // lengths but no distances
615  // **incomplete distance tree**
616  return -1;
617  }
618 
619  if (h.status == 1) {
620  ;// **incomplete distance tree**
621  }
622  if (h.status != 0)
623  return -1;
624 
625  // decompress until an end-of-block code
626  return zip_inflate_codes(buff, off, size);
627 }
628 
629 var zip_inflate_start = function() {
630 
631  var i;
632 
633  if (zip_slide == null)
634  zip_slide = new Array(2 * zip_WSIZE);
635  zip_wp = 0;
636  zip_bit_buf = 0;
637  zip_bit_len = 0;
638  zip_method = -1;
639  zip_eof = false;
640  zip_copy_leng = zip_copy_dist = 0;
641  zip_tl = null;
642 }
643 
644 var zip_inflate_internal = function(buff, off, size) {
645  // decompress an inflated entry
646  var n, i;
647 
648  n = 0;
649  while (n < size) {
650  if (zip_eof && zip_method == -1)
651  return n;
652 
653  if (zip_copy_leng > 0) {
654  if (zip_method != zip_STORED_BLOCK) {
655  // STATIC_TREES or DYN_TREES
656  while (zip_copy_leng > 0 && n < size) {
657  zip_copy_leng--;
658  zip_copy_dist &= zip_WSIZE - 1;
659  zip_wp &= zip_WSIZE - 1;
660  buff[off + n++] = zip_slide[zip_wp++] =
661  zip_slide[zip_copy_dist++];
662  }
663  } else {
664  while (zip_copy_leng > 0 && n < size) {
665  zip_copy_leng--;
666  zip_wp &= zip_WSIZE - 1;
667  zip_NEEDBITS(8);
668  buff[off + n++] = zip_slide[zip_wp++] = zip_GETBITS(8);
669  zip_DUMPBITS(8);
670  }
671  if (zip_copy_leng == 0)
672  zip_method = -1; // done
673  }
674  if (n == size)
675  return n;
676  }
677 
678  if (zip_method == -1) {
679  if (zip_eof)
680  break;
681 
682  // read in last block bit
683  zip_NEEDBITS(1);
684  if (zip_GETBITS(1) != 0)
685  zip_eof = true;
686  zip_DUMPBITS(1);
687 
688  // read in block type
689  zip_NEEDBITS(2);
690  zip_method = zip_GETBITS(2);
691  zip_DUMPBITS(2);
692  zip_tl = null;
693  zip_copy_leng = 0;
694  }
695 
696  switch (zip_method) {
697  case 0: // zip_STORED_BLOCK
698  i = zip_inflate_stored(buff, off + n, size - n);
699  break;
700 
701  case 1: // zip_STATIC_TREES
702  if (zip_tl != null)
703  i = zip_inflate_codes(buff, off + n, size - n);
704  else
705  i = zip_inflate_fixed(buff, off + n, size - n);
706  break;
707 
708  case 2: // zip_DYN_TREES
709  if (zip_tl != null)
710  i = zip_inflate_codes(buff, off + n, size - n);
711  else
712  i = zip_inflate_dynamic(buff, off + n, size - n);
713  break;
714 
715  default: // error
716  i = -1;
717  break;
718  }
719 
720  if (i == -1) {
721  if (zip_eof)
722  return 0;
723  return -1;
724  }
725  n += i;
726  }
727  return n;
728 }
729 
730 var zip_inflate = function(str)
731 {
732  var i, j;
733 
734  zip_inflate_start();
735  zip_inflate_data = str;
736  zip_inflate_pos = 0;
737 
738  var buff = new Array(1024);
739  var aout = [];
740  while ((i = zip_inflate_internal(buff, 0, buff.length)) > 0) {
741  var cbuf = new Array(i);
742  for (j = 0; j < i; j++) {
743  cbuf[j] = String.fromCharCode(buff[j]);
744  }
745  aout[aout.length] = cbuf.join("");
746  }
747  zip_inflate_data = null; // G.C.
748  return aout.join("");
749 }
750 
751 if (! window.RawInflate) RawInflate = {};
752 
753 RawInflate.inflate = zip_inflate;
754 
755 })();