Author: ekohl Date: Sun Oct 23 12:04:48 2011 New Revision: 54241
URL: http://svn.reactos.org/svn/reactos?rev=54241&view=rev Log: [DISKPART] - Add a simple usage function (/? option). - Simplify the interpreter loop a little bit.
Modified: trunk/reactos/base/system/diskpart/diskpart.c trunk/reactos/base/system/diskpart/diskpart.h trunk/reactos/base/system/diskpart/interpreter.c trunk/reactos/base/system/diskpart/lang/en-US.rc trunk/reactos/base/system/diskpart/resource.h
Modified: trunk/reactos/base/system/diskpart/diskpart.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/diskpa... ============================================================================== --- trunk/reactos/base/system/diskpart/diskpart.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/diskpart.c [iso-8859-1] Sun Oct 23 12:04:48 2011 @@ -66,7 +66,6 @@ { 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 @@ timeout = _wtoi(argv[i]); } } + else if (wcscmp(&argv[i][1], L"?") == 0) + { + PrintResourceString(IDS_APP_USAGE); + return EXIT_SUCCESS; + } } }
@@ -132,8 +136,7 @@ } else { - while (interpreter_running) - interpreter_running = interpret_main(); + interpret_main(); }
/* Let the user know the program is exiting */
Modified: trunk/reactos/base/system/diskpart/diskpart.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/diskpa... ============================================================================== --- trunk/reactos/base/system/diskpart/diskpart.h [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/diskpart.h [iso-8859-1] Sun Oct 23 12:04:48 2011 @@ -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 @@
/* 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);
Modified: trunk/reactos/base/system/diskpart/interpreter.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/interp... ============================================================================== --- trunk/reactos/base/system/diskpart/interpreter.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/interpreter.c [iso-8859-1] Sun Oct 23 12:04:48 2011 @@ -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 @@ {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 @@ * 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)); + while (bRun == TRUE) + { + memset(args_vector, 0, sizeof(args_vector));
- /* shown just before the input where the user places commands */ - PrintResourceString(IDS_APP_PROMPT); + /* 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); + /* gets input from the user. */ + fgetws(input_line, MAX_STRING_SIZE, stdin);
- ptr = input_line; - while (*ptr != 0) - { - if (iswspace(*ptr) || *ptr == L'\n') + 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); }
Modified: trunk/reactos/base/system/diskpart/lang/en-US.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/lang/e... ============================================================================== --- trunk/reactos/base/system/diskpart/lang/en-US.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/lang/en-US.rc [iso-8859-1] Sun Oct 23 12:04:48 2011 @@ -14,6 +14,11 @@ 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"
Modified: trunk/reactos/base/system/diskpart/resource.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/resour... ============================================================================== --- trunk/reactos/base/system/diskpart/resource.h [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/resource.h [iso-8859-1] Sun Oct 23 12:04:48 2011 @@ -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