From d9ffc27c8b563d76a493ec9eafad56ec5dda13b9 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Wed, 3 Aug 2016 19:35:48 +0300 Subject: server: core: added check for config directory on config save (crash fix) added "--version" option --- server/src/main.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'server/src/main.cpp') diff --git a/server/src/main.cpp b/server/src/main.cpp index 7dcd83d..f35522b 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -38,6 +38,8 @@ core_api *module_api = nullptr; modules_handler *modules = nullptr; +const char* core_version = "0.0.0.1draft"; + namespace bpo = boost::program_options; @@ -79,6 +81,12 @@ void sig_handler(int sig) boost::asio::io_service io_service_server; +std::string cxx_ver_string(int a, int b, int c) { + std::ostringstream ss; + ss << a << '.' << b << '.' << c; + return ss.str(); +} + extern "C" int main(int argc, char *argv[]) { //handle signals @@ -100,6 +108,7 @@ extern "C" int main(int argc, char *argv[]) ("list-modules", "list all installed modules (you can set verbosity level, accepted values from 0 to 1, default = 0)") ("verbosity,v", bpo::value()->default_value(0), "set global verbosity level") ("run", "start UDM server") + ("version,V", "Get core version") ; bool daemon = false, run = false; @@ -199,6 +208,27 @@ extern "C" int main(int argc, char *argv[]) { run = true; } + if(vm.count("version")) + { + std::string ver_str = "udm core version: ", cxx_ver = + //from http://stackoverflow.com/questions/38530981/output-compiler-version-in-a-c-program +#ifdef __clang__ + cxx_ver_string(__clang_major__, __clang_minor__, __clang_patchlevel__); +#else + cxx_ver_string(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); +#endif + ver_str += core_version; + ver_str += "\nCompiled with: "; +#ifdef __clang__ + ver_str += "clang "; +#else + ver_str += "gcc "; +#endif + ver_str += cxx_ver; + ver_str += "\n"; + std::cout<