-- Stub file  was translated on February 1, 1984 5:21:59 pm PST by Lupine of December 20, 1983 1:22:57 pm PST
-- Source interface AlpineFile came from file AlpineFile.bcd, which was created on February 1, 1984 5:21:52 pm PST with version stamp 151#27#13440653423 from source of October 28, 1983 12:51:11 pm PDT.

-- The RPC stub modules for AlpineFile are:
--   AlpineFileRpcControl.mesa;
--   AlpineFileRpcClientImpl.mesa;
--   AlpineFileRpcBinderImpl.mesa;
--   AlpineFileRpcServerImpl.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 = 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
  AlpineEnvironment,
  AlpineFile,
  AlpineFileRpcControl 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]--;


AlpineFileRpcClientImpl: MONITOR
  IMPORTS AlpineFile, RpcPrivate: RPCLupine, Lupine: LupineRuntime,
      Atom, Rope
  EXPORTS AlpineFile, AlpineFileRpcControl
  SHARES  AlpineFile, AlpineFileRpcControl, Rope
  = BEGIN OPEN AlpineFile, RpcControl: AlpineFileRpcControl, 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 "AlpineFile~151#27#13440653423",
        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.

  Open: PUBLIC PROCEDURE [conversation: Conversation, transID: TransID,
      universalFile: UniversalFile, access: AccessRights, lock: LockOption,
      recoveryOption: RecoveryOption, referencePattern: ReferencePattern]
    RETURNS [--openFileID:-- OpenFileID, --fileID:-- FileID] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Open, transID (1):
        TransID, universalFile (10): UniversalFile, access (19): AccessRights,
        lock (20): LockOption, recoveryOption (21): RecoveryOption, referencePattern
        (22): ReferencePattern];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        openFileID (0): OpenFileID, fileID (2): FileID];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+23] 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 ← 23;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        conversation];
    argPkt↑ ← [transID: transID, universalFile: universalFile, access:
        access, lock: lock, recoveryOption: recoveryOption, referencePattern:
        referencePattern];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 6, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 6];
    RETURN[resPkt.openFileID, resPkt.fileID];
    END;  -- Open.

  Create: PUBLIC PROCEDURE [conversation: Conversation, transID: TransID,
      volumeID: VolOrVolGroupID, owner: OwnerName, initialSize: PageCount,
      recoveryOption: RecoveryOption, referencePattern: ReferencePattern]
    RETURNS [--openFileID:-- OpenFileID, --universalFile:-- UniversalFile]
        =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Create, transID
        (1): TransID, volumeID (10): VolOrVolGroupID, initialSize (15):
        PageCount, recoveryOption (17): RecoveryOption, referencePattern
        (18): ReferencePattern];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        openFileID (0): OpenFileID, universalFile (2): UniversalFile];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+53] 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 ← 19;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        conversation];
    argPkt↑ ← [transID: transID, volumeID: volumeID, initialSize: initialSize,
        recoveryOption: recoveryOption, referencePattern: referencePattern];
    BEGIN  -- Marshal owner: OwnerName to pkt.data[pktLength].
      pkt.data[pktLength] ← owner=NIL;  pktLength ← pktLength+1;
      IF owner # NIL
        THEN BEGIN
          textRope: Rope.Text = Rope.InlineFlatten[r: owner];
          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 owner # NIL.
      END;  -- Marshal owner.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 11, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 11];
    RETURN[resPkt.openFileID, resPkt.universalFile];
    END;  -- Create.

  Close: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Close, openFileID
        (1): OpenFileID];
    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:
        conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- Close.

  Delete: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← Delete, openFileID
        (1): OpenFileID];
    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:
        conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- Delete.

  GetUniversalFile: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID] RETURNS [--universalFile:-- UniversalFile] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetUniversalFile,
        openFileID (1): OpenFileID];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        universalFile (0): UniversalFile];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+9] 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:
        conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 9, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 9];
    RETURN[resPkt.universalFile];
    END;  -- GetUniversalFile.

  GetTransID: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID] RETURNS [--transID:-- TransID] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetTransID, openFileID
        (1): OpenFileID];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transID (0): TransID];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+9] 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:
        conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 9, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 9];
    RETURN[resPkt.transID];
    END;  -- GetTransID.

  GetAccessRights: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID] RETURNS [--access:-- AccessRights] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetAccessRights,
        openFileID (1): OpenFileID];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        access (0): AccessRights];
    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:
        conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.access];
    END;  -- GetAccessRights.

  GetLockOption: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID] RETURNS [--lock:-- LockOption] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetLockOption, openFileID
        (1): OpenFileID];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        lock (0): LockOption];
    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:
        conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.lock];
    END;  -- GetLockOption.

  SetLockOption: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID, lock: LockOption] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetLockOption, openFileID
        (1): OpenFileID, lock (3): LockOption];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+4] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 4;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        conversation];
    argPkt↑ ← [openFileID: openFileID, lock: lock];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- SetLockOption.

  GetRecoveryOption: PUBLIC PROCEDURE [conversation: Conversation,
      openFileID: OpenFileID] RETURNS [--recoveryOption:-- RecoveryOption]
      =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetRecoveryOption,
        openFileID (1): OpenFileID];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        recoveryOption (0): RecoveryOption];
    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:
        conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.recoveryOption];
    END;  -- GetRecoveryOption.

  GetReferencePattern: PUBLIC PROCEDURE [conversation: Conversation,
      openFileID: OpenFileID] RETURNS [--referencePattern:-- ReferencePattern]
      =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetReferencePattern,
        openFileID (1): OpenFileID];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        referencePattern (0): ReferencePattern];
    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:
        conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[resPkt.referencePattern];
    END;  -- GetReferencePattern.

  SetReferencePattern: PUBLIC PROCEDURE [conversation: Conversation,
      openFileID: OpenFileID, referencePattern: ReferencePattern] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetReferencePattern,
        openFileID (1): OpenFileID, referencePattern (3): ReferencePattern];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+4] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 4;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        conversation];
    argPkt↑ ← [openFileID: openFileID, referencePattern: referencePattern];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- SetReferencePattern.

  ReadPages: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID, pageRun: PageRun, pageBuffer: RESULTPageBuffer, lock:
      LockOption] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← ReadPages, openFileID
        (1): OpenFileID, pageRun (3): PageRun, lock (6): LockOption];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+254] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 7;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        conversation];
    argPkt↑ ← [openFileID: openFileID, pageRun: pageRun, lock: lock];
    BEGIN  -- Marshal pageBuffer: RESULTPageBuffer to pkt.data[pktLength].
      Lupine.StubPktDoubleWord[pkt, pktLength]↑ ← (IF BASE[pageBuffer]=NIL
          THEN 0 ELSE LENGTH[pageBuffer]);
      pktLength ← pktLength + 2;
      IF BASE[pageBuffer] # NIL THEN
        NULL;  -- Call by result, send length only.
      END;  -- Marshal pageBuffer.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 254, signalHandler: ClientDispatcher];
    pktLength ← 0;
    BEGIN  -- Unmarshal pageBuffer: RESULTPageBuffer from pkt.data[pktLength].
      DescriptorType: TYPE = RECORD [SEQUENCE COMPUTED CARDINAL OF
          WORD];
      descLength: Lupine.SequenceHeader;
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength:
            pktLength];
      descLength ← Lupine.StubPktDoubleWord[pkt, pktLength]↑;
      pktLength ← pktLength + 2;
      IF descLength # (IF BASE[pageBuffer]=NIL THEN 0 ELSE LENGTH[pageBuffer])
        THEN Lupine.UnmarshalingError;
      NULL;  -- Call by var or result, use existing descriptor.
      pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
          dataAdr: BASE[pageBuffer], dataLength: SIZE[WORD]*LENGTH[pageBuffer],
          alwaysOnePkt: FALSE];
      END;  -- Unmarshal pageBuffer.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    RETURN[];
    END;  -- ReadPages.

  WritePages: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID, pageRun: PageRun, pageBuffer: VALUEPageBuffer, lock:
      LockOption] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← WritePages, openFileID
        (1): OpenFileID, pageRun (3): PageRun, lock (6): LockOption];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+254] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 7;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        conversation];
    argPkt↑ ← [openFileID: openFileID, pageRun: pageRun, lock: lock];
    BEGIN  -- Marshal pageBuffer: VALUEPageBuffer to pkt.data[pktLength].
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
      Lupine.StubPktDoubleWord[pkt, pktLength]↑ ← (IF BASE[pageBuffer]=NIL
          THEN 0 ELSE LENGTH[pageBuffer]);
      pktLength ← pktLength + 2;
      IF BASE[pageBuffer] # NIL THEN
        pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
            dataAdr: BASE[pageBuffer], dataLength: SIZE[WORD]*LENGTH[pageBuffer],
            alwaysOnePkt: FALSE];
      END;  -- Marshal pageBuffer.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- WritePages.

  LockPages: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID, pageRun: PageRun, lock: LockOption] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← LockPages, openFileID
        (1): OpenFileID, pageRun (3): PageRun, lock (6): LockOption];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+7] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 7;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        conversation];
    argPkt↑ ← [openFileID: openFileID, pageRun: pageRun, lock: lock];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- LockPages.

  UnlockPages: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID, pageRun: PageRun] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← UnlockPages, openFileID
        (1): OpenFileID, pageRun (3): PageRun];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+6] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 6;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        conversation];
    argPkt↑ ← [openFileID: openFileID, pageRun: pageRun];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- UnlockPages.

  ReadProperties: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID, desiredProperties: PropertySet, lock: LockOption]
    RETURNS [properties: LIST OF PropertyValuePair] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← ReadProperties,
        openFileID (1): OpenFileID, desiredProperties (3): PropertySet,
        lock (4): LockOption];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+254] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 5;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        conversation];
    argPkt↑ ← [openFileID: openFileID, desiredProperties: desiredProperties,
        lock: lock];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 254, signalHandler: ClientDispatcher];
    pktLength ← 0;
    BEGIN  -- Unmarshal properties: LIST OF PropertyValuePair from
        -- pkt.data[pktLength].
      lastNode: LIST OF PropertyValuePair ← (properties ← NIL);
      listLength: Lupine.ListHeader;
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength:
            pktLength];
      listLength ← Lupine.StubPktDoubleWord[pkt, pktLength]↑;
      pktLength ← pktLength + 2;
      WHILE listLength > 0 DO
        thisNode1: LIST OF PropertyValuePair = paramZones.gc.CONS[--DefaultValue--,NIL];
        BEGIN  -- Unmarshal thisNode1.first: PropertyValuePair from
            -- pkt.data[pktLength].
          pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: @thisNode1.first, dataLength: SIZE[PropertyValuePair],
              alwaysOnePkt: FALSE];
          -- Restore garbled REFs to NIL following copy.
          BEGIN OPEN record: thisNode1.first;
          WITH variant: record SELECT FROM
            modifyAccess =>
              BEGIN OPEN record: variant;
              LOOPHOLE[record.modifyAccess, LONG POINTER] ← NIL;
              END;  -- OPEN record: variant.
            owner =>
              BEGIN OPEN record: variant;
              LOOPHOLE[record.owner, LONG POINTER] ← NIL;
              END;  -- OPEN record: variant.
            readAccess =>
              BEGIN OPEN record: variant;
              LOOPHOLE[record.readAccess, LONG POINTER] ← NIL;
              END;  -- OPEN record: variant.
            stringName =>
              BEGIN OPEN record: variant;
              LOOPHOLE[record.stringName, LONG POINTER] ← NIL;
              END;  -- OPEN record: variant.
            ENDCASE => NULL;  -- WITH variant: record.
          END;  -- OPEN record: thisNode1.first.
          BEGIN OPEN record: thisNode1.first;
          WITH variant: record SELECT FROM
            modifyAccess =>
              BEGIN  -- Unmarshal variant: RECORD [modifyAccess: AccessList]
                  -- from pkt.data[pktLength].
                BEGIN OPEN record: variant;
                BEGIN  -- Unmarshal record.modifyAccess: AccessList
                    -- from pkt.data[pktLength].
                  lastNode: AccessList ← (record.modifyAccess ← NIL);
                  listLength: Lupine.ListHeader;
                  IF pktLength+2 > RpcPrivate.maxDataLength
                    THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt,
                        pktLength: pktLength];
                  listLength ← Lupine.StubPktDoubleWord[pkt, pktLength]↑;
                  pktLength ← pktLength + 2;
                  WHILE listLength > 0 DO
                    thisNode5: AccessList = paramZones.gc.CONS[--DefaultValue--,NIL];
                    BEGIN  -- Unmarshal thisNode5.first: RName from
                        -- pkt.data[pktLength].
                      ropeIsNIL: Lupine.NilHeader;
                      IF pktLength+2 > RpcPrivate.maxDataLength
                        THEN pktLength ← Lupine.FinishThisPkt[pkt:
                            pkt, pktLength: pktLength];
                      ropeIsNIL ← pkt.data[pktLength];  pktLength ←
                          pktLength+1;
                      IF ropeIsNIL
                        THEN thisNode5.first ← NIL
                        ELSE BEGIN
                          ropeLength: Lupine.RopeHeader;
                          textRope: Rope.Text;
                          ropeLength ← pkt.data[pktLength];  pktLength
                              ← pktLength+1;
                          IF ropeLength > RpcPrivate.maxShortStringLength
                            THEN Lupine.UnmarshalingError;
                          thisNode5.first ← textRope ← Rope.NewText[size:
                              ropeLength];
                          pktLength ← Lupine.CopyFromPkt[pkt: pkt,
                              pktLength: pktLength, dataAdr: BASE[DESCRIPTOR[textRope.text]],
                              dataLength: Lupine.WordsForChars[ropeLength],
                              alwaysOnePkt: FALSE];
                          END;  -- IF ropeIsNIL.
                      END;  -- Unmarshal thisNode5.first.
                    IF lastNode # NIL
                      THEN lastNode ← (lastNode.rest ← thisNode5)
                      ELSE lastNode ← (record.modifyAccess ← thisNode5);
                    listLength ← listLength - 1;
                    ENDLOOP;  -- WHILE listLength > 0.
                  END;  -- Unmarshal record.modifyAccess.
                END;  -- OPEN record: variant.
                END;  -- Unmarshal variant.
            owner =>
              BEGIN  -- Unmarshal variant: RECORD [owner: OwnerName]
                  -- from pkt.data[pktLength].
                BEGIN OPEN record: variant;
                BEGIN  -- Unmarshal record.owner: OwnerName from pkt.data[pktLength].
                  ropeIsNIL: Lupine.NilHeader;
                  IF pktLength+2 > RpcPrivate.maxDataLength
                    THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt,
                        pktLength: pktLength];
                  ropeIsNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
                  IF ropeIsNIL
                    THEN record.owner ← NIL
                    ELSE BEGIN
                      ropeLength: Lupine.RopeHeader;
                      textRope: Rope.Text;
                      ropeLength ← pkt.data[pktLength];  pktLength
                          ← pktLength+1;
                      IF ropeLength > RpcPrivate.maxShortStringLength
                        THEN Lupine.UnmarshalingError;
                      record.owner ← textRope ← Rope.NewText[size:
                          ropeLength];
                      pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength:
                          pktLength, dataAdr: BASE[DESCRIPTOR[textRope.text]],
                          dataLength: Lupine.WordsForChars[ropeLength],
                          alwaysOnePkt: FALSE];
                      END;  -- IF ropeIsNIL.
                  END;  -- Unmarshal record.owner.
                END;  -- OPEN record: variant.
                END;  -- Unmarshal variant.
            readAccess =>
              BEGIN  -- Unmarshal variant: RECORD [readAccess: AccessList]
                  -- from pkt.data[pktLength].
                BEGIN OPEN record: variant;
                BEGIN  -- Unmarshal record.readAccess: AccessList from
                    -- pkt.data[pktLength].
                  lastNode: AccessList ← (record.readAccess ← NIL);
                  listLength: Lupine.ListHeader;
                  IF pktLength+2 > RpcPrivate.maxDataLength
                    THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt,
                        pktLength: pktLength];
                  listLength ← Lupine.StubPktDoubleWord[pkt, pktLength]↑;
                  pktLength ← pktLength + 2;
                  WHILE listLength > 0 DO
                    thisNode5: AccessList = paramZones.gc.CONS[--DefaultValue--,NIL];
                    BEGIN  -- Unmarshal thisNode5.first: RName from
                        -- pkt.data[pktLength].
                      ropeIsNIL: Lupine.NilHeader;
                      IF pktLength+2 > RpcPrivate.maxDataLength
                        THEN pktLength ← Lupine.FinishThisPkt[pkt:
                            pkt, pktLength: pktLength];
                      ropeIsNIL ← pkt.data[pktLength];  pktLength ←
                          pktLength+1;
                      IF ropeIsNIL
                        THEN thisNode5.first ← NIL
                        ELSE BEGIN
                          ropeLength: Lupine.RopeHeader;
                          textRope: Rope.Text;
                          ropeLength ← pkt.data[pktLength];  pktLength
                              ← pktLength+1;
                          IF ropeLength > RpcPrivate.maxShortStringLength
                            THEN Lupine.UnmarshalingError;
                          thisNode5.first ← textRope ← Rope.NewText[size:
                              ropeLength];
                          pktLength ← Lupine.CopyFromPkt[pkt: pkt,
                              pktLength: pktLength, dataAdr: BASE[DESCRIPTOR[textRope.text]],
                              dataLength: Lupine.WordsForChars[ropeLength],
                              alwaysOnePkt: FALSE];
                          END;  -- IF ropeIsNIL.
                      END;  -- Unmarshal thisNode5.first.
                    IF lastNode # NIL
                      THEN lastNode ← (lastNode.rest ← thisNode5)
                      ELSE lastNode ← (record.readAccess ← thisNode5);
                    listLength ← listLength - 1;
                    ENDLOOP;  -- WHILE listLength > 0.
                  END;  -- Unmarshal record.readAccess.
                END;  -- OPEN record: variant.
                END;  -- Unmarshal variant.
            stringName =>
              BEGIN  -- Unmarshal variant: RECORD [stringName: Rope.ROPE]
                  -- from pkt.data[pktLength].
                BEGIN OPEN record: variant;
                BEGIN  -- Unmarshal record.stringName: Rope.ROPE from
                    -- pkt.data[pktLength].
                  ropeIsNIL: Lupine.NilHeader;
                  IF pktLength+2 > RpcPrivate.maxDataLength
                    THEN pktLength ← Lupine.FinishThisPkt[pkt: pkt,
                        pktLength: pktLength];
                  ropeIsNIL ← pkt.data[pktLength];  pktLength ← pktLength+1;
                  IF ropeIsNIL
                    THEN record.stringName ← NIL
                    ELSE BEGIN
                      ropeLength: Lupine.RopeHeader;
                      textRope: Rope.Text;
                      ropeLength ← pkt.data[pktLength];  pktLength
                          ← pktLength+1;
                      IF ropeLength > LAST[NAT]
                        THEN Lupine.UnmarshalingError;
                      record.stringName ← textRope ← Rope.NewText[size:
                          ropeLength];
                      pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength:
                          pktLength, dataAdr: BASE[DESCRIPTOR[textRope.text]],
                          dataLength: Lupine.WordsForChars[ropeLength],
                          alwaysOnePkt: FALSE];
                      END;  -- IF ropeIsNIL.
                  END;  -- Unmarshal record.stringName.
                END;  -- OPEN record: variant.
                END;  -- Unmarshal variant.
            ENDCASE => NULL;  -- WITH variant: record.
          END;  -- OPEN record: thisNode1.first.
          END;  -- Unmarshal thisNode1.first.
        IF lastNode # NIL
          THEN lastNode ← (lastNode.rest ← thisNode1)
          ELSE lastNode ← (properties ← thisNode1);
        listLength ← listLength - 1;
        ENDLOOP;  -- WHILE listLength > 0.
      END;  -- Unmarshal properties.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    RETURN[properties];
    END;  -- ReadProperties.

  WriteProperties: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID, properties: LIST OF PropertyValuePair, lock: LockOption]
      =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← WriteProperties,
        openFileID (1): OpenFileID, lock (3): LockOption];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+254] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 4;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        conversation];
    argPkt↑ ← [openFileID: openFileID, lock: lock];
    BEGIN  -- Marshal properties: LIST OF PropertyValuePair to pkt.data[pktLength].
      thisNode1: LIST OF PropertyValuePair;
      listLength: Lupine.ListHeader ← 0;
      FOR thisNode1 ← properties, thisNode1.rest UNTIL thisNode1 =
          NIL DO
        listLength ← listLength + 1;  ENDLOOP;
      IF pktLength+2 > RpcPrivate.maxDataLength
        THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
      Lupine.StubPktDoubleWord[pkt, pktLength]↑ ← listLength;
      pktLength ← pktLength + 2;
      FOR thisNode1 ← properties, thisNode1.rest UNTIL thisNode1 =
          NIL DO
        BEGIN  -- Marshal thisNode1.first: PropertyValuePair to pkt.data[pktLength].
          pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
              dataAdr: @thisNode1.first, dataLength: SIZE[PropertyValuePair],
              alwaysOnePkt: FALSE];
          BEGIN OPEN record: thisNode1.first;
          WITH variant: record SELECT FROM
            modifyAccess =>
              BEGIN  -- Marshal variant: RECORD [modifyAccess: AccessList]
                  -- to pkt.data[pktLength].
                BEGIN OPEN record: variant;
                BEGIN  -- Marshal record.modifyAccess: AccessList to
                    -- pkt.data[pktLength].
                  thisNode5: AccessList;
                  listLength: Lupine.ListHeader ← 0;
                  FOR thisNode5 ← record.modifyAccess, thisNode5.rest
                      UNTIL thisNode5 = NIL DO
                    listLength ← listLength + 1;  ENDLOOP;
                  IF pktLength+2 > RpcPrivate.maxDataLength
                    THEN pktLength ← Lupine.StartNextPkt[pkt: pkt,
                        pktLength: pktLength];
                  Lupine.StubPktDoubleWord[pkt, pktLength]↑ ← listLength;
                  pktLength ← pktLength + 2;
                  FOR thisNode5 ← record.modifyAccess, thisNode5.rest
                      UNTIL thisNode5 = NIL DO
                    BEGIN  -- Marshal thisNode5.first: RName to pkt.data[pktLength].
                      IF pktLength+2 > RpcPrivate.maxDataLength
                        THEN pktLength ← Lupine.StartNextPkt[pkt: pkt,
                            pktLength: pktLength];
                      pkt.data[pktLength] ← thisNode5.first=NIL;  pktLength
                          ← pktLength+1;
                      IF thisNode5.first # NIL
                        THEN BEGIN
                          textRope: Rope.Text = Rope.InlineFlatten[r:
                              thisNode5.first];
                          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: FALSE];
                          END;  -- IF thisNode5.first # NIL.
                      END;  -- Marshal thisNode5.first.
                    ENDLOOP;  -- FOR thisNode5.
                  END;  -- Marshal record.modifyAccess.
                END;  -- OPEN record: variant.
                END;  -- Marshal variant.
            owner =>
              BEGIN  -- Marshal variant: RECORD [owner: OwnerName]
                  -- to pkt.data[pktLength].
                BEGIN OPEN record: variant;
                BEGIN  -- Marshal record.owner: OwnerName to pkt.data[pktLength].
                  IF pktLength+2 > RpcPrivate.maxDataLength
                    THEN pktLength ← Lupine.StartNextPkt[pkt: pkt,
                        pktLength: pktLength];
                  pkt.data[pktLength] ← record.owner=NIL;  pktLength
                      ← pktLength+1;
                  IF record.owner # NIL
                    THEN BEGIN
                      textRope: Rope.Text = Rope.InlineFlatten[r: record.owner];
                      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: FALSE];
                      END;  -- IF record.owner # NIL.
                  END;  -- Marshal record.owner.
                END;  -- OPEN record: variant.
                END;  -- Marshal variant.
            readAccess =>
              BEGIN  -- Marshal variant: RECORD [readAccess: AccessList]
                  -- to pkt.data[pktLength].
                BEGIN OPEN record: variant;
                BEGIN  -- Marshal record.readAccess: AccessList to
                    -- pkt.data[pktLength].
                  thisNode5: AccessList;
                  listLength: Lupine.ListHeader ← 0;
                  FOR thisNode5 ← record.readAccess, thisNode5.rest
                      UNTIL thisNode5 = NIL DO
                    listLength ← listLength + 1;  ENDLOOP;
                  IF pktLength+2 > RpcPrivate.maxDataLength
                    THEN pktLength ← Lupine.StartNextPkt[pkt: pkt,
                        pktLength: pktLength];
                  Lupine.StubPktDoubleWord[pkt, pktLength]↑ ← listLength;
                  pktLength ← pktLength + 2;
                  FOR thisNode5 ← record.readAccess, thisNode5.rest
                      UNTIL thisNode5 = NIL DO
                    BEGIN  -- Marshal thisNode5.first: RName to pkt.data[pktLength].
                      IF pktLength+2 > RpcPrivate.maxDataLength
                        THEN pktLength ← Lupine.StartNextPkt[pkt: pkt,
                            pktLength: pktLength];
                      pkt.data[pktLength] ← thisNode5.first=NIL;  pktLength
                          ← pktLength+1;
                      IF thisNode5.first # NIL
                        THEN BEGIN
                          textRope: Rope.Text = Rope.InlineFlatten[r:
                              thisNode5.first];
                          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: FALSE];
                          END;  -- IF thisNode5.first # NIL.
                      END;  -- Marshal thisNode5.first.
                    ENDLOOP;  -- FOR thisNode5.
                  END;  -- Marshal record.readAccess.
                END;  -- OPEN record: variant.
                END;  -- Marshal variant.
            stringName =>
              BEGIN  -- Marshal variant: RECORD [stringName: Rope.ROPE]
                  -- to pkt.data[pktLength].
                BEGIN OPEN record: variant;
                BEGIN  -- Marshal record.stringName: Rope.ROPE to pkt.data[pktLength].
                  IF pktLength+2 > RpcPrivate.maxDataLength
                    THEN pktLength ← Lupine.StartNextPkt[pkt: pkt,
                        pktLength: pktLength];
                  pkt.data[pktLength] ← record.stringName=NIL;  pktLength
                      ← pktLength+1;
                  IF record.stringName # NIL
                    THEN BEGIN
                      textRope: Rope.Text = Rope.InlineFlatten[r: record.stringName];
                      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: FALSE];
                      END;  -- IF record.stringName # NIL.
                  END;  -- Marshal record.stringName.
                END;  -- OPEN record: variant.
                END;  -- Marshal variant.
            ENDCASE => NULL;  -- WITH variant: record.
          END;  -- OPEN record: thisNode1.first.
          END;  -- Marshal thisNode1.first.
        ENDLOOP;  -- FOR thisNode1.
      END;  -- Marshal properties.
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- WriteProperties.

  UnlockVersion: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← UnlockVersion, openFileID
        (1): OpenFileID];
    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:
        conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- UnlockVersion.

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

  GetSize: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID, lock: LockOption]
    RETURNS [--size:-- PageCount] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← GetSize, openFileID
        (1): OpenFileID, lock (3): LockOption];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        size (0): PageCount];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+4] 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:
        conversation];
    argPkt↑ ← [openFileID: openFileID, lock: lock];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 2, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[resPkt.size];
    END;  -- GetSize.

  SetSize: PUBLIC PROCEDURE [conversation: Conversation, openFileID:
      OpenFileID, size: PageCount, lock: LockOption] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← SetSize, openFileID
        (1): OpenFileID, size (3): PageCount, lock (5): LockOption];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+6] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 6;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: myInterface, localConversation:
        conversation];
    argPkt↑ ← [openFileID: openFileID, size: size, lock: lock];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 0, signalHandler: ClientDispatcher];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 0];
    RETURN[];
    END;  -- SetSize.


