1 /* getans.c - get an answer from the user and return a string array */
3 static char ident[] = "@(#)$Id: getans.c,v 1.8 1992/12/15 00:20:22 jromine Exp $";
14 static char ansbuf[BUFSIZ];
16 static int interrupted;
18 static jmp_buf sigenv;
20 static TYPESIG intrser ();
22 char **getans (prompt, ansp)
33 istat = signal (SIGINT, intrser);
35 switch (setjmp (sigenv)) {
37 istat = signal (SIGINT, intrser);
41 (void) signal (SIGINT, istat);
46 printf ("%s", prompt);
47 (void) fflush (stdout);
49 while ((i = getchar ()) != '\n') {
51 if (i == EOF || interrupted) {
53 (void) signal (SIGINT, istat);
58 longjmp (sigenv, DONE);
60 if (cp < &ansbuf[sizeof ansbuf - 1])
64 if (ansbuf[0] == '?' || cp == ansbuf) {
65 printf ("Options are:\n");
66 printsw (ALL, ansp, "");
69 cpp = brkstring (ansbuf, " ", NULLCP);
70 switch (smatch (*cpp, ansp)) {
75 printf (" -%s unknown. Hit <CR> for help.\n", *cpp);
78 (void) signal (SIGINT, istat);
85 static TYPESIG intrser (i)
89 (void) signal(SIGINT, intrser);
92 longjmp (sigenv, NOTOK);