#define URL_INFO_RECORD 0x2
#define DERP "DERP DERP DERP"
+yajl_gen_config yajl_c = { 0, 0 };
+
struct create_state {
struct MHD_PostProcessor *pp;
char username[33];
gs->entries = make_sequential_list(from, to);
gs->i = to - from;
- yajl_gen_config c;
- c.beautify = 0;
-
- gs->g = yajl_gen_alloc(&c, NULL);
+ gs->g = yajl_gen_alloc(&yajl_c, NULL);
gs->yoff = gs->done = 0;
response = MHD_create_response_from_callback(-1, 262144, &GET_generate_list, gs, &GET_generate_list_free);
*ptr = NULL;
return respond_JSON_Success(connection);
+ } else if (strncmp(url, "/info", 5) == 0) {
+ if (*ptr == NULL) {
+ *ptr = (void *) 1;
+
+ if (strcmp(method, MHD_HTTP_METHOD_GET) != 0)
+ return respond_405(connection);
+ return MHD_YES;
+ }
+
+
+ if (url[5] != '/')
+ return respond_404(connection);
+
+ ret = parse_url_info(url + 6, author, &record);
+ if ((ret & URL_INFO_AUTHOR) == 0)
+ return respond_404(connection);
+
+ if (!blerg_exists(author))
+ return respond_404(connection);
+
+ *ptr == NULL;
+
+ struct blerg *b = blerg_open(author);
+ uint64_t record_count = blerg_get_record_count(b);
+ blerg_close(b);
+
+ char number[21];
+ yajl_gen g = yajl_gen_alloc(&yajl_c, NULL);
+ yajl_gen_map_open(g);
+ yajl_gen_string(g, "record_count", 12);
+ snprintf(number, 21, "%llu", record_count);
+ yajl_gen_string(g, number, strlen(number));
+ yajl_gen_map_close(g);
+
+ const unsigned char *ybuf;
+ yajl_gen_get_buf(g, &ybuf, &len);
+
+ response = MHD_create_response_from_data(len, (void *)ybuf, MHD_NO, MHD_YES);
+ ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
+ MHD_destroy_response(response);
+
+ yajl_gen_free(g);
+
+ return ret;
} else if (strncmp(url, "/create", 8) == 0) {
struct create_state *cs = (struct create_state *) *ptr;