reg: Parse 'reg query' command-line arguments in query.c.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
684d3bc3bf
commit
8e7738be92
|
@ -298,7 +298,7 @@ static int query_all(HKEY key, WCHAR *path, BOOL recurse)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int reg_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
|
||||
static int run_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
|
||||
BOOL value_empty, BOOL recurse)
|
||||
{
|
||||
HKEY key;
|
||||
|
@ -325,3 +325,52 @@ int reg_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int reg_query(int argc, WCHAR *argvW[])
|
||||
{
|
||||
HKEY root;
|
||||
WCHAR *path, *key_name, *value_name = NULL;
|
||||
BOOL value_empty = FALSE, recurse = FALSE;
|
||||
int i;
|
||||
|
||||
if (!parse_registry_key(argvW[2], &root, &path, &key_name))
|
||||
return 1;
|
||||
|
||||
for (i = 3; i < argc; i++)
|
||||
{
|
||||
if (argvW[i][0] == '/' || argvW[i][0] == '-')
|
||||
{
|
||||
WCHAR *str = &argvW[i][1];
|
||||
|
||||
if (!lstrcmpiW(str, L"ve"))
|
||||
{
|
||||
value_empty = TRUE;
|
||||
continue;
|
||||
}
|
||||
else if (!str[0] || str[1])
|
||||
goto invalid;
|
||||
|
||||
switch (towlower(*str))
|
||||
{
|
||||
case 'v':
|
||||
if (value_name || !(value_name = argvW[++i]))
|
||||
goto invalid;
|
||||
break;
|
||||
case 's':
|
||||
recurse = TRUE;
|
||||
break;
|
||||
default:
|
||||
goto invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (value_name && value_empty)
|
||||
goto invalid;
|
||||
|
||||
return run_query(root, path, key_name, value_name, value_empty, recurse);
|
||||
|
||||
invalid:
|
||||
output_message(STRING_INVALID_CMDLINE);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -337,7 +337,7 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
|
|||
static const WCHAR switchVAW[] = {'v','a',0};
|
||||
static const WCHAR switchVEW[] = {'v','e',0};
|
||||
WCHAR *key_name, *path, *value_name = NULL, *type = NULL, *data = NULL, separator = '\0';
|
||||
BOOL value_empty = FALSE, value_all = FALSE, recurse = FALSE, force = FALSE;
|
||||
BOOL value_empty = FALSE, value_all = FALSE, force = FALSE;
|
||||
HKEY root;
|
||||
|
||||
if (argc == 1)
|
||||
|
@ -380,6 +380,9 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
|
|||
if (op == REG_IMPORT)
|
||||
return reg_import(argc, argvW);
|
||||
|
||||
if (op == REG_QUERY)
|
||||
return reg_query(argc, argvW);
|
||||
|
||||
if (!parse_registry_key(argvW[2], &root, &path, &key_name))
|
||||
return 1;
|
||||
|
||||
|
@ -429,12 +432,6 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
|
|||
}
|
||||
break;
|
||||
case 's':
|
||||
if (op == REG_QUERY)
|
||||
{
|
||||
recurse = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
ptr = argvW[++i];
|
||||
if (!ptr || lstrlenW(ptr) != 1)
|
||||
{
|
||||
|
@ -461,9 +458,8 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
|
|||
|
||||
if (op == REG_ADD)
|
||||
ret = reg_add(root, path, value_name, value_empty, type, separator, data, force);
|
||||
else if (op == REG_DELETE)
|
||||
ret = reg_delete(root, path, key_name, value_name, value_empty, value_all, force);
|
||||
else
|
||||
ret = reg_query(root, path, key_name, value_name, value_empty, recurse);
|
||||
ret = reg_delete(root, path, key_name, value_name, value_empty, value_all, force);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ int reg_export(int argc, WCHAR *argvW[]);
|
|||
int reg_import(int argc, WCHAR *argvW[]);
|
||||
|
||||
/* query.c */
|
||||
int reg_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
|
||||
BOOL value_empty, BOOL recurse);
|
||||
int reg_query(int argc, WCHAR *argvW[]);
|
||||
|
||||
#endif /* __REG_H__ */
|
||||
|
|
Loading…
Reference in New Issue