FIX: recorder, storage, and HTTP honour --norevgeo

This commit is contained in:
Jan-Piet Mens
2015-09-02 08:21:47 +02:00
parent cfa111e9c4
commit d253e4785d
4 changed files with 11 additions and 9 deletions
+3 -4
View File
@@ -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);
+2
View File
@@ -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
+5 -4
View File
@@ -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 */
+1 -1
View File
@@ -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