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]) {
32 if (ansbuf[0] == '?' || cp == ansbuf) {
33 printf("Options are:\n");
34 for (ap = ansp; ap->sw; ap++)
35 printf(" %s\n", ap->sw);
38 if ((i = smatch(ansbuf, ansp)) < 0) {
39 printf("%s: %s.\n", ansbuf, i == -1 ? "unknown" : "ambiguous");