cmd: Make WCMD_ask_confirm() static.
This commit is contained in:
parent
b82caec718
commit
e7b125702f
|
@ -66,6 +66,60 @@ static const WCHAR parmY[] = {'/','Y','\0'};
|
||||||
static const WCHAR parmNoY[] = {'/','-','Y','\0'};
|
static const WCHAR parmNoY[] = {'/','-','Y','\0'};
|
||||||
static const WCHAR nullW[] = {'\0'};
|
static const WCHAR nullW[] = {'\0'};
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* WCMD_ask_confirm
|
||||||
|
*
|
||||||
|
* Issue a message and ask 'Are you sure (Y/N)', waiting on a valid
|
||||||
|
* answer.
|
||||||
|
*
|
||||||
|
* Returns True if Y (or A) answer is selected
|
||||||
|
* If optionAll contains a pointer, ALL is allowed, and if answered
|
||||||
|
* set to TRUE
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static BOOL WCMD_ask_confirm (WCHAR *message, BOOL showSureText, BOOL *optionAll) {
|
||||||
|
|
||||||
|
WCHAR msgbuffer[MAXSTRING];
|
||||||
|
WCHAR Ybuffer[MAXSTRING];
|
||||||
|
WCHAR Nbuffer[MAXSTRING];
|
||||||
|
WCHAR Abuffer[MAXSTRING];
|
||||||
|
WCHAR answer[MAX_PATH] = {'\0'};
|
||||||
|
DWORD count = 0;
|
||||||
|
|
||||||
|
/* Load the translated 'Are you sure', plus valid answers */
|
||||||
|
LoadString (hinst, WCMD_CONFIRM, msgbuffer, sizeof(msgbuffer)/sizeof(WCHAR));
|
||||||
|
LoadString (hinst, WCMD_YES, Ybuffer, sizeof(Ybuffer)/sizeof(WCHAR));
|
||||||
|
LoadString (hinst, WCMD_NO, Nbuffer, sizeof(Nbuffer)/sizeof(WCHAR));
|
||||||
|
LoadString (hinst, WCMD_ALL, Abuffer, sizeof(Abuffer)/sizeof(WCHAR));
|
||||||
|
|
||||||
|
/* Loop waiting on a Y or N */
|
||||||
|
while (answer[0] != Ybuffer[0] && answer[0] != Nbuffer[0]) {
|
||||||
|
static const WCHAR startBkt[] = {' ','(','\0'};
|
||||||
|
static const WCHAR endBkt[] = {')','?','\0'};
|
||||||
|
|
||||||
|
WCMD_output_asis (message);
|
||||||
|
if (showSureText) {
|
||||||
|
WCMD_output_asis (msgbuffer);
|
||||||
|
}
|
||||||
|
WCMD_output_asis (startBkt);
|
||||||
|
WCMD_output_asis (Ybuffer);
|
||||||
|
WCMD_output_asis (fslashW);
|
||||||
|
WCMD_output_asis (Nbuffer);
|
||||||
|
if (optionAll) {
|
||||||
|
WCMD_output_asis (fslashW);
|
||||||
|
WCMD_output_asis (Abuffer);
|
||||||
|
}
|
||||||
|
WCMD_output_asis (endBkt);
|
||||||
|
WCMD_ReadFile (GetStdHandle(STD_INPUT_HANDLE), answer,
|
||||||
|
sizeof(answer)/sizeof(WCHAR), &count, NULL);
|
||||||
|
answer[0] = toupperW(answer[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the answer */
|
||||||
|
return ((answer[0] == Ybuffer[0]) ||
|
||||||
|
(optionAll && (answer[0] == Abuffer[0])));
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* WCMD_clear_screen
|
* WCMD_clear_screen
|
||||||
*
|
*
|
||||||
|
@ -2482,59 +2536,6 @@ void WCMD_exit (CMD_LIST **cmdList) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* WCMD_ask_confirm
|
|
||||||
*
|
|
||||||
* Issue a message and ask 'Are you sure (Y/N)', waiting on a valid
|
|
||||||
* answer.
|
|
||||||
*
|
|
||||||
* Returns True if Y (or A) answer is selected
|
|
||||||
* If optionAll contains a pointer, ALL is allowed, and if answered
|
|
||||||
* set to TRUE
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
BOOL WCMD_ask_confirm (WCHAR *message, BOOL showSureText, BOOL *optionAll) {
|
|
||||||
|
|
||||||
WCHAR msgbuffer[MAXSTRING];
|
|
||||||
WCHAR Ybuffer[MAXSTRING];
|
|
||||||
WCHAR Nbuffer[MAXSTRING];
|
|
||||||
WCHAR Abuffer[MAXSTRING];
|
|
||||||
WCHAR answer[MAX_PATH] = {'\0'};
|
|
||||||
DWORD count = 0;
|
|
||||||
|
|
||||||
/* Load the translated 'Are you sure', plus valid answers */
|
|
||||||
LoadString (hinst, WCMD_CONFIRM, msgbuffer, sizeof(msgbuffer)/sizeof(WCHAR));
|
|
||||||
LoadString (hinst, WCMD_YES, Ybuffer, sizeof(Ybuffer)/sizeof(WCHAR));
|
|
||||||
LoadString (hinst, WCMD_NO, Nbuffer, sizeof(Nbuffer)/sizeof(WCHAR));
|
|
||||||
LoadString (hinst, WCMD_ALL, Abuffer, sizeof(Abuffer)/sizeof(WCHAR));
|
|
||||||
|
|
||||||
/* Loop waiting on a Y or N */
|
|
||||||
while (answer[0] != Ybuffer[0] && answer[0] != Nbuffer[0]) {
|
|
||||||
static const WCHAR startBkt[] = {' ','(','\0'};
|
|
||||||
static const WCHAR endBkt[] = {')','?','\0'};
|
|
||||||
|
|
||||||
WCMD_output_asis (message);
|
|
||||||
if (showSureText) {
|
|
||||||
WCMD_output_asis (msgbuffer);
|
|
||||||
}
|
|
||||||
WCMD_output_asis (startBkt);
|
|
||||||
WCMD_output_asis (Ybuffer);
|
|
||||||
WCMD_output_asis (fslashW);
|
|
||||||
WCMD_output_asis (Nbuffer);
|
|
||||||
if (optionAll) {
|
|
||||||
WCMD_output_asis (fslashW);
|
|
||||||
WCMD_output_asis (Abuffer);
|
|
||||||
}
|
|
||||||
WCMD_output_asis (endBkt);
|
|
||||||
WCMD_ReadFile (GetStdHandle(STD_INPUT_HANDLE), answer,
|
|
||||||
sizeof(answer)/sizeof(WCHAR), &count, NULL);
|
|
||||||
answer[0] = toupperW(answer[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the answer */
|
|
||||||
return ((answer[0] == Ybuffer[0]) ||
|
|
||||||
(optionAll && (answer[0] == Abuffer[0])));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* WCMD_assoc
|
* WCMD_assoc
|
||||||
|
|
|
@ -101,7 +101,6 @@ WCHAR *WCMD_strtrim_leading_spaces (WCHAR *string);
|
||||||
void WCMD_strtrim_trailing_spaces (WCHAR *string);
|
void WCMD_strtrim_trailing_spaces (WCHAR *string);
|
||||||
void WCMD_opt_s_strip_quotes(WCHAR *cmd);
|
void WCMD_opt_s_strip_quotes(WCHAR *cmd);
|
||||||
void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable, WCHAR *forValue, BOOL justFors);
|
void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable, WCHAR *forValue, BOOL justFors);
|
||||||
BOOL WCMD_ask_confirm (WCHAR *message, BOOL showSureText, BOOL *optionAll);
|
|
||||||
|
|
||||||
void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext);
|
void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext);
|
||||||
WCHAR *WCMD_LoadMessage(UINT id);
|
WCHAR *WCMD_LoadMessage(UINT id);
|
||||||
|
|
Loading…
Reference in New Issue