* regtool.cc (find_key): Add support for custom key separator.

(usage): Document it.
This commit is contained in:
Christopher Faylor 2002-08-13 15:37:32 +00:00
parent 9b6947db55
commit 403985a498
2 changed files with 19 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2002-08-07 Igor Pechtchanski <pechtcha@cs.nyu.edu>
* regtool.cc (find_key): Add support for custom key separator.
(usage): Document it.
2002-08-02 Corinna Vinschen <corinna@vinschen.de> 2002-08-02 Corinna Vinschen <corinna@vinschen.de>
* mkgroup.c (main): Don't print an entry for "Everyone". * mkgroup.c (main): Don't print an entry for "Everyone".

View File

@ -14,11 +14,15 @@ details. */
#include <getopt.h> #include <getopt.h>
#include <windows.h> #include <windows.h>
#define DEFAULT_KEY_SEPARATOR '\\'
enum enum
{ {
KT_AUTO, KT_INT, KT_STRING, KT_EXPAND, KT_MULTI KT_AUTO, KT_INT, KT_STRING, KT_EXPAND, KT_MULTI
} key_type = KT_AUTO; } key_type = KT_AUTO;
char key_sep = DEFAULT_KEY_SEPARATOR;
#define LIST_KEYS 0x01 #define LIST_KEYS 0x01
#define LIST_VALS 0x02 #define LIST_VALS 0x02
#define LIST_ALL (LIST_KEYS | LIST_VALS) #define LIST_ALL (LIST_KEYS | LIST_VALS)
@ -39,10 +43,11 @@ static struct option longopts[] =
{"string", no_argument, NULL, 's'}, {"string", no_argument, NULL, 's'},
{"verbose", no_argument, NULL, 'v'}, {"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'}, {"version", no_argument, NULL, 'V'},
{"key-separator", required_argument, NULL, 'K'},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
static char opts[] = "ehiklmpqsvV"; static char opts[] = "ehiklmpqsvVK::";
int listwhat = 0; int listwhat = 0;
int postfix = 0; int postfix = 0;
@ -83,6 +88,9 @@ usage (FILE *where = stderr)
" -m, --multi-string set type to REG_MULTI_SZ\n" " -m, --multi-string set type to REG_MULTI_SZ\n"
" -s, --string set type to REG_SZ\n" " -s, --string set type to REG_SZ\n"
"\n" "\n"
"Options for 'set' and 'unset' Actions:\n"
" -K<c>, --key-separator[=]<c> set key separator to <c> instead of '\\'\n"
"\n"
"Other Options:\n" "Other Options:\n"
" -h, --help output usage information and exit\n" " -h, --help output usage information and exit\n"
" -q, --quiet no error output, just nonzero return if KEY/VALUE missing\n" " -q, --quiet no error output, just nonzero return if KEY/VALUE missing\n"
@ -308,9 +316,9 @@ find_key (int howmanyparts, REGSAM access)
e = n + strlen (n); e = n + strlen (n);
if (howmanyparts > 1) if (howmanyparts > 1)
{ {
while (n < e && *e != '\\') while (n < e && *e != key_sep)
e--; e--;
if (*e != '\\') if (*e != key_sep)
{ {
key = wkprefixes[i].key; key = wkprefixes[i].key;
value = n; value = n;
@ -661,6 +669,9 @@ main (int argc, char **_argv)
case 'V': case 'V':
print_version (); print_version ();
exit (0); exit (0);
case 'K':
key_sep = *optarg;
break;
default : default :
usage (); usage ();
} }