예제 #1
0
        internal int inflateInit(ZStream z, int w)
        {
            z.msg  = null;
            blocks = null;

            // handle undocumented nowrap option (no zlib header or check)
            nowrap = 0;
            if (w < 0)
            {
                w      = -w;
                nowrap = 1;
            }

            // set window size
            if (w < 8 || w > 15)
            {
                inflateEnd(z);
                return(Z_STREAM_ERROR);
            }
            wbits = w;

            z.istate.blocks = new InfBlocks(z, z.istate.nowrap != 0?null:this, 1 << w);

            // reset state
            inflateReset(z);
            return(Z_OK);
        }
예제 #2
0
		internal int inflateEnd(ZStream z)
		{
			if (blocks != null)
				blocks.free(z);
			blocks = null;
			//    ZFREE(z, z->state);
			return Z_OK;
		}
예제 #3
0
 internal int inflateEnd(ZStream z)
 {
     if (this.blocks != null)
     {
         this.blocks.free(z);
     }
     this.blocks = null;
     return(0);
 }
예제 #4
0
 internal int inflateEnd(ZStream z)
 {
     if (blocks != null)
     {
         blocks.free(z);
     }
     blocks = null;
     //    ZFREE(z, z->state);
     return(Z_OK);
 }
예제 #5
0
 internal int inflateInit(ZStream z, int w)
 {
     z.msg       = null;
     this.blocks = null;
     this.nowrap = 0;
     if (w < 0)
     {
         w           = -w;
         this.nowrap = 1;
     }
     if (w >= 8 && w <= 15)
     {
         this.wbits      = w;
         z.istate.blocks = new InfBlocks(z, (z.istate.nowrap != 0) ? null : this, 1 << w);
         this.inflateReset(z);
         return(0);
     }
     this.inflateEnd(z);
     return(-2);
 }
예제 #6
0
        internal int proc(InfBlocks s, ZStream z, int r)
        {
            int j; // temporary storage
                   //int[] t; // temporary pointer
            int tindex; // temporary pointer
            int e; // extra bits or operation
            int b = 0; // bit buffer
            int k = 0; // bits in bit buffer
            int p = 0; // input data pointer
            int n; // bytes available there
            int q; // output window write pointer
            int m; // bytes to end of window or read pointer
            int f; // pointer to copy strings from

            // copy input/output information to locals (UPDATE macro restores)
            p = z.next_in_index; n = z.avail_in; b = s.bitb; k = s.bitk;
            q = s.write; m = q < s.read ? s.read - q - 1 : s.end - q;

            // process input and output based on current state
            while (true)
            {
                switch (mode)
                {
                    // waiting for "i:"=input, "o:"=output, "x:"=nothing
                    case START:  // x: set up for LEN
                        if (m >= 258 && n >= 10)
                        {
                            s.bitb = b; s.bitk = k;
                            z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                            s.write = q;
                            r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z);

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

                            if (r != Z_OK)
                            {
                                mode = r == Z_STREAM_END ? WASH : BADCODE;
                                break;
                            }
                        }
                        need = lbits;
                        tree = ltree;
                        tree_index = ltree_index;

                        mode = LEN;
                        goto case LEN;

                    case LEN:  // i: get length/literal/eob next
                        j = need;

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

                        tindex = (tree_index + (b & inflate_mask[j])) * 3;

                        b = SupportClass.URShift(b, (tree[tindex + 1]));
                        k -= (tree[tindex + 1]);

                        e = tree[tindex];

                        if (e == 0)
                        {
                            // literal
                            lit = tree[tindex + 2];
                            mode = LIT;
                            break;
                        }
                        if ((e & 16) != 0)
                        {
                            // length
                            get_Renamed = e & 15;
                            len = tree[tindex + 2];
                            mode = LENEXT;
                            break;
                        }
                        if ((e & 64) == 0)
                        {
                            // next table
                            need = e;
                            tree_index = tindex / 3 + tree[tindex + 2];
                            break;
                        }
                        if ((e & 32) != 0)
                        {
                            // end of block
                            mode = WASH;
                            break;
                        }
                        mode = BADCODE; // invalid code
                        z.msg = "invalid literal/length code";
                        r = Z_DATA_ERROR;

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

                    case LENEXT:  // i: getting length extra (have base)
                        j = get_Renamed;

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

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

                        b >>= j;
                        k -= j;

                        need = dbits;
                        tree = dtree;
                        tree_index = dtree_index;
                        mode = DIST;
                        goto case DIST;

                    case DIST:  // i: get distance next
                        j = need;

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

                        tindex = (tree_index + (b & inflate_mask[j])) * 3;

                        b >>= tree[tindex + 1];
                        k -= tree[tindex + 1];

                        e = (tree[tindex]);
                        if ((e & 16) != 0)
                        {
                            // distance
                            get_Renamed = e & 15;
                            dist = tree[tindex + 2];
                            mode = DISTEXT;
                            break;
                        }
                        if ((e & 64) == 0)
                        {
                            // next table
                            need = e;
                            tree_index = tindex / 3 + tree[tindex + 2];
                            break;
                        }
                        mode = BADCODE; // invalid code
                        z.msg = "invalid distance code";
                        r = Z_DATA_ERROR;

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

                    case DISTEXT:  // i: getting distance extra
                        j = get_Renamed;

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

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

                        b >>= j;
                        k -= j;

                        mode = COPY;
                        goto case COPY;

                    case COPY:  // o: copying bytes in window, waiting for space
                        f = q - dist;
                        while (f < 0)
                        {
                            // modulo window size-"while" instead
                            f += s.end; // of "if" handles invalid distances
                        }
                        while (len != 0)
                        {
                            if (m == 0)
                            {
                                if (q == s.end && s.read != 0)
                                {
                                    q = 0; m = q < s.read ? s.read - q - 1 : s.end - q;
                                }
                                if (m == 0)
                                {
                                    s.write = q; r = s.inflate_flush(z, r);
                                    q = s.write; m = q < s.read ? s.read - q - 1 : s.end - q;

                                    if (q == s.end && s.read != 0)
                                    {
                                        q = 0; m = q < s.read ? s.read - q - 1 : s.end - q;
                                    }

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

                            s.window[q++] = s.window[f++]; m--;

                            if (f == s.end)
                                f = 0;
                            len--;
                        }
                        mode = START;
                        break;

                    case LIT:  // o: got literal, waiting for output space
                        if (m == 0)
                        {
                            if (q == s.end && s.read != 0)
                            {
                                q = 0; m = q < s.read ? s.read - q - 1 : s.end - q;
                            }
                            if (m == 0)
                            {
                                s.write = q; r = s.inflate_flush(z, r);
                                q = s.write; m = q < s.read ? s.read - q - 1 : s.end - q;

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

                        s.window[q++] = (byte)lit; m--;

                        mode = START;
                        break;

                    case WASH:  // o: got eob, possibly more output
                        if (k > 7)
                        {
                            // return unused byte, if any
                            k -= 8;
                            n++;
                            p--; // can always return one
                        }

                        s.write = q; r = s.inflate_flush(z, r);
                        q = s.write; m = q < s.read ? s.read - q - 1 : s.end - q;

                        if (s.read != s.write)
                        {
                            s.bitb = b; s.bitk = k;
                            z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                            s.write = q;
                            return s.inflate_flush(z, r);
                        }
                        mode = END;
                        goto case END;

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

                    case BADCODE:  // x: got error

                        r = Z_DATA_ERROR;

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

                    default:
                        r = Z_STREAM_ERROR;

                        s.bitb = b; s.bitk = k;
                        z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                        s.write = q;
                        return s.inflate_flush(z, r);
                }
            }
        }
예제 #7
0
        // Called with number of bytes left to write in window at least 258
        // (the maximum string length) and number of input bytes available
        // at least ten.  The ten bytes are six bytes for the longest length/
        // distance pair plus four bytes for overloading the bit buffer.
        internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z)
        {
            int t; // temporary pointer
            int[] tp; // temporary pointer
            int tp_index; // temporary pointer
            int e; // extra bits or operation
            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
            int ml; // mask for literal/length tree
            int md; // mask for distance tree
            int c; // bytes to copy
            int d; // distance back to copy from
            int r; // copy source pointer

            // load input, output, bit values
            p = z.next_in_index; n = z.avail_in; b = s.bitb; k = s.bitk;
            q = s.write; m = q < s.read ? s.read - q - 1 : s.end - q;

            // initialize masks
            ml = inflate_mask[bl];
            md = inflate_mask[bd];

            // do until not enough input or output space for fast loop
            do
            {
                // assume called with m >= 258 && n >= 10
                // get literal/length code
                while (k < (20))
                {
                    // max bits for literal/length code
                    n--;
                    b |= (z.next_in[p++] & 0xff) << k; k += 8;
                }

                t = b & ml;
                tp = tl;
                tp_index = tl_index;
                if ((e = tp[(tp_index + t) * 3]) == 0)
                {
                    b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]);

                    s.window[q++] = (byte)tp[(tp_index + t) * 3 + 2];
                    m--;
                    continue;
                }
                do
                {
                    b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]);

                    if ((e & 16) != 0)
                    {
                        e &= 15;
                        c = tp[(tp_index + t) * 3 + 2] + ((int)b & inflate_mask[e]);

                        b >>= e; k -= e;

                        // decode distance base of block to copy
                        while (k < (15))
                        {
                            // max bits for distance code
                            n--;
                            b |= (z.next_in[p++] & 0xff) << k; k += 8;
                        }

                        t = b & md;
                        tp = td;
                        tp_index = td_index;
                        e = tp[(tp_index + t) * 3];

                        do
                        {
                            b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]);

                            if ((e & 16) != 0)
                            {
                                // get extra bits to add to distance base
                                e &= 15;
                                while (k < (e))
                                {
                                    // get extra bits (up to 13)
                                    n--;
                                    b |= (z.next_in[p++] & 0xff) << k; k += 8;
                                }

                                d = tp[(tp_index + t) * 3 + 2] + (b & inflate_mask[e]);

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

                                // do the copy
                                m -= c;
                                if (q >= d)
                                {
                                    // offset before dest
                                    //  just copy
                                    r = q - d;
                                    if (q - r > 0 && 2 > (q - r))
                                    {
                                        s.window[q++] = s.window[r++]; c--; // minimum count is three,
                                        s.window[q++] = s.window[r++]; c--; // so unroll loop a little
                                    }
                                    else
                                    {
                                        Array.Copy(s.window, r, s.window, q, 2);
                                        q += 2; r += 2; c -= 2;
                                    }
                                }
                                else
                                {
                                    // else offset after destination
                                    r = q - d;
                                    do
                                    {
                                        r += s.end; // force pointer in window
                                    }
                                    while (r < 0); // covers invalid distances
                                    e = s.end - r;
                                    if (c > e)
                                    {
                                        // if source crosses,
                                        c -= e; // wrapped copy
                                        if (q - r > 0 && e > (q - r))
                                        {
                                            do
                                            {
                                                s.window[q++] = s.window[r++];
                                            }
                                            while (--e != 0);
                                        }
                                        else
                                        {
                                            Array.Copy(s.window, r, s.window, q, e);
                                            q += e; r += e; e = 0;
                                        }
                                        r = 0; // copy rest from start of window
                                    }
                                }

                                // copy all or what's left
                                if (q - r > 0 && c > (q - r))
                                {
                                    do
                                    {
                                        s.window[q++] = s.window[r++];
                                    }
                                    while (--c != 0);
                                }
                                else
                                {
                                    Array.Copy(s.window, r, s.window, q, c);
                                    q += c; r += c; c = 0;
                                }
                                break;
                            }
                            else if ((e & 64) == 0)
                            {
                                t += tp[(tp_index + t) * 3 + 2];
                                t += (b & inflate_mask[e]);
                                e = tp[(tp_index + t) * 3];
                            }
                            else
                            {
                                z.msg = "invalid distance code";

                                c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3);

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

                                return Z_DATA_ERROR;
                            }
                        }
                        while (true);
                        break;
                    }

                    if ((e & 64) == 0)
                    {
                        t += tp[(tp_index + t) * 3 + 2];
                        t += (b & inflate_mask[e]);
                        if ((e = tp[(tp_index + t) * 3]) == 0)
                        {
                            b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]);

                            s.window[q++] = (byte)tp[(tp_index + t) * 3 + 2];
                            m--;
                            break;
                        }
                    }
                    else if ((e & 32) != 0)
                    {
                        c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3);

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

                        return Z_STREAM_END;
                    }
                    else
                    {
                        z.msg = "invalid literal/length code";

                        c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3);

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

                        return Z_DATA_ERROR;
                    }
                }
                while (true);
            }
            while (m >= 258 && n >= 10);

            // not enough input or output--restore pointers and return
            c = z.avail_in - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3);

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

            return Z_OK;
        }
