RemoteHostCommands.mesa
Copyright Ó 1990, 1992 by Xerox Corporation. All rights reserved.
Last tweaked by Mike Spreitzer on March 18, 1992 8:03 am PST
DIRECTORY BasicTime, Commander, CommanderOps, HostAndTerminalOps, IO, NetAddressing, Rope, TerminalLocation;
RemoteHostCommands: CEDAR PROGRAM
IMPORTS BasicTime, Commander, CommanderOps, HostAndTerminalOps, IO, NetAddressing, TerminalLocation
=
BEGIN OPEN HAT:HostAndTerminalOps, NA:NetAddressing, TL:TerminalLocation;
ROPE: TYPE ~ Rope.ROPE;
ParseResult: TYPE ~ RECORD [msg: ROPE ¬ NIL, addr: NA.Address ¬ NA.nullAddress];
GetLocStateCmd: PROC [cmd: Commander.Handle] RETURNS [result: REF ANY ¬ NIL, msg: ROPE ¬ NIL] --Commander.CommandProc-- ~ {
is: TL.InstState ~ TL.PeekLoc[];
cmd.out.PutRope["Terminal locations are "];
cmd.out.PutRope[TL.FormatInstState[is]];
cmd.out.PutF1["; net-initiated observers will be %g.\n", [rope[IF TL.ObserversAllowed[] THEN "accepted" ELSE "rejected"]] ];
RETURN};
SetPrimaryCmd: PROC [cmd: Commander.Handle] RETURNS [result: REF ANY ¬ NIL, msg: ROPE ¬ NIL] --Commander.CommandProc-- ~ {
argv: CommanderOps.ArgumentVector ~ CommanderOps.Parse[cmd];
IF argv.argc#2 THEN RETURN [$Failure, "Usage: RemoteHostSetPrimary <location>"];
{pl: TL.Location ~ TL.ParseLoc[argv[1] !NA.Error => {
expl: ROPE ~ NA.FormatError[codes, msg];
ERROR CommanderOps.Failed[expl]}];
TL.SetPrimary[pl];
RETURN GetLocStateCmd[cmd]}};
SelPrimaryCmd: PROC [cmd: Commander.Handle] RETURNS [result: REF ANY ¬ NIL, msg: ROPE ¬ NIL] --Commander.CommandProc-- ~ {
argv: CommanderOps.ArgumentVector ~ CommanderOps.Parse[cmd];
IF argv.argc#2 THEN RETURN [$Failure, "Usage: RemoteHostSelPrimary <location>"];
{pl: TL.Location ~ TL.ParseLoc[argv[1] !NA.Error => {
expl: ROPE ~ NA.FormatError[codes, msg];
ERROR CommanderOps.Failed[expl]}];
TL.SelPrimary[pl];
RETURN GetLocStateCmd[cmd]}};
AddSecondaryCmd: PROC [cmd: Commander.Handle] RETURNS [result: REF ANY ¬ NIL, msg: ROPE ¬ NIL] --Commander.CommandProc-- ~ {
argv: CommanderOps.ArgumentVector ~ CommanderOps.Parse[cmd];
IF argv.argc#2 THEN RETURN [$Failure, "Usage: RemoteHostAddSecondary <location>"];
{pl: TL.Location ~ TL.ParseLoc[argv[1] !NA.Error => {
expl: ROPE ~ NA.FormatError[codes, msg];
ERROR CommanderOps.Failed[expl]}];
TL.AddSecondary[pl];
RETURN GetLocStateCmd[cmd]}};
AbandonCmd: PROC [cmd: Commander.Handle] RETURNS [result: REF ANY ¬ NIL, msg: ROPE ¬ NIL] --Commander.CommandProc-- ~ {
argv: CommanderOps.ArgumentVector ~ CommanderOps.Parse[cmd];
IF argv.argc#2 THEN RETURN [$Failure, "Usage: RemoteHostAbandon <location>"];
{pl: TL.Location ~ TL.ParseLoc[argv[1] !NA.Error => {
expl: ROPE ~ NA.FormatError[codes, msg];
ERROR CommanderOps.Failed[expl]}];
TL.Abandon[pl, [BasicTime.Now[], "user command"]];
RETURN GetLocStateCmd[cmd]}};
AcceptObserversCmd: Commander.CommandProc ~ {
TL.AllowObservers[TRUE];
RETURN GetLocStateCmd[cmd]};
RejectObserversCmd: Commander.CommandProc ~ {
TL.AllowObservers[FALSE];
RETURN GetLocStateCmd[cmd]};
PrintVersions: PROC [cmd: Commander.Handle] RETURNS [result: REF ANY ¬ NIL, msg: ROPE ¬ NIL] --Commander.CommandProc-- ~ {
Print: PROC [protocol: ROPE, pvr: HAT.ProtocolVersionRange] ~ {
cmd.out.PutF["%g: [%g .. %g]\n", [rope[protocol]], [integer[pvr.min]], [integer[pvr.max]] ];
RETURN};
HAT.EnumerateProtocolVersionsOfSide[SELECT cmd.procData.clientData FROM $Host => Host, $Terminal => Terminal, ENDCASE => ERROR, Print];
};
Commander.Register["RemoteHostGetLocState", GetLocStateCmd, "--- reports locations of this Host's terminals"];
Commander.Register["RHGetLocState", GetLocStateCmd, "--- reports locations of this Host's terminals"];
Commander.Register["RemoteHostSetPrimary", SetPrimaryCmd, "<location> --- establishes RemoteTerminal connection"];
Commander.Register["RHSetPrimary", SetPrimaryCmd, "<location> --- establishes RemoteTerminal connection"];
Commander.Register["RemoteHostSelPrimary", SelPrimaryCmd, "<location> --- gives floor to indicated terminal"];
Commander.Register["RHSelPrimary", SelPrimaryCmd, "<location> --- gives floor to indicated terminal"];
Commander.Register["RemoteHostAddSecondary", AddSecondaryCmd, "<location> --- add observer"];
Commander.Register["RHAddSecondary", AddSecondaryCmd, "<location> --- add observer"];
Commander.Register["RemoteHostAbandon", AbandonCmd, "<location> --- disconnect from a terminal"];
Commander.Register["RHAbandon", AbandonCmd, "<location> --- disconnect from a terminal"];
Commander.Register["RemoteHostAcceptObservers", AcceptObserversCmd, "--- accept net-initiated observers"];
Commander.Register["RHAcceptObservers", AcceptObserversCmd, "--- accept net-initiated observers"];
Commander.Register["RemoteHostRejectObservers", RejectObserversCmd, "--- reject net-initiated observers"];
Commander.Register["RHRejectObservers", RejectObserversCmd, "--- reject net-initiated observers"];
Commander.Register["HostVersions", PrintVersions, "--- prints installed protocol versions for Host side of RemoteTerminal system", $Host];
END.