VoiceUtils.mesa
Copyright Ó 1985, 1987, 1992 by Xerox Corporation. All rights reserved.
Last modified by D. Swinehart, August 10, 1992 9:36 am PDT
This interface implements a number of utility routines used by all of the voice system components.
DIRECTORY
Arpa USING [ Address ],
ArpaUDP USING [ Port ],
Commander USING [ Handle ],
IO USING [ STREAM, Value ],
Rope USING [ ROPE ],
RPC USING [ EncryptionKey, Password, NetAddress, PupSocket, nullSocket, nullNetAddress ]
;
VoiceUtils: CEDAR DEFINITIONS = {
Variables
PD: TYPE = RECORD [
attended: BOOLEAN¬FALSE,
defaultReportStream: IO.STREAMNIL,
Control over system death due to excess report logging
reportLimit: NAT¬1000, -- If 200 (say) reports of any kind, or 10 problem reports, are
problemLimit: NAT¬10, -- issued in any 60 second period, report that (high priority), and
limitInterval: NAT¬60, -- then inhibit all reports until these limits have not been exceeded
reportingEnabled: BOOL¬TRUE, -- 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 = RPC.NetAddress;
nullSocket: RPC.PupSocket = RPC.nullSocket;
nullNetAddress: NetAddress = RPC.nullNetAddress;
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.STREAM¬NIL];
nullValue: IO.Value = [null[]];
DNFProc: TYPE = PROC[fixedWhereData: REF, whereData: REF] RETURNS[default: BOOL];
RegisterWhereToReport: PROC[
proc: WhereProc¬NIL, where: WhereToReport, fixedWhereData: REF¬NIL, defaultIfNotFound: DNFProc¬NIL];
IF defaultIfNotFound=NIL, answer assumed TRUE
FindWhere: PROC[where: WhereToReport, whereData: REF] RETURNS [s: IO.STREAM¬NIL];
ReportMethod: TYPE = RECORD [
reportByMail: BOOL¬FALSE,
reportTo: ROPE
];
Report: PROC[remark: ROPE, where: WhereToReport¬NIL, whereData: REF ¬NIL];
ReportFR: PROC[remark: ROPE, where: WhereToReport¬NIL, whereData: REF ¬NIL,
a1, a2, a3: IO.Value ¬ nullValue];
ProblemPriority: TYPE = { minimal, low, medium, high, maximum };
Problem: PROC[
remark: ROPE¬NIL, where: WhereToReport¬NIL, whereData: REF ¬NIL,
priority: ProblemPriority ¬ maximum];
ProblemFR: PROC[
remark: ROPE¬NIL, where: WhereToReport¬NIL, whereData: REF ¬NIL,
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: ROPE¬NIL] RETURNS [RPC.EncryptionKey];
CurrentPassword: PROC[passwordText: ROPE¬NIL] RETURNS [RPC.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];
Rspec: TYPE = REF RspecBody;
RspecBody: TYPE = RECORD [
simpleName: ROPE¬NIL,
registry: ROPE¬NIL];
RNameStyle: TYPE = { rName, nameDotLark, rNameDotLark };
InstanceFromNetAddress: PROC[netAddress: NetAddress, suffix: ROPE¬NIL]
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: ROPE¬NIL] 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: BOOL¬FALSE] 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: ROPE¬NIL]
RETURNS [value: ROPE];
Sun RPC addresses should look like "sun#[1.2.3.4]#5", where [1.2.3.4] is the Arpa address, and 5 is the port.
SunProtocol: PROC [netAddressRope: Rope.ROPE] RETURNS [BOOL];
SunAddrFromRope: PROC [netAddressRope: Rope.ROPE]
RETURNS [address: Arpa.Address, port: ArpaUDP.Port];
RopeFromSunAddr: PROC[address: Rope.ROPE¬NIL, port: CARD32]
RETURNS [netAddressRope: Rope.ROPE];
if address is NIL, will use Arpa address of this machine.
GetUniqueID: PROC RETURNS [CARD32];
Unique within a session. May get reused due to rollback or reboot.
}.
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
Dan Swinehart June 4, 1992 7:51:47 am PDT
Eliminate all direct Pup references, remove unneeded functions to extent possible.
changes to: DIRECTORY, OwnNetAddress
Dan Swinehart June 4, 1992 7:51:47 am PDT
Import VoiceUtilsExtras (Sun stuff)
changes to: DIRECTORY, OwnNetAddress
Dan Swinehart August 10, 1992 9:36:32 am PDT
Modify pd to include only a default output stream; see VoiceUtilsImpl for the underlying change.