-- Copyright (C) 1985 by Xerox Corporation.  All rights reserved.
-- Stub file  was translated on July 21, 1985 11:38:51 am PDT by Lupine of May 23, 1985 8:38:08 am PDT
-- Source interface ThParty came from file ThParty.bcd, which was created on July 21, 1985 11:30:23 am PDT with version stamp 64#333#31321156145 from source of May 22, 1985 12:18:35 pm PDT.

-- The RPC stub modules for ThParty are:
--   ThPartyRpcControl.mesa;
--   ThPartyRpcClientImpl.mesa;
--   ThPartyRpcBinderImpl.mesa;
--   ThPartyRpcServerImpl.mesa.

-- The parameters for this translation are:
--   Target language = Cedar
--   Default parameter passing = VALUE
--   Deallocate server heap arguments = TRUE
--   Inline RpcServerImpl dispatcher stubs = TRUE
--   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
  Basics,
  Lark,
  Thrush,
  ThSmarts,
  ThParty,
  ThPartyRpcControl USING [InterfaceRecord, InterMdsCallsOnly, LupineProtocolVersion,
      ProcedureIndex, SignalIndex],
  RPC --USING SOME OF [InterfaceName, standardZones, Zones]--,
  RPCLupine --USING SOME OF [Alloc, Call, DataLength, DeAlloc, Dispatcher,
      -- GetPkt, GetStubPkt, ImportHandle, ImportInterface, maxDataLength,
      -- maxPrincipalLength, maxShortStringLength, pktOverhead, ReceiveExtraPkt,
      -- SendPrelimPkt, StartCall, StartSignal, StubPkt, UnimportInterface]--,
  LupineRuntime --USING SOME OF [BindingError, CheckPktLength, CopyFromPkt,
      -- CopyFromMultiplePkts, CopyToPkt, CopyToMultiplePkts, defaultZones,
      -- DispatchingError, FinishThisPkt, ListHeader, MarshalingError,
      -- MarshalingExprError, MarshalAtom, MarshalRope, NilHeader, ProtocolError,
      -- RopeHeader, RpcPktDoubleWord, RuntimeError, SequenceHeader, SHORT,
      -- StartNextPkt, StringHeader, StubPktDoubleWord, TranslationError,
      -- UnmarshalingError, UnmarshalingExprError, UnmarshalAtom, UnmarshalRope,
      -- WordsForChars]--,
  Atom --USING SOME OF [GetPName, MakeAtom]--,
  PrincOpsUtils --USING SOME OF [Enter, Exit]--,
  Rope --USING SOME OF [InlineFlatten, Length, NewText, Text]--,
  VM --USING SOME OF [AddressForPageNumber, PageCount, PageNumber,
      -- PageNumberForAddress, PagesForWords]--;


ThPartyRpcClientImpl: MONITOR
  IMPORTS RpcPrivate: RPCLupine, Lupine: LupineRuntime, Atom, PrincOpsUtils,
      Rope
  EXPORTS ThParty, ThPartyRpcControl
  SHARES  ThParty, ThPartyRpcControl, Rope
  = BEGIN OPEN ThParty, RpcControl: ThPartyRpcControl, RpcPublic: RPC;


-- Standard remote binding routines.

  bound: BOOLEAN ← FALSE;
  myInterface: RpcPrivate.ImportHandle;
  paramZones: RpcPublic.Zones ← RpcPublic.standardZones;

  ImportInterface: PUBLIC ENTRY SAFE PROCEDURE [
        interfaceName: RpcPublic.InterfaceName,
        parameterStorage: RpcPublic.Zones ] =
    TRUSTED BEGIN ENABLE UNWIND => NULL;
    IsNull: PROCEDURE [string: Rope.ROPE] RETURNS [BOOLEAN] =
      INLINE {RETURN[string.Length[] = 0]};
        myInterface ← RpcPrivate.ImportInterface [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "ThParty~64#333#31321156145",
        instance: interfaceName.instance,
        version: interfaceName.version ],
      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;

  UnimportInterface: PUBLIC ENTRY SAFE PROCEDURE =
    TRUSTED BEGIN ENABLE UNWIND => NULL;
    IF ~bound THEN Lupine.BindingError;
    myInterface ← RpcPrivate.UnimportInterface[myInterface];
    paramZones ← RpcPublic.standardZones;
    bound ← FALSE;
    END;



