MaintainMiscImpl.mesa
Copyright Ó 1987, 1988, 1991, 1992 by Xerox Corporation. All rights reserved.
Wes Irish, February 24, 1988 6:08:56 pm PST
Philip James, July 29, 1991 1:58 pm PDT
Willie-s, January 7, 1992 3:07 pm PST
Doug Wyatt, May 15, 1992 12:23 pm PDT
DIRECTORY
CHEntriesP0V0 USING[ userPassword, members, authKeys, printService ],
Convert USING[ RopeFromCard ],
IO USING[ PutF1, STREAM ],
MaintainDefs USING[ Command, CmdButton, MyData, What ],
MaintainMisc,
Rope USING[ Fetch, Find, FromChar, Length, ROPE, SkipOver, SkipTo, Substr ];
MaintainMiscImpl: CEDAR MONITOR LOCKS d USING d: MyData
IMPORTS Convert, IO, Rope
EXPORTS MaintainMisc =
{
ROPE: TYPE = Rope.ROPE;
STREAM: TYPE = IO.STREAM;
Command: TYPE = MaintainDefs.Command;
What: TYPE = MaintainDefs.What;
CmdButton: TYPE = MaintainDefs.CmdButton;
MyData: TYPE = MaintainDefs.MyData;
all: CARD32 ~ 0;
nullProperty: CARD32 ~ 37777777777B;
RopeFromCommand: PUBLIC PROC [cmd: Command] RETURNS [ROPE] = {
RETURN [SELECT cmd FROM
type => "Type",
isMember => "IsMember",
set => "Set",
add => "Add",
remove => "Remove",
misc => "Misc",
create => "Create",
delete => "Delete",
ENDCASE => "???"
];
};
AtomFromWhat: PUBLIC PROC [what: What] RETURNS [ATOM] = {
RETURN [SELECT what FROM
matches => $Matches,
members => $Members,
summary => $Summary,
details => $Details,
domains => $Domains,
organizations => $Organizations,
finks => $Finks,
direct => $Direct,
extended => $Extended,
occurrences => $Occurrences,
password => $Password,
simple => $SimplePwd,
individualRemark => $IndvRemark,
groupRemark => $GroupRemark,
fileService => $FileServ,
alias => $Alias,
self => $Self,
member => $Member,
owner => $Owner,
friend => $Friend,
mailbox => $Mailbox,
forwarding => $Forwarding,
createIndividual => $CreateIndv,
createGroup => $CreateGroup,
delete => $Delete,
domainsServed => $DomainsServed,
ENDCASE => $QuestionMark
];
};
RopeFromWhat: PUBLIC PROC [what: What] RETURNS [ROPE] = {
RETURN [SELECT what FROM
matches => "Matches",
members => "Members",
summary => "Summary",
details => "Details",
domains => "Domains",
organizations => "Organizations",
finks => "Finks",
direct => "Direct",
extended => "Extended",
occurrences => "Occurrences",
password => "Password",
simple => "Simple Pwd",
individualRemark => "Indv Remark",
groupRemark => "Group Remark",
fileService => "File Serv",
alias => "Alias",
self => "Self",
member => "Member",
owner => "Owner",
friend => "Friend",
mailbox => "Mailbox",
forwarding => "Forwarding",
createIndividual => "Create Indv",
createGroup => "Create Group",
delete => "Delete",
domainsServed => "DomainsServed",
ENDCASE => "???"
];
};
ExposePropertyCode: PUBLIC PROC [prop: CARD32] RETURNS[ROPE] = {
OPEN CHEntriesP0V0;
RETURN[SELECT prop FROM
userPassword => "userPassword",
members => "members",
authKeys => "authKeys",
printService => "printService",
ENDCASE => Convert.RopeFromCard[prop]
];
};
CallForItems: PUBLIC PROC [d: MyData, names: ROPE, proc: PROC [ROPE], evenIfNull: BOOL ¬ FALSE] = {
This PROC parses names and does a call-back on proc for each individual name found. Quotes around an entire name are stripped off and then passed to proc. Quotes around the first part of a GV looking name are left as-is. Names are separated by commas or '\n. On non-quoted names leading and trailing whitespace is stipped off. Quotes must be used to generate names with leading or trailing whitespace. (As ugly as it is some NS names have leading or trailing whitespace!)
StripOffTrailingSpace: PROC [r: ROPE] RETURNS [ROPE] = {
len: INT ¬ Rope.Length[r];
WHILE len > 0 DO
len ¬ len-1;
IF Rope.Find[Rope.FromChar[Rope.Fetch[r, len]], " \t\n"] = -1 THEN EXIT;
r ¬ Rope.Substr[r, 0, len];
ENDLOOP;
RETURN[r];
};
len: INT = Rope.Length[names];
pos: INT ¬ 0;
sepRope, skipRope, thisName: ROPE;
thisOneQuoted: BOOL;
IF Quote[d] THEN { IF len # 0 OR evenIfNull THEN proc[names]; RETURN; };
skipRope ¬ ", \n\t";
sepRope ¬ ",\n";
DO
startPos: INT ¬ Rope.SkipOver[names, pos, skipRope];
IF startPos >= len THEN EXIT;
thisOneQuoted ¬ FALSE;
IF Rope.SkipTo[names, startPos, "\""] = startPos
THEN {
startPos ¬ startPos+1;
thisOneQuoted ¬ TRUE;
pos ¬ Rope.SkipTo[names, startPos, "\""];
IF pos+1 < len AND Rope.Fetch[names, pos+1] = '. THEN {
startPos ¬ startPos - 1;
thisOneQuoted ¬ FALSE;
pos ¬ Rope.SkipTo[names, pos, sepRope];
};
}
ELSE pos ¬ Rope.SkipTo[names, startPos, sepRope];
thisName ¬ Rope.Substr[names, startPos, pos-startPos];
IF thisOneQuoted THEN pos ¬ pos+1;
IF ~thisOneQuoted THEN thisName ¬ StripOffTrailingSpace[thisName];
evenIfNull ¬ FALSE;
proc[thisName];
ENDLOOP;
IF evenIfNull THEN proc[NIL];
};
EnumGroups: PUBLIC PROC [cb: CmdButton] RETURNS [BOOL] = {
SELECT cb.class FROM
group, any => RETURN[TRUE];
individual => RETURN[FALSE];
ENDCASE => RETURN[FALSE];
};
EnumIndividuals: PUBLIC PROC [cb: CmdButton] RETURNS [BOOL] = {
SELECT cb.class FROM
individual, any => RETURN[TRUE];
group => RETURN[FALSE];
ENDCASE => RETURN[FALSE];
};
EnumDead: PUBLIC PROC [cb: CmdButton] RETURNS [BOOL] = {
SELECT cb.class FROM
dead => RETURN[TRUE];
any, group, individual => RETURN[FALSE];
ENDCASE => RETURN[FALSE];
};
Quote: PUBLIC PROC [d: MyData] RETURNS [BOOL] = {
IF d.quote = NIL THEN RETURN[FALSE];
IF d.quote­ = $off THEN RETURN[FALSE];
RETURN[TRUE];
};
verifyOn: ATOM = $on;
Verify: PUBLIC PROC [d: MyData] RETURNS [BOOL] = {
IF d.verify = NIL THEN RETURN[TRUE];
IF d.verify­ = verifyOn THEN RETURN[TRUE];
RETURN[FALSE];
};
Plural: PUBLIC PROC [word, plural: ROPE, n: CARD] RETURNS[ROPE] = {
IF n = 1 THEN RETURN[word]
ELSE RETURN[plural];
};
CheckForm: PUBLIC PROC [clientData: REF, value, label: ROPE] RETURNS[ BOOL ] = {
d: MyData = NARROW[clientData];
IF Rope.Length[value] > 0 AND Rope.Fetch[value, 0] = ' THEN {
IO.PutF1[d.out, "\nPlease fill in the \"%g\" field\n", [rope[label]] ];
RETURN[FALSE] }
ELSE RETURN[TRUE]
};
}.