#! /bin/sh
#
# @(#)boolval	1.4	LPS_UNX_COM	02/19/95
#
# Copyright 1994   Digital Equipment Corporation, Maynard, MA
#
# boolval
#
# Simple support script that exits with a value according to the value
# of the specified string.  The string value must represent one of the
# valid boolean values for LPS Object Database "flag" attributes, one
# of the following (case is not significant and can be mixed):
#
#    true:  "YES", "Y", TRUE", "T"
#    false: "NO", "N", "FALSE", "F"
#
# This script is used to easily test LPS flag attributes without having
# to deal with the actual data content of the associated shell variable.
# For example:
#
#	if boolval $PC_ENABLEBANNERS   # Is banner page printing enabled?
#	then
#	    -yes-
#	else
#	    -no-
#	fi
#
# This script is used extensively during object variable configuration.
#
# Parameters:
#    $1 - String
#
# Global variables:
#    LPSODB
#    -none-
#
# Exit values:
#    0 - Yes, the specified string represents an LPS "true" value.
#    1 - No, the specified string represents an LPS "false" value,
#    2 - Neither, the string does not resolve to a valid LPS truth value,
#	 in which case an evil warning message is delivered to stderr.
#
# Obviously, an invalid string will have the same result as a valid "false"
# string, but the net effect is probably OK, since the result is to imply
# a disabling of a given feature.  Oh well...
###

VAL=$1

case $VAL in
    [Yy] | [Tt] | [Yy][Ee][Ss] | [Tt][Rr][Uu][Ee]     | [Oo][Nn]     ) exit 0 ;;
    [Nn] | [Ff] | [Nn][Oo]     | [Ff][Aa][Ll][Ss][Ee] | [Oo][Ff][Ff] ) exit 1 ;;
esac

echo "[BAD BOOLEAN VALUE: \"$VAL\"]" 1>&2

exit 2
