× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: What API to get IFS last used date?
  • From: Andrew Borts <andrewb@xxxxxxxxxxxxxxxxxxx>
  • Date: Thu, 10 May 2001 08:38:36 -0400
  • Organization: Seta Corporation

Scott - I found some of your examples in the archives... "impressive young luke 
- you've learned to use the force"

I'm going to play with them today...

Andrew Borts / E-Commerce Project Leader
Seta Corporation
6400 East Rogers Circle
Boca Raton, FL 33499

E-mail: Andrewb@setacorporation.com 
Corporate web site http://www.setacorporation.com 
E-Commerce web site http://www.palmbeachjewelry.com
Voice: 561-994-2660 Ext. 2211 / Fax: 561-997-0774

-----Original Message-----
From:   Scott Klement [SMTP:klemscot@klements.com]
Sent:   Thursday, May 10, 2001 2:01 AM
To:     RPG400-L@midrange.com
Subject:        Re: What API to get IFS last used date?



On Wed, 9 May 2001, Buck Calabro wrote:

> Andrew wondered:
> 
> >What is the API to get information about IFS objects with Last Used dates?

Errr.. sorry I deleted the original message by mistake.  What is being 
looked for here...    the last "use" (i.e. last time the file was read)
or the last "modification" date?  or the last time the status of the file
was changed?  (i.e. the access mode, rename, or other modification)

these are stored in the stat structure returned by the stat, fstat and
lstat routines from the UNIX-type API manual.   

> Are you familiar with C?  With using C functions in RPG IV programs?
> Several of us have been doing this for a while.  In particular, search the
> archives for Scott Klement or IFS; he's posted several excellent examples.

Have I posted this before?  How clever of me!

In your application, you probably want to use stat().  (The difference
between stat and lstat is only useful when a symbolic link is being
referenced.  With stat() the data returned is the object the symbolic
link is pointing at, with lstat() the returned data is that of the 
link itself)

If you prefer to use lstat, all you have to do is change ExtProc('stat')
to ExtProc('lstat')  

