:
#
#		BRSCONFIG Procedure
#
#
#	This procedure is used to extract a path name from
#	the BRS Configuration Table under UNX (/usr/lib/brssearch).
#
#	The format of the command line is:
#
#		brsconfig [-f CONFIG-FILE] XXXX
#
#	where XXXX is the name of the entry you are looking for.
#	If XXXX is one of BIN, USERS, QUEUE, TABLES, DATABASES
#	TERMINALS, OFFLINE, MENUS, THESAURUS, LANGUAGES, or PRINTERS
#	and the entry is not found, a default will be returned.
#	The only other available value for XXXX is ROOT.  Any
#	other selections will be searched for, but no defaults
#	will be assembled if the entry does not exist.
#
#		SCCS ID = "@(#) BRS brsconfig.sh v61.2 (8/28/92) { Release 6.1 }"
#

BRShelp=No
if [ $# = 0 -o X$1 = X-h ] ; then
	BRShelp=Yes
elif [ $# != 1 -a $# != 3 ] ; then
	BRShelp=Yes
elif [ $# = 3 -a X$1 != X-f ] ; then
	BRShelp=Yes
	fi

if [ ${BRShelp} = Yes ] ; then
	echo "
The BRSCONFIG Procedure -
     Retrieve a BRS Configuration Entry

COMMAND FORMAT:
	brsconfig OPTIONS ENT-NAME

	Optional Parameters:
		[-f CONFIG-FILE]

DESCRIPTION:
        This  command  procedure  is used to extract a given table entry
        from  any  BRS  Configuration  Table,  "/usr/lib/brssearch"   by
        default.  This procedure is for BRS procedure use only.
"

	exit 1
	fi

# select proper meta-config table

if [ "${BRSConfig}" != "" ] ; then
	BRSconf="${BRSConfig}"
else
	BRSconf='/usr/lib/brssearch'
	fi

# alternate config table selected

if [ $# != 1 -a X$1 = X-f ] ; then
	shift
	BRSconf=${1}
	shift
	fi

# make sure table exists

if [ ! -r "${BRSconf}" ] ; then
	exit 3
	fi

argstr=$1

(
    BRSroot=""
    target=""

    while read entry ; do
        if [ "X${entry}" != X ] ; then
            case ${entry} in
		    ROOT=*)
			BRSroot=`expr "${entry}" : "ROOT=\(.*\)"`
			;;
		    ${argstr}=*)
			target=`expr "${entry}" : "${argstr}=\(.*\)"`
			;;
		    esac
	    fi
        done

    if [ "X${target}" != "X" ] ; then
        echo ${target}
        exit 0
        fi

    if [ "X${BRSroot}" = "X" ] ; then
        exit 1
	fi

    case ${argstr} in
	    ROOT)	target="${BRSroot}" ;;
	    BIN)	target="${BRSroot}Bin/" ;;
	    MENUS)	target="${BRSroot}Menus/" ;;
	    DATABASES)	target="${BRSroot}Config/Databases/" ;;
	    LANGUAGES)	target="${BRSroot}Config/Languages/" ;;
	    OFFLINE)	target="${BRSroot}Config/Offline/" ;;
	    PRINTERS)	target="${BRSroot}Config/Printers/" ;;
	    QUEUE)	target="${BRSroot}Config/Queue/" ;;
	    TABLES)	target="${BRSroot}Config/Tables/" ;;
	    TERMINALS)	target="${BRSroot}Config/Terminals/" ;;
	    THESAURUS)	target="${BRSroot}Config/Thesaurus/" ;;
	    USERS)	target="${BRSroot}Config/Users/" ;;
	    esac

    if [ "X${target}" != "X" ] ; then
        echo ${target}
        exit 0
	fi

    ) <${BRSconf}

exit 1