예제 #8
0
 internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z)
 {
     int num12;
     int num6 = z.next_in_index;
     int num7 = z.avail_in;
     int num4 = s.bitb;
     int num5 = s.bitk;
     int num8 = s.write;
     int num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
     int num10 = InfCodes.inflate_mask[bl];
     int num11 = InfCodes.inflate_mask[bd];
 Label_0092:
     while (num5 < 20)
     {
         num7--;
         num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
         num5 += 8;
     }
     int num1 = num4 & num10;
     int[] numArray1 = tl;
     int num2 = tl_index;
     int num3 = numArray1[(num2 + num1) * 3];
     if (num3 == 0)
     {
         num4 = num4 >> (numArray1[((num2 + num1) * 3) + 1] & 0x1f);
         num5 -= numArray1[((num2 + num1) * 3) + 1];
         s.window[num8++] = (byte) numArray1[((num2 + num1) * 3) + 2];
         num9--;
         goto Label_05E0;
     }
 Label_00F1:
     num4 = num4 >> (numArray1[((num2 + num1) * 3) + 1] & 0x1f);
     num5 -= numArray1[((num2 + num1) * 3) + 1];
     if ((num3 & 0x10) == 0)
     {
         if ((num3 & 0x40) == 0)
         {
             num1 += numArray1[((num2 + num1) * 3) + 2];
             num1 += num4 & InfCodes.inflate_mask[num3];
             num3 = numArray1[(num2 + num1) * 3];
             if (num3 != 0)
             {
                 goto Label_00F1;
             }
             num4 = num4 >> (numArray1[((num2 + num1) * 3) + 1] & 0x1f);
             num5 -= numArray1[((num2 + num1) * 3) + 1];
             s.window[num8++] = (byte) numArray1[((num2 + num1) * 3) + 2];
             num9--;
         }
         else
         {
             if ((num3 & 0x20) != 0)
             {
                 num12 = z.avail_in - num7;
                 num12 = ((num5 >> 3) < num12) ? (num5 >> 3) : num12;
                 num7 += num12;
                 num6 -= num12;
                 num5 -= num12 << 3;
                 s.bitb = num4;
                 s.bitk = num5;
                 z.avail_in = num7;
                 z.total_in += num6 - z.next_in_index;
                 z.next_in_index = num6;
                 s.write = num8;
                 return 1;
             }
             z.msg = "invalid literal/length code";
             num12 = z.avail_in - num7;
             num12 = ((num5 >> 3) < num12) ? (num5 >> 3) : num12;
             num7 += num12;
             num6 -= num12;
             num5 -= num12 << 3;
             s.bitb = num4;
             s.bitk = num5;
             z.avail_in = num7;
             z.total_in += num6 - z.next_in_index;
             z.next_in_index = num6;
             s.write = num8;
             return -3;
         }
         goto Label_05E0;
     }
     num3 &= 15;
     num12 = numArray1[((num2 + num1) * 3) + 2] + (num4 & InfCodes.inflate_mask[num3]);
     num4 = num4 >> (num3 & 0x1f);
     num5 -= num3;
     while (num5 < 15)
     {
         num7--;
         num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
         num5 += 8;
     }
     num1 = num4 & num11;
     numArray1 = td;
     num2 = td_index;
     num3 = numArray1[(num2 + num1) * 3];
 Label_018B:
     num4 = num4 >> (numArray1[((num2 + num1) * 3) + 1] & 0x1f);
     num5 -= numArray1[((num2 + num1) * 3) + 1];
     if ((num3 & 0x10) != 0)
     {
         int num14;
         num3 &= 15;
         while (num5 < num3)
         {
             num7--;
             num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
             num5 += 8;
         }
         int num13 = numArray1[((num2 + num1) * 3) + 2] + (num4 & InfCodes.inflate_mask[num3]);
         num4 = num4 >> (num3 & 0x1f);
         num5 -= num3;
         num9 -= num12;
         if (num8 >= num13)
         {
             num14 = num8 - num13;
             if (((num8 - num14) > 0) && (2 > (num8 - num14)))
             {
                 s.window[num8++] = s.window[num14++];
                 num12--;
                 s.window[num8++] = s.window[num14++];
                 num12--;
             }
             else
             {
                 Array.Copy(s.window, num14, s.window, num8, 2);
                 num8 += 2;
                 num14 += 2;
                 num12 -= 2;
             }
         }
         else
         {
             num14 = num8 - num13;
             do
             {
                 num14 += s.end;
             }
             while (num14 < 0);
             num3 = s.end - num14;
             if (num12 > num3)
             {
                 num12 -= num3;
                 if (((num8 - num14) > 0) && (num3 > (num8 - num14)))
                 {
                     do
                     {
                         s.window[num8++] = s.window[num14++];
                     }
                     while (--num3 != 0);
                 }
                 else
                 {
                     Array.Copy(s.window, num14, s.window, num8, num3);
                     num8 += num3;
                     num14 += num3;
                     num3 = 0;
                 }
                 num14 = 0;
             }
         }
         if (((num8 - num14) > 0) && (num12 > (num8 - num14)))
         {
             do
             {
                 s.window[num8++] = s.window[num14++];
             }
             while (--num12 != 0);
         }
         else
         {
             Array.Copy(s.window, num14, s.window, num8, num12);
             num8 += num12;
             num14 += num12;
             num12 = 0;
         }
     }
     else
     {
         if ((num3 & 0x40) == 0)
         {
             num1 += numArray1[((num2 + num1) * 3) + 2];
             num1 += num4 & InfCodes.inflate_mask[num3];
             num3 = numArray1[(num2 + num1) * 3];
             goto Label_018B;
         }
         z.msg = "invalid distance code";
         num12 = z.avail_in - num7;
         num12 = ((num5 >> 3) < num12) ? (num5 >> 3) : num12;
         num7 += num12;
         num6 -= num12;
         num5 -= num12 << 3;
         s.bitb = num4;
         s.bitk = num5;
         z.avail_in = num7;
         z.total_in += num6 - z.next_in_index;
         z.next_in_index = num6;
         s.write = num8;
         return -3;
     }
 Label_05E0:
     if ((num9 < 0x102) || (num7 < 10))
     {
         num12 = z.avail_in - num7;
         num12 = ((num5 >> 3) < num12) ? (num5 >> 3) : num12;
         num7 += num12;
         num6 -= num12;
         num5 -= num12 << 3;
         s.bitb = num4;
         s.bitk = num5;
         z.avail_in = num7;
         z.total_in += num6 - z.next_in_index;
         z.next_in_index = num6;
         s.write = num8;
         return 0;
     }
     goto Label_0092;
 }
