head 1.2; access; symbols; locks; strict; comment @ * @; 1.2 date 92.10.26.22.50.52; author jromine; state Exp; branches; next 1.1; 1.1 date 92.10.26.22.50.08; author jromine; state Exp; branches; next ; desc @@ 1.2 log @LOCALE @ text @/* gans.c - get an answer from the user */ #ifndef lint static char ident[] = "@@(#)$Id: m_getfld.c,v 1.12 1992/05/12 21:49:37 jromine Exp $"; #endif /* lint */ #include "../h/mh.h" #include gans (prompt, ansp) register char *prompt; register struct swit *ansp; { register int i; register char *cp; register struct swit *ap; char ansbuf[BUFSIZ]; for (;;) { printf ("%s", prompt); (void) fflush (stdout); cp = ansbuf; while ((i = getchar ()) != '\n') { if (i == EOF) return 0; if (cp < &ansbuf[sizeof ansbuf - 1]) { #ifdef LOCALE i = (isalpha(i) && isupper(i)) ? tolower(i) : i; #else if (i >= 'A' && i <= 'Z') i += 'a' - 'A'; #endif *cp++ = i; } } *cp = 0; if (ansbuf[0] == '?' || cp == ansbuf) { printf ("Options are:\n"); for (ap = ansp; ap -> sw; ap++) printf (" %s\n", ap -> sw); continue; } if ((i = smatch (ansbuf, ansp)) < 0) { printf ("%s: %s.\n", ansbuf, i == -1 ? "unknown" : "ambiguous"); continue; } return i; } } @ 1.1 log @Initial revision @ text @d2 3 d27 3 d32 1 @