aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2002-06-07 11:12:16 +0000
committerCorinna Vinschen <corinna@vinschen.de>2002-06-07 11:12:16 +0000
commit381fb8baa1035d55d6d50a5cdfebc044c35589f6 (patch)
tree45eb73caa4fd4a1bd1f147d6f83d640c5d9654f1
parent9d0efbb3aeef0490d227c9b98bd478ac1964d16d (diff)
downloadnewlib-381fb8baa1035d55d6d50a5cdfebc044c35589f6.zip
newlib-381fb8baa1035d55d6d50a5cdfebc044c35589f6.tar.gz
newlib-381fb8baa1035d55d6d50a5cdfebc044c35589f6.tar.bz2
* regtool.cc (Fail): Be more verbose.
(find_key): Add support for remote registry access. (usage): Document it. * utils.sgml: Document it.
-rw-r--r--winsup/utils/ChangeLog7
-rw-r--r--winsup/utils/regtool.cc68
-rw-r--r--winsup/utils/utils.sgml15
3 files changed, 70 insertions, 20 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index dd09e50..6a67038 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -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>
* strace.cc (main): Make toggle a local variable.
diff --git a/winsup/utils/regtool.cc b/winsup/utils/regtool.cc
index b4a3b7d..ffaab6a 100644
--- a/winsup/utils/regtool.cc
+++ b/winsup/utils/regtool.cc
@@ -91,12 +91,16 @@ usage (FILE *where = stderr)
"\n");
if (where == stdout)
fprintf (where, ""
- "KEY is in the format \\prefix\\KEY\\KEY\\VALUE, where prefix is any of:\n"
- " \\root HKCR HKEY_CLASSES_ROOT\n"
- " \\config HKCC HKEY_CURRENT_CONFIG\n"
- " \\user HKCU HKEY_CURRENT_USER\n"
- " \\machine HKLM HKEY_LOCAL_MACHINE\n"
- " \\users HKU HKEY_USERS\n"
+ "KEY is in the format [host]\\prefix\\KEY\\KEY\\VALUE, where host is optional\n"
+ "remote host in either \\\\hostname or hostname: format and prefix is any of:\n"
+ " root HKCR HKEY_CLASSES_ROOT (local only)\n"
+ " config HKCC HKEY_CURRENT_CONFIG (local only)\n"
+ " user HKCU HKEY_CURRENT_USER (local only)\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, ""
"Example: %s get '\\user\\software\\Microsoft\\Clock\\iFormat'\n", prog_name);
@@ -136,7 +140,7 @@ Fail (DWORD rv)
FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM,
0, rv, 0, (CHAR *) & buf, 0, 0);
- fprintf (stderr, "Error: %s\n", buf);
+ fprintf (stderr, "Error (%ld): %s\n", rv, buf);
LocalFree (buf);
}
exit (1);
@@ -251,12 +255,38 @@ translate (char *key)
void
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;
if (*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++ = 0;
for (e = n; *e && *e != '\\'; e++);
c = *e;
*e = 0;
@@ -292,14 +322,24 @@ find_key (int howmanyparts, REGSAM access)
value = e + 1;
}
}
+ if (host)
+ {
+ rv = RegConnectRegistry (host, wkprefixes[i].key, &base);
+ if (rv != ERROR_SUCCESS)
+ Fail (rv);
+ free (host);
+ }
+ else
+ base = wkprefixes[i].key;
+
if (n[0] == 0)
+ key = base;
+ else
{
- key = wkprefixes[i].key;
- return;
+ 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);
}
diff --git a/winsup/utils/utils.sgml b/winsup/utils/utils.sgml
index 6677611..e0ad2f9 100644
--- a/winsup/utils/utils.sgml
+++ b/winsup/utils/utils.sgml
@@ -710,12 +710,15 @@ Regtool Copyright (c) 2000 Red Hat Inc
regtool [-v] unset [key\value] - removes value from key
regtool [-q] get [key\value] - prints value to stdout
-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:
- root HKCR HKEY_CLASSES_ROOT
- config HKCC HKEY_CURRENT_CONFIG
- user HKCU HKEY_CURRENT_USER
- machine HKLM HKEY_LOCAL_MACHINE
- users HKU HKEY_USERS
+ key is in the format [host]\prefix\KEY\KEY\VALUE, where host is optional
+ remote host in either \\hostname or hostname: format and prefix is any of:
+ root HKCR HKEY_CLASSES_ROOT (local only)
+ config HKCC HKEY_CURRENT_CONFIG (local only)
+ user HKCU HKEY_CURRENT_USER (local only)
+ 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
</screen>