1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-30 22:23:13 +03:00

Unified warning prompts into new function UTIL_requireUserConfirmationToProceed()

This commit is contained in:
senhuang42
2020-08-25 11:25:49 -04:00
parent dde97de6c4
commit aab11ce3db
3 changed files with 28 additions and 23 deletions

View File

@ -87,6 +87,22 @@ UTIL_STATIC void* UTIL_realloc(void *ptr, size_t size)
******************************************/
int g_utilDisplayLevel;
int UTIL_requireUserConfirmationToProceed(const char* prompt, const char* abortMsg,
const char* acceptableLetters) {
int ch;
UTIL_DISPLAY("%s", prompt);
ch = getchar();
if (strchr(acceptableLetters, ch) == NULL) {
UTIL_DISPLAY("%s", abortMsg);
return 1;
}
/* flush the rest */
while ((ch!=EOF) && (ch!='\n'))
ch = getchar();
return 0;
}
/*-*************************************
* Constants