Beispiel #1
0
 public void Reset()
 {
     mode     = noHeader ? 2 : 0;
     totalIn  = 0L;
     totalOut = 0L;
     input.Reset();
     outputWindow.Reset();
     dynHeader   = null;
     litlenTree  = null;
     distTree    = null;
     isLastBlock = false;
     adler.Reset();
 }
Beispiel #2
0
        private bool Decode()
        {
            int num2;
            int num3;
            switch (mode)
            {
                case 0:
                    return DecodeHeader();

                case 1:
                    return DecodeDict();

                case 2:
                    if (!isLastBlock)
                    {
                        int num = input.PeekBits(3);
                        if (num < 0)
                        {
                            return false;
                        }
                        input.DropBits(3);
                        if ((num & 1) != 0)
                        {
                            isLastBlock = true;
                        }
                        switch ((num >> 1))
                        {
                            case 0:
                                input.SkipToByteBoundary();
                                mode = 3;
                                goto Label_0134;

                            case 1:
                                litlenTree = InflaterHuffmanTree.DefLitLenTree;
                                distTree = InflaterHuffmanTree.DefDistTree;
                                mode = 7;
                                goto Label_0134;

                            case 2:
                                dynHeader = new InflaterDynHeader();
                                mode = 6;
                                goto Label_0134;
                        }
                        throw new SharpZipBaseException("Unknown block type " + num);
                    }
                    if (!noHeader)
                    {
                        input.SkipToByteBoundary();
                        neededBits = 0x20;
                        mode = DECODE_CHKSUM;
                        return true;
                    }
                    mode = FINISHED;
                    return false;

                case 3:
                    uncomprLen = input.PeekBits(0x10);
                    if (uncomprLen >= 0)
                    {
                        input.DropBits(0x10);
                        mode = 4;
                        goto Label_0167;
                    }
                    return false;

                case 4:
                    goto Label_0167;

                case 5:
                    goto Label_01A9;

                case 6:
                    if (dynHeader.Decode(input))
                    {
                        litlenTree = dynHeader.BuildLitLenTree();
                        distTree = dynHeader.BuildDistTree();
                        mode = 7;
                        goto Label_022D;
                    }
                    return false;

                case 7:
                case 8:
                case 9:
                case 10:
                    goto Label_022D;

                case DECODE_CHKSUM:
                    return DecodeChksum();

                case FINISHED:
                    return false;

                default:
                    throw new SharpZipBaseException("Inflater.Decode unknown mode");
            }
        Label_0134:
            return true;
        Label_0167:
            num2 = input.PeekBits(0x10);
            if (num2 < 0)
            {
                return false;
            }
            input.DropBits(0x10);
            if (num2 != (uncomprLen ^ 0xffff))
            {
                throw new SharpZipBaseException("broken uncompressed block");
            }
            mode = 5;
        Label_01A9:
            num3 = outputWindow.CopyStored(input, uncomprLen);
            uncomprLen -= num3;
            if (uncomprLen == 0)
            {
                mode = 2;
                return true;
            }
            return !input.IsNeedingInput;
        Label_022D:
            return DecodeHuffman();
        }
Beispiel #3
0
 public void Reset()
 {
     mode = noHeader ? 2 : 0;
     totalIn = 0L;
     totalOut = 0L;
     input.Reset();
     outputWindow.Reset();
     dynHeader = null;
     litlenTree = null;
     distTree = null;
     isLastBlock = false;
     adler.Reset();
 }
Beispiel #4
0
        private bool Decode()
        {
            int num2;
            int num3;

            switch (mode)
            {
            case 0:
                return(DecodeHeader());

            case 1:
                return(DecodeDict());

            case 2:
                if (!isLastBlock)
                {
                    int num = input.PeekBits(3);
                    if (num < 0)
                    {
                        return(false);
                    }
                    input.DropBits(3);
                    if ((num & 1) != 0)
                    {
                        isLastBlock = true;
                    }
                    switch ((num >> 1))
                    {
                    case 0:
                        input.SkipToByteBoundary();
                        mode = 3;
                        goto Label_0134;

                    case 1:
                        litlenTree = InflaterHuffmanTree.DefLitLenTree;
                        distTree   = InflaterHuffmanTree.DefDistTree;
                        mode       = 7;
                        goto Label_0134;

                    case 2:
                        dynHeader = new InflaterDynHeader();
                        mode      = 6;
                        goto Label_0134;
                    }
                    throw new SharpZipBaseException("Unknown block type " + num);
                }
                if (!noHeader)
                {
                    input.SkipToByteBoundary();
                    neededBits = 0x20;
                    mode       = DECODE_CHKSUM;
                    return(true);
                }
                mode = FINISHED;
                return(false);

            case 3:
                uncomprLen = input.PeekBits(0x10);
                if (uncomprLen >= 0)
                {
                    input.DropBits(0x10);
                    mode = 4;
                    goto Label_0167;
                }
                return(false);

            case 4:
                goto Label_0167;

            case 5:
                goto Label_01A9;

            case 6:
                if (dynHeader.Decode(input))
                {
                    litlenTree = dynHeader.BuildLitLenTree();
                    distTree   = dynHeader.BuildDistTree();
                    mode       = 7;
                    goto Label_022D;
                }
                return(false);

            case 7:
            case 8:
            case 9:
            case 10:
                goto Label_022D;

            case DECODE_CHKSUM:
                return(DecodeChksum());

            case FINISHED:
                return(false);

            default:
                throw new SharpZipBaseException("Inflater.Decode unknown mode");
            }
Label_0134:
            return(true);

Label_0167:
            num2 = input.PeekBits(0x10);
            if (num2 < 0)
            {
                return(false);
            }
            input.DropBits(0x10);
            if (num2 != (uncomprLen ^ 0xffff))
            {
                throw new SharpZipBaseException("broken uncompressed block");
            }
            mode = 5;
Label_01A9:
            num3        = outputWindow.CopyStored(input, uncomprLen);
            uncomprLen -= num3;
            if (uncomprLen == 0)
            {
                mode = 2;
                return(true);
            }
            return(!input.IsNeedingInput);

Label_022D:
            return(DecodeHuffman());
        }