7#include "uniclientconn.h"
25 UniClientConn::NUM_COMMANDS] = {
27 {
"noop",
"noop: verify that the connection is active" },
28 {
"get",
"get <key>: get the value of a key" },
29 {
"set",
"set <key> <value>: sets the value of a key" },
30 {
"setv",
"setv <key> <value> ...: set multiple key-value pairs" },
31 {
"del",
"del <key>: deletes the key" },
32 {
"subt",
"subt <key> <recurse?>: enumerates the children of a key" },
33 {
"hchild",
"hchild <key>: returns whether a key has children" },
34 {
"commit",
"commit: commits changes to disk" },
35 {
"refresh",
"refresh: refresh contents from disk" },
36 {
"quit",
"quit: kills the session nicely" },
37 {
"help",
"help: returns this help text" },
40 {
"OK",
"OK <payload>: reply on command success" },
41 {
"FAIL",
"FAIL <payload>: reply on command failure" },
42 {
"CHILD",
"CHILD <key> TRUE / FALSE: key has children or not" },
43 {
"ONEVAL",
"ONEVAL <key> <value>: reply to a get" },
46 {
"VAL",
"VAL <key> <value>: intermediate reply value of a key" },
47 {
"TEXT",
"TEXT <text>: intermediate reply of a text message" },
50 {
"HELLO",
"HELLO <version> <message>: sent by server on connection" },
51 {
"NOTICE",
"NOTICE <key> <oldval> <newval>: forget key and its children" },
57 log(
WvString(
"UniConf to %s", dst.isnull() && _s->src() ? *_s->src() :
WvString(dst)),
58 WvLog::Debug5), closed(false), version(-1), payloadbuf(
"")
64UniClientConn::~UniClientConn()
90 char *line =
getline(0,
'\n', 20480);
103 return WvString::null;
107 log(
"Read: %s\n", word);
139 for (
int i = 0; i < NUM_COMMANDS; ++i)
140 if (strcasecmp(cmdinfos[i].name, command.
cstr()) == 0)
175 if (value == WvString::null)
void writeonevalue(const UniConfKey &key, WvStringParm value)
Writes a PART_VALUE message.
virtual void close()
Close this stream.
Command readcmd()
Reads a command from the connection.
void writetext(WvStringParm text)
Writes a PART_TEXT message.
void writecmd(Command command, WvStringParm payload=WvString::null)
Writes a command to the connection.
UniClientConn(IWvStream *_s, WvStringParm dst=WvString::null)
Create a wrapper around the supplied WvStream.
void writefail(WvStringParm payload="")
Writes a REPLY_FAIL message.
WvString readarg()
Reads the next argument from the command payload.
WvConstStringBuffer payloadbuf
void writeok(WvStringParm payload="")
Writes a REPLY_OK message.
void writevalue(const UniConfKey &key, WvStringParm value)
Writes a PART_VALUE message.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
void put(const T *data, size_t count)
Writes the specified number of elements from the specified storage location into the buffer at its ta...
void zap()
Clears the buffer.
void reset(WvStringParm _str)
Resets the buffer contents to a new string.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
bool isnull() const
returns true if this string is null
const char * cstr() const
return a (const char *) for this string.
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
WvStreamClone simply forwards all requests to the "cloned" stream.
virtual void close()
Close this stream.
virtual bool isok() const
return true if the stream is actually usable right now
virtual size_t write(const void *buf, size_t count)
Write data to the stream.
char * getline(time_t wait_msec=0, char separator='\n', int readahead=1024)
Read up to one line of data from the stream and return a pointer to the internal buffer containing th...
WvString is an implementation of a simple and efficient printable-string class.
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 ...
Functions to handle "tcl-style" strings and lists.
WvString wvtcl_escape(WvStringParm s, const WvStringMask &nasties=WVTCL_NASTY_SPACES)
tcl-escape a string.
WvString wvtcl_getword(WvBuf &buf, const WvStringMask &splitchars=WVTCL_SPLITCHARS, bool do_unescape=true)
Get a single tcl word from an input buffer, and return the rest of the buffer untouched.