2 * PROJECT: ReactOS DiskPart
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/system/diskpart/interpreter.c
5 * PURPOSE: Reads the user input and then envokes the selected
7 * PROGRAMMERS: Lee Schroeder
12 BOOL
exit_main(INT argc
, WCHAR
**argv
);
13 BOOL
rem_main(INT argc
, WCHAR
**argv
);
18 {L
"active", active_main
, help_active
},
19 {L
"add", add_main
, help_add
},
20 {L
"assign", assign_main
, help_assign
},
21 {L
"attributes", attributes_main
, help_attributes
},
22 {L
"automount", automount_main
, help_automount
},
23 {L
"break", break_main
, help_break
},
24 {L
"clean", clean_main
, help_clean
},
25 {L
"compact", compact_main
, help_compact
},
26 {L
"convert", convert_main
, help_convert
},
27 {L
"create", create_main
, help_create
},
28 {L
"delete", delete_main
, help_delete
},
29 {L
"detail", detail_main
, help_detail
},
30 {L
"detach", detach_main
, help_detach
},
31 {L
"exit", exit_main
, NULL
},
32 {L
"expand", expand_main
, help_expand
},
33 {L
"extend", extend_main
, help_extend
},
34 {L
"filesystems", filesystems_main
, help_filesystems
},
35 {L
"format", format_main
, help_format
},
36 {L
"gpt", gpt_main
, help_gpt
},
37 {L
"help", help_main
, help_help
},
38 {L
"list", list_main
, help_list
},
39 {L
"import", import_main
, help_import
},
40 {L
"inactive", inactive_main
, help_inactive
},
41 {L
"merge", merge_main
, help_merge
},
42 {L
"offline", offline_main
, help_offline
},
43 {L
"online", online_main
, help_online
},
44 {L
"recover", recover_main
, help_recover
},
45 {L
"rem", rem_main
, NULL
},
46 {L
"remove", remove_main
, help_remove
},
47 {L
"repair", repair_main
, help_repair
},
48 {L
"rescan", rescan_main
, help_rescan
},
49 {L
"retain", retain_main
, help_retain
},
50 {L
"san", san_main
, help_san
},
51 {L
"select", select_main
, help_select
},
52 {L
"setid", setid_main
, help_setid
},
53 {L
"shrink", shrink_main
, help_shrink
},
54 {L
"uniqueid", uniqueid_main
, help_uniqueid
},
59 /* FUNCTIONS *****************************************************************/
62 exit_main(INT argc
, WCHAR
**argv
)
69 rem_main(INT argc
, WCHAR
**argv
)
76 * InterpretCmd(char *cmd_line, char *arg_line):
77 * compares the command name to a list of available commands, and
78 * determines which function to envoke.
81 InterpretCmd(int argc
, WCHAR
**argv
)
85 /* Scan internal command table */
86 for (cmdptr
= cmds
; cmdptr
->name
; cmdptr
++)
88 if (wcsicmp(argv
[0], cmdptr
->name
) == 0)
90 return cmdptr
->func(argc
, argv
);
101 * InterpretScript(char *line):
102 * The main function used for when reading commands from scripts.
105 InterpretScript(WCHAR
*input_line
)
107 WCHAR
*args_vector
[MAX_ARGS_COUNT
];
109 BOOL bWhiteSpace
= TRUE
;
112 memset(args_vector
, 0, sizeof(args_vector
));
117 if (iswspace(*ptr
) || *ptr
== L
'\n')
124 if ((bWhiteSpace
== TRUE
) && (args_count
< MAX_ARGS_COUNT
))
126 args_vector
[args_count
] = ptr
;
136 /* sends the string to find the command */
137 return InterpretCmd(args_count
, args_vector
);
143 * Contents for the main program loop as it reads each line, and then
144 * it sends the string to interpret_line, where it determines what
150 WCHAR input_line
[MAX_STRING_SIZE
];
151 WCHAR
*args_vector
[MAX_ARGS_COUNT
];
153 BOOL bWhiteSpace
= TRUE
;
160 memset(args_vector
, 0, sizeof(args_vector
));
162 /* shown just before the input where the user places commands */
163 PrintResourceString(IDS_APP_PROMPT
);
165 /* gets input from the user. */
166 fgetws(input_line
, MAX_STRING_SIZE
, stdin
);
171 if (iswspace(*ptr
) || *ptr
== L
'\n')
178 if ((bWhiteSpace
== TRUE
) && (args_count
< MAX_ARGS_COUNT
))
180 args_vector
[args_count
] = ptr
;
190 /* sends the string to find the command */
191 bRun
= InterpretCmd(args_count
, args_vector
);