https://git.reactos.org/?p=reactos.git;a=commitdiff;h=72087c1e3aac64ee94618…
commit 72087c1e3aac64ee94618ad845b5e751759d8b9b
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Mar 27 20:09:34 2022 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun Mar 27 20:09:34 2022 +0200
[DISKPART] Move helper functions to a separate file
---
base/system/diskpart/CMakeLists.txt | 1 +
base/system/diskpart/diskpart.h | 19 +++++++++++---
base/system/diskpart/list.c | 9 -------
base/system/diskpart/misc.c | 50 +++++++++++++++++++++++++++++++++++++
base/system/diskpart/uniqueid.c | 34 ++-----------------------
5 files changed, 68 insertions(+), 45 deletions(-)
diff --git a/base/system/diskpart/CMakeLists.txt b/base/system/diskpart/CMakeLists.txt
index f9b5bdd5a3f..0c0c9977947 100644
--- a/base/system/diskpart/CMakeLists.txt
+++ b/base/system/diskpart/CMakeLists.txt
@@ -29,6 +29,7 @@ list(APPEND SOURCE
interpreter.c
list.c
merge.c
+ misc.c
offline.c
online.c
partlist.c
diff --git a/base/system/diskpart/diskpart.h b/base/system/diskpart/diskpart.h
index b961e1e7f37..39aae2f8a94 100644
--- a/base/system/diskpart/diskpart.h
+++ b/base/system/diskpart/diskpart.h
@@ -282,13 +282,24 @@ VOID InterpretMain(VOID);
/* list.c */
BOOL list_main(INT argc, LPWSTR *argv);
+/* merge.c */
+BOOL merge_main(INT argc, LPWSTR *argv);
+
+/* misc.c */
+BOOL
+IsHexString(
+ _In_ PWSTR pszHexString);
+
+BOOL
+HasPrefix(
+ _In_ PWSTR pszString,
+ _In_ PWSTR pszPrefix);
+
ULONGLONG
RoundingDivide(
- _In_ ULONGLONG Dividend,
- _In_ ULONGLONG Divisor);
+ _In_ ULONGLONG Dividend,
+ _In_ ULONGLONG Divisor);
-/* merge.c */
-BOOL merge_main(INT argc, LPWSTR *argv);
/* offline.c */
BOOL offline_main(INT argc, LPWSTR *argv);
diff --git a/base/system/diskpart/list.c b/base/system/diskpart/list.c
index 714f5e3c257..a6a2ebfde89 100644
--- a/base/system/diskpart/list.c
+++ b/base/system/diskpart/list.c
@@ -13,15 +13,6 @@
/* FUNCTIONS ******************************************************************/
-ULONGLONG
-RoundingDivide(
- IN ULONGLONG Dividend,
- IN ULONGLONG Divisor)
-{
- return (Dividend + Divisor / 2) / Divisor;
-}
-
-
static
VOID
ListDisk(VOID)
diff --git a/base/system/diskpart/misc.c b/base/system/diskpart/misc.c
new file mode 100644
index 00000000000..2487530d405
--- /dev/null
+++ b/base/system/diskpart/misc.c
@@ -0,0 +1,50 @@
+/*
+ * PROJECT: ReactOS DiskPart
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: base/system/diskpart/misc.c
+ * PURPOSE: Manages all the partitions of the OS in an interactive way.
+ * PROGRAMMERS: Eric Kohl
+ */
+
+#include "diskpart.h"
+
+/* FUNCTIONS ******************************************************************/
+
+BOOL
+IsHexString(
+ _In_ PWSTR pszHexString)
+{
+ PWSTR ptr;
+
+ if ((pszHexString == NULL) || (*pszHexString == UNICODE_NULL))
+ return FALSE;
+
+ ptr = pszHexString;
+ while (*ptr != UNICODE_NULL)
+ {
+ if (!iswxdigit(*ptr))
+ return FALSE;
+
+ ptr++;
+ }
+
+ return TRUE;
+}
+
+
+BOOL
+HasPrefix(
+ _In_ PWSTR pszString,
+ _In_ PWSTR pszPrefix)
+{
+ return (_wcsnicmp(pszString, pszPrefix, wcslen(pszPrefix)) == 0);
+}
+
+
+ULONGLONG
+RoundingDivide(
+ _In_ ULONGLONG Dividend,
+ _In_ ULONGLONG Divisor)
+{
+ return (Dividend + Divisor / 2) / Divisor;
+}
diff --git a/base/system/diskpart/uniqueid.c b/base/system/diskpart/uniqueid.c
index af2c5e4fc64..df7d3bf6696 100644
--- a/base/system/diskpart/uniqueid.c
+++ b/base/system/diskpart/uniqueid.c
@@ -13,36 +13,6 @@
/* FUNCTIONS ******************************************************************/
-static
-BOOL
-isHexString(
- _In_ PWSTR pszHexString)
-{
- PWSTR ptr;
-
- ptr = pszHexString;
- while (*ptr != UNICODE_NULL)
- {
- if (!iswxdigit(*ptr))
- return FALSE;
-
- ptr++;
- }
-
- return TRUE;
-}
-
-
-static
-BOOL
-hasPrefix(
- _In_ PWSTR pszString,
- _In_ PWSTR pszPrefix)
-{
- return (_wcsnicmp(pszString, pszPrefix, wcslen(pszPrefix)) == 0);
-}
-
-
static
VOID
UniqueIdDisk(
@@ -80,14 +50,14 @@ UniqueIdDisk(
return;
}
- if (!hasPrefix(argv[2], L"ID="))
+ if (!HasPrefix(argv[2], L"ID="))
{
ConResPuts(StdOut, IDS_ERROR_INVALID_ARGS);
return;
}
startptr = &argv[2][3];
- if (isHexString(startptr) == FALSE)
+ if (!IsHexString(startptr))
{
ConResPuts(StdOut, IDS_ERROR_INVALID_ARGS);
return;