|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T g
Length: 845 (0x34d)
Types: TextFile
Names: »gans.c«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit
└─⟦3658e588a⟧ »EurOpenD3/mail/mh/mh-6.7.tar.Z«
└─⟦c75e36ecb⟧
└─⟦this⟧ »mh-6.7/sbr/gans.c«
/* gans.c - get an answer from the user */
#include "../h/mh.h"
#include <stdio.h>
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]) {
if (i >= 'A' && i <= 'Z')
i += 'a' - 'A';
*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;
}
}