mirror of
https://github.com/reactos/reactos.git
synced 2025-02-20 15:35:04 +00:00
[DISKPART]
- Add a simple usage function (/? option). - Simplify the interpreter loop a little bit. svn path=/trunk/; revision=54241
This commit is contained in:
parent
51ca9e5645
commit
813bcdc401
5 changed files with 46 additions and 33 deletions
|
@ -66,7 +66,6 @@ int wmain(int argc, const WCHAR *argv[])
|
|||
{
|
||||
WCHAR szComputerName[MAX_STRING_SIZE];
|
||||
DWORD comp_size = MAX_STRING_SIZE;
|
||||
BOOL interpreter_running = TRUE;
|
||||
LPCWSTR file_name = NULL;
|
||||
int i;
|
||||
int timeout = 0;
|
||||
|
@ -121,6 +120,11 @@ int wmain(int argc, const WCHAR *argv[])
|
|||
timeout = _wtoi(argv[i]);
|
||||
}
|
||||
}
|
||||
else if (wcscmp(&argv[i][1], L"?") == 0)
|
||||
{
|
||||
PrintResourceString(IDS_APP_USAGE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,8 +136,7 @@ int wmain(int argc, const WCHAR *argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
while (interpreter_running)
|
||||
interpreter_running = interpret_main();
|
||||
interpret_main();
|
||||
}
|
||||
|
||||
/* Let the user know the program is exiting */
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: base/system/diskpart/diskpart.c
|
||||
* PURPOSE: Manages all the partitions of the OS in
|
||||
* an interactive way
|
||||
* an interactive way
|
||||
* PROGRAMMERS: Lee Schroeder
|
||||
*/
|
||||
#ifndef DISKPART_H
|
||||
|
@ -139,8 +139,8 @@ VOID help_inactive(INT argc, WCHAR **argv);
|
|||
|
||||
/* interpreter.c */
|
||||
BOOL interpret_script(WCHAR *line);
|
||||
BOOL interpret_main(VOID);
|
||||
BOOL interpret_cmd(INT argc, WCHAR **argv);
|
||||
VOID interpret_main(VOID);
|
||||
|
||||
/* list.c */
|
||||
BOOL list_main(INT argc, WCHAR **argv);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: base/system/diskpart/interpreter.c
|
||||
* PURPOSE: Reads the user input and then envokes the selected
|
||||
* command by the user.
|
||||
* command by the user.
|
||||
* PROGRAMMERS: Lee Schroeder
|
||||
*/
|
||||
|
||||
|
@ -52,7 +52,7 @@ COMMAND cmds[] =
|
|||
{L"setid", setid_main, help_setid},
|
||||
{L"shrink", shrink_main, help_shrink},
|
||||
{L"uniqueid", uniqueid_main, help_uniqueid},
|
||||
{NULL, NULL, NULL}
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
@ -144,45 +144,49 @@ interpret_script(WCHAR *input_line)
|
|||
* it sends the string to interpret_line, where it determines what
|
||||
* command to use.
|
||||
*/
|
||||
BOOL
|
||||
VOID
|
||||
interpret_main(VOID)
|
||||
{
|
||||
WCHAR input_line[MAX_STRING_SIZE];
|
||||
WCHAR *args_vector[MAX_ARGS_COUNT];
|
||||
INT args_count = 0;
|
||||
BOOL bWhiteSpace = TRUE;
|
||||
BOOL bRun = TRUE;
|
||||
WCHAR *ptr;
|
||||
|
||||
memset(args_vector, 0, sizeof(args_vector));
|
||||
|
||||
/* shown just before the input where the user places commands */
|
||||
PrintResourceString(IDS_APP_PROMPT);
|
||||
|
||||
/* gets input from the user. */
|
||||
fgetws(input_line, MAX_STRING_SIZE, stdin);
|
||||
|
||||
ptr = input_line;
|
||||
while (*ptr != 0)
|
||||
while (bRun == TRUE)
|
||||
{
|
||||
if (iswspace(*ptr) || *ptr == L'\n')
|
||||
memset(args_vector, 0, sizeof(args_vector));
|
||||
|
||||
/* shown just before the input where the user places commands */
|
||||
PrintResourceString(IDS_APP_PROMPT);
|
||||
|
||||
/* gets input from the user. */
|
||||
fgetws(input_line, MAX_STRING_SIZE, stdin);
|
||||
|
||||
ptr = input_line;
|
||||
while (*ptr != 0)
|
||||
{
|
||||
*ptr = 0;
|
||||
bWhiteSpace = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((bWhiteSpace == TRUE) && (args_count < MAX_ARGS_COUNT))
|
||||
if (iswspace(*ptr) || *ptr == L'\n')
|
||||
{
|
||||
args_vector[args_count] = ptr;
|
||||
args_count++;
|
||||
*ptr = 0;
|
||||
bWhiteSpace = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((bWhiteSpace == TRUE) && (args_count < MAX_ARGS_COUNT))
|
||||
{
|
||||
args_vector[args_count] = ptr;
|
||||
args_count++;
|
||||
}
|
||||
|
||||
bWhiteSpace = FALSE;
|
||||
}
|
||||
|
||||
bWhiteSpace = FALSE;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
ptr++;
|
||||
/* sends the string to find the command */
|
||||
bRun = interpret_cmd(args_count, args_vector);
|
||||
}
|
||||
|
||||
/* sends the string to find the command */
|
||||
return interpret_cmd(args_count, args_vector);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
|
|||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APP_HEADER, "\nReactOS DiskPart version %s\n"
|
||||
IDS_APP_USAGE, "Diskpart command line syntax:\ndiskpart [/s <script file>] [/t <timeout value>] [/?]\n\
|
||||
/s <script file> - Runs the given script file.\n\
|
||||
/t <timeout value> - Waits for the given time (in seconds) after running a\n\
|
||||
script file.\n\
|
||||
/? - Shows this help text."
|
||||
IDS_APP_LICENSE, "Licensed under the GNU GPLv2\n"
|
||||
IDS_APP_CURR_COMPUTER, "On computer: %s\n\n"
|
||||
IDS_APP_LEAVING, "\nLeaving DiskPart...\n"
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: base/system/diskpart/lang/resource.h
|
||||
* PURPOSE: Manages all the partitions of the OS in
|
||||
* an interactive way
|
||||
* an interactive way
|
||||
* PROGRAMMERS: Lee Schroeder
|
||||
*/
|
||||
#ifndef RESOURCE_H
|
||||
#define RESOURCE_H
|
||||
|
||||
#define IDS_APP_HEADER 0
|
||||
#define IDS_APP_USAGE 1
|
||||
#define IDS_APP_LICENSE 2
|
||||
#define IDS_APP_CURR_COMPUTER 3
|
||||
#define IDS_APP_LEAVING 4
|
||||
|
|
Loading…
Reference in a new issue