Procedures
Null:
PUBLIC SunPMap.NullProc
-- [h: Handle, c: Conversation] -- ~ {
SunRPC.StartCall[h, c, SunPMap.program, SunPMap.programVersion, SunPMap.null];
[] ← SunRPC.SendCallAndReceiveReply[h, fastTimeout, defaultRetries];
SunRPC.ReleaseReply[h];
};
Set:
PUBLIC SunPMap.SetProc
-- [h: Handle, c: Conversation, program, version, protocol, port: CARD32] RETURNS [success: BOOL] -- ~ {
SunRPC.StartCall[h, c, SunPMap.program, SunPMap.programVersion, SunPMap.set];
SunRPC.PutCard32[h, program];
SunRPC.PutCard32[h, version];
SunRPC.PutCard32[h, protocol];
SunRPC.PutCard32[h, port];
[] ← SunRPC.SendCallAndReceiveReply[h, mediumTimeout, defaultRetries];
success ← (SunRPC.GetCard32[h] # 0);
SunRPC.ReleaseReply[h];
};
Unset:
PUBLIC SunPMap.UnsetProc
-- [h: Handle, c: Conversation, program, version: CARD32] RETURNS [success: BOOL] -- ~ {
SunRPC.StartCall[h, c, SunPMap.program, SunPMap.programVersion, SunPMap.unset];
SunRPC.PutCard32[h, program];
SunRPC.PutCard32[h, version];
SunRPC.PutCard32[h, 0]; -- dummy1
SunRPC.PutCard32[h, 0]; -- dummy2
[] ← SunRPC.SendCallAndReceiveReply[h, mediumTimeout, defaultRetries];
success ← (SunRPC.GetCard32[h] # 0);
SunRPC.ReleaseReply[h];
};
GetPort:
PUBLIC SunPMap.GetPortProc
-- [h: Handle, c: Conversation, program, version, protocol: CARD32] RETURNS [port: CARD32] -- ~ {
SunRPC.StartCall[h, c, SunPMap.program, SunPMap.programVersion, SunPMap.getPort];
SunRPC.PutCard32[h, program];
SunRPC.PutCard32[h, version];
SunRPC.PutCard32[h, protocol];
SunRPC.PutCard32[h, 0]; -- dummy
[] ← SunRPC.SendCallAndReceiveReply[h, fastTimeout, defaultRetries];
port ← SunRPC.GetCard32[h];
SunRPC.ReleaseReply[h];
};
Dump:
PUBLIC SunPMap.DumpProc
-- [h: Handle, c: Conversation, eachMapEntry: PROC[MapEntry]] -- ~ {
SunRPC.StartCall[h, c, SunPMap.program, SunPMap.programVersion, SunPMap.dump];
[] ← SunRPC.SendCallAndReceiveReply[h, mediumTimeout, defaultRetries];
DO
newEntry: MapEntry;
more: CARD;
IF (more ← SunRPC.GetCard32[h]) = 0 THEN EXIT;
newEntry.program ← SunRPC.GetCard32[h];
newEntry.version ← SunRPC.GetCard32[h];
newEntry.protocol ← SunRPC.GetCard32[h];
newEntry.port ← SunRPC.GetCard32[h];
eachMapEntry[newEntry];
ENDLOOP;
SunRPC.ReleaseReply[h];
};
Callit:
PUBLIC
PROC [
h: Handle, c: Conversation,
program, version, proc:
CARD32,
args:
REF
TEXT,
timeout:
CARD32]
RETURNS [port: CARD32, result: REF TEXT]
~ {
SunRPC.StartCall[h, c, SunPMap.program, SunPMap.programVersion, SunPMap.callit];
SunRPC.PutCard32[h, program];
SunRPC.PutCard32[h, version];
SunRPC.PutCard32[h, proc];
SunRPC.PutRefText[h, args];
[] ← SunRPC.SendCallAndReceiveReply[h, timeout, noRetries];
port ← SunRPC.GetCard32[h];
result ← SunRPC.GetRefText[h];
SunRPC.ReleaseReply[h];
};
CallWithMultipleReplies:
PUBLIC
PROC [
h: Handle, c: Conversation,
program, version, proc:
CARD32,
args:
REF
TEXT,
processResult: ProcessResultProc,
timeout:
CARD32]
~ {
ENABLE SunRPC.Error => {
SELECT code
FROM
$timeout => CONTINUE;
ENDCASE => REJECT;
};
address: Address;
SunRPC.StartCall[h, c, SunPMap.program, SunPMap.programVersion, SunPMap.callit];
SunRPC.PutCard32[h, program];
SunRPC.PutCard32[h, version];
SunRPC.PutCard32[h, proc];
SunRPC.PutRefText[h, args];
[remoteAddress~address] ← SunRPC.SendCallAndReceiveReply[h, timeout, defaultRetries];
DO
port: CARD32;
result: REF TEXT;
port ← SunRPC.GetCard32[h];
result ← SunRPC.GetRefText[h];
SunRPC.ReleaseReply[h];
IF processResult[address, port, result].quit THEN EXIT;
[remoteAddress~address] ← SunRPC.ReceiveAnotherReply[h, timeout];
ENDLOOP;
};
}...