internal int deflateParams(ZStream strm, int _level, int _strategy) { int result = 0; if (_level == -1) { _level = 6; } if (_level < 0 || _level > 9 || _strategy < 0 || _strategy > 2) { return(-2); } if (Deflate.config_table[this.level].func != Deflate.config_table[_level].func && strm.total_in != 0L) { result = strm.deflate(1); } if (this.level != _level) { this.level = _level; this.max_lazy_match = Deflate.config_table[this.level].max_lazy; this.good_match = Deflate.config_table[this.level].good_length; this.nice_match = Deflate.config_table[this.level].nice_length; this.max_chain_length = Deflate.config_table[this.level].max_chain; } this.strategy = _strategy; return(result); }
internal int deflateParams(ZStream strm, int _level, int _strategy) { int result = 0; if (_level == -1) { _level = 6; } if (_level < 0 || _level > 9 || _strategy < 0 || _strategy > 2) { return(-2); } if (config_table[level].func != config_table[_level].func && strm.total_in != 0) { result = strm.deflate(1); } if (level != _level) { level = _level; max_lazy_match = config_table[level].max_lazy; good_match = config_table[level].good_length; nice_match = config_table[level].nice_length; max_chain_length = config_table[level].max_chain; } strategy = _strategy; return(result); }
public virtual void Finish() { do { z.next_out = buf; z.next_out_index = 0; z.avail_out = buf.Length; int num = (!compress) ? z.inflate(4) : z.deflate(4); if (num != 1 && num != 0) { throw new IOException(((!compress) ? "in" : "de") + "flating: " + z.msg); } int num2 = buf.Length - z.avail_out; if (num2 > 0) { output.Write(buf, 0, num2); } }while (z.avail_in > 0 || z.avail_out == 0); Flush(); }
public virtual void Finish() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) do { z.next_out = buf; z.next_out_index = 0; z.avail_out = buf.Length; int num = (compress ? z.deflate(4) : z.inflate(4)); if (num != 1 && num != 0) { throw new IOException((compress ? "de" : "in") + "flating: " + z.msg); } int num2 = buf.Length - z.avail_out; if (num2 > 0) { output.Write(buf, 0, num2); } }while (z.avail_in > 0 || z.avail_out == 0); ((Stream)this).Flush(); }
public override int Read(byte[] b, int off, int len) { if (len == 0) { return(0); } z.next_out = b; z.next_out_index = off; z.avail_out = len; int err; do { if (z.avail_in == 0 && !nomoreinput) { // if buffer is empty and more input is available, refill it z.next_in_index = 0; z.avail_in = input.Read(buf, 0, buf.Length); //(bufsize<z.avail_out ? bufsize : z.avail_out)); if (z.avail_in <= 0) { z.avail_in = 0; nomoreinput = true; } } err = compress ? z.deflate(flushLevel) : z.inflate(flushLevel); if (nomoreinput && err == JZlib.Z_BUF_ERROR) { return(0); } if (err != JZlib.Z_OK && err != JZlib.Z_STREAM_END) { // TODO // throw new ZStreamException((compress ? "de" : "in") + "flating: " + z.msg); throw new IOException((compress ? "de" : "in") + "flating: " + z.msg); } if ((nomoreinput || err == JZlib.Z_STREAM_END) && z.avail_out == len) { return(0); } }while(z.avail_out == len && err == JZlib.Z_OK); //Console.Error.WriteLine("("+(len-z.avail_out)+")"); return(len - z.avail_out); }
public override void Write(byte[] b, int off, int len) { if (len == 0) { return; } int err; z.next_in = b; z.next_in_index = off; z.avail_in = len; do { z.next_out = buf; z.next_out_index = 0; z.avail_out = BUFSIZE; err = z.deflate(flushLevel); if (err != JZlib.Z_OK) { throw new IOException("deflating: " + z.msg); } outp.Write(buf, 0, BUFSIZE - z.avail_out); }while(z.avail_in > 0 || z.avail_out == 0); }
public override int Read(byte[] b, int off, int len) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) if (len == 0) { return(0); } z.next_out = b; z.next_out_index = off; z.avail_out = len; int num; do { if (z.avail_in == 0 && !nomoreinput) { z.next_in_index = 0; z.avail_in = input.Read(buf, 0, buf.Length); if (z.avail_in <= 0) { z.avail_in = 0; nomoreinput = true; } } num = (compress ? z.deflate(flushLevel) : z.inflate(flushLevel)); if (nomoreinput && num == -5) { return(0); } if (num != 0 && num != 1) { throw new IOException((compress ? "de" : "in") + "flating: " + z.msg); } if ((nomoreinput || num == 1) && z.avail_out == len) { return(0); } }while (z.avail_out == len && num == 0); return(len - z.avail_out); }
internal int deflateParams(ZStream strm, int _level, int _strategy){ int err=Z_OK; if(_level == Z_DEFAULT_COMPRESSION){ _level = 6; } if(_level < 0 || _level > 9 || _strategy < 0 || _strategy > Z_HUFFMAN_ONLY) { return Z_STREAM_ERROR; } if(config_table[level].func!=config_table[_level].func && strm.total_in != 0) { // Flush the last buffer: err = strm.deflate(Z_PARTIAL_FLUSH); } if(level != _level) { level = _level; max_lazy_match = config_table[level].max_lazy; good_match = config_table[level].good_length; nice_match = config_table[level].nice_length; max_chain_length = config_table[level].max_chain; } strategy = _strategy; return err; }
public ZLibStatus deflateParams(ZStream strm, CompressionLevel _level, CompressionStrategy _strategy) { var err = ZLibStatus.Z_OK; if (_level == CompressionLevel.Z_DEFAULT_COMPRESSION) { _level = (CompressionLevel)6; } if (_level < 0 || _level > (CompressionLevel)9 || _strategy < 0 || _strategy > CompressionStrategy.Z_HUFFMAN_ONLY) { return ZLibStatus.Z_STREAM_ERROR; } if (_configurationTable[level].Function != _configurationTable[_level].Function && strm.total_in != 0) { // Flush the last buffer: err = strm.deflate(FlushType.Z_PARTIAL_FLUSH); } if (level != _level) { level = _level; max_lazy_match = _configurationTable[level].MaxLazy; good_match = _configurationTable[level].GoodLength; nice_match = _configurationTable[level].NiceLength; max_chain_length = _configurationTable[level].MaxChain; } strategy = _strategy; return err; }