-- Remote public procedure stubs.

  Alert: PUBLIC SAFE PROCEDURE [shhh: SHHH, credentials: Credentials,
      state: StateInConv, reason: Reason, calledPartyID: PartyHandle, urgency:
      CallUrgency, alertKind: AlertKind, newConv: BOOL, comment: ROPE]
    RETURNS [nb: NB, convID: ConversationHandle] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Alert, credentials
        (1): Credentials, state (8): StateInConv, reason (9): Reason, calledPartyID
        (10): PartyHandle, urgency (12): CallUrgency, alertKind (13): AlertKind,
        newConv (14): BOOL];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): NB, convID (1): ConversationHandle];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+49]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 15;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+49];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shhh];
      argPkt↑ ← [credentials: credentials, state: state, reason: reason,
          calledPartyID: calledPartyID, urgency: urgency, alertKind: alertKind,
          newConv: newConv];
      BEGIN  -- Marshal comment: ROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[comment, pkt, pktLength, TRUE];
        END;  -- Marshal comment.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 3, signalHandler: ClientDispatcher];
      [nb: nb, convID: convID] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 3];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+49];
      RETURN[nb, convID];
      END;  -- UNWIND.
    END;  -- Alert.

  Advance: PUBLIC SAFE PROCEDURE [shhh: SHHH, credentials: Credentials,
      state: StateInConv, reason: Reason, comment: ROPE]
    RETURNS [nb: NB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Advance, credentials
        (1): Credentials, state (8): StateInConv, reason (9): Reason];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): NB];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+44]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 10;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+44];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shhh];
      argPkt↑ ← [credentials: credentials, state: state, reason: reason];
      BEGIN  -- Marshal comment: ROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[comment, pkt, pktLength, TRUE];
        END;  -- Marshal comment.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 1, signalHandler: ClientDispatcher];
      [nb: nb] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+44];
      RETURN[nb];
      END;  -- UNWIND.
    END;  -- Advance.

  CreateConversation: PUBLIC SAFE PROCEDURE [shhh: SHHH, credentials:
      Credentials, urgency: CallUrgency, alertKind: AlertKind]
    RETURNS [nb: NB, convID: ConversationHandle] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← CreateConversation,
        credentials (1): Credentials, urgency (8): CallUrgency, alertKind
        (9): AlertKind];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): NB, convID (1): ConversationHandle];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+10] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 10;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shhh];
    argPkt↑ ← [credentials: credentials, urgency: urgency, alertKind:
        alertKind];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 3, signalHandler: ClientDispatcher];
    [nb: nb, convID: convID] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 3];
    RETURN[nb, convID];
    END;  -- CreateConversation.

  MergeConversations: PUBLIC SAFE PROCEDURE [shhh: SHHH, credentials:
      Credentials, otherStateID: StateID, otherConvID: ConversationHandle]
    RETURNS [nb: NB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← MergeConversations,
        credentials (1): Credentials, otherStateID (8): StateID, otherConvID
        (9): ConversationHandle];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): NB];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+11] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 11;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shhh];
    argPkt↑ ← [credentials: credentials, otherStateID: otherStateID,
        otherConvID: otherConvID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    [nb: nb] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[nb];
    END;  -- MergeConversations.

  OtherParty: PUBLIC SAFE PROCEDURE [shhh: SHHH, credentials: Credentials]
      RETURNS [nb: NB, partyID: PartyHandle, description: Thrush.ROPE,
      conference: BOOL] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← OtherParty, credentials
        (1): Credentials];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): NB, partyID (1): PartyHandle, conference (3): BOOL];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+38]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 8;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+38];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shhh];
      argPkt↑ ← [credentials: credentials];
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 38, signalHandler: ClientDispatcher];
      pktLength ← 4;
      [nb: nb, partyID: partyID, conference: conference] ← resPkt↑;
      BEGIN  -- Unmarshal description: Thrush.ROPE from pkt.data[pktLength].
        [description, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
            TRUE];
        END;  -- Unmarshal description.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+38];
      RETURN[nb, partyID, description, conference];
      END;  -- UNWIND.
    END;  -- OtherParty.

  DescribeParty: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID: PartyHandle]
      RETURNS [description: Thrush.ROPE] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← DescribeParty, partyID
        (1): PartyHandle];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+34]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+34];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shh];
      argPkt↑ ← [partyID: partyID];
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 34, signalHandler: ClientDispatcher];
      pktLength ← 0;
      BEGIN  -- Unmarshal description: Thrush.ROPE from pkt.data[pktLength].
        [description, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
            TRUE];
        END;  -- Unmarshal description.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+34];
      RETURN[description];
      END;  -- UNWIND.
    END;  -- DescribeParty.

  ConversationsForParty: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID:
      PartyHandle] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← ConversationsForParty,
        partyID (1): PartyHandle];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+3] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [partyID: partyID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- ConversationsForParty.

  SetIntervals: PUBLIC SAFE PROCEDURE [shhh: SHHH, credentials: Credentials,
      intervalSpecs: Thrush.IntervalSpecs]
    RETURNS [nb: NB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetIntervals, credentials
        (1): Credentials];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): NB];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 8;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shhh];
      argPkt↑ ← [credentials: credentials];
      BEGIN  -- Marshal intervalSpecs: Thrush.IntervalSpecs to pkt.data[pktLength].
        thisNode1: Thrush.IntervalSpecs;
        listLength: Lupine.ListHeader ← 0;
        FOR thisNode1 ← intervalSpecs, thisNode1.rest UNTIL thisNode1
            = NIL DO
          listLength ← listLength + 1;  ENDLOOP;
        IF pktLength+2 > RpcPrivate.maxDataLength
          THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength:
              pktLength];
        Lupine.RpcPktDoubleWord[pkt, pktLength]↑ ← listLength;
        pktLength ← pktLength + 2;
        FOR thisNode1 ← intervalSpecs, thisNode1.rest UNTIL thisNode1
            = NIL DO
          BEGIN  -- Marshal thisNode1.first: Thrush.IntervalSpec to
              -- pkt.data[pktLength].
            pktLength ← MarshalThrushDotIntervalSpec[thisNode1.first,
                pkt, pktLength];
            END;  -- Marshal thisNode1.first.
          ENDLOOP;  -- FOR thisNode1.
        END;  -- Marshal intervalSpecs.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 1, signalHandler: ClientDispatcher];
      [nb: nb] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[nb];
      END;  -- UNWIND.
    END;  -- SetIntervals.

  DescribeInterval: PUBLIC SAFE PROCEDURE [shhh: SHHH, credentials:
      Credentials, targetInterval: Thrush.IntervalSpec, minSilence: Thrush.VoiceTime]
    RETURNS [nb: NB, exists: BOOL, intervals: Thrush.IntervalSpecs]
        =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← DescribeInterval,
        credentials (1): Credentials, minSilence (8): Thrush.VoiceTime];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): NB, exists (1): BOOL];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 10;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shhh];
      argPkt↑ ← [credentials: credentials, minSilence: minSilence];
      BEGIN  -- Marshal targetInterval: Thrush.IntervalSpec to pkt.data[pktLength].
        pktLength ← MarshalThrushDotIntervalSpec[targetInterval, pkt,
            pktLength];
        END;  -- Marshal targetInterval.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 254, signalHandler: ClientDispatcher];
      pktLength ← 2;
      BEGIN  -- OnePkt.
        -- Move statics from pkt now.
        [nb: nb, exists: exists] ← resPkt↑;
      BEGIN  -- Unmarshal intervals: Thrush.IntervalSpecs from pkt.data[pktLength].
        lastNode: Thrush.IntervalSpecs ← (intervals ← NIL);
        listLength: Lupine.ListHeader;
        IF pktLength+2 > RpcPrivate.maxDataLength
          THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength:
              pktLength];
        listLength ← Lupine.RpcPktDoubleWord[pkt, pktLength]↑;
        pktLength ← pktLength + 2;
        WHILE listLength > 0 DO
          thisNode1: Thrush.IntervalSpecs = paramZones.gc.CONS[--DefaultValue--,NIL];
          BEGIN  -- Unmarshal thisNode1.first: Thrush.IntervalSpec
              -- from pkt.data[pktLength].
            [thisNode1.first, pktLength] ← UnmarshalThrushDotIntervalSpec[pkt,
                pktLength];
            END;  -- Unmarshal thisNode1.first.
          IF lastNode # NIL
            THEN lastNode ← (lastNode.rest ← thisNode1)
            ELSE lastNode ← (intervals ← thisNode1);
          listLength ← listLength - 1;
          ENDLOOP;  -- WHILE listLength > 0.
        END;  -- Unmarshal intervals.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
