-- Copyright (C) 1986 by Xerox Corporation.  All rights reserved.
-- Stub file  was translated on April 23, 1986 4:19:13 pm PST by Lupine of May 23, 1985 8:38:08 am PDT
-- Source interface LoganBerry came from file LoganBerry.bcd, which was created on March 6, 1986 11:57:09 am PST with version stamp 210#224#2316577624 from source of March 6, 1986 11:11:43 am PST.

-- The RPC stub modules for LoganBerry are:
--   LoganBerryRpcControl.mesa;
--   LoganBerryRpcClientImpl.mesa;
--   LoganBerryRpcBinderImpl.mesa;
--   LoganBerryRpcServerImpl.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 = FALSE
--   Warn about short POINTER ("MDS") allocations = TRUE
--   Maximum number of dynamic heap NEWs = 50, MDS NEWs = 50
--   Acceptable parameter protocols = VersionRange[1..1].


DIRECTORY
  RefID,
  Rope,
  RPC,
  LoganBerry,
  LoganBerryRpcControl USING [InterfaceRecord, InterMdsCallsOnly, LupineProtocolVersion,
      ProcedureIndex, SignalIndex],
  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]--,
  VM --USING SOME OF [AddressForPageNumber, PageCount, PageNumber,
      -- PageNumberForAddress, PagesForWords]--;


LoganBerryRpcClientImpl: MONITOR
  IMPORTS LoganBerry, RpcPrivate: RPCLupine, Lupine: LupineRuntime,
      Atom, PrincOpsUtils, Rope
  EXPORTS LoganBerryRpcControl
  SHARES  LoganBerry, LoganBerryRpcControl, Rope
  = BEGIN OPEN LoganBerry, RpcControl: LoganBerryRpcControl, RpcPublic:
      RPC;


-- Standard remote binding routines.


  ImportInterface: PUBLIC ENTRY SAFE PROCEDURE [
        interface: RpcControl.InterfaceRecord,
        interfaceName: RpcPublic.InterfaceName,
        parameterStorage: RpcPublic.Zones ] =
    TRUSTED BEGIN ENABLE UNWIND => NULL;
    IsNull: PROCEDURE [string: Rope.ROPE] RETURNS [BOOLEAN] =
      INLINE {RETURN[string.Length[] = 0]};
        interface↑ ← [Error: Error, clientStubOpen: clientStubOpen,
            clientStubDescribe: clientStubDescribe, clientStubReadEntry:
            clientStubReadEntry, clientStubEnumerateEntries: clientStubEnumerateEntries,
            clientStubGenerateEntries: clientStubGenerateEntries, clientStubNextEntry:
            clientStubNextEntry, clientStubEndGenerate: clientStubEndGenerate,
            clientStubWriteEntry: clientStubWriteEntry, clientStubDeleteEntry:
            clientStubDeleteEntry, clientStubClose: clientStubClose, clientStubBuildIndices:
            clientStubBuildIndices, clientStubCompactLogs: clientStubCompactLogs];
    interface.myInterface ← RpcPrivate.ImportInterface [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "LoganBerry~210#224#2316577624",
        instance: interfaceName.instance,
        version: interfaceName.version ],
      localOnly: RpcControl.InterMdsCallsOnly,
      stubProtocol: RpcControl.LupineProtocolVersion ];
    interface.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 ];
    interface.bound ← TRUE;
    END;



