1 #include "wvautoconf.h"
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");
37 int 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);