SunRPCPgmNamesImpl.mesa
Copyright Ó 1990, 1991, 1992 by Xerox Corporation. All rights reserved.
Demers, October 25, 1990 10:35 am PDT
DIRECTORY
Convert,
Rope,
SunRPCPgmNames
;
SunRPCPgmNamesImpl: CEDAR MONITOR
IMPORTS Convert, Rope
EXPORTS SunRPCPgmNames
~ {
Types
ROPE: TYPE ~ Rope.ROPE;
PgmNum: TYPE ~ SunRPCPgmNames.PgmNum;
nullPgmNum: PgmNum ~ SunRPCPgmNames.nullPgmNum;
Error
Error: PUBLIC ERROR [code: ATOM] ~ CODE;
Global Data
PgmNumXlation: TYPE ~ RECORD [
name: ROPE,
pgmNum: PgmNum
];
pgmNumXlations: LIST OF PgmNumXlation ¬ LIST [
["pmap", 100000],
["rstat", 100001],
["rusers", 100002],
["yp", 100003],
["nfs", 100004],
["mount", 100005],
["dbx", 100006],
["ypbind", 100007],
["wall", 100008],
["yppasswd", 100009],
["etherstat", 100010],
["rquota", 100011],
["spray", 100012],
["ibm3270", 100013],
["ibmrje", 100014],
["selnsvc", 100015],
["rdatabase", 100016],
["rexec", 100017],
["alice", 100018],
["sched", 100019],
["lock", 100020],
["netlock", 100021],
["x25", 100022],
["statmon1", 100023],
["statmon2", 100024],
["selnlib", 100025],
["bootparam", 100026],
["maze", 100027],
["ypupdate", 100028],
["keyserve", 100029],
["securecmd", 100030],
["netfwdi", 100031],
["netfwdt", 100032],
["sunlinkmap", 100033],
["netmon", 100034],
["dbase", 100035],
["pwdauth", 100036],
["tfs", 100037],
["nseprog", 100038],
["nseactivate", 100039],
["localregistry", 390920]
];
Query Operations
NameFromPgm: PUBLIC ENTRY PROC [pgm: PgmNum] RETURNS [name: ROPE] ~ {
ENABLE UNWIND => NULL;
IF pgm = nullPgmNum THEN RETURN [NIL];
FOR each: LIST OF PgmNumXlation ¬ pgmNumXlations, each.rest WHILE each # NIL DO
IF pgm = each.first.pgmNum THEN RETURN [each.first.name];
ENDLOOP;
RETURN [Convert.RopeFromCard[pgm]];
};
PgmFromName: PUBLIC ENTRY PROC [name: ROPE, case: BOOL]
RETURNS [pgm: PgmNum] ~ {
ENABLE UNWIND => NULL;
IF Rope.IsEmpty[name] THEN ERROR Error[$badName];
{
ENABLE Convert.Error => CONTINUE;
p: CARD ¬ Convert.CardFromRope[name];
RETURN[p];
};
FOR each: LIST OF PgmNumXlation ¬ pgmNumXlations, each.rest WHILE each # NIL DO
IF Rope.Equal[name, each.first.name, case] THEN RETURN [each.first.pgmNum];
ENDLOOP;
ERROR Error[$badName];
};
Updating
Def: PUBLIC ENTRY PROC [name: ROPE, pgm: PgmNum] ~ {
ENABLE UNWIND => NULL;
IF pgm = nullPgmNum THEN ERROR Error[$badPgmNum];
pgmNumXlations ¬ CONS[ [name~name, pgmNum~pgm], pgmNumXlations ];
};
Undef: PUBLIC ENTRY PROC [name: ROPE ¬ NIL, case: BOOL ¬ FALSE, pgm: PgmNum ¬ nullPgmNum] ~ {
ENABLE UNWIND => NULL;
nameWildCard: BOOL ~ Rope.IsEmpty[name];
pgmWildCard: BOOL ~ (pgm = nullPgmNum);
prev: LIST OF PgmNumXlation ¬ NIL;
FOR each: LIST OF PgmNumXlation ¬ pgmNumXlations, each.rest WHILE each # NIL DO
IF (nameWildCard OR Rope.Equal[name, each.first.name, case])
AND (pgmWildCard OR (pgm = each.first.pgmNum))
THEN -- delete -- {
IF prev = NIL THEN pgmNumXlations ¬ each.rest ELSE prev.rest ¬ each.rest;
}
ELSE {
prev ¬ each;
};
ENDLOOP;
};
}.