示例#1
0
        internal int proc(ZStream z, int r)
        {
            int t;              // temporary storage
            int b;              // bit buffer
            int k;              // bits in bit buffer
            int p;              // input data pointer
            int n;              // bytes available there
            int q;              // output window write pointer
            int m; {            // bytes to end of window or read pointer
                // copy input/output information to locals (UPDATE macro restores)
                p = z.next_in_index; n = z.avail_in; b = bitb; k = bitk;
            } {
                q = write; m = (int)(q < read?read - q - 1:end - q);
            }

            // process input based on current state
            while (true)
            {
                switch (mode)
                {
                case TYPE:

                    while (k < (3))
                    {
                        if (n != 0)
                        {
                            r = Z_OK;
                        }
                        else
                        {
                            bitb        = b; bitk = k;
                            z.avail_in  = n;
                            z.total_in += p - z.next_in_index; z.next_in_index = p;
                            write       = q;
                            return(inflate_flush(z, r));
                        };
                        n--;
                        b |= (z.next_in[p++] & 0xff) << k;
                        k += 8;
                    }
                    t    = (int)(b & 7);
                    last = t & 1;

                    switch (t >> 1)
                    {
                    case 0: {                             // stored
                        b >>= (3); k -= (3);
                    }
                        t = k & 7; {                        // go to byte boundary
                            b >>= (t); k -= (t);
                        }
                        mode = LENS;                      // get length of stored block
                        break;

                    case 1: {                             // fixed
                        int[]   bl = new int[1];
                        int[]   bd = new int[1];
                        int[][] tl = new int[1][];
                        int[][] td = new int[1][];

                        InfTree.inflate_trees_fixed(bl, bd, tl, td, z);
                        codes.init(bl[0], bd[0], tl[0], 0, td[0], 0, z);
                    } {
                            b >>= (3); k -= (3);
                    }

                        mode = CODES;
                        break;

                    case 2: {                             // dynamic
                        b >>= (3); k -= (3);
                    }

                        mode = TABLE;
                        break;

                    case 3: {                             // illegal
                        b >>= (3); k -= (3);
                    }
                        mode  = BAD;
                        z.msg = "invalid block type";
                        r     = Z_DATA_ERROR;

                        bitb       = b; bitk = k;
                        z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                        write      = q;
                        return(inflate_flush(z, r));
                    }
                    break;

                case LENS:

                    while (k < (32))
                    {
                        if (n != 0)
                        {
                            r = Z_OK;
                        }
                        else
                        {
                            bitb        = b; bitk = k;
                            z.avail_in  = n;
                            z.total_in += p - z.next_in_index; z.next_in_index = p;
                            write       = q;
                            return(inflate_flush(z, r));
                        };
                        n--;
                        b |= (z.next_in[p++] & 0xff) << k;
                        k += 8;
                    }

                    if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
                    {
                        mode  = BAD;
                        z.msg = "invalid stored block lengths";
                        r     = Z_DATA_ERROR;

                        bitb       = b; bitk = k;
                        z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                        write      = q;
                        return(inflate_flush(z, r));
                    }
                    left = (b & 0xffff);
                    b    = k = 0;                        // dump bits
                    mode = left != 0 ? STORED : (last != 0 ? DRY : TYPE);
                    break;

                case STORED:
                    if (n == 0)
                    {
                        bitb       = b; bitk = k;
                        z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                        write      = q;
                        return(inflate_flush(z, r));
                    }

                    if (m == 0)
                    {
                        if (q == end && read != 0)
                        {
                            q = 0; m = (int)(q < read?read - q - 1:end - q);
                        }
                        if (m == 0)
                        {
                            write = q;
                            r     = inflate_flush(z, r);
                            q     = write; m = (int)(q < read?read - q - 1:end - q);
                            if (q == end && read != 0)
                            {
                                q = 0; m = (int)(q < read?read - q - 1:end - q);
                            }
                            if (m == 0)
                            {
                                bitb       = b; bitk = k;
                                z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                                write      = q;
                                return(inflate_flush(z, r));
                            }
                        }
                    }
                    r = Z_OK;

                    t = left;
                    if (t > n)
                    {
                        t = n;
                    }
                    if (t > m)
                    {
                        t = m;
                    }
                    System.Array.Copy(z.next_in, p, window, q, t);
                    p += t;  n -= t;
                    q += t;  m -= t;
                    if ((left -= t) != 0)
                    {
                        break;
                    }
                    mode = last != 0 ? DRY : TYPE;
                    break;

                case TABLE:

                    while (k < (14))
                    {
                        if (n != 0)
                        {
                            r = Z_OK;
                        }
                        else
                        {
                            bitb        = b; bitk = k;
                            z.avail_in  = n;
                            z.total_in += p - z.next_in_index; z.next_in_index = p;
                            write       = q;
                            return(inflate_flush(z, r));
                        };
                        n--;
                        b |= (z.next_in[p++] & 0xff) << k;
                        k += 8;
                    }

                    table = t = (b & 0x3fff);
                    if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
                    {
                        mode  = BAD;
                        z.msg = "too many length or distance symbols";
                        r     = Z_DATA_ERROR;

                        bitb       = b; bitk = k;
                        z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                        write      = q;
                        return(inflate_flush(z, r));
                    }
                    t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
                    if (blens == null || blens.Length < t)
                    {
                        blens = new int[t];
                    }
                    else
                    {
                        for (int i = 0; i < t; i++)
                        {
                            blens[i] = 0;
                        }
                    } {
                        b >>= (14); k -= (14);
                    }

                    index = 0;
                    mode  = BTREE;
                    goto case BTREE;

                case BTREE:
                    while (index < 4 + (table >> 10))
                    {
                        while (k < (3))
                        {
                            if (n != 0)
                            {
                                r = Z_OK;
                            }
                            else
                            {
                                bitb        = b; bitk = k;
                                z.avail_in  = n;
                                z.total_in += p - z.next_in_index; z.next_in_index = p;
                                write       = q;
                                return(inflate_flush(z, r));
                            };
                            n--;
                            b |= (z.next_in[p++] & 0xff) << k;
                            k += 8;
                        }

                        blens[border[index++]] = b & 7; {
                            b >>= (3); k -= (3);
                        }
                    }

                    while (index < 19)
                    {
                        blens[border[index++]] = 0;
                    }

                    bb[0] = 7;
                    t     = inftree.inflate_trees_bits(blens, bb, tb, hufts, z);
                    if (t != Z_OK)
                    {
                        r = t;
                        if (r == Z_DATA_ERROR)
                        {
                            blens = null;
                            mode  = BAD;
                        }

                        bitb       = b; bitk = k;
                        z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                        write      = q;
                        return(inflate_flush(z, r));
                    }

                    index = 0;
                    mode  = DTREE;
                    goto case DTREE;

                case DTREE:
                    while (true)
                    {
                        t = table;
                        if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)))
                        {
                            break;
                        }

                        int i, j, c;

                        t = bb[0];

                        while (k < (t))
                        {
                            if (n != 0)
                            {
                                r = Z_OK;
                            }
                            else
                            {
                                bitb        = b; bitk = k;
                                z.avail_in  = n;
                                z.total_in += p - z.next_in_index; z.next_in_index = p;
                                write       = q;
                                return(inflate_flush(z, r));
                            };
                            n--;
                            b |= (z.next_in[p++] & 0xff) << k;
                            k += 8;
                        }

                        if (tb[0] == -1)
                        {
                            //System.err.println("null...");
                        }

                        t = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 1];
                        c = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 2];

                        if (c < 16)
                        {
                            b >>= (t); k -= (t);
                            blens[index++] = c;
                        }
                        else       // c == 16..18
                        {
                            i = c == 18 ? 7 : c - 14;
                            j = c == 18 ? 11 : 3;

                            while (k < (t + i))
                            {
                                if (n != 0)
                                {
                                    r = Z_OK;
                                }
                                else
                                {
                                    bitb        = b; bitk = k;
                                    z.avail_in  = n;
                                    z.total_in += p - z.next_in_index; z.next_in_index = p;
                                    write       = q;
                                    return(inflate_flush(z, r));
                                };
                                n--;
                                b |= (z.next_in[p++] & 0xff) << k;
                                k += 8;
                            }

                            b >>= (t); k -= (t);

                            j += (b & inflate_mask[i]);

                            b >>= (i); k -= (i);

                            i = index;
                            t = table;
                            if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
                                (c == 16 && i < 1))
                            {
                                blens = null;
                                mode  = BAD;
                                z.msg = "invalid bit length repeat";
                                r     = Z_DATA_ERROR;

                                bitb       = b; bitk = k;
                                z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                                write      = q;
                                return(inflate_flush(z, r));
                            }

                            c = c == 16 ? blens[i - 1] : 0;
                            do
                            {
                                blens[i++] = c;
                            }while (--j != 0);
                            index = i;
                        }
                    }

                    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;         // must be <= 9 for lookahead assumptions
                        bd[0] = 6;         // must be <= 9 for lookahead assumptions

                        t = table;
                        t = inftree.inflate_trees_dynamic(257 + (t & 0x1f),
                                                          1 + ((t >> 5) & 0x1f),
                                                          blens, bl, bd, tl, td, hufts, z);

                        if (t != Z_OK)
                        {
                            if (t == Z_DATA_ERROR)
                            {
                                blens = null;
                                mode  = BAD;
                            }
                            r = t;

                            bitb       = b; bitk = k;
                            z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                            write      = q;
                            return(inflate_flush(z, r));
                        }
                        codes.init(bl[0], bd[0], hufts, tl[0], hufts, td[0], z);
                    }
                    mode = CODES;
                    goto case CODES;

                case CODES:
                    bitb       = b; bitk = k;
                    z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                    write      = q;

                    if ((r = codes.proc(this, z, r)) != Z_STREAM_END)
                    {
                        return(inflate_flush(z, r));
                    }
                    r = Z_OK;
                    codes.free(z);

                    p = z.next_in_index; n = z.avail_in; b = bitb; k = bitk;
                    q = write; m = (int)(q < read?read - q - 1:end - q);

                    if (last == 0)
                    {
                        mode = TYPE;
                        break;
                    }
                    mode = DRY;
                    goto case DRY;

                case DRY:
                    write = q;
                    r     = inflate_flush(z, r);
                    q     = write; m = (int)(q < read?read - q - 1:end - q);
                    if (read != write)
                    {
                        bitb       = b; bitk = k;
                        z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                        write      = q;
                        return(inflate_flush(z, r));
                    }
                    mode = DONE;
                    goto case DONE;

                case DONE:
                    r = Z_STREAM_END;

                    bitb       = b; bitk = k;
                    z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                    write      = q;
                    return(inflate_flush(z, r));

                case BAD:
                    r = Z_DATA_ERROR;

                    bitb       = b; bitk = k;
                    z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                    write      = q;
                    return(inflate_flush(z, r));

                default:
                    r = Z_STREAM_ERROR;

                    bitb       = b; bitk = k;
                    z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                    write      = q;
                    return(inflate_flush(z, r));
                }
            }
        }
