ComponentAce.Compression.Libs.ZLib.Deflate.deflateParams C# (CSharp) Method

deflateParams() private method

Sets deflate algorithm parameters
private deflateParams ( ZStream strm, int level, CompressionStrategy strategy ) : int
strm ZStream
level int
strategy CompressionStrategy
return int
        internal int deflateParams(ZStream strm, int level, CompressionStrategy strategy)
        {
            int err = (int)ZLibResultCode.Z_OK;

            if (level == Z_DEFAULT_COMPRESSION)
            {
                level = 6;
            }
            if (level < 0 || level > 9 || strategy < 0 || strategy > CompressionStrategy.Z_HUFFMAN_ONLY)
            {
                return (int)ZLibResultCode.Z_STREAM_ERROR;
            }

            if (config_table[this._level].func != config_table[level].func && strm.total_in != 0)
            {
                // Flush the last buffer:
                err = strm.deflate(FlushStrategy.Z_PARTIAL_FLUSH);
            }

            if (this._level != level)
            {
                this._level = level;
                max_lazy_match = config_table[this._level].max_lazy;
                good_match = config_table[this._level].good_length;
                nice_match = config_table[this._level].nice_length;
                max_chain_length = config_table[this._level].max_chain;
            }
            this.strategy = strategy;
            return err;
        }