示例#1
0
        internal int Flush(int r)
        {
            int destinationIndex1 = this.Codec.NextOut;
            int num1 = this.Read;
            int num2 = (num1 <= this.Write ? this.Write : this.End) - num1;

            if (num2 > this.Codec.AvailableBytesOut)
            {
                num2 = this.Codec.AvailableBytesOut;
            }
            if (num2 != 0 && r == -5)
            {
                r = 0;
            }
            this.Codec.AvailableBytesOut -= num2;
            this.Codec.TotalBytesOut     += (long)num2;
            if (this.Checkfn != null)
            {
                this.Codec.Adler32 = this.Check = Adler.Adler32(this.Check, this.Window, num1, num2);
            }
            Array.Copy((Array)this.Window, num1, (Array)this.Codec.OutputBuffer, destinationIndex1, num2);
            int destinationIndex2 = destinationIndex1 + num2;
            int num3 = num1 + num2;

            if (num3 == this.End)
            {
                int num4 = 0;
                if (this.Write == this.End)
                {
                    this.Write = 0;
                }
                int num5 = this.Write - num4;
                if (num5 > this.Codec.AvailableBytesOut)
                {
                    num5 = this.Codec.AvailableBytesOut;
                }
                if (num5 != 0 && r == -5)
                {
                    r = 0;
                }
                this.Codec.AvailableBytesOut -= num5;
                this.Codec.TotalBytesOut     += (long)num5;
                if (this.Checkfn != null)
                {
                    this.Codec.Adler32 = this.Check = Adler.Adler32(this.Check, this.Window, num4, num5);
                }
                Array.Copy((Array)this.Window, num4, (Array)this.Codec.OutputBuffer, destinationIndex2, num5);
                destinationIndex2 += num5;
                num3 = num4 + num5;
            }
            this.Codec.NextOut = destinationIndex2;
            this.Read          = num3;
            return(r);
        }
示例#2
0
        internal int Flush(int r)
        {
            int nextOut = this._codec.NextOut;
            int read    = this.read;
            int len     = ((read <= this.write) ? this.write : this.end) - read;

            if (len > this._codec.AvailableBytesOut)
            {
                len = this._codec.AvailableBytesOut;
            }
            if ((len != 0) && (r == -5))
            {
                r = 0;
            }
            this._codec.AvailableBytesOut -= len;
            this._codec.TotalBytesOut     += len;
            if (this.checkfn != null)
            {
                this._codec._Adler32 = this.check = Adler.Adler32(this.check, this.window, read, len);
            }
            Array.Copy(this.window, read, this._codec.OutputBuffer, nextOut, len);
            int destinationIndex = nextOut + len;
            int num5             = read + len;

            if (num5 == this.end)
            {
                int index = 0;
                if (this.write == this.end)
                {
                    this.write = 0;
                }
                int availableBytesOut = this.write - index;
                if (availableBytesOut > this._codec.AvailableBytesOut)
                {
                    availableBytesOut = this._codec.AvailableBytesOut;
                }
                if ((availableBytesOut != 0) && (r == -5))
                {
                    r = 0;
                }
                this._codec.AvailableBytesOut -= availableBytesOut;
                this._codec.TotalBytesOut     += availableBytesOut;
                if (this.checkfn != null)
                {
                    this._codec._Adler32 = this.check = Adler.Adler32(this.check, this.window, index, availableBytesOut);
                }
                Array.Copy(this.window, index, this._codec.OutputBuffer, destinationIndex, availableBytesOut);
                destinationIndex += availableBytesOut;
                num5              = index + availableBytesOut;
            }
            this._codec.NextOut = destinationIndex;
            this.read           = num5;
            return(r);
        }
示例#3
0
        internal void Reset(long[] c)
        {
            if (c != null)
            {
                c[0] = this.check;
            }
            if (this.mode != 4)
            {
                int num1 = this.mode;
            }
            int mode = this.mode;

            this.mode = 0;
            this.bitk = 0;
            this.bitb = 0;
            this.read = this.write = 0;
            if (this.checkfn != null)
            {
                this._codec._Adler32 = this.check = Adler.Adler32(0L, null, 0, 0);
            }
        }
示例#4
0
 internal void Reset(long[] c)
 {
     if (c != null)
     {
         c[0] = this.Check;
     }
     if (this.Mode != 4 && this.Mode != 5)
     {
     }
     if (this.Mode != 6)
     {
     }
     this.Mode = 0;
     this.Bitk = 0;
     this.Bitb = 0;
     this.Read = this.Write = 0;
     if (this.Checkfn == null)
     {
         return;
     }
     this.Codec.Adler32 = this.Check = Adler.Adler32(0L, (byte[])null, 0, 0);
 }
 internal void Reset(long[] c)
 {
     if (c != null)
     {
         c[0] = this.check;
     }
     if (this.mode != 4 && this.mode != 5)
     {
     }
     if (this.mode != 6)
     {
     }
     this.mode = 0;
     this.bitk = 0;
     this.bitb = 0;
     this.read = this.write = 0;
     if (this.checkfn == null)
     {
         return;
     }
     this._codec._Adler32 = this.check = Adler.Adler32(0L, (byte[])null, 0, 0);
 }
示例#6
0
        internal int SetDictionary(byte[] dictionary)
        {
            int start  = 0;
            int length = dictionary.Length;

            if (this.mode != 6)
            {
                throw new ZlibException("Stream error.");
            }
            if (Adler.Adler32(1L, dictionary, 0, dictionary.Length) != this._codec._Adler32)
            {
                return(-3);
            }
            this._codec._Adler32 = Adler.Adler32(0L, null, 0, 0);
            if (length >= (((int)1) << this.wbits))
            {
                length = (((int)1) << this.wbits) - 1;
                start  = dictionary.Length - length;
            }
            this.blocks.SetDictionary(dictionary, start, length);
            this.mode = 7;
            return(0);
        }