-- Copyright (C) 1985 by Xerox Corporation.  All rights reserved.
-- Stub file  was translated on June 22, 1985 9:34:21 pm PDT by Lupine of May 23, 1985 8:38:08 am PDT
-- Source interface CedarNSPrintUtils came from file CedarNSPrintUtils.bcd, which was created on June 22, 1985 9:34:05 pm PDT with version stamp 44#63#2012746333 from source of June 22, 1985 1:52:12 am PDT.

-- The RPC stub modules for CedarNSPrintUtils are:
--   CedarNSPrintUtilsRpcControl.mesa;
--   CedarNSPrintUtilsRpcClientImpl.mesa;
--   CedarNSPrintUtilsRpcBinderImpl.mesa;
--   CedarNSPrintUtilsRpcServerImpl.mesa.

-- The parameters for this translation are:
--   Target language = Mesa
--   Default parameter passing = VALUE
--   Deallocate server heap arguments = TRUE
--   Inline RpcServerImpl dispatcher stubs = FALSE
--   Declare signals = TRUE
--   Warn about short POINTER ("MDS") allocations = TRUE
--   Maximum number of dynamic heap NEWs = 50, MDS NEWs = 50
--   Acceptable parameter protocols = VersionRange[1..1].


DIRECTORY
  CedarNSPrint,
  CedarNSPrintUtils,
  CedarNSPrintUtilsRpcControl USING [
    InterMdsCallsOnly, LupineProtocolVersion, ProcedureIndex, SignalIndex],
  MesaRPC USING [EncryptionKey, InterfaceName, Principal, standardZones, Zones],
  MesaRPCLupine  --USING SOME OF [Call, DataLength, Dispatcher, ExportHandle,
  -- ExportInterface, GetStubPkt, maxDataLength, maxPrincipalLength,
  -- maxShortStringLength, pktOverhead, ReceiveExtraPkt, SendPrelimPkt,
  -- StartCall, StartSignal, StubPkt, UnexportInterface]-- ,
  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]-- ;


