#ifndef RESOURCE_FORMAT_BUFFER_H #define RESOURCE_FORMAT_BUFFER_H #include #include typedef void *(*fb_resize_fn)(void *, size_t, size_t, void *); typedef void (*fb_release_fn)(void *, size_t, void *); typedef struct { fb_resize_fn resize; fb_release_fn release; void *context; } fb_allocator; typedef struct { const unsigned char *data; size_t length; size_t capacity; size_t limit; size_t fields; int active; } fb_snapshot; enum { FB_OK = 0, FB_INVALID = 1, FB_STATE = 2, FB_LIMIT = 3, FB_MEMORY = 4 }; int fb_open(size_t limit, fb_allocator allocator); int fb_reserve(size_t logical); int fb_append(const unsigned char *data, size_t length); int fb_escaped(const unsigned char *data, size_t length); int fb_field(const char *key, const unsigned char *data, size_t length); int fb_integer(const char *key, int64_t value); int fb_reset(void); int fb_close(void); fb_snapshot fb_view(void); int fb_copy(unsigned char *destination, size_t capacity, size_t *written); #endif