-- Remote public procedure stubs.

  clientStubOpen: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      conv: Conv, dbName: ROPE] RETURNS [db: OpenDB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Open];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        db (0): OpenDB];
    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 ← 1;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: conv];
      argPkt.transferIndex ← Open;
      BEGIN  -- Marshal dbName: ROPE to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[dbName, pkt, pktLength, FALSE];
        END;  -- Marshal dbName.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 2, signalHandler: ClientDispatcher];
      [db: db] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[db];
      END;  -- UNWIND.
    END;  -- Open.

  clientStubDescribe: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      conv: Conv, db: OpenDB] RETURNS [info: SchemaInfo] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Describe, db (1):
        OpenDB];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: conv];
      argPkt↑ ← [db: db];
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 254, signalHandler: ClientDispatcher];
      pktLength ← 0;
      BEGIN  -- Unmarshal info: SchemaInfo from pkt.data[pktLength].
        BEGIN OPEN record: info;
        BEGIN  -- Unmarshal record.dbName: ROPE from pkt.data[pktLength].
          [record.dbName, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
              FALSE];
          END;  -- Unmarshal record.dbName.
        BEGIN  -- Unmarshal record.keys: LIST OF AttributeType from
            -- pkt.data[pktLength].
          lastNode: LIST OF AttributeType ← (record.keys ← 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
            thisNode2: LIST OF AttributeType = interface.paramZones.gc.CONS[--DefaultValue--,NIL];
            BEGIN  -- Unmarshal thisNode2.first: AttributeType from
                -- pkt.data[pktLength].
              [thisNode2.first, pktLength] ← Lupine.UnmarshalAtom[pkt,
                  pktLength];
              END;  -- Unmarshal thisNode2.first.
            IF lastNode # NIL
              THEN lastNode ← (lastNode.rest ← thisNode2)
              ELSE lastNode ← (record.keys ← thisNode2);
            listLength ← listLength - 1;
            ENDLOOP;  -- WHILE listLength > 0.
          END;  -- Unmarshal record.keys.
        BEGIN  -- Unmarshal record.indexNames: LIST OF ROPE from pkt.data[pktLength].
          lastNode: LIST OF ROPE ← (record.indexNames ← 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
            thisNode2: LIST OF ROPE = interface.paramZones.gc.CONS[--DefaultValue--,NIL];
            BEGIN  -- Unmarshal thisNode2.first: ROPE from pkt.data[pktLength].
              [thisNode2.first, pktLength] ← Lupine.UnmarshalRope[pkt,
                  pktLength, FALSE];
              END;  -- Unmarshal thisNode2.first.
            IF lastNode # NIL
              THEN lastNode ← (lastNode.rest ← thisNode2)
              ELSE lastNode ← (record.indexNames ← thisNode2);
            listLength ← listLength - 1;
            ENDLOOP;  -- WHILE listLength > 0.
          END;  -- Unmarshal record.indexNames.
        BEGIN  -- Unmarshal record.logs: LIST OF LogID from pkt.data[pktLength].
          lastNode: LIST OF LogID ← (record.logs ← 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
            thisNode2: LIST OF LogID = interface.paramZones.gc.CONS[--DefaultValue--,NIL];
            BEGIN
            IF pktLength+1 > RpcPrivate.maxDataLength
              THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength:
                  pktLength];
            thisNode2.first ← pkt.data[pktLength];  pktLength ← pktLength+1;
            END;
            IF lastNode # NIL
              THEN lastNode ← (lastNode.rest ← thisNode2)
              ELSE lastNode ← (record.logs ← thisNode2);
            listLength ← listLength - 1;
            ENDLOOP;  -- WHILE listLength > 0.
          END;  -- Unmarshal record.logs.
        BEGIN  -- Unmarshal record.logNames: LIST OF ROPE from pkt.data[pktLength].
          lastNode: LIST OF ROPE ← (record.logNames ← 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
            thisNode2: LIST OF ROPE = interface.paramZones.gc.CONS[--DefaultValue--,NIL];
            BEGIN  -- Unmarshal thisNode2.first: ROPE from pkt.data[pktLength].
              [thisNode2.first, pktLength] ← Lupine.UnmarshalRope[pkt,
                  pktLength, FALSE];
              END;  -- Unmarshal thisNode2.first.
            IF lastNode # NIL
              THEN lastNode ← (lastNode.rest ← thisNode2)
              ELSE lastNode ← (record.logNames ← thisNode2);
            listLength ← listLength - 1;
            ENDLOOP;  -- WHILE listLength > 0.
          END;  -- Unmarshal record.logNames.
        END;  -- OPEN record: info.
        END;  -- Unmarshal info.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[info];
      END;  -- UNWIND.
    END;  -- Describe.

  clientStubReadEntry: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      conv: Conv, db: OpenDB, key: AttributeType, value: AttributeValue]
    RETURNS [entry: Entry, others: BOOLEAN] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← ReadEntry, db (1):
        OpenDB];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        others (0): BOOLEAN];
    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 ← 3;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: conv];
      argPkt↑ ← [db: db];
      BEGIN  -- Marshal key: AttributeType to pkt.data[pktLength].
        pktLength ← Lupine.MarshalAtom[key, pkt, pktLength];
        END;  -- Marshal key.
      BEGIN  -- Marshal value: AttributeValue to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[value, pkt, pktLength, FALSE];
        END;  -- Marshal value.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 254, signalHandler: ClientDispatcher];
      pktLength ← 1;
      BEGIN  -- OnePkt.
        -- Move statics from pkt now.
        [others: others] ← resPkt↑;
      BEGIN  -- Unmarshal entry: Entry from pkt.data[pktLength].
        lastNode: Entry ← (entry ← 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: Entry = interface.paramZones.gc.CONS[--DefaultValue--,NIL];
          BEGIN  -- Unmarshal thisNode1.first: Attribute from pkt.data[pktLength].
            BEGIN OPEN record: thisNode1.first;
            BEGIN  -- Unmarshal record.type: AttributeType from pkt.data[pktLength].
              [record.type, pktLength] ← Lupine.UnmarshalAtom[pkt,
                  pktLength];
              END;  -- Unmarshal record.type.
            BEGIN  -- Unmarshal record.value: AttributeValue from pkt.data[pktLength].
              [record.value, pktLength] ← Lupine.UnmarshalRope[pkt,
                  pktLength, FALSE];
              END;  -- Unmarshal record.value.
            END;  -- OPEN record: thisNode1.first.
            END;  -- Unmarshal thisNode1.first.
          IF lastNode # NIL
            THEN lastNode ← (lastNode.rest ← thisNode1)
            ELSE lastNode ← (entry ← thisNode1);
          listLength ← listLength - 1;
          ENDLOOP;  -- WHILE listLength > 0.
        END;  -- Unmarshal entry.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
RETURN[entry, others];
      END;  -- OnePkt.
      END;  -- UNWIND.
    END;  -- ReadEntry.

  clientStubEnumerateEntries: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      db: OpenDB, key: AttributeType, start: AttributeValue, end: AttributeValue,
      proc: EntryProc] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← EnumerateEntries,
        db (1): OpenDB];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface];
      argPkt↑ ← [db: db];
      BEGIN  -- Marshal key: AttributeType to pkt.data[pktLength].
        pktLength ← Lupine.MarshalAtom[key, pkt, pktLength];
        END;  -- Marshal key.
      BEGIN  -- Marshal start: AttributeValue to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[start, pkt, pktLength, FALSE];
        END;  -- Marshal start.
      BEGIN  -- Marshal end: AttributeValue to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[end, pkt, pktLength, FALSE];
        END;  -- Marshal end.
