summaryrefslogtreecommitdiff
path: root/ot_buf.h
blob: 219a06943828ac09ffe7871c4687a555de5f2421 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
   It is considered beerware. Prost. Skol. Cheers or whatever.

   $id$ */

#ifndef OT_BUF_H__
#define OT_BUF_H__

#include <stddef.h>

/* A growable byte buffer, holding an HTTP request that did not arrive in a
   single packet. Requests that arrive whole are served straight from the
   worker's input buffer and never come near this. */
typedef struct {
  char  *data;
  size_t size;
} ot_buf;

/* Append len bytes from src. Returns 0, or -1 if the memory could not be
   had, in which case the buffer keeps whatever it already held. */
int buf_cat(ot_buf *buf, const void *src, size_t len);

void buf_truncate(ot_buf *buf, size_t len);

void buf_reset(ot_buf *buf);

#endif