KEEL 1.0.0
Minimal C11 HTTP client/server library built on epoll/kqueue/io_uring/poll
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
decompress.h File Reference
#include <keel/allocator.h>
#include <keel/compress.h>
#include <stddef.h>
Include dependency graph for decompress.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  KlDecompress
 
struct  KlDecompressConfig
 Decompression configuration. More...
 
struct  KlDecompressStream
 Decompression stream handle. More...
 

Typedefs

typedef struct KlDecompress KlDecompress
 Pluggable decompression vtable.
 
typedef KlDecompress *(* KlDecompressFactory) (KlCompressCtx *ctx, KlAllocator *alloc)
 Factory creates a KlDecompress session from the shared context.
 
typedef struct KlDecompressConfig KlDecompressConfig
 Decompression configuration.
 

Functions

int kl_decompress_body (KlDecompressConfig *cfg, const char *in, size_t in_len, char **out, size_t *out_len, KlAllocator *alloc)
 Decompress a buffer body in one shot.
 
int kl_decompress_stream_init (KlDecompressStream *ds, KlDecompressConfig *cfg, KlAllocator *alloc)
 Initialize a decompression stream.
 
int kl_decompress_stream_feed (KlDecompressStream *ds, const char *data, size_t len, int flush, int(*emit)(void *ctx, const char *data, size_t len), void *emit_ctx)
 Feed compressed data through the decompression stream.
 
void kl_decompress_stream_free (KlDecompressStream *ds)
 Free decompression stream resources.
 

Typedef Documentation

◆ KlDecompress

typedef struct KlDecompress KlDecompress

Pluggable decompression vtable.

Users implement this interface to provide decompression (gzip, deflate, zstd). One KlDecompress instance is created per decompress operation via the factory.

◆ KlDecompressFactory

typedef KlDecompress *(* KlDecompressFactory) (KlCompressCtx *ctx, KlAllocator *alloc)

Factory creates a KlDecompress session from the shared context.

Shares KlCompressCtx with compression — same algorithm configuration.

Parameters
ctxShared compression context (algorithm, level).
allocAllocator for session resources.
Returns
New decompression session, or NULL on failure.

◆ KlDecompressConfig

Decompression configuration.

Shares KlCompressCtx with KlCompressConfig for algorithm configuration.

Function Documentation

◆ kl_decompress_body()

int kl_decompress_body ( KlDecompressConfig cfg,
const char *  in,
size_t  in_len,
char **  out,
size_t *  out_len,
KlAllocator alloc 
)

Decompress a buffer body in one shot.

Creates a decompression session, decompresses data, destroys session. Caller owns *out and must kl_free(alloc, *out, *out_len).

Parameters
cfgDecompression config (factory + context).
inCompressed input data.
in_lenInput length.
outReceives allocated decompressed output.
out_lenReceives decompressed output length.
allocAllocator for output buffer.
Returns
0 on success, -1 on error.

◆ kl_decompress_stream_init()

int kl_decompress_stream_init ( KlDecompressStream ds,
KlDecompressConfig cfg,
KlAllocator alloc 
)

Initialize a decompression stream.

Creates a decompression session via the factory and stores it in the stream handle.

Parameters
dsDecompression stream handle (caller-owned).
cfgDecompression config.
allocAllocator for session resources.
Returns
0 on success, -1 on error.

◆ kl_decompress_stream_feed()

int kl_decompress_stream_feed ( KlDecompressStream ds,
const char *  data,
size_t  len,
int  flush,
int(*)(void *ctx, const char *data, size_t len)  emit,
void *  emit_ctx 
)

Feed compressed data through the decompression stream.

Parameters
dsDecompression stream handle.
dataCompressed data.
lenData length.
flush0 for intermediate, 1 for final.
emitCallback to receive decompressed output.
emit_ctxContext passed to emit callback.
Returns
0 on success, -1 on error.

◆ kl_decompress_stream_free()

void kl_decompress_stream_free ( KlDecompressStream ds)

Free decompression stream resources.

Destroys the decompression session. Safe to call multiple times.

Parameters
dsDecompression stream handle.