20#include "uniconfdaemon.h"
21#include "uniclientconn.h"
22#include "unisecuregen.h"
23#include "unipermgen.h"
24#include "uniconfroot.h"
25#include "wvstrutils.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);
56 if (it != namedgens.end())
73 time_t commit_interval;
79 bool namedgen_cb(WvStringParm option,
void *)
85 ptr = strchr(
name.edit(),
'=');
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);
131 IUniConfGen *gen = cfg[path].mount(moniker,
false);
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),
177 args.add_option(0,
"pid-file",
178 "Specify the .pid file to use (only applies with --daemonize)",
"filename",
180 args.add_set_bool_option(
'a',
"need-auth",
181 "Require authentication on incoming connections", needauth);
182 args.add_option(
'A',
"check-access",
183 "Check all accesses against perms moniker",
"moniker",
185 args.add_option(
'l',
"listen",
186 "Listen on the given socket (eg. tcp:4111, ssl:tcp:4112)",
187 "lmoniker", lmonikers);
188 args.add_option(
'n',
"named-gen",
189 "creates a \"named\" moniker 'name' from 'moniker'",
191 wv::bind(&UniConfd::namedgen_cb,
this, _1, _2), NULL);
192 args.add_optional_arg(
"MONIKERS",
true);
193 args.set_email(
"<" WVPACKAGE_BUGREPORT
">");
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.
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...
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.
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(WvStringParm name, WvStringParm version, WvDaemonCallback cb)
void add_die_stream(IWvStream *istream, bool auto_free, const char *id)
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*)