A gzip (RFC1951 + RFC1952) compression and decompression library
Provides functions to read and write compressed data using the gzip algorithm. This extension includes code from Oskar Schirmers excellent z3liblibrary.
Errors occurring in inflation/deflation procedures will result in a composite condition of the kinds exn and z3.
Initializes compression of data into a memory buffer. Various keyword arguments can be supplied to control compression:
Returns a z3 handle.
Encode data (a string) into a memory buffer and returns the number of bytes written. If less data has been commpressed than given in the call, invoke z3:encode repeatedly with the remaining data. Returns #f when finished. Each time some compressed data is available, the one-argument procedure RECEIVER is called with a string containing a chunk of compressed data.
Initialize an in-memory decompression and return a z3 handle for it.
Decode the compressed data in BUFFER (a string) and return the number of bytes decompressed.
Returns #t if X is a z3 handle or #f otherwise.
Encodes the data in STRING with optional start- and end-positions. If DESTINATION is given, then the compressed data will be stored in that argument (which should be a string of sufficient size) and z3:encode-buffer returns the length of the compressed data. If no destination is given then a freshly allocated string is returned that contains the compressed data.
Decodes the compressed data in STRING and returns the uncompressed data. Optional start- and end-position may be given.
Open a compressed file (specified by the file-descriptor in FILENO) for encoded data. The keyword arguments have the following meaning:
Returns a z3 file-handle.
Writes DATA (a string) into a compressed file, optionally limited in length. Before a file has been encoded completely, this procedure must be called once more with DATA being #f to indicate that the compression process is finished.
Returns a z3 file-handle for reading the file designated by the file-descriptor FILENO.
Reads a chunk of decoded data from a compressed file. The length of the chunk can be given as an optional argument and defaults to 4096 bytes. Returns a string or the end-of-file object.
Returns #t if X is a z3 file handle or #f otherwise.
Returns the file-descriptor associated with a z3 file-handle.
Opens a compressed input file and returns a port that automatically decompresses the data as it is read.
Creates a compressed file and returns an output-port. The keyword arguments have the same meaning as for the z3:encode-file procedure.