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




Does any one use this function in RPGLE?

I use them all the time.

If so, what authorities are required to read a file. I am calling passing the parm of 'r' which, to the best of my knowledge, is the flag for read only. The jobs work great if you have *RWX but blow up if you have *R or *RX only.

Correct. I just tried to re-create your problem by creating a file that I only have *R permission to, and it worked just fine, so I'm not sure what you're doing differently.

I have been searching IBM great hiding place called InfoCenter with no luck.

What I would really like is the link to the whole _C_IFS_ api's that
shows the necessary authorities.

Okay. I'll explain. These functions (fopen & friends) aren't considered system APIs. ( The system APIs for working with the IFS are open(), read(), etc. ). Instead, the functions that you're trying to call are part of the ILE C runtime library.

According to the ANSI standards for the C programming language, there needs to be a function called fopen() that you can use to open and read a file. If you didn't have that on the iSeries, the iSeries wouldn't conform to the standards, which wouldn't be good.

So, IBM created an fopen() function that worked with the standard library/file scheme, compatible with what you can do with F-specs in RPG.

Then, later, IBM created the IFS. This made it easier for people porting C software from Windows or Unix because the IFS stores stream files in the same way. Those people were using fopen() to read stream files on Windows/Unix, so it's desirable for them to use the same functions here on the iSeries. But, fopen() already exists! And it's not for the IFS!

So they added a compiler option. If you specify SYSIFCOPT(*IFSIO) on the compile command, the fopen() function will access the IFS. If don't specify that option, it uses the traditional library/object method.

The way they implemented this SYSIFCOPT(*IFSIO) option was by writing two underlying APIs in the ILE C runtime. One called fopen(), and another called _C_IFS_fopen(). When you specify *IFSIO, it automatically maps fopen() to the latter.

If you wanted to, you COULD do the same thing in RPG. In RPG the code would look like this:

      /if defined(USE_IFS_IO)
     D fopen           PR              *   ExtProc('_C_IFS_fopen')
      /else
     D fopen           PR              *   ExtProc('fopen')
      /endif
     D   filename                      *   value options(*string)
     D   mode                          *   value options(*string)

Of course, there's really no reason to use the standard fopen() function in RPG, since RPG has it's own support for traditional file access. You only need the IFS support, since RPG doesn't have that built in.

Now that you understand that, hopefully you understand why you can't find _C_IFS_fopen() in the information center. The documentation is intended for C programmers, and they don't think of this function as having that name... they simply think of it as fopen().

Go into the Information Center and look at

 Programming -> Languages -> C and C++ -> ILE C/C++ Run Time Library Functions

That's the path for V5R3. The paths for earlier versions are similar, but I don't think there was a "Languages" section in older releases. You just go straight from Programming to C and C++.

Anyway, in that book, look up the fopen() function. (or fclose, fread, fgets, whatever you need.)

Another interesting function is fdopen(). It lets you take a file that you've already opened with open(), and upgrade it to work with fgets(), fread(), etc.

Hopefully that helps...

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.