s/JSONDIR/STORAGEDIR/g

This commit is contained in:
Jan-Piet Mens
2015-08-19 18:58:12 +02:00
parent 745cbf5806
commit 4b45699e4f
5 changed files with 16 additions and 9 deletions

View File

@@ -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

4
file.c
View File

@@ -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);

View File

@@ -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);

2
misc.c
View File

@@ -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

View File

@@ -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));
}