tur/zlib
gzip + raw deflate encode/decode for Turmeric.
Since: Phase Z1
gzip-encode
(gzip-encode [data ptr<void> data-len : int] :)
gzip-compress a raw byte buffer.
| data | input buffer (ptr<void>) | |
| data-len | input byte count |
A newly-allocated GzipBuf (opaque ptr<void>) with the compressed bytes; the caller frees via gzip-buf-free. Returns NULL on allocation failure or zlib internal error.
(let [b (gzip-encode src src-len)]
(use-bytes (gzip-buf-data b) (gzip-buf-len b))
(gzip-buf-free b))
Since: Phase Z1
gzip-decode
(gzip-decode [data ptr<void> data-len : int] :)
gzip-decompress to a new buffer.
| data | compressed input buffer (ptr<void>); must start with | |
| the standard gzip magic bytes (1F 8B). | ||
| data-len | input byte count |
A newly-allocated GzipBuf (opaque ptr<void>) with the decompressed bytes; the caller frees via gzip-buf-free. Returns NULL on allocation failure or invalid input. Use inflate-raw for raw deflate streams (no gzip wrapper).
(let [b (gzip-decode src src-len)]
(use-bytes (gzip-buf-data b) (gzip-buf-len b))
(gzip-buf-free b))
Since: Phase Z1
deflate-raw
(deflate-raw [data ptr<void> data-len : int] :)
compress a buffer using raw deflate (no gzip wrapper).
| data | input buffer (ptr<void>) | |
| data-len | input byte count |
A GzipBuf with the raw-deflate bytes, or NULL on failure. Caller frees via gzip-buf-free.
(let [b (deflate-raw src src-len)]
(write-bytes (gzip-buf-data b) (gzip-buf-len b))
(gzip-buf-free b))
Since: Phase Z1
inflate-raw
(inflate-raw [data ptr<void> data-len : int] :)
decompress a raw deflate stream (no gzip wrapper).
| data | compressed input buffer (ptr<void>) | |
| data-len | input byte count |
A GzipBuf with the decompressed bytes, or NULL on failure. Caller frees via gzip-buf-free.
(let [b (inflate-raw src src-len)]
(use-bytes (gzip-buf-data b) (gzip-buf-len b))
(gzip-buf-free b))
Since: Phase Z1
gzip-buf-data
(gzip-buf-data [b ptr<void>] :)
raw byte pointer into a GzipBuf payload.
| b | GzipBuf handle from gzip-encode/gzip-decode/deflate-raw/inflate-raw |
A ptr<void> into the buffer's bytes. The pointer is valid until gzip-buf-free is called. Pair with gzip-buf-len for the byte count.
(write-bytes fd (gzip-buf-data b) (gzip-buf-len b))
Since: Phase Z1
gzip-buf-len
(gzip-buf-len [b ptr<void>] :)
byte count of a GzipBuf payload.
| b | GzipBuf handle |
Number of bytes in the buffer. Returns 0 for a NULL handle.
(gzip-buf-len b)
Since: Phase Z1
gzip-buf-free
(gzip-buf-free [b ptr<void>] :)
release a GzipBuf allocation.
| b | GzipBuf handle (NULL is a no-op) |
(gzip-buf-free b)
Since: Phase Z1