strbuffer_t * json_token_tostr(char *js, jsmntok_t *t) { if(t->start > strlen(js) || t->end > strlen(js) || t->end > strlen(js) || (t->end - t->start) > strlen(js) ) { return NULL; } strbuffer_t *string = (strbuffer_t *) json_malloc(sizeof(strbuffer_t)); strbuffer_init(string); strbuffer_append_bytes(string, js + t->start, (t->end - t->start) ); return string; }
static int dump_to_strbuffer(const char *buffer, size_t size, void *data) { return strbuffer_append_bytes((strbuffer_t *)data, buffer, size); }
int strbuffer_append_byte(strbuffer_t *strbuff, char byte) { return strbuffer_append_bytes(strbuff, &byte, 1); }
int strbuffer_append(strbuffer_t *strbuff, const char *string) { return strbuffer_append_bytes(strbuff, string, strlen(string)); }