× 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.



I've never done FTP exit points, so I can't help with that, I can give
you a sample of reading an IFS directory in RPG, though.

I'll put the code at the end of the message.


On Wed, 27 Mar 2002, Jim Franz wrote:

> there was an rpg for reading ifs directories posted
> about a year ago. possibly in midrange-l list.
> works very well. If you can't find the archive,
> email me privately & I'll find where I used it (may
> take a day or two)
> jim
>
> ----- Original Message -----
> From: "Giri Gopal" <GiriGopal@bcginK.com>
> To: <rpg400-l@midrange.com>
> Sent: Wednesday, March 27, 2002 10:30 AM
> Subject: FTP Exit point and IFS directory reads
>
>
> > Hello:
> >
> > Can I read the IFS directory in my rpg program. I want to read the directory
> > and get the file names. Can this be done?  Next question is I read an
> > article about FTP exit points. Does any one have some sample programs you
> > can share how to read an IFS directory and how to implement FTP exit points.
> >
> >
> > Thanks for your help
> > GG
> >

I know I've posted this before, but I don't feel like searching the
archives, so here it is again:

     ** This is a simple test program, to demonstrate reading a directory
     **  using the IFS API with RPG IV.

     H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('QC2LE')

      ** <<CHANGE THIS!!>>
     D PATHTOLIST      C                   CONST('/QOpenSys/test/')

     D**********************************************************************
     D*
     D* Directory Entry Structure (dirent)
     D*
     D* struct dirent {
     D*   char           d_reserved1[16];  /* Reserved                       */
     D*   unsigned int   d_reserved2;      /* Reserved                       */
     D*   ino_t          d_fileno;         /* The file number of the file    */
     D*   unsigned int   d_reclen;         /* Length of this directory entry
     D*                                     * in bytes                       */
     D*   int            d_reserved3;      /* Reserved                       */
     D*   char           d_reserved4[8];   /* Reserved                       */
     D*   qlg_nls_t      d_nlsinfo;        /* National Language Information
     D*                                     * about d_name                   */
     D*   unsigned int   d_namelen;        /* Length of the name, in bytes
     D*                                     * excluding NULL terminator      */
     D*   char           d_name[_QP0L_DIR_NAME]; /* Name...null terminated   */
     D*
     D* };
     D*
     D p_dirent        s               *
     D dirent          ds                  based(p_dirent)
     D   d_reserv1                   16A
     D   d_reserv2                   10U 0
     D   d_fileno                    10U 0
     D   d_reclen                    10U 0
     D   d_reserv3                   10I 0
     D   d_reserv4                    8A
     D   d_nlsinfo                   12A
     D     nls_ccsid                 10I 0 OVERLAY(d_nlsinfo:1)
     D     nls_cntry                  2A   OVERLAY(d_nlsinfo:5)
     D     nls_lang                   3A   OVERLAY(d_nlsinfo:7)
     D     nls_reserv                 3A   OVERLAY(d_nlsinfo:10)
     D   d_namelen                   10U 0
     D   d_name                     640A

     D*--------------------------------------------------------------------
     D* Open a Directory
     D*
     D* DIR *opendir(const char *dirname)
     D*
     D*--------------------------------------------------------------------
     D opendir         PR              *   EXTPROC('opendir')
     D  dirname                        *   value options(*string)

     D*--------------------------------------------------------------------
     D* Read Directory Entry
     D*
     D* struct dirent *readdir(DIR *dirp)
     D*
     D*--------------------------------------------------------------------
     D readdir         PR              *   EXTPROC('readdir')
     D  dirp                           *   value options(*string)

      *-------------------------------------------------------------------
      * prototype defs stolen from ERRNO_H (requires BNDDIR('QC2LE'))
      *  Used for working with errors for the UNIX-type APIs
      *-------------------------------------------------------------------
     D @__errno        PR              *   ExtProc('__errno')
     D strerror        PR              *   ExtProc('strerror')
     D    errnum                     10I 0 value
     D errno           PR            10I 0


     D* a few local variables...
     D dh              S               *
     D Name            S            640A
     D Msg             S             52A

     c                   eval      *inlr = *On

     C* Step1: Open up the directory.
     C                   eval      dh = opendir(PATHTOLIST)
     C                   if        dh = *NULL
     c                   eval      Msg = 'opendir: '+ %str(strerror(errno))
     c                   dsply                   Msg
     c                   return
     c                   endif

     C* Step2: Read each entry from the directory (in a loop)
     c                   eval      p_dirent = readdir(dh)
     c                   dow       p_dirent <> *NULL

     c                   eval      Name = %str(%addr(d_name))
     c                   if        Name<>'.' and Name<>'..'
     c                   eval      Msg = Name
     c     Msg           dsply
     c                   endif

     c                   eval      p_dirent = readdir(dh)
     c                   enddo

     C* Step3: End Program
     c                   dsply                   Pause             1
     c                   return


      *-------------------------------------------------------------------
      * Retrieve the error number for UNIX-type APIs
      *-------------------------------------------------------------------
     P errno           B
     D errno           PI            10I 0
     D p_errno         S               *
     D wwreturn        S             10I 0 based(p_errno)
     C                   eval      p_errno = @__errno
     c                   return    wwreturn
     P                 E



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.