From 4b45699e4f6c8c803c9285b68dea37b3a9ce412e Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Wed, 19 Aug 2015 18:58:12 +0200 Subject: [PATCH] s/JSONDIR/STORAGEDIR/g --- config.h.example | 9 ++++++++- file.c | 4 ++-- ghash.c | 8 ++++---- misc.c | 2 +- ot-recorder.c | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/config.h.example b/config.h.example index beec9f9..fb53b9e 100644 --- a/config.h.example +++ b/config.h.example @@ -1,4 +1,11 @@ -#define JSONDIR "store" +/* + * This is the top-level directory you create; ot-recorder + * stores files below this hierarchy and creates directories + * therin by itself. Note that the user running `ot-recorder' + * must be granted write access (rwx) + */ + +#define STORAGEDIR "/path/to/store" /* * 1 => 5,009.4km x 4,992.6km diff --git a/file.c b/file.c index 465f354..c96caf0 100644 --- a/file.c +++ b/file.c @@ -52,9 +52,9 @@ FILE *pathn(char *mode, char *prefix, UT_string *user, UT_string *device, char * if (device) { ut_lower(device); - utstring_printf(path, "%s/%s/%s/%s", JSONDIR, prefix, utstring_body(user), utstring_body(device)); + utstring_printf(path, "%s/%s/%s/%s", STORAGEDIR, prefix, utstring_body(user), utstring_body(device)); } else { - utstring_printf(path, "%s/%s/%s", JSONDIR, prefix, utstring_body(user)); + utstring_printf(path, "%s/%s/%s", STORAGEDIR, prefix, utstring_body(user)); } ut_clean(path); diff --git a/ghash.c b/ghash.c index 7471795..0b02e6b 100644 --- a/ghash.c +++ b/ghash.c @@ -123,7 +123,7 @@ int ghash_readcache(struct udata *ud, char *ghash, UT_string *addr, UT_string *c if (ud->usefiles) { /* if ghash file is available, read cc:addr into that */ - snprintf(gfile, BUFSIZ, "%s/ghash/%-3.3s/%s.json", JSONDIR, ghash, ghash); + snprintf(gfile, BUFSIZ, "%s/ghash/%-3.3s/%s.json", STORAGEDIR, ghash, ghash); // fprintf(stderr, "Reading GhashCache from %s\n", gfile); if ((fp = fopen(gfile, "r")) != NULL) { @@ -176,7 +176,7 @@ void ghash_storecache(struct udata *ud, JsonNode *geo, char *ghash, char *addr, #endif if (ud->usefiles) { - snprintf(gfile, BUFSIZ, "%s/ghash", JSONDIR); + snprintf(gfile, BUFSIZ, "%s/ghash", STORAGEDIR); if (mkpath(gfile) < 0) { perror(gfile); } else { @@ -186,12 +186,12 @@ void ghash_storecache(struct udata *ud, JsonNode *geo, char *ghash, char *addr, json_append_member(geo, "cc", json_mkstring(ghash)); if ((js = json_stringify(geo, NULL)) != NULL) { - snprintf(gfile, BUFSIZ, "%s/ghash/%-3.3s", JSONDIR, ghash); + snprintf(gfile, BUFSIZ, "%s/ghash/%-3.3s", STORAGEDIR, ghash); if (mkpath(gfile) != 0) { perror(gfile); return; } - snprintf(gfile, BUFSIZ, "%s/ghash/%-3.3s/%s.json", JSONDIR, ghash, ghash); + snprintf(gfile, BUFSIZ, "%s/ghash/%-3.3s/%s.json", STORAGEDIR, ghash, ghash); if ((fp = fopen(gfile, "w")) != NULL) { fprintf(fp, "%s\n", js); diff --git a/misc.c b/misc.c index a1510e2..e766ba3 100644 --- a/misc.c +++ b/misc.c @@ -47,7 +47,7 @@ void monitorhook(struct udata *userdata, time_t now, char *topic) utstring_renew(us); utstring_printf(us, "%ld %s\n", now, topic); - sprintf(mpath, "%s/monitor", JSONDIR); + sprintf(mpath, "%s/monitor", STORAGEDIR); safewrite(mpath, utstring_body(us)); } #endif diff --git a/ot-recorder.c b/ot-recorder.c index 5456a7a..39f2c0b 100644 --- a/ot-recorder.c +++ b/ot-recorder.c @@ -532,7 +532,7 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m /* Now safewrite the last location */ utstring_printf(ts, "%s/last/%s/%s", - JSONDIR, utstring_body(username), utstring_body(device)); + STORAGEDIR, utstring_body(username), utstring_body(device)); if (mkpath(utstring_body(ts)) < 0) { perror(utstring_body(ts)); }