RPCImpl.mesa
Stub for use by Finch.
Copyright Ó 1990, 1992 by Xerox Corporation. All rights reserved.
Swinehart, January 11, 1987 6:01:33 pm PST
Polle Zellweger (PTZ) August 1, 1990 7:48:50 pm PDT
DIRECTORY
Basics USING [BITXOR, BITSHIFT],
RefTab USING [ Create, Delete, Ref, Store ],
Rope USING [Fetch, Length, ROPE],
RPC
;
RPCImpl: CEDAR MONITOR
IMPORTS Basics, RefTab, Rope
EXPORTS RPC
= BEGIN
bpw: INT = 2; -- bytes per word on Dorado
MakeKey: PUBLIC PROCEDURE [text: Rope.ROPE] RETURNS [RPC.EncryptionKey] = CHECKED {
RETURN[GVBasics.MakeKey[text]] -- definition expanded below:
key: RPC.EncryptionKey;
key ¬ ALL[0];
FOR i: CARD16 IN CARD16[0..Rope.Length[text]) DO
j: [0..LENGTH[key]) = (i/bpw) MOD LENGTH[key];
c: WORD = LOOPHOLE[ IF Rope.Fetch[text, i] IN ['A..'Z]
THEN Rope.Fetch[text, i] - 'A + 'a
ELSE Rope.Fetch[text, i] ];
key[j] ¬ Basics.BITXOR[key[j], Basics.BITSHIFT[c, IF (i MOD 2) = 0 THEN 9 ELSE 1]];
ENDLOOP;
RETURN[key];
};
convTable: RefTab.Ref ¬ RefTab.Create[];
n: INT ¬ 0;
GenerateConversation: PUBLIC ENTRY PROC RETURNS [RPC.Conversation] ~ {
conv: REF INT ¬ NEW[INT ¬ n];
n ¬ n+1;
[] ¬ RefTab.Store[x: convTable, key: conv, val: $OK ];
RETURN[conv];
};
EndConversation: PUBLIC ENTRY PROC [conversation: RPC.Conversation] ~ {
[] ¬ RefTab.Delete[x: convTable, key: conversation];
};
END.