internal InfBlocks(ZStream z, object checkfn, int w) { this.window = new byte[w]; this.end = w; this.checkfn = checkfn; this.mode = 0; this.reset(z, null); }
public virtual void end() { if (this.compress) { this.z.deflateEnd(); } else { this.z.inflateEnd(); } this.z.free(); this.z = null; }
internal InfCodes(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, ZStream z) { this.mode = 0; this.lbits = (byte)bl; this.dbits = (byte)bd; this.ltree = tl; this.ltree_index = tl_index; this.dtree = td; this.dtree_index = td_index; }
public ZOutputStream(Stream out_Renamed) { this.z = new ZStream(); this.bufsize = 0x200; this.buf1 = new byte[1]; this.InitBlock(); this.out_Renamed = out_Renamed; this.z.inflateInit(); this.compress = false; }
public ZOutputStream(Stream out_Renamed, int level) { this.z = new ZStream(); this.bufsize = 0x200; this.buf1 = new byte[1]; this.InitBlock(); this.out_Renamed = out_Renamed; this.z.deflateInit(level); this.compress = true; }
public ZInputStream(Stream in_Renamed, int level) : base(in_Renamed) { this.z = new ZStream(); this.bufsize = 0x200; this.buf1 = new byte[1]; this.InitBlock(); this.in_Renamed = in_Renamed; this.z.deflateInit(level); this.compress = true; this.z.next_in = this.buf; this.z.next_in_index = 0; this.z.avail_in = 0; }
internal int inflate_flush(ZStream z, int r) { int destinationIndex = z.next_out_index; int read = this.read; int len = ((read <= this.write) ? this.write : this.end) - read; if (len > z.avail_out) { len = z.avail_out; } if ((len != 0) && (r == -5)) { r = 0; } z.avail_out -= len; z.total_out += len; if (this.checkfn != null) { z.adler = this.check = z._adler.adler32(this.check, this.window, read, len); } Array.Copy(this.window, read, z.next_out, destinationIndex, len); destinationIndex += len; read += len; if (read == this.end) { read = 0; if (this.write == this.end) { this.write = 0; } len = this.write - read; if (len > z.avail_out) { len = z.avail_out; } if ((len != 0) && (r == -5)) { r = 0; } z.avail_out -= len; z.total_out += len; if (this.checkfn != null) { z.adler = this.check = z._adler.adler32(this.check, this.window, read, len); } Array.Copy(this.window, read, z.next_out, destinationIndex, len); destinationIndex += len; read += len; } z.next_out_index = destinationIndex; this.read = read; return r; }
internal int proc(InfBlocks s, ZStream z, int r) { int num; int num10; int number = 0; int bitk = 0; int num6 = 0; num6 = z.next_in_index; int num7 = z.avail_in; number = s.bitb; bitk = s.bitk; int write = s.write; int num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); Label_0051: switch (this.mode) { case 0: if ((num9 < 0x102) || (num7 < 10)) { break; } s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; r = this.inflate_fast(this.lbits, this.dbits, this.ltree, this.ltree_index, this.dtree, this.dtree_index, s, z); num6 = z.next_in_index; num7 = z.avail_in; number = s.bitb; bitk = s.bitk; write = s.write; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); if (r == 0) { break; } this.mode = (r == 1) ? 7 : 9; goto Label_0051; case 1: goto Label_0199; case 2: num = this.get_Renamed; while (bitk < num) { if (num7 != 0) { r = 0; } else { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); } num7--; number |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } this.len += number & inflate_mask[num]; number = number >> num; bitk -= num; this.need = this.dbits; this.tree = this.dtree; this.tree_index = this.dtree_index; this.mode = 3; goto Label_0412; case 3: goto Label_0412; case 4: num = this.get_Renamed; while (bitk < num) { if (num7 != 0) { r = 0; } else { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); } num7--; number |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } this.dist += number & inflate_mask[num]; number = number >> num; bitk -= num; this.mode = 5; goto Label_0635; case 5: goto Label_0635; case 6: if (num9 == 0) { if ((write == s.end) && (s.read != 0)) { write = 0; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); } if (num9 == 0) { s.write = write; r = s.inflate_flush(z, r); write = s.write; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); if ((write == s.end) && (s.read != 0)) { write = 0; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); } if (num9 == 0) { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); } } } r = 0; s.window[write++] = (byte)this.lit; num9--; this.mode = 0; goto Label_0051; case 7: if (bitk > 7) { bitk -= 8; num7++; num6--; } s.write = write; r = s.inflate_flush(z, r); write = s.write; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); if (s.read != s.write) { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); } this.mode = 8; goto Label_098A; case 8: goto Label_098A; case 9: r = -3; s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); default: r = -2; s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); } this.need = this.lbits; this.tree = this.ltree; this.tree_index = this.ltree_index; this.mode = 1; Label_0199: num = this.need; while (bitk < num) { if (num7 != 0) { r = 0; } else { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); } num7--; number |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } int index = (this.tree_index + (number & inflate_mask[num])) * 3; number = SupportClass.URShift(number, this.tree[index + 1]); bitk -= this.tree[index + 1]; int num3 = this.tree[index]; if (num3 == 0) { this.lit = this.tree[index + 2]; this.mode = 6; goto Label_0051; } if ((num3 & 0x10) != 0) { this.get_Renamed = num3 & 15; this.len = this.tree[index + 2]; this.mode = 2; goto Label_0051; } if ((num3 & 0x40) == 0) { this.need = num3; this.tree_index = (index / 3) + this.tree[index + 2]; goto Label_0051; } if ((num3 & 0x20) != 0) { this.mode = 7; goto Label_0051; } this.mode = 9; z.msg = "invalid literal/length code"; r = -3; s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); Label_0412: num = this.need; while (bitk < num) { if (num7 != 0) { r = 0; } else { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); } num7--; number |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } index = (this.tree_index + (number & inflate_mask[num])) * 3; number = number >> this.tree[index + 1]; bitk -= this.tree[index + 1]; num3 = this.tree[index]; if ((num3 & 0x10) != 0) { this.get_Renamed = num3 & 15; this.dist = this.tree[index + 2]; this.mode = 4; goto Label_0051; } if ((num3 & 0x40) == 0) { this.need = num3; this.tree_index = (index / 3) + this.tree[index + 2]; goto Label_0051; } this.mode = 9; z.msg = "invalid distance code"; r = -3; s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); Label_0635: num10 = write - this.dist; while (num10 < 0) { num10 += s.end; } while (this.len != 0) { if (num9 == 0) { if ((write == s.end) && (s.read != 0)) { write = 0; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); } if (num9 == 0) { s.write = write; r = s.inflate_flush(z, r); write = s.write; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); if ((write == s.end) && (s.read != 0)) { write = 0; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); } if (num9 == 0) { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); } } } s.window[write++] = s.window[num10++]; num9--; if (num10 == s.end) { num10 = 0; } this.len--; } this.mode = 0; goto Label_0051; Label_098A: r = 1; s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return s.inflate_flush(z, r); }
internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZStream z) { bl[0] = 9; bd[0] = 5; tl[0] = fixed_tl; td[0] = fixed_td; return 0; }
internal static int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZStream z) { int[] hn = new int[1]; int[] v = new int[0x120]; int num = huft_build(c, 0, nl, 0x101, cplens, cplext, tl, bl, hp, hn, v); if ((num != 0) || (bl[0] == 0)) { if (num == -3) { z.msg = "oversubscribed literal/length tree"; return num; } if (num != -4) { z.msg = "incomplete literal/length tree"; num = -3; } return num; } num = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v); if ((num == 0) && ((bd[0] != 0) || (nl <= 0x101))) { return 0; } if (num == -3) { z.msg = "oversubscribed distance tree"; return num; } if (num == -5) { z.msg = "incomplete distance tree"; return -3; } if (num != -4) { z.msg = "empty distance tree with lengths"; num = -3; } return num; }
internal int inflateSyncPoint(ZStream z) { if (((z != null) && (z.istate != null)) && (z.istate.blocks != null)) { return z.istate.blocks.sync_point(); } return -2; }
internal int inflateSetDictionary(ZStream z, byte[] dictionary, int dictLength) { int start = 0; int n = dictLength; if (((z == null) || (z.istate == null)) || (z.istate.mode != 6)) { return -2; } if (z._adler.adler32(1L, dictionary, 0, dictLength) != z.adler) { return -3; } z.adler = z._adler.adler32(0L, null, 0, 0); if (n >= (((int)1) << z.istate.wbits)) { n = (((int)1) << z.istate.wbits) - 1; start = dictLength - n; } z.istate.blocks.set_dictionary(dictionary, start, n); z.istate.mode = 7; return 0; }
internal int inflateInit(ZStream z, int w) { z.msg = null; this.blocks = null; this.nowrap = 0; if (w < 0) { w = -w; this.nowrap = 1; } if ((w < 8) || (w > 15)) { this.inflateEnd(z); return -2; } this.wbits = w; z.istate.blocks = new InfBlocks(z, (z.istate.nowrap != 0) ? null : this, ((int)1) << w); this.inflateReset(z); return 0; }
internal void free(ZStream z) { this.reset(z, null); this.window = null; this.hufts = null; }
internal void reset(ZStream z, long[] c) { if (c != null) { c[0] = this.check; } if ((this.mode == 4) || (this.mode == 5)) { this.blens = null; } if (this.mode == 6) { this.codes.free(z); } this.mode = 0; this.bitk = 0; this.bitb = 0; this.read = this.write = 0; if (this.checkfn != null) { z.adler = this.check = z._adler.adler32(0L, null, 0, 0); } }
internal void free(ZStream z) { }
internal int proc(ZStream z, int r) { int table; int sourceIndex = z.next_in_index; int num5 = z.avail_in; int bitb = this.bitb; int bitk = this.bitk; int write = this.write; int num7 = (write < this.read) ? ((this.read - write) - 1) : (this.end - write); Label_0047: switch (this.mode) { case 0: while (bitk < 3) { if (num5 != 0) { r = 0; } else { this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } num5--; bitb |= (z.next_in[sourceIndex++] & 0xff) << bitk; bitk += 8; } table = bitb & 7; this.last = table & 1; switch (SupportClass.URShift(table, 1)) { case 0: bitb = SupportClass.URShift(bitb, 3); bitk -= 3; table = bitk & 7; bitb = SupportClass.URShift(bitb, table); bitk -= table; this.mode = 1; goto Label_0047; case 1: { int[] numArray = new int[1]; int[] numArray2 = new int[1]; int[][] numArray3 = new int[1][]; int[][] numArray4 = new int[1][]; InfTree.inflate_trees_fixed(numArray, numArray2, numArray3, numArray4, z); this.codes = new InfCodes(numArray[0], numArray2[0], numArray3[0], numArray4[0], z); bitb = SupportClass.URShift(bitb, 3); bitk -= 3; this.mode = 6; goto Label_0047; } case 2: bitb = SupportClass.URShift(bitb, 3); bitk -= 3; this.mode = 3; goto Label_0047; case 3: bitb = SupportClass.URShift(bitb, 3); bitk -= 3; this.mode = 9; z.msg = "invalid block type"; r = -3; this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } goto Label_0047; case 1: while (bitk < 0x20) { if (num5 != 0) { r = 0; } else { this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } num5--; bitb |= (z.next_in[sourceIndex++] & 0xff) << bitk; bitk += 8; } if ((SupportClass.URShift(~bitb, 0x10) & 0xffff) != (bitb & 0xffff)) { this.mode = 9; z.msg = "invalid stored block lengths"; r = -3; this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } this.left = bitb & 0xffff; bitb = bitk = 0; this.mode = (this.left != 0) ? 2 : ((this.last != 0) ? 7 : 0); goto Label_0047; case 2: if (num5 != 0) { if (num7 == 0) { if ((write == this.end) && (this.read != 0)) { write = 0; num7 = (write < this.read) ? ((this.read - write) - 1) : (this.end - write); } if (num7 == 0) { this.write = write; r = this.inflate_flush(z, r); write = this.write; num7 = (write < this.read) ? ((this.read - write) - 1) : (this.end - write); if ((write == this.end) && (this.read != 0)) { write = 0; num7 = (write < this.read) ? ((this.read - write) - 1) : (this.end - write); } if (num7 == 0) { this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } } } r = 0; table = this.left; if (table > num5) { table = num5; } if (table > num7) { table = num7; } Array.Copy(z.next_in, sourceIndex, this.window, write, table); sourceIndex += table; num5 -= table; write += table; num7 -= table; this.left -= table; if (this.left == 0) { this.mode = (this.last != 0) ? 7 : 0; } goto Label_0047; } this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); case 3: while (bitk < 14) { if (num5 != 0) { r = 0; } else { this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } num5--; bitb |= (z.next_in[sourceIndex++] & 0xff) << bitk; bitk += 8; } this.table = table = bitb & 0x3fff; if (((table & 0x1f) > 0x1d) || (((table >> 5) & 0x1f) > 0x1d)) { this.mode = 9; z.msg = "too many length or distance symbols"; r = -3; this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } table = (0x102 + (table & 0x1f)) + ((table >> 5) & 0x1f); this.blens = new int[table]; bitb = SupportClass.URShift(bitb, 14); bitk -= 14; this.index = 0; this.mode = 4; break; case 4: break; case 5: goto Label_07B9; case 6: goto Label_0B63; case 7: goto Label_0C2C; case 8: goto Label_0CC1; case 9: r = -3; this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); default: r = -2; this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } while (this.index < (4 + SupportClass.URShift(this.table, 10))) { while (bitk < 3) { if (num5 != 0) { r = 0; } else { this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } num5--; bitb |= (z.next_in[sourceIndex++] & 0xff) << bitk; bitk += 8; } this.blens[border[this.index++]] = bitb & 7; bitb = SupportClass.URShift(bitb, 3); bitk -= 3; } while (this.index < 0x13) { this.blens[border[this.index++]] = 0; } this.bb[0] = 7; table = InfTree.inflate_trees_bits(this.blens, this.bb, this.tb, this.hufts, z); if (table != 0) { r = table; if (r == -3) { this.blens = null; this.mode = 9; } this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } this.index = 0; this.mode = 5; Label_07B9: table = this.table; if (this.index < ((0x102 + (table & 0x1f)) + ((table >> 5) & 0x1f))) { table = this.bb[0]; while (bitk < table) { if (num5 != 0) { r = 0; } else { this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } num5--; bitb |= (z.next_in[sourceIndex++] & 0xff) << bitk; bitk += 8; } int num1 = this.tb[0]; table = this.hufts[((this.tb[0] + (bitb & inflate_mask[table])) * 3) + 1]; int num10 = this.hufts[((this.tb[0] + (bitb & inflate_mask[table])) * 3) + 2]; if (num10 < 0x10) { bitb = SupportClass.URShift(bitb, table); bitk -= table; this.blens[this.index++] = num10; } else { int index = (num10 == 0x12) ? 7 : (num10 - 14); int num9 = (num10 == 0x12) ? 11 : 3; while (bitk < (table + index)) { if (num5 != 0) { r = 0; } else { this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } num5--; bitb |= (z.next_in[sourceIndex++] & 0xff) << bitk; bitk += 8; } bitb = SupportClass.URShift(bitb, table); bitk -= table; num9 += bitb & inflate_mask[index]; bitb = SupportClass.URShift(bitb, index); bitk -= index; index = this.index; table = this.table; if (((index + num9) > ((0x102 + (table & 0x1f)) + ((table >> 5) & 0x1f))) || ((num10 == 0x10) && (index < 1))) { this.blens = null; this.mode = 9; z.msg = "invalid bit length repeat"; r = -3; this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } num10 = (num10 == 0x10) ? this.blens[index - 1] : 0; do { this.blens[index++] = num10; } while (--num9 != 0); this.index = index; } goto Label_07B9; } this.tb[0] = -1; int[] bl = new int[1]; int[] bd = new int[1]; int[] tl = new int[1]; int[] td = new int[1]; bl[0] = 9; bd[0] = 6; table = this.table; table = InfTree.inflate_trees_dynamic(0x101 + (table & 0x1f), 1 + ((table >> 5) & 0x1f), this.blens, bl, bd, tl, td, this.hufts, z); switch (table) { case 0: this.codes = new InfCodes(bl[0], bd[0], this.hufts, tl[0], this.hufts, td[0], z); this.blens = null; this.mode = 6; goto Label_0B63; case -3: this.blens = null; this.mode = 9; break; } r = table; this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); Label_0B63: this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; if ((r = this.codes.proc(this, z, r)) != 1) { return this.inflate_flush(z, r); } r = 0; this.codes.free(z); sourceIndex = z.next_in_index; num5 = z.avail_in; bitb = this.bitb; bitk = this.bitk; write = this.write; num7 = (write < this.read) ? ((this.read - write) - 1) : (this.end - write); if (this.last == 0) { this.mode = 0; goto Label_0047; } this.mode = 7; Label_0C2C: this.write = write; r = this.inflate_flush(z, r); write = this.write; num7 = (write < this.read) ? ((this.read - write) - 1) : (this.end - write); if (this.read != this.write) { this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); } this.mode = 8; Label_0CC1: r = 1; this.bitb = bitb; this.bitk = bitk; z.avail_in = num5; z.total_in += sourceIndex - z.next_in_index; z.next_in_index = sourceIndex; this.write = write; return this.inflate_flush(z, r); }
internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z) { int num12; int num6 = z.next_in_index; int num7 = z.avail_in; int bitb = s.bitb; int bitk = s.bitk; int write = s.write; int num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); int num10 = inflate_mask[bl]; int num11 = inflate_mask[bd]; Label_0092: while (bitk < 20) { num7--; bitb |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } int num = bitb & num10; int[] numArray = tl; int num2 = tl_index; int index = numArray[(num2 + num) * 3]; if (index == 0) { bitb = bitb >> numArray[((num2 + num) * 3) + 1]; bitk -= numArray[((num2 + num) * 3) + 1]; s.window[write++] = (byte)numArray[((num2 + num) * 3) + 2]; num9--; goto Label_05E0; } Label_00F1: bitb = bitb >> numArray[((num2 + num) * 3) + 1]; bitk -= numArray[((num2 + num) * 3) + 1]; if ((index & 0x10) == 0) { if ((index & 0x40) == 0) { num += numArray[((num2 + num) * 3) + 2]; num += bitb & inflate_mask[index]; index = numArray[(num2 + num) * 3]; if (index != 0) { goto Label_00F1; } bitb = bitb >> numArray[((num2 + num) * 3) + 1]; bitk -= numArray[((num2 + num) * 3) + 1]; s.window[write++] = (byte)numArray[((num2 + num) * 3) + 2]; num9--; } else { if ((index & 0x20) != 0) { num12 = z.avail_in - num7; num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12; num7 += num12; num6 -= num12; bitk -= num12 << 3; s.bitb = bitb; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(1); } z.msg = "invalid literal/length code"; num12 = z.avail_in - num7; num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12; num7 += num12; num6 -= num12; bitk -= num12 << 3; s.bitb = bitb; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(-3); } goto Label_05E0; } index &= 15; num12 = numArray[((num2 + num) * 3) + 2] + (bitb & inflate_mask[index]); bitb = bitb >> index; bitk -= index; while (bitk < 15) { num7--; bitb |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } num = bitb & num11; numArray = td; num2 = td_index; index = numArray[(num2 + num) * 3]; Label_018B: bitb = bitb >> numArray[((num2 + num) * 3) + 1]; bitk -= numArray[((num2 + num) * 3) + 1]; if ((index & 0x10) != 0) { int num14; index &= 15; while (bitk < index) { num7--; bitb |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } int num13 = numArray[((num2 + num) * 3) + 2] + (bitb & inflate_mask[index]); bitb = bitb >> index; bitk -= index; num9 -= num12; if (write >= num13) { num14 = write - num13; if (((write - num14) > 0) && (2 > (write - num14))) { s.window[write++] = s.window[num14++]; num12--; s.window[write++] = s.window[num14++]; num12--; } else { Array.Copy(s.window, num14, s.window, write, 2); write += 2; num14 += 2; num12 -= 2; } } else { num14 = write - num13; do { num14 += s.end; }while (num14 < 0); index = s.end - num14; if (num12 > index) { num12 -= index; if (((write - num14) > 0) && (index > (write - num14))) { do { s.window[write++] = s.window[num14++]; }while (--index != 0); } else { Array.Copy(s.window, num14, s.window, write, index); write += index; num14 += index; index = 0; } num14 = 0; } } if (((write - num14) > 0) && (num12 > (write - num14))) { do { s.window[write++] = s.window[num14++]; }while (--num12 != 0); } else { Array.Copy(s.window, num14, s.window, write, num12); write += num12; num14 += num12; num12 = 0; } } else { if ((index & 0x40) == 0) { num += numArray[((num2 + num) * 3) + 2]; num += bitb & inflate_mask[index]; index = numArray[(num2 + num) * 3]; goto Label_018B; } z.msg = "invalid distance code"; num12 = z.avail_in - num7; num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12; num7 += num12; num6 -= num12; bitk -= num12 << 3; s.bitb = bitb; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(-3); } Label_05E0: if ((num9 >= 0x102) && (num7 >= 10)) { goto Label_0092; } num12 = z.avail_in - num7; num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12; num7 += num12; num6 -= num12; bitk -= num12 << 3; s.bitb = bitb; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(0); }
internal int inflateEnd(ZStream z) { if (this.blocks != null) { this.blocks.free(z); } this.blocks = null; return 0; }
internal int inflateReset(ZStream z) { if ((z == null) || (z.istate == null)) { return -2; } z.total_in = z.total_out = 0L; z.msg = null; z.istate.mode = (z.istate.nowrap != 0) ? 7 : 0; z.istate.blocks.reset(z, null); return 0; }
internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z) { int num12; int num6 = z.next_in_index; int num7 = z.avail_in; int bitb = s.bitb; int bitk = s.bitk; int write = s.write; int num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); int num10 = inflate_mask[bl]; int num11 = inflate_mask[bd]; Label_0092: while (bitk < 20) { num7--; bitb |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } int num = bitb & num10; int[] numArray = tl; int num2 = tl_index; int index = numArray[(num2 + num) * 3]; if (index == 0) { bitb = bitb >> numArray[((num2 + num) * 3) + 1]; bitk -= numArray[((num2 + num) * 3) + 1]; s.window[write++] = (byte)numArray[((num2 + num) * 3) + 2]; num9--; goto Label_05E0; } Label_00F1: bitb = bitb >> numArray[((num2 + num) * 3) + 1]; bitk -= numArray[((num2 + num) * 3) + 1]; if ((index & 0x10) == 0) { if ((index & 0x40) == 0) { num += numArray[((num2 + num) * 3) + 2]; num += bitb & inflate_mask[index]; index = numArray[(num2 + num) * 3]; if (index != 0) { goto Label_00F1; } bitb = bitb >> numArray[((num2 + num) * 3) + 1]; bitk -= numArray[((num2 + num) * 3) + 1]; s.window[write++] = (byte)numArray[((num2 + num) * 3) + 2]; num9--; } else { if ((index & 0x20) != 0) { num12 = z.avail_in - num7; num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12; num7 += num12; num6 -= num12; bitk -= num12 << 3; s.bitb = bitb; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return 1; } z.msg = "invalid literal/length code"; num12 = z.avail_in - num7; num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12; num7 += num12; num6 -= num12; bitk -= num12 << 3; s.bitb = bitb; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return -3; } goto Label_05E0; } index &= 15; num12 = numArray[((num2 + num) * 3) + 2] + (bitb & inflate_mask[index]); bitb = bitb >> index; bitk -= index; while (bitk < 15) { num7--; bitb |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } num = bitb & num11; numArray = td; num2 = td_index; index = numArray[(num2 + num) * 3]; Label_018B: bitb = bitb >> numArray[((num2 + num) * 3) + 1]; bitk -= numArray[((num2 + num) * 3) + 1]; if ((index & 0x10) != 0) { int num14; index &= 15; while (bitk < index) { num7--; bitb |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } int num13 = numArray[((num2 + num) * 3) + 2] + (bitb & inflate_mask[index]); bitb = bitb >> index; bitk -= index; num9 -= num12; if (write >= num13) { num14 = write - num13; if (((write - num14) > 0) && (2 > (write - num14))) { s.window[write++] = s.window[num14++]; num12--; s.window[write++] = s.window[num14++]; num12--; } else { Array.Copy(s.window, num14, s.window, write, 2); write += 2; num14 += 2; num12 -= 2; } } else { num14 = write - num13; do { num14 += s.end; } while (num14 < 0); index = s.end - num14; if (num12 > index) { num12 -= index; if (((write - num14) > 0) && (index > (write - num14))) { do { s.window[write++] = s.window[num14++]; } while (--index != 0); } else { Array.Copy(s.window, num14, s.window, write, index); write += index; num14 += index; index = 0; } num14 = 0; } } if (((write - num14) > 0) && (num12 > (write - num14))) { do { s.window[write++] = s.window[num14++]; } while (--num12 != 0); } else { Array.Copy(s.window, num14, s.window, write, num12); write += num12; num14 += num12; num12 = 0; } } else { if ((index & 0x40) == 0) { num += numArray[((num2 + num) * 3) + 2]; num += bitb & inflate_mask[index]; index = numArray[(num2 + num) * 3]; goto Label_018B; } z.msg = "invalid distance code"; num12 = z.avail_in - num7; num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12; num7 += num12; num6 -= num12; bitk -= num12 << 3; s.bitb = bitb; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return -3; } Label_05E0: if ((num9 >= 0x102) && (num7 >= 10)) { goto Label_0092; } num12 = z.avail_in - num7; num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12; num7 += num12; num6 -= num12; bitk -= num12 << 3; s.bitb = bitb; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return 0; }
internal int inflateSync(ZStream z) { if ((z == null) || (z.istate == null)) { return -2; } if (z.istate.mode != 13) { z.istate.mode = 13; z.istate.marker = 0; } int num = z.avail_in; if (num == 0) { return -5; } int index = z.next_in_index; int marker = z.istate.marker; while ((num != 0) && (marker < 4)) { if (z.next_in[index] == mark[marker]) { marker++; } else if (z.next_in[index] != 0) { marker = 0; } else { marker = 4 - marker; } index++; num--; } z.total_in += index - z.next_in_index; z.next_in_index = index; z.avail_in = num; z.istate.marker = marker; if (marker != 4) { return -3; } long num4 = z.total_in; long num5 = z.total_out; this.inflateReset(z); z.total_in = num4; z.total_out = num5; z.istate.mode = 7; return 0; }
internal static int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZStream z) { int[] hn = new int[1]; int[] v = new int[0x13]; int num = huft_build(c, 0, 0x13, 0x13, null, null, tb, bb, hp, hn, v); if (num == -3) { z.msg = "oversubscribed dynamic bit lengths tree"; return num; } if ((num != -5) && (bb[0] != 0)) { return num; } z.msg = "incomplete dynamic bit lengths tree"; return -3; }
internal int inflate(ZStream z, int f) { if (((z == null) || (z.istate == null)) || (z.next_in == null)) { return -2; } f = (f == 4) ? -5 : 0; int r = -5; Label_0024: switch (z.istate.mode) { case 0: if (z.avail_in != 0) { r = f; z.avail_in--; z.total_in += 1L; if (((z.istate.method = z.next_in[z.next_in_index++]) & 15) != 8) { z.istate.mode = 13; z.msg = "unknown compression method"; z.istate.marker = 5; goto Label_0024; } if (((z.istate.method >> 4) + 8) > z.istate.wbits) { z.istate.mode = 13; z.msg = "invalid window size"; z.istate.marker = 5; goto Label_0024; } z.istate.mode = 1; break; } return r; case 1: break; case 2: goto Label_01EE; case 3: goto Label_0258; case 4: goto Label_02CA; case 5: goto Label_033B; case 6: z.istate.mode = 13; z.msg = "need dictionary"; z.istate.marker = 0; return -2; case 7: r = z.istate.blocks.proc(z, r); if (r != -3) { if (r == 0) { r = f; } if (r != 1) { return r; } r = f; z.istate.blocks.reset(z, z.istate.was); if (z.istate.nowrap != 0) { z.istate.mode = 12; goto Label_0024; } z.istate.mode = 8; goto Label_0468; } z.istate.mode = 13; z.istate.marker = 0; goto Label_0024; case 8: goto Label_0468; case 9: goto Label_04D3; case 10: goto Label_0546; case 11: goto Label_05B8; case 12: goto Label_0667; case 13: return -3; default: return -2; } if (z.avail_in == 0) { return r; } r = f; z.avail_in--; z.total_in += 1L; int num2 = z.next_in[z.next_in_index++] & 0xff; if ((((z.istate.method << 8) + num2) % 0x1f) != 0) { z.istate.mode = 13; z.msg = "incorrect header check"; z.istate.marker = 5; goto Label_0024; } if ((num2 & 0x20) == 0) { z.istate.mode = 7; goto Label_0024; } z.istate.mode = 2; Label_01EE: if (z.avail_in == 0) { return r; } r = f; z.avail_in--; z.total_in += 1L; z.istate.need = ((z.next_in[z.next_in_index++] & 0xff) << 0x18) & -16777216; z.istate.mode = 3; Label_0258: if (z.avail_in == 0) { return r; } r = f; z.avail_in--; z.total_in += 1L; z.istate.need += ((z.next_in[z.next_in_index++] & 0xff) << 0x10) & 0xff0000L; z.istate.mode = 4; Label_02CA: if (z.avail_in == 0) { return r; } r = f; z.avail_in--; z.total_in += 1L; z.istate.need += ((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L; z.istate.mode = 5; Label_033B: if (z.avail_in == 0) { return r; } r = f; z.avail_in--; z.total_in += 1L; z.istate.need += z.next_in[z.next_in_index++] & 0xffL; z.adler = z.istate.need; z.istate.mode = 6; return 2; Label_0468: if (z.avail_in == 0) { return r; } r = f; z.avail_in--; z.total_in += 1L; z.istate.need = ((z.next_in[z.next_in_index++] & 0xff) << 0x18) & -16777216; z.istate.mode = 9; Label_04D3: if (z.avail_in == 0) { return r; } r = f; z.avail_in--; z.total_in += 1L; z.istate.need += ((z.next_in[z.next_in_index++] & 0xff) << 0x10) & 0xff0000L; z.istate.mode = 10; Label_0546: if (z.avail_in == 0) { return r; } r = f; z.avail_in--; z.total_in += 1L; z.istate.need += ((z.next_in[z.next_in_index++] & 0xff) << 8) & 0xff00L; z.istate.mode = 11; Label_05B8: if (z.avail_in == 0) { return r; } r = f; z.avail_in--; z.total_in += 1L; z.istate.need += z.next_in[z.next_in_index++] & 0xffL; if (((int)z.istate.was[0]) != ((int)z.istate.need)) { z.istate.mode = 13; z.msg = "incorrect data check"; z.istate.marker = 5; goto Label_0024; } z.istate.mode = 12; Label_0667: return 1; }
internal int proc(InfBlocks s, ZStream z, int r) { int num; int num10; int number = 0; int bitk = 0; int num6 = 0; num6 = z.next_in_index; int num7 = z.avail_in; number = s.bitb; bitk = s.bitk; int write = s.write; int num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); Label_0051: switch (this.mode) { case 0: if ((num9 < 0x102) || (num7 < 10)) { break; } s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; r = this.inflate_fast(this.lbits, this.dbits, this.ltree, this.ltree_index, this.dtree, this.dtree_index, s, z); num6 = z.next_in_index; num7 = z.avail_in; number = s.bitb; bitk = s.bitk; write = s.write; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); if (r == 0) { break; } this.mode = (r == 1) ? 7 : 9; goto Label_0051; case 1: goto Label_0199; case 2: num = this.get_Renamed; while (bitk < num) { if (num7 != 0) { r = 0; } else { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); } num7--; number |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } this.len += number & inflate_mask[num]; number = number >> num; bitk -= num; this.need = this.dbits; this.tree = this.dtree; this.tree_index = this.dtree_index; this.mode = 3; goto Label_0412; case 3: goto Label_0412; case 4: num = this.get_Renamed; while (bitk < num) { if (num7 != 0) { r = 0; } else { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); } num7--; number |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } this.dist += number & inflate_mask[num]; number = number >> num; bitk -= num; this.mode = 5; goto Label_0635; case 5: goto Label_0635; case 6: if (num9 == 0) { if ((write == s.end) && (s.read != 0)) { write = 0; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); } if (num9 == 0) { s.write = write; r = s.inflate_flush(z, r); write = s.write; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); if ((write == s.end) && (s.read != 0)) { write = 0; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); } if (num9 == 0) { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); } } } r = 0; s.window[write++] = (byte)this.lit; num9--; this.mode = 0; goto Label_0051; case 7: if (bitk > 7) { bitk -= 8; num7++; num6--; } s.write = write; r = s.inflate_flush(z, r); write = s.write; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); if (s.read != s.write) { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); } this.mode = 8; goto Label_098A; case 8: goto Label_098A; case 9: r = -3; s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); default: r = -2; s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); } this.need = this.lbits; this.tree = this.ltree; this.tree_index = this.ltree_index; this.mode = 1; Label_0199: num = this.need; while (bitk < num) { if (num7 != 0) { r = 0; } else { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); } num7--; number |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } int index = (this.tree_index + (number & inflate_mask[num])) * 3; number = SupportClass.URShift(number, this.tree[index + 1]); bitk -= this.tree[index + 1]; int num3 = this.tree[index]; if (num3 == 0) { this.lit = this.tree[index + 2]; this.mode = 6; goto Label_0051; } if ((num3 & 0x10) != 0) { this.get_Renamed = num3 & 15; this.len = this.tree[index + 2]; this.mode = 2; goto Label_0051; } if ((num3 & 0x40) == 0) { this.need = num3; this.tree_index = (index / 3) + this.tree[index + 2]; goto Label_0051; } if ((num3 & 0x20) != 0) { this.mode = 7; goto Label_0051; } this.mode = 9; z.msg = "invalid literal/length code"; r = -3; s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); Label_0412: num = this.need; while (bitk < num) { if (num7 != 0) { r = 0; } else { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); } num7--; number |= (z.next_in[num6++] & 0xff) << bitk; bitk += 8; } index = (this.tree_index + (number & inflate_mask[num])) * 3; number = number >> this.tree[index + 1]; bitk -= this.tree[index + 1]; num3 = this.tree[index]; if ((num3 & 0x10) != 0) { this.get_Renamed = num3 & 15; this.dist = this.tree[index + 2]; this.mode = 4; goto Label_0051; } if ((num3 & 0x40) == 0) { this.need = num3; this.tree_index = (index / 3) + this.tree[index + 2]; goto Label_0051; } this.mode = 9; z.msg = "invalid distance code"; r = -3; s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); Label_0635: num10 = write - this.dist; while (num10 < 0) { num10 += s.end; } while (this.len != 0) { if (num9 == 0) { if ((write == s.end) && (s.read != 0)) { write = 0; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); } if (num9 == 0) { s.write = write; r = s.inflate_flush(z, r); write = s.write; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); if ((write == s.end) && (s.read != 0)) { write = 0; num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write); } if (num9 == 0) { s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); } } } s.window[write++] = s.window[num10++]; num9--; if (num10 == s.end) { num10 = 0; } this.len--; } this.mode = 0; goto Label_0051; Label_098A: r = 1; s.bitb = number; s.bitk = bitk; z.avail_in = num7; z.total_in += num6 - z.next_in_index; z.next_in_index = num6; s.write = write; return(s.inflate_flush(z, r)); }