#!/bin/sh -f
# \
exec dptcl -f "$0" "$@"

#
# $Log: not supported by cvs2svn $
#

# Remote display server. This script sets up a dp RPC server
#   on port 4550. Clients call the procedure below with
#   their DISPLAY environment variable, and a list of adl
#   files. This procedure starts medm, the display(s) popping
#   up on the remote client's screen.

#
# Called when client first attempts contact with this server.
#   Allow all hosts to connect for now.
#
proc connectionHook {args} {
    return
}

#
# Called when client attempts an RPC invocation. Here we will only
#   allow a client to execute the "displayScreens" procedure below.
#   This prevents arbitrary tcl command execution from a remote host.
#
proc commandHook {cmd args} {
    if {![string compare $cmd "displayScreens"]} {
	return
    } else {
	error "tsk tsk..."
    }
}

dp_MakeRPCServer 4550 connectionHook commandHook

proc displayScreens {displayName args} {
    global env
    set env(DISPLAY) $displayName
    eval exec medm -x -l -cleanup $args &
}

tkwait variable exitFlag

