XNSCHHacks.mesa
Demers, February 4, 1987 4:00:38 pm PST
DIRECTORY
CHEntriesP0V0 USING [members],
Convert USING [XNSHostFromRope, XNSNetFromRope],
Rope USING [ROPE],
XNS USING [Address, Host, Net],
XNSCH USING [Conversation, Error, InitiateConversation, ListMembers, LookupAddress, Name, TerminateConversation],
XNSCHName USING [NameFromRope];
XNSCHHacks: CEDAR MONITOR
IMPORTS Convert, XNSCH, XNSCHName
~ {
ROPE: TYPE ~ Rope.ROPE;
Name: TYPE ~ XNSCH.Name;
NameList: TYPE ~ LIST OF Name;
Pair: TYPE ~ RECORD [name: Name, address: XNS.Address];
PairList: TYPE ~ LIST OF Pair;
FilterProc: TYPE ~ PROC [pair: Pair] RETURNS [yes: BOOL];
glueGroupName: ROPE ← "CHServers:CHServers:CHServers";
EnumerateGroup: PROC [groupName: ROPENIL]
RETURNS [n: NAT ← 0, nameList: NameList] ~ {
c: XNSCH.Conversation;
EachMember: PROC [it: XNSCH.Name] ~ {
n ← n.SUCC;
nameList ← CONS[it, nameList] };
c ← XNSCH.InitiateConversation[];
IF groupName = NIL THEN groupName ← glueGroupName;
[] ← XNSCH.ListMembers[c~c, pattern~XNSCHName.NameFromRope[groupName], pID~CHEntriesP0V0.members, eachMember~EachMember];
XNSCH.TerminateConversation[c];
};
PairsFromNameList: PROC [nameList: NameList] RETURNS [n: NAT ← 0, pairList: PairList] ~ {
c: XNSCH.Conversation;
c ← XNSCH.InitiateConversation[];
FOR list: NameList ← nameList, list.rest WHILE list # NIL DO
pair: Pair;
[pair.name, pair.address] ← XNSCH.LookupAddress[c~c, pattern~list.first
! XNSCH.Error => { --pair ← [list.first, XNS.unknownAddress];-- LOOP } ];
n ← n.SUCC;
pairList ← CONS[pair, pairList];
ENDLOOP;
XNSCH.TerminateConversation[c];
};
FilterPairList: PROC [pairList: PairList, iWantIt: FilterProc]
RETURNS [n: NAT ← 0, filteredPairList: PairList] ~ {
c: XNSCH.Conversation;
c ← XNSCH.InitiateConversation[];
FOR list: PairList ← pairList, list.rest WHILE list # NIL DO
IF NOT iWantIt[list.first] THEN LOOP;
n ← n.SUCC;
filteredPairList ← CONS[list.first, filteredPairList];
ENDLOOP;
XNSCH.TerminateConversation[c];
};
FilterPairListByNet: PROC [pairList: PairList, theDesiredNet: ROPE]
RETURNS [n: NAT ← 0, filteredPairList: PairList] ~ {
net: XNS.Net;
FilterByNet: FilterProc ~ { yes ← pair.address.net = net };
net ← Convert.XNSNetFromRope[theDesiredNet];
[n, filteredPairList] ← FilterPairList[pairList, FilterByNet];
};
FilterPairListByHost: PROC [pairList: PairList, theDesiredHost: ROPE]
RETURNS [n: NAT ← 0, filteredPairList: PairList] ~ {
host: XNS.Host;
FilterByHost: FilterProc ~ { yes ← pair.address.host = host };
host ← Convert.XNSHostFromRope[theDesiredHost];
[n, filteredPairList] ← FilterPairList[pairList, FilterByHost];
};
globalElementList: NameList ← NIL;
DefaultElementStreamProc: PROC [n: Name] ~ {
globalElementList ← CONS[n, globalElementList] };
globalNameList: NameList ← NIL;
DefaultNameStreamProc: PROC [n: Name] ~ {
globalNameList ← CONS[n, globalNameList] };
}.