4 #include <yajl/yajl_gen.h>
7 int parse_url_info(const char *url, struct url_info *info) {
20 memcpy(info->author, url, len);
21 info->author[len] = 0;
22 info->contents |= URL_INFO_AUTHOR;
24 if (c == NULL || c[1] == 0)
25 return info->contents;
27 info->record = strtoull(c + 1, NULL, 10);
28 info->contents |= URL_INFO_RECORD;
31 if (c == NULL || c[1] == 0)
32 return info->contents;
34 info->record_to = strtoull(c + 1, NULL, 10);
35 info->contents |= URL_INFO_RECORD_TO;
37 return info->contents;
40 uint64_t *make_sequential_list(uint64_t from, uint64_t to) {
41 uint64_t len = to - from + 1;
42 uint64_t *list = malloc(len * sizeof(uint64_t));
45 for (i = 0; i < len; i++) {
52 void json_generate_one_record(yajl_gen g, const char *author, struct blerg *b, uint64_t record) {
57 if (!blerg_fetch(b, record, &data, &len)) {
58 fprintf(stderr, "Could not fetch record\n");
64 yajl_gen_string(g, "author", 6);
65 yajl_gen_string(g, author, strlen(author));
67 yajl_gen_string(g, "record", 6);
68 snprintf(number, 21, "%llu", record);
69 yajl_gen_string(g, number, strlen(number));
70 yajl_gen_string(g, "timestamp", 9);
71 yajl_gen_integer(g, blerg_get_timestamp(b, record));
72 yajl_gen_string(g, "data", 4);
73 yajl_gen_string(g, data, len);
74 yajl_gen_map_close(g);