head 1.8; access; symbols; locks; strict; comment @ * @; 1.8 date 92.12.15.00.20.22; author jromine; state Exp; branches; next 1.7; 1.7 date 92.11.12.00.57.49; author jromine; state Exp; branches; next 1.6; 1.6 date 92.10.26.22.38.03; author jromine; state Exp; branches; next 1.5; 1.5 date 90.04.05.15.31.15; author sources; state Exp; branches; next 1.4; 1.4 date 90.04.05.14.45.27; author sources; state Exp; branches; next 1.3; 1.3 date 90.02.06.13.03.44; author sources; state Exp; branches; next 1.2; 1.2 date 90.02.05.14.22.01; author sources; state Exp; branches; next 1.1; 1.1 date 90.02.05.14.20.51; author sources; state Exp; branches; next ; desc @@ 1.8 log @endif sugar @ text @/* getans.c - get an answer from the user and return a string array */ #ifndef lint static char ident[] = "@@(#)$Id: getans.c,v 1.7 1992/11/12 00:57:49 jromine Exp jromine $"; #endif /* lint */ #include "../h/mh.h" #ifdef BSD42 #include #endif /* BSD42 */ #include #include static char ansbuf[BUFSIZ]; #ifndef BSD42 static int interrupted; #else /* BSD42 */ static jmp_buf sigenv; #endif /* BSD42 */ static TYPESIG intrser (); char **getans (prompt, ansp) char *prompt; struct swit *ansp; { int i; TYPESIG (*istat) (); char *cp, **cpp; #ifndef BSD42 interrupted = 0; istat = signal (SIGINT, intrser); #else /* BSD42 */ switch (setjmp (sigenv)) { case OK: istat = signal (SIGINT, intrser); break; default: (void) signal (SIGINT, istat); return NULL; } #endif /* BSD42 */ for (;;) { printf ("%s", prompt); (void) fflush (stdout); cp = ansbuf; while ((i = getchar ()) != '\n') { #ifndef BSD42 if (i == EOF || interrupted) { interrupted = 0; (void) signal (SIGINT, istat); return NULL; } #else /* BSD42 */ if (i == EOF) longjmp (sigenv, DONE); #endif /* BSD42 */ if (cp < &ansbuf[sizeof ansbuf - 1]) *cp++ = i; } *cp = 0; if (ansbuf[0] == '?' || cp == ansbuf) { printf ("Options are:\n"); printsw (ALL, ansp, ""); continue; } cpp = brkstring (ansbuf, " ", NULLCP); switch (smatch (*cpp, ansp)) { case AMBIGSW: ambigsw (*cpp, ansp); continue; case UNKWNSW: printf (" -%s unknown. Hit for help.\n", *cpp); continue; default: (void) signal (SIGINT, istat); return cpp; } } } static TYPESIG intrser (i) int i; { #ifndef BSD42 (void) signal(SIGINT, intrser); interrupted = 1; #else /* BSD42 */ longjmp (sigenv, NOTOK); #endif /* BSD42 */ } @ 1.7 log @fix for SVR4 @ text @d3 2 a4 2 static char ident[] = "@@(#)$Id: getans.c,v 1.6 1992/10/26 22:38:03 jromine Exp jromine $"; #endif lint d9 1 a9 1 #endif BSD42 d17 1 a17 1 #else BSD42 d19 1 a19 1 #endif BSD42 d34 1 a34 1 #else BSD42 d44 1 a44 1 #endif BSD42 d56 1 a56 1 #else BSD42 d59 1 a59 1 #endif BSD42 d91 1 a91 1 #else BSD42 d93 1 a93 1 #endif BSD42 @ 1.6 log @add TYPESIG on intrser @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: getans.c,v 1.5 1990/04/05 15:31:15 sources Exp jromine $"; d85 3 a87 1 static TYPESIG intrser () { @ 1.5 log @add ID @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id:$"; d20 1 a20 1 static int intrser (); d85 1 a85 1 static int intrser () { @ 1.4 log @add ID @ text @d3 1 a3 1 static char ident[] = "$Id:"; @ 1.3 log @ANSI Compilance @ text @d2 3 @ 1.2 log @TYPESIG @ text @d17 1 a17 1 int intrser (); @ 1.1 log @Initial revision @ text @d24 1 a24 1 int (*istat) (); @