diff --git a/util/proc.cpp b/util/util.cpp similarity index 95% rename from util/proc.cpp rename to util/util.cpp index bfcd3210..4af99705 100644 --- a/util/proc.cpp +++ b/util/util.cpp @@ -1,5 +1,5 @@ -/// \file proc.cpp -/// Contains generic functions for managing processes. +/// \file util.cpp +/// Contains generic functions for managing processes and configuration. #include "proc.h" #include @@ -246,3 +246,15 @@ std::string Util::Procs::getName(pid_t name){ } return ""; } + +Util::Config::Config(){ + listen_port = 4242; + daemon_mode = true; + interface = "0.0.0.0"; + configfile = "/etc/ddvtech.conf"; + username = "root"; + ignore_daemon = false; + ignore_interface = false; + ignore_port = false; + ignore_user = false; +} \ No newline at end of file diff --git a/util/proc.h b/util/util.h similarity index 61% rename from util/proc.h rename to util/util.h index 4b117f0c..4037a9ca 100644 --- a/util/proc.h +++ b/util/util.h @@ -1,5 +1,5 @@ -/// \file proc.h -/// Contains generic function headers for managing processes. +/// \file util.h +/// Contains generic function headers for managing processes and configuration. #include #include @@ -28,6 +28,27 @@ namespace Util{ static std::string getName(pid_t name); }; + /// Will set the active user to the named username. static setUser(std::string user); + + /// Deals with parsing configuration from files or commandline options. + class Config{ + private: + bool ignore_daemon; + bool ignore_interface; + bool ignore_port; + bool ignore_user; + public: + std::string configfile; + bool daemon_mode; + std::string interface; + int listen_port; + std::string username; + Config(); + void parseArgs(int argc, char ** argv); + }; + /// Will turn the current process into a daemon. + void Daemonize(); + };