]>
diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/sbr/gans.c
1 /* gans.c - get an answer from the user */
3 static char ident
[] = "@(#)$Id: gans.c,v 1.2 1992/10/26 22:50:52 jromine Exp $";
11 register char *prompt
;
12 register struct swit
*ansp
;
16 register struct swit
*ap
;
20 printf ("%s", prompt
);
21 (void) fflush (stdout
);
23 while ((i
= getchar ()) != '\n') {
26 if (cp
< &ansbuf
[sizeof ansbuf
- 1]) {
28 i
= (isalpha(i
) && isupper(i
)) ? tolower(i
) : i
;
30 if (i
>= 'A' && i
<= 'Z')
37 if (ansbuf
[0] == '?' || cp
== ansbuf
) {
38 printf ("Options are:\n");
39 for (ap
= ansp
; ap
-> sw
; ap
++)
40 printf (" %s\n", ap
-> sw
);
43 if ((i
= smatch (ansbuf
, ansp
)) < 0) {
44 printf ("%s: %s.\n", ansbuf
, i
== -1 ? "unknown" : "ambiguous");