]> diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/sbr/RCS/gans.c,v
Exposed a bunch of switches that are now documented.
[nmh] / docs / historical / mh-6.8.5 / sbr / RCS / gans.c,v
1 head 1.2;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.2
9 date 92.10.26.22.50.52; author jromine; state Exp;
10 branches;
11 next 1.1;
12
13 1.1
14 date 92.10.26.22.50.08; author jromine; state Exp;
15 branches;
16 next ;
17
18
19 desc
20 @@
21
22
23 1.2
24 log
25 @LOCALE
26 @
27 text
28 @/* gans.c - get an answer from the user */
29 #ifndef lint
30 static char ident[] = "@@(#)$Id: m_getfld.c,v 1.12 1992/05/12 21:49:37 jromine Exp $";
31 #endif /* lint */
32
33 #include "../h/mh.h"
34 #include <stdio.h>
35
36
37 gans (prompt, ansp)
38 register char *prompt;
39 register struct swit *ansp;
40 {
41 register int i;
42 register char *cp;
43 register struct swit *ap;
44 char ansbuf[BUFSIZ];
45
46 for (;;) {
47 printf ("%s", prompt);
48 (void) fflush (stdout);
49 cp = ansbuf;
50 while ((i = getchar ()) != '\n') {
51 if (i == EOF)
52 return 0;
53 if (cp < &ansbuf[sizeof ansbuf - 1]) {
54 #ifdef LOCALE
55 i = (isalpha(i) && isupper(i)) ? tolower(i) : i;
56 #else
57 if (i >= 'A' && i <= 'Z')
58 i += 'a' - 'A';
59 #endif
60 *cp++ = i;
61 }
62 }
63 *cp = 0;
64 if (ansbuf[0] == '?' || cp == ansbuf) {
65 printf ("Options are:\n");
66 for (ap = ansp; ap -> sw; ap++)
67 printf (" %s\n", ap -> sw);
68 continue;
69 }
70 if ((i = smatch (ansbuf, ansp)) < 0) {
71 printf ("%s: %s.\n", ansbuf, i == -1 ? "unknown" : "ambiguous");
72 continue;
73 }
74 return i;
75 }
76 }
77 @
78
79
80 1.1
81 log
82 @Initial revision
83 @
84 text
85 @d2 3
86 d27 3
87 d32 1
88 @