diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-25 15:27:41 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-25 15:27:41 +0200 |
| commit | b8148f216a8c3ca990243d1f2208bd3a62ee9d9c (patch) | |
| tree | e781ca50813b6741dc624829a6316bf60ec03e47 /tools/server/base64.h | |
| parent | fb8f096b51cb518f81f558d4e0580a3652d104c1 (diff) | |
| download | ffwd-b8148f216a8c3ca990243d1f2208bd3a62ee9d9c.tar.gz ffwd-b8148f216a8c3ca990243d1f2208bd3a62ee9d9c.zip | |
server: encode base64 embeddings directly into the response buffer
Diffstat (limited to 'tools/server/base64.h')
| -rw-r--r-- | tools/server/base64.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/server/base64.h b/tools/server/base64.h index 88d88b3..2e77e2d 100644 --- a/tools/server/base64.h +++ b/tools/server/base64.h @@ -3,8 +3,18 @@ #include <stddef.h> -/* Standard base64 (with '=' padding) of n bytes. Returns a NUL-terminated heap - * string the caller frees; die-on-OOM, so it never returns NULL. */ +/* Standard base64 (with '=' padding). */ + +/* Number of base64 characters for n input bytes, excluding any NUL. Aborts + * (die-on-OOM) if n is so large the length would overflow. */ +size_t base64_encoded_len(size_t n); + +/* Encode n bytes of src as base64 into dst, writing exactly base64_encoded_len(n) + * bytes and no NUL terminator; dst must have room for that many bytes. */ +void base64_encode_to(char *dst, const unsigned char *src, size_t n); + +/* Convenience wrapper: returns a NUL-terminated heap string the caller frees; + * die-on-OOM, so it never returns NULL. */ char *base64_encode(const unsigned char *src, size_t n); #endif /* FFWD_BASE64_H */ |
