Previous: compression zip, Up: compression


2.2.7 ZLIB custom input port

The (weinholt compression zlib) library provides a custom input port for reading ZLIB compressed data.

— Procedure: make-zlib-input-port binary-input-port id max-buffer-size close-underlying-port? dictionaries

Returns a binary input port that decompresses and reads a ZLIB stream from the binary input port binary-input-port. The id is the name of the returned custom binary input port.

If max-buffer-size is false then the internal buffer can grow without bounds (might be a bad idea). Protocols using ZLIB will normally specify a "flush" behavior. If your protocol uses flushing and specifies a maximum record size, then use that size as max-buffer-size.

If close-underlying-port? is true then at the end of the zlib stream the binary-input-port will be closed.

An application can define dictionaries which can improve compression by containing byte sequences commonly found at the start of files. The dictionaries argument is an alist that maps Adler-32 checksums to bytevectors. See compression adler-32.

Version history: