midrange.com code scratchpad
Name:
CP1245R - CHKIN/CHKOUT status
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
03/23/2016 02:57:48 pm
IP:
Logged
Description:
Retrieve (for a given IFS file) CHKIN/CHKOUT data (using the QP0L_ATTR_CHECKED_OUT option with the Qp0lGetAttr API)
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(cp1245r)                                                   ;
  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.       //                                                  Procedures                                                  //
  34.       //                                                                                                              //
  35.       //--------------------------------------------------------------------------------------------------------------//
  36.       //                                                   mainLine                                                   //
  37.       //--------------------------------------------------------------------------------------------------------------//
  38.        Dcl-Proc cp1245r                                                        ;
  39.          Dcl-PI *n          ExtPgm                                             ;
  40.            pathName         Char(80)                                           ;
  41.          End-PI                                                                ;
  42.  
  43.        Dcl-DS qlgPathName                   Align Qualified                    ;
  44.          CCSID              Int(10)         Inz(0)                             ;
  45.          country            Char(2)         Inz(x'0000')                       ;
  46.          language           Char(3)         Inz(x'000000')                     ;
  47.          reserved1          Char(3)         Inz(*Allx'00')                     ;
  48.          pathType           Int(10)         Inz(0)                             ;
  49.          pathLength         Int(10)                                            ;
  50.          pathDelimiter      Char(2)         Inz('/')                           ;
  51.          reserved2          Char(10)        Inz(*Allx'00')                     ;
  52.          path               Char(80)                                           ;
  53.        End-DS                                                                  ;
  54.  
  55.        Dcl-DS qp0AttrTypes                  Qualified                          ;
  56.          attrCnt            Uns(10)                                            ;
  57.          attrTypes          Uns(10)         Dim(256)            Inz(0)         ;
  58.        End-DS                                                                  ;
  59.  
  60.        Dcl-DS qp0lAttrCheckedOut Based(qp0lAttrCheckedOut@) Qualified          ;
  61.          status             Char(1)                                            ;
  62.          user               Char(10)                                           ;
  63.          reserved1          Char(1)                                            ;
  64.          time               Int(10)                                            ;
  65.        End-DS                                                                  ;
  66.  
  67.        Dcl-DS buffWin       Based(buffWin@) Qualified                          ;
  68.          offset             Int(10)                                            ;
  69.          attrib             Int(10)                                            ;
  70.          szAttrib           Int(10)                                            ;
  71.          reserved1          Char(4)                                            ;
  72.          attribDta          Char(1)                                            ;// all we need is the address
  73.        End-DS                                                                  ;
  74.  
  75.        Dcl-S  buffer        Char(1024)      Based(buffer@)                     ;
  76.        Dcl-S  bfrSN         Uns(10)                                            ;// buffer size needed
  77.        Dcl-S  bfrSR         Uns(10)                                            ;// buffer size returned
  78.        Dcl-S  rtnVal        Int(10)                                            ;
  79.        Dcl-S  errno         Int(10)         Based(errno@)                      ;
  80.  
  81.        buffer@                   = %Alloc(1024)                                ;// arbitrary - only need 32
  82.        qlgPathName.Path          = %Trim(pathName)                             ;
  83.        qlgPathName.PathLength    = %Len(%Trim(qlgPathName.Path))               ;
  84.        qp0AttrTypes.attrCnt      = 1                                           ;
  85.        qp0AttrTypes.attrTypes(1) = 9                                           ;
  86.  
  87.        rtnVal = getAttr( %Addr(qlgPathName)
  88.                        : %Addr(qp0AttrTypes)
  89.                        : buffer@
  90.                        : 1024
  91.                        : %Addr(bfrSN)
  92.                        : %Addr(bfrSR)
  93.                        : 0
  94.                        )                                                       ;
  95.        If ( rtnVal <> 0 )                                                      ;
  96.          errno@ = @__errno()                                                   ;
  97.        Else                                                                    ;
  98.          buffWin@ = buffer@                                                    ;//next would be buffer@ + buffWin.offset
  99.          qp0lAttrCheckedOut@ = %Addr(buffWin.attribDta)                        ;
  100.        EndIf                                                                   ;
  101.        Return                                                                  ;
  102.        End-Proc                                                                ;
  103.  
© 2004-2019 by midrange.com generated in 0.007s valid xhtml & css