コード例 #1
0
 internal int Flush(int r)
 {
     for (int i = 0; i < 2; i++)
     {
         int availableBytesOut;
         if (i == 0)
         {
             availableBytesOut = ((this.readAt <= this.writeAt) ? this.writeAt : this.end) - this.readAt;
         }
         else
         {
             availableBytesOut = this.writeAt - this.readAt;
         }
         if (availableBytesOut == 0)
         {
             if (r == -5)
             {
                 r = 0;
             }
             return(r);
         }
         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, this.readAt, availableBytesOut);
         }
         Array.Copy(this.window, this.readAt, this._codec.OutputBuffer, this._codec.NextOut, availableBytesOut);
         this._codec.NextOut += availableBytesOut;
         this.readAt         += availableBytesOut;
         if ((this.readAt == this.end) && (i == 0))
         {
             this.readAt = 0;
             if (this.writeAt == this.end)
             {
                 this.writeAt = 0;
             }
         }
         else
         {
             i++;
         }
     }
     return(r);
 }
コード例 #2
0
        internal uint Reset()
        {
            uint check = this.check;

            this.mode   = InflateBlockMode.TYPE;
            this.bitk   = 0;
            this.bitb   = 0;
            this.readAt = this.writeAt = 0;
            if (this.checkfn != null)
            {
                this._codec._Adler32 = this.check = Adler.Adler32(0, null, 0, 0);
            }
            return(check);
        }
コード例 #3
0
        internal int read_buf(byte[] buf, int start, int size)
        {
            int availableBytesIn = this.AvailableBytesIn;

            if (availableBytesIn > size)
            {
                availableBytesIn = size;
            }
            if (availableBytesIn == 0)
            {
                return(0);
            }
            this.AvailableBytesIn -= availableBytesIn;
            if (this.dstate.WantRfc1950HeaderBytes)
            {
                this._Adler32 = Adler.Adler32(this._Adler32, this.InputBuffer, this.NextIn, availableBytesIn);
            }
            Array.Copy(this.InputBuffer, this.NextIn, buf, start, availableBytesIn);
            this.NextIn       += availableBytesIn;
            this.TotalBytesIn += availableBytesIn;
            return(availableBytesIn);
        }
コード例 #4
0
        internal int SetDictionary(byte[] dictionary)
        {
            int start  = 0;
            int length = dictionary.Length;

            if (this.mode != InflateManagerMode.DICT0)
            {
                throw new ZlibException("Stream error.");
            }
            if (Adler.Adler32(1, dictionary, 0, dictionary.Length) != this._codec._Adler32)
            {
                return(-3);
            }
            this._codec._Adler32 = Adler.Adler32(0, 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 = InflateManagerMode.BLOCKS;
            return(0);
        }
コード例 #5
0
ファイル: ZlibCodec.cs プロジェクト: wty0512/ZHSan
        // Read a new buffer from the current input stream, update the adler32
        // and total number of bytes read.  All deflate() input goes through
        // this function so some applications may wish to modify it to avoid
        // allocating a large strm->next_in buffer and copying from it.
        // (See also flush_pending()).
        internal int read_buf(byte[] buf, int start, int size)
        {
            int len = AvailableBytesIn;

            if (len > size)
            {
                len = size;
            }
            if (len == 0)
            {
                return(0);
            }

            AvailableBytesIn -= len;

            if (dstate.WantRfc1950HeaderBytes)
            {
                _Adler32 = Adler.Adler32(_Adler32, InputBuffer, NextIn, len);
            }
            Array.Copy(InputBuffer, NextIn, buf, start, len);
            NextIn       += len;
            TotalBytesIn += len;
            return(len);
        }