1 /* 2 * Copyright (c) 2009-2014 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 24 /* Steal the value and close the strbuffer */ 25 char *strbuffer_steal_value(strbuffer_t *strbuff); 26 27 int strbuffer_append(strbuffer_t *strbuff, const char *string); 28 int strbuffer_append_byte(strbuffer_t *strbuff, char byte); 29 int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size); 30 31 char strbuffer_pop(strbuffer_t *strbuff); 32 33 #endif 34