]>
Commit | Line | Data |
---|---|---|
556826b5 OM |
1 | /* |
2 | * Copyright (c) 2009-2016 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 | #include <stdlib.h> | |
12 | ||
13 | typedef struct { | |
14 | char *value; | |
15 | size_t length; /* bytes used */ | |
16 | size_t size; /* bytes allocated */ | |
17 | } strbuffer_t; | |
18 | ||
19 | int strbuffer_init(strbuffer_t *strbuff); | |
20 | void strbuffer_close(strbuffer_t *strbuff); | |
21 | ||
22 | void strbuffer_clear(strbuffer_t *strbuff); | |
23 | ||
24 | const char *strbuffer_value(const strbuffer_t *strbuff); | |
25 | ||
26 | /* Steal the value and close the strbuffer */ | |
27 | char *strbuffer_steal_value(strbuffer_t *strbuff); | |
28 | ||
29 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte); | |
30 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size); | |
31 | ||
32 | char strbuffer_pop(strbuffer_t *strbuff); | |
33 | ||
34 | #endif |