示例#2
0
        internal int proc(ZStream z, int r)
        {
            int num  = z.next_in_index;
            int num2 = z.avail_in;
            int num3 = this.bitb;
            int i    = this.bitk;
            int num4 = this.write;
            int num5 = (num4 < this.read) ? (this.read - num4 - 1) : (this.end - num4);
            int num6;

            while (true)
            {
                switch (this.mode)
                {
                case 0:
                    while (i < 3)
                    {
                        if (num2 == 0)
                        {
                            goto IL_8C;
                        }
                        r = 0;
                        num2--;
                        num3 |= (int)(z.next_in[num++] & 255) << i;
                        i    += 8;
                    }
                    num6      = (num3 & 7);
                    this.last = (num6 & 1);
                    switch (num6 >> 1)
                    {
                    case 0:
                        num3    >>= 3;
                        i        -= 3;
                        num6      = (i & 7);
                        num3    >>= num6;
                        i        -= num6;
                        this.mode = 1;
                        continue;

                    case 1:
                    {
                        int[]   array  = new int[1];
                        int[]   array2 = new int[1];
                        int[][] array3 = new int[1][];
                        int[][] array4 = new int[1][];
                        InfTree.inflate_trees_fixed(array, array2, array3, array4, z);
                        this.codes.init(array[0], array2[0], array3[0], 0, array4[0], 0, z);
                        num3    >>= 3;
                        i        -= 3;
                        this.mode = 6;
                        continue;
                    }

                    case 2:
                        num3    >>= 3;
                        i        -= 3;
                        this.mode = 3;
                        continue;

                    case 3:
                        goto IL_1BE;

                    default:
                        continue;
                    }
                    break;

                case 1:
                    while (i < 32)
                    {
                        if (num2 == 0)
                        {
                            goto IL_22A;
                        }
                        r = 0;
                        num2--;
                        num3 |= (int)(z.next_in[num++] & 255) << i;
                        i    += 8;
                    }
                    if ((~num3 >> 16 & 65535) != (num3 & 65535))
                    {
                        goto Block_8;
                    }
                    this.left = (num3 & 65535);
                    i         = (num3 = 0);
                    this.mode = ((this.left != 0) ? 2 : ((this.last != 0) ? 7 : 0));
                    continue;

                case 2:
                    if (num2 == 0)
                    {
                        goto Block_11;
                    }
                    if (num5 == 0)
                    {
                        if (num4 == this.end && this.read != 0)
                        {
                            num4 = 0;
                            num5 = ((num4 < this.read) ? (this.read - num4 - 1) : (this.end - num4));
                        }
                        if (num5 == 0)
                        {
                            this.write = num4;
                            r          = this.inflate_flush(z, r);
                            num4       = this.write;
                            num5       = ((num4 < this.read) ? (this.read - num4 - 1) : (this.end - num4));
                            if (num4 == this.end && this.read != 0)
                            {
                                num4 = 0;
                                num5 = ((num4 < this.read) ? (this.read - num4 - 1) : (this.end - num4));
                            }
                            if (num5 == 0)
                            {
                                goto Block_21;
                            }
                        }
                    }
                    r    = 0;
                    num6 = this.left;
                    if (num6 > num2)
                    {
                        num6 = num2;
                    }
                    if (num6 > num5)
                    {
                        num6 = num5;
                    }
                    Array.Copy(z.next_in, num, this.window, num4, num6);
                    num  += num6;
                    num2 -= num6;
                    num4 += num6;
                    num5 -= num6;
                    if ((this.left -= num6) == 0)
                    {
                        this.mode = ((this.last != 0) ? 7 : 0);
                        continue;
                    }
                    continue;

                case 3:
                    while (i < 14)
                    {
                        if (num2 == 0)
                        {
                            goto IL_4FE;
                        }
                        r = 0;
                        num2--;
                        num3 |= (int)(z.next_in[num++] & 255) << i;
                        i    += 8;
                    }
                    num6 = (this.table = (num3 & 16383));
                    if ((num6 & 31) > 29 || (num6 >> 5 & 31) > 29)
                    {
                        goto IL_58C;
                    }
                    num6 = 258 + (num6 & 31) + (num6 >> 5 & 31);
                    if (this.blens == null || this.blens.Length < num6)
                    {
                        this.blens = new int[num6];
                    }
                    else
                    {
                        for (int j = 0; j < num6; j++)
                        {
                            this.blens[j] = 0;
                        }
                    }
                    num3     >>= 14;
                    i         -= 14;
                    this.index = 0;
                    this.mode  = 4;
                    goto IL_6F1;

                case 4:
                    goto IL_6F1;

                case 5:
                    goto IL_7CB;

                case 6:
                    goto IL_B71;

                case 7:
                    goto IL_C3A;

                case 8:
                    goto IL_CCF;

                case 9:
                    goto IL_D16;
                }
                break;
IL_6F1:
                while (this.index < 4 + (this.table >> 10))
                {
                    while (i < 3)
                    {
                        if (num2 == 0)
                        {
                            goto IL_65A;
                        }
                        r = 0;
                        num2--;
                        num3 |= (int)(z.next_in[num++] & 255) << i;
                        i    += 8;
                    }
                    this.blens[InfBlocks.border[this.index++]] = (num3 & 7);
                    num3 >>= 3;
                    i     -= 3;
                }
                while (this.index < 19)
                {
                    this.blens[InfBlocks.border[this.index++]] = 0;
                }
                this.bb[0] = 7;
                num6       = this.inftree.inflate_trees_bits(this.blens, this.bb, this.tb, this.hufts, z);
                if (num6 != 0)
                {
                    goto Block_34;
                }
                this.index = 0;
                this.mode  = 5;
                while (true)
                {
IL_7CB:
                    num6 = this.table;
                    if (this.index >= 258 + (num6 & 31) + (num6 >> 5 & 31))
                    {
                        break;
                    }
                    num6 = this.bb[0];
                    while (i < num6)
                    {
                        if (num2 == 0)
                        {
                            goto IL_802;
                        }
                        r = 0;
                        num2--;
                        num3 |= (int)(z.next_in[num++] & 255) << i;
                        i    += 8;
                    }
                    int arg_878_0 = this.tb[0];
                    num6 = this.hufts[(this.tb[0] + (num3 & InfBlocks.inflate_mask[num6])) * 3 + 1];
                    int num7 = this.hufts[(this.tb[0] + (num3 & InfBlocks.inflate_mask[num6])) * 3 + 2];
                    if (num7 < 16)
                    {
                        num3 >>= num6;
                        i     -= num6;
                        this.blens[this.index++] = num7;
                    }
                    else
                    {
                        int num8 = (num7 == 18) ? 7 : (num7 - 14);
                        int num9 = (num7 == 18) ? 11 : 3;
                        while (i < num6 + num8)
                        {
                            if (num2 == 0)
                            {
                                goto IL_910;
                            }
                            r = 0;
                            num2--;
                            num3 |= (int)(z.next_in[num++] & 255) << i;
                            i    += 8;
                        }
                        num3 >>= num6;
                        i     -= num6;
                        num9  += (num3 & InfBlocks.inflate_mask[num8]);
                        num3 >>= num8;
                        i     -= num8;
                        num8   = this.index;
                        num6   = this.table;
                        if (num8 + num9 > 258 + (num6 & 31) + (num6 >> 5 & 31) || (num7 == 16 && num8 < 1))
                        {
                            goto IL_9D8;
                        }
                        num7 = ((num7 == 16) ? this.blens[num8 - 1] : 0);
                        do
                        {
                            this.blens[num8++] = num7;
                        }while (--num9 != 0);
                        this.index = num8;
                    }
                }
                this.tb[0] = -1;
                int[] array5 = new int[1];
                int[] array6 = new int[1];
                int[] array7 = new int[1];
                int[] array8 = new int[1];
                array5[0] = 9;
                array6[0] = 6;
                num6      = this.table;
                num6      = this.inftree.inflate_trees_dynamic(257 + (num6 & 31), 1 + (num6 >> 5 & 31), this.blens, array5, array6, array7, array8, this.hufts, z);
                if (num6 != 0)
                {
                    goto Block_48;
                }
                this.codes.init(array5[0], array6[0], this.hufts, array7[0], this.hufts, array8[0], z);
                this.mode = 6;
IL_B71:
                this.bitb       = num3;
                this.bitk       = i;
                z.avail_in      = num2;
                z.total_in     += (long)(num - z.next_in_index);
                z.next_in_index = num;
                this.write      = num4;
                if ((r = this.codes.proc(this, z, r)) != 1)
                {
                    goto Block_50;
                }
                r = 0;
                this.codes.free(z);
                num  = z.next_in_index;
                num2 = z.avail_in;
                num3 = this.bitb;
                i    = this.bitk;
                num4 = this.write;
                num5 = ((num4 < this.read) ? (this.read - num4 - 1) : (this.end - num4));
                if (this.last != 0)
                {
                    goto IL_C33;
                }
                this.mode = 0;
            }
            r               = -2;
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

IL_8C:
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

IL_1BE:
            num3          >>= 3;
            i              -= 3;
            this.mode       = 9;
            z.msg           = "invalid block type";
            r               = -3;
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

IL_22A:
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

Block_8:
            this.mode       = 9;
            z.msg           = "invalid stored block lengths";
            r               = -3;
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

Block_11:
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

Block_21:
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

IL_4FE:
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

IL_58C:
            this.mode       = 9;
            z.msg           = "too many length or distance symbols";
            r               = -3;
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

IL_65A:
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

Block_34:
            r = num6;
            if (r == -3)
            {
                this.blens = null;
                this.mode  = 9;
            }
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

IL_802:
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

IL_910:
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

IL_9D8:
            this.blens      = null;
            this.mode       = 9;
            z.msg           = "invalid bit length repeat";
            r               = -3;
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

Block_48:
            if (num6 == -3)
            {
                this.blens = null;
                this.mode  = 9;
            }
            r               = num6;
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

Block_50:
            return(this.inflate_flush(z, r));

IL_C33:
            this.mode = 7;
IL_C3A:
            this.write = num4;
            r          = this.inflate_flush(z, r);
            num4       = this.write;
            int arg_C74_0 = (num4 < this.read) ? (this.read - num4 - 1) : (this.end - num4);

            if (this.read != this.write)
            {
                this.bitb       = num3;
                this.bitk       = i;
                z.avail_in      = num2;
                z.total_in     += (long)(num - z.next_in_index);
                z.next_in_index = num;
                this.write      = num4;
                return(this.inflate_flush(z, r));
            }
            this.mode = 8;
IL_CCF:
            r               = 1;
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));

