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.
14 gans(char *prompt, struct swit *ansp)
25 while ((i = getchar()) != '\n') {
28 if (cp < &ansbuf[sizeof ansbuf - 1]) {
33 if (ansbuf[0] == '?' || cp == ansbuf) {
34 printf("Options are:\n");
35 for (ap = ansp; ap->sw; ap++)
36 printf(" %s\n", ap->sw);
39 if ((i = smatch(ansbuf, ansp)) < 0) {
40 printf("%s: %s.\n", ansbuf, i == -1 ? "unknown" : "ambiguous");