-- Copyright (C) 1987 by Xerox Corporation.  All rights reserved.
-- Stub file  was translated on March 25, 1987 3:05:39 pm PST by Lupine of January 22, 1987 5:37:32 pm PST
-- Source interface AlpineFile came from file AlpineFile.bcd, which was created on March 25, 1987 12:09:49 pm PST with version stamp 257#330#25514770454 from source of June 16, 1986 10:44:04 am 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 [InterfaceRecord, InterMdsCallsOnly, LupineProtocolVersion,
      ProcedureIndex, SignalIndex],
  RPC --USING SOME OF [InterfaceName, standardZones, Zones]--,
  RPCLupine --USING SOME OF [Alloc, Call, DataLength, DeAlloc, Dispatcher,
      -- GetPkt, GetStubPkt, ImportHandle, ImportInterface, ImportInterfaceWithHost,
      -- maxDataLength, maxPrincipalLength, maxShortStringLength, noHost,
      -- pktOverhead, ReceiveExtraPkt, RPCHost, SendPrelimPkt, StartCall,
      -- StartSignal, StubPkt, UnimportInterface]--,
  LupineRuntime --USING SOME OF [BindingError, CheckPktLength, CopyFromPkt,
      -- CopyFromMultiplePkts, CopyToPkt, CopyToMultiplePkts, defaultZones,
      -- DispatchingError, FinishThisPkt, ListHeader, MarshalingError,
      -- MarshalingExprError, MarshalAtom, MarshalRope, NilHeader, ProtocolError,
      -- RopeHeader, RpcPktDoubleWord, RuntimeError, SequenceHeader, SHORT,
      -- StartNextPkt, StringHeader, StubPktDoubleWord, TranslationError,
      -- UnmarshalingError, UnmarshalingExprError, UnmarshalAtom, UnmarshalRope,
      -- WordsForChars]--,
  Atom --USING SOME OF [GetPName, MakeAtom]--,
  PrincOpsUtils --USING SOME OF [Enter, Exit]--,
  Rope --USING SOME OF [InlineFlatten, Length, NewText, Text]--,
  VM --USING SOME OF [AddressForPageNumber, PageCount, PageNumber,
      -- PageNumberForAddress, PagesForWords]--;


AlpineFileRpcClientImpl: MONITOR
  IMPORTS AlpineFile, RpcPrivate: RPCLupine, Lupine: LupineRuntime,
      Atom, PrincOpsUtils, Rope
  EXPORTS AlpineFileRpcControl
  SHARES  AlpineFile, AlpineFileRpcControl, Rope
  = BEGIN OPEN AlpineFile, RpcControl: AlpineFileRpcControl, RpcPublic:
      RPC;


