diff --git a/Makefile b/Makefile index c1fe4b2..581021d 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ http.o: http.c mongoose.h util.h http.h storage.h util.o: util.c util.h Makefile config.mk ghashfind.o: ghashfind.c util.h mongoose.o: mongoose.c mongoose.h -ocat.o: ocat.c storage.h util.h config.mk +ocat.o: ocat.c storage.h util.h config.mk version.h storage.o: storage.c storage.h config.h util.h gcache.h ghash2lmdb.o: ghash2lmdb.c gcache.h diff --git a/ocat.c b/ocat.c index 2c73e89..8b959eb 100644 --- a/ocat.c +++ b/ocat.c @@ -30,6 +30,7 @@ #include "storage.h" #include "util.h" #include "misc.h" +#include "version.h" /* * Print the value in a single JSON node. If string, easy. If number account for @@ -143,6 +144,7 @@ void usage(char *prog) printf(" --storage -S storage dir (%s)\n", STORAGEDEFAULT); printf(" --norevgeo -G disable ghash to reverge-geo lookups\n"); printf(" --precision ghash precision (dflt: %d)\n", GEOHASH_PREC); + printf(" --version print version information\n"); printf("\n"); printf("Options override these environment variables:\n"); printf(" $OCAT_USERNAME\n"); @@ -153,6 +155,24 @@ void usage(char *prog) exit(1); } +void print_versioninfo() +{ + printf("This is OwnTracks Recorder, version %s\n", VERSION); + printf("built with:\n"); +#ifdef HAVE_LMDB + printf("\tHAVE_LMDB = yes\n"); +#endif +#ifdef HAVE_HTTP + printf("\tHAVE_HTTP = yes\n"); +#endif + printf("\tSTORAGEDEFAULT = \"%s\"\n", STORAGEDEFAULT); + printf("\tGEOHASH_PREC = %d\n", GEOHASH_PREC); + printf("\tDEFAULT_HISTORY_HOURS = %d\n", DEFAULT_HISTORY_HOURS); + printf("\tJSON_INDENT = \"%s\"\n", (JSON_INDENT) ? JSON_INDENT : "NULL"); + + exit(0); +} + int main(int argc, char **argv) { char *progname = *argv, *p; @@ -192,6 +212,7 @@ int main(int argc, char **argv) while (1) { static struct option long_options[] = { { "help", no_argument, 0, 'h'}, + { "version", no_argument, 0, 3}, { "list", no_argument, 0, 'l'}, { "user", required_argument, 0, 'u'}, { "device", required_argument, 0, 'd'}, @@ -221,6 +242,9 @@ int main(int argc, char **argv) case 2: geohash_setprec(atoi(optarg)); break; + case 3: + print_versioninfo(); + break; case 'l': list = 1; break; diff --git a/version.h b/version.h new file mode 100644 index 0000000..cb1ae9a --- /dev/null +++ b/version.h @@ -0,0 +1 @@ +#define VERSION "0.2.1"