1#ifndef UTILS_H
2#define UTILS_H
3
4#include <stddef.h>
5
6/* Case-insensitive substring search
7 Returns Ptr to first match in hay, NULL=Not found */
8const char* cistrstr(const char* hay, const char* nee);
9
10/* Extract header value from raw HTTP request header block
11 Returns 0=Success, -1=Not found / Malformed */
12int hdr_get_value(char out[512], const char* hdr, const char* key);
13
14/* Join two path fragments
15 Returns 0=Success, -1=Overflow / Invalid input */
16int join_path(char* out, size_t outsz, const char* a, const char* b);
17
18/* Securely zero memory
19 Prevents compiler from optimising the wipe away */
20void secure_bzero(void* p, size_t n);
21
22/* Write exactly n bytes to a file descriptor
23 Retries on EINTR.
24 Returns 0=Success, -1=Failure */
25int write_all(int fd, const void* buf, size_t n);
26
27#endif /* UTILS_H */
28