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 - metrics - download
Index: T b

⟦0770cb017⟧ TextFile

    Length: 1223 (0x4c7)
    Types: TextFile
    Names: »boolean.c«

Derivation

└─⟦060c9c824⟧ Bits:30007080 DKUUG TeX 2/12/89
    └─⟦this⟧ »./DVIware/laser-setters/quicspool/libprofile/boolean.c« 
└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12
    └─⟦af5ba6c8e⟧ »unix3.0/DVIWARE.tar.Z« 
        └─⟦ca79c7339⟧ 
            └─⟦this⟧ »DVIware/laser-setters/quicspool/libprofile/boolean.c« 

TextFile

static char *rcs = "$Header: boolean.c,v 1.1 88/01/15 12:16:56 simpson Rel $";
/*
$Log:	boolean.c,v $
 * Revision 1.1  88/01/15  12:16:56  simpson
 * initial release
 * 
 * Revision 0.1  87/12/11  17:02:10  simpson
 * beta test
 * 
*/
#include <ctype.h>
#include "profile.h"

static char *Yes[] = {
	"yes",
	"on",
	"true",
	"enable",
	"available",
	"present",
	0
};

static char *No[] = {
	"no",
	"off",
	"false",
	"disable",
	"unavailable",
	"absent",
	0
};

int profile_boolean (v)
PROFILE_VALUE *v;
{
	char x[16];
	int i;

	if (v == 0)
		return(0);

	switch (v->class) {
	case PROFILE_OTHER:
	case PROFILE_STRING:
		strncpy(x, v->value.s, sizeof(x)-1);
		x[sizeof(x)-1] = 0;
		downshift(x);
		for (i = 0; Yes[i]; i++)
			if (strcmp(x, Yes[i]) == 0)
				return(1);
			else if (strcmp(x, No[i]) == 0)
				return(0);
		return(-1);	/* unknown string */

	case PROFILE_HEX:
	case PROFILE_INTEGER:
	case PROFILE_OCTAL:
		return(v->value.i != 0);

	case PROFILE_CHARACTER:
		return(v->value.c != 0);

	case PROFILE_FLOAT:
		return(v->value.f != 0.0);

	default:
		return(-1);	/* unknown class */
	}
}

/* downshift a string in place */
static downshift (s)
char *s;
{
	for (; *s; s++)
		if (isupper(*s))
			*s = tolower(*s);
}