<<>> <> <> <> <> <<>> <> <<>> DIRECTORY Atom, Commander, CommanderOps, Identification, IO, Rope, SystemNames, Xl, XlAccess, XlDetails, XlPredefinedAtoms; X11Commands: CEDAR MONITOR IMPORTS Atom, Commander, CommanderOps, Identification, IO, Rope, SystemNames, Xl, XlAccess, XlDetails = BEGIN CurrentServerDefaults: PROC [app: ATOM] RETURNS [msg: Rope.ROPE] = { msg ¬ IO.PutFR1["X server general default: %g", IO.rope[XlAccess.DefaultServer[NIL]]]; IF app#NIL AND app#$X11 THEN { msg ¬ IO.PutFR["%g, (for application %g: %g)", IO.rope[msg], IO.atom[app], IO.rope[XlAccess.DefaultServer[app]] ]; }; msg ¬ Rope.Concat[msg, "\n"]; }; TestServer: PROC [server: Rope.ROPE] RETURNS [ok: BOOL ¬ TRUE, message: Rope.ROPE] = { c: Xl.Connection; c ¬ Xl.CreateConnection[server ! Xl.connectionNotCreated => { ok ¬ FALSE; message ¬ why.reason; CONTINUE }]; IF ok THEN { ok ¬ Xl.Alive[c]; IF ok THEN Xl.CloseConnection[c]; }; }; DefaultServerCommand: Commander.CommandProc = { num: INT ¬ CommanderOps.NumArgs[cmd]; app: ATOM; server, message: Rope.ROPE; ok: BOOL; SELECT num FROM 1 => {msg ¬ CurrentServerDefaults[NIL]; RETURN}; 2 => app ¬ $X11; 3 => app ¬ Atom.MakeAtom[CommanderOps.NextArgument[cmd]]; ENDCASE => CommanderOps.Failed["Format is: X11DefaultServer {{application} server}"]; server ¬ CommanderOps.NextArgument[cmd]; IF Rope.Equal[server, "nil", FALSE] THEN Atom.RemProp[app, $DISPLAY] ELSE { [ok, message] ¬ TestServer[server]; IF ok THEN Atom.PutProp[app, $DISPLAY, server] ELSE CommanderOps.Failed[Rope.Cat[server , " not accessed: ", message, "\n"]]; }; msg ¬ CurrentServerDefaults[app]; }; IdentificationCommand: Commander.CommandProc = { msg ¬ Rope.Concat[Identification.Self[], "\n"] }; TrustedSetServerHostCommand: Commander.CommandProc = { ENABLE { Xl.XError => { msg ¬ err.explanation; result ¬ $Failure; Xl.CloseConnection[err.connection]; GOTO Oops }; Xl.connectionNotCreated => {msg ¬ why.reason; result ¬ $Failure; GOTO Oops}; }; server: Rope.ROPE ¬ SystemNames.MachineName[]; c: Xl.Connection ¬ Xl.CreateConnection[server]; serverHostAtom: Xl.XAtom ¬ Xl.MakeAtom[c, "PARC_ServerHost"]; Xl.ChangeProperty[c: c, w: Xl.FirstRoot[c], property: serverHostAtom, type: XlPredefinedAtoms.string, data: server, details: XlDetails.ignoreErrors]; Xl.CloseConnection[c]; EXITS Oops => {}; }; Commander.Register[key: "X11DefaultServer", proc: DefaultServerCommand, doc: "Denote X server for new connections. Use X11DefaultServer {application} server"]; Commander.Register[key: "X11Identification", proc: IdentificationCommand, doc: "Print Identification"]; Commander.Register[key: "X11TrustedSetServerHost", proc: TrustedSetServerHostCommand, doc: "Initializes PARC_ServerHost convention on server"]; END.