DIRECTORY Atom USING [ MakeAtom ], Basics USING [ Comparison ], BasicTime USING [ GMT, Period ], Convert USING [ RopeFromInt ], Names, PupDefs USING [ AnyLocalPupAddress, PupAddress ], Rope USING [ Cat, Concat, Fetch, Length, MakeRope, ROPE, Size, SkipTo, Substr ], RPC USING [ MakeKey, EncryptionKey ], UserCredentials USING [ Get ] ; NamesImpl: CEDAR PROGRAM IMPORTS Atom, BasicTime, Convert, PupDefs, RPC, Rope, UserCredentials EXPORTS Names = { ROPE: TYPE=Names.ROPE; FileSpec: TYPE = Names.FileSpec; FileSpecBody: TYPE = Names.FileSpecBody; larkRegistry: ROPE=".Lark"; NetError: PUBLIC ERROR[problem: Names.NetProblem] = CODE; ParseFile: PUBLIC PROCEDURE[ server: ROPE_NIL, dirName: ROPE_NIL, dirPassword: ROPE_NIL, fileName: ROPE_] RETURNS [spec: FileSpec] ={ start, end: INT; spec_NEW[FileSpecBody_[ server: IF server#NIL THEN server ELSE "Indigo", name: CurrentRName[], password: UserCredentials.Get[].password]]; spec.dirName_IF dirName#NIL THEN Registrize[dirName] ELSE spec.name; start_0; IF Rope.Fetch[fileName, start]='[ THEN { end_Rope.SkipTo[fileName, start, "]"]; spec.server_Rope.Substr[fileName, start+1, end-start-1]; start_end+1; }; IF dirPassword#NIL THEN { spec.dirPassword_dirPassword; IF Rope.Fetch[fileName, start]='< THEN { end_Rope.SkipTo[fileName, start, ">"]; spec.dirName_Rope.Substr[fileName, start+1, end-start-1]; start_end+1; } ELSE IF dirName=NIL THEN ERROR; } ELSE spec.dirPassword _ spec.password; spec.fileName_Rope.Substr[fileName, start]; }; Registrize: PUBLIC PROC[name: ROPE] RETURNS [ROPE] = { dot: INT; IF name=NIL THEN RETURN[NIL]; dot_Rope.SkipTo[name, 0, "."]; IF dot=name.Length[] THEN name_Rope.Concat[name, DefaultRegistry[]]; RETURN[name]; }; CurrentRName: PUBLIC PROC RETURNS [ROPE] = { RETURN[UserCredentials.Get[].name]; }; CurrentPasskey: PUBLIC PROC[passwordText: ROPE] RETURNS [RPC.EncryptionKey] = { IF passwordText=NIL THEN passwordText_UserCredentials.Get[].password; RETURN[RPC.MakeKey[passwordText]]; }; OwnNetAddress: PUBLIC PROC RETURNS [netAddress: Names.NetAddress] = TRUSTED { pa: PupDefs.PupAddress; pa _ PupDefs.AnyLocalPupAddress[[0,0]]; netAddress _ [net: pa.net, host: pa.host]; }; DefaultRegistry: PUBLIC PROC RETURNS [registry: ROPE] = { name: ROPE=CurrentRName[]; dot: INT=Rope.SkipTo[name, 0, "."]; IF dot=name.Length[] THEN ERROR; RETURN[name.Substr[dot]]; }; InstanceFromNetAddress: PUBLIC PROC[netAddress: Names.NetAddress, suffix: ROPE_NIL] RETURNS [instance: ROPE] = { pa: PupDefs.PupAddress = [ net: [netAddress.net], host: [netAddress.host], socket: [a: 0, b: 0]]; instance _ Rope.Cat[Convert.RopeFromInt[pa.net, 8, FALSE], "#", Convert.RopeFromInt[pa.host, 8, FALSE], "#", suffix]; }; LowerCaseRope: PROC[r: ROPE] RETURNS [ROPE] = { RETURN[Rope.MakeRope[base: r, size: r.Size[], fetch: LCFetch]]}; LCFetch: SAFE PROC[data: REF, index: INT] RETURNS [c: CHAR] = TRUSTED { SELECT (c_NARROW[data,ROPE].Fetch[index]) FROM IN ['A..'Z]=>c_c+('a-'A); ENDCASE}; RnameToRspec: PUBLIC PROC[name: Names.Rname, defaultRegistry: ROPE_NIL] RETURNS [spec: Names.Rspec] ={ j: INT_0; i: INT; WHILE (i_Rope.SkipTo[s: name, pos: j, skip: "."])#Rope.Size[name] DO j_i+1; ENDLOOP; IF j#0 THEN defaultRegistry_Rope.Substr[base: name, start: j] ELSE j_i+1; IF Rope.Size[defaultRegistry]=0 THEN RETURN[NIL]; spec_NEW[Names.RspecBody_[simpleName: Rope.Substr[name, 0, j-1], registry: defaultRegistry]]; }; RspecToName: PUBLIC PROC[spec: Names.Rspec] RETURNS [name: Names.Rname] = { RETURN[Rope.Concat[spec.simpleName, Rope.Concat[".", spec.registry]]]; }; RspecToSortName: PUBLIC PROC[spec: Names.Rspec] RETURNS [name: ROPE] ={ RETURN[Rope.Concat[spec.registry, Rope.Concat[".", spec.simpleName]]]; }; MakeAtom: PUBLIC PROC[rName: Names.Rname, case: BOOL_FALSE] RETURNS [ATOM] = { RETURN[Atom.MakeAtom[ IF ~case THEN LowerCaseRope[rName] ELSE rName]]; }; GMTComp: PUBLIC PROC[t1, t2: BasicTime.GMT] RETURNS [c: Basics.Comparison] = { period: INT = BasicTime.Period[t2, t1]; RETURN[IF period>0 THEN greater ELSE IF period=0 THEN equal ELSE less]; }; }. ͺNamesImpl.Mesa Last modified by Swinehart, July 19, 1984 10:39:36 am PDT Last modified by Stewart, August 29, 1983 8:44 pm Obligatory concrete Conversion routines case: if FALSE, case considered not important . . . all calls that expect results to match must use FALSE, since implementation is to convert rName to lower case. if TRUE, leave rope alone and make the ATOM as is. "Leftover" Procedures exported to Names Κ˜Jšœ™Jšœ9™9Jšœ1™1J˜šΟk ˜ Jšœœ˜Jšœœ˜Jšœ œœ ˜ Jšœœ˜J˜šœœ˜J˜!—Jšœœ)œ˜PJšœœ˜%Jšœœ˜J˜J˜—šœ  ˜š˜Jšœ#œ˜=—Jšœ ˜—Jšœœœ˜Jšœ œ˜ Jšœœ˜(Jšœœ ˜J˜Jšœ™Jšœ œœœ˜9J˜šΟn œœ œ˜Jšœœœ˜Jšœ œœ˜Jšœ œœ˜Jšœ œœ˜,Jšœ œ˜šœœ˜Jš œœœœœ ˜0J˜Jšœ+˜+—Jš œ œ œœœ ˜DJ˜šœ œ˜(J˜&J˜8J˜—šœ œœ˜J˜šœ œ˜(J˜&J˜9J˜—Jš œœ œœœ˜!—Jšœ"˜&J˜.J˜—š ž œœœœœœ˜6Jšœœ˜ Jš œœœœœ˜J˜Jšœœ+˜DJšœ ˜J˜—š ž œœœœœ˜,Jšœ ˜&J˜—š žœœœœœœ˜OJšœœœ-˜EJšœœ˜%J˜—š ž œœœœ"œ˜MJ˜J˜'J˜-J˜—š žœœœœ œ˜9Jšœœ˜Jšœœ˜#Jšœœœ˜ Jšœ˜J˜—š žœœœ'œœ˜SJšœ œ˜J˜bšœ3œ˜@Jšœ œ˜5—J˜J˜—™J˜š ž œœœœœ˜/Jšœ:˜@—šžœœœœ œœœœ˜GJš œœœœœœ˜R——™š ž œœœ%œœœ˜fIintšœœ˜ Kšœœ˜Kšœ=œœ˜TJšœœ3œ˜IJšœœœœ˜1šœœ8˜@J˜——šž œœœœ˜KJšœC˜I—š žœœœœœ˜GJšœC˜I—J˜šžœœœœœœœ˜Nšœ œVœ9™’Jšœœ œ™2—šœ˜Jšœœœ ˜3———™'J™š žœœœœœ˜OJšœ'˜'Jšœœ œ œœ œœ˜GJ˜J˜——J˜J˜—…—Ύψ