MCPcopy Create free account
hub / github.com/F-Stack/f-stack / UTIL_requireUserConfirmation

Function UTIL_requireUserConfirmation

freebsd/contrib/zstd/programs/util.c:90–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88int g_utilDisplayLevel;
89
90int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg,
91 const char* acceptableLetters, int hasStdinInput) {
92 int ch, result;
93
94 if (hasStdinInput) {
95 UTIL_DISPLAY("stdin is an input - not proceeding.\n");
96 return 1;
97 }
98
99 UTIL_DISPLAY("%s", prompt);
100 ch = getchar();
101 result = 0;
102 if (strchr(acceptableLetters, ch) == NULL) {
103 UTIL_DISPLAY("%s", abortMsg);
104 result = 1;
105 }
106 /* flush the rest */
107 while ((ch!=EOF) && (ch!='\n'))
108 ch = getchar();
109 return result;
110}
111
112
113/*-*************************************

Callers 2

FIO_openDstFileFunction · 0.85

Calls 1

strchrFunction · 0.85

Tested by

no test coverage detected