-- Stub file  was translated on January 3, 1984 0:09 am by Lupine of December 20, 1983 1:22 pm
-- Source interface ThParty came from file ThParty.bcd, which was created on January 3, 1984 0:09 am with version stamp 137B#133B#34120436254B from source of December 28, 1983 11:09 pm.

-- 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 = 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
  Basics,
  Lark,
  Thrush,
  ThSmarts,
  ThParty,
  ThPartyRpcControl USING [InterMdsCallsOnly, LupineProtocolVersion,
      ProcedureIndex, SignalIndex],
  RPC USING [InterfaceName, standardZones, Zones],
  RPCLupine --USING SOME OF [Call, DataLength, Dispatcher, 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, 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]--;


ThPartyRpcClientImpl: MONITOR
  IMPORTS RpcPrivate: RPCLupine, Lupine: LupineRuntime, Atom, 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]};
    IF bound THEN Lupine.BindingError;
    myInterface ← RpcPrivate.ImportInterface [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "ThParty~137B#133B#34120436254B",
        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];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+49] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 15;
    lastPkt: BOOLEAN;
    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].
      pkt.data[pktLength] ← comment=NIL;  pktLength ← pktLength+1;
      IF comment # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: comment];
          IF textRope.length > RpcPrivate.maxShortStringLength
            THEN Lupine.MarshalingError;
          pkt.data[pktLength] ← textRope.length;  pktLength ← pktLength+1;
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[textRope.length],
              alwaysOnePkt: TRUE];
          END;  -- IF comment # NIL.
      END;  -- Marshal comment.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 3, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 3];
    RETURN[resPkt.nb, resPkt.convID];
    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];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+44] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 10;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shhh];
    argPkt↑ ← [credentials: credentials, state: state, reason: reason];
    BEGIN  -- Marshal comment: ROPE to pkt.data[pktLength].
      pkt.data[pktLength] ← comment=NIL;  pktLength ← pktLength+1;
      IF comment # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: comment];
          IF textRope.length > RpcPrivate.maxShortStringLength
            THEN Lupine.MarshalingError;
          pkt.data[pktLength] ← textRope.length;  pktLength ← pktLength+1;
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[textRope.length],
              alwaysOnePkt: TRUE];
          END;  -- IF comment # NIL.
      END;  -- Marshal comment.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.nb];
    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: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: 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];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 3];
    RETURN[resPkt.nb, resPkt.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: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: 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];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.nb];
    END;  -- MergeConversations.

  SetSubject: PUBLIC SAFE PROCEDURE [shh: SHHH, convID: ConversationHandle,
      subject: ROPE] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetSubject, convID
        (1): ConversationHandle];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+37] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [convID: convID];
    BEGIN  -- Marshal subject: ROPE to pkt.data[pktLength].
      pkt.data[pktLength] ← subject=NIL;  pktLength ← pktLength+1;
      IF subject # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: subject];
          IF textRope.length > RpcPrivate.maxShortStringLength
            THEN Lupine.MarshalingError;
          pkt.data[pktLength] ← textRope.length;  pktLength ← pktLength+1;
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[textRope.length],
              alwaysOnePkt: TRUE];
          END;  -- IF subject # NIL.
      END;  -- Marshal subject.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- SetSubject.

  GetSubject: PUBLIC SAFE PROCEDURE [shh: SHHH, convID: ConversationHandle]
      RETURNS [subject: ROPE] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetSubject, convID
        (1): ConversationHandle];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+34] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [convID: convID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 34, signalHandler: ClientDispatcher];
    pktLength ← 0;
    BEGIN  -- Unmarshal subject: ROPE from pkt.data[pktLength].
      ropeIsNIL: Lupine.NilHeader;
      ropeIsNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
      IF ropeIsNIL
        THEN subject ← NIL
        ELSE BEGIN
          ropeLength: Lupine.RopeHeader;
          textRope: Rope.Text;
          ropeLength ← pkt.data[pktLength];  pktLength ← pktLength+1;
          IF ropeLength > RpcPrivate.maxShortStringLength
            THEN Lupine.UnmarshalingError;
          subject ← 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 subject.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    RETURN[subject];
    END;  -- GetSubject.

  OtherParty: PUBLIC SAFE PROCEDURE [shhh: SHHH, credentials: Credentials]
      RETURNS [--nb:-- NB, --partyID:-- PartyHandle, --description:-- Thrush.ROPE,
      --conference:-- BOOL] =
    TRUSTED BEGIN
    description: Thrush.ROPE;
    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];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+38] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 8;
    lastPkt: BOOLEAN;
    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;
    BEGIN  -- Unmarshal description: Thrush.ROPE from pkt.data[pktLength].
      ropeIsNIL: Lupine.NilHeader;
      ropeIsNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
      IF ropeIsNIL
        THEN description ← NIL
        ELSE BEGIN
          ropeLength: Lupine.RopeHeader;
          textRope: Rope.Text;
          ropeLength ← pkt.data[pktLength];  pktLength ← pktLength+1;
          IF ropeLength > RpcPrivate.maxShortStringLength
            THEN Lupine.UnmarshalingError;
          description ← 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 description.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    RETURN[resPkt.nb, resPkt.partyID, description, resPkt.conference];
    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];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+34] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: 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: 34, signalHandler: ClientDispatcher];
    pktLength ← 0;
    BEGIN  -- Unmarshal description: Thrush.ROPE from pkt.data[pktLength].
      ropeIsNIL: Lupine.NilHeader;
      ropeIsNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
      IF ropeIsNIL
        THEN description ← NIL
        ELSE BEGIN
          ropeLength: Lupine.RopeHeader;
          textRope: Rope.Text;
          ropeLength ← pkt.data[pktLength];  pktLength ← pktLength+1;
          IF ropeLength > RpcPrivate.maxShortStringLength
            THEN Lupine.UnmarshalingError;
          description ← 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 description.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    RETURN[description];
    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: 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.

  SetInterval: PUBLIC SAFE PROCEDURE [shhh: SHHH, credentials: Credentials,
      intervalSpec: Thrush.IntervalSpec]
    RETURNS [--nb:-- NB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetInterval, credentials
        (1): Credentials];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        nb (0): NB];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+17] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 8;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shhh];
    argPkt↑ ← [credentials: credentials];
    BEGIN  -- Marshal intervalSpec: Thrush.IntervalSpec to pkt.data[pktLength].
      pkt.data[pktLength] ← intervalSpec=NIL;  pktLength ← pktLength+1;
      IF intervalSpec # NIL THEN
        BEGIN  -- Marshal intervalSpec↑: Thrush.IntervalSpecBody to
            -- pkt.data[pktLength].
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: LOOPHOLE[intervalSpec], dataLength: SIZE[Thrush.IntervalSpecBody],
              alwaysOnePkt: TRUE];
          END;  -- Marshal intervalSpec↑.
      END;  -- Marshal intervalSpec.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.nb];
    END;  -- SetInterval.

  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: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: 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];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[resPkt.nb, resPkt.keyIndex];
    END;  -- RegisterKey.

  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];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+36] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 2;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [type: type];
    BEGIN  -- Marshal rName: Rname to pkt.data[pktLength].
      pkt.data[pktLength] ← rName=NIL;  pktLength ← pktLength+1;
      IF rName # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: rName];
          IF textRope.length > RpcPrivate.maxShortStringLength
            THEN Lupine.MarshalingError;
          pkt.data[pktLength] ← textRope.length;  pktLength ← pktLength+1;
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[textRope.length],
              alwaysOnePkt: TRUE];
          END;  -- IF rName # NIL.
      END;  -- Marshal rName.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 2, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[resPkt.partyID];
    END;  -- CreateParty.

  GetParty: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID: PartyHandle,
      rName: Rname]
    RETURNS [--newPartyID:-- PartyHandle] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetParty, partyID
        (1): PartyHandle];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        newPartyID (0): PartyHandle];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+37] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [partyID: partyID];
    BEGIN  -- Marshal rName: Rname to pkt.data[pktLength].
      pkt.data[pktLength] ← rName=NIL;  pktLength ← pktLength+1;
      IF rName # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: rName];
          IF textRope.length > RpcPrivate.maxShortStringLength
            THEN Lupine.MarshalingError;
          pkt.data[pktLength] ← textRope.length;  pktLength ← pktLength+1;
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[textRope.length],
              alwaysOnePkt: TRUE];
          END;  -- IF rName # NIL.
      END;  -- Marshal rName.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 2, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[resPkt.newPartyID];
    END;  -- GetParty.

  GetJayParty: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID: PartyHandle]
      RETURNS [--newPartyID:-- PartyHandle] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetJayParty, partyID
        (1): PartyHandle];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        newPartyID (0): PartyHandle];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+3] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @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: 2, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[resPkt.newPartyID];
    END;  -- GetJayParty.

  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];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+72] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 4;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [partyID: partyID, trunkOK: trunkOK];
    BEGIN  -- Marshal phoneNumber: Thrush.ROPE to pkt.data[pktLength].
      pkt.data[pktLength] ← phoneNumber=NIL;  pktLength ← pktLength+1;
      IF phoneNumber # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: phoneNumber];
          IF textRope.length > RpcPrivate.maxShortStringLength
            THEN Lupine.MarshalingError;
          pkt.data[pktLength] ← textRope.length;  pktLength ← pktLength+1;
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[textRope.length],
              alwaysOnePkt: TRUE];
          END;  -- IF phoneNumber # NIL.
      END;  -- Marshal phoneNumber.
    BEGIN  -- Marshal description: ROPE to pkt.data[pktLength].
      pkt.data[pktLength] ← description=NIL;  pktLength ← pktLength+1;
      IF description # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: description];
          IF textRope.length > RpcPrivate.maxShortStringLength
            THEN Lupine.MarshalingError;
          pkt.data[pktLength] ← textRope.length;  pktLength ← pktLength+1;
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[textRope.length],
              alwaysOnePkt: TRUE];
          END;  -- IF description # NIL.
      END;  -- Marshal description.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 2, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[resPkt.newPartyID];
    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];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+37] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [partyID: partyID];
    BEGIN  -- Marshal feepNum: Thrush.ROPE to pkt.data[pktLength].
      pkt.data[pktLength] ← feepNum=NIL;  pktLength ← pktLength+1;
      IF feepNum # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: feepNum];
          IF textRope.length > RpcPrivate.maxShortStringLength
            THEN Lupine.MarshalingError;
          pkt.data[pktLength] ← textRope.length;  pktLength ← pktLength+1;
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[textRope.length],
              alwaysOnePkt: TRUE];
          END;  -- IF feepNum # NIL.
      END;  -- Marshal feepNum.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 2, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[resPkt.newPartyID];
    END;  -- GetPartyFromFeepNum.

  ReleaseTrunkParty: PUBLIC SAFE PROCEDURE [shh: SHHH, partyID: PartyHandle]
      =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← ReleaseTrunkParty,
        partyID (1): PartyHandle];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+3] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: 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;  -- ReleaseTrunkParty.

  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];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+34] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: 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: 34, signalHandler: ClientDispatcher];
    pktLength ← 0;
    BEGIN  -- Unmarshal Rname: Thrush.Rname from pkt.data[pktLength].
      ropeIsNIL: Lupine.NilHeader;
      ropeIsNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
      IF ropeIsNIL
        THEN Rname ← NIL
        ELSE BEGIN
          ropeLength: Lupine.RopeHeader;
          textRope: Rope.Text;
          ropeLength ← pkt.data[pktLength];  pktLength ← pktLength+1;
          IF ropeLength > RpcPrivate.maxShortStringLength
            THEN Lupine.UnmarshalingError;
          Rname ← 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 Rname.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    RETURN[Rname];
    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];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+82] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 7;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt↑ ← [partyID: partyID, properties: properties, oldSmartsID:
        oldSmartsID];
    BEGIN  -- Marshal interface: SmartsInterface to pkt.data[pktLength].
      pkt.data[pktLength] ← interface=NIL;  pktLength ← pktLength+1;
      IF interface # NIL THEN
        BEGIN  -- Marshal interface↑: ThSmarts.SmartsInterfaceRecord
            -- to pkt.data[pktLength].
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: LOOPHOLE[interface], dataLength: SIZE[ThSmarts.SmartsInterfaceRecord],
              alwaysOnePkt: TRUE];
          BEGIN OPEN record: interface↑;
          BEGIN  -- Marshal record.type: ShortROPE to pkt.data[pktLength].
            pkt.data[pktLength] ← record.type=NIL;  pktLength ← pktLength+1;
            IF record.type # NIL
              THEN BEGIN
                textRope: Rope.Text = Rope.InlineFlatten[r: record.type];
                IF textRope.length > RpcPrivate.maxShortStringLength
                  THEN Lupine.MarshalingError;
                pkt.data[pktLength] ← textRope.length;  pktLength ←
                    pktLength+1;
                pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
                    dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength:
                    Lupine.WordsForChars[textRope.length], alwaysOnePkt:
                    TRUE];
                END;  -- IF record.type # NIL.
            END;  -- Marshal record.type.
          BEGIN  -- Marshal record.instance: ShortROPE to pkt.data[pktLength].
            pkt.data[pktLength] ← record.instance=NIL;  pktLength ←
                pktLength+1;
            IF record.instance # NIL
              THEN BEGIN
                textRope: Rope.Text = Rope.InlineFlatten[r: record.instance];
                IF textRope.length > RpcPrivate.maxShortStringLength
                  THEN Lupine.MarshalingError;
                pkt.data[pktLength] ← textRope.length;  pktLength ←
                    pktLength+1;
                pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
                    dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength:
                    Lupine.WordsForChars[textRope.length], alwaysOnePkt:
                    TRUE];
                END;  -- IF record.instance # NIL.
            END;  -- Marshal record.instance.
          END;  -- OPEN record: interface↑.
          END;  -- Marshal interface↑.
      END;  -- Marshal interface.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 2, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[resPkt.smartsID];
    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: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: 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];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[resPkt.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: 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: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: 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];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.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: POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: 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];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.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];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+102] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 1;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        shh];
    argPkt.transferIndex ← GetNumbersForRName;
    BEGIN  -- Marshal rName: ROPE to pkt.data[pktLength].
      pkt.data[pktLength] ← rName=NIL;  pktLength ← pktLength+1;
      IF rName # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: rName];
          IF textRope.length > RpcPrivate.maxShortStringLength
            THEN Lupine.MarshalingError;
          pkt.data[pktLength] ← textRope.length;  pktLength ← pktLength+1;
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: BASE[DESCRIPTOR[textRope.text]], dataLength: Lupine.WordsForChars[textRope.length],
              alwaysOnePkt: TRUE];
          END;  -- IF rName # NIL.
      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].
      ropeIsNIL: Lupine.NilHeader;
      ropeIsNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
      IF ropeIsNIL
        THEN fullRName ← NIL
        ELSE BEGIN
          ropeLength: Lupine.RopeHeader;
          textRope: Rope.Text;
          ropeLength ← pkt.data[pktLength];  pktLength ← pktLength+1;
          IF ropeLength > RpcPrivate.maxShortStringLength
            THEN Lupine.UnmarshalingError;
          fullRName ← 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 fullRName.
    BEGIN  -- Unmarshal number: ROPE from pkt.data[pktLength].
      ropeIsNIL: Lupine.NilHeader;
      ropeIsNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
      IF ropeIsNIL
        THEN number ← NIL
        ELSE BEGIN
          ropeLength: Lupine.RopeHeader;
          textRope: Rope.Text;
          ropeLength ← pkt.data[pktLength];  pktLength ← pktLength+1;
          IF ropeLength > RpcPrivate.maxShortStringLength
            THEN Lupine.UnmarshalingError;
          number ← 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 number.
    BEGIN  -- Unmarshal homeNumber: ROPE from pkt.data[pktLength].
      ropeIsNIL: Lupine.NilHeader;
      ropeIsNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
      IF ropeIsNIL
        THEN homeNumber ← NIL
        ELSE BEGIN
          ropeLength: Lupine.RopeHeader;
          textRope: Rope.Text;
          ropeLength ← pkt.data[pktLength];  pktLength ← pktLength+1;
          IF ropeLength > RpcPrivate.maxShortStringLength
            THEN Lupine.UnmarshalingError;
          homeNumber ← 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 homeNumber.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    RETURN[fullRName, number, homeNumber];
    END;  -- GetNumbersForRName.


-- 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.


-- No module initialization.

END.  -- ThPartyRpcClientImpl.