Skip to content
Common Lisp library for lzip (LZMA) (de)compression using bindings to the lzlib C library
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
LICENSE Add license file Jun 2, 2019
README.org Add some C library name variants for unix-like systems Jun 3, 2019
lzlib-tests.asd Refactor some tests Jun 19, 2019
lzlib.asd Refactor some tests Jun 19, 2019

README.org

cl-lzlib

Description

cl-lzlib is a Common Lisp library for lzip (LZMA) compression/decompression using bindings to the lzlib C library.

License

cl-lzlib is released under the GPL-3 license. See the LICENSE file for details.

Dependencies

cl-lzlib requires:

cffi and cl-octet-streams can be easily installed with quicklisp.

A lzlib package should be available in almost every GNU/Linux or *BSD distribution. For example it is called lzlib on Gentoo and Guix, and liblz1 on Debian and Ubuntu.

API

The library can be loaded with the usual:

(asdf:load-system "lzlib")

or

(quicklisp:quickload "lzlib")

The functions will then be available in the lzlib package.

Compression

The compression can be customized using serveral parameters:

  • The maximum size of members inside the lzip archive can be indicated with the member-size parameter. The default value is 2 PiB.
  • The compression level can be indicated either using the level parameter, or by using both the dictionary-size and match-len-limit parameters. The default level is 6, which sets dictionary-size to 8 MiB and match-len-limit to 36. level must be between 0 (fast encoder) and 9 (strong compression).
(compress-stream input output &key level member-size dictionary-size match-len-limit) => t

Read the data from the input octet stream, compress it, and write the result to the output octet stream.

(compress-file input output &key level member-size dictionary-size match-len-limit) => t

Read the data from the input file, compress it, and write the result to the output file.

(compress-buffer (buffer &key start end level member-size dictionary-size match-len-limit) => bytes

Read the data between the start and end offsets in the buffer, compress it, and return the resulting octet vector.

Decompression

The decompression can be customized using serveral parameters:

  • When an archive has some trailing data, if ignore-trailing is nil an error will be generated, otherwise the trailing data will be ignored.
  • When an archive has some trailing data looking like a corrupt header, if loose-trailing is nil an error will be generated, otherwise the trailing data will be ignored.
(decompress-stream input output &key ignore-trailing loose-trailing) => t

Read the data from the input octet stream, decompress it, and write the result to the output octet stream.

(decompress-file input output &key ignore-trailing loose-trailing) => t

Read the data from the input file, decompress it, and write the result to the output file.

(decompress-buffer buffer &key start end ignore-trailing loose-trailing) => bytes

Read the data between the start and end offsets in the buffer, decompress it, and return the resulting octet vector.

Tests

The tests require the fiveam package. They can be run with:

(asdf:test-system "lzlib")
You can’t perform that action at this time.