No matching definitions.

tur/zlib

src/tur/zlib.tur

gzip + raw deflate encode/decode for Turmeric.

Since: Phase Z1

defn

gzip-encode

(gzip-encode [data ptr<void> data-len : int] :)

gzip-compress a raw byte buffer.

datainput buffer (ptr<void>)
data-leninput 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

defn

gzip-decode

(gzip-decode [data ptr<void> data-len : int] :)

gzip-decompress to a new buffer.

datacompressed input buffer (ptr<void>); must start with
the standard gzip magic bytes (1F 8B).
data-leninput 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

defn

deflate-raw

(deflate-raw [data ptr<void> data-len : int] :)

compress a buffer using raw deflate (no gzip wrapper).

datainput buffer (ptr<void>)
data-leninput 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

defn

inflate-raw

(inflate-raw [data ptr<void> data-len : int] :)

decompress a raw deflate stream (no gzip wrapper).

datacompressed input buffer (ptr<void>)
data-leninput 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

defn

gzip-buf-data

(gzip-buf-data [b ptr<void>] :)

raw byte pointer into a GzipBuf payload.

bGzipBuf 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

defn

gzip-buf-len

(gzip-buf-len [b ptr<void>] :)

byte count of a GzipBuf payload.

bGzipBuf handle

Number of bytes in the buffer. Returns 0 for a NULL handle.

(gzip-buf-len b)

Since: Phase Z1

defn

gzip-buf-free

(gzip-buf-free [b ptr<void>] :)

release a GzipBuf allocation.

bGzipBuf handle (NULL is a no-op)
(gzip-buf-free b)

Since: Phase Z1