zlib

This module uses zlib-binding to create a more idiomatic Open Dylan API to zlib.

Conditions

<zlib-error> Class

Superclass of all error types signaled by the zlib library.

Superclasses:

<error>

See also:

<zlib-errno-error> Class
Superclasses:

<zlib-error>

<zlib-stream-error> Class
Superclasses:

<zlib-error>

See also:

See $z-stream-error.

<zlib-data-error> Class
Superclasses:

<zlib-error>

See also:

See $z-data-error.

<zlib-memory-error> Class
Superclasses:

<zlib-error>

See also:

See $z-mem-error.

<zlib-buffer-error> Class
Superclasses:

<zlib-error>

See also:

See $z-buf-error.

<zlib-version-error> Class
Superclasses:

<zlib-error>

See also:

See $z-version-error.

<zlib-unexpected-error> Class

There was an unexpected error compressing or decompressing.

Superclasses:

<zlib-error>

Compression / Uncompression

zlib-compress

zlib-compress Function
Signature:

zlib-compress string #key level => (compressed)

Parameters:
Example:

The following code compress a string with a $z-default-compression level.

let phrase = "A horse, a horse, my kingdom for a horse";
let compressed = zlib-compress(phrase);
format-out("Phrase size: %d Compressed size: %d\n",
           phrase.size,
           compressed.size);

Now we compress the string using the maximum compression level ($z-best-compression).

let phrase = "Brevity is the soul of wit";
let compressed = zlib-compress(phrase, level: $z-best-compression);

zlib-uncompress

zlib-uncompress Function

Uncompress a previously compressed string.

Signature:

zlib-uncompress compressed length => (string)

Parameters:
  • compressed – An instance of <string>. A compressed string.

  • length – An instance of <integer>. Length of the uncompressed string. The size of the uncompressed data must have been saved previously by the compressor.

Values:
  • string – An instance of <string>. Uncompressed string.

Example:
let phrase = "A horse, a horse, my kingdom for a horse";
let compressed = zlib-compress(phrase);
let uncompressed = zlib-uncompress(compressed, phrase.size);
format-out("Phrase: %s Uncompressed: %s\n", phrase, uncompressed);