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 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); }