diff -uNr wvstreams/uniconf/tests/uni.cc wvstreams.patched/uniconf/tests/uni.cc --- wvstreams/uniconf/tests/uni.cc 2010-05-11 12:01:02.000000000 +0200 +++ wvstreams.patched/uniconf/tests/uni.cc 2011-06-30 21:35:55.000000000 +0200 @@ -28,6 +28,12 @@ " del - delete all subkeys\n" " help - this text\n" "\n" + "Additional commands for llxcfg vars:\n" + " uni show [...]\n" + " uni add [...]\n" + " uni unset [...]\n" + " uni xdel [...]\n" + "\n" "You must set the UNICONF environment variable to a valid " "UniConf moniker.\n" "\n" @@ -47,10 +53,13 @@ // note: we know cmd and arg1 are non-NULL, but arg2 may be the argv // terminator, which is a NULL. That has a special meaning for some // commands, like 'set', and is different from the empty string. - const char *_cmd = argv[1], *arg1 = argv[2], + const char *_cmd = argv[1], *arg1 = argv[2], *argnull = NULL, *arg2 = argc > 3 ? argv[3] : NULL; + char *arg; + int i; WvString cmd(_cmd); strlwr(cmd.edit()); + char *varname, *varvalue; if (cmd == "help") { @@ -94,6 +103,74 @@ cfg.commit(); return 0; // always works } + else if (cmd == "show") + { + for (i = 2; i < argc; i++) + { + //fprintf(stdout,"%s",argv[i]); + arg = argv[i]; + WvString val = cfg[arg].getme(argnull); + if (!val.isnull()) + { + // fputs(arg, stdout); + // fputs(val, stdout); + // fprintf(stdout,"%s='%s';\n",arg,val); + if (strcmp(val,"''") == 0) + { + val=""; + } + wvcon->print("%s='%s';\n",arg ,val); + //fflush(stdout); // shouldn't be necessary! + } + } + return 0; + } + else if (cmd == "xshow") + { + // note: the output of this command happens to be compatible with + // (can be read by) the 'ini' UniConf backend. + UniConf::XIter i(cfg, arg1); + for (i.rewind(); i.next(); ) + wvcon->print("%s='%s';\n", + wvtcl_escape(i->fullkey(cfg), nasties), + wvtcl_escape(i->getme(""), nasties)); + } + else if (cmd == "add") + { + for (i = 2; i < argc; i++) + { + varname = strtok(argv[i],"="); + varvalue = strtok(NULL,""); + if (varvalue == NULL) + { + varvalue="''"; + } + cfg[varname].setme(varvalue); + cfg.commit(); + } + return 0; + } + else if (cmd == "unset") + { + for (i = 2; i < argc; i++) + { + arg = argv[i]; + cfg[arg].setme("''"); + cfg.commit(); + } + return 0; + } + else if (cmd == "xdel") + { + for (i = 2; i < argc; i++) + { + arg = argv[i]; + UniConf sub(cfg[arg]); + sub.remove(); + cfg.commit(); + } + return 0; + } else if (cmd == "xset") { // like set, but read from stdin