summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/main.cpp41
1 files changed, 40 insertions, 1 deletions
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<short>()->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<<ver_str;
+ return 0;
+ }
}
catch(std::exception &e)
{
@@ -280,7 +310,16 @@ extern "C" int main(int argc, char *argv[])
std::cerr<<"error: no command specified"<<std::endl;
std::cout<<desc<<std::endl;
- bpt::write_info(parsed_config_path, runtime_config.config_file); //save config on exit
+ if(!boost::filesystem::exists(boost::filesystem::path(parsed_config_path).parent_path()))
+ {
+ boost::filesystem::create_directories(boost::filesystem::path(parsed_config_path).parent_path());
+ }
+ if(!boost::filesystem::is_directory(boost::filesystem::path(parsed_config_path).parent_path()))
+ {
+ std::cerr<<"failed to save config on exit"<<std::endl;
+ }
+ else
+ bpt::write_info(parsed_config_path, runtime_config.config_file); //save config on exit