IL_D16:
            r               = -3;
            this.bitb       = num3;
            this.bitk       = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            this.write      = num4;
            return(this.inflate_flush(z, r));
        }
示例#3
0
        internal int proc(ZStream z, int r)
        {
            int num  = z.next_in_index;
            int num2 = z.avail_in;
            int num3 = bitb;
            int i    = bitk;
            int num4 = write;
            int num5 = (num4 >= read) ? (end - num4) : (read - num4 - 1);

            while (true)
            {
                switch (mode)
                {
                case 0:
                {
                    for (; i < 3; i += 8)
                    {
                        if (num2 == 0)
                        {
                            bitb            = num3;
                            bitk            = i;
                            z.avail_in      = num2;
                            z.total_in     += num - z.next_in_index;
                            z.next_in_index = num;
                            write           = num4;
                            return(inflate_flush(z, r));
                        }
                        r = 0;
                        num2--;
                        num3 |= (z.next_in[num++] & 0xFF) << i;
                    }
                    int num7 = num3 & 7;
                    last = (num7 & 1);
                    switch (num7 >> 1)
                    {
                    case 0:
                        num3 >>= 3;
                        i     -= 3;
                        num7   = (i & 7);
                        num3 >>= num7;
                        i     -= num7;
                        mode   = 1;
                        break;

                    case 1:
                    {
                        int[]   array5 = new int[1];
                        int[]   array6 = new int[1];
                        int[][] array7 = new int[1][];
                        int[][] array8 = new int[1][];
                        InfTree.inflate_trees_fixed(array5, array6, array7, array8, z);
                        codes.init(array5[0], array6[0], array7[0], 0, array8[0], 0, z);
                        num3 >>= 3;
                        i     -= 3;
                        mode   = 6;
                        break;
                    }

                    case 2:
                        num3 >>= 3;
                        i     -= 3;
                        mode   = 3;
                        break;

                    case 3:
                        num3          >>= 3;
                        i              -= 3;
                        mode            = 9;
                        z.msg           = "invalid block type";
                        r               = -3;
                        bitb            = num3;
                        bitk            = i;
                        z.avail_in      = num2;
                        z.total_in     += num - z.next_in_index;
                        z.next_in_index = num;
                        write           = num4;
                        return(inflate_flush(z, r));
                    }
                    break;
                }

                case 1:
                    for (; i < 32; i += 8)
                    {
                        if (num2 == 0)
                        {
                            bitb            = num3;
                            bitk            = i;
                            z.avail_in      = num2;
                            z.total_in     += num - z.next_in_index;
                            z.next_in_index = num;
                            write           = num4;
                            return(inflate_flush(z, r));
                        }
                        r = 0;
                        num2--;
                        num3 |= (z.next_in[num++] & 0xFF) << i;
                    }
                    if (((~num3 >> 16) & 0xFFFF) != (num3 & 0xFFFF))
                    {
                        mode            = 9;
                        z.msg           = "invalid stored block lengths";
                        r               = -3;
                        bitb            = num3;
                        bitk            = i;
                        z.avail_in      = num2;
                        z.total_in     += num - z.next_in_index;
                        z.next_in_index = num;
                        write           = num4;
                        return(inflate_flush(z, r));
                    }
                    left = (num3 & 0xFFFF);
                    num3 = (i = 0);
                    mode = ((left != 0) ? 2 : ((last != 0) ? 7 : 0));
                    break;

                case 2:
                {
                    if (num2 == 0)
                    {
                        bitb            = num3;
                        bitk            = i;
                        z.avail_in      = num2;
                        z.total_in     += num - z.next_in_index;
                        z.next_in_index = num;
                        write           = num4;
                        return(inflate_flush(z, r));
                    }
                    if (num5 == 0)
                    {
                        if (num4 == end && read != 0)
                        {
                            num4 = 0;
                            num5 = ((num4 >= read) ? (end - num4) : (read - num4 - 1));
                        }
                        if (num5 == 0)
                        {
                            write = num4;
                            r     = inflate_flush(z, r);
                            num4  = write;
                            num5  = ((num4 >= read) ? (end - num4) : (read - num4 - 1));
                            if (num4 == end && read != 0)
                            {
                                num4 = 0;
                                num5 = ((num4 >= read) ? (end - num4) : (read - num4 - 1));
                            }
                            if (num5 == 0)
                            {
                                bitb            = num3;
                                bitk            = i;
                                z.avail_in      = num2;
                                z.total_in     += num - z.next_in_index;
                                z.next_in_index = num;
                                write           = num4;
                                return(inflate_flush(z, r));
                            }
                        }
                    }
                    r = 0;
                    int num7 = left;
                    if (num7 > num2)
                    {
                        num7 = num2;
                    }
                    if (num7 > num5)
                    {
                        num7 = num5;
                    }
                    Array.Copy(z.next_in, num, window, num4, num7);
                    num  += num7;
                    num2 -= num7;
                    num4 += num7;
                    num5 -= num7;
                    if ((left -= num7) == 0)
                    {
                        mode = ((last != 0) ? 7 : 0);
                    }
                    break;
                }

                case 3:
                {
                    for (; i < 14; i += 8)
                    {
                        if (num2 == 0)
                        {
                            bitb            = num3;
                            bitk            = i;
                            z.avail_in      = num2;
                            z.total_in     += num - z.next_in_index;
                            z.next_in_index = num;
                            write           = num4;
                            return(inflate_flush(z, r));
                        }
                        r = 0;
                        num2--;
                        num3 |= (z.next_in[num++] & 0xFF) << i;
                    }
                    int num7 = table = (num3 & 0x3FFF);
                    if ((num7 & 0x1F) > 29 || ((num7 >> 5) & 0x1F) > 29)
                    {
                        mode            = 9;
                        z.msg           = "too many length or distance symbols";
                        r               = -3;
                        bitb            = num3;
                        bitk            = i;
                        z.avail_in      = num2;
                        z.total_in     += num - z.next_in_index;
                        z.next_in_index = num;
                        write           = num4;
                        return(inflate_flush(z, r));
                    }
                    num7 = 258 + (num7 & 0x1F) + ((num7 >> 5) & 0x1F);
                    if (blens == null || blens.Length < num7)
                    {
                        blens = new int[num7];
                    }
                    else
                    {
                        for (int j = 0; j < num7; j++)
                        {
                            blens[j] = 0;
                        }
                    }
                    num3 >>= 14;
                    i     -= 14;
                    index  = 0;
                    mode   = 4;
                    goto case 4;
                }

                case 4:
                {
                    while (index < 4 + (table >> 10))
                    {
                        for (; i < 3; i += 8)
                        {
                            if (num2 == 0)
                            {
                                bitb            = num3;
                                bitk            = i;
                                z.avail_in      = num2;
                                z.total_in     += num - z.next_in_index;
                                z.next_in_index = num;
                                write           = num4;
                                return(inflate_flush(z, r));
                            }
                            r = 0;
                            num2--;
                            num3 |= (z.next_in[num++] & 0xFF) << i;
                        }
                        blens[border[index++]] = (num3 & 7);
                        num3 >>= 3;
                        i     -= 3;
                    }
                    while (index < 19)
                    {
                        blens[border[index++]] = 0;
                    }
                    bb[0] = 7;
                    int num7 = inftree.inflate_trees_bits(blens, bb, tb, hufts, z);
                    if (num7 != 0)
                    {
                        r = num7;
                        if (r == -3)
                        {
                            blens = null;
                            mode  = 9;
                        }
                        bitb            = num3;
                        bitk            = i;
                        z.avail_in      = num2;
                        z.total_in     += num - z.next_in_index;
                        z.next_in_index = num;
                        write           = num4;
                        return(inflate_flush(z, r));
                    }
                    index = 0;
                    mode  = 5;
                    goto case 5;
                }

                case 5:
                {
                    int num7;
                    while (true)
                    {
                        num7 = table;
                        if (index >= 258 + (num7 & 0x1F) + ((num7 >> 5) & 0x1F))
                        {
                            break;
                        }
                        for (num7 = bb[0]; i < num7; i += 8)
                        {
                            if (num2 == 0)
                            {
                                bitb            = num3;
                                bitk            = i;
                                z.avail_in      = num2;
                                z.total_in     += num - z.next_in_index;
                                z.next_in_index = num;
                                write           = num4;
                                return(inflate_flush(z, r));
                            }
                            r = 0;
                            num2--;
                            num3 |= (z.next_in[num++] & 0xFF) << i;
                        }
                        if (tb[0] == -1)
                        {
                        }
                        num7 = hufts[(tb[0] + (num3 & inflate_mask[num7])) * 3 + 1];
                        int num11 = hufts[(tb[0] + (num3 & inflate_mask[num7])) * 3 + 2];
                        if (num11 < 16)
                        {
                            num3         >>= num7;
                            i             -= num7;
                            blens[index++] = num11;
                        }
                        else
                        {
                            int num12 = (num11 != 18) ? (num11 - 14) : 7;
                            int num13 = (num11 != 18) ? 3 : 11;
                            for (; i < num7 + num12; i += 8)
                            {
                                if (num2 == 0)
                                {
                                    bitb            = num3;
                                    bitk            = i;
                                    z.avail_in      = num2;
                                    z.total_in     += num - z.next_in_index;
                                    z.next_in_index = num;
                                    write           = num4;
                                    return(inflate_flush(z, r));
                                }
                                r = 0;
                                num2--;
                                num3 |= (z.next_in[num++] & 0xFF) << i;
                            }
                            num3 >>= num7;
                            i     -= num7;
                            num13 += (num3 & inflate_mask[num12]);
                            num3 >>= num12;
                            i     -= num12;
                            num12  = index;
                            num7   = table;
                            if (num12 + num13 > 258 + (num7 & 0x1F) + ((num7 >> 5) & 0x1F) || (num11 == 16 && num12 < 1))
                            {
                                blens           = null;
                                mode            = 9;
                                z.msg           = "invalid bit length repeat";
                                r               = -3;
                                bitb            = num3;
                                bitk            = i;
                                z.avail_in      = num2;
                                z.total_in     += num - z.next_in_index;
                                z.next_in_index = num;
                                write           = num4;
                                return(inflate_flush(z, r));
                            }
                            num11 = ((num11 == 16) ? blens[num12 - 1] : 0);
                            do
                            {
                                blens[num12++] = num11;
                            }while (--num13 != 0);
                            index = num12;
                        }
                    }
                    tb[0] = -1;
                    int[] array  = new int[1];
                    int[] array2 = new int[1];
                    int[] array3 = new int[1];
                    int[] array4 = new int[1];
                    array[0]  = 9;
                    array2[0] = 6;
                    num7      = table;
                    num7      = inftree.inflate_trees_dynamic(257 + (num7 & 0x1F), 1 + ((num7 >> 5) & 0x1F), blens, array, array2, array3, array4, hufts, z);
                    switch (num7)
                    {
                    case -3:
                        blens = null;
                        mode  = 9;
                        goto default;

                    default:
                        r               = num7;
                        bitb            = num3;
                        bitk            = i;
                        z.avail_in      = num2;
                        z.total_in     += num - z.next_in_index;
                        z.next_in_index = num;
                        write           = num4;
                        return(inflate_flush(z, r));

                    case 0:
                        break;
                    }
                    codes.init(array[0], array2[0], hufts, array3[0], hufts, array4[0], z);
                    mode = 6;
                    goto case 6;
                }

                case 6:
                    bitb            = num3;
                    bitk            = i;
                    z.avail_in      = num2;
                    z.total_in     += num - z.next_in_index;
                    z.next_in_index = num;
                    write           = num4;
                    if ((r = codes.proc(this, z, r)) != 1)
                    {
                        return(inflate_flush(z, r));
                    }
                    r = 0;
                    codes.free(z);
                    num  = z.next_in_index;
                    num2 = z.avail_in;
                    num3 = bitb;
                    i    = bitk;
                    num4 = write;
                    num5 = ((num4 >= read) ? (end - num4) : (read - num4 - 1));
                    if (last == 0)
                    {
                        mode = 0;
                        break;
                    }
                    mode = 7;
                    goto case 7;

                case 7:
                    write = num4;
                    r     = inflate_flush(z, r);
                    num4  = write;
                    num5  = ((num4 >= read) ? (end - num4) : (read - num4 - 1));
                    if (read != write)
                    {
                        bitb            = num3;
                        bitk            = i;
                        z.avail_in      = num2;
                        z.total_in     += num - z.next_in_index;
                        z.next_in_index = num;
                        write           = num4;
                        return(inflate_flush(z, r));
                    }
                    mode = 8;
                    goto case 8;

                case 8:
                    r               = 1;
                    bitb            = num3;
                    bitk            = i;
                    z.avail_in      = num2;
                    z.total_in     += num - z.next_in_index;
                    z.next_in_index = num;
                    write           = num4;
                    return(inflate_flush(z, r));

                case 9:
                    r               = -3;
                    bitb            = num3;
                    bitk            = i;
                    z.avail_in      = num2;
                    z.total_in     += num - z.next_in_index;
                    z.next_in_index = num;
                    write           = num4;
                    return(inflate_flush(z, r));

                default:
                    r               = -2;
                    bitb            = num3;
                    bitk            = i;
                    z.avail_in      = num2;
                    z.total_in     += num - z.next_in_index;
                    z.next_in_index = num;
                    write           = num4;
                    return(inflate_flush(z, r));
                }
            }
        }
