2 ** getans.c -- get an answer from the user and return a string array
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.
10 #include <h/signals.h>
15 static char ansbuf[BUFSIZ];
16 static jmp_buf sigenv;
21 static void intrser(int);
25 getans(char *prompt, struct swit *ansp)
28 SIGNAL_HANDLER istat = NULL;
31 if (!(setjmp(sigenv))) {
32 istat = SIGNAL(SIGINT, intrser);
34 SIGNAL(SIGINT, istat);
42 while ((i = getchar()) != '\n') {
45 if (cp < &ansbuf[sizeof ansbuf - 1])
49 if (ansbuf[0] == '?' || cp == ansbuf) {
50 printf("Options are:\n");
51 print_sw(ALL, ansp, "", stdout);
54 cpp = brkstring(ansbuf, " ", NULL);
55 switch (smatch(*cpp, ansp)) {
60 printf(" -%s unknown. Hit <CR> for help.\n", *cpp);
63 SIGNAL(SIGINT, istat);
74 ** should this be siglongjmp?