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, June 13, 1984 5:12:13 pm PDT Last modified by Stewart, August 29, 1983 8:44 pm Obligatory concrete Conversion routines "Leftover" Procedures exported to Names Êp˜Jšœ™Jšœ8™8Jšœ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šœ˜Jšœœœ ˜2———™'J™š žœœœœœ˜OJšœ'˜'Jšœœ œ œœ œœ˜GJ˜J˜——J˜J˜—…—¼þ