예제 #9
0
        // Called with number of bytes left to write in window at least 258
        // (the maximum string length) and number of input bytes available
        // at least ten.  The ten bytes are six bytes for the longest length/
        // distance pair plus four bytes for overloading the bit buffer.

        internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z)
        {
            int t;             // temporary pointer

            int[] tp;          // temporary pointer
            int   tp_index;    // temporary pointer
            int   e;           // extra bits or operation
            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
            int   ml;          // mask for literal/length tree
            int   md;          // mask for distance tree
            int   c;           // bytes to copy
            int   d;           // distance back to copy from
            int   r;           // copy source pointer

            // load input, output, bit values
            p = z.next_in_index; n = z.avail_in; b = s.bitb; k = s.bitk;
            q = s.write; m = q < s.read?s.read - q - 1:s.end - q;

            // initialize masks
            ml = inflate_mask[bl];
            md = inflate_mask[bd];

            // do until not enough input or output space for fast loop
            do
            {
                // assume called with m >= 258 && n >= 10
                // get literal/length code
                while (k < (20))
                {
                    // max bits for literal/length code
                    n--;
                    b |= (z.next_in[p++] & 0xff) << k; k += 8;
                }

                t        = b & ml;
                tp       = tl;
                tp_index = tl_index;
                if ((e = tp[(tp_index + t) * 3]) == 0)
                {
                    b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]);

                    s.window[q++] = (byte)tp[(tp_index + t) * 3 + 2];
                    m--;
                    continue;
                }
                do
                {
                    b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]);

                    if ((e & 16) != 0)
                    {
                        e &= 15;
                        c  = tp[(tp_index + t) * 3 + 2] + ((int)b & inflate_mask[e]);

                        b >>= e; k -= e;

                        // decode distance base of block to copy
                        while (k < (15))
                        {
                            // max bits for distance code
                            n--;
                            b |= (z.next_in[p++] & 0xff) << k; k += 8;
                        }

                        t        = b & md;
                        tp       = td;
                        tp_index = td_index;
                        e        = tp[(tp_index + t) * 3];

                        do
                        {
                            b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]);

                            if ((e & 16) != 0)
                            {
                                // get extra bits to add to distance base
                                e &= 15;
                                while (k < (e))
                                {
                                    // get extra bits (up to 13)
                                    n--;
                                    b |= (z.next_in[p++] & 0xff) << k; k += 8;
                                }

                                d = tp[(tp_index + t) * 3 + 2] + (b & inflate_mask[e]);

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

                                // do the copy
                                m -= c;
                                if (q >= d)
                                {
                                    // offset before dest
                                    //  just copy
                                    r = q - d;
                                    if (q - r > 0 && 2 > (q - r))
                                    {
                                        s.window[q++] = s.window[r++]; c--;                                         // minimum count is three,
                                        s.window[q++] = s.window[r++]; c--;                                         // so unroll loop a little
                                    }
                                    else
                                    {
                                        Array.Copy(s.window, r, s.window, q, 2);
                                        q += 2; r += 2; c -= 2;
                                    }
                                }
                                else
                                {
                                    // else offset after destination
                                    r = q - d;
                                    do
                                    {
                                        r += s.end;                                    // force pointer in window
                                    }while (r < 0);                                    // covers invalid distances
                                    e = s.end - r;
                                    if (c > e)
                                    {
                                        // if source crosses,
                                        c -= e;                                         // wrapped copy
                                        if (q - r > 0 && e > (q - r))
                                        {
                                            do
                                            {
                                                s.window[q++] = s.window[r++];
                                            }while (--e != 0);
                                        }
                                        else
                                        {
                                            Array.Copy(s.window, r, s.window, q, e);
                                            q += e; r += e; e = 0;
                                        }
                                        r = 0;                                         // copy rest from start of window
                                    }
                                }

                                // copy all or what's left
                                if (q - r > 0 && c > (q - r))
                                {
                                    do
                                    {
                                        s.window[q++] = s.window[r++];
                                    }while (--c != 0);
                                }
                                else
                                {
                                    Array.Copy(s.window, r, s.window, q, c);
                                    q += c; r += c; c = 0;
                                }
                                break;
                            }
                            else if ((e & 64) == 0)
                            {
                                t += tp[(tp_index + t) * 3 + 2];
                                t += (b & inflate_mask[e]);
                                e  = tp[(tp_index + t) * 3];
                            }
                            else
                            {
                                z.msg = "invalid distance code";

                                c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3);

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

                                return(Z_DATA_ERROR);
                            }
                        }while (true);
                        break;
                    }

                    if ((e & 64) == 0)
                    {
                        t += tp[(tp_index + t) * 3 + 2];
                        t += (b & inflate_mask[e]);
                        if ((e = tp[(tp_index + t) * 3]) == 0)
                        {
                            b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]);

                            s.window[q++] = (byte)tp[(tp_index + t) * 3 + 2];
                            m--;
                            break;
                        }
                    }
                    else if ((e & 32) != 0)
                    {
                        c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3);

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

                        return(Z_STREAM_END);
                    }
                    else
                    {
                        z.msg = "invalid literal/length code";

                        c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3);

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

                        return(Z_DATA_ERROR);
                    }
                }while (true);
            }while (m >= 258 && n >= 10);

            // not enough input or output--restore pointers and return
            c = z.avail_in - n; c = (k >> 3) < c?k >> 3:c; n += c; p -= c; k -= (c << 3);

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

            return(Z_OK);
        }
예제 #10
0
        internal int proc(InfBlocks s, ZStream z, int r)
        {
            int num  = z.next_in_index;
            int num2 = z.avail_in;
            int num3 = s.bitb;
            int i    = s.bitk;
            int num4 = s.write;
            int num5 = (num4 < s.read) ? (s.read - num4 - 1) : (s.end - num4);

            while (true)
            {
                int num6;
                switch (this.mode)
                {
                case 0:
                    if (num5 >= 258 && num2 >= 10)
                    {
                        s.bitb          = num3;
                        s.bitk          = i;
                        z.avail_in      = num2;
                        z.total_in     += (long)(num - z.next_in_index);
                        z.next_in_index = num;
                        s.write         = num4;
                        r    = this.inflate_fast((int)this.lbits, (int)this.dbits, this.ltree, this.ltree_index, this.dtree, this.dtree_index, s, z);
                        num  = z.next_in_index;
                        num2 = z.avail_in;
                        num3 = s.bitb;
                        i    = s.bitk;
                        num4 = s.write;
                        num5 = ((num4 < s.read) ? (s.read - num4 - 1) : (s.end - num4));
                        if (r != 0)
                        {
                            this.mode = ((r == 1) ? 7 : 9);
                            continue;
                        }
                    }
                    this.need       = (int)this.lbits;
                    this.tree       = this.ltree;
                    this.tree_index = this.ltree_index;
                    this.mode       = 1;
                    goto IL_199;

                case 1:
                    goto IL_199;

                case 2:
                    num6 = this.get_Renamed;
                    while (i < num6)
                    {
                        if (num2 == 0)
                        {
                            goto IL_34F;
                        }
                        r = 0;
                        num2--;
                        num3 |= (int)(z.next_in[num++] & 255) << i;
                        i    += 8;
                    }
                    this.len       += (num3 & InfCodes.inflate_mask[num6]);
                    num3          >>= num6;
                    i              -= num6;
                    this.need       = (int)this.dbits;
                    this.tree       = this.dtree;
                    this.tree_index = this.dtree_index;
                    this.mode       = 3;
                    goto IL_412;

                case 3:
                    goto IL_412;

                case 4:
                    num6 = this.get_Renamed;
                    while (i < num6)
                    {
                        if (num2 == 0)
                        {
                            goto IL_596;
                        }
                        r = 0;
                        num2--;
                        num3 |= (int)(z.next_in[num++] & 255) << i;
                        i    += 8;
                    }
                    this.dist += (num3 & InfCodes.inflate_mask[num6]);
                    num3     >>= num6;
                    i         -= num6;
                    this.mode  = 5;
                    goto IL_635;

                case 5:
                    goto IL_635;

                case 6:
                    if (num5 == 0)
                    {
                        if (num4 == s.end && s.read != 0)
                        {
                            num4 = 0;
                            num5 = ((num4 < s.read) ? (s.read - num4 - 1) : (s.end - num4));
                        }
                        if (num5 == 0)
                        {
                            s.write = num4;
                            r       = s.inflate_flush(z, r);
                            num4    = s.write;
                            num5    = ((num4 < s.read) ? (s.read - num4 - 1) : (s.end - num4));
                            if (num4 == s.end && s.read != 0)
                            {
                                num4 = 0;
                                num5 = ((num4 < s.read) ? (s.read - num4 - 1) : (s.end - num4));
                            }
                            if (num5 == 0)
                            {
                                goto Block_44;
                            }
                        }
                    }
                    r = 0;
                    s.window[num4++] = (byte)this.lit;
                    num5--;
                    this.mode = 0;
                    continue;

                case 7:
                    goto IL_8DB;

                case 8:
                    goto IL_98A;

                case 9:
                    goto IL_9D4;
                }
                break;
IL_199:
                num6 = this.need;
                while (i < num6)
                {
                    if (num2 == 0)
                    {
                        goto IL_1AB;
                    }
                    r = 0;
                    num2--;
                    num3 |= (int)(z.next_in[num++] & 255) << i;
                    i    += 8;
                }
                int num7 = (this.tree_index + (num3 & InfCodes.inflate_mask[num6])) * 3;
                num3 = SupportClass.URShift(num3, this.tree[num7 + 1]);
                i   -= this.tree[num7 + 1];
                int num8 = this.tree[num7];
                if (num8 == 0)
                {
                    this.lit  = this.tree[num7 + 2];
                    this.mode = 6;
                    continue;
                }
                if ((num8 & 16) != 0)
                {
                    this.get_Renamed = (num8 & 15);
                    this.len         = this.tree[num7 + 2];
                    this.mode        = 2;
                    continue;
                }
                if ((num8 & 64) == 0)
                {
                    this.need       = num8;
                    this.tree_index = num7 / 3 + this.tree[num7 + 2];
                    continue;
                }
                if ((num8 & 32) != 0)
                {
                    this.mode = 7;
                    continue;
                }
                goto IL_2DF;
IL_412:
                num6 = this.need;
                while (i < num6)
                {
                    if (num2 == 0)
                    {
                        goto IL_424;
                    }
                    r = 0;
                    num2--;
                    num3 |= (int)(z.next_in[num++] & 255) << i;
                    i    += 8;
                }
                num7   = (this.tree_index + (num3 & InfCodes.inflate_mask[num6])) * 3;
                num3 >>= this.tree[num7 + 1];
                i     -= this.tree[num7 + 1];
                num8   = this.tree[num7];
                if ((num8 & 16) != 0)
                {
                    this.get_Renamed = (num8 & 15);
                    this.dist        = this.tree[num7 + 2];
                    this.mode        = 4;
                    continue;
                }
                if ((num8 & 64) == 0)
                {
                    this.need       = num8;
                    this.tree_index = num7 / 3 + this.tree[num7 + 2];
                    continue;
                }
                goto IL_526;
IL_635:
                int j;
                for (j = num4 - this.dist; j < 0; j += s.end)
                {
                }
                while (this.len != 0)
                {
                    if (num5 == 0)
                    {
                        if (num4 == s.end && s.read != 0)
                        {
                            num4 = 0;
                            num5 = ((num4 < s.read) ? (s.read - num4 - 1) : (s.end - num4));
                        }
                        if (num5 == 0)
                        {
                            s.write = num4;
                            r       = s.inflate_flush(z, r);
                            num4    = s.write;
                            num5    = ((num4 < s.read) ? (s.read - num4 - 1) : (s.end - num4));
                            if (num4 == s.end && s.read != 0)
                            {
                                num4 = 0;
                                num5 = ((num4 < s.read) ? (s.read - num4 - 1) : (s.end - num4));
                            }
                            if (num5 == 0)
                            {
                                goto Block_32;
                            }
                        }
                    }
                    s.window[num4++] = s.window[j++];
                    num5--;
                    if (j == s.end)
                    {
                        j = 0;
                    }
                    this.len--;
                }
                this.mode = 0;
            }
            r               = -2;
            s.bitb          = num3;
            s.bitk          = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            s.write         = num4;
            return(s.inflate_flush(z, r));

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

IL_2DF:
            this.mode       = 9;
            z.msg           = "invalid literal/length code";
            r               = -3;
            s.bitb          = num3;
            s.bitk          = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            s.write         = num4;
            return(s.inflate_flush(z, r));

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

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

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

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

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

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

IL_8DB:
            if (i > 7)
            {
                i -= 8;
                num2++;
                num--;
            }
            s.write = num4;
            r       = s.inflate_flush(z, r);
            num4    = s.write;
            int arg_92C_0 = (num4 < s.read) ? (s.read - num4 - 1) : (s.end - num4);

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

IL_9D4:
            r               = -3;
            s.bitb          = num3;
            s.bitk          = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            s.write         = num4;
            return(s.inflate_flush(z, r));
        }
