VoiceUtils.mesa
Copyright Ó 1985, 1987 by Xerox Corporation. All rights reserved.
Last modified by D. Swinehart, February 9, 1987 8:53:13 am PST
This interface implements a number of utility routines used by all of the voice system components.
DIRECTORY
Commander USING [ Handle ],
GVBasics USING [ Password ],
IO USING [ STREAM, Value ],
Rope USING [ ROPE ],
RPC USING [ EncryptionKey ],
Pup USING [ Address, nullAddress ]
;
VoiceUtils: CEDAR DEFINITIONS = {
Variables
PD: TYPE = RECORD [
attended: BOOLEANFALSE,
sysIn: IO.STREAM,
sysOut: IO.STREAM, -- IOs for error and system status reporting
ch: Commander.Handle←NIL,
Control over system death due to excess report logging
reportLimit: NAT�, -- If 200 (say) reports of any kind, or 10 problem reports, are
problemLimit: NAT�, -- issued in any 60 second period, report that (high priority), and
limitInterval: NAT�, -- then inhibit all reports until these limits have not been exceeded
reportingEnabled: BOOLTRUE, -- whether the limits have been reached
Control over mailing of problem reports for various priorities
reportMethods: ARRAY ProblemPriority OF ReportMethod ← ALL[],
maximumMailReportInterval: INT ← 60*15 -- mailed reports no more frequently than 4/hr.
];
pd: REF PD;
Types
ROPE: TYPE=Rope.ROPE;
Rname: TYPE = ROPE;
NetAddress: TYPE = Pup.Address;
nullNetAddress: Pup.Address = Pup.nullAddress;
Status reporting, Error reporting and management
Report finds an appropriate stream and prints a time-stamped version of remark. Clients can register procedures to interpret the WhereToReport atoms and obtain the appropriate stream for a given call, aided by the whereData supplied in the Report call.
Problem is intended for reporting unexpected errors and conditions. It will raise an internal SIGNAL if the system is currently attended (there's an executive command.) In any case, it will Report the remark argument. It will return automatically or if the operator proceeds from the signal, so the caller needs to do what is necessary to recover after calling Problem.
The defaultIfNotFound parameter to the registration procedure indicates whether the message should be ignored (FALSE) or printed (TRUE) when the corresponding stream-finding procedure returns NIL.
WhereToReport: TYPE=ATOM;
WhereProc: TYPE = PROC[fixedWhereData: REF, whereData: REF] RETURNS[s: IO.STREAMNIL];
nullValue: IO.Value = [null[]];
DNFProc: TYPE = PROC[fixedWhereData: REF, whereData: REF] RETURNS[default: BOOL];
RegisterWhereToReport: PROC[
proc: WhereProc←NIL, where: WhereToReport, fixedWhereData: REFNIL, defaultIfNotFound: DNFProc←NIL];
IF defaultIfNotFound=NIL, answer assumed TRUE
FindWhere: PROC[where: WhereToReport, whereData: REF] RETURNS [s: IO.STREAMNIL];
ReportMethod: TYPE = RECORD [
reportByMail: BOOLFALSE,
reportTo: ROPE
];
Report: PROC[remark: ROPE, where: WhereToReport←NIL, whereData: REFNIL];
ReportFR: PROC[remark: ROPE, where: WhereToReport←NIL, whereData: REFNIL,
a1, a2, a3: IO.Value ← nullValue];
ProblemPriority: TYPE = { minimal, low, medium, high, maximum };
Problem: PROC[
remark: ROPENIL, where: WhereToReport←NIL, whereData: REFNIL,
priority: ProblemPriority ← maximum];
ProblemFR: PROC[
remark: ROPENIL, where: WhereToReport←NIL, whereData: REFNIL,
a1, a2: IO.Value ← nullValue, priority: ProblemPriority ← maximum];
Simple RName, password, net address manipulations. These just look at local machine global information or do various kinds of parsing; they don't do any communicating.
Registrize: PROC[name: ROPE] RETURNS [ROPE];
Adds the Default registry to the name if the name doesn't have a registry field.
CurrentRName: PROC RETURNS [ROPE];
Current logged-in name.
CurrentPasskey: PROC[passwordText: ROPENIL] RETURNS [RPC.EncryptionKey];
CurrentPassword: PROC[passwordText: ROPENIL] RETURNS [GVBasics.Password] = INLINE {
RETURN[LOOPHOLE[CurrentPasskey[passwordText]]]; };
Keys made from logged in password. The two types are based on client needs.
OwnNetAddress: PROC RETURNS [netAddress: NetAddress];
NetAddressFromRope: PROC [netAddressRope: ROPE] RETURNS [netAddress: NetAddress];
Rspec: TYPE = REF RspecBody;
RspecBody: TYPE = RECORD [
simpleName: ROPENIL,
registry: ROPENIL];
RNameStyle: TYPE = { rName, nameDotLark, rNameDotLark };
InstanceFromNetAddress: PROC[netAddress: NetAddress, suffix: ROPENIL]
RETURNS [instance: Rname];
Returns instance name, concatenated with suffix.
Suffix could be "0" to complete a text version of a socket ID, or ".lark" to complete an RName.
RnameToRspec: PROC[name: Rname, defaultRegistry: ROPENIL] RETURNS [spec: Rspec];
Takes the fields of an Rname apart.
RspecToRname: PROC[spec: Rspec] RETURNS [name: Rname];
Puts one back together.
RspecToSortName: PROC[spec: Rspec] RETURNS [name: ROPE];
Produces a rope of the form registry.name
MakeAtom: PROC[rName: Rname, case: BOOLFALSE] RETURNS [ATOM];
Produces a case-independent (if case=FALSE) unique atom from the RName
MakeRName: PROC[name: ROPE, style: RNameStyle← rNameDotLark] RETURNS[rName: ROPE];
LowerCaseRope: PROC[r: ROPE] RETURNS [ROPE];
CommandTool parsing aid
CmdOrToken: PROC[cmd: Commander.Handle, key: ROPE, default: ROPENIL]
RETURNS [value: ROPE];
}.
Swinehart, July 19, 1985 2:34:21 pm PDT
Clean up, eliminate SLOG stuff (Break Tool, Spy, Celtics dominate), DIRECTORY, Log
Swinehart, October 24, 1985 3:48:07 pm PDT
This was always Log until now.
Eliminate CLog stuff, GetBinding stuff, combine with Names (also pruned severely), CurrentPasskey, ROPE, NetAddress, Rname
Swinehart, October 28, 1985 10:02:53 am PST
Eliminate ProblemBool, ProblemHandle
changes to: WhereToReport, ProblemFR
Swinehart, February 8, 1987 9:22:33 am PST
Add Problem, ProblemFR priorities -- determines how hard to work in order to report them.
changes to: ProblemPriority, Problem, ProblemFR, PD, ReportMethod, Report, DIRECTORY