#!/bin/ksh -p
#
# ident "@(#)gdm-lookup-dpy.sh	1.1 04/04/14"
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
#
# utility script to lookup which X server is connected to a token 
#
# The database of available display numbers is taken as 
# Xservers. If a display is mentioned as
#
#	sysname:num OR :num
#
# at the beginning of a line or the beginning of a comment, it is considered
# unavailable for use.
#
# E.g. a line '# :3 RESERVED' will prevent display 3 from being assigned
#

verbose=0
umask 0022
unset LD_LIBRARY_PATH

BASE=/etc/opt/SUNWut/basedir
SUNWUT=$BASE
SUNWUTLIB=$SUNWUT/lib

dir=$1		# configuration directory location
token=$2	# token name

xserv=$dir/Xservers     # DMNAME's Xservers file
xconf=$dir/Xconfig      # DMNAME's Xconfig file
xconfiglock=$dir/config.lock    # X-Windows config lock file

#
# Get the current X display  for this token
#
$SUNWUTLIB/utdtutil -l $xconfiglock -g "_TOKEN=$token\>" $xserv $xconf