示例#4
0
        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.end - write) : ((this.read - write) - 1);

Label_004D:
            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 ((table >> 1))
                {
                case 0:
                    bitb      = bitb >> 3;
                    bitk     -= 3;
                    table     = bitk & 7;
                    bitb      = bitb >> table;
                    bitk     -= table;
                    this.mode = 1;
                    break;

                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.init(numArray[0], numArray2[0], numArray3[0], 0, numArray4[0], 0, z);
                    bitb      = bitb >> 3;
                    bitk     -= 3;
                    this.mode = 6;
                    break;
                }

                case 2:
                    bitb      = bitb >> 3;
                    bitk     -= 3;
                    this.mode = 3;
                    break;

                case 3:
                    bitb            = 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_004D;

            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 (((~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) ? ((this.last == 0) ? 0 : 7) : 2;
                goto Label_004D;

            case 2:
                if (num5 != 0)
                {
                    if (num7 == 0)
                    {
                        if ((write == this.end) && (this.read != 0))
                        {
                            write = 0;
                            num7  = (write >= this.read) ? (this.end - write) : ((this.read - write) - 1);
                        }
                        if (num7 == 0)
                        {
                            this.write = write;
                            r          = this.inflate_flush(z, r);
                            write      = this.write;
                            num7       = (write >= this.read) ? (this.end - write) : ((this.read - write) - 1);
                            if ((write == this.end) && (this.read != 0))
                            {
                                write = 0;
                                num7  = (write >= this.read) ? (this.end - write) : ((this.read - write) - 1);
                            }
                            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) ? 0 : 7;
                    }
                    goto Label_004D;
                }
                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);
                if ((this.blens == null) || (this.blens.Length < table))
                {
                    this.blens = new int[table];
                }
                else
                {
                    for (int i = 0; i < table; i++)
                    {
                        this.blens[i] = 0;
                    }
                }
                bitb       = bitb >> 14;
                bitk      -= 14;
                this.index = 0;
                this.mode  = 4;
                break;

            case 4:
                break;

            case 5:
                goto Label_0880;

            case 6:
                goto Label_0C72;

            case 7:
                goto Label_0D4C;

            case 8:
                goto Label_0DEF;

            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 + (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  = bitb >> 3;
                bitk -= 3;
            }
            while (this.index < 0x13)
            {
                this.blens[border[this.index++]] = 0;
            }
            this.bb[0] = 7;
            table      = this.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_0880:
            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;
                }
                if (this.tb[0] == -1)
                {
                }
                table = this.hufts[((this.tb[0] + (bitb & inflate_mask[table])) * 3) + 1];
                int num14 = this.hufts[((this.tb[0] + (bitb & inflate_mask[table])) * 3) + 2];
                if (num14 < 0x10)
                {
                    bitb  = bitb >> table;
                    bitk -= table;
                    this.blens[this.index++] = num14;
                }
                else
                {
                    int index = (num14 != 0x12) ? (num14 - 14) : 7;
                    int num13 = (num14 != 0x12) ? 3 : 11;
                    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   = bitb >> table;
                    bitk  -= table;
                    num13 += bitb & inflate_mask[index];
                    bitb   = bitb >> index;
                    bitk  -= index;
                    index  = this.index;
                    table  = this.table;
                    if (((index + num13) > ((0x102 + (table & 0x1f)) + ((table >> 5) & 0x1f))) || ((num14 == 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));
                    }
                    num14 = (num14 != 0x10) ? 0 : this.blens[index - 1];
                    do
                    {
                        this.blens[index++] = num14;
                    }while (--num13 != 0);
                    this.index = index;
                }
                goto Label_0880;
            }
            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 = this.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.init(bl[0], bd[0], this.hufts, tl[0], this.hufts, td[0], z);
                this.mode = 6;
                goto Label_0C72;

            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_0C72:
            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.end - write) : ((this.read - write) - 1);
            if (this.last == 0)
            {
                this.mode = 0;
                goto Label_004D;
            }
            this.mode = 7;
Label_0D4C:
            this.write = write;
            r          = this.inflate_flush(z, r);
            write      = this.write;
            num7       = (write >= this.read) ? (this.end - write) : ((this.read - write) - 1);
            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_0DEF:
            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));
        }