* regtool.cc (Fail): Be more verbose.

(find_key): Add support for remote registry access.
	(usage): Document it.
	* utils.sgml: Document it.
This commit is contained in:
Corinna Vinschen 2002-06-07 11:12:16 +00:00
parent 9d0efbb3ae
commit 381fb8baa1
3 changed files with 71 additions and 21 deletions

View File

@ -1,3 +1,10 @@
2002-06-06 Egor Duda <deo@logos-m.ru>
* regtool.cc (Fail): Be more verbose.
(find_key): Add support for remote registry access.
(usage): Document it.
* utils.sgml: Document it.
2002-06-06 Christopher Faylor <cgf@redhat.com> 2002-06-06 Christopher Faylor <cgf@redhat.com>
* strace.cc (main): Make toggle a local variable. * strace.cc (main): Make toggle a local variable.

View File

@ -91,12 +91,16 @@ usage (FILE *where = stderr)
"\n"); "\n");
if (where == stdout) if (where == stdout)
fprintf (where, "" fprintf (where, ""
"KEY is in the format \\prefix\\KEY\\KEY\\VALUE, where prefix is any of:\n" "KEY is in the format [host]\\prefix\\KEY\\KEY\\VALUE, where host is optional\n"
" \\root HKCR HKEY_CLASSES_ROOT\n" "remote host in either \\\\hostname or hostname: format and prefix is any of:\n"
" \\config HKCC HKEY_CURRENT_CONFIG\n" " root HKCR HKEY_CLASSES_ROOT (local only)\n"
" \\user HKCU HKEY_CURRENT_USER\n" " config HKCC HKEY_CURRENT_CONFIG (local only)\n"
" \\machine HKLM HKEY_LOCAL_MACHINE\n" " user HKCU HKEY_CURRENT_USER (local only)\n"
" \\users HKU HKEY_USERS\n" " machine HKLM HKEY_LOCAL_MACHINE\n"
" users HKU HKEY_USERS\n"
"\n"
"You can use forward slash ('/') as a separator instead of backslash, in\n"
"that case backslash is treated as escape character\n"
""); "");
fprintf (where, "" fprintf (where, ""
"Example: %s get '\\user\\software\\Microsoft\\Clock\\iFormat'\n", prog_name); "Example: %s get '\\user\\software\\Microsoft\\Clock\\iFormat'\n", prog_name);
@ -136,7 +140,7 @@ Fail (DWORD rv)
FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM, | FORMAT_MESSAGE_FROM_SYSTEM,
0, rv, 0, (CHAR *) & buf, 0, 0); 0, rv, 0, (CHAR *) & buf, 0, 0);
fprintf (stderr, "Error: %s\n", buf); fprintf (stderr, "Error (%ld): %s\n", rv, buf);
LocalFree (buf); LocalFree (buf);
} }
exit (1); exit (1);
@ -251,12 +255,38 @@ translate (char *key)
void void
find_key (int howmanyparts, REGSAM access) find_key (int howmanyparts, REGSAM access)
{ {
char *n = argv[0], *e, c; HKEY base;
int rv;
char *n = argv[0], *e, *h, c;
char* host = NULL;
int i; int i;
if (*n == '/') if (*n == '/')
translate (n); translate (n);
while (*n == '\\') if (*n != '\\')
{
/* expect host:/key/value format */
host = (char*) malloc (strlen (n) + 1);
host[0] = host [1] = '\\';
for (e = n, h = host + 2; *e && *e != ':'; e++, h++)
*h = *e;
*h = 0;
n = e + 1;
if (*n == '/')
translate (n);
}
else if (n[0] == '\\' && n[1] == '\\')
{
/* expect //host/key/value format */
host = (char*) malloc (strlen (n) + 1);
host[0] = host[1] = '\\';
for (e = n + 2, h = host + 2; *e && *e != '\\'; e++, h++)
*h = *e;
*h = 0;
n = e;
}
while (*n != '\\')
n++; n++;
*n++ = 0;
for (e = n; *e && *e != '\\'; e++); for (e = n; *e && *e != '\\'; e++);
c = *e; c = *e;
*e = 0; *e = 0;
@ -292,14 +322,24 @@ find_key (int howmanyparts, REGSAM access)
value = e + 1; value = e + 1;
} }
} }
if (n[0] == 0) if (host)
{ {
key = wkprefixes[i].key; rv = RegConnectRegistry (host, wkprefixes[i].key, &base);
return; if (rv != ERROR_SUCCESS)
Fail (rv);
free (host);
}
else
base = wkprefixes[i].key;
if (n[0] == 0)
key = base;
else
{
rv = RegOpenKeyEx (base, n, 0, access, &key);
if (rv != ERROR_SUCCESS)
Fail (rv);
} }
int rv = RegOpenKeyEx (wkprefixes[i].key, n, 0, access, &key);
if (rv != ERROR_SUCCESS)
Fail (rv);
//printf("key `%s' value `%s'\n", n, value); //printf("key `%s' value `%s'\n", n, value);
} }

View File

@ -710,12 +710,15 @@ Regtool Copyright (c) 2000 Red Hat Inc
regtool [-v] unset [key\value] - removes value from key regtool [-v] unset [key\value] - removes value from key
regtool [-q] get [key\value] - prints value to stdout regtool [-q] get [key\value] - prints value to stdout
-q=quiet, no error msg, just return nonzero exit if key/value missing -q=quiet, no error msg, just return nonzero exit if key/value missing
keys are like \prefix\key\key\key\value, where prefix is any of: key is in the format [host]\prefix\KEY\KEY\VALUE, where host is optional
root HKCR HKEY_CLASSES_ROOT remote host in either \\hostname or hostname: format and prefix is any of:
config HKCC HKEY_CURRENT_CONFIG root HKCR HKEY_CLASSES_ROOT (local only)
user HKCU HKEY_CURRENT_USER config HKCC HKEY_CURRENT_CONFIG (local only)
machine HKLM HKEY_LOCAL_MACHINE user HKCU HKEY_CURRENT_USER (local only)
users HKU HKEY_USERS machine HKLM HKEY_LOCAL_MACHINE
users HKU HKEY_USERS
You can use forward slash ('/') as a separator instead of backslash, in
that case backslash is treated as escape character.
example: \user\software\Microsoft\Clock\iFormat example: \user\software\Microsoft\Clock\iFormat
</screen> </screen>