reg: Parse the registry key using a helper function.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2016-06-15 02:30:53 +00:00 committed by Alexandre Julliard
parent 16a64e993d
commit 4a22ba5b46
1 changed files with 21 additions and 13 deletions

View File

@ -818,6 +818,24 @@ static int reg_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
return ret;
}
static BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path)
{
if (!sane_path(key))
return FALSE;
*root = path_get_rootkey(key);
if (!*root)
{
output_message(STRING_INVALID_KEY);
return FALSE;
}
*path = strchrW(key, '\\');
if (*path) (*path)++;
return TRUE;
}
static BOOL is_help_switch(const WCHAR *s)
{
if (strlenW(s) > 2)
@ -906,21 +924,11 @@ int wmain(int argc, WCHAR *argvW[])
return 0;
}
if (!parse_registry_key(argvW[2], &root, &path))
return 1;
key_name = argvW[2];
if (!sane_path(key_name))
return 1;
root = path_get_rootkey(key_name);
if (!root)
{
output_message(STRING_INVALID_KEY);
return 1;
}
path = strchrW(key_name, '\\');
if (path) path++;
for (i = 3; i < argc; i++)
{
if (argvW[i][0] == '/' || argvW[i][0] == '-')