RETURN[nb, exists, intervals];
      END;  -- OnePkt.
      END;  -- UNWIND.
    END;  -- DescribeInterval.

  RegisterKey: PUBLIC SAFE PROCEDURE [shh: SHHH, credentials: Credentials,
      key: Thrush.EncryptionKey]
    RETURNS [nb: NB, keyIndex: [0..15]] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← RegisterKey, credentials
        (1): Credentials, key (8): Thrush.EncryptionKey];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): NB, keyIndex (1): [0..15]];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+12] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 12;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [credentials: credentials, key: key];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 2, signalHandler: ClientDispatcher];
    [nb: nb, keyIndex: keyIndex] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[nb, keyIndex];
    END;  -- RegisterKey.

  SetProse: PUBLIC SAFE PROCEDURE [shhh: SHHH, credentials: Credentials,
      proseSpecs: Thrush.ProseSpecs]
    RETURNS [nb: NB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetProse, credentials
        (1): Credentials];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): NB];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 8;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shhh];
      argPkt↑ ← [credentials: credentials];
      BEGIN  -- Marshal proseSpecs: Thrush.ProseSpecs to pkt.data[pktLength].
        thisNode1: Thrush.ProseSpecs;
        listLength: Lupine.ListHeader ← 0;
        FOR thisNode1 ← proseSpecs, thisNode1.rest UNTIL thisNode1
            = NIL DO
          listLength ← listLength + 1;  ENDLOOP;
        IF pktLength+2 > RpcPrivate.maxDataLength
          THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength:
              pktLength];
        Lupine.RpcPktDoubleWord[pkt, pktLength]↑ ← listLength;
        pktLength ← pktLength + 2;
        FOR thisNode1 ← proseSpecs, thisNode1.rest UNTIL thisNode1
            = NIL DO
          BEGIN  -- Marshal thisNode1.first: Thrush.ProseSpec to pkt.data[pktLength].
            pktLength ← MarshalThrushDotProseSpec[thisNode1.first,
                pkt, pktLength];
            END;  -- Marshal thisNode1.first.
          ENDLOOP;  -- FOR thisNode1.
        END;  -- Marshal proseSpecs.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 1, signalHandler: ClientDispatcher];
      [nb: nb] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[nb];
      END;  -- UNWIND.
    END;  -- SetProse.

  CreateParty: PUBLIC SAFE PROCEDURE [shh: SHHH, rName: Rname, type:
      Thrush.PartyType]
    RETURNS [partyID: PartyHandle] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← CreateParty, type
        (1): Thrush.PartyType];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        partyID (0): PartyHandle];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+36]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+36];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shh];
      argPkt↑ ← [type: type];
      BEGIN  -- Marshal rName: Rname to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[rName, pkt, pktLength, TRUE];
        END;  -- Marshal rName.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 2, signalHandler: ClientDispatcher];
      [partyID: partyID] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+36];
      RETURN[partyID];
      END;  -- UNWIND.
    END;  -- CreateParty.

  GetParty: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID: PartyHandle,
      rName: Rname, type: Thrush.PartyType]
    RETURNS [newPartyID: PartyHandle] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetParty, partyID
        (1): PartyHandle, type (3): Thrush.PartyType];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        newPartyID (0): PartyHandle];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+38]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 4;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+38];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shh];
      argPkt↑ ← [partyID: partyID, type: type];
      BEGIN  -- Marshal rName: Rname to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[rName, pkt, pktLength, TRUE];
        END;  -- Marshal rName.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 2, signalHandler: ClientDispatcher];
      [newPartyID: newPartyID] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+38];
      RETURN[newPartyID];
      END;  -- UNWIND.
    END;  -- GetParty.

  GetPartyFromNumber: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID: PartyHandle,
      phoneNumber: Thrush.ROPE, description: ROPE, trunkOK: BOOL]
    RETURNS [newPartyID: PartyHandle] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetPartyFromNumber,
        partyID (1): PartyHandle, trunkOK (3): BOOL];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        newPartyID (0): PartyHandle];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+72]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 4;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+72];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shh];
      argPkt↑ ← [partyID: partyID, trunkOK: trunkOK];
      BEGIN  -- Marshal phoneNumber: Thrush.ROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[phoneNumber, pkt, pktLength,
            TRUE];
        END;  -- Marshal phoneNumber.
      BEGIN  -- Marshal description: ROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[description, pkt, pktLength,
            TRUE];
        END;  -- Marshal description.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 2, signalHandler: ClientDispatcher];
      [newPartyID: newPartyID] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+72];
      RETURN[newPartyID];
      END;  -- UNWIND.
    END;  -- GetPartyFromNumber.

  GetPartyFromFeepNum: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID: PartyHandle,
      feepNum: Thrush.ROPE]
    RETURNS [newPartyID: PartyHandle] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetPartyFromFeepNum,
        partyID (1): PartyHandle];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        newPartyID (0): PartyHandle];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+37]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+37];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shh];
      argPkt↑ ← [partyID: partyID];
      BEGIN  -- Marshal feepNum: Thrush.ROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[feepNum, pkt, pktLength, TRUE];
        END;  -- Marshal feepNum.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 2, signalHandler: ClientDispatcher];
      [newPartyID: newPartyID] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+37];
      RETURN[newPartyID];
      END;  -- UNWIND.
    END;  -- GetPartyFromFeepNum.

  GetRname: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID: PartyHandle]
      RETURNS [Rname: Thrush.Rname] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetRname, partyID
        (1): PartyHandle];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+34]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+34];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shh];
      argPkt↑ ← [partyID: partyID];
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 34, signalHandler: ClientDispatcher];
      pktLength ← 0;
      BEGIN  -- Unmarshal Rname: Thrush.Rname from pkt.data[pktLength].
        [Rname, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength, TRUE];
        END;  -- Unmarshal Rname.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+34];
      RETURN[Rname];
      END;  -- UNWIND.
    END;  -- GetRname.

  Register: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID: PartyHandle,
      interface: SmartsInterface, properties: ThSmarts.SmartsProperties,
      oldSmartsID: SmartsHandle]
    RETURNS [smartsID: SmartsHandle] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Register, partyID
        (1): PartyHandle, properties (3): ThSmarts.SmartsProperties, oldSmartsID
        (5): SmartsHandle];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        smartsID (0): SmartsHandle];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+82]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 7;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+82];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shh];
      argPkt↑ ← [partyID: partyID, properties: properties, oldSmartsID:
          oldSmartsID];
      BEGIN  -- Marshal interface: SmartsInterface to pkt.data[pktLength].
        pktLength ← MarshalSmartsInterface[interface, pkt, pktLength];
        END;  -- Marshal interface.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 2, signalHandler: ClientDispatcher];
      [smartsID: smartsID] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+82];
      RETURN[smartsID];
      END;  -- UNWIND.
    END;  -- Register.

  RegisterClone: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID: PartyHandle,
      clonePartyID: PartyHandle, oldSmartsID: SmartsHandle]
    RETURNS [smartsID: SmartsHandle] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← RegisterClone, partyID
        (1): PartyHandle, clonePartyID (3): PartyHandle, oldSmartsID (5):
        SmartsHandle];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        smartsID (0): SmartsHandle];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+7] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 7;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [partyID: partyID, clonePartyID: clonePartyID, oldSmartsID:
        oldSmartsID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 2, signalHandler: ClientDispatcher];
    [smartsID: smartsID] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[smartsID];
    END;  -- RegisterClone.

  Deregister: PUBLIC SAFE PROCEDURE [shh: SHHH, smartsID: SmartsHandle]
      =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Deregister, smartsID
        (1): SmartsHandle];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+3] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [smartsID: smartsID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- Deregister.

  Enable: PUBLIC SAFE PROCEDURE [shh: SHHH, smartsID: SmartsHandle]
      RETURNS [nb: Thrush.NB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Enable, smartsID
        (1): SmartsHandle];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): Thrush.NB];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+3] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [smartsID: smartsID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    [nb: nb] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[nb];
    END;  -- Enable.

  Disable: PUBLIC SAFE PROCEDURE [shh: SHHH, smartsID: SmartsHandle]
      RETURNS [nb: Thrush.NB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Disable, smartsID
        (1): SmartsHandle];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): Thrush.NB];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+3] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [smartsID: smartsID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    [nb: nb] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[nb];
    END;  -- Disable.

  GetNumbersForRName: PUBLIC SAFE PROCEDURE [shh: SHHH, rName: ROPE]
      RETURNS [fullRName: ROPE, number: ROPE, homeNumber: ROPE] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetNumbersForRName];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+102]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+102];
      RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
          shh];
      argPkt.transferIndex ← GetNumbersForRName;
      BEGIN  -- Marshal rName: ROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[rName, pkt, pktLength, TRUE];
        END;  -- Marshal rName.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 102, signalHandler: ClientDispatcher];
      pktLength ← 0;
      BEGIN  -- Unmarshal fullRName: ROPE from pkt.data[pktLength].
        [fullRName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
            TRUE];
        END;  -- Unmarshal fullRName.
      BEGIN  -- Unmarshal number: ROPE from pkt.data[pktLength].
        [number, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
            TRUE];
        END;  -- Unmarshal number.
      BEGIN  -- Unmarshal homeNumber: ROPE from pkt.data[pktLength].
        [homeNumber, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
            TRUE];
        END;  -- Unmarshal homeNumber.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+102];
      RETURN[fullRName, number, homeNumber];
      END;  -- UNWIND.
    END;  -- GetNumbersForRName.

  SetRingEnable: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID: PartyHandle,
      ringEnable: Thrush.RingEnable, ringInterval: INT, update: BOOL] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetRingEnable, partyID
        (1): PartyHandle, ringEnable (3): Thrush.RingEnable, ringInterval
        (4): INT, update (6): BOOL];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+7] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 7;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [partyID: partyID, ringEnable: ringEnable, ringInterval:
        ringInterval, update: update];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- SetRingEnable.


