Ejemplo n.º 1
0
        /// <summary>
        /// Inflates the compressed stream to the output buffer.  If this
        /// returns 0, you should check, whether needsDictionary(),
        /// needsInput() or finished() returns true, to determine why no
        /// further output is produced.
        /// </summary>
        /// <param name = "buf">
        /// the output buffer.
        /// </param>
        /// <param name = "off">
        /// the offset into buffer where the output should start.
        /// </param>
        /// <param name = "len">
        /// the maximum length of the output.
        /// </param>
        /// <returns>
        /// the number of bytes written to the buffer, 0 if no further output can be produced.
        /// </returns>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// if len is &lt;= 0.
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// if the off and/or len are wrong.
        /// </exception>
        /// <exception cref="System.FormatException">
        /// if deflated stream is invalid.
        /// </exception>
        public int Inflate(byte[] buf, int off, int len)
        {
            if (len <= 0)
            {
                throw new ArgumentOutOfRangeException("len <= 0");
            }
            int count = 0;
            int more;

            do
            {
                if (mode != DECODE_CHKSUM)
                {
                    /* Don't give away any output, if we are waiting for the
                     * checksum in the input stream.
                     *
                     * With this trick we have always:
                     *   needsInput() and not finished()
                     *   implies more output can be produced.
                     */
                    more = outputWindow.CopyOutput(buf, off, len);
                    adler.Update(buf, off, more);
                    off      += more;
                    count    += more;
                    totalOut += more;
                    len      -= more;
                    if (len == 0)
                    {
                        return(count);
                    }
                }
            } while (Decode() || (outputWindow.GetAvailable() > 0 &&
                                  mode != DECODE_CHKSUM));
            return(count);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Inflates the compressed stream to the output buffer.  If this
        /// returns 0, you should check, whether needsDictionary(),
        /// needsInput() or finished() returns true, to determine why no
        /// further output is produced.
        /// </summary>
        /// <param name="buffer">
        /// the output buffer.
        /// </param>
        /// <param name="offset">
        /// the offset in buffer where storing starts.
        /// </param>
        /// <param name="count">
        /// the maximum number of bytes to output.
        /// </param>
        /// <returns>
        /// the number of bytes written to the buffer, 0 if no further output can be produced.
        /// </returns>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// if count is less than 0.
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// if the index and / or count are wrong.
        /// </exception>
        /// <exception cref="System.FormatException">
        /// if deflated stream is invalid.
        /// </exception>
        public int Inflate(byte[] buffer, int offset, int count)
        {
            if (buffer == null)
            {
                //throw new ArgumentNullException(//nameof//(buffer));
            }

            if (count < 0)
            {
            }

            if (offset < 0)
            {
            }

            if (offset + count > buffer.Length)
            {
                //throw new ArgumentException("count exceeds buffer bounds");
            }

            // Special case: count may be zero
            if (count == 0)
            {
                if (!IsFinished)                   // -jr- 08-Nov-2003 INFLATE_BUG fix..
                {
                    Decode();
                }
                return(0);
            }

            int bytesCopied = 0;

            do
            {
                if (mode != DECODE_CHKSUM)
                {
                    /* Don't give away any output, if we are waiting for the
                     * checksum in the input stream.
                     *
                     * With this trick we have always:
                     *   IsNeedingInput() and not IsFinished()
                     *   implies more output can be produced.
                     */
                    int more = outputWindow.CopyOutput(buffer, offset, count);
                    if (more > 0)
                    {
                        adler.Update(buffer, offset, more);
                        offset      += more;
                        bytesCopied += more;
                        totalOut    += (long)more;
                        count       -= more;
                        if (count == 0)
                        {
                            return(bytesCopied);
                        }
                    }
                }
            } while (Decode() || ((outputWindow.GetAvailable() > 0) && (mode != DECODE_CHKSUM)));
            return(bytesCopied);
        }
Ejemplo n.º 3
0
        public int Inflate(byte[] buffer, int offset, int count)
        {
            //IL_0008: Unknown result type (might be due to invalid IL or missing references)
            //IL_001c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0030: Unknown result type (might be due to invalid IL or missing references)
            //IL_0043: Unknown result type (might be due to invalid IL or missing references)
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", "count cannot be negative");
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", "offset cannot be negative");
            }
            if (offset + count > buffer.Length)
            {
                throw new ArgumentException("count exceeds buffer bounds");
            }
            if (count == 0)
            {
                if (!IsFinished)
                {
                    Decode();
                }
                return(0);
            }
            int num = 0;

            do
            {
                if (mode == 11)
                {
                    continue;
                }
                int num2 = outputWindow.CopyOutput(buffer, offset, count);
                if (num2 > 0)
                {
                    adler.Update(buffer, offset, num2);
                    offset   += num2;
                    num      += num2;
                    totalOut += num2;
                    count    -= num2;
                    if (count == 0)
                    {
                        return(num);
                    }
                }
            }while (Decode() || (outputWindow.GetAvailable() > 0 && mode != 11));
            return(num);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///   Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether needsDictionary(), needsInput() or finished() returns true, to determine why no further output is produced.
        /// </summary>
        /// <param name="buf"> the output buffer. </param>
        /// <param name="offset"> the offset into buffer where the output should start. </param>
        /// <param name="len"> the maximum length of the output. </param>
        /// <returns> the number of bytes written to the buffer, 0 if no further output can be produced. </returns>
        /// <exception cref="System.ArgumentOutOfRangeException">if len is &lt;= 0.</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">if the offset and/or len are wrong.</exception>
        /// <exception cref="System.FormatException">if deflated stream is invalid.</exception>
        public int Inflate(byte[] buf, int offset, int len)
        {
            if (len < 0)
            {
                throw new ArgumentOutOfRangeException("len < 0");
            }

            // Special case: len may be zero
            if (len == 0)
            {
                if (IsFinished == false)
                {
                    // -jr- 08-Nov-2003 INFLATE_BUG fix..
                    Decode();
                }

                return(0);
            }

            /*
             *          // Check for correct buff, off, len triple
             *          if (off < 0 || off + len >= buf.Length) {
             *                  throw new ArgumentException("off/len outside buf bounds");
             *          }
             */
            int count = 0;
            int more;

            do
            {
                if (mode != DECODE_CHKSUM)
                {
                    /* Don't give away any output, if we are waiting for the
                     * checksum in the input stream.
                     *
                     * With this trick we have always:
                     *   needsInput() and not finished()
                     *   implies more output can be produced.
                     */
                    more = outputWindow.CopyOutput(buf, offset, len);
                    adler.Update(buf, offset, more);
                    offset   += more;
                    count    += more;
                    totalOut += more;
                    len      -= more;
                    if (len == 0)
                    {
                        return(count);
                    }
                }
            } while (Decode() || (outputWindow.GetAvailable() > 0 && mode != DECODE_CHKSUM));
            return(count);
        }
Ejemplo n.º 5
0
        public int Inflate(byte[] buffer, int offset, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", "count cannot be negative");
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", "offset cannot be negative");
            }
            if ((offset + count) > buffer.Length)
            {
                throw new ArgumentException("count exceeds buffer bounds");
            }
            if (count == 0)
            {
                if (!IsFinished)
                {
                    Decode();
                }
                return(0);
            }
            int num = 0;

            do
            {
                if (mode != DECODE_CHKSUM)
                {
                    int num2 = outputWindow.CopyOutput(buffer, offset, count);
                    if (num2 > 0)
                    {
                        adler.Update(buffer, offset, num2);
                        offset   += num2;
                        num      += num2;
                        totalOut += num2;
                        count    -= num2;
                        if (count == 0)
                        {
                            return(num);
                        }
                    }
                }
            }while (Decode() || ((outputWindow.GetAvailable() > 0) && (mode != DECODE_CHKSUM)));
            return(num);
        }