예제 #11
0
        internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z)
        {
            int num  = z.next_in_index;
            int num2 = z.avail_in;
            int num3 = s.bitb;
            int i    = s.bitk;
            int num4 = s.write;
            int num5 = (num4 < s.read) ? (s.read - num4 - 1) : (s.end - num4);
            int num6 = InfCodes.inflate_mask[bl];
            int num7 = InfCodes.inflate_mask[bd];
            int num9;
            int num10;

            while (true)
            {
                if (i >= 20)
                {
                    int num8 = num3 & num6;
                    if ((num9 = tl[(tl_index + num8) * 3]) == 0)
                    {
                        num3           >>= tl[(tl_index + num8) * 3 + 1];
                        i               -= tl[(tl_index + num8) * 3 + 1];
                        s.window[num4++] = (byte)tl[(tl_index + num8) * 3 + 2];
                        num5--;
                    }
                    else
                    {
                        while (true)
                        {
                            num3 >>= tl[(tl_index + num8) * 3 + 1];
                            i     -= tl[(tl_index + num8) * 3 + 1];
                            if ((num9 & 16) != 0)
                            {
                                break;
                            }
                            if ((num9 & 64) != 0)
                            {
                                goto IL_4D3;
                            }
                            num8 += tl[(tl_index + num8) * 3 + 2];
                            num8 += (num3 & InfCodes.inflate_mask[num9]);
                            if ((num9 = tl[(tl_index + num8) * 3]) == 0)
                            {
                                goto Block_20;
                            }
                        }
                        num9  &= 15;
                        num10  = tl[(tl_index + num8) * 3 + 2] + (num3 & InfCodes.inflate_mask[num9]);
                        num3 >>= num9;
                        for (i -= num9; i < 15; i += 8)
                        {
                            num2--;
                            num3 |= (int)(z.next_in[num++] & 255) << i;
                        }
                        num8 = (num3 & num7);
                        num9 = td[(td_index + num8) * 3];
                        while (true)
                        {
                            num3 >>= td[(td_index + num8) * 3 + 1];
                            i     -= td[(td_index + num8) * 3 + 1];
                            if ((num9 & 16) != 0)
                            {
                                break;
                            }
                            if ((num9 & 64) != 0)
                            {
                                goto IL_3D9;
                            }
                            num8 += td[(td_index + num8) * 3 + 2];
                            num8 += (num3 & InfCodes.inflate_mask[num9]);
                            num9  = td[(td_index + num8) * 3];
                        }
                        num9 &= 15;
                        while (i < num9)
                        {
                            num2--;
                            num3 |= (int)(z.next_in[num++] & 255) << i;
                            i    += 8;
                        }
                        int num11 = td[(td_index + num8) * 3 + 2] + (num3 & InfCodes.inflate_mask[num9]);
                        num3 >>= num9;
                        i     -= num9;
                        num5  -= num10;
                        int num12;
                        if (num4 >= num11)
                        {
                            num12 = num4 - num11;
                            if (num4 - num12 > 0 && 2 > num4 - num12)
                            {
                                s.window[num4++] = s.window[num12++];
                                num10--;
                                s.window[num4++] = s.window[num12++];
                                num10--;
                            }
                            else
                            {
                                Array.Copy(s.window, num12, s.window, num4, 2);
                                num4  += 2;
                                num12 += 2;
                                num10 -= 2;
                            }
                        }
                        else
                        {
                            num12 = num4 - num11;
                            do
                            {
                                num12 += s.end;
                            }while (num12 < 0);
                            num9 = s.end - num12;
                            if (num10 > num9)
                            {
                                num10 -= num9;
                                if (num4 - num12 > 0 && num9 > num4 - num12)
                                {
                                    do
                                    {
                                        s.window[num4++] = s.window[num12++];
                                    }while (--num9 != 0);
                                }
                                else
                                {
                                    Array.Copy(s.window, num12, s.window, num4, num9);
                                    num4  += num9;
                                    num12 += num9;
                                }
                                num12 = 0;
                            }
                        }
                        if (num4 - num12 > 0 && num10 > num4 - num12)
                        {
                            do
                            {
                                s.window[num4++] = s.window[num12++];
                            }while (--num10 != 0);
                            goto IL_5E0;
                        }
                        Array.Copy(s.window, num12, s.window, num4, num10);
                        num4  += num10;
                        num12 += num10;
                        goto IL_5E0;
Block_20:
                        num3           >>= tl[(tl_index + num8) * 3 + 1];
                        i               -= tl[(tl_index + num8) * 3 + 1];
                        s.window[num4++] = (byte)tl[(tl_index + num8) * 3 + 2];
                        num5--;
                    }
IL_5E0:
                    if (num5 < 258 || num2 < 10)
                    {
                        goto IL_5F2;
                    }
                }
                else
                {
                    num2--;
                    num3 |= (int)(z.next_in[num++] & 255) << i;
                    i    += 8;
                }
            }
IL_3D9:
            z.msg           = "invalid distance code";
            num10           = z.avail_in - num2;
            num10           = ((i >> 3 < num10) ? (i >> 3) : num10);
            num2           += num10;
            num            -= num10;
            i              -= num10 << 3;
            s.bitb          = num3;
            s.bitk          = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            s.write         = num4;
            return(-3);

IL_4D3:
            if ((num9 & 32) != 0)
            {
                num10           = z.avail_in - num2;
                num10           = ((i >> 3 < num10) ? (i >> 3) : num10);
                num2           += num10;
                num            -= num10;
                i              -= num10 << 3;
                s.bitb          = num3;
                s.bitk          = i;
                z.avail_in      = num2;
                z.total_in     += (long)(num - z.next_in_index);
                z.next_in_index = num;
                s.write         = num4;
                return(1);
            }
            z.msg           = "invalid literal/length code";
            num10           = z.avail_in - num2;
            num10           = ((i >> 3 < num10) ? (i >> 3) : num10);
            num2           += num10;
            num            -= num10;
            i              -= num10 << 3;
            s.bitb          = num3;
            s.bitk          = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            s.write         = num4;
            return(-3);

IL_5F2:
            num10           = z.avail_in - num2;
            num10           = ((i >> 3 < num10) ? (i >> 3) : num10);
            num2           += num10;
            num            -= num10;
            i              -= num10 << 3;
            s.bitb          = num3;
            s.bitk          = i;
            z.avail_in      = num2;
            z.total_in     += (long)(num - z.next_in_index);
            z.next_in_index = num;
            s.write         = num4;
            return(0);
        }
예제 #12
0
파일: Inflate.cs 프로젝트: BjkGkh/R106
        internal int inflateInit(ZStream z, int w)
        {
            z.msg = null;
            blocks = null;

            // handle undocumented nowrap option (no zlib header or check)
            nowrap = 0;
            if (w < 0)
            {
                w = - w;
                nowrap = 1;
            }

            // set window size
            if (w < 8 || w > 15)
            {
                inflateEnd(z);
                return Z_STREAM_ERROR;
            }
            wbits = w;

            z.istate.blocks = new InfBlocks(z, z.istate.nowrap != 0?null:this, 1 << w);

            // reset state
            inflateReset(z);
            return Z_OK;
        }
예제 #13
0
 internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z)
 {
     int num12;
     int num6 = z.next_in_index;
     int num7 = z.avail_in;
     int bitb = s.bitb;
     int bitk = s.bitk;
     int write = s.write;
     int num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write);
     int num10 = inflate_mask[bl];
     int num11 = inflate_mask[bd];
 Label_0092:
     while (bitk < 20)
     {
         num7--;
         bitb |= (z.next_in[num6++] & 0xff) << bitk;
         bitk += 8;
     }
     int num = bitb & num10;
     int[] numArray = tl;
     int num2 = tl_index;
     int index = numArray[(num2 + num) * 3];
     if (index == 0)
     {
         bitb = bitb >> numArray[((num2 + num) * 3) + 1];
         bitk -= numArray[((num2 + num) * 3) + 1];
         s.window[write++] = (byte) numArray[((num2 + num) * 3) + 2];
         num9--;
         goto Label_05E0;
     }
 Label_00F1:
     bitb = bitb >> numArray[((num2 + num) * 3) + 1];
     bitk -= numArray[((num2 + num) * 3) + 1];
     if ((index & 0x10) == 0)
     {
         if ((index & 0x40) == 0)
         {
             num += numArray[((num2 + num) * 3) + 2];
             num += bitb & inflate_mask[index];
             index = numArray[(num2 + num) * 3];
             if (index != 0)
             {
                 goto Label_00F1;
             }
             bitb = bitb >> numArray[((num2 + num) * 3) + 1];
             bitk -= numArray[((num2 + num) * 3) + 1];
             s.window[write++] = (byte) numArray[((num2 + num) * 3) + 2];
             num9--;
         }
         else
         {
             if ((index & 0x20) != 0)
             {
                 num12 = z.avail_in - num7;
                 num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12;
                 num7 += num12;
                 num6 -= num12;
                 bitk -= num12 << 3;
                 s.bitb = bitb;
                 s.bitk = bitk;
                 z.avail_in = num7;
                 z.total_in += num6 - z.next_in_index;
                 z.next_in_index = num6;
                 s.write = write;
                 return 1;
             }
             z.msg = "invalid literal/length code";
             num12 = z.avail_in - num7;
             num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12;
             num7 += num12;
             num6 -= num12;
             bitk -= num12 << 3;
             s.bitb = bitb;
             s.bitk = bitk;
             z.avail_in = num7;
             z.total_in += num6 - z.next_in_index;
             z.next_in_index = num6;
             s.write = write;
             return -3;
         }
         goto Label_05E0;
     }
     index &= 15;
     num12 = numArray[((num2 + num) * 3) + 2] + (bitb & inflate_mask[index]);
     bitb = bitb >> index;
     bitk -= index;
     while (bitk < 15)
     {
         num7--;
         bitb |= (z.next_in[num6++] & 0xff) << bitk;
         bitk += 8;
     }
     num = bitb & num11;
     numArray = td;
     num2 = td_index;
     index = numArray[(num2 + num) * 3];
 Label_018B:
     bitb = bitb >> numArray[((num2 + num) * 3) + 1];
     bitk -= numArray[((num2 + num) * 3) + 1];
     if ((index & 0x10) != 0)
     {
         int num14;
         index &= 15;
         while (bitk < index)
         {
             num7--;
             bitb |= (z.next_in[num6++] & 0xff) << bitk;
             bitk += 8;
         }
         int num13 = numArray[((num2 + num) * 3) + 2] + (bitb & inflate_mask[index]);
         bitb = bitb >> index;
         bitk -= index;
         num9 -= num12;
         if (write >= num13)
         {
             num14 = write - num13;
             if (((write - num14) > 0) && (2 > (write - num14)))
             {
                 s.window[write++] = s.window[num14++];
                 num12--;
                 s.window[write++] = s.window[num14++];
                 num12--;
             }
             else
             {
                 Array.Copy(s.window, num14, s.window, write, 2);
                 write += 2;
                 num14 += 2;
                 num12 -= 2;
             }
         }
         else
         {
             num14 = write - num13;
             do
             {
                 num14 += s.end;
             }
             while (num14 < 0);
             index = s.end - num14;
             if (num12 > index)
             {
                 num12 -= index;
                 if (((write - num14) > 0) && (index > (write - num14)))
                 {
                     do
                     {
                         s.window[write++] = s.window[num14++];
                     }
                     while (--index != 0);
                 }
                 else
                 {
                     Array.Copy(s.window, num14, s.window, write, index);
                     write += index;
                     num14 += index;
                     index = 0;
                 }
                 num14 = 0;
             }
         }
         if (((write - num14) > 0) && (num12 > (write - num14)))
         {
             do
             {
                 s.window[write++] = s.window[num14++];
             }
             while (--num12 != 0);
         }
         else
         {
             Array.Copy(s.window, num14, s.window, write, num12);
             write += num12;
             num14 += num12;
             num12 = 0;
         }
     }
     else
     {
         if ((index & 0x40) == 0)
         {
             num += numArray[((num2 + num) * 3) + 2];
             num += bitb & inflate_mask[index];
             index = numArray[(num2 + num) * 3];
             goto Label_018B;
         }
         z.msg = "invalid distance code";
         num12 = z.avail_in - num7;
         num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12;
         num7 += num12;
         num6 -= num12;
         bitk -= num12 << 3;
         s.bitb = bitb;
         s.bitk = bitk;
         z.avail_in = num7;
         z.total_in += num6 - z.next_in_index;
         z.next_in_index = num6;
         s.write = write;
         return -3;
     }
 Label_05E0:
     if ((num9 >= 0x102) && (num7 >= 10))
     {
         goto Label_0092;
     }
     num12 = z.avail_in - num7;
     num12 = ((bitk >> 3) < num12) ? (bitk >> 3) : num12;
     num7 += num12;
     num6 -= num12;
     bitk -= num12 << 3;
     s.bitb = bitb;
     s.bitk = bitk;
     z.avail_in = num7;
     z.total_in += num6 - z.next_in_index;
     z.next_in_index = num6;
     s.write = write;
     return 0;
 }
