mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 03:55:41 +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
|
interpreter.c
|
||||||
list.c
|
list.c
|
||||||
merge.c
|
merge.c
|
||||||
|
misc.c
|
||||||
offline.c
|
offline.c
|
||||||
online.c
|
online.c
|
||||||
partlist.c
|
partlist.c
|
||||||
|
|
|
@ -282,14 +282,25 @@ VOID InterpretMain(VOID);
|
||||||
/* list.c */
|
/* list.c */
|
||||||
BOOL list_main(INT argc, LPWSTR *argv);
|
BOOL list_main(INT argc, LPWSTR *argv);
|
||||||
|
|
||||||
ULONGLONG
|
|
||||||
RoundingDivide(
|
|
||||||
_In_ ULONGLONG Dividend,
|
|
||||||
_In_ ULONGLONG Divisor);
|
|
||||||
|
|
||||||
/* merge.c */
|
/* merge.c */
|
||||||
BOOL merge_main(INT argc, LPWSTR *argv);
|
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 */
|
/* offline.c */
|
||||||
BOOL offline_main(INT argc, LPWSTR *argv);
|
BOOL offline_main(INT argc, LPWSTR *argv);
|
||||||
|
|
||||||
|
|
|
@ -13,15 +13,6 @@
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
ULONGLONG
|
|
||||||
RoundingDivide(
|
|
||||||
IN ULONGLONG Dividend,
|
|
||||||
IN ULONGLONG Divisor)
|
|
||||||
{
|
|
||||||
return (Dividend + Divisor / 2) / Divisor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
ListDisk(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 ******************************************************************/
|
/* 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
|
static
|
||||||
VOID
|
VOID
|
||||||
UniqueIdDisk(
|
UniqueIdDisk(
|
||||||
|
@ -80,14 +50,14 @@ UniqueIdDisk(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasPrefix(argv[2], L"ID="))
|
if (!HasPrefix(argv[2], L"ID="))
|
||||||
{
|
{
|
||||||
ConResPuts(StdOut, IDS_ERROR_INVALID_ARGS);
|
ConResPuts(StdOut, IDS_ERROR_INVALID_ARGS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
startptr = &argv[2][3];
|
startptr = &argv[2][3];
|
||||||
if (isHexString(startptr) == FALSE)
|
if (!IsHexString(startptr))
|
||||||
{
|
{
|
||||||
ConResPuts(StdOut, IDS_ERROR_INVALID_ARGS);
|
ConResPuts(StdOut, IDS_ERROR_INVALID_ARGS);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue