mmmmh
This commit is contained in:
parent
82aee127b0
commit
a92b119549
99 changed files with 6922 additions and 5723 deletions
32
docs/base64.md
Normal file
32
docs/base64.md
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
title = Base 64
|
||||
---
|
||||
# Base 64
|
||||
----------
|
||||
|
||||
The `base64.h` header has only two functions, one to encode and one to decode to/from base 64.
|
||||
|
||||
Example usage:
|
||||
```c
|
||||
char *recv_callback(arena_t *arena, buffer_t msg) {
|
||||
buffer_t decoded = base64Decode(arena, msg);
|
||||
alloc(arena, char); // allocate an extra char for the null pointer
|
||||
return (char *)decoded.data;
|
||||
}
|
||||
|
||||
buffer_t send_callback(arena_t *arena) {
|
||||
char msg[] = "Hello World!";
|
||||
buffer_t buf = {
|
||||
.data = msg,
|
||||
.len = arrlen(msg) - 1, // don't include the null pointer
|
||||
};
|
||||
buffer_t encoded = base64Encode(arena, buf);
|
||||
return encoded;
|
||||
}
|
||||
|
||||
int main() {
|
||||
arena_t arena = arenaMake(ARENA_VIRTUAL, GB(1));
|
||||
run_server(&arena, 8080, recv_callback, send_callback);
|
||||
arenaCleanup(&arena);
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue