7 #include "uniconfdaemonconn.h"
8 #include "uniconfdaemon.h"
15 UniConfDaemonConn::UniConfDaemonConn(
WvStream *_s,
const UniConf &_root)
26 UniConfDaemonConn::~UniConfDaemonConn()
40 void UniConfDaemonConn::addcallback()
42 root.
add_callback(
this, wv::bind(&UniConfDaemonConn::deltacallback,
this,
47 void UniConfDaemonConn::delcallback()
71 do_invalid(command_string);
80 do_malformed(command);
87 do_malformed(command);
94 do_malformed(command);
101 do_malformed(command);
103 do_subtree(arg1, arg2.
num() == 1);
108 do_malformed(command);
110 do_haschildren(arg1);
130 do_invalid(command_string);
146 UniClientConn::cmdinfos[c].name));
150 void UniConfDaemonConn::do_noop()
162 void UniConfDaemonConn::do_get(
const UniConfKey &key)
175 root[key].
setme(value);
179 void UniConfDaemonConn::do_remove(
const UniConfKey &_key)
181 int notifications_sent = 0;
182 bool single_key =
true;
186 for (
int n = strkey.len()-1; n > 0; n--)
188 if (strkey.
edit()[n] ==
'/')
189 strkey.
edit()[n] =
' ';
204 for (it.rewind(); it.next(); )
207 WvString sect_name = getdirname(it->fullkey());
208 root[it->fullkey()].
remove();
210 if (sect_name ==
".")
211 sect_name = WvString::null;
213 if (!root[sect_name].haschildren())
217 if (++notifications_sent > CONTINUE_SELECT_AT)
219 notifications_sent = 0;
232 void UniConfDaemonConn::do_subtree(
const UniConfKey &key,
bool recursive)
234 static int niceness = 0;
242 for (it.rewind(); it.next(); )
250 if (++niceness > CONTINUE_SELECT_AT)
260 for (it.rewind(); it.next(); )
277 void UniConfDaemonConn::do_haschildren(
const UniConfKey &key)
285 void UniConfDaemonConn::do_commit()
292 void UniConfDaemonConn::do_refresh()
301 void UniConfDaemonConn::do_quit()
308 void UniConfDaemonConn::do_help()
310 for (
int i = 0; i < UniClientConn::NUM_COMMANDS; ++i)
311 writetext(UniClientConn::cmdinfos[i].description);
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
This iterator performs depth-first traversal of a subtree.
void remove() const
Removes this key and all of its children from the registry.
Functions to handle "tcl-style" strings and lists.
Represents a connection to a UniConf daemon via any WvStream.
This iterator walks through all immediate children of a UniConf node.
void writevalue(const UniConfKey &key, WvStringParm value)
Writes a PART_VALUE message.
bool isnull() const
returns true if this string is null
bool continue_select(time_t msec_timeout)
return to the caller from execute(), but don't really return exactly; this uses WvCont::yield() to re...
void commit() const
Commits information about this key recursively.
virtual bool isok() const
return true if the stream is actually usable right now
int num() const
Return a stdc++ string with the contents of this string.
void writetext(WvStringParm text)
Writes a PART_TEXT message.
bool uses_continue_select
If this is set, enables the use of continue_select().
void del_callback(void *cookie, bool recurse=true) const
Cancels notification requested using add_callback().
bool haschildren() const
Returns true if this key has children.
void append(const UniConfKey &other)
Appends a path to this path.
virtual void close()
Close this stream.
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
WvString readarg()
Reads the next argument from the command payload.
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
char * edit()
make the string editable, and return a non-const (char*)
Command readcmd()
Reads a command from the connection.
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
WvString spacecat(WvStringParm a, WvStringParm b, char sep= ' ', bool onesep=false)
return the string formed by concatenating string 'a' and string 'b' with the 'sep' character between ...
UniConf instances function as handles to subtrees of a UniConf tree and expose a high-level interface...
void writecmd(Command command, WvStringParm payload=WvString::null)
Writes a command to the connection.
WvString wvtcl_escape(WvStringParm s, const WvStringMask &nasties=WVTCL_NASTY_SPACES)
tcl-escape a string.
void terminate_continue_select()
you MUST run this from your destructor if you use continue_select(), or very weird things will happen...
UniConfKey fullkey() const
Returns the full path of this node, starting at the root.
Various little string functions.
void writeok(WvStringParm payload="")
Writes a REPLY_OK message.
char * trim_string(char *string)
Trims whitespace from the beginning and end of the character string, including carriage return / line...
void setme(WvStringParm value) const
Stores a string value for this key into the registry.
bool refresh() const
Refreshes information about this key recursively.
WvString is an implementation of a simple and efficient printable-string class.
void writeonevalue(const UniConfKey &key, WvStringParm value)
Writes a PART_VALUE message.
void add_callback(void *cookie, const UniConfCallback &callback, bool recurse=true) const
Requests notification when any of the keys covered by the recursive depth specification change by inv...
void writefail(WvStringParm payload="")
Writes a REPLY_FAIL message.
virtual void close()
Close this stream.