This library provides the binding for zlib compression library. For now, it only provides the highest level APIs.
Subcondition of &error
.
This condition is raised when zlib process is finished unsuccessfully. You can
obtain the cause z-stream with the condition-zlib-stream
procedure and
get the detail message with the zlib-error-message
procedure. When error
occurred, however, it is raised with message-condition
and it has the
error message with. So you can simply get it with condition-message
procedure.
Z-stream must be z-stream object.
Retrieve error message from z-stream. If z-stream does not have any error message and this procedure is called, the behaviour is unspecified.
_ strategy dictionary owner?
Sink must be binary output port. Creates a custom binary output port. The port deflates its input and put the result to sink. With the optional keys, you can specify the following conditions:
You can specify an exact integer between 1 and 9 (inclusive) to compression-level. When it is omitted, a default compression level is used, which is usually 6. The following constants are defined to specify _compression-level_conveniently:
It specifies the buffer size of the port in bytes. The default is 4096.
It specifies the size of the window in exact integer. Typically the value should be between 8 and 15, inclusive, and it specifies the base two logarithm of the window size used in compression. Larger number yields better compression ratio, but more memory usage. The default value is 15.
It specifies how much memory should be allocated to keep the internal state during compression. 1 means smallest memory which causes slow and less compression. 9 means fastest and best compression with the largest amount of memory. The default value is 8.
To fine tune compression algorithm, you can use the strategy argument. The following constants are defined as the valid value as strategy.
The default strategy, suitable for most ordinary data.
Suitable for data generated by filters (or predictors). Filtered data consists mostly of small values with a somewhat compress them better. The effect of this is to force more huffman coding and less string matching.
Force to use huffman encoding only.
This is designed to be almost as fast as Z_HUFFMAN_ONLY, but gives better compression for PNG image data.
This prevents the use of dynamic huffman codes, allowing for a simpler decoder for special applications. The choice of strategy only affects compression ratio and speed. Any choice produces correct and decompressable data.
You can give an initial dictionary to the dictionary argument to be used in compression. The compressor and decompressor must use exactly the same dictionary.
If this argument is specified true value, the created port automatically closes the given output port sink when it is closed.
Source must be a binary input port.
The open-inflating-input-port
creates a custom binary input port, which
reads compressed binary data from the given port source and decompresses
the read data. When source port supports both port-position
and
set-port-position!
then the procedure will set source position
to offset of used bytes length when the created custom port is being closed.
Thus if the source port contains mixture of deflated data and non
deflated data then the custom port will only read deflated data and won't
forward the original port position beyond it no matter how big the
buffer-size is specified.
The meaning of buffer-size is the same as
open-deflating-output-port
.
The meaning of window-bits is almost the same, except if a value increased by 32 is given, the inflating port automatically detecs whether the source stream is zlib or gzip by its header.
If the input data is compressed with specified dictionary, the same dictionary must be given to dictionary argument. Otherwise &zlib-error condition is raised.
Inflate/deflate given bytevector bv respectively.
These are convenient procedures. It uses open-inflating-input-port
or
open-deflating-output-port
to inflate/deflate.
The opts will be passed to underlying procedures.
Returns CSC32/Adler32 checksum of bytevector bv, respectively.
If optional checksum is given, then returned checksum is an update of checksum by bv.