From: Teemu Toivola Date: Wed, 21 Oct 2015 19:07:19 +0000 (+0300) Subject: use VERSION string from config.h instead of VNSTATVERSION from common.h X-Git-Tag: v1.15~13^2~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed7c5b8dcfecd4781eb46c9c44e115fd40f5482a;p=vnstat use VERSION string from config.h instead of VNSTATVERSION from common.h --- diff --git a/Makefile.am b/Makefile.am index 962fd76..bb11ab6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -88,4 +88,4 @@ profile: myclean: maintainer-clean clean-local: - -rm -fr coverage *.lcov *.gz test*.log test*.xml + -rm -fr coverage *.lcov *.gz test*.log test*.xml src/*.gc* tests/*.gc* diff --git a/Makefile.in b/Makefile.in index 8c5eec8..6523e18 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1625,7 +1625,7 @@ profile: myclean: maintainer-clean clean-local: - -rm -fr coverage *.lcov *.gz test*.log test*.xml + -rm -fr coverage *.lcov *.gz test*.log test*.xml src/*.gc* tests/*.gc* # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/src/cfg.c b/src/cfg.c index 1b4d108..7bab5eb 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -5,7 +5,7 @@ void printcfgfile(void) { ibwnode *p = ifacebw; - printf("# vnStat %s config file\n", VNSTATVERSION); + printf("# vnStat %s config file\n", getversion()); printf("##\n\n"); printf("# default interface\n"); diff --git a/src/common.c b/src/common.c index 44b9cc1..7ff2862 100644 --- a/src/common.c +++ b/src/common.c @@ -250,3 +250,16 @@ void panicexit(const char *sourcefile, const int sourceline) printe(PT_Error); exit(EXIT_FAILURE); } + +char *getversion(void) +{ + int i; + static char versionbuffer[16]; + strncpy_nt(versionbuffer, VERSION, 16); + for (i=0; i\n", VNSTATVERSION, XMLVERSION); + printf("\n", getversion(), XMLVERSION); } void xmlfooter(void) diff --git a/src/vnstat.c b/src/vnstat.c index da04e68..d92bb6c 100644 --- a/src/vnstat.c +++ b/src/vnstat.c @@ -305,7 +305,7 @@ int main(int argc, char *argv[]) { free(p.ifacelist); return 0; } else if ((strcmp(argv[currentarg],"-v")==0) || (strcmp(argv[currentarg],"--version")==0)) { - printf("vnStat %s by Teemu Toivola \n", VNSTATVERSION); + printf("vnStat %s by Teemu Toivola \n", getversion()); return 0; } else if ((strcmp(argv[currentarg],"-r")==0) || (strcmp(argv[currentarg],"--reset")==0)) { p.reset=1; @@ -442,7 +442,7 @@ int synccounters(const char *iface, const char *dirname) void showhelp(PARAMS *p) { - printf(" vnStat %s by Teemu Toivola \n\n", VNSTATVERSION); + printf(" vnStat %s by Teemu Toivola \n\n", getversion()); printf(" -q, --query query database\n"); printf(" -h, --hours show hours\n"); @@ -464,7 +464,7 @@ void showhelp(PARAMS *p) void showlonghelp(PARAMS *p) { - printf(" vnStat %s by Teemu Toivola \n\n", VNSTATVERSION); + printf(" vnStat %s by Teemu Toivola \n\n", getversion()); printf(" Query:\n"); printf(" -q, --query query database\n"); diff --git a/src/vnstatd.c b/src/vnstatd.c index 6794404..7ef043b 100644 --- a/src/vnstatd.c +++ b/src/vnstatd.c @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) } else if (strcmp(argv[currentarg],"--noadd")==0) { s.noadd = 1; } else if ((strcmp(argv[currentarg],"-v")==0) || (strcmp(argv[currentarg],"--version")==0)) { - printf("vnStat daemon %s by Teemu Toivola \n", VNSTATVERSION); + printf("vnStat daemon %s by Teemu Toivola \n", getversion()); return 0; } else if ((strcmp(argv[currentarg],"-p")==0) || (strcmp(argv[currentarg],"--pidfile")==0)) { if (currentarg+1\n\n", VNSTATVERSION); + printf(" vnStat daemon %s by Teemu Toivola \n\n", getversion()); printf(" -d, --daemon fork process to background\n"); printf(" -n, --nodaemon stay in foreground attached to the terminal\n\n"); printf(" -s, --sync sync interface counters on first update\n"); diff --git a/src/vnstati.c b/src/vnstati.c index a8a777f..52f7010 100644 --- a/src/vnstati.c +++ b/src/vnstati.c @@ -213,7 +213,7 @@ int main(int argc, char *argv[]) printf("Rateunit changed: %d\n", cfg.rateunit); } } else if ((strcmp(argv[currentarg],"-v")==0) || (strcmp(argv[currentarg],"--version"))==0) { - printf("vnStat image output %s by Teemu Toivola \n", VNSTATVERSION); + printf("vnStat image output %s by Teemu Toivola \n", getversion()); return 0; } else { printf("Unknown arg \"%s\". Use --help for help.\n",argv[currentarg]); @@ -258,7 +258,7 @@ void initiparams(IPARAMS *p) void showihelp(IPARAMS *p) { - printf(" vnStat image output %s by Teemu Toivola \n\n", VNSTATVERSION); + printf(" vnStat image output %s by Teemu Toivola \n\n", getversion()); printf(" -h, --hours output hours\n"); printf(" -d, --days output days\n"); printf(" -m, --months output months\n"); diff --git a/tests/common_tests.c b/tests/common_tests.c index cf01a4a..04c50d5 100644 --- a/tests/common_tests.c +++ b/tests/common_tests.c @@ -368,6 +368,14 @@ START_TEST(isnumeric_it_is_not) } END_TEST +START_TEST(getversion_returns_a_version) +{ + ck_assert_int_gt((int)strlen(getversion()), 1); + ck_assert(strchr(getversion(), '_') == NULL); + ck_assert(strchr(getversion(), '.') != NULL); +} +END_TEST + void add_common_tests(Suite *s) { TCase *tc_common = tcase_create("Common"); @@ -395,5 +403,6 @@ void add_common_tests(Suite *s) tcase_add_test(tc_common, isnumeric_empty); tcase_add_test(tc_common, isnumeric_it_is); tcase_add_test(tc_common, isnumeric_it_is_not); + tcase_add_test(tc_common, getversion_returns_a_version); suite_add_tcase(s, tc_common); }