]> diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/sbr/RCS/getans.c,v
Exposed a bunch of switches that are now documented.
[nmh] / docs / historical / mh-6.8.5 / sbr / RCS / getans.c,v
1 head 1.8;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.8
9 date 92.12.15.00.20.22; author jromine; state Exp;
10 branches;
11 next 1.7;
12
13 1.7
14 date 92.11.12.00.57.49; author jromine; state Exp;
15 branches;
16 next 1.6;
17
18 1.6
19 date 92.10.26.22.38.03; author jromine; state Exp;
20 branches;
21 next 1.5;
22
23 1.5
24 date 90.04.05.15.31.15; author sources; state Exp;
25 branches;
26 next 1.4;
27
28 1.4
29 date 90.04.05.14.45.27; author sources; state Exp;
30 branches;
31 next 1.3;
32
33 1.3
34 date 90.02.06.13.03.44; author sources; state Exp;
35 branches;
36 next 1.2;
37
38 1.2
39 date 90.02.05.14.22.01; author sources; state Exp;
40 branches;
41 next 1.1;
42
43 1.1
44 date 90.02.05.14.20.51; author sources; state Exp;
45 branches;
46 next ;
47
48
49 desc
50 @@
51
52
53 1.8
54 log
55 @endif sugar
56 @
57 text
58 @/* getans.c - get an answer from the user and return a string array */
59 #ifndef lint
60 static char ident[] = "@@(#)$Id: getans.c,v 1.7 1992/11/12 00:57:49 jromine Exp jromine $";
61 #endif /* lint */
62
63 #include "../h/mh.h"
64 #ifdef BSD42
65 #include <setjmp.h>
66 #endif /* BSD42 */
67 #include <signal.h>
68 #include <stdio.h>
69
70
71 static char ansbuf[BUFSIZ];
72 #ifndef BSD42
73 static int interrupted;
74 #else /* BSD42 */
75 static jmp_buf sigenv;
76 #endif /* BSD42 */
77 static TYPESIG intrser ();
78
79 char **getans (prompt, ansp)
80 char *prompt;
81 struct swit *ansp;
82 {
83 int i;
84 TYPESIG (*istat) ();
85 char *cp,
86 **cpp;
87
88 #ifndef BSD42
89 interrupted = 0;
90 istat = signal (SIGINT, intrser);
91 #else /* BSD42 */
92 switch (setjmp (sigenv)) {
93 case OK:
94 istat = signal (SIGINT, intrser);
95 break;
96
97 default:
98 (void) signal (SIGINT, istat);
99 return NULL;
100 }
101 #endif /* BSD42 */
102 for (;;) {
103 printf ("%s", prompt);
104 (void) fflush (stdout);
105 cp = ansbuf;
106 while ((i = getchar ()) != '\n') {
107 #ifndef BSD42
108 if (i == EOF || interrupted) {
109 interrupted = 0;
110 (void) signal (SIGINT, istat);
111 return NULL;
112 }
113 #else /* BSD42 */
114 if (i == EOF)
115 longjmp (sigenv, DONE);
116 #endif /* BSD42 */
117 if (cp < &ansbuf[sizeof ansbuf - 1])
118 *cp++ = i;
119 }
120 *cp = 0;
121 if (ansbuf[0] == '?' || cp == ansbuf) {
122 printf ("Options are:\n");
123 printsw (ALL, ansp, "");
124 continue;
125 }
126 cpp = brkstring (ansbuf, " ", NULLCP);
127 switch (smatch (*cpp, ansp)) {
128 case AMBIGSW:
129 ambigsw (*cpp, ansp);
130 continue;
131 case UNKWNSW:
132 printf (" -%s unknown. Hit <CR> for help.\n", *cpp);
133 continue;
134 default:
135 (void) signal (SIGINT, istat);
136 return cpp;
137 }
138 }
139 }
140
141
142 static TYPESIG intrser (i)
143 int i;
144 {
145 #ifndef BSD42
146 (void) signal(SIGINT, intrser);
147 interrupted = 1;
148 #else /* BSD42 */
149 longjmp (sigenv, NOTOK);
150 #endif /* BSD42 */
151 }
152 @
153
154
155 1.7
156 log
157 @fix for SVR4
158 @
159 text
160 @d3 2
161 a4 2
162 static char ident[] = "@@(#)$Id: getans.c,v 1.6 1992/10/26 22:38:03 jromine Exp jromine $";
163 #endif lint
164 d9 1
165 a9 1
166 #endif BSD42
167 d17 1
168 a17 1
169 #else BSD42
170 d19 1
171 a19 1
172 #endif BSD42
173 d34 1
174 a34 1
175 #else BSD42
176 d44 1
177 a44 1
178 #endif BSD42
179 d56 1
180 a56 1
181 #else BSD42
182 d59 1
183 a59 1
184 #endif BSD42
185 d91 1
186 a91 1
187 #else BSD42
188 d93 1
189 a93 1
190 #endif BSD42
191 @
192
193
194 1.6
195 log
196 @add TYPESIG on intrser
197 @
198 text
199 @d3 1
200 a3 1
201 static char ident[] = "@@(#)$Id: getans.c,v 1.5 1990/04/05 15:31:15 sources Exp jromine $";
202 d85 3
203 a87 1
204 static TYPESIG intrser () {
205 @
206
207
208 1.5
209 log
210 @add ID
211 @
212 text
213 @d3 1
214 a3 1
215 static char ident[] = "@@(#)$Id:$";
216 d20 1
217 a20 1
218 static int intrser ();
219 d85 1
220 a85 1
221 static int intrser () {
222 @
223
224
225 1.4
226 log
227 @add ID
228 @
229 text
230 @d3 1
231 a3 1
232 static char ident[] = "$Id:";
233 @
234
235
236 1.3
237 log
238 @ANSI Compilance
239 @
240 text
241 @d2 3
242 @
243
244
245 1.2
246 log
247 @TYPESIG
248 @
249 text
250 @d17 1
251 a17 1
252 int intrser ();
253 @
254
255
256 1.1
257 log
258 @Initial revision
259 @
260 text
261 @d24 1
262 a24 1
263 int (*istat) ();
264 @