DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T c

⟦ae2b7d4e5⟧ TextFile

    Length: 892 (0x37c)
    Types: TextFile
    Names: »confirm.c«

Derivation

└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen
    └─ ⟦this⟧ »cph85dist/stat/src/confirm.c« 

TextFile

/* 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;
	}