|
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 c
Length: 892 (0x37c) Types: TextFile Names: »confirm.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen └─⟦this⟧ »cph85dist/stat/src/confirm.c«
/* LINTLIBRARY */ #include "unixstat.h" FUN(confirm,get confirmation,5.0,1985) #ifdef MSDOS /* to provide direct access to terminal */ #define DEVTTY "con:" #else #define DEVTTY "/dev/tty" #endif /* get a yes/no 1/0 answer from the user */ confirm (msg, arg) char *msg; /* prompt in printf format */ char *arg; /* optional string argument to format string */ { char line[10]; FILE *dttyin, *dttyout; if ((dttyin = fopen (DEVTTY, "r")) == NULL) return (0); if ((dttyout = fopen (DEVTTY, "w")) == NULL) { VOID fclose (dttyin); return (0); } getconfirm: fprintf (dttyout, msg, arg ? arg : ""); fprintf (dttyout, " (y/n) "); VOID fflush (dttyout); if (fgets (line, 10, dttyin) == NULL) return (0); switch (*line) { case 'Y': case 'y': return (1); case 'N': case 'n': return (0); default: fprintf (dttyout, "type y for yes, n for no\n"); } goto getconfirm; }