KEEL 1.0.0
Minimal C11 HTTP client/server library built on epoll/kqueue/io_uring/poll
Loading...
Searching...
No Matches
compress.h
Go to the documentation of this file.
1#ifndef KEEL_COMPRESS_H
2#define KEEL_COMPRESS_H
3
4#include <keel/allocator.h>
5#include <keel/response.h>
6#include <stddef.h>
7
15typedef struct KlCompress KlCompress;
16
17struct KlCompress {
32 int (*compress)(KlCompress *self, const char *in, size_t in_len,
33 char **out, size_t *out_len, KlAllocator *alloc);
34
46 int (*feed)(KlCompress *self, const char *data, size_t len, int flush,
47 int (*emit)(void *ctx, const char *data, size_t len),
48 void *emit_ctx);
49
54 const char *(*encoding)(KlCompress *self);
55
57 void (*reset)(KlCompress *self);
58
60 void (*destroy)(KlCompress *self);
61};
62
68
75typedef KlCompress *(*KlCompressFactory)(KlCompressCtx *ctx,
76 KlAllocator *alloc);
77
86
102
117 const char *data, size_t len);
118
132 int status, KlCompressStream *cs);
133
146 size_t len);
147
158
159#endif /* KEEL_COMPRESS_H */
int kl_compress_stream_begin(KlResponse *res, KlCompressConfig *cfg, int status, KlCompressStream *cs)
Begin a compressed chunked streaming response.
struct KlCompressCtx KlCompressCtx
Opaque per-server compression context (algorithm config, level). User-owned — KEEL never inspects or ...
Definition compress.h:67
int kl_compress_stream_write(KlCompressStream *cs, const char *data, size_t len)
Write data to a compressed stream.
KlCompress *(* KlCompressFactory)(KlCompressCtx *ctx, KlAllocator *alloc)
Factory creates a KlCompress session from the shared context.
Definition compress.h:75
int kl_response_body_compress(KlResponse *res, KlCompressConfig *cfg, const char *data, size_t len)
Compress a buffer body and set it on the response.
int kl_compress_stream_end(KlCompressStream *cs)
End a compressed stream.
int(* KlWriteFn)(void *ctx, const char *data, size_t len)
Pluggable write callback — same signature as sh_json's ShJsonWriteFn.
Definition response.h:12
Bring-your-own allocator vtable.
Definition allocator.h:12
Compression configuration for KlConfig.
Definition compress.h:81
void(* ctx_destroy)(KlCompressCtx *ctx)
Definition compress.h:84
KlCompressFactory factory
Definition compress.h:83
KlCompressCtx * ctx
Definition compress.h:82
Compressed streaming handle.
Definition compress.h:94
void * write_ctx
Definition compress.h:97
KlAllocator * alloc
Definition compress.h:99
KlWriteFn write_fn
Definition compress.h:96
KlResponse * res
Definition compress.h:98
KlCompress * comp
Definition compress.h:95
int error
Definition compress.h:100
Definition compress.h:17
int(* compress)(KlCompress *self, const char *in, size_t in_len, char **out, size_t *out_len, KlAllocator *alloc)
Single-shot: compress entire buffer into *out.
Definition compress.h:32
void(* destroy)(KlCompress *self)
Free all resources.
Definition compress.h:60
void(* reset)(KlCompress *self)
Reset for reuse (may be NULL if not reusable).
Definition compress.h:57
int(* feed)(KlCompress *self, const char *data, size_t len, int flush, int(*emit)(void *ctx, const char *data, size_t len), void *emit_ctx)
Streaming: feed input, emit compressed output via callback.
Definition compress.h:46
Definition response.h:21