https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6fc87692b3e02ec702479…
commit 6fc87692b3e02ec70247939dc093bab99e668bce
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sun Jan 16 20:22:40 2022 +0100
Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com>
CommitDate: Sun Jun 19 13:06:29 2022 +0200
[WINESYNC] reg: Split 'delete' functions from reg.c.
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 81a3eecc3c2e7ddced2f25cabc6de47101fd4fb1 by Hugh McMaster
<hugh.mcmaster(a)outlook.com>
---
base/applications/cmdutils/reg/delete.c | 109 ++++++++++++++++++++++++++++++++
base/applications/cmdutils/reg/reg.c | 88 --------------------------
base/applications/cmdutils/reg/reg.h | 4 ++
sdk/tools/winesync/reg.cfg | 2 +-
4 files changed, 114 insertions(+), 89 deletions(-)
diff --git a/base/applications/cmdutils/reg/delete.c
b/base/applications/cmdutils/reg/delete.c
new file mode 100644
index 00000000000..530d4513ece
--- /dev/null
+++ b/base/applications/cmdutils/reg/delete.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2016-2017, 2021 Hugh McMaster
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <windows.h>
+#include <wine/heap.h>
+#include "reg.h"
+
+int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
+ BOOL value_empty, BOOL value_all, BOOL force)
+{
+ HKEY key;
+
+ if (!force)
+ {
+ BOOL ret;
+
+ if (value_name || value_empty)
+ ret = ask_confirm(STRING_DELETE_VALUE, value_name);
+ else if (value_all)
+ ret = ask_confirm(STRING_DELETE_VALUEALL, key_name);
+ else
+ ret = ask_confirm(STRING_DELETE_SUBKEY, key_name);
+
+ if (!ret)
+ {
+ output_message(STRING_CANCELLED);
+ return 0;
+ }
+ }
+
+ /* Delete subtree only if no /v* option is given */
+ if (!value_name && !value_empty && !value_all)
+ {
+ if (RegDeleteTreeW(root, path) != ERROR_SUCCESS)
+ {
+ output_message(STRING_CANNOT_FIND);
+ return 1;
+ }
+ output_message(STRING_SUCCESS);
+ return 0;
+ }
+
+ if (RegOpenKeyW(root, path, &key) != ERROR_SUCCESS)
+ {
+ output_message(STRING_CANNOT_FIND);
+ return 1;
+ }
+
+ if (value_all)
+ {
+ DWORD max_value_len = 256, value_len;
+ WCHAR *value_name;
+ LONG rc;
+
+ value_name = heap_xalloc(max_value_len * sizeof(WCHAR));
+
+ while (1)
+ {
+ value_len = max_value_len;
+ rc = RegEnumValueW(key, 0, value_name, &value_len, NULL, NULL, NULL,
NULL);
+ if (rc == ERROR_SUCCESS)
+ {
+ rc = RegDeleteValueW(key, value_name);
+ if (rc != ERROR_SUCCESS)
+ {
+ heap_free(value_name);
+ RegCloseKey(key);
+ output_message(STRING_VALUEALL_FAILED, key_name);
+ return 1;
+ }
+ }
+ else if (rc == ERROR_MORE_DATA)
+ {
+ max_value_len *= 2;
+ value_name = heap_xrealloc(value_name, max_value_len * sizeof(WCHAR));
+ }
+ else break;
+ }
+ heap_free(value_name);
+ }
+ else if (value_name || value_empty)
+ {
+ if (RegDeleteValueW(key, value_empty ? NULL : value_name) != ERROR_SUCCESS)
+ {
+ RegCloseKey(key);
+ output_message(STRING_CANNOT_FIND);
+ return 1;
+ }
+ }
+
+ RegCloseKey(key);
+ output_message(STRING_SUCCESS);
+ return 0;
+}
diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c
index 81535b5c7de..81b2f1b295e 100644
--- a/base/applications/cmdutils/reg/reg.c
+++ b/base/applications/cmdutils/reg/reg.c
@@ -422,94 +422,6 @@ static int reg_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL
value_empty,
return 0;
}
-static int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
- BOOL value_empty, BOOL value_all, BOOL force)
-{
- HKEY key;
-
- if (!force)
- {
- BOOL ret;
-
- if (value_name || value_empty)
- ret = ask_confirm(STRING_DELETE_VALUE, value_name);
- else if (value_all)
- ret = ask_confirm(STRING_DELETE_VALUEALL, key_name);
- else
- ret = ask_confirm(STRING_DELETE_SUBKEY, key_name);
-
- if (!ret)
- {
- output_message(STRING_CANCELLED);
- return 0;
- }
- }
-
- /* Delete subtree only if no /v* option is given */
- if (!value_name && !value_empty && !value_all)
- {
- if (RegDeleteTreeW(root, path) != ERROR_SUCCESS)
- {
- output_message(STRING_CANNOT_FIND);
- return 1;
- }
- output_message(STRING_SUCCESS);
- return 0;
- }
-
- if (RegOpenKeyW(root, path, &key) != ERROR_SUCCESS)
- {
- output_message(STRING_CANNOT_FIND);
- return 1;
- }
-
- if (value_all)
- {
- DWORD max_value_len = 256, value_len;
- WCHAR *value_name;
- LONG rc;
-
- value_name = heap_xalloc(max_value_len * sizeof(WCHAR));
-
- while (1)
- {
- value_len = max_value_len;
- rc = RegEnumValueW(key, 0, value_name, &value_len, NULL, NULL, NULL,
NULL);
- if (rc == ERROR_SUCCESS)
- {
- rc = RegDeleteValueW(key, value_name);
- if (rc != ERROR_SUCCESS)
- {
- heap_free(value_name);
- RegCloseKey(key);
- output_message(STRING_VALUEALL_FAILED, key_name);
- return 1;
- }
- }
- else if (rc == ERROR_MORE_DATA)
- {
- max_value_len *= 2;
- value_name = heap_xrealloc(value_name, max_value_len * sizeof(WCHAR));
- }
- else break;
- }
- heap_free(value_name);
- }
- else if (value_name || value_empty)
- {
- if (RegDeleteValueW(key, value_empty ? NULL : value_name) != ERROR_SUCCESS)
- {
- RegCloseKey(key);
- output_message(STRING_CANNOT_FIND);
- return 1;
- }
- }
-
- RegCloseKey(key);
- output_message(STRING_SUCCESS);
- return 0;
-}
-
WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD
subkey_len)
{
WCHAR *subkey_path;
diff --git a/base/applications/cmdutils/reg/reg.h b/base/applications/cmdutils/reg/reg.h
index 471ed9c4d55..c8baaa0f9a9 100644
--- a/base/applications/cmdutils/reg/reg.h
+++ b/base/applications/cmdutils/reg/reg.h
@@ -41,6 +41,10 @@ HKEY path_get_rootkey(const WCHAR *path);
WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD
subkey_len);
BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key);
+/* delete.c */
+int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name,
+ BOOL value_empty, BOOL value_all, BOOL force);
+
/* export.c */
int reg_export(int argc, WCHAR *argv[]);
diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg
index 8dc6fd16966..bf7d17e38a6 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: b80de8721690947bcd2e86b658b261f201002039
+ wine: 81a3eecc3c2e7ddced2f25cabc6de47101fd4fb1