20#include "uniconfdaemon.h"
21#include "uniclientconn.h"
22#include "unisecuregen.h"
23#include "unipermgen.h"
24#include "uniconfroot.h"
26#include "wvfileutils.h"
27#include "wvstreamsdaemon.h"
40#pragma comment(linker, "/include:?UniRegistryGenMoniker@@3V?$WvMoniker@VIUniConfGen@@@@A")
41#pragma comment(linker, "/include:?UniPStoreGenMoniker@@3V?$WvMoniker@VIUniConfGen@@@@A")
42#pragma comment(linker, "/include:?UniIniGenMoniker@@3V?$WvMoniker@VIUniConfGen@@@@A")
45#define DEFAULT_CONFIG_FILE "ini:uniconf.ini"
48static map<WvString, shared_ptr<IUniConfGen> > namedgens;
53 map<WvString, shared_ptr<IUniConfGen> >::iterator it = namedgens.find(s);
54 shared_ptr<IUniConfGen> gen;
56 if (it != namedgens.end())
73 time_t commit_interval;
93 namedgens[
name] = shared_ptr<IUniConfGen>(
94 wvcreate<IUniConfGen>(moniker),
107 s->
alarm(commit_interval * 1000);
114 WvStringList::Iter i(_extra_args);
115 for (i.rewind(); i.next(); )
118 char *cptr = strchr(path.
edit(),
'=');
130 log(
"Mounting '%s' on '%s': ", moniker, path);
132 if (gen && gen->
isok())
141 permgen = !!permmon ? wvcreate<IUniConfGen>(permmon) : NULL;
146 if (lmonikers.isempty())
148 log(WvLog::Critical,
"Can't start: no listeners given!\n");
153 WvStringList::Iter i(lmonikers);
154 for (i.rewind(); i.next(); )
158 commit_stream->
setcallback(wv::bind(&UniConfd::commit_stream_cb,
this,
160 commit_stream->
alarm(commit_interval * 1000);
171 wv::bind(&UniConfd::startup,
this)),
173 commit_interval(5*60),
178 "Specify the .pid file to use (only applies with --daemonize)",
"filename",
181 "Require authentication on incoming connections", needauth);
183 "Check all accesses against perms moniker",
"moniker",
186 "Listen on the given socket (eg. tcp:4111, ssl:tcp:4112)",
187 "lmoniker", lmonikers);
189 "creates a \"named\" moniker 'name' from 'moniker'",
191 wv::bind(&UniConfd::namedgen_cb,
this, _1, _2), NULL);
199int main(
int argc,
char **argv)
203 return uniconfd.
run(argc, argv);
The basic interface which is included by all other XPLC interfaces and objects.
virtual unsigned int release()=0
Indicate that you are finished using this object.
An abstract data container that backs a UniConf tree.
virtual bool isok()=0
Determines if the generator is usable and working properly.
virtual bool refresh()=0
Refreshes information about a key recursively.
void listen(WvStringParm lmoniker)
Start listening on a socket described by the given WvListener moniker.
Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated strin...
void commit() const
Commits information about this key recursively.
bool refresh() const
Refreshes information about this key recursively.
IUniConfGen * mount(WvStringParm moniker, bool refresh=true) const
Mounts a generator at this key using a moniker.
void add_optional_arg(WvStringParm desc, bool multiple=false)
Add an optional argument to the list of parameters.
void add_option(char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, int &val)
Add a switch that takes an integer argument.
void set_email(WvStringParm email)
Set the e-mail address for bug reports.
void add_set_bool_option(char short_option, WvStringParm long_option, WvStringParm desc, bool &val)
Add a boolean option, which, when specified, sets the specified boolean variable to true.
WvString pid_file
The path to the pid file to use for the daemon; defaults to /var/run/name.pid, where name is above.
WvString name
The name and version of the daemon; used for -V and logging.
int run(const char *argv0)
Run the daemon with no argument processing. Returns exit status.
WvLog log
The daemon's log mechanism.
void die(int status=0)
Force the daemon to exit as soon as the run callback exits.
WvArgs args
The arguments the daemon accepts; the defaults are described above.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
void alarm(time_t msec_timeout)
set an alarm, ie.
void setcallback(IWvStreamCallback _callfunc)
define the callback function for this stream, called whenever the callback() member is run,...
WvStreamsDaemon - High-level abstraction for a daemon process that does nothing but add streams to th...
void add_die_stream(IWvStream *istream, bool auto_free, const char *id)
Add a stream to the daemon; if the stream goes !isok() the daemon will exit.
This is a WvList of WvStrings, and is a really handy way to parse strings.
WvString is an implementation of a simple and efficient printable-string class.
char * edit()
make the string editable, and return a non-const (char*)
Various little string functions.