-- Remote public signals and errors.


-- Public signal and error dispatcher.

  ClientDispatcher: --PROCEDURE [pkt: RPCPkt, callLength: DataLength,
      -- lastPkt: BOOLEAN, localConversation: Conversation] RETURNS [returnLength:
      -- DataLength]-- RpcPrivate.Dispatcher =
    BEGIN

    SELECT LOOPHOLE[pkt.data[0], RpcControl.SignalIndex] FROM
      ENDCASE => RETURN[Lupine.DispatchingError[]];

    END;  -- ClientDispatcher


-- Public signal and error dispatcher stubs.


-- Marshall/Unmarshal procedures.
MarshalThrushDotIntervalSpec: PROC[value: Thrush.IntervalSpec, pkt:
    RpcPrivate.RPCPkt, pktLength0: RpcPrivate.DataLength]
  RETURNS[pktLength: RpcPrivate.DataLength] = BEGIN
  pktLength ← pktLength0; {
  IF pktLength+1 > RpcPrivate.maxDataLength
    THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
  pkt.data[pktLength] ← value=NIL;  pktLength ← pktLength+1;
  IF value # NIL THEN
    BEGIN  -- Marshal value↑: Thrush.IntervalSpecBody to pkt.data[pktLength].
      pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
          dataAdr: LOOPHOLE[value], dataLength: SIZE[Thrush.IntervalSpecBody],
          alwaysOnePkt: FALSE];
      END;  -- Marshal value↑.
  };END;

