DefaultRegistryImpl.mesa
Created Thursday, June 14, 1984 4:58:18 pm PDT
Eric Nickell, June 15, 1984 4:53:39 pm PDT
DIRECTORY
Atom USING [GetPName],
DefaultRegistry,
Rope USING [Cat, Concat, Find, Substr],
UserCredentials USING [Get],
UserProfile USING [Token];
DefaultRegistryImpl:
CEDAR
PROGRAM
IMPORTS Atom, Rope, UserCredentials, UserProfile
EXPORTS DefaultRegistry
~ {
OPEN DefaultRegistry;
MakeRegistryExplicit:
PUBLIC
PROC [in:
ROPE, packages:
LIST
OF
ATOM ←
LIST [$Default], defaultDefault:
ROPE ← UsersRegistry[]]
RETURNS [out:
ROPE] ~ {
Does the obvious. If 'in' has a period in it, then it just returns that. Otherwise, it will look in the user profile for entries of the form 'UserExtension.x: extension', where the x's come from the list of ropes (packages), and extension is the extension that will be appended. If there is no appropriate user profile entry, the defaultDefault is used.
IF Rope.Find[in, "."] # -1 THEN out ← in
ELSE out ← Rope.Cat[in, ".", GetDefaultRegistry[packages, defaultDefault]];
};
GetDefaultRegistry:
PUBLIC
PROC [packages:
LIST
OF
ATOM ←
LIST [$Default], defaultDefault:
ROPE ← UsersRegistry[]]
RETURNS [registry:
ROPE] ~ {
Tells you what the default extension would be for the packages listed.
packageList: LIST OF ATOM ← packages;
WHILE packageList #
NIL
DO
ext: ROPE ← UserProfile.Token[Rope.Concat[Atom.GetPName[packageList.first], ".DefaultRegistry"]]; --Get profile entry for it, if exists
IF ext#NIL THEN RETURN[ext]; --Return it if good, else try again
packageList ← packageList.rest; --Remove first atom from list
ENDLOOP;
RETURN[defaultDefault];
};
UsersRegistry:
PUBLIC
PROC
RETURNS [registry:
ROPE] ~ {
Returns the extension of the current CEDAR user.
credentials: ROPE ← UserCredentials.Get[].name;
registry ← Rope.Substr[base: credentials, start: Rope.Find[credentials, "."]+1];
};
}.