14 const string n = conf.
GetName()+
".log";
16 po::options_description config(
"Program options");
18 (
"dns", var<string>(
"localhost"),
"Dim nameserver (overwites DIM_DNS_NODE environment variable)")
19 (
"host", var<string>(
""),
"Address with which the Dim nameserver can connect to this host (overwites DIM_HOST_NODE environment variable)")
20 (
"log,l", var<string>(n),
"Write log-file")
23 conf.
AddEnv(
"dns",
"DIM_DNS_NODE");
24 conf.
AddEnv(
"host",
"DIM_HOST_NODE");
41 "The chatserv is a Dim-based chat server.\n" 43 "It is a non-interactive program which acts as a relay of messages " 44 "sent via a Dim command CHAT/MSG and which are redirected to the " 45 "logging service CHAT/MESSAGE.\n" 47 "Usage: chatserv [OPTIONS]\n" 48 " or: chatserv [OPTIONS]\n";
64 return GetCurrentState();
71 (
"|msg[string]:message to be distributed");
75 int main(
int argc,
const char *argv[])
92 cerr <<
"ERROR - Couldn't open log-file " << conf.
Get<
string>(
"log") <<
": " << strerror(errno) << endl;
A general base-class describing events issues in a state machine.
A C++ ostream to an ncurses window supporting attributes and colors.
void SetPrintUsage(const std::function< void(void)> &func)
T Get(const std::string &var)
void AddEnv(const std::string &conf, const std::string &env)
std::string GetString() const
void Setup(const std::string &dns="", const std::string &host="")
bool Has(const std::string &var)
void AddOptions(const po::options_description &opt, bool visible=true)
int HandleMsg(const EventImp &evt)
ChatServer(ostream &lout)
void SetupConfiguration(Configuration &conf)
bool PrintBootMsg(std::ostream &out, const std::string &name, bool interactive=true)
Commandline parsing, resource file parsing and database access.
int main(int argc, const char *argv[])
Class for a state machine implementation within a DIM network.
virtual int Run(bool dummy)
Start the mainloop.
bool OpenLogFile(const std::string &filename, bool append=false)
Open a log-file.
bool DoParse(int argc, const char **argv, const std::function< void()> &func=std::function< void()>())
const std::string & GetName() const