#include "tags.h"
#include "auth.h"
#include "canned_responses.h"
-#include "http.h"
+#include "app.h"
#include "config.h"
-#define URL_INFO_AUTHOR 0x1
-#define URL_INFO_RECORD 0x2
-#define URL_INFO_RECORD_TO 0x4
-#define DERP "DERP DERP DERP"
-
yajl_gen_config yajl_c = { 0, 0 };
struct create_state {
int done;
};
-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);
-}
-
ssize_t GET_generate_list(void *cls, uint64_t pos, char *buf, size_t max) {
struct get_state *gs = cls;
const unsigned char *ybuf;