https://git.reactos.org/?p=reactos.git;a=commitdiff;h=65957cc65b6154e6317ca…
commit 65957cc65b6154e6317ca180b05c14b48e738d7a
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:31 2022 +0200
[WINESYNC] reg: Parse 'reg add' command-line arguments in add.c.
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 9138f5893c2eb7cafabdd8ed49b99a633eeda462 by Hugh McMaster
<hugh.mcmaster(a)outlook.com>
---
base/applications/cmdutils/reg/add.c | 67 ++++++++++++++++++++++++++++-
base/applications/cmdutils/reg/reg.c | 82 +++---------------------------------
base/applications/cmdutils/reg/reg.h | 3 +-
sdk/tools/winesync/reg.cfg | 2 +-
4 files changed, 72 insertions(+), 82 deletions(-)
diff --git a/base/applications/cmdutils/reg/add.c b/base/applications/cmdutils/reg/add.c
index 3d0a509b4f0..672ec19ef98 100644
--- a/base/applications/cmdutils/reg/add.c
+++ b/base/applications/cmdutils/reg/add.c
@@ -149,8 +149,8 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR
separator, DW
return out_data;
}
-int reg_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
- WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
+static int run_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
+ WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
{
HKEY key;
@@ -208,3 +208,66 @@ int reg_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL
value_empty,
return 0;
}
+
+int reg_add(int argc, WCHAR *argvW[])
+{
+ HKEY root;
+ WCHAR *path, *key_name, *value_name = NULL, *type = NULL, *data = NULL, separator =
'\0';
+ BOOL value_empty = FALSE, force = 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 't':
+ if (type || !(type = argvW[++i]))
+ goto invalid;
+ break;
+ case 'd':
+ if (data || !(data = argvW[++i]))
+ goto invalid;
+ break;
+ case 's':
+ str = argvW[++i];
+ if (!str || lstrlenW(str) != 1)
+ goto invalid;
+ separator = str[0];
+ break;
+ case 'f':
+ force = TRUE;
+ break;
+ default:
+ goto invalid;
+ }
+ }
+ }
+
+ if (value_name && value_empty)
+ goto invalid;
+
+ return run_add(root, path, value_name, value_empty, type, separator, data, force);
+
+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 8dea9501730..fef8db6f6bf 100644
--- a/base/applications/cmdutils/reg/reg.c
+++ b/base/applications/cmdutils/reg/reg.c
@@ -333,11 +333,7 @@ static enum operations get_operation(const WCHAR *str, int *op_help)
int __cdecl wmain(int argc, WCHAR *argvW[])
{
- int i, op, op_help;
- static const WCHAR switchVEW[] = {'v','e',0};
- WCHAR *key_name, *path, *value_name = NULL, *type = NULL, *data = NULL, separator =
'\0';
- BOOL value_empty = FALSE, force = FALSE;
- HKEY root;
+ int op, op_help;
if (argc == 1)
{
@@ -373,6 +369,9 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
return 0;
}
+ if (op == REG_ADD)
+ return reg_add(argc, argvW);
+
if (op == REG_DELETE)
return reg_delete(argc, argvW);
@@ -382,76 +381,5 @@ 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;
-
- for (i = 3; i < argc; i++)
- {
- if (argvW[i][0] == '/' || argvW[i][0] == '-')
- {
- WCHAR *ptr = &argvW[i][1];
-
- if (!lstrcmpiW(ptr, switchVEW))
- {
- value_empty = TRUE;
- continue;
- }
- else if (!ptr[0] || ptr[1])
- {
- output_message(STRING_INVALID_CMDLINE);
- return 1;
- }
-
- switch(towlower(argvW[i][1]))
- {
- case 'v':
- if (value_name || !(value_name = argvW[++i]))
- {
- output_message(STRING_INVALID_CMDLINE);
- return 1;
- }
- break;
- case 't':
- if (type || !(type = argvW[++i]))
- {
- output_message(STRING_INVALID_CMDLINE);
- return 1;
- }
- break;
- case 'd':
- if (data || !(data = argvW[++i]))
- {
- output_message(STRING_INVALID_CMDLINE);
- return 1;
- }
- break;
- case 's':
- ptr = argvW[++i];
- if (!ptr || lstrlenW(ptr) != 1)
- {
- output_message(STRING_INVALID_CMDLINE);
- return 1;
- }
- separator = ptr[0];
- break;
- case 'f':
- force = TRUE;
- break;
- default:
- output_message(STRING_INVALID_CMDLINE);
- return 1;
- }
- }
- }
-
- if (value_name && value_empty)
- {
- output_message(STRING_INVALID_CMDLINE);
- return 1;
- }
-
- return reg_add(root, path, value_name, value_empty, type, separator, data, force);
+ return reg_query(argc, argvW);
}
diff --git a/base/applications/cmdutils/reg/reg.h b/base/applications/cmdutils/reg/reg.h
index e4ee13eca6e..3525bed75b8 100644
--- a/base/applications/cmdutils/reg/reg.h
+++ b/base/applications/cmdutils/reg/reg.h
@@ -43,8 +43,7 @@ BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path,
WCHAR **long
BOOL is_switch(const WCHAR *s, const WCHAR c);
/* add.c */
-int reg_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty,
- WCHAR *type, WCHAR separator, WCHAR *data, BOOL force);
+int reg_add(int arc, WCHAR *argvW[]);
/* delete.c */
int reg_delete(int argc, WCHAR *argvW[]);
diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg
index b9f81cb1160..df540a629f6 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: 434c345e41222ae6eebe734e655a32bfd51871ae
+ wine: 9138f5893c2eb7cafabdd8ed49b99a633eeda462