int deflateParams(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; }
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; }
int deflateParams(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; }
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; }
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; }
int deflateParams(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; }
@Override public int compress(byte[] buffer, int offset, int length) { _zstream.next_in = buffer; _zstream.next_in_index = offset; _zstream.avail_in = length - offset; int status, outputLen = offset; do { _zstream.next_out = _tmp; _zstream.next_out_index = 0; _zstream.avail_out = BUF_SIZE; status = _zstream.deflate(JZlib.Z_PARTIAL_FLUSH); switch( status ) { case JZlib.Z_OK: System.arraycopy(_tmp, 0, buffer, outputLen, BUF_SIZE - _zstream.avail_out); outputLen += (BUF_SIZE - _zstream.avail_out); break; default: // TODO Error handling? System.err.println("compress: deflate returned " + status); } } while( _zstream.avail_out == 0 ); return outputLen; }
public byte[] compress(byte[] buf, int start, int len) throws IOException { compressOut.reset(); stream.next_in = buf; stream.next_in_index = start; stream.avail_in = len - start; int status; do { stream.next_out = tmpbuf; stream.next_out_index = 0; stream.avail_out = BUF_SIZE; status = stream.deflate(JZlib.Z_PARTIAL_FLUSH); switch(status) { case JZlib.Z_OK: compressOut.write(tmpbuf, 0, BUF_SIZE - stream.avail_out); break; default: throw new IOException("compress: deflate returnd " + status); } } while(stream.avail_out == 0); return compressOut.toByteArray(); }
stream.next_out_index=0; stream.avail_out=BUF_SIZE; status=stream.deflate(JZlib.Z_PARTIAL_FLUSH); switch(status){ case JZlib.Z_OK:
stream.next_out_index=0; stream.avail_out=BUF_SIZE; status=stream.deflate(JZlib.Z_PARTIAL_FLUSH); switch(status){ case JZlib.Z_OK:
public void write(byte b[], int off, int len) throws IOException { 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; if(compress) err=z.deflate(flush); else err=z.inflate(flush); if(err!=JZlib.Z_OK) throw new ZStreamException((compress?"de":"in")+"flating: "+z.msg); out.write(buf, 0, bufsize-z.avail_out); } while(z.avail_in>0 || z.avail_out==0); }
public void write(byte b[], int off, int len) throws IOException { 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; if(compress) err=z.deflate(flush); else err=z.inflate(flush); if(err!=JZlib.Z_OK) throw new ZStreamException((compress?"de":"in")+"flating: "+z.msg); out.write(buf, 0, bufsize-z.avail_out); } while(z.avail_in>0 || z.avail_out==0); }
public void write(byte b[], int off, int len) throws IOException { 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; if(compress) err=z.deflate(flush); else err=z.inflate(flush); if(err!=JZlib.Z_OK) throw new ZStreamException((compress?"de":"in")+"flating: "+z.msg); out.write(buf, 0, bufsize-z.avail_out); } while(z.avail_in>0 || z.avail_out==0); }
err=z.deflate(flush); else err=z.inflate(flush);
err=z.deflate(flush); else err=z.inflate(flush);
err=z.deflate(flush); else err=z.inflate(flush);
public void finish() throws IOException { int err; do{ z.next_out=buf; z.next_out_index=0; z.avail_out=bufsize; if(compress){ err=z.deflate(JZlib.Z_FINISH); } else{ err=z.inflate(JZlib.Z_FINISH); } if(err!=JZlib.Z_STREAM_END && err != JZlib.Z_OK) throw new ZStreamException((compress?"de":"in")+"flating: "+z.msg); if(bufsize-z.avail_out>0){ out.write(buf, 0, bufsize-z.avail_out); } } while(z.avail_in>0 || z.avail_out==0); flush(); } public void end() {
public void finish() throws IOException { int err; do{ z.next_out=buf; z.next_out_index=0; z.avail_out=bufsize; if(compress){ err=z.deflate(JZlib.Z_FINISH); } else{ err=z.inflate(JZlib.Z_FINISH); } if(err!=JZlib.Z_STREAM_END && err != JZlib.Z_OK) throw new ZStreamException((compress?"de":"in")+"flating: "+z.msg); if(bufsize-z.avail_out>0){ out.write(buf, 0, bufsize-z.avail_out); } } while(z.avail_in>0 || z.avail_out==0); flush(); } public void end() {
public void finish() throws IOException { int err; do{ z.next_out=buf; z.next_out_index=0; z.avail_out=bufsize; if(compress){ err=z.deflate(JZlib.Z_FINISH); } else{ err=z.inflate(JZlib.Z_FINISH); } if(err!=JZlib.Z_STREAM_END && err != JZlib.Z_OK) throw new ZStreamException((compress?"de":"in")+"flating: "+z.msg); if(bufsize-z.avail_out>0){ out.write(buf, 0, bufsize-z.avail_out); } } while(z.avail_in>0 || z.avail_out==0); try { flush(); } catch (IOException ignored) { } } public void end() throws IOException {
@Override public void compress(Buffer buffer) { stream.next_in = buffer.array(); stream.next_in_index = buffer.rpos(); stream.avail_in = buffer.available(); buffer.wpos(buffer.rpos()); do { stream.next_out = tempBuf; stream.next_out_index = 0; stream.avail_out = BUF_SIZE; final int status = stream.deflate(JZlib.Z_PARTIAL_FLUSH); if (status == JZlib.Z_OK) { buffer.putRawBytes(tempBuf, 0, BUF_SIZE - stream.avail_out); } else { throw new SSHRuntimeException("compress: deflate returned " + status); } } while (stream.avail_out == 0); }