예제 #14
0
        internal int proc(InfBlocks s, ZStream z, int r)
        {
            int num;
            int num10;
            int number = 0;
            int bitk = 0;
            int num6 = 0;
            num6 = z.next_in_index;
            int num7 = z.avail_in;
            number = s.bitb;
            bitk = s.bitk;
            int write = s.write;
            int num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write);
        Label_0051:
            switch (this.mode)
            {
                case 0:
                    if ((num9 < 0x102) || (num7 < 10))
                    {
                        break;
                    }
                    s.bitb = number;
                    s.bitk = bitk;
                    z.avail_in = num7;
                    z.total_in += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write = write;
                    r = this.inflate_fast(this.lbits, this.dbits, this.ltree, this.ltree_index, this.dtree, this.dtree_index, s, z);
                    num6 = z.next_in_index;
                    num7 = z.avail_in;
                    number = s.bitb;
                    bitk = s.bitk;
                    write = s.write;
                    num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write);
                    if (r == 0)
                    {
                        break;
                    }
                    this.mode = (r == 1) ? 7 : 9;
                    goto Label_0051;

                case 1:
                    goto Label_0199;

                case 2:
                    num = this.get_Renamed;
                    while (bitk < num)
                    {
                        if (num7 != 0)
                        {
                            r = 0;
                        }
                        else
                        {
                            s.bitb = number;
                            s.bitk = bitk;
                            z.avail_in = num7;
                            z.total_in += num6 - z.next_in_index;
                            z.next_in_index = num6;
                            s.write = write;
                            return s.inflate_flush(z, r);
                        }
                        num7--;
                        number |= (z.next_in[num6++] & 0xff) << bitk;
                        bitk += 8;
                    }
                    this.len += number & inflate_mask[num];
                    number = number >> num;
                    bitk -= num;
                    this.need = this.dbits;
                    this.tree = this.dtree;
                    this.tree_index = this.dtree_index;
                    this.mode = 3;
                    goto Label_0412;

                case 3:
                    goto Label_0412;

                case 4:
                    num = this.get_Renamed;
                    while (bitk < num)
                    {
                        if (num7 != 0)
                        {
                            r = 0;
                        }
                        else
                        {
                            s.bitb = number;
                            s.bitk = bitk;
                            z.avail_in = num7;
                            z.total_in += num6 - z.next_in_index;
                            z.next_in_index = num6;
                            s.write = write;
                            return s.inflate_flush(z, r);
                        }
                        num7--;
                        number |= (z.next_in[num6++] & 0xff) << bitk;
                        bitk += 8;
                    }
                    this.dist += number & inflate_mask[num];
                    number = number >> num;
                    bitk -= num;
                    this.mode = 5;
                    goto Label_0635;

                case 5:
                    goto Label_0635;

                case 6:
                    if (num9 == 0)
                    {
                        if ((write == s.end) && (s.read != 0))
                        {
                            write = 0;
                            num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write);
                        }
                        if (num9 == 0)
                        {
                            s.write = write;
                            r = s.inflate_flush(z, r);
                            write = s.write;
                            num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write);
                            if ((write == s.end) && (s.read != 0))
                            {
                                write = 0;
                                num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write);
                            }
                            if (num9 == 0)
                            {
                                s.bitb = number;
                                s.bitk = bitk;
                                z.avail_in = num7;
                                z.total_in += num6 - z.next_in_index;
                                z.next_in_index = num6;
                                s.write = write;
                                return s.inflate_flush(z, r);
                            }
                        }
                    }
                    r = 0;
                    s.window[write++] = (byte) this.lit;
                    num9--;
                    this.mode = 0;
                    goto Label_0051;

                case 7:
                    if (bitk > 7)
                    {
                        bitk -= 8;
                        num7++;
                        num6--;
                    }
                    s.write = write;
                    r = s.inflate_flush(z, r);
                    write = s.write;
                    num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write);
                    if (s.read != s.write)
                    {
                        s.bitb = number;
                        s.bitk = bitk;
                        z.avail_in = num7;
                        z.total_in += num6 - z.next_in_index;
                        z.next_in_index = num6;
                        s.write = write;
                        return s.inflate_flush(z, r);
                    }
                    this.mode = 8;
                    goto Label_098A;

                case 8:
                    goto Label_098A;

                case 9:
                    r = -3;
                    s.bitb = number;
                    s.bitk = bitk;
                    z.avail_in = num7;
                    z.total_in += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write = write;
                    return s.inflate_flush(z, r);

                default:
                    r = -2;
                    s.bitb = number;
                    s.bitk = bitk;
                    z.avail_in = num7;
                    z.total_in += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write = write;
                    return s.inflate_flush(z, r);
            }
            this.need = this.lbits;
            this.tree = this.ltree;
            this.tree_index = this.ltree_index;
            this.mode = 1;
        Label_0199:
            num = this.need;
            while (bitk < num)
            {
                if (num7 != 0)
                {
                    r = 0;
                }
                else
                {
                    s.bitb = number;
                    s.bitk = bitk;
                    z.avail_in = num7;
                    z.total_in += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write = write;
                    return s.inflate_flush(z, r);
                }
                num7--;
                number |= (z.next_in[num6++] & 0xff) << bitk;
                bitk += 8;
            }
            int index = (this.tree_index + (number & inflate_mask[num])) * 3;
            number = SupportClass.URShift(number, this.tree[index + 1]);
            bitk -= this.tree[index + 1];
            int num3 = this.tree[index];
            if (num3 == 0)
            {
                this.lit = this.tree[index + 2];
                this.mode = 6;
                goto Label_0051;
            }
            if ((num3 & 0x10) != 0)
            {
                this.get_Renamed = num3 & 15;
                this.len = this.tree[index + 2];
                this.mode = 2;
                goto Label_0051;
            }
            if ((num3 & 0x40) == 0)
            {
                this.need = num3;
                this.tree_index = (index / 3) + this.tree[index + 2];
                goto Label_0051;
            }
            if ((num3 & 0x20) != 0)
            {
                this.mode = 7;
                goto Label_0051;
            }
            this.mode = 9;
            z.msg = "invalid literal/length code";
            r = -3;
            s.bitb = number;
            s.bitk = bitk;
            z.avail_in = num7;
            z.total_in += num6 - z.next_in_index;
            z.next_in_index = num6;
            s.write = write;
            return s.inflate_flush(z, r);
        Label_0412:
            num = this.need;
            while (bitk < num)
            {
                if (num7 != 0)
                {
                    r = 0;
                }
                else
                {
                    s.bitb = number;
                    s.bitk = bitk;
                    z.avail_in = num7;
                    z.total_in += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write = write;
                    return s.inflate_flush(z, r);
                }
                num7--;
                number |= (z.next_in[num6++] & 0xff) << bitk;
                bitk += 8;
            }
            index = (this.tree_index + (number & inflate_mask[num])) * 3;
            number = number >> this.tree[index + 1];
            bitk -= this.tree[index + 1];
            num3 = this.tree[index];
            if ((num3 & 0x10) != 0)
            {
                this.get_Renamed = num3 & 15;
                this.dist = this.tree[index + 2];
                this.mode = 4;
                goto Label_0051;
            }
            if ((num3 & 0x40) == 0)
            {
                this.need = num3;
                this.tree_index = (index / 3) + this.tree[index + 2];
                goto Label_0051;
            }
            this.mode = 9;
            z.msg = "invalid distance code";
            r = -3;
            s.bitb = number;
            s.bitk = bitk;
            z.avail_in = num7;
            z.total_in += num6 - z.next_in_index;
            z.next_in_index = num6;
            s.write = write;
            return s.inflate_flush(z, r);
        Label_0635:
            num10 = write - this.dist;
            while (num10 < 0)
            {
                num10 += s.end;
            }
            while (this.len != 0)
            {
                if (num9 == 0)
                {
                    if ((write == s.end) && (s.read != 0))
                    {
                        write = 0;
                        num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write);
                    }
                    if (num9 == 0)
                    {
                        s.write = write;
                        r = s.inflate_flush(z, r);
                        write = s.write;
                        num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write);
                        if ((write == s.end) && (s.read != 0))
                        {
                            write = 0;
                            num9 = (write < s.read) ? ((s.read - write) - 1) : (s.end - write);
                        }
                        if (num9 == 0)
                        {
                            s.bitb = number;
                            s.bitk = bitk;
                            z.avail_in = num7;
                            z.total_in += num6 - z.next_in_index;
                            z.next_in_index = num6;
                            s.write = write;
                            return s.inflate_flush(z, r);
                        }
                    }
                }
                s.window[write++] = s.window[num10++];
                num9--;
                if (num10 == s.end)
                {
                    num10 = 0;
                }
                this.len--;
            }
            this.mode = 0;
            goto Label_0051;
        Label_098A:
            r = 1;
            s.bitb = number;
            s.bitk = bitk;
            z.avail_in = num7;
            z.total_in += num6 - z.next_in_index;
            z.next_in_index = num6;
            s.write = write;
            return s.inflate_flush(z, r);
        }
