DIRECTORY ArchivistBTreePublic USING [OpenBTree, Handle, CloseBTree, EnumerateRecord, FileInfoList], BasicTime USING [GMT, nullGMT, Unpacked, Unpack, Now], Commander USING [CommandProc, Register], CommandTool USING [ArgumentVector, Failed, Parse], FS USING [ComponentPositions, ExpandName, Error], IO USING [PutRope, PutF, PutFR, int, rope], Rope USING [Substr, Equal, Length, Fetch, ROPE] ; ListArchivesImpl: CEDAR PROGRAM IMPORTS ArchivistBTreePublic, BasicTime, Commander, CommandTool, FS, IO, Rope = BEGIN ROPE: TYPE ~ Rope.ROPE; GMT: TYPE ~ BasicTime.GMT; ListArchivesCommandProc: Commander.CommandProc = BEGIN h: ArchivistBTreePublic.Handle _ NIL; BEGIN ProcessList: PROC [list: ArchivistBTreePublic.FileInfoList] = BEGIN cp: FS.ComponentPositions; newDir: ROPE; DO IF list = NIL THEN EXIT; cp _ FS.ExpandName[list.fileName].cp; newDir _ list.fileName.Substr[0, cp.base.start]; IF NOT lastFileDirStuff.Equal[newDir, FALSE] THEN cmd.out.PutF["%g\n", IO.rope[newDir]]; lastFileDirStuff _ newDir; cmd.out.PutF[" %g\t%g %g\n", IO.rope[list.fileName.Substr[cp.base.start]], IO.rope[RFC822Date[list.created]], IO.rope[list.volumes]]; list _ list.next; ENDLOOP; END; pattern, r: ROPE _ NIL; lastFileDirStuff: ROPE _ NIL; list: ArchivistBTreePublic.FileInfoList _ NIL; argv: CommandTool.ArgumentVector _ CommandTool.Parse[cmd: cmd ! CommandTool.Failed => {cmd.out.PutF["%g\n", IO.rope[errorMsg]]; GOTO Failed}]; IF argv.argc <= 1 THEN {cmd.out.PutRope["\n"]; RETURN; }; h _ ArchivistBTreePublic.OpenBTree[cmd.out]; IF h = NIL THEN RETURN; FOR i: NAT IN [1..argv.argc) DO arg: ROPE _ argv[i]; IF Rope.Length[arg] = 0 THEN LOOP; IF Rope.Fetch[arg, 0] = '- THEN { -- Since there are not switches -- LOOP; }; arg _ FS.ExpandName[arg ! FS.Error => GOTO Failed].fullFName; IO.PutRope[cmd.out, "Enumerating ... "]; list _ ArchivistBTreePublic.EnumerateRecord[h, arg]; IO.PutRope[cmd.out, "Done\n"]; ProcessList[list]; ENDLOOP; ArchivistBTreePublic.CloseBTree[h]; EXITS Failed => {ArchivistBTreePublic.CloseBTree[h]; RETURN}; END; END; RFC822Date: PUBLIC PROC[gmt: BasicTime.GMT_ BasicTime.nullGMT] RETURNS[date: ROPE] = -- generates arpa standard time, dd mmm yy hh:mm:ss zzz BEGIN OPEN IO; upt: BasicTime.Unpacked _ BasicTime.Unpack[IF gmt = BasicTime.nullGMT THEN BasicTime.Now[] ELSE gmt]; zone: ROPE; month, tyme, year: ROPE; timeFormat: ROPE = "%02g:%02g:%02g %g"; -- "hh:mm:ss zzz" dateFormat: ROPE = "%2g %g %g %g"; -- "dd mmm yy timeFormat" arpaNeg: BOOL_ upt.zone > 0; aZone: INT_ ABS[upt.zone]; zDif: INT_ aZone / 60; zMul: INT_ zDif * 60; IF (zMul = aZone) AND arpaNeg THEN BEGIN IF upt.dst = yes THEN SELECT zDif FROM 0 => zone_ "UT"; 4 => zone_ "EDT"; 5 => zone_ "CDT"; 6 => zone_ "MDT"; 8 => zone_ "PDT"; ENDCASE ELSE SELECT zDif FROM 0 => zone_ "UT"; 5 => zone_ "EST"; 6 => zone_ "CST"; 7 => zone_ "MST"; 8 => zone_ "PST"; ENDCASE; END; IF zone = NIL THEN BEGIN mm: INT_ aZone - zMul; zone_ PutFR[IF arpaNeg THEN "-%02g%02g" ELSE "+%02g%02g", int[zDif], int[mm]]; END; SELECT upt.month FROM January => month_ "Jan"; February => month_ "Feb"; March => month_ "Mar"; April => month_ "Apr"; May => month_ "May"; June => month_ "Jun"; July => month_ "Jul"; August => month_ "Aug"; September => month_ "Sep"; October => month_ "Oct"; November => month_ "Nov"; December => month_ "Dec"; unspecified => ERROR; ENDCASE => ERROR; year_ Rope.Substr[PutFR[NIL, int[upt.year]], 2]; tyme_ PutFR[timeFormat, int[upt.hour], int[upt.minute], int[upt.second], rope[zone]]; date_ PutFR[dateFormat, int[upt.day], rope[month], rope[year], rope[tyme]]; END; Commander.Register[key: "ListArchives", proc: ListArchivesCommandProc, doc: "ListArchives pattern"]; END...... ’ListArchivesImpl.mesa Copyright (C) 1984, Xerox Corporation. All rights reserved. Tim Diebert: November 7, 1985 5:53:03 pm PST CommandProc: TYPE = PROC [cmd: Handle] RETURNS [result: REF _ NIL, msg: Rope.ROPE _ NIL]; CommandObject = [in, out, err: STREAM, commandLine, command: ROPE, ...] This argument sets switches for the remaining patterns Now the argument is assumed to be a file pattern. Κ[˜™J™J˜Jšœ œ˜Jšœœœ ˜Jšœœ ˜Jšœœ ˜šœœ ˜"šœœ˜š˜šœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jš˜——š˜šœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜———Jšœ˜—J˜šœœ ˜Jšœœ˜Jšœ œ œ œ"˜NJšœ˜—J˜šœ ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœœ˜Jšœœ˜J˜—Jšœœ˜0JšœU˜UJšœK˜KJ˜Jšœ˜—Jšœd˜dJ˜Jšœ˜ ——…—ZG