Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygeninterpreter.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS DiskPart 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: base/system/diskpart/interpreter.c 00005 * PURPOSE: Reads the user input and then envokes the selected 00006 * command by the user. 00007 * PROGRAMMERS: Lee Schroeder 00008 */ 00009 00010 #include "diskpart.h" 00011 00012 BOOL exit_main(INT argc, WCHAR **argv); 00013 BOOL rem_main(INT argc, WCHAR **argv); 00014 00015 00016 COMMAND cmds[] = 00017 { 00018 {L"active", active_main, help_active}, 00019 {L"add", add_main, help_add}, 00020 {L"assign", assign_main, help_assign}, 00021 {L"attributes", attributes_main, help_attributes}, 00022 {L"automount", automount_main, help_automount}, 00023 {L"break", break_main, help_break}, 00024 {L"clean", clean_main, help_clean}, 00025 {L"compact", compact_main, help_compact}, 00026 {L"convert", convert_main, help_convert}, 00027 {L"create", create_main, help_create}, 00028 {L"delete", delete_main, help_delete}, 00029 {L"detail", detail_main, help_detail}, 00030 {L"detach", detach_main, help_detach}, 00031 {L"exit", exit_main, NULL}, 00032 {L"expand", expand_main, help_expand}, 00033 {L"extend", extend_main, help_extend}, 00034 {L"filesystems", filesystems_main, help_filesystems}, 00035 {L"format", format_main, help_format}, 00036 {L"gpt", gpt_main, help_gpt}, 00037 {L"help", help_main, help_help}, 00038 {L"list", list_main, help_list}, 00039 {L"import", import_main, help_import}, 00040 {L"inactive", inactive_main, help_inactive}, 00041 {L"merge", merge_main, help_merge}, 00042 {L"offline", offline_main, help_offline}, 00043 {L"online", online_main, help_online}, 00044 {L"recover", recover_main, help_recover}, 00045 {L"rem", rem_main, NULL}, 00046 {L"remove", remove_main, help_remove}, 00047 {L"repair", repair_main, help_repair}, 00048 {L"rescan", rescan_main, help_rescan}, 00049 {L"retain", retain_main, help_retain}, 00050 {L"san", san_main, help_san}, 00051 {L"select", select_main, help_select}, 00052 {L"setid", setid_main, help_setid}, 00053 {L"shrink", shrink_main, help_shrink}, 00054 {L"uniqueid", uniqueid_main, help_uniqueid}, 00055 {NULL, NULL, NULL} 00056 }; 00057 00058 00059 /* FUNCTIONS *****************************************************************/ 00060 00061 BOOL 00062 exit_main(INT argc, WCHAR **argv) 00063 { 00064 return FALSE; 00065 } 00066 00067 00068 BOOL 00069 rem_main(INT argc, WCHAR **argv) 00070 { 00071 return TRUE; 00072 } 00073 00074 00075 /* 00076 * interpret_cmd(char *cmd_line, char *arg_line): 00077 * compares the command name to a list of available commands, and 00078 * determines which function to envoke. 00079 */ 00080 BOOL 00081 interpret_cmd(int argc, WCHAR **argv) 00082 { 00083 PCOMMAND cmdptr; 00084 00085 /* Scan internal command table */ 00086 for (cmdptr = cmds; cmdptr->name; cmdptr++) 00087 { 00088 if (wcsicmp(argv[0], cmdptr->name) == 0) 00089 { 00090 return cmdptr->func(argc, argv); 00091 } 00092 } 00093 00094 help_cmdlist(); 00095 00096 return TRUE; 00097 } 00098 00099 00100 /* 00101 * interpret_script(char *line): 00102 * The main function used for when reading commands from scripts. 00103 */ 00104 BOOL 00105 interpret_script(WCHAR *input_line) 00106 { 00107 WCHAR *args_vector[MAX_ARGS_COUNT]; 00108 INT args_count = 0; 00109 BOOL bWhiteSpace = TRUE; 00110 WCHAR *ptr; 00111 00112 memset(args_vector, 0, sizeof(args_vector)); 00113 00114 ptr = input_line; 00115 while (*ptr != 0) 00116 { 00117 if (iswspace(*ptr) || *ptr == L'\n') 00118 { 00119 *ptr = 0; 00120 bWhiteSpace = TRUE; 00121 } 00122 else 00123 { 00124 if ((bWhiteSpace == TRUE) && (args_count < MAX_ARGS_COUNT)) 00125 { 00126 args_vector[args_count] = ptr; 00127 args_count++; 00128 } 00129 00130 bWhiteSpace = FALSE; 00131 } 00132 00133 ptr++; 00134 } 00135 00136 /* sends the string to find the command */ 00137 return interpret_cmd(args_count, args_vector); 00138 } 00139 00140 00141 /* 00142 * interpret_main(): 00143 * Contents for the main program loop as it reads each line, and then 00144 * it sends the string to interpret_line, where it determines what 00145 * command to use. 00146 */ 00147 VOID 00148 interpret_main(VOID) 00149 { 00150 WCHAR input_line[MAX_STRING_SIZE]; 00151 WCHAR *args_vector[MAX_ARGS_COUNT]; 00152 INT args_count = 0; 00153 BOOL bWhiteSpace = TRUE; 00154 BOOL bRun = TRUE; 00155 WCHAR *ptr; 00156 00157 while (bRun == TRUE) 00158 { 00159 memset(args_vector, 0, sizeof(args_vector)); 00160 00161 /* shown just before the input where the user places commands */ 00162 PrintResourceString(IDS_APP_PROMPT); 00163 00164 /* gets input from the user. */ 00165 fgetws(input_line, MAX_STRING_SIZE, stdin); 00166 00167 ptr = input_line; 00168 while (*ptr != 0) 00169 { 00170 if (iswspace(*ptr) || *ptr == L'\n') 00171 { 00172 *ptr = 0; 00173 bWhiteSpace = TRUE; 00174 } 00175 else 00176 { 00177 if ((bWhiteSpace == TRUE) && (args_count < MAX_ARGS_COUNT)) 00178 { 00179 args_vector[args_count] = ptr; 00180 args_count++; 00181 } 00182 00183 bWhiteSpace = FALSE; 00184 } 00185 00186 ptr++; 00187 } 00188 00189 /* sends the string to find the command */ 00190 bRun = interpret_cmd(args_count, args_vector); 00191 } 00192 } Generated on Sun May 27 2012 04:18:47 for ReactOS by
1.7.6.1
|