CedarNSPrintUtilsRpcServerImpl: MONITOR
  IMPORTS CedarNSPrintUtils, RpcPrivate: MesaRPCLupine, Lupine: LupineRuntime
  EXPORTS CedarNSPrintUtilsRpcControl
  SHARES CedarNSPrintUtils, CedarNSPrintUtilsRpcControl =
  BEGIN
  OPEN CedarNSPrintUtils, RpcControl: CedarNSPrintUtilsRpcControl,
    RpcPublic: MesaRPC;


  -- Standard remote binding routines.

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

  ExportInterface: PUBLIC ENTRY PROCEDURE [
    interfaceName: RpcPublic.InterfaceName, user: RpcPublic.Principal,
    password: RpcPublic.EncryptionKey, parameterStorage: RpcPublic.Zones] =
    BEGIN
    ENABLE UNWIND => NULL;
    IsNull: PROCEDURE [string: LONG STRING] RETURNS [BOOLEAN] = INLINE {
      RETURN[string = NIL OR string.length = 0]};
    IF bound THEN Lupine.BindingError;
    myInterface ← RpcPrivate.ExportInterface[
      interface: [
      type:
      IF ~IsNull[interfaceName.type] THEN interfaceName.type
      ELSE "CedarNSPrintUtils~44#63#2012746333",
      instance: interfaceName.instance, version: interfaceName.version],
      user: user, password: password, dispatcher: ServerDispatcher,
      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;

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


  -- Public procedure dispatcher and public signal and error catcher.

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

    -- Catch public signals.

    ENABLE
      BEGIN

      END;  -- Catch public signals.


    -- Call public procedures (still in dispatcher).

    SELECT LOOPHOLE[pkt.data[0], RpcControl.ProcedureIndex] FROM
      FreeString =>
        RETURN[
          FreeStringStub[
            pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      FreeMedia =>
        RETURN[
          FreeMediaStub[
            pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      FreePrinterProperties =>
        RETURN[
          FreePrinterPropertiesStub[
            pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      FreePrinterStatus =>
        RETURN[
          FreePrinterStatusStub[
            pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      FreeRequestStatus =>
        RETURN[
          FreeRequestStatusStub[
            pkt: pkt, callLength: callLength, lastPkt: lastPkt,
            localConversation: localConversation]];
      ENDCASE => RETURN[Lupine.DispatchingError[]];

    END;  -- ServerDispatcher


  -- Public procedure dispatcher stubs.

  FreeStringStub: --PROCEDURE [string: LONG POINTER TO String]--
    RpcPrivate.Dispatcher =
    BEGIN
    string: LONG POINTER TO String;
    pktLength: RpcPrivate.DataLength ← 1;
    MaxHeapAllocs: CARDINAL = 2;
    heapAllocVector: ARRAY [1..MaxHeapAllocs] OF LONG POINTER ← ALL[NIL];
    BEGIN
    ENABLE
      UNWIND =>
        BEGIN  -- Free storage.
        FOR ptr: CARDINAL IN [1..LENGTH[heapAllocVector]] DO
          IF heapAllocVector[ptr] = NIL THEN EXIT;
          paramZones.heap.FREE[@heapAllocVector[ptr]];
          ENDLOOP;
        END;  -- Free storage.
    BEGIN  -- Unmarshal string: LONG POINTER TO String from pkt.data[pktLength].
    isNIL: Lupine.NilHeader;
    IF pktLength + 1 > RpcPrivate.maxDataLength THEN
      pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
    isNIL ← pkt.data[pktLength];
    pktLength ← pktLength + 1;
    IF isNIL THEN string ← NIL
    ELSE
      BEGIN
      string ← (heapAllocVector[1] ← paramZones.heap.NEW[String]);
      BEGIN  -- Unmarshal string↑: String from pkt.data[pktLength].
      pktLength ← Lupine.CopyFromPkt[
        pkt: pkt, pktLength: pktLength, dataAdr: string,
        dataLength: SIZE[String], alwaysOnePkt: FALSE];
      BEGIN OPEN record: string↑;
      BEGIN  -- Unmarshal record.bytes: LONG POINTER TO PACKED
      -- ARRAY CARDINAL OF [0..255] from pkt.data[pktLength].
      isNIL: Lupine.NilHeader;
      IF pktLength + 1 > RpcPrivate.maxDataLength THEN
        pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
      isNIL ← pkt.data[pktLength];
      pktLength ← pktLength + 1;
      IF isNIL THEN record.bytes ← NIL
      ELSE
        BEGIN
        record.bytes ←
          (heapAllocVector[2] ← paramZones.heap.NEW[
            PACKED ARRAY CARDINAL OF [0..255]]);
        BEGIN  -- Unmarshal record.bytes↑: PACKED ARRAY
        -- CARDINAL OF [0..255] from pkt.data[pktLength].
        pktLength ← Lupine.CopyFromPkt[
          pkt: pkt, pktLength: pktLength, dataAdr: @record.bytes↑,
          dataLength: SIZE[PACKED ARRAY CARDINAL OF [0..255]],
          alwaysOnePkt: FALSE];
        END;  -- Unmarshal record.bytes↑.
        END;  -- IF isNIL.
      END;  -- Unmarshal record.bytes.
      END;  -- OPEN record: string↑.
      END;  -- Unmarshal string↑.
      END;  -- IF isNIL.
    END;  -- Unmarshal string.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    FreeString[string];
    pktLength ← 0;
    END;  -- ENABLE UNWIND => Free storage.
    FOR ptr: CARDINAL IN [1..LENGTH[heapAllocVector]] DO
      IF heapAllocVector[ptr] = NIL THEN EXIT;
      paramZones.heap.FREE[@heapAllocVector[ptr]];
      ENDLOOP;
    RETURN[returnLength: pktLength];
    END;  -- FreeStringStub.

  FreeMediaStub: --PROCEDURE [media: LONG POINTER TO Media]--
    RpcPrivate.Dispatcher =
    BEGIN
    media: LONG POINTER TO Media;
    pktLength: RpcPrivate.DataLength ← 1;
    MaxHeapAllocs: CARDINAL = 2;
    heapAllocVector: ARRAY [1..MaxHeapAllocs] OF LONG POINTER ← ALL[NIL];
    BEGIN
    ENABLE
      UNWIND =>
        BEGIN  -- Free storage.
        FOR ptr: CARDINAL IN [1..LENGTH[heapAllocVector]] DO
          IF heapAllocVector[ptr] = NIL THEN EXIT;
          paramZones.heap.FREE[@heapAllocVector[ptr]];
          ENDLOOP;
        END;  -- Free storage.
    BEGIN  -- Unmarshal media: LONG POINTER TO Media from pkt.data[pktLength].
    isNIL: Lupine.NilHeader;
    IF pktLength + 1 > RpcPrivate.maxDataLength THEN
      pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
    isNIL ← pkt.data[pktLength];
    pktLength ← pktLength + 1;
    IF isNIL THEN media ← NIL
    ELSE
      BEGIN
      media ← (heapAllocVector[1] ← paramZones.heap.NEW[Media]);
      BEGIN  -- Unmarshal media↑: Media from pkt.data[pktLength].
      DescriptorType: TYPE = RECORD [
        SEQUENCE COMPUTED CARDINAL OF CedarNSPrint.Medium];
      descLength: Lupine.SequenceHeader;
      IF pktLength + 2 > RpcPrivate.maxDataLength THEN
        pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
      descLength ← Lupine.RpcPktDoubleWord[pkt, pktLength]↑;
      pktLength ← pktLength + 2;
      media↑ ← DESCRIPTOR[
        (heapAllocVector[2] ← paramZones.heap.NEW[
          DescriptorType [Lupine.SHORT[descLength]]]), Lupine.SHORT[
          descLength]];
      pktLength ← Lupine.CopyFromPkt[
        pkt: pkt, pktLength: pktLength, dataAdr: BASE[media↑],
        dataLength: SIZE[CedarNSPrint.Medium] * LENGTH[media↑],
        alwaysOnePkt: FALSE];
      END;  -- Unmarshal media↑.
      END;  -- IF isNIL.
    END;  -- Unmarshal media.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    FreeMedia[media];
    pktLength ← 0;
    END;  -- ENABLE UNWIND => Free storage.
    FOR ptr: CARDINAL IN [1..LENGTH[heapAllocVector]] DO
      IF heapAllocVector[ptr] = NIL THEN EXIT;
      paramZones.heap.FREE[@heapAllocVector[ptr]];
      ENDLOOP;
    RETURN[returnLength: pktLength];
    END;  -- FreeMediaStub.

  FreePrinterPropertiesStub:  --PROCEDURE [printerProperties: LONG POINTER
    -- TO PrinterProperties]-- RpcPrivate.Dispatcher =
    BEGIN
    printerProperties: LONG POINTER TO PrinterProperties;
    pktLength: RpcPrivate.DataLength ← 1;
    MaxHeapAllocs: CARDINAL = 53;
    heapAllocs: CARDINAL ← 0;
    heapAllocVector: ARRAY [1..MaxHeapAllocs] OF LONG POINTER ← ALL[NIL];
    BEGIN
    ENABLE
      UNWIND =>
        BEGIN  -- Free storage.
        FOR ptr: CARDINAL IN [1..LENGTH[heapAllocVector]] DO
          IF heapAllocVector[ptr] = NIL THEN EXIT;
          paramZones.heap.FREE[@heapAllocVector[ptr]];
          ENDLOOP;
        END;  -- Free storage.
    BEGIN  -- Unmarshal printerProperties: LONG POINTER TO PrinterProperties
    -- from pkt.data[pktLength].
    isNIL: Lupine.NilHeader;
    IF pktLength + 1 > RpcPrivate.maxDataLength THEN
      pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
    isNIL ← pkt.data[pktLength];
    pktLength ← pktLength + 1;
    IF isNIL THEN printerProperties ← NIL
    ELSE
      BEGIN
      printerProperties ←
        (heapAllocVector[
          (IF (heapAllocs ← heapAllocs + 1) <= MaxHeapAllocs THEN heapAllocs
           ELSE Lupine.UnmarshalingExprError[])] ← paramZones.heap.NEW[
          PrinterProperties]);
      BEGIN  -- Unmarshal printerProperties↑: PrinterProperties
      -- from pkt.data[pktLength].
      DescriptorType: TYPE = RECORD [
        SEQUENCE COMPUTED CARDINAL OF CedarNSPrint.PrinterProperty];
      descLength: Lupine.SequenceHeader;
      IF pktLength + 2 > RpcPrivate.maxDataLength THEN
        pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
      descLength ← Lupine.RpcPktDoubleWord[pkt, pktLength]↑;
      pktLength ← pktLength + 2;
      printerProperties↑ ← DESCRIPTOR[
        (heapAllocVector[
          (IF (heapAllocs ← heapAllocs + 1) <= MaxHeapAllocs THEN heapAllocs
           ELSE Lupine.UnmarshalingExprError[])] ← paramZones.heap.NEW[
          DescriptorType [Lupine.SHORT[descLength]]]), Lupine.SHORT[
          descLength]];
      FOR element2: CARDINAL IN
        [FIRST[CARDINAL]..FIRST[CARDINAL] + LENGTH[printerProperties↑]) DO
        BEGIN  -- Unmarshal printerProperties↑[element2]: CedarNSPrint.PrinterProperty
        -- from pkt.data[pktLength].
        pktLength ← Lupine.CopyFromPkt[
          pkt: pkt, pktLength: pktLength,
          dataAdr: @printerProperties↑[element2],
          dataLength: SIZE[CedarNSPrint.PrinterProperty], alwaysOnePkt: FALSE];
        BEGIN OPEN record: printerProperties↑[element2];
        WITH variant: record SELECT FROM
          media =>
            BEGIN  -- Unmarshal variant: MACHINE DEPENDENT
            -- RECORD [media: Media] from pkt.data[pktLength].
            BEGIN OPEN record: variant;
            BEGIN  -- Unmarshal record.media: Media from
            -- pkt.data[pktLength].
            DescriptorType: TYPE = RECORD [
              SEQUENCE COMPUTED CARDINAL OF Medium];
            descLength: Lupine.SequenceHeader;
            IF pktLength + 2 > RpcPrivate.maxDataLength THEN
              pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
            descLength ← Lupine.RpcPktDoubleWord[pkt, pktLength]↑;
            pktLength ← pktLength + 2;
            record.media ← DESCRIPTOR[
              (heapAllocVector[
                (IF (heapAllocs ← heapAllocs + 1) <= MaxHeapAllocs THEN
                 heapAllocs ELSE Lupine.UnmarshalingExprError[])] ←
                paramZones.heap.NEW[DescriptorType [Lupine.SHORT[descLength]]]),
                Lupine.SHORT[descLength]];
            pktLength ← Lupine.CopyFromPkt[
              pkt: pkt, pktLength: pktLength, dataAdr: BASE[record.media],
              dataLength: SIZE[Medium] * LENGTH[record.media],
              alwaysOnePkt: FALSE];
            END;  -- Unmarshal record.media.
            END;  -- OPEN record: variant.
            END;  -- Unmarshal variant.
          ENDCASE => NULL;  -- WITH variant: record.
        END;  -- OPEN record: printerProperties↑[element2].
        END;  -- Unmarshal printerProperties↑[element2].
        ENDLOOP;  -- FOR element2.
      END;  -- Unmarshal printerProperties↑.
      END;  -- IF isNIL.
    END;  -- Unmarshal printerProperties.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    FreePrinterProperties[printerProperties];
    pktLength ← 0;
    END;  -- ENABLE UNWIND => Free storage.
    FOR ptr: CARDINAL IN [1..LENGTH[heapAllocVector]] DO
      IF heapAllocVector[ptr] = NIL THEN EXIT;
      paramZones.heap.FREE[@heapAllocVector[ptr]];
      ENDLOOP;
    RETURN[returnLength: pktLength];
    END;  -- FreePrinterPropertiesStub.

  FreePrinterStatusStub:  --PROCEDURE [printerStatus: LONG POINTER TO
    -- PrinterStatus]-- RpcPrivate.Dispatcher =
    BEGIN
    printerStatus: LONG POINTER TO PrinterStatus;
    pktLength: RpcPrivate.DataLength ← 1;
    MaxHeapAllocs: CARDINAL = 53;
    heapAllocs: CARDINAL ← 0;
    heapAllocVector: ARRAY [1..MaxHeapAllocs] OF LONG POINTER ← ALL[NIL];
    BEGIN
    ENABLE
      UNWIND =>
        BEGIN  -- Free storage.
        FOR ptr: CARDINAL IN [1..LENGTH[heapAllocVector]] DO
          IF heapAllocVector[ptr] = NIL THEN EXIT;
          paramZones.heap.FREE[@heapAllocVector[ptr]];
          ENDLOOP;
        END;  -- Free storage.
    BEGIN  -- Unmarshal printerStatus: LONG POINTER TO PrinterStatus
    -- from pkt.data[pktLength].
    isNIL: Lupine.NilHeader;
    IF pktLength + 1 > RpcPrivate.maxDataLength THEN
      pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
    isNIL ← pkt.data[pktLength];
    pktLength ← pktLength + 1;
    IF isNIL THEN printerStatus ← NIL
    ELSE
      BEGIN
      printerStatus ←
        (heapAllocVector[
          (IF (heapAllocs ← heapAllocs + 1) <= MaxHeapAllocs THEN heapAllocs
           ELSE Lupine.UnmarshalingExprError[])] ← paramZones.heap.NEW[
          PrinterStatus]);
      BEGIN  -- Unmarshal printerStatus↑: PrinterStatus from
      -- pkt.data[pktLength].
      DescriptorType: TYPE = RECORD [
        SEQUENCE COMPUTED CARDINAL OF CedarNSPrint.PrinterStatusComponent];
      descLength: Lupine.SequenceHeader;
      IF pktLength + 2 > RpcPrivate.maxDataLength THEN
        pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
      descLength ← Lupine.RpcPktDoubleWord[pkt, pktLength]↑;
      pktLength ← pktLength + 2;
      printerStatus↑ ← DESCRIPTOR[
        (heapAllocVector[
          (IF (heapAllocs ← heapAllocs + 1) <= MaxHeapAllocs THEN heapAllocs
           ELSE Lupine.UnmarshalingExprError[])] ← paramZones.heap.NEW[
          DescriptorType [Lupine.SHORT[descLength]]]), Lupine.SHORT[
          descLength]];
      FOR element2: CARDINAL IN
        [FIRST[CARDINAL]..FIRST[CARDINAL] + LENGTH[printerStatus↑]) DO
        BEGIN  -- Unmarshal printerStatus↑[element2]: CedarNSPrint.PrinterStatusComponent
        -- from pkt.data[pktLength].
        pktLength ← Lupine.CopyFromPkt[
          pkt: pkt, pktLength: pktLength, dataAdr: @printerStatus↑[element2],
          dataLength: SIZE[CedarNSPrint.PrinterStatusComponent],
          alwaysOnePkt: FALSE];
        BEGIN OPEN record: printerStatus↑[element2];
        WITH variant: record SELECT FROM
          media =>
            BEGIN  -- Unmarshal variant: MACHINE DEPENDENT
            -- RECORD [media: Media] from pkt.data[pktLength].
            BEGIN OPEN record: variant;
            BEGIN  -- Unmarshal record.media: Media from
            -- pkt.data[pktLength].
            DescriptorType: TYPE = RECORD [
              SEQUENCE COMPUTED CARDINAL OF Medium];
            descLength: Lupine.SequenceHeader;
            IF pktLength + 2 > RpcPrivate.maxDataLength THEN
              pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
            descLength ← Lupine.RpcPktDoubleWord[pkt, pktLength]↑;
            pktLength ← pktLength + 2;
            record.media ← DESCRIPTOR[
              (heapAllocVector[
                (IF (heapAllocs ← heapAllocs + 1) <= MaxHeapAllocs THEN
                 heapAllocs ELSE Lupine.UnmarshalingExprError[])] ←
                paramZones.heap.NEW[DescriptorType [Lupine.SHORT[descLength]]]),
                Lupine.SHORT[descLength]];
            pktLength ← Lupine.CopyFromPkt[
              pkt: pkt, pktLength: pktLength, dataAdr: BASE[record.media],
              dataLength: SIZE[Medium] * LENGTH[record.media],
              alwaysOnePkt: FALSE];
            END;  -- Unmarshal record.media.
            END;  -- OPEN record: variant.
            END;  -- Unmarshal variant.
          ENDCASE => NULL;  -- WITH variant: record.
        END;  -- OPEN record: printerStatus↑[element2].
        END;  -- Unmarshal printerStatus↑[element2].
        ENDLOOP;  -- FOR element2.
      END;  -- Unmarshal printerStatus↑.
      END;  -- IF isNIL.
    END;  -- Unmarshal printerStatus.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    FreePrinterStatus[printerStatus];
    pktLength ← 0;
    END;  -- ENABLE UNWIND => Free storage.
    FOR ptr: CARDINAL IN [1..LENGTH[heapAllocVector]] DO
      IF heapAllocVector[ptr] = NIL THEN EXIT;
      paramZones.heap.FREE[@heapAllocVector[ptr]];
      ENDLOOP;
    RETURN[returnLength: pktLength];
    END;  -- FreePrinterStatusStub.

  FreeRequestStatusStub:  --PROCEDURE [requestStatus: LONG POINTER TO
    -- RequestStatus]-- RpcPrivate.Dispatcher =
    BEGIN
    requestStatus: LONG POINTER TO RequestStatus;
    pktLength: RpcPrivate.DataLength ← 1;
    MaxHeapAllocs: CARDINAL = 53;
    heapAllocs: CARDINAL ← 0;
    heapAllocVector: ARRAY [1..MaxHeapAllocs] OF LONG POINTER ← ALL[NIL];
    BEGIN
    ENABLE
      UNWIND =>
        BEGIN  -- Free storage.
        FOR ptr: CARDINAL IN [1..LENGTH[heapAllocVector]] DO
          IF heapAllocVector[ptr] = NIL THEN EXIT;
          paramZones.heap.FREE[@heapAllocVector[ptr]];
          ENDLOOP;
        END;  -- Free storage.
    BEGIN  -- Unmarshal requestStatus: LONG POINTER TO RequestStatus
    -- from pkt.data[pktLength].
    isNIL: Lupine.NilHeader;
    IF pktLength + 1 > RpcPrivate.maxDataLength THEN
      pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
    isNIL ← pkt.data[pktLength];
    pktLength ← pktLength + 1;
    IF isNIL THEN requestStatus ← NIL
    ELSE
      BEGIN
      requestStatus ←
        (heapAllocVector[
          (IF (heapAllocs ← heapAllocs + 1) <= MaxHeapAllocs THEN heapAllocs
           ELSE Lupine.UnmarshalingExprError[])] ← paramZones.heap.NEW[
          RequestStatus]);
      BEGIN  -- Unmarshal requestStatus↑: RequestStatus from
      -- pkt.data[pktLength].
      DescriptorType: TYPE = RECORD [
        SEQUENCE COMPUTED CARDINAL OF CedarNSPrint.RequestStatusComponent];
      descLength: Lupine.SequenceHeader;
      IF pktLength + 2 > RpcPrivate.maxDataLength THEN
        pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
      descLength ← Lupine.RpcPktDoubleWord[pkt, pktLength]↑;
      pktLength ← pktLength + 2;
      requestStatus↑ ← DESCRIPTOR[
        (heapAllocVector[
          (IF (heapAllocs ← heapAllocs + 1) <= MaxHeapAllocs THEN heapAllocs
           ELSE Lupine.UnmarshalingExprError[])] ← paramZones.heap.NEW[
          DescriptorType [Lupine.SHORT[descLength]]]), Lupine.SHORT[
          descLength]];
      FOR element2: CARDINAL IN
        [FIRST[CARDINAL]..FIRST[CARDINAL] + LENGTH[requestStatus↑]) DO
        BEGIN  -- Unmarshal requestStatus↑[element2]: CedarNSPrint.RequestStatusComponent
        -- from pkt.data[pktLength].
        pktLength ← Lupine.CopyFromPkt[
          pkt: pkt, pktLength: pktLength, dataAdr: @requestStatus↑[element2],
          dataLength: SIZE[CedarNSPrint.RequestStatusComponent],
          alwaysOnePkt: FALSE];
        BEGIN OPEN record: requestStatus↑[element2];
        WITH variant: record SELECT FROM
          statusMessage =>
            BEGIN  -- Unmarshal variant: MACHINE DEPENDENT
            -- RECORD [statusMessage: String] from pkt.data[pktLength].
            BEGIN OPEN record: variant;
            BEGIN  -- Unmarshal record.statusMessage: String
            -- from pkt.data[pktLength].
            BEGIN OPEN record: record.statusMessage;
            BEGIN  -- Unmarshal record.bytes: LONG POINTER
            -- TO PACKED ARRAY CARDINAL OF [0..255] from
            -- pkt.data[pktLength].
            isNIL: Lupine.NilHeader;
            IF pktLength + 1 > RpcPrivate.maxDataLength THEN
              pktLength ← Lupine.FinishThisPkt[pkt: pkt, pktLength: pktLength];
            isNIL ← pkt.data[pktLength];
            pktLength ← pktLength + 1;
            IF isNIL THEN record.bytes ← NIL
            ELSE
              BEGIN
              record.bytes ←
                (heapAllocVector[
                  (IF (heapAllocs ← heapAllocs + 1) <= MaxHeapAllocs THEN
                   heapAllocs ELSE Lupine.UnmarshalingExprError[])] ←
                  paramZones.heap.NEW[PACKED ARRAY CARDINAL OF [0..255]]);
              BEGIN  -- Unmarshal record.bytes↑:
              -- PACKED ARRAY CARDINAL OF [0..255]
              -- from pkt.data[pktLength].
              pktLength ← Lupine.CopyFromPkt[
                pkt: pkt, pktLength: pktLength, dataAdr: @record.bytes↑,
                dataLength: SIZE[PACKED ARRAY CARDINAL OF [0..255]],
                alwaysOnePkt: FALSE];
              END;  -- Unmarshal record.bytes↑.
              END;  -- IF isNIL.
            END;  -- Unmarshal record.bytes.
            END;  -- OPEN record: record.statusMessage.
            END;  -- Unmarshal record.statusMessage.
            END;  -- OPEN record: variant.
            END;  -- Unmarshal variant.
          ENDCASE => NULL;  -- WITH variant: record.
        END;  -- OPEN record: requestStatus↑[element2].
        END;  -- Unmarshal requestStatus↑[element2].
        ENDLOOP;  -- FOR element2.
      END;  -- Unmarshal requestStatus↑.
      END;  -- IF isNIL.
    END;  -- Unmarshal requestStatus.
    Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength];
    FreeRequestStatus[requestStatus];
    pktLength ← 0;
    END;  -- ENABLE UNWIND => Free storage.
    FOR ptr: CARDINAL IN [1..LENGTH[heapAllocVector]] DO
      IF heapAllocVector[ptr] = NIL THEN EXIT;
      paramZones.heap.FREE[@heapAllocVector[ptr]];
      ENDLOOP;
    RETURN[returnLength: pktLength];
    END;  -- FreeRequestStatusStub.


  -- Marshall/Unmarshal procedures.


  -- No module initialization.

  END.  -- CedarNSPrintUtilsRpcServerImpl.