regtool: allow /proc/registry{,32,64}/ registry path prefix

The user can supply the registry path prefix /proc/registry{,32,64}/ to
use path completion.
This commit is contained in:
Brian Inglis 2019-11-11 10:29:00 -07:00 committed by Corinna Vinschen
parent d14714c690
commit d3110717f0
2 changed files with 19 additions and 5 deletions

View File

@ -1976,8 +1976,11 @@ remote host in either \\hostname or hostname: format and prefix is any of:
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: regtool get '\user\software\Microsoft\Clock\iFormat'
that case backslash is treated as an escape character.
You can also supply the registry path prefix /proc/registry{,32,64}/ to
use path completion.
Example:
regtool list '/HKLM/SOFTWARE/Classes/MIME/Database/Content Type/audio\\/wav'
</screen>
</refsect1>

View File

@ -166,11 +166,13 @@ usage (FILE *where = stderr)
" machine HKLM HKEY_LOCAL_MACHINE\n"
" users HKU HKEY_USERS\n"
"\n"
"If the keyname starts with a forward slash ('/'), the forward slash is used\n"
"as separator and the backslash can be used as escape character.\n");
"You can use forward slash ('/') as a separator instead of backslash, in\n"
"that case backslash is treated as an escape character.\n"
"You can also supply the registry path prefix /proc/registry{,32,64}/ to\n"
"use path completion.\n");
fprintf (where, ""
"Example:\n"
"%s list '/machine/SOFTWARE/Classes/MIME/Database/Content Type/audio\\/wav'\n\n", prog_name);
"%s list '/HKLM/SOFTWARE/Classes/MIME/Database/Content Type/audio\\/wav'\n\n", prog_name);
}
if (where == stderr)
fprintf (where,
@ -350,6 +352,15 @@ find_key (int howmanyparts, REGSAM access, int option = 0)
*h = 0;
n = e;
}
else if (strncmp ("\\proc\\registry", n, strlen ("\\proc\\registry")) == 0)
{
/* skip /proc/registry{,32,64}/ prefix */
n += strlen ("\\proc\\registry");
if (strncmp ("64", n, strlen ("64")) == 0)
n += strlen ("64");
else if (strncmp ("32", n, strlen ("32")) == 0)
n += strlen ("32");
}
while (*n != '\\')
n++;
*n++ = 0;