CasabaPlatformImpl.Mesa
Copyright Ó 1988 by Xerox Corporation. All rights reserved.
Bill Jackson (bj) October 20, 1988 11:10:10 am PDT
DIRECTORY
BasicTime USING [ GMT, Now ],
Commander USING [ Register ],
CommandTool USING [ ArgumentVector, Parse ],
IO USING [ card, PutFR, rope, STREAM, time ],
Loader USING [ BCDBuildTime ],
Rope USING [ ROPE ],
SystemNames USING [ UserName ],
UserCredentials USING [ Get ],
UXIO USING [ CreateFileStream ],
CasabaPlatform;
CasabaPlatformImpl:
CEDAR
MONITOR
IMPORTS BasicTime, Commander, CommandTool, IO, SystemNames, UXIO
EXPORTS CasabaPlatform ~ {
OPEN CasabaPlatform;
ROPE: TYPE ~ Rope.ROPE;
Commander
Register:
PUBLIC
PROC [ key: Rope.
ROPE, proc: CommandProc ←
NIL, doc: Rope.
ROPE ←
NIL,
clientData:
REF ←
NIL, interpreted:
BOOL ←
TRUE ] ~ {
Commander.Register[key, proc, doc, clientData, interpreted];
};
GetArgument:
PUBLIC
PROC [ cmd: Handle, index:
NAT ]
RETURNS [ arg: Rope.
ROPE ←
NIL ] ~ {
args: CommandTool.ArgumentVector ~ CommandTool.Parse[cmd];
arg ← args[index];
};
FS
Error: PUBLIC ERROR [ code: ATOM, explanation: Rope.ROPE ] ~ CODE;
StreamOpen:
PUBLIC
PROC [ fileName: Rope.
ROPE, accessOptions: AccessOptions ← $read ]
RETURNS [ s:
IO.
STREAM ←
NIL ] ~ {
SELECT accessOptions
FROM
read => { s ← UXIO.CreateFileStream[fileName, read] };
append => { s ← UXIO.CreateFileStream[fileName, append] };
write => { s ← UXIO.CreateFileStream[fileName, write] };
create => { s ← UXIO.CreateFileStream[fileName, write] };
ENDCASE => { ERROR };
};
Version Utilities
ToolVersion:
PUBLIC
PROC [ name: Rope.
ROPE, version: Version,
p:
PROC
ANY
RETURNS
ANY ]
RETURNS [ v: Rope.
ROPE ←
NIL ] ~ {
date: BasicTime.GMT ~ BasicTime.Now[]; -- eventually: Loader.BCDBuildTime[p];
patch: Rope.ROPE ~ IF ( version.patch # 0 )
THEN IO.PutFR[".%g", IO.card[version.patch] ] ELSE NIL;
v ← IO.PutFR["%g [%g.%g%g] of %g", IO.rope[name], IO.card[version.major], IO.card[version.minor], IO.rope[patch], IO.time[date] ];
};
BuildTime:
PUBLIC
PROC [ p:
PROC
ANY
RETURNS
ANY ]
RETURNS [ date: BasicTime.
GMT ] ~ {
date ← BasicTime.Now[]; -- eventually: Loader.BCDBuildTime[p];
};
UserName:
PUBLIC
PROC
RETURNS [ user: Rope.
ROPE ←
NIL ] ~ {
somebody: Rope.
ROPE ~ "somebody";
eventually: UserCredentials.Get[].name; or SystemNames.UserName[]
user ← SystemNames.UserName[];
};
}.