DIRECTORY Ascii, Atom, Convert, EnvironmentVariables, Identification, IO, NetworkName, SystemNames, Rope, XlAccess; XlAccessImpl: CEDAR PROGRAM IMPORTS Ascii, Atom, Convert, EnvironmentVariables, IO, NetworkName, Rope, SystemNames EXPORTS Identification, XlAccess = BEGIN hostName: Rope.ROPE ฌ SystemNames.MachineName[]; cirioPort: Rope.ROPE ฌ GetCirioPortRope[]; ident: Rope.ROPE ฌ IO.PutFR["%g (%g)", IO.rope[hostName], IO.rope[cirioPort]]; GetCirioPortNum: PROC [] RETURNS [n: CARD ฌ 0] = { Get: PROC [] RETURNS [CARD] = TRUSTED MACHINE CODE { "CirioNubLocalGetPort" }; n ฌ Get[ ! UNCAUGHT => CONTINUE ] }; GetCirioPortRope: PROC [] RETURNS [Rope.ROPE] = { RETURN [Convert.RopeFromCard[GetCirioPortNum[]]] }; Self: PUBLIC PROC [a: ATOM ฌ NIL] RETURNS [Rope.ROPE] = { SELECT a FROM NIL => RETURN [ident]; $Host => RETURN [hostName]; $Cirio => RETURN [cirioPort]; ENDCASE => RETURN [ident]; }; ServerNameFromProperties: PROC [for: ATOM] RETURNS [name: Rope.ROPE ฌ NIL] = { IF for=NIL THEN for ฌ $X11; WITH Atom.GetProp[for, $DISPLAY] SELECT FROM r: Rope.ROPE => name ฌ r; ENDCASE => {}; }; IsArpaAddress: PROC [r: Rope.ROPE] RETURNS [BOOL ฌ FALSE] ~ { len: INT ~ Rope.Length[r]; IF len>0 AND Ascii.Digit[Rope.Fetch[r, 0]] THEN IF Rope.SkipOver[s: r, skip: "0123456789."] >= len THEN IF Rope.Match[pattern: "*.*.*.*", object: r] THEN RETURN [TRUE] }; SubstituteLocalNames: PROC [serverName: Rope.ROPE] RETURNS [Rope.ROPE] = { IF ~IsLocalHost[serverName] THEN RETURN [serverName] ELSE { localHost: Rope.ROPE ~ "localhost"; colonPos: INT ~ Rope.SkipTo[s: serverName, skip: ":"]; RETURN [ Rope.Replace[base: serverName, len: colonPos, with: localHost] ]; }; }; StripDisplayNumber: PROC [name: Rope.ROPE] RETURNS [Rope.ROPE] = { colonPos: INT ฌ Rope.SkipTo[s: name, skip: ":"]; RETURN [Rope.Substr[name, 0, colonPos]] }; IsLocalHost: PUBLIC PROC [serverName: Rope.ROPE] RETURNS [BOOL] = { serverName ฌ StripDisplayNumber[serverName]; SELECT TRUE FROM Rope.IsEmpty[serverName] => RETURN [TRUE]; Rope.Equal["localhost", serverName, FALSE] => RETURN [TRUE]; Rope.Equal["unix", serverName, FALSE] => RETURN [TRUE]; Rope.Equal["127.0.0.1", serverName, FALSE] => RETURN [TRUE]; Rope.Equal["[127.0.0.1]", serverName, FALSE] => RETURN [TRUE]; Rope.Equal[hostName, serverName, FALSE] => RETURN [TRUE]; ENDCASE => RETURN [FALSE] }; DefaultServer: PUBLIC PROC [for: ATOM ฌ NIL] RETURNS [serverName: Rope.ROPE] = { IF for#$Unix THEN { serverName ฌ ServerNameFromProperties[for]; IF Rope.IsEmpty[serverName] AND for#NIL THEN serverName ฌ ServerNameFromProperties[NIL] }; IF Rope.IsEmpty[serverName] THEN serverName ฌ EnvironmentVariables.Get["DISPLAY"]; serverName ฌ SubstituteLocalNames[serverName]; }; AddressFromNameFailed: PUBLIC ERROR [msg: Rope.ROPE] = CODE; AddressFromName: PUBLIC PROC [name: Rope.ROPE] RETURNS [address: Rope.ROPE ฌ NIL] = { Raise: PROC[msg: Rope.ROPE] = {AddressFromNameFailed[msg]}; name ฌ StripDisplayNumber[name]; IF IsArpaAddress[name] THEN RETURN [name]; IF IsLocalHost[name] THEN RETURN ["127.0.0.1"]; address ฌ NetworkName.AddressFromName[family: $ARPA, name: name, components: host ! NetworkName.Error => Raise[msg]].addr; }; END. LXlAccessImpl.mesa Copyright ำ 1988, 1991, 1992, 1993 by Xerox Corporation. All rights reserved. Christian Jacobi, May 11, 1988 6:05 pm PST Christian Jacobi, March 10, 1993 10:43 am PST Willie-s, September 30, 1991 6:24 pm PDT NOTE: different source for different architectures. This is for portable Cedar on top of PCR. สา–(cedarcode) style•NewlineDelimiter ˜code™Kšœ ฯeœC™NKšœ+™+K™-K™(K™K™3K™)K™—šฯk œ;žœ+˜sK˜—šฯn œžœž˜Kšžœ-žœ ˜VKšžœ˜"—Kšžœ˜K˜Kšœžœ˜0Kšœžœ˜*Kš œ žœžœžœžœ˜NK˜šŸœžœžœžœ ˜2šŸœžœžœžœžœžœžœ˜4K˜K˜—Kšœ žœžœ˜!Kšœ˜K˜—šŸœžœžœžœ˜1Kšžœ*˜0K˜—K˜š Ÿœž œžœžœžœžœ˜9šžœž˜ Kšžœžœ ˜Kšœ žœ ˜Kšœ žœ ˜Kšžœžœ ˜—K˜K™—š Ÿœžœžœžœ žœžœ˜NKšžœžœžœ ˜šžœžœž˜,Kšœžœ ˜Kšžœ˜—K˜—K˜š Ÿ œžœ žœžœžœžœ˜=Kšœžœ˜šžœžœžœ˜0šžœ1žœ˜8Kšžœ+žœžœžœ˜?——Kšœ˜K˜—š Ÿœžœžœžœžœ˜JKšžœžœžœ˜5šžœ˜Kšœžœ˜#Kšœ žœ)˜6KšžœD˜JK˜—K˜K˜—š Ÿœžœ žœžœžœ˜BKšœ žœ#˜0Kšžœ!˜'Kšœ˜—K˜š Ÿ œž œžœžœžœ˜CKšœ,˜,šžœžœž˜Kšœžœžœ˜*Kšœ$žœžœžœ˜Kšœ!žœžœžœ˜9Kšžœžœžœ˜—K˜—K˜šŸ œžœžœžœžœžœžœ˜Pšžœ žœ˜Kšœ+˜+šžœžœžœžœ˜-Kšœ&žœ˜*—K˜—Kšžœžœ2˜RKšœ.˜.K˜K˜—Kš Ÿœžœžœ žœžœ˜