Util merge-age

This commit is contained in:
Thulinma 2011-10-17 08:42:26 +02:00
parent fdfe95e792
commit 8c29434ef4
2 changed files with 37 additions and 4 deletions

View file

@ -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 <string.h>
@ -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;
}

View file

@ -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 <unistd.h>
#include <string>
@ -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();
};