Next: , Previous: compression gzip, Up: compression


2.2.3 Decompress DEFLATE'd data

The procedures in (weinholt compression inflate) decompress DEFLATE data streams. DEFLATE is the data format used by gzip, zip and zlib. This library handles the raw data stream.

— Procedure: inflate binary-input-port binary-output-port crc-init crc-update crc-finish

Inflates a complete DEFLATE data stream. It reads compressed data from binary-input-port and writes decompressed data to binary-output-port.

The arguments crc-init, crc-update and crc-finish should have the same semantics that (weinholt crypto crc) uses, see crypto crc and compression adler-32.

Three values are returned: the final CRC of the decompressed data, its length, and a bytevector with read but unused bytes from the input.

— Procedure: make-inflater binary-input-port sink window-size dictionary

Returns a procedure that, when called, decompresses a DEFLATE block from binary-input-port. The returned procedure should be called with zero arguments and returns either the symbol done, to signify the end of the DEFLATE stream, or more to indicate more blocks are (or will be) available.

For a description of the sink argument, see compression sliding-buffer.

The window-size is the size of the sliding window buffer. The most common value is 32*1024 bytes, but each DEFLATE stream has a correct value that was used when creating the stream. For zlib streams this value is specified in the header.

The dictionary is a bytevector that is prepended to the output buffer, but it is not actually copied to the output. See compression zlib.

The inflate algorithm needs some lookahead and therefore it can read a byte or two that does not belong to the inflate stream itself. Apply the symbol get-buffer to the returned procedure to recover those extra bytes as a bytevector.

Version history: