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 y

⟦1d5240e72⟧ TextFile

    Length: 1858 (0x742)
    Types: TextFile
    Names: »yesno.c«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec8/mcp/src/yesno.c« 

TextFile

#include <stdio.h>
#include "sysdep.h"
#include "mem.h"
#include "lists.h"
#include "gpa.h"

static	char *yn[4] = { "yes", "no", "YES!!!", "NO!!!" };
static	char *y[1] = { "yes" };
static	char *n[1] = { "no" };

struct	list YesNo = {	4, 4, (addr *)yn };

static	struct list Yes = { 1, 1, (addr *)y };
static	struct list No = { 1, 1, (addr *)n };

/*
 * Query for a yes or no answer.  Allows carriage return to default
 * yes.  Returns 1 if answer is yes, 0 for no.
 */
yes(prompt)
char *prompt;

{
	addr *argv;
	int argc;
	char **cpp;

	argv = get_gpa(2);
	cpp = (char **) argv;
	do {
		GetLine(prompt, 1, &argc, argv, &Yes);
		if (argc == 0 || **cpp == 'y' || **cpp == 'Y') {
			pop_gpa(2);
			return(1);
		}
		else if (**cpp == 'n' || **cpp == 'N') {
			pop_gpa(2);
			return(0);
		}
	} while (clear_gpa(argv, 2));
	/* NOTREACHED */
}


/*
 * Query for a yes or no answer.  Allows carriage return to default
 * no.  Returns 1 if answer is no, 0 for yes.
 */
no(prompt)
char *prompt;

{
	addr *argv;
	int argc;
	char **cpp;

	argv = get_gpa(2);
	cpp = (char **) argv;
	do {
		GetLine(prompt, 1, &argc, argv, &No);
		if (argc == 0 || **cpp == 'n' || **cpp == 'N') {
			pop_gpa(2);
			return(1);
		}
		else if (**cpp == 'y' || **cpp == 'Y') {
			pop_gpa(2);
			return(0);
		}
	} while (clear_gpa(argv, 2));
	/* NOTREACHED */
}


/*
 * Query for a yes or no answer.  Disallows carriage return default;
 * answer must be specified.  Returns 1 if answer is yes, 0 for no.
 */
yesno(prompt)
char *prompt;

{
	addr *argv;
	int argc;
	char **cpp;

	argv = get_gpa(2);
	cpp = (char **) argv;
	do {
		GetLine(prompt, 1, &argc, argv, &YesNo);
		if (argc == 0) continue;
		if (**cpp == 'y' || **cpp == 'Y') {
			pop_gpa(2);
			return(1);
		}
		else if (**cpp == 'n' || **cpp == 'N') {
			pop_gpa(2);
			return(0);
		}
	} while (clear_gpa(argv, 2));
	/* NOTREACHED */
}