1 | /* |
2 | * Copyright (c) 2009-2012 Petri Lehtinen <petri@digip.org> |
3 | * |
4 | * Jansson is free software; you can redistribute it and/or modify |
5 | * it under the terms of the MIT license. See LICENSE for details. |
6 | */ |
7 | |
8 | #ifndef STRBUFFER_H |
9 | #define STRBUFFER_H |
10 | |
11 | typedef struct { |
12 | char *value; |
13 | size_t length; /* bytes used */ |
14 | size_t size; /* bytes allocated */ |
15 | } strbuffer_t; |
16 | |
17 | int strbuffer_init(strbuffer_t *strbuff); |
18 | void strbuffer_close(strbuffer_t *strbuff); |
19 | |
20 | void strbuffer_clear(strbuffer_t *strbuff); |
21 | |
22 | const char *strbuffer_value(const strbuffer_t *strbuff); |
23 | char *strbuffer_steal_value(strbuffer_t *strbuff); |
24 | |
25 | int strbuffer_append(strbuffer_t *strbuff, const char *string); |
26 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte); |
27 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size); |
28 | |
29 | char strbuffer_pop(strbuffer_t *strbuff); |
30 | |
31 | #endif |
32 | |