mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[DISKPART] Move helper functions to a separate file
This commit is contained in:
parent
d873865971
commit
72087c1e3a
5 changed files with 69 additions and 46 deletions
|
@ -29,6 +29,7 @@ list(APPEND SOURCE
|
|||
interpreter.c
|
||||
list.c
|
||||
merge.c
|
||||
misc.c
|
||||
offline.c
|
||||
online.c
|
||||
partlist.c
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -13,15 +13,6 @@
|
|||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
ULONGLONG
|
||||
RoundingDivide(
|
||||
IN ULONGLONG Dividend,
|
||||
IN ULONGLONG Divisor)
|
||||
{
|
||||
return (Dividend + Divisor / 2) / Divisor;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
ListDisk(VOID)
|
||||
|
|
50
base/system/diskpart/misc.c
Normal file
50
base/system/diskpart/misc.c
Normal 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;
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue