+ 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;
+}
+
+ssize_t GET_generate_list(void *cls, uint64_t pos, char *buf, size_t max) {
+ struct get_state *gs = cls;
+ const unsigned char *ybuf;
+ char *data;
+ char number[21];
+ unsigned int len;
+
+ if (gs->yoff > 0) {
+ yajl_gen_get_buf(gs->g, &ybuf, &len);
+ size_t bytes_remaining = len - gs->yoff;
+ if (bytes_remaining > max) {
+ memcpy(buf, ybuf + gs->yoff, max);
+ gs->yoff += max;
+ return max;
+ } else {
+ memcpy(buf, ybuf + gs->yoff, bytes_remaining);
+ gs->yoff = 0;
+ yajl_gen_clear(gs->g);
+ return bytes_remaining;
+ }
+ }
+
+ if (gs->done)
+ return -1;
+
+ if (pos == 0) { /* Start iterating */
+ yajl_gen_array_open(gs->g);
+ }
+
+ /* Snarf one record */
+ blerg_fetch(gs->b, gs->entries[gs->i], &data, &len);
+
+ yajl_gen_map_open(gs->g);
+ yajl_gen_string(gs->g, "record", 6);
+ snprintf(number, 21, "%llu", gs->entries[gs->i]);
+ yajl_gen_string(gs->g, number, strlen(number));
+ yajl_gen_string(gs->g, "data", 4);
+ yajl_gen_string(gs->g, data, len);
+ yajl_gen_map_close(gs->g);
+
+ free(data);
+ if (gs->i == 0) {
+ yajl_gen_array_close(gs->g);
+ gs->done = 1;
+ }
+ gs->i--;
+