1 #include "wvautoconf.h"
11 #include <sys/types.h>
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"
48 static 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;
79 bool namedgen_cb(WvStringParm option,
void *)
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);
199 int main(
int argc,
char **argv)
203 return uniconfd.
run(argc, argv);
char * edit()
make the string editable, and return a non-const (char*)
bool refresh() const
Refreshes information about this key recursively.
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 commit() const
Commits information about this key recursively.
WvArgs args
The arguments the daemon accepts; the defaults are described above.
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.
void listen(WvStringParm lmoniker)
Start listening on a socket described by the given WvListener moniker.
WvString is an implementation of a simple and efficient printable-string class.
An abstract data container that backs a UniConf tree.
WvStreamsDaemon(WvStringParm name, WvStringParm version, WvDaemonCallback cb)
Construct a new WvStreamsDaemon with given name and version, and use the cb function to populate the ...
void set_email(WvStringParm email)
Set the e-mail address for bug reports.
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
virtual unsigned int release()=0
Indicate that you are finished using this object.
WvLog log
The daemon's log mechanism.
void alarm(time_t msec_timeout)
set an alarm, ie.
WvStreamsDaemon - High-level abstraction for a daemon process that does nothing but add streams to th...
WvString name
The name and version of the daemon; used for -V and logging.
void die(int status=0)
Force the daemon to exit as soon as the run callback exits.
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
IUniConfGen * mount(WvStringParm moniker, bool refresh=true) const
Mounts a generator at this key using a moniker.
int run(const char *argv0)
Run the daemon with no argument processing. Returns exit status.
virtual bool isok()=0
Determines if the generator is usable and working properly.
void setcallback(IWvStreamCallback _callfunc)
define the callback function for this stream, called whenever the callback() member is run,...
virtual bool refresh()=0
Refreshes information about a key recursively.
void add_optional_arg(WvStringParm desc, bool multiple=false)
Add an optional argument to the list of parameters.
Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated strin...
This is a WvList of WvStrings, and is a really handy way to parse strings.
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.