Here is the /COPY from my RPG xTools service program for many of the IFS
routines.  You can use it freely; you just have to keep the original notice
in the source code.
Note that I've used two naming conventions, xxxxIFS and IFSxxxx.
xxxxIFS use the Unix C runtime library and provide the most flexibility. 
IFSxxxx use the As/400 IFS_C_xxxxx routines that allow a record-at-a-time
I/O to data on the IFS as well as other interesting things.
The point is, pick one style and use it. I now use the xxxxxIFS prototypes
almost exclusively.

-Bob Cozzi

      **  Copyright 2003 - Robert Cozzi, Jr.
      **  All rights reserved.
      **   RPG xTool - IFS Prototypes collection
      **  Permission granted for internal use-only
      **  provided the text between the two lines 
      **  containing all *  (asterisks) are retained.

     D O_READ_ONLY     C                   Const('r')
     D O_WRITE_ONLY    C                   Const('w')
     D R_OK            C                   Const(4)
     D W_OK            C                   Const(2)
     D F_OK            C                   Const(0)

     D O_RDONLY        C                   Const(1)
     D O_WRONLY        C                   Const(2)
     D O_RDWR          C                   Const(4)
     D O_CREAT         C                   Const(8)
     D O_EXCL          C                   Const(16)
     D O_CCSID         C                   Const(32)
     D O_TRUNC         C                   Const(64)
     D O_APPEND        C                   Const(256)
     D O_SYNC          C                   Const(1024)
     D O_DSYNC         C                   Const(2048)
     D O_RSYNC         C                   Const(4096)
     D O_NOCTTY        C                   Const(32768)
     D O_SHARE_RDONLY  C                   Const(65536)
     D O_SHARE_WRONLY  C                   Const(131072)
     D O_SHARE_RDWR    C                   Const(262144)
     D O_SHARE_NONE    C                   Const(524288)
     D O_CODEPAGE      C                   Const(8388608)
     D O_TEXT_CREAT    C                   Const(33554432)
     D O_INHERITMODE   C                   Const(134217728)
     D O_TEXTDATA      C                   Const(16777216)
     D O_LARGEFILE     C                   Const(536870912)

      ** Object Authority Flags
     D S_IXOTH         C                   Const(1)
     D S_IWOTH         C                   Const(2)
     D S_IROTH         C                   Const(4)
     D S_IRWXO         C                   Const(7)
     D S_IXGRP         C                   Const(8)
     D S_IWGRP         C                   Const(16)
     D S_IRGRP         C                   Const(32)
     D S_IRWXG         C                   Const(56)
     D S_IXUSR         C                   Const(64)
     D S_IWUSR         C                   Const(128)
     D S_IRUSR         C                   Const(256)
     D S_IRWXU         C                   Const(448)

     D openIFS         PR            10I 0 ExtProc('open64')
     D  szIFSFileName                  *   Value options(*string)
     D  openFlags                    10I 0 Value
     D  fMod                         10U 0 Value options(*nopass)
     D  CCSID                        10U 0 Value options(*nopass)

     D writeIfs        PR            10I 0 ExtProc('write')
     D   hFile                       10I 0 Value
     D   pBuffer                       *   Value
     D   nBytesToWrite...
     D                               10U 0 Value     

     D readIfs         PR            10I 0 ExtProc('read')
     D  hFile                        10I 0 Value
     D  szBuffer                       *   Value
     D  nBufLen                      10U 0 Value

     D closeIfs        PR            10I 0 ExtProc('close')
     D  hFile                        10I 0 Value

     D access          PR            10I 0 ExtProc('access')
     D  szIFSFile                      *   Value OPTIONS(*STRING)
     D  nAccessMode                  10I 0 Value

     D ifsTmpName      PR              *   ExtProc('_C_IFS_tmpnam')
     D   szFileName                    *   Value Options(*STRING)

     D ifsTmpFile      PR              *   ExtProc('_C_IFS_tmpfile')
     D* void

     D ifsOpen         PR              *   ExtProc('_C_IFS_fopen')
     D  szFileName                     *   Value Options(*STRING)
     D  ifsmode                        *   Value Options(*STRING)

     D ifsClose        PR            10I 0 ExtProc('_C_IFS_fclose')
     D  pIfsFile                       *   Value

     D ifsGets         PR              *   ExtProc('_C_IFS_fgets')
     D  inBuffer                       *   Value Options(*STRING)
     D  inBufLen                     10I 0 Value
     D  pIfsFile                       *   Value

     D ifsEof          PR            10I 0 ExtProc('_C_IFS_feof')
     D  pIfsFile                       *   Value

     D ifsReadLine     PR              *   ExtProc('_C_IFS_fgets')
     D  pInBuffer                      *   Value 
     D  inBufLen                     10I 0 Value
     D  pIfsFile                       *   Value

     D ifsRead         PR            10I 0 ExtProc('_C_IFS_fread')
     D  pInBuffer                      *   Value 
     D  unitSize                     10I 0 Value
     D  inBufLen                     10I 0 Value
     D  pIfsFile                       *   Value

     D ifsWrite        PR            10I 0 ExtProc('_C_IFS_fwrite')
     D  szOutBuffer                    *   Value 
     D  unitSize                     10I 0 Value
     D  nBufLen                      10I 0 Value
     D  pIfsFile                       *   Value

     D ifsWriteLine    PR              *   ExtProc('_C_IFS_fputs')
     D  szOutBuffer                    *   Value OPTIONS(*STRING)
     D  pIfsFile                       *   Value
     D ifsErrNo        PR              *   ExtProc('__errno')

      * Get file status
     D ifsStat         pr            10I 0 ExtProc('stat64')
     D  ifsFile                        *   Value options(*string)
     D  pStat                          *   Value
     D ifsStat_T       DS                  ALIGN
     D  ifs_Permissions...                                          
     D                               10U 0                         
     D  ifs_sFileID                  10U 0                         
     D  ifs_sLnkCnt                   5U 0                         
     D  ifs_sUsrID                   10U 0                         
     D  ifs_sGroupID                 10U 0                         
      ** File size, in bytes.
     D  ifs_nFileSize...
     D                               10I 0
     D  ifs_LastFileAccess...
     D                               10I 0
     D  ifs_LastChgTime...
     D                               10I 0
     D  ifs_LastStsChgTime...
     D                               10I 0
     D  ifs_FileSysID... 
     D                               10U 0
     D  ifs_BlockSize...         
     D                               10U 0
     D  ifs_AllocBytes...              
     D                               10U 0
     D  ifs_ObjectType...
     D                               11A
     D  ifs_CodePage...  
     D                                5U 0
     D                               62A
     D  ifs_GenID...
     D                               10U 0      

      **  Link (Create a link)
     D ifsLink         PR            10I 0 extproc('link')
     D  szFilePath                     *   value options(*string)
     D  szNewLink                      *   value options(*string)

      **  Unlink (Unlink an IFS file)
     D ifsUnlink       PR            10I 0 extproc('unlink')
     D  szFilePath                     *   value options(*string)

     D errno           PR              *   ExtProc('__errno') 

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Mike Wills
Sent: Thursday, July 29, 2004 10:34 AM
To: Midrange_RPG400_L
Subject: Writing to an IFS file

Is there any free wrappers for writing to the IFS? We are going to be
comming up on a project, and I would like to avoid writting that from
scratch if I don't have to. Does the iSeries Toolkit have something
like that?

Mike Wills
iSeries Programmer/Lawson Administrator
Want Gmail? Email koldark+gmail@xxxxxxxxx to get on my waiting list.
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives

This thread ...


Return to Archive home page | Return to MIDRANGE.COM home page