-- Standard remote binding routines.


  ImportInterface: PUBLIC ENTRY SAFE PROCEDURE [
        interface: RpcControl.InterfaceRecord,
        interfaceName: RpcPublic.InterfaceName,
        parameterStorage: RpcPublic.Zones,
        hostHint: RpcPrivate.RPCHost←RpcPrivate.noHost ] =
    TRUSTED BEGIN ENABLE UNWIND => NULL;
    IsNull: PROCEDURE [string: Rope.ROPE] RETURNS [BOOLEAN] =
      INLINE {RETURN[string.Length[] = 0]};
        interface↑ ← [clientStubOpen: clientStubOpen, clientStubCreate:
            clientStubCreate, clientStubClose: clientStubClose, clientStubDelete:
            clientStubDelete, clientStubGetUniversalFile: clientStubGetUniversalFile,
            clientStubGetTransID: clientStubGetTransID, clientStubGetAccessRights:
            clientStubGetAccessRights, clientStubGetLockOption: clientStubGetLockOption,
            clientStubSetLockOption: clientStubSetLockOption, clientStubGetRecoveryOption:
            clientStubGetRecoveryOption, clientStubGetReferencePattern:
            clientStubGetReferencePattern, clientStubSetReferencePattern:
            clientStubSetReferencePattern, clientStubReadPages: clientStubReadPages,
            clientStubWritePages: clientStubWritePages, clientStubLockPages:
            clientStubLockPages, clientStubUnlockPages: clientStubUnlockPages,
            clientStubValidateCachePageLock: clientStubValidateCachePageLock,
            clientStubValidateCachePageLocks: clientStubValidateCachePageLocks,
            clientStubReadProperties: clientStubReadProperties, clientStubWriteProperties:
            clientStubWriteProperties, clientStubReadUserProperties: clientStubReadUserProperties,
            clientStubWriteUserProperties: clientStubWriteUserProperties,
            clientStubUnlockVersion: clientStubUnlockVersion, clientStubIncrementVersion:
            clientStubIncrementVersion, clientStubGetSize: clientStubGetSize,
            clientStubSetSize: clientStubSetSize, clientStubUnlockFile:
            clientStubUnlockFile, AccessFailed: AccessFailed, LockFailed:
            LockFailed, OperationFailed: OperationFailed, StaticallyInvalid:
            StaticallyInvalid, Unknown: Unknown, PossiblyDamaged: PossiblyDamaged];
    interface.myInterface ← RpcPrivate.ImportInterfaceWithHost [
      interface: [
        type: IF ~IsNull[interfaceName.type]
          THEN interfaceName.type ELSE "AlpineFile~257#330#25514770454",
        instance: interfaceName.instance,
        version: interfaceName.version ],
      localOnly: RpcControl.InterMdsCallsOnly,
      stubProtocol: RpcControl.LupineProtocolVersion,
      hostHint: hostHint ];
    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 PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 23;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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];
    [openFileID: openFileID, fileID: fileID] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 6];
    RETURN[openFileID, fileID];
    END;  -- Open.

  clientStubCreate: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+53]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 19;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+53];
      RpcPrivate.StartCall[callPkt: pkt, interface: 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];
      [openFileID: openFileID, universalFile: universalFile] ← resPkt↑;
      Lupine.CheckPktLength[pkt: pkt, pktLength: 11];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+53];
      RETURN[openFileID, universalFile];
      END;  -- UNWIND.
    END;  -- Create.

  clientStubClose: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

  clientStubDelete: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

  clientStubGetUniversalFile: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
        localConversation: conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 9, signalHandler: ClientDispatcher];
    [universalFile: universalFile] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 9];
    RETURN[universalFile];
    END;  -- GetUniversalFile.

  clientStubGetTransID: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
        localConversation: conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 9, signalHandler: ClientDispatcher];
    [transID: transID] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 9];
    RETURN[transID];
    END;  -- GetTransID.

  clientStubGetAccessRights: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
        localConversation: conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    [access: access] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[access];
    END;  -- GetAccessRights.

  clientStubGetLockOption: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
        localConversation: conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    [lock: lock] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[lock];
    END;  -- GetLockOption.

  clientStubSetLockOption: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 4;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

  clientStubGetRecoveryOption: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
        localConversation: conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    [recoveryOption: recoveryOption] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[recoveryOption];
    END;  -- GetRecoveryOption.

  clientStubGetReferencePattern: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
        localConversation: conversation];
    argPkt↑ ← [openFileID: openFileID];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    [referencePattern: referencePattern] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[referencePattern];
    END;  -- GetReferencePattern.

  clientStubSetReferencePattern: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 4;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

  clientStubReadPages: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 7;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
          localConversation: conversation];
      argPkt↑ ← [openFileID: openFileID, pageRun: pageRun, lock: lock];
      BEGIN  -- Marshal pageBuffer: RESULTPageBuffer to pkt.data[pktLength].
        Lupine.RpcPktDoubleWord[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.RpcPktDoubleWord[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];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[];
      END;  -- UNWIND.
    END;  -- ReadPages.

  clientStubWritePages: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 7;
    lastPkt: BOOLEAN;
    BEGIN ENABLE UNWIND => RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RpcPrivate.StartCall[callPkt: pkt, interface: 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.RpcPktDoubleWord[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];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[];
      END;  -- UNWIND.
    END;  -- WritePages.

  clientStubLockPages: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 7;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

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

  clientStubValidateCachePageLock: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      conversation: Conversation, lock: CachePageLockConversion] RETURNS
      [success: BOOLEAN] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← ValidateCachePageLock,
        lock (1): CachePageLockConversion];
    ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [
        success (0): BOOLEAN];
    pktBuffer: ARRAY [1..RpcPrivate.pktOverhead+15] OF WORD;
    pkt: RpcPrivate.StubPkt = RpcPrivate.GetStubPkt[space: @pktBuffer];
    argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 15;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
        localConversation: conversation];
    argPkt↑ ← [lock: lock];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 1, signalHandler: ClientDispatcher];
    [success: success] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 1];
    RETURN[success];
    END;  -- ValidateCachePageLock.

  clientStubValidateCachePageLocks: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      conversation: Conversation, locks: CachePageLockConversions] RETURNS
      [locksGranted: LIST OF CachePageLockConversion, locksNotGranted:
      LIST OF CachePageLockConversion] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← ValidateCachePageLocks];
    pkt: RpcPrivate.RPCPkt = RpcPrivate.GetPkt[space: RpcPrivate.Alloc[RpcPrivate.pktOverhead+254]];
    argPkt: LONG POINTER TO ArgumentOverlay = @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: conversation];
      argPkt.transferIndex ← ValidateCachePageLocks;
      BEGIN  -- Marshal locks: CachePageLockConversions to pkt.data[pktLength].
        pktLength ← MarshalCachePageLockConversions[locks, pkt, pktLength];
        END;  -- Marshal locks.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 254, signalHandler: ClientDispatcher];
      pktLength ← 0;
      BEGIN  -- Unmarshal locksGranted: LIST OF CachePageLockConversion
          -- from pkt.data[pktLength].
        lastNode: LIST OF CachePageLockConversion ← (locksGranted ←
            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: LIST OF CachePageLockConversion = interface.paramZones.gc.CONS[--DefaultValue--,NIL];
          BEGIN  -- Unmarshal thisNode1.first: CachePageLockConversion
              -- from pkt.data[pktLength].
            pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
                dataAdr: @thisNode1.first, dataLength: SIZE[CachePageLockConversion],
                alwaysOnePkt: FALSE];
            END;  -- Unmarshal thisNode1.first.
          IF lastNode # NIL
            THEN lastNode ← (lastNode.rest ← thisNode1)
            ELSE lastNode ← (locksGranted ← thisNode1);
          listLength ← listLength - 1;
          ENDLOOP;  -- WHILE listLength > 0.
        END;  -- Unmarshal locksGranted.
      BEGIN  -- Unmarshal locksNotGranted: LIST OF CachePageLockConversion
          -- from pkt.data[pktLength].
        lastNode: LIST OF CachePageLockConversion ← (locksNotGranted
            ← 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: LIST OF CachePageLockConversion = interface.paramZones.gc.CONS[--DefaultValue--,NIL];
          BEGIN  -- Unmarshal thisNode1.first: CachePageLockConversion
              -- from pkt.data[pktLength].
            pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
                dataAdr: @thisNode1.first, dataLength: SIZE[CachePageLockConversion],
                alwaysOnePkt: FALSE];
            END;  -- Unmarshal thisNode1.first.
          IF lastNode # NIL
            THEN lastNode ← (lastNode.rest ← thisNode1)
            ELSE lastNode ← (locksNotGranted ← thisNode1);
          listLength ← listLength - 1;
          ENDLOOP;  -- WHILE listLength > 0.
        END;  -- Unmarshal locksNotGranted.
      Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[locksGranted, locksNotGranted];
      END;  -- UNWIND.
    END;  -- ValidateCachePageLocks.

  clientStubReadProperties: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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];
    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: 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.RpcPktDoubleWord[pkt, pktLength]↑;
        pktLength ← pktLength + 2;
        WHILE listLength > 0 DO
          thisNode1: LIST OF PropertyValuePair = interface.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.RpcPktDoubleWord[pkt, pktLength]↑;
                    pktLength ← pktLength + 2;
                    WHILE listLength > 0 DO
                      thisNode5: AccessList = interface.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.RpcPktDoubleWord[pkt, pktLength]↑;
                    pktLength ← pktLength + 2;
                    WHILE listLength > 0 DO
                      thisNode5: AccessList = interface.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];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[properties];
      END;  -- UNWIND.
    END;  -- ReadProperties.

  clientStubWriteProperties: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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];
    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: 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.RpcPktDoubleWord[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.RpcPktDoubleWord[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.RpcPktDoubleWord[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];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[];
      END;  -- UNWIND.
    END;  -- WriteProperties.

  clientStubReadUserProperties: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      conversation: Conversation, openFileID: OpenFileID, desiredProperties:
      UserProperties, lock: LockOption]
    RETURNS [properties: UserPropertyValuePairs] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← ReadUserProperties,
        openFileID (1): OpenFileID, lock (3): LockOption];
    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: conversation];
      argPkt↑ ← [openFileID: openFileID, lock: lock];
      BEGIN  -- Marshal desiredProperties: UserProperties to pkt.data[pktLength].
        thisNode1: UserProperties;
        listLength: Lupine.ListHeader ← 0;
        FOR thisNode1 ← desiredProperties, 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 ← desiredProperties, thisNode1.rest UNTIL thisNode1
            = NIL DO
          BEGIN  -- Marshal thisNode1.first: AlpineEnvironment.UserProperty
              -- to pkt.data[pktLength].
            IF pktLength+2 > RpcPrivate.maxDataLength
              THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength:
                  pktLength];
            pkt.data[pktLength] ← thisNode1.first=NIL;  pktLength ←
                pktLength+1;
            IF thisNode1.first # NIL
              THEN BEGIN
                textRope: Rope.Text = Rope.InlineFlatten[r: thisNode1.first];
                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 thisNode1.first # NIL.
            END;  -- Marshal thisNode1.first.
          ENDLOOP;  -- FOR thisNode1.
        END;  -- Marshal desiredProperties.
      [returnLength: , lastPkt: lastPkt] ←
        RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
            maxReturnLength: 254, signalHandler: ClientDispatcher];
      pktLength ← 0;
      BEGIN  -- Unmarshal properties: UserPropertyValuePairs from pkt.data[pktLength].
        lastNode: UserPropertyValuePairs ← (properties ← 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: UserPropertyValuePairs = interface.paramZones.gc.CONS[--DefaultValue--,NIL];
          BEGIN  -- Unmarshal thisNode1.first: AlpineEnvironment.UserPropertyValuePair
              -- from pkt.data[pktLength].
            pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength,
                dataAdr: @thisNode1.first, dataLength: SIZE[AlpineEnvironment.UserPropertyValuePair],
                alwaysOnePkt: FALSE];
            -- Restore garbled REFs to NIL following copy.
            BEGIN OPEN record: thisNode1.first;
            LOOPHOLE[record.property, LONG POINTER] ← NIL;
            WITH variant: record SELECT FROM
              rope =>
                BEGIN OPEN record: variant;
                LOOPHOLE[record.rope, LONG POINTER] ← NIL;
                END;  -- OPEN record: variant.
              ENDCASE => NULL;  -- WITH variant: record.
            END;  -- OPEN record: thisNode1.first.
            BEGIN OPEN record: thisNode1.first;
            BEGIN  -- Unmarshal record.property: UserProperty 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.property ← NIL
                ELSE BEGIN
                  ropeLength: Lupine.RopeHeader;
                  textRope: Rope.Text;
                  ropeLength ← pkt.data[pktLength];  pktLength ← pktLength+1;
                  IF ropeLength > LAST[NAT]
                    THEN Lupine.UnmarshalingError;
                  record.property ← 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.property.
            WITH variant: record SELECT FROM
              rope =>
                BEGIN  -- Unmarshal variant: RECORD [rope: Rope.ROPE]
                    -- from pkt.data[pktLength].
                  BEGIN OPEN record: variant;
                  BEGIN  -- Unmarshal record.rope: 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.rope ← NIL
                      ELSE BEGIN
                        ropeLength: Lupine.RopeHeader;
                        textRope: Rope.Text;
                        ropeLength ← pkt.data[pktLength];  pktLength
                            ← pktLength+1;
                        IF ropeLength > LAST[NAT]
                          THEN Lupine.UnmarshalingError;
                        record.rope ← 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.rope.
                  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];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[properties];
      END;  -- UNWIND.
    END;  -- ReadUserProperties.

  clientStubWriteUserProperties: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      conversation: Conversation, openFileID: OpenFileID, properties: UserPropertyValuePairs,
      lock: LockOption] =
    BEGIN
    ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [
        transferIndex (0): RpcControl.ProcedureIndex ← WriteUserProperties,
        openFileID (1): OpenFileID, lock (3): LockOption];
    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: conversation];
      argPkt↑ ← [openFileID: openFileID, lock: lock];
      BEGIN  -- Marshal properties: UserPropertyValuePairs to pkt.data[pktLength].
        thisNode1: UserPropertyValuePairs;
        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.RpcPktDoubleWord[pkt, pktLength]↑ ← listLength;
        pktLength ← pktLength + 2;
        FOR thisNode1 ← properties, thisNode1.rest UNTIL thisNode1
            = NIL DO
          BEGIN  -- Marshal thisNode1.first: AlpineEnvironment.UserPropertyValuePair
              -- to pkt.data[pktLength].
            pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
                dataAdr: @thisNode1.first, dataLength: SIZE[AlpineEnvironment.UserPropertyValuePair],
                alwaysOnePkt: FALSE];
            BEGIN OPEN record: thisNode1.first;
            BEGIN  -- Marshal record.property: UserProperty to pkt.data[pktLength].
              IF pktLength+2 > RpcPrivate.maxDataLength
                THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength:
                    pktLength];
              pkt.data[pktLength] ← record.property=NIL;  pktLength
                  ← pktLength+1;
              IF record.property # NIL
                THEN BEGIN
                  textRope: Rope.Text = Rope.InlineFlatten[r: record.property];
                  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.property # NIL.
              END;  -- Marshal record.property.
            WITH variant: record SELECT FROM
              rope =>
                BEGIN  -- Marshal variant: RECORD [rope: Rope.ROPE]
                    -- to pkt.data[pktLength].
                  BEGIN OPEN record: variant;
                  BEGIN  -- Marshal record.rope: Rope.ROPE to pkt.data[pktLength].
                    IF pktLength+2 > RpcPrivate.maxDataLength
                      THEN pktLength ← Lupine.StartNextPkt[pkt: pkt,
                          pktLength: pktLength];
                    pkt.data[pktLength] ← record.rope=NIL;  pktLength
                        ← pktLength+1;
                    IF record.rope # NIL
                      THEN BEGIN
                        textRope: Rope.Text = Rope.InlineFlatten[r:
                            record.rope];
                        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.rope # NIL.
                    END;  -- Marshal record.rope.
                  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];
      RpcPrivate.DeAlloc[LOOPHOLE[pkt], RpcPrivate.pktOverhead+254];
      RETURN[];
      END;  -- UNWIND.
    END;  -- WriteUserProperties.

  clientStubUnlockVersion: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 3;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

  clientStubIncrementVersion: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 5;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

  clientStubGetSize: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 4;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: interface.myInterface,
        localConversation: conversation];
    argPkt↑ ← [openFileID: openFileID, lock: lock];
    [returnLength: , lastPkt: lastPkt] ←
      RpcPrivate.Call[ pkt: pkt, callLength: pktLength,
          maxReturnLength: 2, signalHandler: ClientDispatcher];
    [size: size] ← resPkt↑;
    Lupine.CheckPktLength[pkt: pkt, pktLength: 2];
    RETURN[size];
    END;  -- GetSize.

  clientStubSetSize: PUBLIC PROCEDURE [interface: RpcControl.InterfaceRecord,
      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: LONG POINTER TO ArgumentOverlay = @pkt.data[0];
    pktLength: RpcPrivate.DataLength ← 6;
    lastPkt: BOOLEAN;
    RpcPrivate.StartCall[callPkt: pkt, interface: 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.

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


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


-- Marshall/Unmarshal procedures.
MarshalCachePageLockConversions: PROC[value: AlpineFile.CachePageLockConversions,
    pkt: RpcPrivate.RPCPkt, pktLength0: RpcPrivate.DataLength]
  RETURNS[pktLength: RpcPrivate.DataLength] = BEGIN
  pktLength ← pktLength0; {
  BEGIN  -- Marshal value↑: AlpineEnvironment.CachePageLockConversionsObject
      -- to pkt.data[pktLength].
    IF pktLength+3 > RpcPrivate.maxDataLength
      THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength];
    pkt.data[pktLength] ← value=NIL;  pktLength ← pktLength+1;
    IF value # NIL THEN BEGIN
      -- Record has a sequence, put its length up front.
      Lupine.RpcPktDoubleWord[pkt, pktLength]↑ ← LENGTH[DESCRIPTOR[value↑]];
      pktLength ← pktLength + 2;
      pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength,
          dataAdr: LOOPHOLE[value], dataLength: SIZE[AlpineEnvironment.CachePageLockConversionsObject[LENGTH[DESCRIPTOR[value↑]]]],
          alwaysOnePkt: FALSE];
      END;  -- IF value # NIL.
    END;  -- Marshal value↑.
  };END;



-- No module initialization.

END.  -- AlpineFileRpcClientImpl.