2#include "uniconfroot.h"
5#include "wvstringmask.h"
9#pragma comment(linker, "/include:?UniRegistryGenMoniker@@3V?$WvMoniker@VIUniConfGen@@@@A")
10#pragma comment(linker, "/include:?UniPStoreGenMoniker@@3V?$WvMoniker@VIUniConfGen@@@@A")
11#pragma comment(linker, "/include:?UniIniGenMoniker@@3V?$WvMoniker@VIUniConfGen@@@@A")
17 "Usage: uni <cmd> <key> [extra stuff...]\n"
18 " where <cmd> is one of:\n"
19 " get - get the value of a key, with optional default\n"
20 " set - set a key to the given value from the command line\n"
21 " xset - set a key to the given value from stdin\n"
22 " keys - list the subkeys of a key\n"
23 " hkeys - list the subkeys of a key, their subkeys, etc\n"
24 " xkeys - list keys that match a wildcard\n"
25 " dump - list the subkeys/values of a key (key=value)\n"
26 " hdump - list the subkeys/values recursively\n"
27 " xdump - list keys/values that match a wildcard\n"
28 " del - delete all subkeys\n"
31 "You must set the UNICONF environment variable to a valid "
34 "Report bugs to <" WVPACKAGE_BUGREPORT
">.\n");
37int main(
int argc,
char **argv)
50 const char *_cmd = argv[1], *arg1 = argv[2],
51 *arg2 = argc > 3 ? argv[3] : NULL;
61 const char *confuri = getenv(
"UNICONF");
64 fprintf(stderr,
"%s: UNICONF environment variable not set!\n",
71 if (!cfg.whichmount() || !cfg.whichmount()->isok())
73 fprintf(stderr,
"%s: can't connect to uniconf at '%s'\n",
81 WvString val = cfg[arg1].getme(arg2);
91 else if (cmd ==
"set")
93 cfg[arg1].setme(arg2);
97 else if (cmd ==
"xset")
103 while (wvcon->
isok())
105 cptr = (
char *)buf.
alloc(10240);
106 len = wvcon->
read(cptr, 10240);
109 cfg[arg1].setme(buf.getstr());
113 else if (cmd ==
"keys")
116 for (i.rewind(); i.next(); )
118 WVTCL_NASTY_NEWLINES));
120 else if (cmd ==
"hkeys")
124 for (i.rewind(); i.next(); )
126 WVTCL_NASTY_NEWLINES));
128 else if (cmd ==
"xkeys")
131 for (i.rewind(); i.next(); )
133 WVTCL_NASTY_NEWLINES));
135 else if (cmd ==
"dump")
140 for (i.rewind(); i.next(); )
141 wvcon->print(
"%s = %s\n",
145 else if (cmd ==
"hdump")
151 for (i.rewind(); i.next(); )
152 wvcon->print(
"%s = %s\n",
156 else if (cmd ==
"xdump")
161 for (i.rewind(); i.next(); )
162 wvcon->print(
"%s = %s\n",
166 else if (cmd ==
"del")
174 fprintf(stderr,
"%s: unknown command '%s'!\n", argv[0], _cmd);
Represents the root of a hierarhical registry consisting of pairs of UniConfKeys and associated strin...
This iterator walks through all immediate children of a UniConf node.
This iterator performs depth-first traversal of a subtree.
This iterator walks over all children that match a wildcard pattern.
UniConf instances function as handles to subtrees of a UniConf tree and expose a high-level interface...
void unalloc(size_t count)
Unallocates exactly the specified number of elements by removing them from the buffer and releasing t...
T * alloc(size_t count)
Allocates exactly the specified number of elements and returns a pointer to an UNINITIALIZED storage ...
bool isnull() const
returns true if this string is null
Captures formatted log messages and outputs them to the specified file descriptor.
virtual bool isok() const
return true if the stream is actually usable right now
virtual size_t read(void *buf, size_t count)
read a data block on the stream.
A class used to provide a masked lookup for characters in a string.
WvString is an implementation of a simple and efficient printable-string class.
char * strlwr(char *string)
In-place modify a character string so that all contained letters are in lower case.
Functions to handle "tcl-style" strings and lists.
WvString wvtcl_escape(WvStringParm s, const WvStringMask &nasties=WVTCL_NASTY_SPACES)
tcl-escape a string.