<<>> <> <> <> <> <> <<>> DIRECTORY Arpa, ArpaName, Atom, Identification, IO, XlAccess, Rope, ThisMachine, UserProfile; XlAccessAndNameTranslationlPrincOps: CEDAR PROGRAM IMPORTS ArpaName, Atom, IO, Rope, ThisMachine, UserProfile EXPORTS XlAccess, Identification ~ BEGIN Self: PUBLIC PROC [a: ATOM ¬ NIL] RETURNS [Rope.ROPE] = { SELECT a FROM NIL => RETURN [ThisMachine.Name[]]; ENDCASE => RETURN [ThisMachine.Name[]]; }; <<>> ServerNameFromProperties: PROC [for: ATOM] RETURNS [name: Rope.ROPE ¬ NIL] = { IF for=NIL THEN for ¬ $X11; WITH Atom.GetProp[atom: for, $DISPLAY] SELECT FROM r: Rope.ROPE => name ¬ r; ENDCASE => {}; }; DefaultServer: PUBLIC PROC [for: ATOM ¬ NIL] RETURNS [serverName: Rope.ROPE] = { serverKey: Rope.ROPE; IF for#$UserProfile THEN { serverName ¬ ServerNameFromProperties[for]; IF Rope.IsEmpty[serverName] AND for#NIL THEN serverName ¬ ServerNameFromProperties[NIL] }; IF Rope.IsEmpty[serverName] THEN { IF for=NIL THEN serverKey ¬ "X11.ServerName" ELSE serverKey ¬ Rope.Concat["X11.ServerName.", Atom.GetPName[for]]; serverName ¬ UserProfile.Token[serverKey]; IF Rope.IsEmpty[serverName] AND for#NIL THEN serverName ¬ UserProfile.Token["X11.ServerName"]; }; }; AddressFromNameFailed: PUBLIC ERROR [msg: Rope.ROPE] = CODE; StatusToRope: PROC [status: ArpaName.ReplyStatus] RETURNS [msg: Rope.ROPE] = { msg ¬ SELECT status FROM ok => "ArpaName: ok", bogus => "ArpaName: Invalid name/address", other => "ArpaName: Entry is of other type. Try a different type of query", down => "ArpaName: Servers for address are not responding properly. Try again later", ENDCASE => "ArpaName: other" }; NameToAddress: PUBLIC PROC [name: Rope.ROPE] RETURNS [address: Rope.ROPE] = { a: Arpa.Address; status: ArpaName.ReplyStatus; [addr~a, status~status] ¬ ArpaName.NameToAddress[name]; IF status#ok THEN AddressFromNameFailed[StatusToRope[status]]; IF a=Arpa.nullAddress THEN AddressFromNameFailed["null address"]; address ¬ IO.PutFR["%g.%g.%g.%g", IO.int[a.a], IO.int[a.b], IO.int[a.c], IO.int[a.d]] }; END.