예제 #15
0
        internal int proc(InfBlocks s, ZStream z, int r)
        {
            int num1;
            int num10;
            int num4 = 0;
            int num5 = 0;
            int num6 = 0;

            num6 = z.next_in_index;
            int num7 = z.avail_in;

            num4 = s.bitb;
            num5 = s.bitk;
            int num8 = s.write;
            int num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);

Label_0051:
            switch (this.mode)
            {
            case 0:
                if ((num9 < 0x102) || (num7 < 10))
                {
                    break;
                }
                s.bitb          = num4;
                s.bitk          = num5;
                z.avail_in      = num7;
                z.total_in     += num6 - z.next_in_index;
                z.next_in_index = num6;
                s.write         = num8;
                r    = this.inflate_fast(this.lbits, this.dbits, this.ltree, this.ltree_index, this.dtree, this.dtree_index, s, z);
                num6 = z.next_in_index;
                num7 = z.avail_in;
                num4 = s.bitb;
                num5 = s.bitk;
                num8 = s.write;
                num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                if (r == 0)
                {
                    break;
                }
                this.mode = (r == 1) ? 7 : 9;
                goto Label_0051;

            case 1:
                goto Label_0199;

            case 2:
                num1 = this.get_Renamed;
                while (num5 < num1)
                {
                    if (num7 != 0)
                    {
                        r = 0;
                    }
                    else
                    {
                        s.bitb          = num4;
                        s.bitk          = num5;
                        z.avail_in      = num7;
                        z.total_in     += num6 - z.next_in_index;
                        z.next_in_index = num6;
                        s.write         = num8;
                        return(s.inflate_flush(z, r));
                    }
                    num7--;
                    num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
                    num5 += 8;
                }
                this.len       += num4 & InfCodes.inflate_mask[num1];
                num4            = num4 >> (num1 & 0x1f);
                num5           -= num1;
                this.need       = this.dbits;
                this.tree       = this.dtree;
                this.tree_index = this.dtree_index;
                this.mode       = 3;
                goto Label_0412;

            case 3:
                goto Label_0412;

            case 4:
                num1 = this.get_Renamed;
                while (num5 < num1)
                {
                    if (num7 != 0)
                    {
                        r = 0;
                    }
                    else
                    {
                        s.bitb          = num4;
                        s.bitk          = num5;
                        z.avail_in      = num7;
                        z.total_in     += num6 - z.next_in_index;
                        z.next_in_index = num6;
                        s.write         = num8;
                        return(s.inflate_flush(z, r));
                    }
                    num7--;
                    num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
                    num5 += 8;
                }
                this.dist += num4 & InfCodes.inflate_mask[num1];
                num4       = num4 >> (num1 & 0x1f);
                num5      -= num1;
                this.mode  = 5;
                goto Label_0635;

            case 5:
                goto Label_0635;

            case 6:
                if (num9 == 0)
                {
                    if ((num8 == s.end) && (s.read != 0))
                    {
                        num8 = 0;
                        num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                    }
                    if (num9 == 0)
                    {
                        s.write = num8;
                        r       = s.inflate_flush(z, r);
                        num8    = s.write;
                        num9    = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                        if ((num8 == s.end) && (s.read != 0))
                        {
                            num8 = 0;
                            num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                        }
                        if (num9 == 0)
                        {
                            s.bitb          = num4;
                            s.bitk          = num5;
                            z.avail_in      = num7;
                            z.total_in     += num6 - z.next_in_index;
                            z.next_in_index = num6;
                            s.write         = num8;
                            return(s.inflate_flush(z, r));
                        }
                    }
                }
                r = 0;
                s.window[num8++] = (byte)this.lit;
                num9--;
                this.mode = 0;
                goto Label_0051;

            case 7:
                if (num5 > 7)
                {
                    num5 -= 8;
                    num7++;
                    num6--;
                }
                s.write = num8;
                r       = s.inflate_flush(z, r);
                num8    = s.write;
                num9    = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                if (s.read != s.write)
                {
                    s.bitb          = num4;
                    s.bitk          = num5;
                    z.avail_in      = num7;
                    z.total_in     += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write         = num8;
                    return(s.inflate_flush(z, r));
                }
                this.mode = 8;
                goto Label_098A;

            case 8:
                goto Label_098A;

            case 9:
                r               = -3;
                s.bitb          = num4;
                s.bitk          = num5;
                z.avail_in      = num7;
                z.total_in     += num6 - z.next_in_index;
                z.next_in_index = num6;
                s.write         = num8;
                return(s.inflate_flush(z, r));

            default:
                r               = -2;
                s.bitb          = num4;
                s.bitk          = num5;
                z.avail_in      = num7;
                z.total_in     += num6 - z.next_in_index;
                z.next_in_index = num6;
                s.write         = num8;
                return(s.inflate_flush(z, r));
            }
            this.need       = this.lbits;
            this.tree       = this.ltree;
            this.tree_index = this.ltree_index;
            this.mode       = 1;
Label_0199:
            num1 = this.need;
            while (num5 < num1)
            {
                if (num7 != 0)
                {
                    r = 0;
                }
                else
                {
                    s.bitb          = num4;
                    s.bitk          = num5;
                    z.avail_in      = num7;
                    z.total_in     += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write         = num8;
                    return(s.inflate_flush(z, r));
                }
                num7--;
                num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
                num5 += 8;
            }
            int num2 = (this.tree_index + (num4 & InfCodes.inflate_mask[num1])) * 3;

            num4  = SupportClass.URShift(num4, this.tree[num2 + 1]);
            num5 -= this.tree[num2 + 1];
            int num3 = this.tree[num2];

            if (num3 == 0)
            {
                this.lit  = this.tree[num2 + 2];
                this.mode = 6;
                goto Label_0051;
            }
            if ((num3 & 0x10) != 0)
            {
                this.get_Renamed = num3 & 15;
                this.len         = this.tree[num2 + 2];
                this.mode        = 2;
                goto Label_0051;
            }
            if ((num3 & 0x40) == 0)
            {
                this.need       = num3;
                this.tree_index = (num2 / 3) + this.tree[num2 + 2];
                goto Label_0051;
            }
            if ((num3 & 0x20) != 0)
            {
                this.mode = 7;
                goto Label_0051;
            }
            this.mode       = 9;
            z.msg           = "invalid literal/length code";
            r               = -3;
            s.bitb          = num4;
            s.bitk          = num5;
            z.avail_in      = num7;
            z.total_in     += num6 - z.next_in_index;
            z.next_in_index = num6;
            s.write         = num8;
            return(s.inflate_flush(z, r));

Label_0412:
            num1 = this.need;
            while (num5 < num1)
            {
                if (num7 != 0)
                {
                    r = 0;
                }
                else
                {
                    s.bitb          = num4;
                    s.bitk          = num5;
                    z.avail_in      = num7;
                    z.total_in     += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write         = num8;
                    return(s.inflate_flush(z, r));
                }
                num7--;
                num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
                num5 += 8;
            }
            num2  = (this.tree_index + (num4 & InfCodes.inflate_mask[num1])) * 3;
            num4  = num4 >> (this.tree[num2 + 1] & 0x1f);
            num5 -= this.tree[num2 + 1];
            num3  = this.tree[num2];
            if ((num3 & 0x10) != 0)
            {
                this.get_Renamed = num3 & 15;
                this.dist        = this.tree[num2 + 2];
                this.mode        = 4;
                goto Label_0051;
            }
            if ((num3 & 0x40) == 0)
            {
                this.need       = num3;
                this.tree_index = (num2 / 3) + this.tree[num2 + 2];
                goto Label_0051;
            }
            this.mode       = 9;
            z.msg           = "invalid distance code";
            r               = -3;
            s.bitb          = num4;
            s.bitk          = num5;
            z.avail_in      = num7;
            z.total_in     += num6 - z.next_in_index;
            z.next_in_index = num6;
            s.write         = num8;
            return(s.inflate_flush(z, r));

Label_0635:
            num10 = num8 - this.dist;
            while (num10 < 0)
            {
                num10 += s.end;
            }
            while (this.len != 0)
            {
                if (num9 == 0)
                {
                    if ((num8 == s.end) && (s.read != 0))
                    {
                        num8 = 0;
                        num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                    }
                    if (num9 == 0)
                    {
                        s.write = num8;
                        r       = s.inflate_flush(z, r);
                        num8    = s.write;
                        num9    = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                        if ((num8 == s.end) && (s.read != 0))
                        {
                            num8 = 0;
                            num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                        }
                        if (num9 == 0)
                        {
                            s.bitb          = num4;
                            s.bitk          = num5;
                            z.avail_in      = num7;
                            z.total_in     += num6 - z.next_in_index;
                            z.next_in_index = num6;
                            s.write         = num8;
                            return(s.inflate_flush(z, r));
                        }
                    }
                }
                s.window[num8++] = s.window[num10++];
                num9--;
                if (num10 == s.end)
                {
                    num10 = 0;
                }
                this.len--;
            }
            this.mode = 0;
            goto Label_0051;
Label_098A:
            r               = 1;
            s.bitb          = num4;
            s.bitk          = num5;
            z.avail_in      = num7;
            z.total_in     += num6 - z.next_in_index;
            z.next_in_index = num6;
            s.write         = num8;
            return(s.inflate_flush(z, r));
        }
