https://git.reactos.org/?p=reactos.git;a=commitdiff;h=354e15827d8587fa750e4…
commit 354e15827d8587fa750e4c94107f9bf18f4b0266
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sun Jan 16 20:48:04 2022 +0100
Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com>
CommitDate: Sun Jun 19 13:06:30 2022 +0200
[WINESYNC] reg: Parse 'reg query' command-line arguments in query.c.
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 8e7738be92888c3aae19ab799d232d3f5112254c by Hugh McMaster
<hugh.mcmaster(a)outlook.com>
---
base/applications/cmdutils/reg/query.c | 51 +++++++++++++++++++++++++++++++++-
base/applications/cmdutils/reg/reg.c | 16 ++++-------
base/applications/cmdutils/reg/reg.h | 3 +-
sdk/tools/winesync/reg.cfg | 2 +-
4 files changed, 58 insertions(+), 14 deletions(-)
diff --git a/base/applications/cmdutils/reg/query.c
b/base/applications/cmdutils/reg/query.c
index 6ab518c91d9..7ae99fad6d5 100644
--- a/base/applications/cmdutils/reg/query.c
+++ b/base/applications/cmdutils/reg/query.c
@@ -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;
+}
diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c
index 8c94366beb8..6089d701d3c 100644
--- a/base/applications/cmdutils/reg/reg.c
+++ b/base/applications/cmdutils/reg/reg.c
@@ -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;
}
diff --git a/base/applications/cmdutils/reg/reg.h b/base/applications/cmdutils/reg/reg.h
index 89492ae8f74..e1e4804d19d 100644
--- a/base/applications/cmdutils/reg/reg.h
+++ b/base/applications/cmdutils/reg/reg.h
@@ -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__ */
diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg
index ebb2f3a63c9..df410292a44 100644
--- a/sdk/tools/winesync/reg.cfg
+++ b/sdk/tools/winesync/reg.cfg
@@ -4,4 +4,4 @@ directories:
files:
programs/reg/resource.h: base/applications/cmdutils/reg/resource.h
tags:
- wine: e319a463a20b060c059de36058624639e04c12a0
+ wine: 8e7738be92888c3aae19ab799d232d3f5112254c