int userprompt(unsigned id,...) { char *fmt, *str; int ch; if(!getPromptString(id, &str, &fmt)) return 0; /* Issue message */ if(*fmt) { va_list ap; va_start(ap, id); vprintf(fmt, ap); va_end(ap); } while((ch = vcgetchar()) == 0 || (ch = mapMetakey(str, ch)) == 0) beep(); /* hit erroreous character */ outc('\n'); /* advance to next line */ freePromptString(str, fmt); return ch; }
int vcgetcstr(const char *const legalCh) { int ch; assert(legalCh); fflush(stdout); /* Make sure the pending output arrives the screen as we bypass the stdio interface */ while ((ch = vcgetchar()) == 0 || !strchr(legalCh, ch)) beep(); /* hit erroreous character */ outc('\n'); /* advance to next line */ return ch; }
/* * get a visual character that must match one of the supplied * ones */ int vcgetcstr(const char *const legalCh) { int ch; assert(legalCh); fflush(stdout); /* Make sure the pending output arrives the screen as we bypass the stdio interface */ while ((ch = toupper(vcgetchar())) == 0 || !strchr(legalCh, ch)) { if (cbreak) { ch = CTL_C; /* This is ^C for ^Break */ break; } beep(); /* hit erroreous character */ } putchar('\n'); /* advance to next line */ return ch; }