예제 #16
0
        internal int proc(InfBlocks s, ZStream z, int r)
        {
            int j;             // temporary storage
            //int[] t; // temporary pointer
            int tindex;        // temporary pointer
            int e;             // extra bits or operation
            int b = 0;         // bit buffer
            int k = 0;         // bits in bit buffer
            int p = 0;         // input data pointer
            int n;             // bytes available there
            int q;             // output window write pointer
            int m;             // bytes to end of window or read pointer
            int f;             // pointer to copy strings from

            // copy input/output information to locals (UPDATE macro restores)
            p = z.next_in_index; n = z.avail_in; b = s.bitb; k = s.bitk;
            q = s.write; m = q < s.read?s.read - q - 1:s.end - q;

            // process input and output based on current state
            while (true)
            {
                switch (mode)
                {
                // waiting for "i:"=input, "o:"=output, "x:"=nothing
                case START:                          // x: set up for LEN
                    if (m >= 258 && n >= 10)
                    {
                        s.bitb     = b; s.bitk = k;
                        z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                        s.write    = q;
                        r          = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z);

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

                        if (r != Z_OK)
                        {
                            mode = r == Z_STREAM_END?WASH:BADCODE;
                            break;
                        }
                    }
                    need       = lbits;
                    tree       = ltree;
                    tree_index = ltree_index;

                    mode = LEN;
                    goto case LEN;

                case LEN:                          // i: get length/literal/eob next
                    j = need;

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

                    tindex = (tree_index + (b & inflate_mask[j])) * 3;

                    b  = SupportClass.URShift(b, (tree[tindex + 1]));
                    k -= (tree[tindex + 1]);

                    e = tree[tindex];

                    if (e == 0)
                    {
                        // literal
                        lit  = tree[tindex + 2];
                        mode = LIT;
                        break;
                    }
                    if ((e & 16) != 0)
                    {
                        // length
                        get_Renamed = e & 15;
                        len         = tree[tindex + 2];
                        mode        = LENEXT;
                        break;
                    }
                    if ((e & 64) == 0)
                    {
                        // next table
                        need       = e;
                        tree_index = tindex / 3 + tree[tindex + 2];
                        break;
                    }
                    if ((e & 32) != 0)
                    {
                        // end of block
                        mode = WASH;
                        break;
                    }
                    mode  = BADCODE;                            // invalid code
                    z.msg = "invalid literal/length code";
                    r     = Z_DATA_ERROR;

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


                case LENEXT:                          // i: getting length extra (have base)
                    j = get_Renamed;

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

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

                    b >>= j;
                    k  -= j;

                    need       = dbits;
                    tree       = dtree;
                    tree_index = dtree_index;
                    mode       = DIST;
                    goto case DIST;

                case DIST:                          // i: get distance next
                    j = need;

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

                    tindex = (tree_index + (b & inflate_mask[j])) * 3;

                    b >>= tree[tindex + 1];
                    k  -= tree[tindex + 1];

                    e = (tree[tindex]);
                    if ((e & 16) != 0)
                    {
                        // distance
                        get_Renamed = e & 15;
                        dist        = tree[tindex + 2];
                        mode        = DISTEXT;
                        break;
                    }
                    if ((e & 64) == 0)
                    {
                        // next table
                        need       = e;
                        tree_index = tindex / 3 + tree[tindex + 2];
                        break;
                    }
                    mode  = BADCODE;                            // invalid code
                    z.msg = "invalid distance code";
                    r     = Z_DATA_ERROR;

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


                case DISTEXT:                          // i: getting distance extra
                    j = get_Renamed;

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

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

                    b >>= j;
                    k  -= j;

                    mode = COPY;
                    goto case COPY;

                case COPY:                          // o: copying bytes in window, waiting for space
                    f = q - dist;
                    while (f < 0)
                    {
                        // modulo window size-"while" instead
                        f += s.end;                                 // of "if" handles invalid distances
                    }
                    while (len != 0)
                    {
                        if (m == 0)
                        {
                            if (q == s.end && s.read != 0)
                            {
                                q = 0; m = q < s.read?s.read - q - 1:s.end - q;
                            }
                            if (m == 0)
                            {
                                s.write = q; r = s.inflate_flush(z, r);
                                q       = s.write; m = q < s.read?s.read - q - 1:s.end - q;

                                if (q == s.end && s.read != 0)
                                {
                                    q = 0; m = q < s.read?s.read - q - 1:s.end - q;
                                }

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

                        s.window[q++] = s.window[f++]; m--;

                        if (f == s.end)
                        {
                            f = 0;
                        }
                        len--;
                    }
                    mode = START;
                    break;

                case LIT:                          // o: got literal, waiting for output space
                    if (m == 0)
                    {
                        if (q == s.end && s.read != 0)
                        {
                            q = 0; m = q < s.read?s.read - q - 1:s.end - q;
                        }
                        if (m == 0)
                        {
                            s.write = q; r = s.inflate_flush(z, r);
                            q       = s.write; m = q < s.read?s.read - q - 1:s.end - q;

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

                    s.window[q++] = (byte)lit; m--;

                    mode = START;
                    break;

                case WASH:                          // o: got eob, possibly more output
                    if (k > 7)
                    {
                        // return unused byte, if any
                        k -= 8;
                        n++;
                        p--;                                 // can always return one
                    }

                    s.write = q; r = s.inflate_flush(z, r);
                    q       = s.write; m = q < s.read?s.read - q - 1:s.end - q;

                    if (s.read != s.write)
                    {
                        s.bitb     = b; s.bitk = k;
                        z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                        s.write    = q;
                        return(s.inflate_flush(z, r));
                    }
                    mode = END;
                    goto case END;

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


                case BADCODE:                          // x: got error

                    r = Z_DATA_ERROR;

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


                default:
                    r = Z_STREAM_ERROR;

                    s.bitb     = b; s.bitk = k;
                    z.avail_in = n; z.total_in += p - z.next_in_index; z.next_in_index = p;
                    s.write    = q;
                    return(s.inflate_flush(z, r));
                }
            }
        }
예제 #17
0
        internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z)
        {
            int num12;
            int num6  = z.next_in_index;
            int num7  = z.avail_in;
            int num4  = s.bitb;
            int num5  = s.bitk;
            int num8  = s.write;
            int num9  = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
            int num10 = InfCodes.inflate_mask[bl];
            int num11 = InfCodes.inflate_mask[bd];

Label_0092:
            while (num5 < 20)
            {
                num7--;
                num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
                num5 += 8;
            }
            int num1 = num4 & num10;

            int[] numArray1 = tl;
            int   num2      = tl_index;
            int   num3      = numArray1[(num2 + num1) * 3];

            if (num3 == 0)
            {
                num4             = num4 >> (numArray1[((num2 + num1) * 3) + 1] & 0x1f);
                num5            -= numArray1[((num2 + num1) * 3) + 1];
                s.window[num8++] = (byte)numArray1[((num2 + num1) * 3) + 2];
                num9--;
                goto Label_05E0;
            }
Label_00F1:
            num4  = num4 >> (numArray1[((num2 + num1) * 3) + 1] & 0x1f);
            num5 -= numArray1[((num2 + num1) * 3) + 1];
            if ((num3 & 0x10) == 0)
            {
                if ((num3 & 0x40) == 0)
                {
                    num1 += numArray1[((num2 + num1) * 3) + 2];
                    num1 += num4 & InfCodes.inflate_mask[num3];
                    num3  = numArray1[(num2 + num1) * 3];
                    if (num3 != 0)
                    {
                        goto Label_00F1;
                    }
                    num4             = num4 >> (numArray1[((num2 + num1) * 3) + 1] & 0x1f);
                    num5            -= numArray1[((num2 + num1) * 3) + 1];
                    s.window[num8++] = (byte)numArray1[((num2 + num1) * 3) + 2];
                    num9--;
                }
                else
                {
                    if ((num3 & 0x20) != 0)
                    {
                        num12           = z.avail_in - num7;
                        num12           = ((num5 >> 3) < num12) ? (num5 >> 3) : num12;
                        num7           += num12;
                        num6           -= num12;
                        num5           -= num12 << 3;
                        s.bitb          = num4;
                        s.bitk          = num5;
                        z.avail_in      = num7;
                        z.total_in     += num6 - z.next_in_index;
                        z.next_in_index = num6;
                        s.write         = num8;
                        return(1);
                    }
                    z.msg           = "invalid literal/length code";
                    num12           = z.avail_in - num7;
                    num12           = ((num5 >> 3) < num12) ? (num5 >> 3) : num12;
                    num7           += num12;
                    num6           -= num12;
                    num5           -= num12 << 3;
                    s.bitb          = num4;
                    s.bitk          = num5;
                    z.avail_in      = num7;
                    z.total_in     += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write         = num8;
                    return(-3);
                }
                goto Label_05E0;
            }
            num3 &= 15;
            num12 = numArray1[((num2 + num1) * 3) + 2] + (num4 & InfCodes.inflate_mask[num3]);
            num4  = num4 >> (num3 & 0x1f);
            num5 -= num3;
            while (num5 < 15)
            {
                num7--;
                num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
                num5 += 8;
            }
            num1      = num4 & num11;
            numArray1 = td;
            num2      = td_index;
            num3      = numArray1[(num2 + num1) * 3];
Label_018B:
            num4  = num4 >> (numArray1[((num2 + num1) * 3) + 1] & 0x1f);
            num5 -= numArray1[((num2 + num1) * 3) + 1];
            if ((num3 & 0x10) != 0)
            {
                int num14;
                num3 &= 15;
                while (num5 < num3)
                {
                    num7--;
                    num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
                    num5 += 8;
                }
                int num13 = numArray1[((num2 + num1) * 3) + 2] + (num4 & InfCodes.inflate_mask[num3]);
                num4  = num4 >> (num3 & 0x1f);
                num5 -= num3;
                num9 -= num12;
                if (num8 >= num13)
                {
                    num14 = num8 - num13;
                    if (((num8 - num14) > 0) && (2 > (num8 - num14)))
                    {
                        s.window[num8++] = s.window[num14++];
                        num12--;
                        s.window[num8++] = s.window[num14++];
                        num12--;
                    }
                    else
                    {
                        Array.Copy(s.window, num14, s.window, num8, 2);
                        num8  += 2;
                        num14 += 2;
                        num12 -= 2;
                    }
                }
                else
                {
                    num14 = num8 - num13;
                    do
                    {
                        num14 += s.end;
                    }while (num14 < 0);
                    num3 = s.end - num14;
                    if (num12 > num3)
                    {
                        num12 -= num3;
                        if (((num8 - num14) > 0) && (num3 > (num8 - num14)))
                        {
                            do
                            {
                                s.window[num8++] = s.window[num14++];
                            }while (--num3 != 0);
                        }
                        else
                        {
                            Array.Copy(s.window, num14, s.window, num8, num3);
                            num8  += num3;
                            num14 += num3;
                            num3   = 0;
                        }
                        num14 = 0;
                    }
                }
                if (((num8 - num14) > 0) && (num12 > (num8 - num14)))
                {
                    do
                    {
                        s.window[num8++] = s.window[num14++];
                    }while (--num12 != 0);
                }
                else
                {
                    Array.Copy(s.window, num14, s.window, num8, num12);
                    num8  += num12;
                    num14 += num12;
                    num12  = 0;
                }
            }
            else
            {
                if ((num3 & 0x40) == 0)
                {
                    num1 += numArray1[((num2 + num1) * 3) + 2];
                    num1 += num4 & InfCodes.inflate_mask[num3];
                    num3  = numArray1[(num2 + num1) * 3];
                    goto Label_018B;
                }
                z.msg           = "invalid distance code";
                num12           = z.avail_in - num7;
                num12           = ((num5 >> 3) < num12) ? (num5 >> 3) : num12;
                num7           += num12;
                num6           -= num12;
                num5           -= num12 << 3;
                s.bitb          = num4;
                s.bitk          = num5;
                z.avail_in      = num7;
                z.total_in     += num6 - z.next_in_index;
                z.next_in_index = num6;
                s.write         = num8;
                return(-3);
            }
Label_05E0:
            if ((num9 < 0x102) || (num7 < 10))
            {
                num12           = z.avail_in - num7;
                num12           = ((num5 >> 3) < num12) ? (num5 >> 3) : num12;
                num7           += num12;
                num6           -= num12;
                num5           -= num12 << 3;
                s.bitb          = num4;
                s.bitk          = num5;
                z.avail_in      = num7;
                z.total_in     += num6 - z.next_in_index;
                z.next_in_index = num6;
                s.write         = num8;
                return(0);
            }
            goto Label_0092;
        }
예제 #18
0
        internal int proc(InfBlocks s, ZStream z, int r)
        {
            int num1;
            int num10;
            int num4 = 0;
            int num5 = 0;
            int num6 = 0;
            num6 = z.next_in_index;
            int num7 = z.avail_in;
            num4 = s.bitb;
            num5 = s.bitk;
            int num8 = s.write;
            int num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
        Label_0051:
            switch (this.mode)
            {
                case 0:
                    if ((num9 < 0x102) || (num7 < 10))
                    {
                        break;
                    }
                    s.bitb = num4;
                    s.bitk = num5;
                    z.avail_in = num7;
                    z.total_in += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write = num8;
                    r = this.inflate_fast(this.lbits, this.dbits, this.ltree, this.ltree_index, this.dtree, this.dtree_index, s, z);
                    num6 = z.next_in_index;
                    num7 = z.avail_in;
                    num4 = s.bitb;
                    num5 = s.bitk;
                    num8 = s.write;
                    num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                    if (r == 0)
                    {
                        break;
                    }
                    this.mode = (r == 1) ? 7 : 9;
                    goto Label_0051;

                case 1:
                    goto Label_0199;

                case 2:
                    num1 = this.get_Renamed;
                    while (num5 < num1)
                    {
                        if (num7 != 0)
                        {
                            r = 0;
                        }
                        else
                        {
                            s.bitb = num4;
                            s.bitk = num5;
                            z.avail_in = num7;
                            z.total_in += num6 - z.next_in_index;
                            z.next_in_index = num6;
                            s.write = num8;
                            return s.inflate_flush(z, r);
                        }
                        num7--;
                        num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
                        num5 += 8;
                    }
                    this.len += num4 & InfCodes.inflate_mask[num1];
                    num4 = num4 >> (num1 & 0x1f);
                    num5 -= num1;
                    this.need = this.dbits;
                    this.tree = this.dtree;
                    this.tree_index = this.dtree_index;
                    this.mode = 3;
                    goto Label_0412;

                case 3:
                    goto Label_0412;

                case 4:
                    num1 = this.get_Renamed;
                    while (num5 < num1)
                    {
                        if (num7 != 0)
                        {
                            r = 0;
                        }
                        else
                        {
                            s.bitb = num4;
                            s.bitk = num5;
                            z.avail_in = num7;
                            z.total_in += num6 - z.next_in_index;
                            z.next_in_index = num6;
                            s.write = num8;
                            return s.inflate_flush(z, r);
                        }
                        num7--;
                        num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
                        num5 += 8;
                    }
                    this.dist += num4 & InfCodes.inflate_mask[num1];
                    num4 = num4 >> (num1 & 0x1f);
                    num5 -= num1;
                    this.mode = 5;
                    goto Label_0635;

                case 5:
                    goto Label_0635;

                case 6:
                    if (num9 == 0)
                    {
                        if ((num8 == s.end) && (s.read != 0))
                        {
                            num8 = 0;
                            num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                        }
                        if (num9 == 0)
                        {
                            s.write = num8;
                            r = s.inflate_flush(z, r);
                            num8 = s.write;
                            num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                            if ((num8 == s.end) && (s.read != 0))
                            {
                                num8 = 0;
                                num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                            }
                            if (num9 == 0)
                            {
                                s.bitb = num4;
                                s.bitk = num5;
                                z.avail_in = num7;
                                z.total_in += num6 - z.next_in_index;
                                z.next_in_index = num6;
                                s.write = num8;
                                return s.inflate_flush(z, r);
                            }
                        }
                    }
                    r = 0;
                    s.window[num8++] = (byte) this.lit;
                    num9--;
                    this.mode = 0;
                    goto Label_0051;

                case 7:
                    if (num5 > 7)
                    {
                        num5 -= 8;
                        num7++;
                        num6--;
                    }
                    s.write = num8;
                    r = s.inflate_flush(z, r);
                    num8 = s.write;
                    num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                    if (s.read != s.write)
                    {
                        s.bitb = num4;
                        s.bitk = num5;
                        z.avail_in = num7;
                        z.total_in += num6 - z.next_in_index;
                        z.next_in_index = num6;
                        s.write = num8;
                        return s.inflate_flush(z, r);
                    }
                    this.mode = 8;
                    goto Label_098A;

                case 8:
                    goto Label_098A;

                case 9:
                    r = -3;
                    s.bitb = num4;
                    s.bitk = num5;
                    z.avail_in = num7;
                    z.total_in += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write = num8;
                    return s.inflate_flush(z, r);

                default:
                    r = -2;
                    s.bitb = num4;
                    s.bitk = num5;
                    z.avail_in = num7;
                    z.total_in += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write = num8;
                    return s.inflate_flush(z, r);
            }
            this.need = this.lbits;
            this.tree = this.ltree;
            this.tree_index = this.ltree_index;
            this.mode = 1;
        Label_0199:
            num1 = this.need;
            while (num5 < num1)
            {
                if (num7 != 0)
                {
                    r = 0;
                }
                else
                {
                    s.bitb = num4;
                    s.bitk = num5;
                    z.avail_in = num7;
                    z.total_in += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write = num8;
                    return s.inflate_flush(z, r);
                }
                num7--;
                num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
                num5 += 8;
            }
            int num2 = (this.tree_index + (num4 & InfCodes.inflate_mask[num1])) * 3;
            num4 = SupportClass.URShift(num4, this.tree[num2 + 1]);
            num5 -= this.tree[num2 + 1];
            int num3 = this.tree[num2];
            if (num3 == 0)
            {
                this.lit = this.tree[num2 + 2];
                this.mode = 6;
                goto Label_0051;
            }
            if ((num3 & 0x10) != 0)
            {
                this.get_Renamed = num3 & 15;
                this.len = this.tree[num2 + 2];
                this.mode = 2;
                goto Label_0051;
            }
            if ((num3 & 0x40) == 0)
            {
                this.need = num3;
                this.tree_index = (num2 / 3) + this.tree[num2 + 2];
                goto Label_0051;
            }
            if ((num3 & 0x20) != 0)
            {
                this.mode = 7;
                goto Label_0051;
            }
            this.mode = 9;
            z.msg = "invalid literal/length code";
            r = -3;
            s.bitb = num4;
            s.bitk = num5;
            z.avail_in = num7;
            z.total_in += num6 - z.next_in_index;
            z.next_in_index = num6;
            s.write = num8;
            return s.inflate_flush(z, r);
        Label_0412:
            num1 = this.need;
            while (num5 < num1)
            {
                if (num7 != 0)
                {
                    r = 0;
                }
                else
                {
                    s.bitb = num4;
                    s.bitk = num5;
                    z.avail_in = num7;
                    z.total_in += num6 - z.next_in_index;
                    z.next_in_index = num6;
                    s.write = num8;
                    return s.inflate_flush(z, r);
                }
                num7--;
                num4 |= (z.next_in[num6++] & 0xff) << (num5 & 0x1f);
                num5 += 8;
            }
            num2 = (this.tree_index + (num4 & InfCodes.inflate_mask[num1])) * 3;
            num4 = num4 >> (this.tree[num2 + 1] & 0x1f);
            num5 -= this.tree[num2 + 1];
            num3 = this.tree[num2];
            if ((num3 & 0x10) != 0)
            {
                this.get_Renamed = num3 & 15;
                this.dist = this.tree[num2 + 2];
                this.mode = 4;
                goto Label_0051;
            }
            if ((num3 & 0x40) == 0)
            {
                this.need = num3;
                this.tree_index = (num2 / 3) + this.tree[num2 + 2];
                goto Label_0051;
            }
            this.mode = 9;
            z.msg = "invalid distance code";
            r = -3;
            s.bitb = num4;
            s.bitk = num5;
            z.avail_in = num7;
            z.total_in += num6 - z.next_in_index;
            z.next_in_index = num6;
            s.write = num8;
            return s.inflate_flush(z, r);
        Label_0635:
            num10 = num8 - this.dist;
            while (num10 < 0)
            {
                num10 += s.end;
            }
            while (this.len != 0)
            {
                if (num9 == 0)
                {
                    if ((num8 == s.end) && (s.read != 0))
                    {
                        num8 = 0;
                        num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                    }
                    if (num9 == 0)
                    {
                        s.write = num8;
                        r = s.inflate_flush(z, r);
                        num8 = s.write;
                        num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                        if ((num8 == s.end) && (s.read != 0))
                        {
                            num8 = 0;
                            num9 = (num8 < s.read) ? ((s.read - num8) - 1) : (s.end - num8);
                        }
                        if (num9 == 0)
                        {
                            s.bitb = num4;
                            s.bitk = num5;
                            z.avail_in = num7;
                            z.total_in += num6 - z.next_in_index;
                            z.next_in_index = num6;
                            s.write = num8;
                            return s.inflate_flush(z, r);
                        }
                    }
                }
                s.window[num8++] = s.window[num10++];
                num9--;
                if (num10 == s.end)
                {
                    num10 = 0;
                }
                this.len--;
            }
            this.mode = 0;
            goto Label_0051;
        Label_098A:
            r = 1;
            s.bitb = num4;
            s.bitk = num5;
            z.avail_in = num7;
            z.total_in += num6 - z.next_in_index;
            z.next_in_index = num6;
            s.write = num8;
            return s.inflate_flush(z, r);
        }