[DISKPART] Move helper functions to a separate file

This commit is contained in:
Eric Kohl 2022-03-27 20:09:34 +02:00
parent d873865971
commit 72087c1e3a
5 changed files with 69 additions and 46 deletions

View file

@ -29,6 +29,7 @@ list(APPEND SOURCE
interpreter.c
list.c
merge.c
misc.c
offline.c
online.c
partlist.c

View file

@ -282,14 +282,25 @@ VOID InterpretMain(VOID);
/* list.c */
BOOL list_main(INT argc, LPWSTR *argv);
ULONGLONG
RoundingDivide(
_In_ ULONGLONG Dividend,
_In_ ULONGLONG Divisor);
/* 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);
/* offline.c */
BOOL offline_main(INT argc, LPWSTR *argv);

View file

@ -13,15 +13,6 @@
/* FUNCTIONS ******************************************************************/
ULONGLONG
RoundingDivide(
IN ULONGLONG Dividend,
IN ULONGLONG Divisor)
{
return (Dividend + Divisor / 2) / Divisor;
}
static
VOID
ListDisk(VOID)

View file

@ -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;
}

View file

@ -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;