-- ##### Error: Cannot YET marshal transfer (e.g., procedure) parameter.
    -- Identifier or type = EntryProc. --  Lupine.TranslationError;
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 0, signalHandler: ClientDispatcher];
      Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[];
      END;  -- UNWIND.
    END;  -- EnumerateEntries.

  clientStubGenerateEntries: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      conv: Conv, db: OpenDB, key: AttributeType, start: AttributeValue,
      end: AttributeValue]
    RETURNS [cursor: Cursor] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GenerateEntries,
        db (1): OpenDB];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        cursor (0): Cursor];
    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 ← 3;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: conv];
      argPkt↑ ← [db: db];
      BEGIN  -- Marshal key: AttributeType to pkt.data[pktLength].
        pktLength ← Lupine.MarshalAtom[key, pkt, pktLength];
        END;  -- Marshal key.
      BEGIN  -- Marshal start: AttributeValue to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[start, pkt, pktLength, FALSE];
        END;  -- Marshal start.
      BEGIN  -- Marshal end: AttributeValue to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[end, pkt, pktLength, FALSE];
        END;  -- Marshal end.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 2, signalHandler: ClientDispatcher];
      [cursor: cursor] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[cursor];
      END;  -- UNWIND.
    END;  -- GenerateEntries.

  clientStubNextEntry: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      conv: Conv, cursor: Cursor, dir: CursorDirection]
    RETURNS [entry: Entry] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← NextEntry, cursor
        (1): Cursor, dir (3): CursorDirection];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 4;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: conv];
      argPkt↑ ← [cursor: cursor, dir: dir];
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 254, signalHandler: ClientDispatcher];
      pktLength ← 0;
      BEGIN  -- Unmarshal entry: Entry from pkt.data[pktLength].
        lastNode: Entry ← (entry ← 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: Entry = interface.paramZones.gc.CONS[--DefaultValue--,NIL];
          BEGIN  -- Unmarshal thisNode1.first: Attribute from pkt.data[pktLength].
            BEGIN OPEN record: thisNode1.first;
            BEGIN  -- Unmarshal record.type: AttributeType from pkt.data[pktLength].
              [record.type, pktLength] ← Lupine.UnmarshalAtom[pkt,
                  pktLength];
              END;  -- Unmarshal record.type.
            BEGIN  -- Unmarshal record.value: AttributeValue from pkt.data[pktLength].
              [record.value, pktLength] ← Lupine.UnmarshalRope[pkt,
                  pktLength, FALSE];
              END;  -- Unmarshal record.value.
            END;  -- OPEN record: thisNode1.first.
            END;  -- Unmarshal thisNode1.first.
          IF lastNode # NIL
            THEN lastNode ← (lastNode.rest ← thisNode1)
            ELSE lastNode ← (entry ← thisNode1);
          listLength ← listLength - 1;
          ENDLOOP;  -- WHILE listLength > 0.
        END;  -- Unmarshal entry.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[entry];
      END;  -- UNWIND.
    END;  -- NextEntry.

  clientStubEndGenerate: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      conv: Conv, cursor: Cursor] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← EndGenerate, cursor
        (1): Cursor];
    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: interface.myInterface,
        localConversation: conv];
    argPkt↑ ← [cursor: cursor];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- EndGenerate.

  clientStubWriteEntry: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      conv: Conv, db: OpenDB, entry: Entry, log: LogID, replace: BOOLEAN]
      =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← WriteEntry, db (1):
        OpenDB, log (3): LogID, replace (4): BOOLEAN];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 5;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: conv];
      argPkt↑ ← [db: db, log: log, replace: replace];
      BEGIN  -- Marshal entry: Entry to pkt.data[pktLength].
        thisNode1: Entry;
        listLength: Lupine.ListHeader ← 0;
        FOR thisNode1 ← entry, 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 ← entry, thisNode1.rest UNTIL thisNode1 = NIL
            DO
          BEGIN  -- Marshal thisNode1.first: Attribute to pkt.data[pktLength].
            BEGIN OPEN record: thisNode1.first;
            BEGIN  -- Marshal record.type: AttributeType to pkt.data[pktLength].
              pktLength ← Lupine.MarshalAtom[record.type, pkt, pktLength];
              END;  -- Marshal record.type.
            BEGIN  -- Marshal record.value: AttributeValue to pkt.data[pktLength].
              pktLength ← Lupine.MarshalRope[record.value, pkt, pktLength,
                  FALSE];
              END;  -- Marshal record.value.
            END;  -- OPEN record: thisNode1.first.
            END;  -- Marshal thisNode1.first.
          ENDLOOP;  -- FOR thisNode1.
        END;  -- Marshal entry.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 0, signalHandler: ClientDispatcher];
      Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[];
      END;  -- UNWIND.
    END;  -- WriteEntry.

  clientStubDeleteEntry: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      conv: Conv, db: OpenDB, key: AttributeType, value: AttributeValue]
      =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← DeleteEntry, db
        (1): OpenDB];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: conv];
      argPkt↑ ← [db: db];
      BEGIN  -- Marshal key: AttributeType to pkt.data[pktLength].
        pktLength ← Lupine.MarshalAtom[key, pkt, pktLength];
        END;  -- Marshal key.
      BEGIN  -- Marshal value: AttributeValue to pkt.data[pktLength].
        pktLength ← Lupine.MarshalRope[value, pkt, pktLength, FALSE];
        END;  -- Marshal value.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 0, signalHandler: ClientDispatcher];
      Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[];
      END;  -- UNWIND.
    END;  -- DeleteEntry.

  clientStubClose: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      conv: Conv, db: OpenDB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Close, db (1): OpenDB];
    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: interface.myInterface,
        localConversation: conv];
    argPkt↑ ← [db: db];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- Close.

  clientStubBuildIndices: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      conv: Conv, db: OpenDB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← BuildIndices, db
        (1): OpenDB];
    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: interface.myInterface,
        localConversation: conv];
    argPkt↑ ← [db: db];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- BuildIndices.

  clientStubCompactLogs: PUBLIC SAFE PROCEDURE [interface: RpcControl.InterfaceRecord,
      conv: Conv, db: OpenDB] =
    TRUSTED BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← CompactLogs, db
        (1): OpenDB];
    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: interface.myInterface,
        localConversation: conv];
    argPkt↑ ← [db: db];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- CompactLogs.


--Remote public signals and errors are imported from the interface.


-- 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
      Error => RETURN[
        ErrorStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      ENDCASE => RETURN[Lupine.DispatchingError[]];

    END;  -- ClientDispatcher


-- Public signal and error dispatcher stubs.

  ErrorStub: --ERROR [ec: ErrorCode, explanation: ROPE]-- RpcPrivate.Dispatcher
      =
    INLINE BEGIN
    ec: ErrorCode;
    explanation: ROPE;
    pktLength: RpcPrivate.DataLength ← 1;
    BEGIN  -- Unmarshal ec: ErrorCode from pkt.data[pktLength].
      [ec, pktLength] ← Lupine.UnmarshalAtom[pkt, pktLength];
      END;  -- Unmarshal ec.
    BEGIN  -- Unmarshal explanation: ROPE from pkt.data[pktLength].
      [explanation, pktLength] ← Lupine.UnmarshalRope[pkt, pktLength,
          FALSE];
      END;  -- Unmarshal explanation.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    ERROR Error[ec, explanation];
    END;  -- ErrorStub.


-- Marshall/Unmarshal procedures.


-- No module initialization.

END.  -- LoganBerryRpcClientImpl.