2 ** gans.c -- get an answer from the user
4 ** This code is Copyright (c) 2002, by the authors of nmh. See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
13 gans(char *prompt, struct swit *ansp)
17 register struct swit *ap;
24 while ((i = getchar()) != '\n') {
27 if (cp < &ansbuf[sizeof ansbuf - 1]) {
29 i = (isalpha(i) && isupper(i)) ? tolower(i) : i;
31 if (i >= 'A' && i <= 'Z')
38 if (ansbuf[0] == '?' || cp == ansbuf) {
39 printf("Options are:\n");
40 for (ap = ansp; ap->sw; ap++)
41 printf(" %s\n", ap->sw);
44 if ((i = smatch(ansbuf, ansp)) < 0) {
45 printf("%s: %s.\n", ansbuf, i == -1 ? "unknown" : "ambiguous");