InbasketP18V2ServerImpl.mesa
Copyright Ó 1991, 1992 by Xerox Corporation. All rights reserved.
Willie-s, December 10, 1991 4:34 pm PST
DIRECTORY
CrRPC,
CHNameP2V0,
AuthenticationP14V2,
MailTransportP17V5,
BulkDataP0V1,
InbasketP18V2;
InbasketP18V2ServerImpl: CEDAR PROGRAM
IMPORTS CrRPC, InbasketP18V2 ~ {
OPEN InbasketP18V2;
GetSizeCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ {
inbasket: CHNameP2V0.ThreePartName;
credentials: AuthenticationP14V2.Credentials;
verifier: AuthenticationP14V2.SeqWords;
sizeInBytes: CARD32;
{
inbasket.organization ¬ CrRPC.GetRope[s];
inbasket.domain ¬ CrRPC.GetRope[s];
inbasket.object ¬ CrRPC.GetRope[s];
};
{
credentials.type ¬ VAL[CrRPC.GetCard16[s]];
credentials.value ¬ UProc28[h, s];
};
{
verifier ¬ UProc28[h, s];
};
[sizeInBytes] ¬ GetSize[h, inbasket, credentials, verifier];
beginReturn[h];
{
CrRPC.PutCard32[s, sizeInBytes];
};
};
LogoffCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ {
session: Session;
{
FOR i29: CARDINAL IN [0..2) DO
session.token[i29] ¬ CrRPC.GetCard16[s];
ENDLOOP;
session.verifier ¬ UProc28[h, s];
};
[] ¬ Logoff[h, session];
beginReturn[h];
};
LogonCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ {
inbasket: CHNameP2V0.ThreePartName;
credentials: AuthenticationP14V2.Credentials;
verifier: AuthenticationP14V2.SeqWords;
session: Session;
state: State;
anchor: Anchor;
{
inbasket.organization ¬ CrRPC.GetRope[s];
inbasket.domain ¬ CrRPC.GetRope[s];
inbasket.object ¬ CrRPC.GetRope[s];
};
{
credentials.type ¬ VAL[CrRPC.GetCard16[s]];
credentials.value ¬ UProc28[h, s];
};
{
verifier ¬ UProc28[h, s];
};
[session, state, anchor] ¬ Logon[h, inbasket, credentials, verifier];
beginReturn[h];
{
FOR i30: CARDINAL IN [0..2) DO
CrRPC.PutCard16[s, session.token[i30]];
ENDLOOP;
MProc31[h, s, session.verifier];
};
{
CrRPC.PutCard16[s, state.new];
CrRPC.PutCard16[s, state.total];
};
{
FOR i32: CARDINAL IN [0..5) DO
CrRPC.PutCard16[s, anchor[i32]];
ENDLOOP;
};
};
DeleteCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ {
range: Range;
session: Session;
{
range.low ¬ CrRPC.GetCard32[s];
range.high ¬ CrRPC.GetCard32[s];
};
{
FOR i33: CARDINAL IN [0..2) DO
session.token[i33] ¬ CrRPC.GetCard16[s];
ENDLOOP;
session.verifier ¬ UProc28[h, s];
};
[] ¬ Delete[h, range, session];
beginReturn[h];
};
ChangeMessageStatusCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ {
range: Range;
changeUserDefinedStatus: BOOLEAN;
newUserDefinedStatus: CARD16;
session: Session;
{
range.low ¬ CrRPC.GetCard32[s];
range.high ¬ CrRPC.GetCard32[s];
};
{
changeUserDefinedStatus ¬ CrRPC.GetBool[s];
};
{
newUserDefinedStatus ¬ CrRPC.GetCard16[s];
};
{
FOR i34: CARDINAL IN [0..2) DO
session.token[i34] ¬ CrRPC.GetCard16[s];
ENDLOOP;
session.verifier ¬ UProc28[h, s];
};
[] ¬ ChangeMessageStatus[h, range, changeUserDefinedStatus, newUserDefinedStatus, session];
beginReturn[h];
};
RetrieveBodyPartsCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ {
message: CARD32;
bodyParts: BodyPartSequence;
contents: CrRPC.BulkDataSink;
session: Session;
{
message ¬ CrRPC.GetCard32[s];
};
{
bodyParts ¬ UProc35[h, s];
};
TRUSTED {
contents ¬ CrRPC.GetBulkDataSink[h, s];
};
{
FOR i36: CARDINAL IN [0..2) DO
session.token[i36] ¬ CrRPC.GetCard16[s];
ENDLOOP;
session.verifier ¬ UProc28[h, s];
};
[] ¬ RetrieveBodyParts[h, message, bodyParts, contents, session];
beginReturn[h];
};
MailPollCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ {
inbasket: CHNameP2V0.ThreePartName;
credentials: AuthenticationP14V2.Credentials;
verifier: AuthenticationP14V2.SeqWords;
state: State;
{
inbasket.organization ¬ CrRPC.GetRope[s];
inbasket.domain ¬ CrRPC.GetRope[s];
inbasket.object ¬ CrRPC.GetRope[s];
};
{
credentials.type ¬ VAL[CrRPC.GetCard16[s]];
credentials.value ¬ UProc28[h, s];
};
{
verifier ¬ UProc28[h, s];
};
[state] ¬ MailPoll[h, inbasket, credentials, verifier];
beginReturn[h];
{
CrRPC.PutCard16[s, state.new];
CrRPC.PutCard16[s, state.total];
};
};
ChangeBodyPartsStatusCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ {
index: CARD32;
setStatusTo: BodyPartStatusChangeSequence;
session: Session;
deleted: BOOLEAN;
{
index ¬ CrRPC.GetCard32[s];
};
{
setStatusTo ¬ UProc37[h, s];
};
{
FOR i38: CARDINAL IN [0..2) DO
session.token[i38] ¬ CrRPC.GetCard16[s];
ENDLOOP;
session.verifier ¬ UProc28[h, s];
};
[deleted] ¬ ChangeBodyPartsStatus[h, index, setStatusTo, session];
beginReturn[h];
{
CrRPC.PutBool[s, deleted];
};
};
RetrieveEnvelopesCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ {
last: CARD32;
whichMsg: WhichOne;
session: Session;
transportEnvelope: MailTransportP17V5.Envelope;
status: Status;
next: CARD32;
{
last ¬ CrRPC.GetCard32[s];
};
{
whichMsg ¬ VAL[CrRPC.GetCard16[s]];
};
{
FOR i39: CARDINAL IN [0..2) DO
session.token[i39] ¬ CrRPC.GetCard16[s];
ENDLOOP;
session.verifier ¬ UProc28[h, s];
};
[transportEnvelope, status, next] ¬ RetrieveEnvelopes[h, last, whichMsg, session];
beginReturn[h];
{
MProc40[h, s, transportEnvelope];
};
{
CrRPC.PutCard16[s, status.messageStatus.userDefinedStatus];
CrRPC.PutCard16[s, ORD[status.messageStatus.existenceOfMessage]];
MProc41[h, s, status.bodyPartsStatus];
};
{
CrRPC.PutCard32[s, next];
};
};
MailCheckCaller: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, beginReturn: CrRPC.BeginReturnProc] ~ {
session: Session;
state: State;
{
FOR i42: CARDINAL IN [0..2) DO
session.token[i42] ¬ CrRPC.GetCard16[s];
ENDLOOP;
session.verifier ¬ UProc28[h, s];
};
[state] ¬ MailCheck[h, session];
beginReturn[h];
{
CrRPC.PutCard16[s, state.new];
CrRPC.PutCard16[s, state.total];
};
};
Server: CrRPC.ServerProc ~ {
ENABLE {
InbasketP18V2.TransferError => { -- (7 )
beginError[h, 7 ];
CrRPC.PutCard16[s, ORD[problem]];
GOTO Finished;
};
InbasketP18V2.IndexError => { -- (9 )
beginError[h, 9 ];
CrRPC.PutCard16[s, ORD[problem]];
GOTO Finished;
};
InbasketP18V2.ServiceError => { -- (6 )
beginError[h, 6 ];
CrRPC.PutCard16[s, ORD[problem]];
GOTO Finished;
};
InbasketP18V2.InbasketInUse => { -- (10 )
beginError[h, 10 ];
CrRPC.PutRope[s, user.organization];
CrRPC.PutRope[s, user.domain];
CrRPC.PutRope[s, user.object];
GOTO Finished;
};
InbasketP18V2.SessionError => { -- (5 )
beginError[h, 5 ];
CrRPC.PutCard16[s, ORD[problem]];
GOTO Finished;
};
InbasketP18V2.OtherError => { -- (8 )
beginError[h, 8 ];
CrRPC.PutCard16[s, ORD[problem]];
GOTO Finished;
};
InbasketP18V2.AuthenticationError => { -- (1 )
beginError[h, 1 ];
CrRPC.PutCard16[s, ORD[problem]];
GOTO Finished;
};
InbasketP18V2.AccessError => { -- (0 )
beginError[h, 0 ];
CrRPC.PutCard16[s, ORD[problem]];
GOTO Finished;
};
};
IF (pgmVersion # 2) THEN {
beginReject[h, CrRPC.noSuchVersion];
CrRPC.PutCard16[s, 2]; --low
CrRPC.PutCard16[s, 2]; --high
RETURN
};
SELECT proc FROM
10 => GetSizeCaller[h, s, beginReturn];
4 => LogoffCaller[h, s, beginReturn];
5 => LogonCaller[h, s, beginReturn];
1 => DeleteCaller[h, s, beginReturn];
0 => ChangeMessageStatusCaller[h, s, beginReturn];
8 => RetrieveBodyPartsCaller[h, s, beginReturn];
7 => MailPollCaller[h, s, beginReturn];
3 => ChangeBodyPartsStatusCaller[h, s, beginReturn];
2 => RetrieveEnvelopesCaller[h, s, beginReturn];
6 => MailCheckCaller[h, s, beginReturn];
ENDCASE => {
beginReject[h, CrRPC.noSuchProcedure];
};
EXITS
Finished => { NULL };
};
MProc31: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: AuthenticationP14V2.SeqWords] ~ {
CrRPC.PutCard16[s, val.length];
FOR i43: CARDINAL IN [0..val.length) DO
CrRPC.PutCard16[s, val.body[i43]];
ENDLOOP;
};
UProc28: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: AuthenticationP14V2.SeqWords] ~ {
{
length45: CARDINAL ~ CrRPC.GetCard16[s];
res ¬ NEW[AuthenticationP14V2.SeqWordsObject[length45]];
FOR i44: CARDINAL IN [0..length45) DO
res.body[i44] ¬ CrRPC.GetCard16[s];
ENDLOOP;
};
};
UProc37: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: BodyPartStatusChangeSequence] ~ {
{
length47: CARDINAL ~ CrRPC.GetCard16[s];
res ¬ NEW[BodyPartStatusChangeSequenceObject[length47]];
FOR i46: CARDINAL IN [0..length47) DO
res.body[i46].bodyPartIndex ¬ CrRPC.GetCard16[s];
res.body[i46].deleteable ¬ VAL[CrRPC.GetCard16[s]];
ENDLOOP;
};
};
MProc41: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: BodyPartsStatus] ~ {
CrRPC.PutCard16[s, val.length];
FOR i48: CARDINAL IN [0..val.length) DO
CrRPC.PutBool[s, val.body[i48]];
ENDLOOP;
};
UProc35: PROC [h: CrRPC.Handle, s: CrRPC.STREAM] RETURNS [res: BodyPartSequence] ~ {
{
length50: CARDINAL ~ CrRPC.GetCard16[s];
res ¬ NEW[BodyPartSequenceObject[length50]];
FOR i49: CARDINAL IN [0..length50) DO
res.body[i49] ¬ CrRPC.GetCard16[s];
ENDLOOP;
};
};
MProc40: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: MailTransportP17V5.Envelope] ~ {
CrRPC.PutCard16[s, val.length];
FOR i51: CARDINAL IN [0..val.length) DO
CrRPC.PutCard32[s, val.body[i51].type];
MProc52[h, s, val.body[i51].value];
ENDLOOP;
};
MProc52: PROC [h: CrRPC.Handle, s: CrRPC.STREAM, val: MailTransportP17V5.Opaque] ~ {
CrRPC.PutCard16[s, val.length];
FOR i53: CARDINAL IN [0..val.length) DO
CrRPC.PutCard16[s, val.body[i53]];
ENDLOOP;
};
CrRPC.RegisterServerProcs[pgm~18, serverProc~Server, pgmLoVersion~2, pgmHiVersion~2];
CrRPC.EnsureListener[class~$SPP];
}...