/** * Gives a readable snapshot of the buffer in hex. This is useful for debugging. * * @return snapshot of the buffer as a hex string with each octet delimited by a space */ public String printHex() { return ByteArrayUtils.printHex(array(), rpos(), available()); }
@Override public void uncompress(Buffer from, Buffer to) throws TransportException { inflater.setNextIn(from.array()); inflater.setNextInIndex(from.rpos()); inflater.setAvailIn(from.available()); while (true) { inflater.setNextOut(tempBuf); inflater.setNextOutIndex(0); inflater.setAvailOut(BUF_SIZE); final int status = inflater.inflate(JZlib.Z_PARTIAL_FLUSH); switch (status) { case JZlib.Z_OK: to.putRawBytes(tempBuf, 0, BUF_SIZE - inflater.getAvailOut()); break; case JZlib.Z_BUF_ERROR: return; default: throw new TransportException(DisconnectReason.COMPRESSION_ERROR, "uncompress: inflate returned " + status); } } }
@Override public void compress(Buffer buffer) { deflater.setNextIn(buffer.array()); deflater.setNextInIndex(buffer.rpos()); deflater.setAvailIn(buffer.available()); buffer.wpos(buffer.rpos()); do { deflater.setNextOut(tempBuf); deflater.setNextOutIndex(0); deflater.setAvailOut(BUF_SIZE); final int status = deflater.deflate(JZlib.Z_PARTIAL_FLUSH); if (status == JZlib.Z_OK) { buffer.putRawBytes(tempBuf, 0, BUF_SIZE - deflater.getAvailOut()); } else { throw new SSHRuntimeException("compress: deflate returned " + status); } } while (deflater.getAvailOut() == 0); }
/** * Gives a readable snapshot of the buffer in hex. This is useful for debugging. * * @return snapshot of the buffer as a hex string with each octet delimited by a space */ public String printHex() { return ByteArrayUtils.printHex(array(), rpos(), available()); }
/** * Gives a readable snapshot of the buffer in hex. This is useful for debugging. * * @return snapshot of the buffer as a hex string with each octet delimited by a space */ public String printHex() { return ByteArrayUtils.printHex(array(), rpos(), available()); }
@Override public void uncompress(Buffer from, Buffer to) throws TransportException { stream.next_in = from.array(); stream.next_in_index = from.rpos(); stream.avail_in = from.available(); while (true) { stream.next_out = tempBuf; stream.next_out_index = 0; stream.avail_out = BUF_SIZE; final int status = stream.inflate(JZlib.Z_PARTIAL_FLUSH); switch (status) { case JZlib.Z_OK: to.putRawBytes(tempBuf, 0, BUF_SIZE - stream.avail_out); break; case JZlib.Z_BUF_ERROR: return; default: throw new TransportException(DisconnectReason.COMPRESSION_ERROR, "uncompress: inflate returned " + status); } } }
@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); }
@Override public void uncompress(Buffer from, Buffer to) throws TransportException { inflater.setNextIn(from.array()); inflater.setNextInIndex(from.rpos()); inflater.setAvailIn(from.available()); while (true) { inflater.setNextOut(tempBuf); inflater.setNextOutIndex(0); inflater.setAvailOut(BUF_SIZE); final int status = inflater.inflate(JZlib.Z_PARTIAL_FLUSH); switch (status) { case JZlib.Z_OK: to.putRawBytes(tempBuf, 0, BUF_SIZE - inflater.getAvailOut()); break; case JZlib.Z_BUF_ERROR: return; default: throw new TransportException(DisconnectReason.COMPRESSION_ERROR, "uncompress: inflate returned " + status); } } }
@Override public void compress(Buffer buffer) { deflater.setNextIn(buffer.array()); deflater.setNextInIndex(buffer.rpos()); deflater.setAvailIn(buffer.available()); buffer.wpos(buffer.rpos()); do { deflater.setNextOut(tempBuf); deflater.setNextOutIndex(0); deflater.setAvailOut(BUF_SIZE); final int status = deflater.deflate(JZlib.Z_PARTIAL_FLUSH); if (status == JZlib.Z_OK) { buffer.putRawBytes(tempBuf, 0, BUF_SIZE - deflater.getAvailOut()); } else { throw new SSHRuntimeException("compress: deflate returned " + status); } } while (deflater.getAvailOut() == 0); }