DIRECTORY EnvironmentVariables USING [Get], IO, RefText, Rope, SystemNames USING [Release, ReleaseOption], SystemVersion USING [release], ThisMachine USING [Name]; SystemNamesImpl: CEDAR MONITOR IMPORTS EnvironmentVariables, IO, RefText, Rope, SystemVersion, ThisMachine EXPORTS SystemNames ~ { ROPE: TYPE ~ Rope.ROPE; Release: TYPE ~ SystemNames.Release; ReleaseOption: TYPE ~ SystemNames.ReleaseOption; ReleaseArray: TYPE ~ ARRAY Release OF ROPE; releaseNames: REF ReleaseArray ~ NEW[ReleaseArray ¬ ALL[NIL]]; defaultDir: ROPE ~ "Cedar"; machineLocalDir: ROPE ~ "tmp"; Initialize: PROC ~ { Version: TYPE ~ RECORD [major, minor: INT]; current: Version ~ [major: SystemVersion.release.major, minor: SystemVersion.release.minor]; previous: Version ~ IF current.minor>0 THEN [major: current.major, minor: current.minor-1] ELSE [major: 0, minor: 0]; -- must edit this by hand each major release next: Version ~ [major: current.major, minor: current.minor+1]; versions: ARRAY Release OF Version ¬ [previous: previous, current: current, next: next]; FOR r: Release IN Release DO v: Version ~ versions[r]; releaseNames[r] ¬ Rope.Flatten[IO.PutFR["%g.%g", IO.int[v.major], IO.int[v.minor]]]; ENDLOOP; }; ReleaseName: PUBLIC PROC [release: Release ¬ current] RETURNS [ROPE] ~ { RETURN [releaseNames[release]]; }; userName: ROPE ¬ NIL; UserName: PUBLIC ENTRY PROC RETURNS [name: ROPE] ~ { IF userName = NIL THEN userName ¬ EnvironmentVariables.Get["USER"]; name ¬ userName; }; homeDirectory: ROPE ¬ NIL; SimpleHomeDirectory: PUBLIC ENTRY PROC RETURNS [wdir: Rope.ROPE] ~ { IF homeDirectory = NIL THEN { temp: ROPE ¬ EnvironmentVariables.Get["HOME"]; IF temp.Fetch[temp.Length[]-1] # '/ THEN temp ¬ temp.Concat["/"]; homeDirectory ¬ temp; }; wdir ¬ homeDirectory; }; MachineName: PUBLIC PROC RETURNS [machine: ROPE ¬ NIL] ~ { machine ¬ ThisMachine.Name[]; IF machine=NIL THEN machine ¬ "AnonymousMachine"; }; ReleaseDir: PUBLIC PROC [dir: ROPE, release: Release] RETURNS [ROPE] ~ { releaseName: ROPE ~ releaseNames[release]; IF dir = NIL THEN dir ¬ defaultDir; RETURN[Rope.Flatten[Rope.Concat[dir, releaseName]]]; }; ReleaseSubDir: PUBLIC PROC [subDirs: ROPE, release: Release] RETURNS [ROPE] ~ { releaseName: ROPE ~ releaseNames[release]; IF Rope.IsEmpty[subDirs] THEN RETURN[releaseName] ELSE RETURN[Rope.Flatten[Rope.Cat[releaseName, "/", subDirs]]]; }; MachineLocalDir: PUBLIC PROC [subDirs: ROPE, option: ReleaseOption, release: Release ¬ current] RETURNS [ROPE] ~ { RETURN[ConstructDir[machineLocalDir, subDirs, option, release]]; }; CedarDir: PUBLIC PROC [subDirs: ROPE, release: Release, dir: ROPE] RETURNS [ROPE] ~ { IF dir=NIL THEN dir ¬ defaultDir; RETURN[ConstructDir[dir, subDirs, $releaseDir, release]]; }; UserCedarDir: PUBLIC PROC [subDirs: ROPE, option: ReleaseOption, release: Release] RETURNS [ROPE] ~ { dir: ROPE ¬ NIL; SELECT option FROM releaseDir => dir ¬ ReleaseDir[dir, release]; releaseOmitted => NULL; ENDCASE => ERROR; RETURN[ConstructName[dir, subDirs, TRUE]]; }; ConstructDir: PROC [ dir, subDirs: ROPE, option: ReleaseOption, release: Release] RETURNS [ROPE] ~ { SELECT option FROM releaseDir => dir ¬ ReleaseDir[dir, release]; releaseSubDir => subDirs ¬ ReleaseSubDir[subDirs, release]; releaseOmitted => NULL; ENDCASE => ERROR; RETURN[ConstructName[dir: dir, subDirs: subDirs]]; }; ConstructName: PROC [dir, subDirs: ROPE ¬ NIL, userRelative: BOOL ¬ FALSE] RETURNS [fName: ROPE] = { GetTildeRope: PROC RETURNS [r: Rope.ROPE] = { r ¬ SimpleHomeDirectory[]; IF r = NIL THEN ERROR -- can't happen. presumably the user logged on. ELSE RETURN[Rope.Concat[r, ".cedar"]]; }; scratch: REF TEXT ~ RefText.ObtainScratch[120]; text: REF TEXT ¬ scratch; IF userRelative THEN text ¬ RefText.AppendRope[text, GetTildeRope[]]; text ¬ RefText.AppendChar[text, '/ ]; IF NOT Rope.IsEmpty[dir] THEN { text ¬ RefText.AppendRope[text, dir]; text ¬ RefText.AppendChar[text, '/ ]; }; IF NOT Rope.IsEmpty[subDirs] THEN { text ¬ RefText.AppendRope[text, subDirs]; text ¬ RefText.AppendChar[text, '/ ]; }; fName ¬ Rope.FromRefText[text]; RefText.ReleaseScratch[scratch]; }; Initialize[]; }. SystemNamesImpl.mesa Copyright Σ 1987, 1989, 1991, 1992, 1993 by Xerox Corporation. All rights reserved. Doug Wyatt, January 24, 1987 7:03:35 pm PST Willie-sue, August 19, 1991 2:12 pm PDT JKF December 20, 1988 11:01:09 am PST Carl Hauser, December 9, 1988 5:41:01 pm PST Michael Plass, May 11, 1989 5:45:31 pm PDT Christian Jacobi, March 31, 1993 3:20 pm PST This impl of SystemNames simply gets the needed info from the environment string instead of going through YellowPages ie return something like: "/palain/wyatt/Cedar" Κϋ•NewlineDelimiter –(cedarcode) style˜codešœ™Kšœ ΟeœI™TKšœ(Οk™+Kšœ'™'Kšžœ"™%K™,K™*K™,K™Kšœu™u—K˜šž ˜ Kšœžœ˜!Kšžœ˜Kšœ˜Kšœ˜Kšœ žœ˜+Kšœžœ ˜Kšœ žœœ˜K˜—šΟnœžœž˜Kšžœœžžžœ+˜KKšžœ˜K˜šžœžœžœ˜K˜—Kšœ žœ˜$šœžœ˜0K˜—Kš œžœžœ žœžœ˜+š œžœžœžœžœ˜>K˜—Kšœ žœ ˜šœžœ ˜K˜—šŸ œžœ˜Kšœ žœžœžœ˜+Kšœ\˜\Kšœžœžœ/žœΟc,˜’Kšœ@˜@Kšœ žœ žœ>˜Xšžœ žœ ž˜K˜Kšœžœžœžœ˜TKšžœ˜—K˜K˜—š Ÿ œžœžœžœžœ˜HKšžœ˜K˜K™—Kšœ žœžœ˜š Ÿœžœžœžœžœžœ˜4Kšžœ žœžœ-˜CKšœ˜K˜K˜—Kšœžœžœ˜š Ÿœžœžœžœžœ žœ˜Dšžœžœžœ˜Kšœžœ$˜.Kšžœ"žœ˜AKšœ˜K˜—Kšœ˜K˜K˜—š Ÿ œžœžœžœ žœžœ˜:Kšœ˜Kšžœ žœžœ˜1K˜K˜—š Ÿ œžœžœžœžœžœ˜HKšœ žœ˜*Kšžœžœžœ˜#Kšžœ.˜4˜K˜——š Ÿ œžœžœ žœžœžœ˜OKšœ žœ˜*Kš žœžœžœ žœžœ4˜qK˜K˜—š Ÿœžœžœ žœ5žœžœ˜rKšžœ:˜@K˜K™—šŸœžœžœ žœžœžœžœ˜UKšžœžœžœ˜!Kšžœ3˜9K˜K™—š Ÿ œžœžœ žœ+žœžœ˜eKšœžœžœ˜šžœž˜Kšœ-˜-Kšœžœ˜Kšžœžœ˜—Kšžœžœ˜*K˜K˜—š Ÿ œžœžœ+žœžœ˜dšžœž˜Kšœ-˜-Kšœ;˜;Kšœžœ˜Kšžœžœ˜—Kšžœ,˜2K˜K™—šŸ œžœžœžœžœžœžœ žœ˜dšŸ œžœžœ žœ˜-Kšœ/™/Kšœ˜Kšžœžœžœžœ /œžœžœ˜lK˜K˜—Icode2šœ žœžœ˜/Lšœžœžœ ˜Lšžœžœ1˜EL˜%šžœžœžœ˜Lšœ%˜%L˜%L˜—šžœžœžœ˜#Lšœ)˜)L˜%L˜—L˜L˜ Lšœ˜—K˜K˜Kšœ ˜ K˜Kšœ˜——…—#