Ejemplo n.º 6
0
        public int Inflate(byte[] buffer, int offset, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            if (count < 0)
            {
#if NETCF_1_0
                throw new ArgumentOutOfRangeException("count");
#else
                throw new ArgumentOutOfRangeException("count", "count cannot be negative");
#endif
            }

            if (offset < 0)
            {
#if NETCF_1_0
                throw new ArgumentOutOfRangeException("offset");
#else
                throw new ArgumentOutOfRangeException("offset", "offset cannot be negative");
#endif
            }

            if (offset + count > buffer.Length)
            {
                throw new ArgumentException("count exceeds buffer bounds");
            }

            if (count == 0)
            {
                if (!IsFinished)
                {
                    Decode();
                }
                return(0);
            }

            int bytesCopied = 0;

            do
            {
                if (mode != DECODE_CHKSUM)
                {
                    int more = outputWindow.CopyOutput(buffer, offset, count);
                    if (more > 0)
                    {
                        adler.Update(buffer, offset, more);
                        offset      += more;
                        bytesCopied += more;
                        totalOut    += (long)more;
                        count       -= more;
                        if (count == 0)
                        {
                            return(bytesCopied);
                        }
                    }
                }
            } while (Decode() || ((outputWindow.GetAvailable() > 0) && (mode != DECODE_CHKSUM)));
            return(bytesCopied);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Inflates the compressed stream to the output buffer.  If this
        /// returns 0, you should check, whether needsDictionary(),
        /// needsInput() or State.Done() returns true, to determine why no
        /// further output is produced.
        /// </summary>
        /// <param name="buffer">
        /// the output buffer.
        /// </param>
        /// <param name="offset">
        /// the offset in buffer where storing starts.
        /// </param>
        /// <param name="count">
        /// the maximum number of bytes to output.
        /// </param>
        /// <returns>
        /// the number of bytes written to the buffer, 0 if no further output can be produced.
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// if count is less than 0.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// if the index and / or count are wrong.
        /// </exception>
        /// <exception cref="FormatException">
        /// if deflated stream is invalid.
        /// </exception>
        public int Inflate(byte[] buffer, int offset, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count), "count cannot be negative");
            }

            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(offset), "offset cannot be negative");
            }

            if (offset + count > buffer.Length)
            {
                throw new ArgumentException("count exceeds buffer bounds");
            }

            // Special case: count may be zero
            if (count == 0)
            {
                if (!IsDone)
                { // -jr- 08-Nov-2003 INFLATE_BUG fix..
                    Decode();
                }

                return(0);
            }

            var bytesCopied = 0;

            do
            {
                if (mode != State.Checksum)
                {
                    /* Don't give away any output, if we are waiting for the
                     * checksum in the input stream.
                     *
                     * With this trick we have always:
                     *   IsNeedingInput() and not IsState.Done()
                     *   implies more output can be produced.
                     */
                    var more = outputWindow.CopyOutput(buffer, offset, count);
                    if (more > 0)
                    {
                        adler.Update(buffer, offset, more);
                        offset      += more;
                        bytesCopied += more;
                        TotalOut    += more;
                        count       -= more;
                        if (count == 0)
                        {
                            return(bytesCopied);
                        }
                    }
                }
            }while (Decode() || ((outputWindow.GetAvailable() > 0) && (mode != State.Checksum)));
            return(bytesCopied);
        }