Compression library for Common Lisp
Common Lisp Makefile
Switch branches/tags
release10.1_t6 release10.1_t5 release10.1_t4 release10.1_t3 release10.1_t2 release10.1_t1 release10.1_release_point release10.1_rc5 release10.1_rc4 release10.1_rc3 release10.1_rc2 release10.1_rc1 release10.1_beta3_release_point release10.1.beta2_release_point release10.1.beta_t6 release10.1.beta_t5 release10.1.beta_t4 release10.1.beta_t3 release10.1.beta_t2 release10.1.beta_t1 release10.1.beta_release_point release10.1.beta_rc4 release10.1.beta_rc3 release10.1.beta_rc2 release10.1.beta_rc1 release10.0_t3 release10.0_t2 release10.0_t1 release10.0_rc9 release10.0_rc8 release10.0_rc7 release10.0_rc6 release10.0_rc5 release10.0_rc4 release10.0_rc3 release10.0_rc2 release10.0_rc1 release10.0.pre-final.30_release_point release10.0.pre-final.17_release_point release10.0.beta_t13 release10.0.beta_t12 release10.0.beta_t11 release10.0.beta_t10 release10.0.beta_t9 release10.0.beta_t8 release10.0.beta_t7 release10.0.beta_t6 release10.0.beta_t5 release10.0.beta_t4 release10.0.beta_t3 release10.0.beta_t2 release10.0.beta_t1 release10.0.beta_release_point release10.0.beta_rc2 release10.0.beta_rc1 release_aclt2 release_acl100b14t8 release_acl100b11t7 release_acl100b10t6 release_acl100b8t5 release_acl100b7t4 release_acl100b6t3 release_acl100b4t2 release_acl100b2t1 release_acl90b21rc5 release_acl90b20_release_point release_acl90b20rc4 release_acl90b19rc3 release_acl90b18rc2 release_acl90b15_release_point release_acl90b15rc1 release_acl90b13t1 release_acl90b11t1 release_acl90b9t1 release_acl90b8t1 release_acl90b6_release_point release_acl90b6rc2 release_acl90b_release_point release_acl90a52rc1 release_acl90a44rc2 release_acl90a43rc1 release_acl90a39 release_acl90a39rc2 release_acl90a32 release_acl90a27 release_acl90a25 release_acl90a24 release_acl90a23 release_acl90a20 release_acl90a18 install-spider_2013-04-26T12-55-31 install-spider_2013-04-25T12-56-58 install-spider_2013-04-24T16-52-55 install-spider_2013-04-24T16-42-42 install-spider_2013-04-24T16-29-36 install-spider_2013-04-24T15-47-16 install-spider_2013-04-24T15-37-01 install-spider_2013-04-24T15-02-09 install-spider_2013-04-23T11-10-35 install-spider_2013-04-12T14-51-27
Nothing to show
Latest commit 7949b48 May 18, 2017 @dklayer dklayer rfe14955: move deflate-stream class above zlib load
See the discussion in the rfe. Basically, when the foreign loading
fails, we want the stream class to exist, so dependent modules can
define methods using it.

Change-Id: Ib2379848ef7db29e00d03ef36ff99b68ab694d5f
Reviewed-by: Robert Rorschach <>
Reviewed-by: Duane Rettig <>
Reviewed-by: Martin Mikelsons <>
Reviewed-by: Mikel Bancroft <>
Reviewed-by: Kevin Layer <>
Tested-by: Kevin Layer <>

zlib: Compression Library for Common Lisp

Table of contents

  • Description
  • Author
  • Author comments
  • Documentation
  • Platforms
  • Dependencies
  • Installation
  • Configuration
  • Licence
  • Notes
  • Examples
  • Franz Inc. Open Source Info


Deflation is a means of compressing an octet sequence that combines the LZ77 algorithm for marking common substrings and Huffman coding to take advantage of the different frequencies of occurence of byte sequences in the file. This algorithm may not be as easy to understand or as efficient as the LZW compression algorithm but Deflate does have the important advantage in that it is not patented. Thus Deflate widely used. Presently it's the most common compression method used by Windows Zip programs (e.g. Winzip) and in the Unix gzip program. Java jar files, being just zip files, also use this compression method.


John Foderaro, Franz Inc.

Author comments

If you have any doubt that Lisp is a better language for writing bit level algorithms you need only compare the source for this version of the Inflate algorithm with the C version found in programs such as gzip. The C code is essentially unreadable.


All Common Lisps, but tested on Allegro Common Lisp.


None for Allegro Common Lisp. For non-Allegro Common Lisps the acl-compat package is required, which provides the if* macro.


Load the inflate source file:

(load "/path/to/your/")






open a stream p to a file containing the compressed data. If this file has a gzip header then:

(skip-gzip-header p)
(make-instance 'inflate-stream :input-handle p)

will return a stream which can be read to recover the uncompressed data.


inflate (input-stream output-stream)

inflates the input-stream into the output-stream. Both streams should be of type unsigned-byte 8. Closing the inflate-stream will not close stream p. That must be done separately.

skip-gzip-header (input-stream)

If the input stream is positioned on the header of a gzip'ed file then the header is skipped. If the input-stream is not positioned on the gzip header then nothing is done.


The zlib source code is licensed under the terms of the Lisp Lesser GNU Public License, known as the LLGPL. The LLGPL consists of a preamble and the LGPL. Where these conflict, the preamble takes precedence. This project is referenced in the preamble as the LIBRARY.


At present this module only contains the code to uncompress a deflated byte sequence. We may write code to do deflation in the future but at present have no pressing need for this functionality.

We will be adding a simple-streams interface soon. With this interface you can layer the decompressor onto a simple-stream and decompress while you read bytes or characters from the stream.

Examples and Information

See the forms at the end of the file that is part of this project for examples and tests.

Franz Open Source Info

This project's homepage is There is an informal community support and development mailing list for these open source projects. We encourage you to take advantage by subscribing to the list. Once you're subscribed, email to with your questions, comments, suggestions, and patches.