-- Stub file was translated on December 19, 1983 1:38 pm by Lupine of October 25, 1983 10:51 am -- Source interface LarkSmarts came from file LarkSmarts.bcd, which was created on December 19, 1983 1:37 pm with version stamp 307B#212B#1634254640B from source of December 19, 1983 1:37 pm. -- The RPC stub modules for LarkSmarts are: -- LarkSmartsRpcControl.mesa; -- LarkSmartsRpcClientImpl.mesa; -- LarkSmartsRpcBinderImpl.mesa; -- LarkSmartsRpcServerImpl.mesa. -- The parameters for this translation are: -- Target language = Cedar -- Default parameter passing = VALUE -- Deallocate server heap arguments = TRUE -- Inline RpcServerImpl dispatcher stubs = FALSE -- Declare signals = TRUE -- Warn about short POINTER ("MDS") allocations = TRUE -- Maximum number of dynamic heap NEWs = 50, MDS NEWs = 50 -- Acceptable parameter protocols = VersionRange[1..1]. DIRECTORY BasicTime, Lark, RPC, LarkSmarts, LarkSmartsRpcControl USING [InterMdsCallsOnly, LupineProtocolVersion, ProcedureIndex, SignalIndex], RPCLupine --USING SOME OF [Call, DataLength, Dispatcher, ExportHandle, -- ExportInterface, GetStubPkt, maxDataLength, maxPrincipalLength, -- maxShortStringLength, pktOverhead, ReceiveExtraPkt, SendPrelimPkt, -- StartCall, StartSignal, StubPkt, UnexportInterface]--, LupineRuntime --USING SOME OF [BindingError, CheckPktLength, CopyFromPkt, -- CopyFromMultiplePkts, CopyToPkt, CopyToMultiplePkts, defaultZones, -- DispatchingError, FinishThisPkt, ListHeader, MarshalingError, -- MarshalingExprError, NilHeader, ProtocolError, RopeHeader, RpcPktDoubleWord, -- RuntimeError, SequenceHeader, SHORT, StartNextPkt, StringHeader, -- StubPktDoubleWord, TranslationError, UnmarshalingError, UnmarshalingExprError, -- WordsForChars]--, Atom --USING SOME OF [GetPName, MakeAtom]--, Rope --USING SOME OF [InlineFlatten, Length, NewText, Text]--; LarkSmartsRpcServerImpl: MONITOR IMPORTS LarkSmarts, RpcPrivate: RPCLupine, Lupine: LupineRuntime, Atom, Rope EXPORTS LarkSmartsRpcControl SHARES LarkSmarts, LarkSmartsRpcControl, Rope = BEGIN OPEN LarkSmarts, RpcControl: LarkSmartsRpcControl, RpcPublic: RPC; -- Standard remote binding routines. bound: BOOLEAN ← FALSE; myInterface: RpcPrivate.ExportHandle; paramZones: RpcPublic.Zones ← RpcPublic.standardZones; ExportInterface: PUBLIC ENTRY SAFE PROCEDURE [ interfaceName: RpcPublic.InterfaceName, user: RpcPublic.Principal, password: RpcPublic.EncryptionKey, parameterStorage: RpcPublic.Zones ] = TRUSTED BEGIN ENABLE UNWIND => NULL; IsNull: PROCEDURE [string: Rope.ROPE] RETURNS [BOOLEAN] = INLINE {RETURN[string.Length[] = 0]}; IF bound THEN Lupine.BindingError; myInterface ← RpcPrivate.ExportInterface [ interface: [ type: IF ~IsNull[interfaceName.type] THEN interfaceName.type ELSE "LarkSmarts~307B#212B#1634254640B", instance: interfaceName.instance, version: interfaceName.version ], user: user, password: password, dispatcher: ServerDispatcher, localOnly: RpcControl.InterMdsCallsOnly, stubProtocol: RpcControl.LupineProtocolVersion ]; paramZones ← [ gc: IF parameterStorage.gc # NIL THEN parameterStorage.gc ELSE Lupine.defaultZones.gc, heap: IF parameterStorage.heap # NIL THEN parameterStorage.heap ELSE Lupine.defaultZones.heap, mds: IF parameterStorage.mds # NIL THEN parameterStorage.mds ELSE Lupine.defaultZones.mds ]; bound ← TRUE; END; UnexportInterface: PUBLIC ENTRY SAFE PROCEDURE = TRUSTED BEGIN ENABLE UNWIND => NULL; IF ~bound THEN Lupine.BindingError; myInterface ← RpcPrivate.UnexportInterface[myInterface]; paramZones ← RpcPublic.standardZones; bound ← FALSE; END; -- Public procedure dispatcher and public signal and error catcher. ServerDispatcher: --PROCEDURE [pkt: RPCPkt, callLength: DataLength, -- lastPkt: BOOLEAN, localConversation: Conversation] RETURNS [returnLength: -- DataLength]-- RpcPrivate.Dispatcher = BEGIN -- Catch public signals. ENABLE BEGIN END; -- Catch public signals. -- Call public procedures (still in dispatcher). SELECT LOOPHOLE[pkt.data[0], RpcControl.ProcedureIndex] FROM Register => RETURN[ RegisterStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; RecordEvent => RETURN[ RecordEventStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; EventRope => RETURN[ EventRopeStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; Login => RETURN[ LoginStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; ENDCASE => RETURN[Lupine.DispatchingError[]]; END; -- ServerDispatcher -- Public procedure dispatcher stubs. RegisterStub: --PROCEDURE [shh: SHHH, oldSmartsID: SmartsHandle, -- oldEpoch: Epoch, netAddress: NetAddress, model: Lark.LarkModel, -- authenticated: BOOL, clientInstance: ROPE] -- RETURNS [smartsID: SmartsHandle, epoch: Epoch]-- RpcPrivate.Dispatcher = BEGIN clientInstance: ROPE; ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, oldSmartsID (1): SmartsHandle, oldEpoch (3): Epoch, netAddress (5): NetAddress, model (6): Lark.LarkModel, authenticated (8): BOOL]; ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [ smartsID (0): SmartsHandle, epoch (2): Epoch]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength ← 9; BEGIN -- Unmarshal clientInstance: ROPE from pkt.data[pktLength]. ropeIsNIL: Lupine.NilHeader; ropeIsNIL ← pkt.data[pktLength]; pktLength ← pktLength+1; IF ropeIsNIL THEN clientInstance ← NIL ELSE BEGIN ropeLength: Lupine.RopeHeader; textRope: Rope.Text; ropeLength ← pkt.data[pktLength]; pktLength ← pktLength+1; IF ropeLength > RpcPrivate.maxShortStringLength THEN Lupine.UnmarshalingError; clientInstance ← textRope ← Rope.NewText[size: ropeLength]; pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength, dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[ropeLength], alwaysOnePkt: TRUE]; END; -- IF ropeIsNIL. END; -- Unmarshal clientInstance. Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength]; [resPkt.smartsID, resPkt.epoch] ← Register[localConversation, argPkt.oldSmartsID, argPkt.oldEpoch, argPkt.netAddress, argPkt.model, argPkt.authenticated, clientInstance]; pktLength ← 4; RETURN[returnLength: pktLength]; END; -- RegisterStub. RecordEventStub: --PROCEDURE [shh: SHHH, smartsID: SmartsHandle, -- whatHappened: Lark.StatusEvents] -- RETURNS [success: BOOL]-- RpcPrivate.Dispatcher = BEGIN whatHappened: Lark.StatusEvents; ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, smartsID (1): SmartsHandle]; ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [ success (0): BOOL]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength ← 3; BEGIN -- Unmarshal whatHappened: Lark.StatusEvents from pkt.data[pktLength]. BEGIN -- Unmarshal whatHappened↑: Lark.StatusEventSequence from -- pkt.data[pktLength]. recordIsNIL: Lupine.NilHeader; recordIsNIL ← pkt.data[pktLength]; pktLength ← pktLength+1; IF recordIsNIL THEN whatHappened ← NIL ELSE BEGIN seqLength: Lupine.SequenceHeader; seqLength ← Lupine.RpcPktDoubleWord[pkt, pktLength]↑; pktLength ← pktLength + 2; whatHappened ← (paramZones.gc.NEW[Lark.StatusEventSequence[Lupine.SHORT[seqLength]]]); pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength, dataAdr: LOOPHOLE[whatHappened], dataLength: SIZE[Lark.StatusEventSequence[LENGTH[DESCRIPTOR[whatHappened↑]]]], alwaysOnePkt: TRUE]; END; -- IF recordIsNIL. END; -- Unmarshal whatHappened↑. END; -- Unmarshal whatHappened. Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength]; [resPkt.success] ← RecordEvent[localConversation, argPkt.smartsID, whatHappened]; pktLength ← 1; RETURN[returnLength: pktLength]; END; -- RecordEventStub. EventRopeStub: --PROCEDURE [shh: SHHH, smartsID: SmartsHandle, time: -- CARDINAL, device: Lark.Device, events: ROPE] -- RETURNS [success: BOOL]-- RpcPrivate.Dispatcher = BEGIN events: ROPE; ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, smartsID (1): SmartsHandle, time (3): CARDINAL, device (4): Lark.Device]; ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [ success (0): BOOL]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength ← 5; BEGIN -- Unmarshal events: ROPE from pkt.data[pktLength]. ropeIsNIL: Lupine.NilHeader; ropeIsNIL ← pkt.data[pktLength]; pktLength ← pktLength+1; IF ropeIsNIL THEN events ← NIL ELSE BEGIN ropeLength: Lupine.RopeHeader; textRope: Rope.Text; ropeLength ← pkt.data[pktLength]; pktLength ← pktLength+1; IF ropeLength > RpcPrivate.maxShortStringLength THEN Lupine.UnmarshalingError; events ← textRope ← Rope.NewText[size: ropeLength]; pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength, dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[ropeLength], alwaysOnePkt: TRUE]; END; -- IF ropeIsNIL. END; -- Unmarshal events. Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength]; [resPkt.success] ← EventRope[localConversation, argPkt.smartsID, argPkt.time, argPkt.device, events]; pktLength ← 1; RETURN[returnLength: pktLength]; END; -- EventRopeStub. LoginStub: --PROCEDURE [shh: SHHH, smartsID: SmartsHandle, authenticated: -- BOOL]-- RpcPrivate.Dispatcher = BEGIN ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, smartsID (1): SmartsHandle, authenticated (3): BOOL]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength ← 4; Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength]; Login[localConversation, argPkt.smartsID, argPkt.authenticated]; pktLength ← 0; RETURN[returnLength: pktLength]; END; -- LoginStub. -- No module initialization. END. -- LarkSmartsRpcServerImpl.