-- FastDirDefs.mesa edited: Bruce July 8, 1980 8:38 AM -- Copyright Xerox Corporation 1979, 1980 DIRECTORY AltoFileDefs USING [FP], Mopcodes USING [zAND]; FastDirDefs: DEFINITIONS = BEGIN OPEN AltoFileDefs, Mopcodes; UpCase: CARDINAL = 137B; HashVal: TYPE = [0..1000); FileType: TYPE = {source, bcd, config, symbols, code, image}; --extensions: ARRAY FileType OF STRING = ["mesa", "bcd", "config", "symbols", "code", "image"]; FileSwitches: TYPE = PACKED ARRAY FileType OF BOOLEAN; NilFileSwitches: FileSwitches = [FALSE, FALSE, FALSE, FALSE, FALSE, FALSE]; -- ALL [FALSE] later AllFileSwitches: FileSwitches = [TRUE, TRUE, TRUE, TRUE, TRUE, TRUE]; -- ALL [TRUE] later StringItem: TYPE = RECORD [ link: POINTER TO StringItem, hash: HashVal, s: STRING]; ItemHandle: TYPE = POINTER TO Item; Item: TYPE = RECORD [link: POINTER TO Item, hash: WORD, name: STRING, fp: FP]; EnumerateList: PROCEDURE [ ft: FileType, proc: PROCEDURE [ItemHandle] RETURNS [BOOLEAN]] RETURNS [ItemHandle]; EquivalentString: PROCEDURE [s1, s2: STRING] RETURNS [BOOLEAN]; GetExtension: PROCEDURE [ft: FileType] RETURNS [ext: STRING]; LocalDir: PROCEDURE [PROCEDURE [POINTER TO FP, STRING] RETURNS [BOOLEAN]] = LOOPHOLE[3]; LookupItem: PROCEDURE [s: STRING, t: FileType] RETURNS [p: ItemHandle]; ScanDir: PROCEDURE [ files: FileSwitches, proc: PROCEDURE [PROCEDURE [POINTER TO FP, STRING] RETURNS [BOOLEAN]] ← LocalDir]; StripExtension: PROCEDURE [name, ext: STRING]; StripSwitches: PROCEDURE [name, switches: STRING]; Cap: PROCEDURE [c: CHARACTER] RETURNS [CHARACTER] = INLINE BEGIN RETURN[IF c IN ['a..'z] THEN LOOPHOLE[CharMask[c, UpCase]] ELSE c] END; CharMask: PROCEDURE [CHARACTER, CARDINAL] RETURNS [CARDINAL] = MACHINE CODE BEGIN zAND END; Hash: PROCEDURE [s: STRING] RETURNS [HashVal] = INLINE BEGIN RETURN[ (CharMask[s[0], UpCase]*s.length + CharMask[s[s.length/2], UpCase]) MOD (LAST[HashVal] + 1)]; END; END.