1 /* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
2 * BSD-style license. Please see the COPYING file for details.
7 #include <yajl/yajl_gen.h>
11 void json_generate_one_record(yajl_gen g, const char *author, struct blerg *b, uint64_t record, int brief) {
16 if (!blerg_fetch(b, record, &data, &len)) {
17 fprintf(stderr, "Could not fetch record\n");
21 if (brief && len > 150) {
23 /* This is a bit of a hackish way to add an ellipsis, and will
24 * probably cause weird results if we overwrite part of a UTF-8
33 yajl_gen_string(g, "author", 6);
34 yajl_gen_string(g, author, strlen(author));
36 yajl_gen_string(g, "record", 6);
37 snprintf(number, 21, "%llu", record);
38 yajl_gen_string(g, number, strlen(number));
39 yajl_gen_string(g, "timestamp", 9);
40 yajl_gen_integer(g, blerg_get_timestamp(b, record));
41 yajl_gen_string(g, "data", 4);
42 yajl_gen_string(g, data, len);
43 yajl_gen_map_close(g);