diff options
Diffstat (limited to 'ot_buf.h')
| -rw-r--r-- | ot_buf.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ot_buf.h b/ot_buf.h new file mode 100644 index 0000000..219a069 --- /dev/null +++ b/ot_buf.h | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | ||
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. | ||
| 3 | |||
| 4 | $id$ */ | ||
| 5 | |||
| 6 | #ifndef OT_BUF_H__ | ||
| 7 | #define OT_BUF_H__ | ||
| 8 | |||
| 9 | #include <stddef.h> | ||
| 10 | |||
| 11 | /* A growable byte buffer, holding an HTTP request that did not arrive in a | ||
| 12 | single packet. Requests that arrive whole are served straight from the | ||
| 13 | worker's input buffer and never come near this. */ | ||
| 14 | typedef struct { | ||
| 15 | char *data; | ||
| 16 | size_t size; | ||
| 17 | } ot_buf; | ||
| 18 | |||
| 19 | /* Append len bytes from src. Returns 0, or -1 if the memory could not be | ||
| 20 | had, in which case the buffer keeps whatever it already held. */ | ||
| 21 | int buf_cat(ot_buf *buf, const void *src, size_t len); | ||
| 22 | |||
| 23 | void buf_truncate(ot_buf *buf, size_t len); | ||
| 24 | |||
| 25 | void buf_reset(ot_buf *buf); | ||
| 26 | |||
| 27 | #endif | ||
