-int parse_url_info(const char *url, struct url_info *info) {
- const char *c;
- int len;
- info->contents = 0;
-
- c = strchr(url, '/');
- if (c == NULL) {
- len = strlen(url);
- } else {
- len = c - url;
- }
- if (len == 0)
- return 0;
- memcpy(info->author, url, len);
- info->author[len] = 0;
- info->contents |= URL_INFO_AUTHOR;
-
- if (c == NULL || c[1] == 0)
- return info->contents;
-
- info->record = strtoull(c + 1, NULL, 10);
- info->contents |= URL_INFO_RECORD;
-
- c = strchr(c, '-');
- if (c == NULL || c[1] == 0)
- return info->contents;
-
- info->record_to = strtoull(c + 1, NULL, 10);
- info->contents |= URL_INFO_RECORD_TO;
-
- return info->contents;
-}
-
-uint64_t *make_sequential_list(uint64_t from, uint64_t to) {
- uint64_t len = to - from + 1;
- uint64_t *list = malloc(len * sizeof(uint64_t));
- uint64_t i;
-
- for (i = 0; i < len; i++) {
- list[i] = from + i;
- }
-
- return list;
-}
-
-void json_generate_one_record(yajl_gen g, const char *author, struct blerg *b, uint64_t record) {
- char *data;
- char number[21];
- int len;
-
- if (!blerg_fetch(b, record, &data, &len)) {
- fprintf(stderr, "Could not fetch record\n");
- return;
- }
-
- yajl_gen_map_open(g);
- if (author != NULL) {
- yajl_gen_string(g, "author", 6);
- yajl_gen_string(g, author, strlen(author));
- }
- yajl_gen_string(g, "record", 6);
- snprintf(number, 21, "%llu", record);
- yajl_gen_string(g, number, strlen(number));
- yajl_gen_string(g, "timestamp", 9);
- yajl_gen_integer(g, blerg_get_timestamp(b, record));
- yajl_gen_string(g, "data", 4);
- yajl_gen_string(g, data, len);
- yajl_gen_map_close(g);
-
- free(data);
-}
-