diff --git a/http.c b/http.c index a35642c..cd42abe 100644 --- a/http.c +++ b/http.c @@ -28,6 +28,7 @@ #include "config.h" #include "util.h" #include "storage.h" +#include "udata.h" #ifdef HAVE_HTTP # include "http.h" #endif @@ -86,10 +87,10 @@ void push_geojson(struct mg_connection *conn) JsonNode *obj, *locs, *arr, *f, *geojson, *json, *fields = NULL; time_t s_lo, s_hi; - char *time_from = "2015-08-28", *time_to = NULL; + char *time_from = "2015-08-24", *time_to = NULL; char *js; - char *username = "jpm", *device = "5s"; + char *username = "jpm", *device = "test"; if (make_times(time_from, &s_lo, time_to, &s_hi) != 1) { return; @@ -205,8 +206,6 @@ int ev_handler(struct mg_connection *conn, enum mg_event ev) return (MG_FALSE); /* Fail it */ } - storage_init(); - /* GET */ if (!strcmp(conn->uri, "/api/me")) { push_geojson(conn); diff --git a/ot-recorder.c b/ot-recorder.c index 7ec7535..8178e11 100644 --- a/ot-recorder.c +++ b/ot-recorder.c @@ -841,6 +841,7 @@ int main(int argc, char **argv) syslog(LOG_WARNING, "Can't initialize gcache in %s", db_filename); exit(1); } + storage_init(ud->revgeo); /* For the HTTP server */ #endif revgeo_init(); } @@ -938,6 +939,7 @@ int main(int argc, char **argv) // mg_set_option(udata.server, "cgi_pattern", "**.cgi"); syslog(LOG_INFO, "HTTP listener started on %s", mg_get_option(udata.server, "listening_port")); + } #endif diff --git a/storage.c b/storage.c index b95b02d..09ed20a 100644 --- a/storage.c +++ b/storage.c @@ -44,14 +44,16 @@ char STORAGEDIR[BUFSIZ] = "./store"; static struct gcache *gc = NULL; -void storage_init() +void storage_init(int revgeo) { char path[BUFSIZ]; setenv("TZ", "UTC", 1); - snprintf(path, BUFSIZ, "%s/ghash", STORAGEDIR); - gc = gcache_open(path, TRUE); + if (revgeo) { + snprintf(path, BUFSIZ, "%s/ghash", STORAGEDIR); + gc = gcache_open(path, TRUE); + } } void get_geo(JsonNode *o, char *ghash) @@ -504,7 +506,6 @@ static int candidate_line(char *line, void *param) if (locs == NULL || locs->tag != JSON_ARRAY) return (-1); - if (limit == 0) { /* Reading forwards; account for time */ diff --git a/storage.h b/storage.h index 954e9fc..093952e 100644 --- a/storage.h +++ b/storage.h @@ -23,6 +23,6 @@ JsonNode *geo_linestring(JsonNode *location_array); JsonNode *kill_datastore(char *username, char *device); JsonNode *last_users(); char *gpx_string(JsonNode *json); -void storage_init(); +void storage_init(int revgeo); #endif