midrange.com code scratchpad
Name:
CP1246R - qp0lGetAttr example
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
03/23/2016 03:03:56 pm
IP:
Logged
Description:
Use qp0lGetAttr to retrieve both check out (QP0L_ATTR_CHECKED_OUT) and object authority (QP0L_ATTR_AUTH) information
Code:
  1.       //--------------------------------------------------------------------------------------------------------------//
  2.       //                                                                                                              //
  3.       //                                                                                                              //
  4.       //                                       contrived example - Qp0lGettAttr                                       //
  5.       //                                                                                                              //
  6.       //                                                                                                              //
  7.       //--------------------------------------------------------------------------------------------------------------//
  8.        Ctl-Opt dftActGrp(*No) actGrp(*Caller)
  9.                debug(*Yes) option(*SrcStmt:*NoDebugIO)
  10.                BndDir('QC2LE')
  11.                Main(cp1246r)                                                   ;
  12.       //--------------------------------------------------------------------------------------------------------------//
  13.       //                                                                                                              //
  14.       //... procedure interfaces ...                                                                                  //
  15.       //                                                                                                              //
  16.       //--------------------------------------------------------------------------------------------------------------//
  17.       //
  18.       // ... external services ...
  19.       //
  20.        Dcl-PR getAttr       Int(10)         ExtProc('Qp0lGetAttr')             ;
  21.          *n                 Pointer                         Value              ;
  22.          *n                 Pointer                         Value              ;
  23.          *n                 Pointer                         Value              ;
  24.          *n                 Uns(10)                         Value              ;
  25.          *n                 Pointer                         Value              ;
  26.          *n                 Pointer                         Value              ;
  27.          *n                 Uns(10)                         Value              ;
  28.        End-PR                                                                  ;
  29.        Dcl-PR @__errno      Pointer         ExtProc('__errno')                 ;
  30.        End-PR                                                                  ;
  31.       //--------------------------------------------------------------------------------------------------------------//
  32.       //                                                                                                              //
  33.       // ... global variables/constants ...                                                                           //
  34.       //                                                                                                              //
  35.       //--------------------------------------------------------------------------------------------------------------//
  36.        Dcl-DS qlgPathName                   Align Qualified                    ;
  37.          CCSID              Int(10)         Inz(0)                             ;
  38.          country            Char(2)         Inz(x'0000')                       ;
  39.          language           Char(3)         Inz(x'000000')                     ;
  40.          reserved1          Char(3)         Inz(*Allx'00')                     ;
  41.          pathType           Int(10)         Inz(0)                             ;
  42.          pathLength         Int(10)                                            ;
  43.          pathDelimiter      Char(2)         Inz('/')                           ;
  44.          reserved2          Char(10)        Inz(*Allx'00')                     ;
  45.          path               Char(80)                                           ;
  46.        End-DS                                                                  ;
  47.  
  48.        Dcl-DS qp0AttrTypes                  Qualified                          ;
  49.          attrCnt            Uns(10)                                            ;
  50.          attrTypes          Uns(10)         Dim(256)        Inz(0)             ;
  51.        End-DS                                                                  ;
  52.  
  53.        Dcl-DS qp0lAttrCheckedOut Based(qp0lAttrCheckedOut@) Qualified          ;
  54.          status             Char(1)                                            ;
  55.          user               Char(10)                                           ;
  56.          reserved1          Char(1)                                            ;
  57.          time               Int(10)                                            ;
  58.        End-DS                                                                  ;
  59.  
  60.        Dcl-DS qp0lAttrAuth  Based(qp0lAttrAuth@)            Qualified          ;
  61.          owner              Char(10)                                           ;
  62.          primaryGroup       Char(10)                                           ;
  63.          autl               Char(10)                                           ;
  64.          reserved1          Char(10)                                           ;
  65.          offset             Uns(10)                                            ;
  66.          userCount          Uns(10)                                            ;
  67.          szUserFld          Uns(10)                                            ;
  68.          reserved2          Char(12)                                           ;
  69.          dta                Char(1)                                            ;
  70.        End-DS                                                                  ;
  71.  
  72.        Dcl-DS qp0lAuthorityUsers Dim(256) Based(qp0lAuthorityUsers@) Qualified ;
  73.          name               Char(10)                                           ;
  74.          aut                Char(10)                                           ;
  75.          objMgmt            Char(1)                                            ;
  76.          objExistence       Char(1)                                            ;
  77.          objAlter           Char(1)                                            ;
  78.          objReference       Char(1)                                            ;
  79.          reserved1          Char(10)                                           ;
  80.          dtaOperational     Char(1)                                            ;
  81.          dtaRead            Char(1)                                            ;
  82.          dtaAdd             Char(1)                                            ;
  83.          dtaUpdate          Char(1)                                            ;
  84.          dtaDelete          Char(1)                                            ;
  85.          dtaExecute         Char(1)                                            ;
  86.          dtaExclude         Char(1)                                            ;
  87.          reserved2          Char(7)                                            ;
  88.        End-DS                                                                  ;
  89.  
  90.        Dcl-DS buffWin       Based(buffWin@) Qualified                          ;
  91.          offset             Int(10)                                            ;
  92.          attrib             Int(10)                                            ;
  93.          szAttrib           Int(10)                                            ;
  94.          reserved1          Char(4)                                            ;
  95.          attribDta          Char(1)                                            ;// all we need is the address
  96.        End-DS                                                                  ;
  97.  
  98.        Dcl-C  QP0L_ATTR_CHECKED_OUT         9                                  ;
  99.        Dcl-C  QP0L_ATTR_AUTH                11                                 ;
  100.       //--------------------------------------------------------------------------------------------------------------//
  101.       //                                                                                                              //
  102.       //                                                  Procedures                                                  //
  103.       //                                                                                                              //
  104.       //--------------------------------------------------------------------------------------------------------------//
  105.       //                                                   mainLine                                                   //
  106.       //--------------------------------------------------------------------------------------------------------------//
  107.        Dcl-Proc cp1246r                                                        ;
  108.          Dcl-PI *n          ExtPgm                                             ;
  109.            pathName         Char(80)                                           ;
  110.          End-PI                                                                ;
  111.  
  112.  
  113.        Dcl-S  buffer        Char(1024)      Based(buffer@)                     ;
  114.        Dcl-S  bfrSN         Uns(10)                                            ;// buffer size needed
  115.        Dcl-S  bfrSR         Uns(10)                                            ;// buffer size returned
  116.        Dcl-S  rtnVal        Int(10)                                            ;
  117.        Dcl-S  errno         Int(10)         Based(errno@)                      ;
  118.        Dcl-S  tstOffset     Int(10)                                            ;
  119.  
  120.        buffer@                   = %Alloc(1024)                                ;// arbitrary - only need 32
  121.        qlgPathName.Path          = %Trim(pathName)                             ;
  122.        qlgPathName.PathLength    = %Len(%Trim(qlgPathName.Path))               ;
  123.        qp0AttrTypes.attrCnt      = 2                                           ;
  124.        qp0AttrTypes.attrTypes(1) = 9                                           ;
  125.        qp0AttrTypes.attrTypes(2) = 11                                          ;
  126.  
  127.        rtnVal = getAttr( %Addr(qlgPathName)
  128.                        : %Addr(qp0AttrTypes)
  129.                        : buffer@
  130.                        : 1024
  131.                        : %Addr(bfrSN)
  132.                        : %Addr(bfrSR)
  133.                        : 0
  134.                        )                                                       ;
  135.        If ( rtnVal <> 0 )                                                      ;
  136.          errno@ = @__errno()                                                   ;
  137.        Else                                                                    ;
  138.          buffWin@ = buffer@                                                    ;//next would be buffer@ + buffWin.offset
  139.          DoU ( tstOffset = 0 )                                                 ;
  140.            Select                                                              ;
  141.            When ( buffWin.attrib = QP0L_ATTR_CHECKED_OUT  )                    ;
  142.              qp0lAttrCheckedOut@ = %Addr(buffWin.attribDta)                    ;
  143.            When ( buffWin.attrib = QP0L_ATTR_AUTH         )                    ;
  144.              qp0lAttrAuth@       = %Addr(buffWin.attribDta)                    ;
  145.              qp0lAuthorityUsers@ = %Addr(qp0lAttrAuth.dta )                    ;
  146.            Other                                                               ;
  147.            EndSl                                                               ;
  148.            tstOffset = buffWin.offset                                          ;
  149.            buffWin@ += buffWin.offset                                          ;
  150.          EndDo                                                                 ;
  151.        EndIf                                                                   ;
  152.        Return                                                                  ;
  153.        End-Proc                                                                ;
  154.  
© 2004-2019 by midrange.com generated in 0.008s valid xhtml & css