     **
     **  Program summary
     **  ---------------
     **
     **  Configuration API:
     **    QDCLCFGD      List configuration    Returns a list of configuration
     **                  descriptions          descriptions based on type as
     **                                        well as selection criterias such
     **                                        as status and category.
     **
     **  User space APIs:
     **    QUSCRTUS      Create user space     Creates a user space.
     **
     **    QUSPTRUS      Retrieve pointer to   Returns a pointer to the contents
     **                  user space            of a user space. The data pointed
     **                                        to can be directly modified by
     **                                        the program obtaining the pointer.
     **
     **    QUSDLTUS      Delete user space     Deletes a user space.
     **
     **  Message handling API:
     **    QMHSNDPM      Send program message  Sends a message to a program stack
     **                                        entry (current, previous, etc.) or
     **                                        the joblog.
     **
     **  Sequence of events:
     **    1. Create user space
     **
     **    2. List configuration description(s) selected
     **       to the user space
     **
     **    3. Retrieve the configuration description(s)
     **       one by one.
     **
     **    4. Send completion message to inform caller
     **       what line - if any - is currently allocating
     **       the ECS resource.
     **
     **    5. Delete user space.
     **
     **
     **  Compile options:
     **   CrtRpgMod Module( CBX0062 )  DbgView( *LIST )
     **
     **   CrtPgm    Pgm( CBX0062 )
     **             Module( CBX0062 )
     **             BndSrvPgm( CBX0061 )
     **
     **-- Control spec:  -----------------------------------------------------**
     H Option( *SrcStmt )
     **-- API Error Data Structure:  -----------------------------------------**
     D ApiError        Ds
     D  AeBytPro                     10i 0 Inz( %Size( ApiError ))
     D  AeBytAvl                     10i 0 Inz
     **-- Global variables:  -------------------------------------------------**
     D MsgKey          s              4a
     **-- Create User Space Parameter:  --------------------------------------**
     D CuUsrSpcQ       Ds
     D  CuUsrSpcNam                  10    Inz( 'CFGLST   ' )
     D  CuUsrSpcLib                  10    Inz( 'QTEMP ' )
     **-- API format CFGD0200: List information:  ----------------------------**
     D CfgLst200       Ds                  Based( pLstEnt )
     D  C2CurStsNam                  10i 0
     D  C2CfgDscNam                  10a
     D  C2CfgDscCat                  10a
     D  C2CurStsTxt                  20a
     D  C2TxtDsc                     50a
     D  C2JobNam                     10a
     D  C2JobUsr                     10a
     D  C2JobNbr                      6a
     D  C2PasTdev                    10a
     D  C2RtvApiNam                   8a
     D  C2CfgCmdSfx                   4a
     **-- API format CFGD0200: Header information:  --------------------------**
     D HdrInf          Ds                  Based( pHdrInf )
     D  ClCfgTypU                    10a
     D  ClObjQualU                   40a
     D  ClStsQualU                   20a
     D                                2a
     D  ClUspNamU                    10a
     D  ClUspLibU                    10a
     **-- User Space Generic Header:  ---------- -----------------------------**
     D UsrSpc          Ds                  Based( pUsrSpc )
     D  UsOfsHdr                     10i 0 Overlay( UsrSpc: 117 )
     D  UsOfsLst                     10i 0 Overlay( UsrSpc: 125 )
     D  UsNumLstEnt                  10i 0 Overlay( UsrSpc: 133 )
     D  UsSizLstEnt                  10i 0 Overlay( UsrSpc: 137 )
     **-- Pointers:  ---------------------------------------------------------**
     D pUsrSpc         s               *   Inz( *Null )
     D pHdrInf         s               *   Inz( *Null )
     D pLstEnt         s               *   Inz( *Null )
     **-- Get ECS resource:  -------------------------------------------------**
     D GetEcsRsc       Pr            32a
     **-- List configuration descriptions:  ----------------------------------**
     D LstCfgDsc       Pr                  ExtPgm( 'QDCLCFGD' )
     D  LcSpcNamQ                    20a   Const
     D  LcFmtNam                      8a   Const
     D  LcCfgDscTyp                  10a   Const
     D  LcObjQual                    40a   Const
     D  LcStsQual                    20a   Const
     D  LcError                   32767a         Options( *NoPass: *VarSize )
     **-- Create user space: -------------------------------------------------**
     D CrtUsrSpc       Pr                  ExtPgm( 'QUSCRTUS' )
     D  CsSpcNamQ                    20a   Const
     D  CsExtAtr                     10a   Const
     D  CsInzSiz                     10i 0 Const
     D  CsInzVal                      1a   Const
     D  CsPubAut                     10a   Const
     D  CsText                       50a   Const
     **-- Optional 1:
     D  CsReplace                    10a   Const Options( *NoPass )
     D  CsError                   32767a         Options( *NoPass: *VarSize )
     **-- Optional 2:
     D  CsDomain                     10a   Const Options( *NoPass )
     **-- Retrieve pointer to user space: ------------------------------------**
     D RtvPtrSpc       Pr                  ExtPgm( 'QUSPTRUS' )
     D  RpSpcNamQ                    20a   Const
     D  RpPointer                      *
     D  RpError                   32767a         Options( *NoPass: *VarSize )
     **-- Delete user space: -------------------------------------------------**
     D DltUsrSpc       Pr                  ExtPgm( 'QUSDLTUS' )
     D  DsSpcNamQ                    20a   Const
     D  DsError                   32767a         Options( *VarSize )
     **-- Send completion message:  ------------------------------------------**
     D SndCmpMsg       Pr            10i 0
     D  PxMsgId                      10a   Const
     D  PxMsgF                       10a   Const
     D  PxMsgFlib                    10a   Const
     D  PxMsgDta                    512a   Const  Varying
     **-----------------------------------------------------------------------**
     **
     C                   CallP     CrtUsrSpc( CuUsrSpcQ
     C                                      : *Blanks
     C                                      : 65535
     C                                      : x'00'
     C                                      : '*CHANGE'
     C                                      : *Blanks
     C                                      : '*YES'
     C                                      : ApiError
     C                                      )
     **
     C                   CallP     LstCfgDsc( CuUsrSpcQ
     C                                      : 'CFGD0200'
     C                                      : '*LIND'
     C                                      : '*RSRC     ' + GetEcsRsc()
     C                                      : '*GE       *VARYON'
     C                                      : ApiError
     C                                      )
     **
     C                   If        AeBytAvl    = *Zero
     C                   CallP     RtvPtrSpc( CuUsrSpcQ
     C                                      : pUsrSpc
     C                                      )
     **
     C                   ExSr      GetCfgDsc
     C                   EndIf
     **
     C                   CallP     DltUsrSpc( CuUsrSpcQ
     C                                      : ApiError
     C                                      )
     **
     C                   Return
     **
     **-- Get Configuration Description:  ------------------------------------**
     C     GetCfgDsc     BegSr
     **
     C                   Eval      pHdrInf     = pUsrSpc + UsOfsHdr
     **
     C                   If        UsNumLstEnt = *Zero
     C                   ExSr      RscVacMsg
     **
     C                   Else
     C                   Eval      pLstEnt     = pUsrSpc + UsOfsLst
     C                   Do        UsNumLstEnt
     **
     C                   ExSr      PrcLstEnt
     C                   Eval      pLstEnt     = pLstEnt + UsSizLstEnt
     C                   EndDo
     C                   EndIf
     **
     C                   EndSr
     **-- Ressource vacant message:  -----------------------------------------**
     C     RscVacMsg     BegSr
     **
     C                   CallP     SndCmpMsg( 'CPF9898'
     C                                      : 'QCPFMSG'
     C                                      : '*LIBL'
     C                                      : 'No lines currently active'
     C                                      )
     **
     C                   EndSr
     **-- Process List Entry:  -----------------------------------------------**
     C     PrcLstEnt     BegSr
     **
     C                   CallP     SndCmpMsg( 'CPF9898'
     C                                      : 'QCPFMSG'
     C                                      : '*LIBL'
     C                                      : 'Line '                +
     C                                        %TrimR( C2CfgDscNam )  + ' (' +
     C                                        %TrimR( C2TxtDsc    )  + ')' +
     C                                        ' is currently '        +
     C                                        %TrimR( C2CurStsTxt )
     C                                      )
     **
     C                   EndSr
     **-- Send completion message:  ------------------------------------------**
     P SndCmpMsg       B
     D                 Pi            10i 0
     D  PxMsgId                      10a   Const
     D  PxMsgF                       10a   Const
     D  PxMsgFlib                    10a   Const
     D  PxMsgDta                    512a   Const  Varying
     **-- Send program message:  ---------------------------------------------**
     D SndPgmMsg       Pr                  ExtPgm( 'QMHSNDPM' )                 send program message
     D  SpMsgId                       7a   Const                                message identifier
     D  SpMsgFq                      20a   Const                                message file
     D  SpMsgDta                    512a   Const Options( *VarSize )            message data
     D  SpMsgDtaLen                  10i 0 Const                                message data length
     D  SpMsgTyp                     10a   Const                                message type
     D  SpCalStkE                    10a   Const Options( *VarSize )            call stack entry
     D  SpCalStkCtr                  10i 0 Const                                call stack counter
     D  SpMsgKey                      4a                                        message key
     D  SpError                     512a         Options( *VarSize )            API error code
     **
     D  SpCalStkElen                 10i 0 Const Options( *NoPass )             call stack counter
     D  SpCalStkEq                   20a   Const Options( *NoPass )             call stack counter
     D  SpDspWait                    10i 0 Const Options( *NoPass )             call stack counter
     **
     D  SpCalStkEtyp                 20a   Const Options( *NoPass )             call stack counter
     D  SpCcsId                      10i 0 Const Options( *NoPass )             call stack counter
     **
     **-- Send error message:  -----------------------------------------------**
     **
     C                   CallP     SndPgmMsg( PxMsgId
     C                                      : PxMsgF + PxMsgFlib
     C                                      : PxMsgDta
     C                                      : %Len( PxMsgDta )
     C                                      : '*COMP'
     C                                      : '*PGMBDY'
     C                                      : 1
     C                                      : MsgKey
     C                                      : ApiError )
     **
     C                   If        AeBytAvl    = *Zero
     C                   Return    0
     **
     C                   Else
     C                   Return    -1
     C                   EndIf
     **
     P SndCmpMsg       E
