Exemplo n.º 1
0
 public int EndInflate()
 {
     if (this.istate == null)
         throw new ZlibException("No Inflate State!");
     int num = this.istate.End();
     this.istate = (InflateManager)null;
     return num;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Ends an inflation session.
        /// </summary>
        /// <remarks>
        /// Call this after successively calling Inflate().  This will cause all buffers to be flushed.
        /// After calling this you cannot call Inflate() without a intervening call to one of the
        /// InitializeInflate() overloads.
        /// </remarks>
        /// <returns>Z_OK if everything goes well.</returns>
        public int EndInflate()
        {
            if (istate == null)
            {
                throw new ZlibException("No Inflate State!");
            }
            int ret = istate.End();

            istate = null;
            return(ret);
        }
Exemplo n.º 3
0
        public int InitializeInflate(int windowBits, bool expectRfc1950Header)
        {
            WindowBits = windowBits;
            if (Dstate != null)
            {
                throw new ZlibException("You may not call InitializeInflate() after calling InitializeDeflate().");
            }

            Istate = new InflateManager(expectRfc1950Header);
            return(Istate.Initialize(this, windowBits));
        }
Exemplo n.º 4
0
        public int EndInflate()
        {
            if (Istate == null)
            {
                throw new ZlibException("No Inflate State!");
            }

            var ret = Istate.End();

            Istate = null;
            return(ret);
        }
        public int EndInflate()
        {
            if (this.istate == null)
            {
                throw new ZLibException("No Inflate State!");
            }

            int ret = this.istate.End();

            this.istate = null;
            return(ret);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Ends an inflation session. 
        /// </summary>
        /// <remarks>
        /// Call this after successively calling Inflate().  This will cause all buffers to be flushed. 
        /// After calling this you cannot call Inflate() without a intervening call to one of the
        /// InitializeInflate() overloads.
        /// </remarks>
        /// <returns>Z_OK if everything goes well.</returns>
        public int EndInflate()
        {
            if (this.Istate == null)
                throw new ZlibException("No Inflate State!");

            int ret = this.Istate.End();

            this.Istate = null;

            return ret;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initialize the inflation state with an explicit flag to govern the handling of
        /// RFC1950 header bytes. 
        /// </summary>
        ///
        /// <remarks>
        /// If you want to read a zlib stream you should specify true for
        /// expectRfc1950Header. In this case, the library will expect to find a ZLIB
        /// header, as defined in <see href="http://www.ietf.org/rfc/rfc1950.txt">RFC
        /// 1950</see>, in the compressed stream.  If you will be reading a DEFLATE or
        /// GZIP stream, which does not have such a header, you will want to specify
        /// false.
        /// </remarks>
        ///
        /// <param name="expectRfc1950Header">whether to expect an RFC1950 header byte pair when reading 
        /// the stream of data to be inflated.</param>
        /// <param name="windowBits">The number of window bits to use. If you need to ask what that is, 
        /// then you shouldn't be calling this initializer.</param>
        /// <returns>Z_OK if everything goes well.</returns>
        public int InitializeInflate(int windowBits, bool expectRfc1950Header)
        {
            this.WindowBits = windowBits;

            //if (dstate != null)
            //    throw new ZlibException("You may not call InitializeInflate() after calling InitializeDeflate().");

            this.Istate = new InflateManager(expectRfc1950Header);

            return this.Istate.Initialize(this, windowBits);
        }
Exemplo n.º 8
0
 public int InitializeInflate(int windowBits, bool expectRfc1950Header)
 {
     this.WindowBits = windowBits;
     this.Istate     = new InflateManager(expectRfc1950Header);
     return(this.Istate.Initialize(this, windowBits));
 }
Exemplo n.º 9
0
 public int InitializeInflate(int windowBits, bool expectRfc1950Header)
 {
     this.WindowBits = windowBits;
     this.istate = new InflateManager(expectRfc1950Header);
     return this.istate.Initialize(this, windowBits);
 }
Exemplo n.º 10
0
        internal int Inflate(FlushType flush)
        {
            int num1 = (int)flush;

            if (this._codec.InputBuffer == null)
            {
                throw new ZlibException("InputBuffer is null. ");
            }
            int num2 = num1 == 4 ? -5 : 0;
            int r    = -5;

            while (true)
            {
                switch (this.mode)
                {
                case 0:
                    if (this._codec.AvailableBytesIn != 0)
                    {
                        r = num2;
                        --this._codec.AvailableBytesIn;
                        ++this._codec.TotalBytesIn;
                        InflateManager inflateManager = this;
                        byte[]         numArray       = this._codec.InputBuffer;
                        int            index          = this._codec.NextIn++;
                        int            num3;
                        int            num4 = num3 = (int)numArray[index];
                        inflateManager.method = num3;
                        if ((num4 & 15) != 8)
                        {
                            this.mode           = 13;
                            this._codec.Message = string.Format("unknown compression method (0x{0:X2})", (object)this.method);
                            this.marker         = 5;
                            break;
                        }
                        else if ((this.method >> 4) + 8 > this.wbits)
                        {
                            this.mode           = 13;
                            this._codec.Message = string.Format("invalid window size ({0})", (object)((this.method >> 4) + 8));
                            this.marker         = 5;
                            break;
                        }
                        else
                        {
                            this.mode = 1;
                            goto case 1;
                        }
                    }
                    else
                    {
                        goto label_4;
                    }

                case 1:
                    if (this._codec.AvailableBytesIn != 0)
                    {
                        r = num2;
                        --this._codec.AvailableBytesIn;
                        ++this._codec.TotalBytesIn;
                        int num3 = (int)this._codec.InputBuffer[this._codec.NextIn++] & (int)byte.MaxValue;
                        if (((this.method << 8) + num3) % 31 != 0)
                        {
                            this.mode           = 13;
                            this._codec.Message = "incorrect header check";
                            this.marker         = 5;
                            break;
                        }
                        else if ((num3 & 32) == 0)
                        {
                            this.mode = 7;
                            break;
                        }
                        else
                        {
                            goto label_16;
                        }
                    }
                    else
                    {
                        goto label_11;
                    }

                case 2:
                    goto label_17;

                case 3:
                    goto label_20;

                case 4:
                    goto label_23;

                case 5:
                    goto label_26;

                case 6:
                    goto label_29;

                case 7:
                    r = this.blocks.Process(r);
                    if (r == -3)
                    {
                        this.mode   = 13;
                        this.marker = 0;
                        break;
                    }
                    else
                    {
                        if (r == 0)
                        {
                            r = num2;
                        }
                        if (r == 1)
                        {
                            r = num2;
                            this.blocks.Reset(this.was);
                            if (!this.HandleRfc1950HeaderBytes)
                            {
                                this.mode = 12;
                                break;
                            }
                            else
                            {
                                this.mode = 8;
                                goto case 8;
                            }
                        }
                        else
                        {
                            goto label_35;
                        }
                    }

                case 8:
                    if (this._codec.AvailableBytesIn != 0)
                    {
                        r = num2;
                        --this._codec.AvailableBytesIn;
                        ++this._codec.TotalBytesIn;
                        this.need = (long)(((int)this._codec.InputBuffer[this._codec.NextIn++] & (int)byte.MaxValue) << 24 & -16777216);
                        this.mode = 9;
                        goto case 9;
                    }
                    else
                    {
                        goto label_40;
                    }

                case 9:
                    if (this._codec.AvailableBytesIn != 0)
                    {
                        r = num2;
                        --this._codec.AvailableBytesIn;
                        ++this._codec.TotalBytesIn;
                        this.need += (long)(((int)this._codec.InputBuffer[this._codec.NextIn++] & (int)byte.MaxValue) << 16) & 16711680L;
                        this.mode  = 10;
                        goto case 10;
                    }
                    else
                    {
                        goto label_43;
                    }

                case 10:
                    if (this._codec.AvailableBytesIn != 0)
                    {
                        r = num2;
                        --this._codec.AvailableBytesIn;
                        ++this._codec.TotalBytesIn;
                        this.need += (long)(((int)this._codec.InputBuffer[this._codec.NextIn++] & (int)byte.MaxValue) << 8) & 65280L;
                        this.mode  = 11;
                        goto case 11;
                    }
                    else
                    {
                        goto label_46;
                    }

                case 11:
                    if (this._codec.AvailableBytesIn != 0)
                    {
                        r = num2;
                        --this._codec.AvailableBytesIn;
                        ++this._codec.TotalBytesIn;
                        this.need += (long)this._codec.InputBuffer[this._codec.NextIn++] & (long)byte.MaxValue;
                        if ((int)this.was[0] != (int)this.need)
                        {
                            this.mode           = 13;
                            this._codec.Message = "incorrect data check";
                            this.marker         = 5;
                            break;
                        }
                        else
                        {
                            goto label_52;
                        }
                    }
                    else
                    {
                        goto label_49;
                    }

                case 12:
                    goto label_53;

                case 13:
                    goto label_54;

                default:
                    goto label_55;
                }
            }
label_4:
            return(r);

label_11:
            return(r);

label_16:
            this.mode = 2;
label_17:
            if (this._codec.AvailableBytesIn == 0)
            {
                return(r);
            }
            r = num2;
            --this._codec.AvailableBytesIn;
            ++this._codec.TotalBytesIn;
            this.need = (long)(((int)this._codec.InputBuffer[this._codec.NextIn++] & (int)byte.MaxValue) << 24 & -16777216);
            this.mode = 3;
label_20:
            if (this._codec.AvailableBytesIn == 0)
            {
                return(r);
            }
            r = num2;
            --this._codec.AvailableBytesIn;
            ++this._codec.TotalBytesIn;
            this.need += (long)(((int)this._codec.InputBuffer[this._codec.NextIn++] & (int)byte.MaxValue) << 16) & 16711680L;
            this.mode  = 4;
label_23:
            if (this._codec.AvailableBytesIn == 0)
            {
                return(r);
            }
            r = num2;
            --this._codec.AvailableBytesIn;
            ++this._codec.TotalBytesIn;
            this.need += (long)(((int)this._codec.InputBuffer[this._codec.NextIn++] & (int)byte.MaxValue) << 8) & 65280L;
            this.mode  = 5;
label_26:
            if (this._codec.AvailableBytesIn == 0)
            {
                return(r);
            }
            --this._codec.AvailableBytesIn;
            ++this._codec.TotalBytesIn;
            this.need           += (long)this._codec.InputBuffer[this._codec.NextIn++] & (long)byte.MaxValue;
            this._codec._Adler32 = this.need;
            this.mode            = 6;
            return(2);

label_29:
            this.mode           = 13;
            this._codec.Message = "need dictionary";
            this.marker         = 0;
            return(-2);

label_35:
            return(r);

label_40:
            return(r);

label_43:
            return(r);

label_46:
            return(r);

label_49:
            return(r);

label_52:
            this.mode = 12;
label_53:
            return(1);

label_54:
            throw new ZlibException(string.Format("Bad state ({0})", (object)this._codec.Message));
label_55:
            throw new ZlibException("Stream error.");
        }