From d772c76b6e118e416f56cc0d613d1a0bd98db66b Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Sat, 14 May 2016 21:31:17 +0100 Subject: [PATCH 1/5] Add VERSION to STDERR and log messages that output the string MMDVMHost They now output the string MMDVMHost-yyymmdd a) for completeness and; b) to quickly output the version number by calling the host executable with no arguments so Kim can easily grab it for his dashboard. I did think about a -v|--version argument, but this was much simpler for the purpose. --- MMDVMHost.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index af49fd8..2bc63c6 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -128,13 +128,13 @@ int CMMDVMHost::run() { bool ret = m_conf.read(); if (!ret) { - ::fprintf(stderr, "MMDVMHost: cannot read the .ini file\n"); + ::fprintf(stderr, "MMDVMHost-%s: cannot read the .ini file\n", VERSION); return 1; } ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); if (!ret) { - ::fprintf(stderr, "MMDVMHost: unable to open the log file\n"); + ::fprintf(stderr, "MMDVMHost-%s: unable to open the log file\n", VERSION); return 1; } @@ -306,7 +306,7 @@ int CMMDVMHost::run() setMode(MODE_IDLE); - LogMessage("MMDVMHost is running"); + LogMessage("MMDVMHost-%s is running", VERSION); while (!m_killed) { bool lockout = m_modem->hasLockout(); @@ -554,7 +554,7 @@ int CMMDVMHost::run() } } - LogMessage("MMDVMHost is exiting on receipt of SIGHUP1"); + LogMessage("MMDVMHost-%s is exiting on receipt of SIGHUP1", VERSION); setMode(MODE_IDLE); From 4d44936e1452570e309b15218f91c194970ae040 Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Sat, 14 May 2016 23:26:16 +0100 Subject: [PATCH 2/5] Remove the version from STDERR messages and add -v | --version flag --- MMDVMHost.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 2bc63c6..9c76e3f 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -72,8 +72,17 @@ const char* HEADER4 = "Copyright(C) 2015, 2016 by Jonathan Naylor, G4KLX and oth int main(int argc, char** argv) { const char* iniFile = DEFAULT_INI_FILE; - if (argc > 1) - iniFile = argv[1]; + if (argc > 1) { + for (int currentArg = 1; currentArg < argc; ++currentArg) { + std::string arg = argv[currentArg]; + if ((arg == "-v") || (arg == "--version")) { + ::fprintf(stdout, "MMDVMHost %s\n", VERSION); + return 0; + } else { + iniFile = argv[currentArg]; + } + } + } #if !defined(_WIN32) && !defined(_WIN64) ::signal(SIGTERM, sigHandler); @@ -128,13 +137,13 @@ int CMMDVMHost::run() { bool ret = m_conf.read(); if (!ret) { - ::fprintf(stderr, "MMDVMHost-%s: cannot read the .ini file\n", VERSION); + ::fprintf(stderr, "MMDVMHost: cannot read the .ini file\n"); return 1; } ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); if (!ret) { - ::fprintf(stderr, "MMDVMHost-%s: unable to open the log file\n", VERSION); + ::fprintf(stderr, "MMDVMHost: unable to open the log file\n"); return 1; } From db8adfcfe0678ac7b239ff03d1ebed05b8e0446a Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Sat, 14 May 2016 23:31:33 +0100 Subject: [PATCH 3/5] Clean up tabbing --- MMDVMHost.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 9c76e3f..b9d7f68 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -71,8 +71,8 @@ const char* HEADER4 = "Copyright(C) 2015, 2016 by Jonathan Naylor, G4KLX and oth int main(int argc, char** argv) { - const char* iniFile = DEFAULT_INI_FILE; - if (argc > 1) { + const char* iniFile = DEFAULT_INI_FILE; + if (argc > 1) { for (int currentArg = 1; currentArg < argc; ++currentArg) { std::string arg = argv[currentArg]; if ((arg == "-v") || (arg == "--version")) { From 2723e0c8423eab39d098a034f2862125411af809 Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Sun, 15 May 2016 06:59:09 +0100 Subject: [PATCH 4/5] Capture bad command line arguments --- MMDVMHost.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index b9d7f68..94e7487 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -78,6 +78,9 @@ int main(int argc, char** argv) if ((arg == "-v") || (arg == "--version")) { ::fprintf(stdout, "MMDVMHost %s\n", VERSION); return 0; + } else if (arg.substr(0,1) == "-") { + ::fprintf(stderr, "Usage: MMDVMHost [-v|--version] [filename]\n"); + return 1; } else { iniFile = argv[currentArg]; } From 2256b8d025cd4ea527b7b2592f92244b56f57d9c Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Sun, 15 May 2016 07:06:38 +0100 Subject: [PATCH 5/5] Add word version to output --- MMDVMHost.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 94e7487..db111d7 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -76,7 +76,7 @@ int main(int argc, char** argv) for (int currentArg = 1; currentArg < argc; ++currentArg) { std::string arg = argv[currentArg]; if ((arg == "-v") || (arg == "--version")) { - ::fprintf(stdout, "MMDVMHost %s\n", VERSION); + ::fprintf(stdout, "MMDVMHost version %s\n", VERSION); return 0; } else if (arg.substr(0,1) == "-") { ::fprintf(stderr, "Usage: MMDVMHost [-v|--version] [filename]\n");