So...  stat.  Right?  Here's an example of getting meaningful dates:

     H DFTACTGRP(*NO) ACTGRP(*NEW)
     D**********************************************************************
     D* File Information Structure (stat)
     D*
     D* struct stat {
     D*  mode_t         st_mode;       /* File mode                       */
     D*  ino_t          st_ino;        /* File serial number              */
     D*  nlink_t        st_nlink;      /* Number of links                 */
     D*  uid_t          st_uid;        /* User ID of the owner of file    */
     D*  gid_t          st_gid;        /* Group ID of the group of file   */
     D*  off_t          st_size;       /* For regular files, the file
     D*                                 * size in bytes                   */
     D*  time_t         st_atime;      /* Time of last access             */
     D*  time_t         st_mtime;      /* Time of last data modification  */
     D*  time_t         st_ctime;      /* Time of last file status change */
     D*  dev_t          st_dev;        /* ID of device containing file    */
     D*  size_t         st_blksize;    /* Size of a block of the file     */
     D*  unsigned long  st_allocsize;  /* Allocation size of the file     */
     D*  qp0l_objtype_t st_objtype;    /* AS/400 object type              */
     D*  unsigned short st_codepage;   /* Object data codepage            */
     D*  char           st_reserved1[66]; /* Reserved                     */
     D* };
     D*
     D p_statds        S               *
     D statds          DS                  BASED(p_statds)
     D  st_mode                      10U 0
     D  st_ino                       10U 0
     D  st_nlink                      5U 0
     D  st_pad                        2A
     D  st_uid                       10U 0
     D  st_gid                       10U 0
     D  st_size                      10I 0
     D  st_atime                     10I 0
     D  st_mtime                     10I 0
     D  st_ctime                     10I 0
     D  st_dev                       10U 0
     D  st_blksize                   10U 0
     D  st_alctize                   10U 0
     D  st_objtype                   12A
     D  st_codepag                    5U 0
     D  st_resv11                    62A
     D  st_ino_gen_id                10U 0

     D*--------------------------------------------------------------------
     D* Get File Information
     D*
     D* int stat(const char *path, struct stat *buf)
     D*--------------------------------------------------------------------
     D stat            PR            10I 0 ExtProc('stat')
     D   path                          *   value options(*string)
     D   buf                           *   value

     D GetTimeZone     PR             5A

     D timezone        DS
     D   tzDir                        1A
     D   tzHour                       2S 0
     D   tzFrac                       2S 0


     D statsize        S             10I 0
     d Msg             S             50A
     D AccessTime      S               Z
     D ModifyTime      S               Z
     D ChgStsTime      S               Z
     D charTS          S             26A
     D Epoch           S               Z   INZ(z'1970-01-01-00.00.00')

     c                   eval      *inlr = *on

     c                   eval      statsize = %size(statds)
     c                   alloc     statsize      p_statds

     c                   if        stat('/funkyfile.dat': p_statds) < 0
     c                   eval      Msg = 'stat() failed?  Check errno!'
     c                   dsply                   Msg
     c                   return
     c                   endif

      ** times in statds are seconds from the "epoch" (Jan 1, 1970)
      **   and are in GMT (Greenwich Mean Time)...
      ** Hey!  Lets convert them to RPG timestamps!
     c     Epoch         adddur    st_atime:*S   AccessTime
     c     Epoch         adddur    st_mtime:*S   ModifyTime
     c     Epoch         adddur    st_ctime:*S   ChgStsTime

      ** adjust timestamps for timezone:
     c                   eval      timezone = GetTimeZone
     c                   if        tzDir = '-'
     c                   subdur    tzHour:*H     AccessTime
     c                   subdur    tzHour:*H     ModifyTime
     c                   subdur    tzHour:*H     ChgStsTime
     c                   else
     c                   adddur    tzHour:*H     AccessTime
     c                   adddur    tzHour:*H     ModifyTime
     c                   adddur    tzHour:*H     ChgStsTime
     c                   endif

     C* display the relevant times:
     c                   move      AccessTime    charTS
     c                   eval      Msg = 'Last Access ' + charTS
     c                   dsply                   Msg

     c                   move      ModifyTime    charTS
     c                   eval      Msg = 'Last Modified ' + charTS
     c                   dsply                   Msg

     c                   move      ChgStsTime    charTS
     c                   eval      Msg = 'Status Changed ' + charTS
     c                   dsply                   Msg

     c                   dealloc                 p_statds
     c                   eval      *inlr = *on


     P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P*  This gets the offset from Universal Coordinated Time (UTC)
     P*    from the system value QUTCOFFSET
     P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P GetTimeZone     B
     D GetTimeZone     PI             5A
     D peRcvVar        S              1A   DIM(100)
     D peRVarLen       S             10I 0
     D peNumVals       S             10I 0
     D peSysValNm      S             10A
     D p_Offset        S               *
     D wkOffset        S             10I 0 BASED(p_Offset)
     D p_SV            S               *
     D dsSV            ds                  BASED(p_SV)
     D   dsSVSysVal                  10A
     D   dsSVDtaTyp                   1A
     D   dsSVDtaSts                   1A
     D   dsSVDtaLen                  10I 0
     D   dsSVData                     5A
     D dsErrCode       DS
     D  dsBytesPrv             1      4B 0 INZ(256)
     D  dsBytesAvl             5      8B 0 INZ(0)
     D  dsExcpID               9     15
     D  dsReserved            16     16
     D  dsExcpData            17    256
     C                   CALL      'QWCRSVAL'                           99
     C                   PARM                    peRcvVar
     C                   PARM      100           peRVarLen
     c                   PARM      1             peNumVals
     c                   PARM      'QUTCOFFSET'  peSysValNm
     c                   PARM                    dsErrCode
     c                   if        dsBytesAvl > 0  or  *IN99 = *On
     c                   return    *blanks
     c                   endif
     c                   eval      p_Offset = %addr(peRcvVar(5))
     c                   eval      p_SV = %addr(peRcvVar(wkOffset+1))
     c                   return    dsSVData
     P                 E



+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.