]> diplodocus.org Git - nmh/blob - docs/historical/mh-nov-1983/subs/gans.c
Update XOAUTH2 documentation.
[nmh] / docs / historical / mh-nov-1983 / subs / gans.c
1 #include "mh.h"
2 #include <stdio.h>
3
4 gans(prompt, ansp)
5 struct swit *ansp;
6 {
7 char ansbuf[32];
8 register char *cp;
9 register int i;
10 struct swit *ap;
11
12 for(;;) {
13 printf("%s", prompt);
14 fflush(stdout);
15 cp = ansbuf;
16 while((i = getchar()) != '\n') {
17 if(i == EOF)
18 return(0);
19 if(cp < &ansbuf[31]) {
20 if(i >= 'A' && i <= 'Z')
21 i += 'a'-'A';
22 *cp++ = i;
23 }
24 }
25 *cp = 0;
26 if(ansbuf[0] == '?' || cp == ansbuf) {
27 printf("Options are:\n");
28 for(ap = ansp; ap->sw; ap++)
29 printf(" %s\n", ap->sw);
30 continue;
31 }
32 if((i = smatch(ansbuf, ansp)) < 0) {
33 printf("%s: %s.\n", ansbuf, i == -1? "unknown":"ambiguous");
34 continue;
35 }
36 return(i);
37 }
38 }