From 9a1d03c6482fe7bbfa75cfe28019335b5298eec3 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Sat, 6 Aug 2022 18:46:11 +0200 Subject: [PATCH] replace all SHARE by TOUR the word 'share' is difficult and ambiguos (why are we involved in investments?) and we're nipping this in the bud by renaming everything now in order to avoid the region/waypoint linguistic issues of the past. --- Makefile | 4 +-- config.mk.in | 2 +- http.c | 10 +++---- misc.c | 8 +++--- recorder.c | 78 ++++++++++++++++++++++++++-------------------------- storage.h | 2 +- udata.h | 2 +- util.c | 4 +-- util.h | 2 +- 9 files changed, 56 insertions(+), 56 deletions(-) diff --git a/Makefile b/Makefile index 42d241f..f2b9a41 100644 --- a/Makefile +++ b/Makefile @@ -53,8 +53,8 @@ ifeq ($(WITH_HTTP),yes) OTR_EXTRA_OBJS += mongoose.o http.o endif -ifeq ($(WITH_SHARES),yes) - CFLAGS += -DWITH_SHARES +ifeq ($(WITH_TOURS),yes) + CFLAGS += -DWITH_TOURS OTR_EXTRA_OBJS += endif diff --git a/config.mk.in b/config.mk.in index 25fdb3c..db896b8 100644 --- a/config.mk.in +++ b/config.mk.in @@ -40,7 +40,7 @@ WITH_MQTT ?= yes WITH_HTTP ?= yes # Do you want recorder support for shared views? Requires WITH_HTTP -WITH_SHARES ?= no +WITH_TOURS ?= no # Do you have Lua libraries installed and want the Lua hook integration? WITH_LUA ?= no diff --git a/http.c b/http.c index f6719da..0551467 100644 --- a/http.c +++ b/http.c @@ -139,7 +139,7 @@ static JsonNode *loadview(struct udata *ud, const char *viewname) view = json_mkobject(); if (json_copy_from_file(view, UB(fpath)) != TRUE) { -#ifdef WITH_SHARES +#ifdef WITH_TOURS /* Now try second possibility */ utstring_renew(fpath); utstring_printf(fpath, "%s/%s.json", toursdir(), viewname); @@ -147,7 +147,7 @@ static JsonNode *loadview(struct udata *ud, const char *viewname) #endif json_delete(view); return (NULL); -#ifdef WITH_SHARES +#ifdef WITH_TOURS } #endif } @@ -660,7 +660,7 @@ static int dopublish(struct mg_connection *conn, const char *uri) if (jnode != NULL) { /* - * Response data for share/shares is available; add it to + * Response data for tour/tours is available; add it to * the outgoing JSON which will be returned to the HTTP * client. */ @@ -971,7 +971,7 @@ static int view(struct mg_connection *conn, const char *viewname) debug(ud, "page file=%s", UB(fpath)); if ((fp = fopen(UB(fpath), "r")) == NULL) { -#ifdef WITH_SHARES +#ifdef WITH_TOURS utstring_renew(fpath); utstring_printf(fpath, "%s/%s", toursdir(), j->string_); debug(ud, "page file=%s", UB(fpath)); @@ -979,7 +979,7 @@ static int view(struct mg_connection *conn, const char *viewname) #endif json_delete(view); return send_status(conn, 404, "Cannot open view page"); -#ifdef WITH_SHARES +#ifdef WITH_TOURS } #endif } diff --git a/misc.c b/misc.c index 9f3f2e3..da07609 100644 --- a/misc.c +++ b/misc.c @@ -229,9 +229,9 @@ void get_defaults(char *filename, struct udata *ud) ud->http_port = c_int(cf, "OTR_HTTPPORT", ud->http_port); -#ifdef WITH_SHARES +#ifdef WITH_TOURS ud->http_prefix = c_str(cf, "OTR_HTTPPREFIX", NULL); -# endif /* WITH_SHARES */ +# endif /* WITH_TOURS */ #endif /* WITH_HTTP */ #if WITH_LUA @@ -289,9 +289,9 @@ void display_variables(struct udata *ud) d_str("OTR_HTTPLOGDIR", ud->http_logdir); d_str("OTR_BROWSERAPIKEY", ud->browser_apikey); d_str("OTR_VIEWSDIR", ud->viewsdir); -# ifdef WITH_SHARES +# ifdef WITH_TOURS d_str("OTR_HTTPPREFIX", ud->http_prefix); -# endif /* SHARES */ +# endif /* WITH_TOURS */ #endif #ifdef WITH_LUA d_str("OTR_LUASCRIPT", ud->luascript); diff --git a/recorder.c b/recorder.c index 6fa4696..d95a0b6 100644 --- a/recorder.c +++ b/recorder.c @@ -384,7 +384,7 @@ void waypoints_dump(struct udata *ud, UT_string *username, UT_string *device, ch free(js); } -#ifdef WITH_SHARES +#ifdef WITH_TOURS static char *elem(JsonNode *json, char *e) { JsonNode *j; @@ -397,9 +397,9 @@ static char *elem(JsonNode *json, char *e) } return (val); } -# endif /* WITH_SHARES */ +# endif /* WITH_TOURS */ -#ifdef WITH_SHARES +#ifdef WITH_TOURS void do_request(struct udata *ud, UT_string *username, UT_string *device, char *payloadstring, bool httpmode, JsonNode **jnode) { JsonNode *json = json_decode(payloadstring), *j, *r, *resp; @@ -437,11 +437,11 @@ void do_request(struct udata *ud, UT_string *username, UT_string *device, char * request_type = j->string_; } - if (strcmp(request_type, "share") == 0) { + if (strcmp(request_type, "tour") == 0) { FILE *fp; char path[BUFSIZ]; - if ((r = json_find_member(json, "share")) == NULL) { + if ((r = json_find_member(json, "tour")) == NULL) { return; } @@ -467,7 +467,7 @@ void do_request(struct udata *ud, UT_string *username, UT_string *device, char * free(js); fclose(fp); } else { - olog(LOG_ERR, "Can't create at share %s: %m", path); + olog(LOG_ERR, "Can't create tour at %s: %m", path); json_delete(o); return; } @@ -477,15 +477,15 @@ void do_request(struct udata *ud, UT_string *username, UT_string *device, char * resp = json_mkobject(); json_append_member(resp, "_type", json_mkstring("cmd")); json_append_member(resp, "action", json_mkstring("response")); - json_append_member(resp, "request", json_mkstring("share")); + json_append_member(resp, "request", json_mkstring("tour")); json_append_member(resp, "status", json_mknumber(200)); - JsonNode *nshare = json_mkobject(); - json_copy_to_object(nshare, r, false); - json_append_member(nshare, "uuid", json_mkstring(uuid)); - json_append_member(nshare, "url", json_mkstring(UB(url))); + JsonNode *nt = json_mkobject(); + json_copy_to_object(nt, r, false); + json_append_member(nt, "uuid", json_mkstring(uuid)); + json_append_member(nt, "url", json_mkstring(UB(url))); - json_append_member(resp, "share", nshare); + json_append_member(resp, "tour", nt); if (httpmode) { *jnode = resp; // caller will delete `resp' @@ -498,18 +498,18 @@ void do_request(struct udata *ud, UT_string *username, UT_string *device, char * } json_delete(resp); - } else if (strcmp(request_type, "shares") == 0) { + } else if (strcmp(request_type, "tours") == 0) { JsonNode *arr, *o; char path[BUFSIZ]; DIR *dirp; struct dirent *dp; - int nomatch, nshare = 0; + int nomatch, ntour = 0; resp = json_mkobject(); json_append_member(resp, "_type", json_mkstring("cmd")); json_append_member(resp, "action", json_mkstring("response")); - json_append_member(resp, "request", json_mkstring("shares")); + json_append_member(resp, "request", json_mkstring("tours")); arr = json_mkarray(); @@ -539,17 +539,17 @@ void do_request(struct udata *ud, UT_string *username, UT_string *device, char * } json_append_element(arr, o); - ++nshare; + ++ntour; } closedir(dirp); } else { perror(ud->viewsdir); } - json_append_member(resp, "shares", arr); - json_append_member(resp, "nshares", json_mknumber(nshare)); + json_append_member(resp, "tours", arr); + json_append_member(resp, "ntours", json_mknumber(ntour)); - olog(LOG_DEBUG, "Returning nshares=%d for %s/%s", nshare, UB(username), UB(device)); + olog(LOG_DEBUG, "Returning ntours=%d for %s/%s", ntour, UB(username), UB(device)); if (httpmode) { *jnode = resp; // caller will delete `resp' @@ -563,27 +563,27 @@ void do_request(struct udata *ud, UT_string *username, UT_string *device, char * json_delete(resp); - } else if (strcmp(request_type, "unshare") == 0) { + } else if (strcmp(request_type, "untour") == 0) { JsonNode *r; char path[BUFSIZ]; if ((r = json_find_member(json, "uuid")) == NULL) { - fprintf(stderr, "No uuid in unshare request\n"); + fprintf(stderr, "No uuid in untour request\n"); return; } - olog(LOG_DEBUG, "Unshare %s for %s/%s", r->string_, UB(username), UB(device)); + olog(LOG_DEBUG, "Untour %s for %s/%s", r->string_, UB(username), UB(device)); snprintf(path, sizeof(path), "%s/%s.json", toursdir(), r->string_); if (access(path, R_OK) < 0) { - olog(LOG_ERR, "Can't find share %s: %m", r->string_); + olog(LOG_ERR, "Can't find tour %s: %m", r->string_); } if (remove(path) != 0) { - olog(LOG_ERR, "Can't delete share %s: %m", r->string_); + olog(LOG_ERR, "Can't delete tour %s: %m", r->string_); } } } -#endif /* WITH_SHARES */ +#endif /* WITH_TOURS */ #ifdef WITH_GREENWICH @@ -893,9 +893,9 @@ void handle_message(void *userdata, char *topic, char *payload, size_t payloadle else if (!strcmp(j->string_, "waypoint")) _type = T_WAYPOINT; else if (!strcmp(j->string_, "waypoints")) _type = T_WAYPOINTS; else if (!strcmp(j->string_, "dump")) _type = T_CONFIG; -#ifdef WITH_SHARES +#ifdef WITH_TOURS else if (!strcmp(j->string_, "request")) _type = T_REQUEST; -#endif /* WITH_SHARES */ +#endif /* WITH_TOURS */ #if WITH_ENCRYPT else if (!strcmp(j->string_, "encrypted")) _type = T_ENCRYPTED; #endif /* WITH_ENCRYPT */ @@ -977,12 +977,12 @@ void handle_message(void *userdata, char *topic, char *payload, size_t payloadle return; break; #endif /* WITH_ENCRYPT */ -#ifdef WITH_SHARES +#ifdef WITH_TOURS case T_REQUEST: do_request(ud, username, device, payload, httpmode, jnode); goto cleanup; break; -#endif /* WITH_SHARES */ +#endif /* WITH_TOURS */ default: if (r_ok) { putrec(ud, now, reltopic, username, device, bindump(payload, payloadlen)); @@ -1415,9 +1415,9 @@ int main(int argc, char **argv) #endif /* WITH_MQTT */ #if WITH_HTTP UT_string *uviewsdir; -# if WITH_SHARES +# if WITH_TOURS UT_string *uhttp_prefix; -# endif /* WITH_SHARES */ +# endif /* WITH_TOURS */ #endif /* WITH_HTTP */ char err[1024]; char *logfacility = "local0"; @@ -1464,19 +1464,19 @@ int main(int argc, char **argv) udata.http_logdir = NULL; udata.browser_apikey = NULL; udata.viewsdir = NULL; -#ifdef WITH_SHARES +#ifdef WITH_TOURS udata.http_prefix = NULL; -# endif /* WITH_SHARES */ +# endif /* WITH_TOURS */ utstring_new(uviewsdir); utstring_printf(uviewsdir, "%s/views", DOCROOT); udata.viewsdir = strdup(UB(uviewsdir)); -#ifdef WITH_SHARES +#ifdef WITH_TOURS utstring_new(uhttp_prefix); utstring_printf(uhttp_prefix, "%s", "http://localhost:8083"); udata.http_prefix = strdup(UB(uhttp_prefix)); -# endif /* WITH_SHARES */ +# endif /* WITH_TOURS */ #endif #ifdef WITH_LUA udata.luascript = NULL; @@ -1947,10 +1947,10 @@ int main(int argc, char **argv) olog(LOG_ERR, "HTTP port is in use. Exiting."); exit(2); } -#ifdef WITH_SHARES +#ifdef WITH_TOURS olog(LOG_INFO, "HTTP prefix is %s", ud->http_prefix ? ud->http_prefix : "unset"); -# endif /* WITH_SHARES */ +# endif /* WITH_TOURS */ } #endif @@ -2003,9 +2003,9 @@ int main(int argc, char **argv) free(ud->http_host); free(ud->browser_apikey); free(ud->viewsdir); -# ifdef WITH_SHARES +# ifdef WITH_TOURS free(ud->http_prefix); -# endif /* WITH_SHARES */ +# endif /* WITH_TOURS */ if (ud->http_logdir) free(ud->http_logdir); #endif diff --git a/storage.h b/storage.h index c86db8e..d196962 100644 --- a/storage.h +++ b/storage.h @@ -36,7 +36,7 @@ typedef enum { #if WITH_ENCRYPT T_ENCRYPTED, #endif -#ifdef WITH_SHARES +#ifdef WITH_TOURS T_REQUEST, #endif } payload_type; diff --git a/udata.h b/udata.h index 020611f..43770d3 100644 --- a/udata.h +++ b/udata.h @@ -42,7 +42,7 @@ struct udata { char *http_logdir; /* full path to http access log */ char *browser_apikey; /* Google maps browser API key */ char *viewsdir; /* path to views directory */ -# ifdef WITH_SHARES +# ifdef WITH_TOURS char *http_prefix; /* prefix URL to this Recorder */ # endif /* SHARES */ #endif diff --git a/util.c b/util.c index abb1cc0..41563b1 100644 --- a/util.c +++ b/util.c @@ -32,7 +32,7 @@ #include #include #include -#ifdef WITH_SHARES +#ifdef WITH_TOURS # include #endif #include "udata.h" @@ -631,7 +631,7 @@ double number(JsonNode *j, char *element) return (NAN); } -#ifdef WITH_SHARES +#ifdef WITH_TOURS char *uuid4() { static char uustr[37]; diff --git a/util.h b/util.h index 98945ec..25045c9 100644 --- a/util.h +++ b/util.h @@ -40,7 +40,7 @@ double haversine_dist(double th1, double ph1, double th2, double ph2); void debug(struct udata *, char *fmt, ...); void chomp(char *s); double number(JsonNode *j, char *element); -#ifdef WITH_SHARES +#ifdef WITH_TOURS char *uuid4(void); char *toursdir(void); FILE *tourfile(struct udata *ud, char *filename, char *mode);