1#pragma once
2
3#include <stdbool.h>
4
5/*
6 * Buffer abstract data type
7 */
8struct strbuf {
9	char *bytes;
10	unsigned size;
11	unsigned used;
12};
13
14void strbuf_init(struct strbuf *buf);
15void strbuf_release(struct strbuf *buf);
16void strbuf_clear(struct strbuf *buf);
17
18/* Destroy buffer and return a copy as a C string */
19char *strbuf_steal(struct strbuf *buf);
20
21/*
22 * Return a C string owned by the buffer invalidated if the buffer is
23 * changed).
24 */
25const char *strbuf_str(struct strbuf *buf);
26
27bool strbuf_pushchar(struct strbuf *buf, char ch);
28unsigned strbuf_pushchars(struct strbuf *buf, const char *str);
29void strbuf_popchar(struct strbuf *buf);
30void strbuf_popchars(struct strbuf *buf, unsigned n);
31