UnmarshalThrushDotIntervalSpec: PROC[pkt: RpcPrivate.RPCPkt, pktLength0:
    RpcPrivate.DataLength]
  RETURNS[value: Thrush.IntervalSpec, pktLength: RpcPrivate.DataLength]
      = BEGIN
  pktLength ← pktLength0; {
  isNIL: Lupine.NilHeader;
  IF pktLength+1 > RpcPrivate.maxDataLength
    THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
  isNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
  IF isNIL
    THEN value ← NIL
    ELSE BEGIN
      value ← (paramZones.gc.NEW[Thrush.IntervalSpecBody]);
      BEGIN  -- Unmarshal value↑: Thrush.IntervalSpecBody from pkt.data[pktLength].
        pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
            dataAdr: LOOPHOLE[value], dataLength: SIZE[Thrush.IntervalSpecBody],
            alwaysOnePkt: FALSE];
        END;  -- Unmarshal value↑.
      END;  -- IF isNIL.
  };END;

MarshalSmartsInterface: PROC[value: ThParty.SmartsInterface, pkt: RpcPrivate.RPCPkt,
    pktLength0: RpcPrivate.DataLength]
  RETURNS[pktLength: RpcPrivate.DataLength] = BEGIN
  pktLength ← pktLength0; {
  pkt.data[pktLength] ← value=NIL;  pktLength ← pktLength+1;
  IF value # NIL THEN
    BEGIN  -- Marshal value↑: ThSmarts.SmartsInterfaceRecord to pkt.data[pktLength].
      pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
          dataAdr: LOOPHOLE[value], dataLength: SIZE[ThSmarts.SmartsInterfaceRecord],
          alwaysOnePkt: TRUE];
      BEGIN OPEN record: value↑;
      BEGIN  -- Marshal record.type: RPC.ShortROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[record.type, pkt, pktLength,
            TRUE];
        END;  -- Marshal record.type.
      BEGIN  -- Marshal record.instance: RPC.ShortROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[record.instance, pkt, pktLength,
            TRUE];
        END;  -- Marshal record.instance.
      END;  -- OPEN record: value↑.
      END;  -- Marshal value↑.
  };END;

MarshalThrushDotProseSpec: PROC[value: Thrush.ProseSpec, pkt: RpcPrivate.RPCPkt,
    pktLength0: RpcPrivate.DataLength]
  RETURNS[pktLength: RpcPrivate.DataLength] = BEGIN
  pktLength ← pktLength0; {
  IF pktLength+1 > RpcPrivate.maxDataLength
    THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
  pkt.data[pktLength] ← value=NIL;  pktLength ← pktLength+1;
  IF value # NIL THEN
    BEGIN  -- Marshal value↑: Thrush.ProseSpecBody to pkt.data[pktLength].
      pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
          dataAdr: LOOPHOLE[value], dataLength: SIZE[Thrush.ProseSpecBody],
          alwaysOnePkt: FALSE];
      BEGIN OPEN record: value↑;
      BEGIN  -- Marshal record.prose: Rope.ROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[record.prose, pkt, pktLength,
            FALSE];
        END;  -- Marshal record.prose.
      END;  -- OPEN record: value↑.
      END;  -- Marshal value↑.
  };END;



-- No module initialization.

END.  -- ThPartyRpcClientImpl.