--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
      AccessFailed => RETURN[
        AccessFailedStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      LockFailed => RETURN[
        LockFailedStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      OperationFailed => RETURN[
        OperationFailedStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      StaticallyInvalid => RETURN[
        StaticallyInvalidStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      Unknown => RETURN[
        UnknownStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      PossiblyDamaged => RETURN[
        PossiblyDamagedStub[pkt: pkt, callLength: callLength, lastPkt:
            lastPkt, localConversation: localConversation]];
      ENDCASE => RETURN[Lupine.DispatchingError[]];

    END;  -- ClientDispatcher


-- Public signal and error dispatcher stubs.

  AccessFailedStub: --ERROR [missingAccess: AlpineEnvironment.NeededAccess]--
      RpcPrivate.Dispatcher =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.SignalIndex, missingAccess (1): AlpineEnvironment.NeededAccess];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    ERROR AccessFailed[argPkt.missingAccess];
    END;  -- AccessFailedStub.

  LockFailedStub: --ERROR [why: AlpineEnvironment.LockFailure]-- RpcPrivate.Dispatcher
      =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.SignalIndex, why (1): AlpineEnvironment.LockFailure];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    ERROR LockFailed[argPkt.why];
    END;  -- LockFailedStub.

  OperationFailedStub: --ERROR [why: AlpineEnvironment.OperationFailure]--
      RpcPrivate.Dispatcher =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.SignalIndex, why (1): AlpineEnvironment.OperationFailure];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    ERROR OperationFailed[argPkt.why];
    END;  -- OperationFailedStub.

  StaticallyInvalidStub: --ERROR-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    ERROR StaticallyInvalid[];
    END;  -- StaticallyInvalidStub.

  UnknownStub: --ERROR [what: AlpineEnvironment.UnknownType]-- RpcPrivate.Dispatcher
      =
    INLINE BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.SignalIndex, what (1): AlpineEnvironment.UnknownType];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    ERROR Unknown[argPkt.what];
    END;  -- UnknownStub.

  PossiblyDamagedStub: --SIGNAL-- RpcPrivate.Dispatcher =
    INLINE BEGIN
    pktLength: RpcPrivate.DataLength;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    SIGNAL PossiblyDamaged[];
    pktLength ← 0;
    RETURN[returnLength: pktLength];
    END;  -- PossiblyDamagedStub.


-- No module initialization.

END.  -- AlpineFileRpcClientImpl.