File:  [CSRG BSD Unix] / 43BSDReno / contrib / isode-beta / dsap / common / boolean.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:56 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43reno
BSD 4.3reno

/* SYNTAX boolean ::= 'TRUE' | 'FALSE' */

#include "quipu/util.h"
#include "quipu/attr.h"
#include "psap.h"

strprint();
sfree();
pstrcmp();

static PE boolenc (x)
char *x;
{
	return (bool2prim (lexequ (x,"TRUE") ? 0 : 1));
}

static char * booldec (pe)
PE pe;
{
        if (! test_prim_pe (pe,PE_CLASS_UNIV,PE_PRIM_BOOL))
		return (NULLCP);

	if (prim2flag (pe) == 1)
		return (strdup ("TRUE"));
	else
		return (strdup ("FALSE"));
}

static char * boolget (x)
char * x;
{
	if ((lexequ (x,"TRUE") == 0) || (lexequ (x,"FALSE") == 0))
		return (strdup(x));

	parse_error ("TRUE or FALSE expected (%s)",x);
	return (NULLCP);
}

boolean_syntax ()
{
	(void) add_attribute_syntax ("boolean",
		(IFP) boolenc,	(IFP) booldec,
		(IFP) boolget,	strprint,
		(IFP) strdup,	pstrcmp,
		sfree,		NULLCP,
		NULLIFP,	FALSE);
}


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.