SunPMapClientStub.mesa
Copyright Ó 1989, 1991, 1992 by Xerox Corporation. All rights reserved.
Demers, January 5, 1988 5:43:49 pm PST
Willie-Sue, March 16, 1989 6:55:57 pm PST
Chauser, January 3, 1992 10:58 am PST
DIRECTORY
ArpaUDP USING [Address],
SunPMap USING [callit, dump, DumpProc, getPort, GetPortProc, MapEntry, null, NullProc, program, programVersion, set, SetProc, unset, UnsetProc],
SunPMapClient USING [ProcessResultProc],
SunRPC USING [Error, GetCard32, GetRefText, Handle, PutCard32, PutRefText, ReceiveAnotherReply, ReleaseReply, SendCallAndReceiveReply, StartCall],
SunRPCOnUDP USING [GetReplyAddress],
SunRPCAuth USING [Conversation]
;
SunPMapClientStub: CEDAR PROGRAM
IMPORTS SunRPC, SunRPCOnUDP
EXPORTS SunPMapClient
~ {
Types
Address: TYPE ~ ArpaUDP.Address;
Handle: TYPE ~ SunRPC.Handle;
Conversation: TYPE ~ SunRPCAuth.Conversation;
MapEntry: TYPE ~ SunPMap.MapEntry;
ProcessResultProc: TYPE ~ SunPMapClient.ProcessResultProc;
Parameters
fastTimeout: CARD ¬ 500;
mediumTimeout: CARD ¬ 1000;
defaultRetries: CARD ¬ 10;
noRetries: CARD ¬ 0;
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];
SunRPC.SendCallAndReceiveReply[h, timeout, defaultRetries];
[remoteAddress~address] ¬ SunRPCOnUDP.GetReplyAddress[h];
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;
SunRPC.ReceiveAnotherReply[h, timeout];
[remoteAddress~address] ¬ SunRPCOnUDP.GetReplyAddress[h];
ENDLOOP;
};
}...