Finger.mesa
Last Edited by: Khall, August 17, 1984 11:21:52 am PDT
Last edited by: Donahue, October 11, 1984 2:19:55 pm PDT
DIRECTORY
BasicTime USING [GMT, nullGMT],
Commander USING [CommandProc, Handle, Register],
Convert USING [RopeFromCard, RopeFromTime],
FingerOps,
IO USING [BreakProc, EndOfStream, GetTokenRope, NUL, PutRope, RIS, SP, STREAM],
Rope USING [Cat, Length, ROPE];
Finger: CEDAR MONITOR
IMPORTS
Commander, Convert, FingerOps, IO, Rope =
BEGIN
fingerErrorCode: FingerOps.Reason;
PerformFingerAtExec: ENTRY Commander.CommandProc =
BEGIN
ENABLE
BEGIN
IO.EndOfStream => CONTINUE;
FingerOps.FingerError => {
fingerErrorCode ← reason; GOTO FingerProblem };
END;
Break: IO.BreakProc =
BEGIN
RETURN[IF char IN [IO.NUL..IO.SP] THEN sepr ELSE other]
END;
stream: IO.STREAMIO.RIS[cmd.commandLine];
actualName, plan, pictureFile: Rope.ROPE;
time: BasicTime.GMT;
operation: FingerOps.LoginLogout;
user: Rope.ROPE;
WHILE TRUE DO -- stop when command line is exhausted and IO.EndOfStream is raised
userNamePattern: Rope.ROPEIO.GetTokenRope[stream, Break].token;
fingerResult: FingerOps.FingerList ← FingerOps.GetMatchingObjects[pattern: userNamePattern];
matches: CARDINAL ← 0;
FOR list: FingerOps.FingerList ← fingerResult, list.rest WHILE list # NIL DO
matches ← matches + 1
ENDLOOP;
SELECT matches FROM
0 => IO.PutRope[cmd.out, Rope.Cat["\nThere were no matches on the username pattern \"", userNamePattern, "\".\n"]];
1 => IO.PutRope[cmd.out, Rope.Cat["\nThere was 1 match on the username pattern \"", userNamePattern, "\":\n"]];
ENDCASE => IO.PutRope[cmd.out, Rope.Cat["\nThere were ", Convert.RopeFromCard[matches], " matches on the username pattern \"", userNamePattern, "\":\n"]];
UNTIL fingerResult = NIL DO
nextObject: FingerOps.FingerObject = fingerResult.first;
[actualName, plan, pictureFile] ← FingerOps.GetProps[nextObject];
output results
IO.PutRope[cmd.out, Rope.Cat["\t\"", nextObject.name, "\""]];
IF Rope.Length[actualName] > 0 THEN IO.PutRope[cmd.out, Rope.Cat[" (", actualName, ")"]];
IO.PutRope[cmd.out, Rope.Cat[" is a ", IF nextObject.type = person THEN "Person" ELSE "Machine"]];
IF nextObject.type = person THEN {
machineList: LIST OF Rope.ROPE;
[machineList, time] ← FingerOps.GetUserData[nextObject.name];
IF time # BasicTime.nullGMT THEN
IO.PutRope[cmd.out, Rope.Cat["\n Last read mail at ", Convert.RopeFromTime[time]]];
FOR mList: LIST OF Rope.ROPE ← machineList, mList.rest UNTIL mList = NIL DO
[lastOp ~ operation, time ~ time] ← FingerOps.GetMachineData[mList.first];
IO.PutRope[cmd.out, Rope.Cat["\n ", IF operation = login THEN "Logged in to " ELSE "Logged out from ", mList.first, " at ", Convert.RopeFromTime[time]]]
ENDLOOP
}
ELSE {
[lastOp ~ operation, time ~ time, user ~ user] ← FingerOps.GetMachineData[nextObject.name];
IO.PutRope[cmd.out, Rope.Cat["\n ", user, IF operation = login THEN " Logged in to " ELSE " Logged out from ", nextObject.name, " at ", Convert.RopeFromTime[time]]]
};
IF Rope.Length[plan] > 0 THEN IO.PutRope[cmd.out, Rope.Cat["\nPlan: ", plan]];
IO.PutRope[cmd.out, "\n"];
fingerResult ← fingerResult.rest;
ENDLOOP;
IO.PutRope[cmd.out, "\n"];
ENDLOOP;
EXITS FingerProblem => {
IO.PutRope[cmd.out,
SELECT fingerErrorCode FROM
Aborted => "\n... Transaction Aborted; Retry Finger Operation",
Error => "\n... Internal Finger Error; Contact Implementor",
Failure => "\n... Connection with server broken; try again later",
ENDCASE => NIL ] };
END;
Register commands with the Exec to perform finger and create an instance of the Finger Tool.
Commander.Register[key: "Finger", proc: PerformFingerAtExec, doc: "Perform a finger." ];
END.