|
MistServer
2.5.3-Pro-19-gf5e75b1 ( Generic_64)
|
Deals with parsing configuration from commandline options. More...
#include <config.h>
Public Member Functions | |
| Config () | |
| Config () | |
| Config (std::string cmd) | |
| Creates a new configuration manager. More... | |
| Config (std::string cmd) | |
| void | activate () |
| Activated the stored config. More... | |
| void | activate () |
| void | addBasicConnectorOptions (JSON::Value &capabilities) |
| void | addBasicConnectorOptions (JSON::Value &capabilities) |
| Adds the default connector options. Also updates the capabilities structure with the default options. More... | |
| void | addConnectorOptions (int port, JSON::Value &capabilities) |
| Adds the default connector options. More... | |
| void | addConnectorOptions (int port, JSON::Value &capabilities) |
| void | addOption (std::string optname, JSON::Value option) |
| void | addOption (std::string optname, JSON::Value option) |
| Adds an option to the configuration parser. More... | |
| int | forkServer (Socket::Server &server_socket, int(*callback)(Socket::Connection &S)) |
| int | forkServer (Socket::Server &server_socket, int(*callback)(Socket::Connection &S)) |
| bool | getBool (std::string optname) |
| Returns the current value of an option or default if none was set as a bool. More... | |
| bool | getBool (std::string optname) |
| long long int | getInteger (std::string optname) |
| Returns the current value of an option or default if none was set as a long long int. More... | |
| long long int | getInteger (std::string optname) |
| JSON::Value & | getOption (std::string optname, bool asArray=false) |
| Returns a reference to the current value of an option or default if none was set. More... | |
| JSON::Value & | getOption (std::string optname, bool asArray=false) |
| std::string | getString (std::string optname) |
| std::string | getString (std::string optname) |
| Returns the current value of an option or default if none was set as a string. More... | |
| bool | parseArgs (int &argc, char **&argv) |
| Parses commandline arguments. More... | |
| bool | parseArgs (int &argc, char **&argv) |
| void | printHelp (std::ostream &output) |
| Prints a usage message to the given output. More... | |
| void | printHelp (std::ostream &output) |
| int | serveForkedSocket (int(*callback)(Socket::Connection &S)) |
| int | serveForkedSocket (int(*callback)(Socket::Connection &S)) |
| int | servePlainSocket (int(*callback)(Socket::Connection &S)) |
| int | servePlainSocket (int(*callback)(Socket::Connection &S)) |
| int | serveThreadedSocket (int(*callback)(Socket::Connection &S)) |
| int | serveThreadedSocket (int(*callback)(Socket::Connection &S)) |
| int | threadServer (Socket::Server &server_socket, int(*callback)(Socket::Connection &S)) |
| int | threadServer (Socket::Server &server_socket, int(*callback)(Socket::Connection &S)) |
Static Public Attributes | |
| static bool | is_active = false |
| Set to true by activate(), set to false by the signal handler. More... | |
| static unsigned int | printDebugLevel = DEBUG |
Static Private Member Functions | |
| static void | signal_handler (int signum, siginfo_t *sigInfo, void *ignore) |
| Basic signal handler. More... | |
| static void | signal_handler (int signum, siginfo_t *sigInfo, void *ignore) |
Private Attributes | |
| int | long_count |
| JSON::Value | vals |
| Holds all current config values. More... | |
Deals with parsing configuration from commandline options.
| Util::Config::Config | ( | ) |
| Util::Config::Config | ( | std::string | cmd | ) |
Creates a new configuration manager.
| Util::Config::Config | ( | ) |
| Util::Config::Config | ( | std::string | cmd | ) |
| void Util::Config::activate | ( | ) |
Activated the stored config.
This will:
| void Util::Config::activate | ( | ) |
| void Util::Config::addBasicConnectorOptions | ( | JSON::Value & | capabilities | ) |
Adds the default connector options. Also updates the capabilities structure with the default options.
| void Util::Config::addBasicConnectorOptions | ( | JSON::Value & | capabilities | ) |
| void Util::Config::addConnectorOptions | ( | int | port, |
| JSON::Value & | capabilities | ||
| ) |
Adds the default connector options.
Also updates the capabilities structure with the default options. Besides the options addBasicConnectorOptions adds, this function also adds port and interface options.
| void Util::Config::addConnectorOptions | ( | int | port, |
| JSON::Value & | capabilities | ||
| ) |
| void Util::Config::addOption | ( | std::string | optname, |
| JSON::Value | option | ||
| ) |
Adds an option to the configuration parser.
The option needs an unique name (doubles will overwrite the previous) and can contain the following in the option itself:
| void Util::Config::addOption | ( | std::string | optname, |
| JSON::Value | option | ||
| ) |
| int Util::Config::forkServer | ( | Socket::Server & | server_socket, |
| int(*)(Socket::Connection &S) | callback | ||
| ) |
| int Util::Config::forkServer | ( | Socket::Server & | server_socket, |
| int(*)(Socket::Connection &S) | callback | ||
| ) |
| bool Util::Config::getBool | ( | std::string | optname | ) |
Returns the current value of an option or default if none was set as a bool.
Calls getOption internally.
| bool Util::Config::getBool | ( | std::string | optname | ) |
| long long int Util::Config::getInteger | ( | std::string | optname | ) |
| long long int Util::Config::getInteger | ( | std::string | optname | ) |
Returns the current value of an option or default if none was set as a long long int.
Calls getOption internally.
| JSON::Value & Util::Config::getOption | ( | std::string | optname, |
| bool | asArray = false |
||
| ) |
Returns a reference to the current value of an option or default if none was set.
If the option does not exist, this exits the application with a return code of 37.
| JSON::Value& Util::Config::getOption | ( | std::string | optname, |
| bool | asArray = false |
||
| ) |
| std::string Util::Config::getString | ( | std::string | optname | ) |
| std::string Util::Config::getString | ( | std::string | optname | ) |
Returns the current value of an option or default if none was set as a string.
Calls getOption internally.
| bool Util::Config::parseArgs | ( | int & | argc, |
| char **& | argv | ||
| ) |
| bool Util::Config::parseArgs | ( | int & | argc, |
| char **& | argv | ||
| ) |
Parses commandline arguments.
Calls exit if an unknown option is encountered, printing a help message.
| void Util::Config::printHelp | ( | std::ostream & | output | ) |
| void Util::Config::printHelp | ( | std::ostream & | output | ) |
Prints a usage message to the given output.
| int Util::Config::serveForkedSocket | ( | int(*)(Socket::Connection &S) | callback | ) |
| int Util::Config::serveForkedSocket | ( | int(*)(Socket::Connection &S) | callback | ) |
| int Util::Config::servePlainSocket | ( | int(*)(Socket::Connection &S) | callback | ) |
| int Util::Config::servePlainSocket | ( | int(*)(Socket::Connection &S) | callback | ) |
| int Util::Config::serveThreadedSocket | ( | int(*)(Socket::Connection &S) | callback | ) |
| int Util::Config::serveThreadedSocket | ( | int(*)(Socket::Connection &S) | callback | ) |
|
staticprivate |
Basic signal handler.
Sets is_active to false if it receives a SIGINT, SIGHUP or SIGTERM signal, reaps children for the SIGCHLD signal, and ignores all other signals.
|
staticprivate |
| int Util::Config::threadServer | ( | Socket::Server & | server_socket, |
| int(*)(Socket::Connection &S) | callback | ||
| ) |
| int Util::Config::threadServer | ( | Socket::Server & | server_socket, |
| int(*)(Socket::Connection &S) | callback | ||
| ) |
|
static |
Set to true by activate(), set to false by the signal handler.
|
private |
|
static |
|
private |
Holds all current config values.
1.8.11