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



Ironically, the first thing I did was make sure the O_TEXTDATA option wasn't used. And still had inconsistent results.

I did get around it with the fopen and it ran straight through no issues.

I was just getting the 10u/0 and 10i/0 confused on my side.


Fun fun.

Jay



----- Original Message -----

From: "Scott Klement" <rpg400-l@xxxxxxxxxxxxxxxx>
To: "RPG programming on the IBM i (AS/400 and iSeries)" <rpg400-l@xxxxxxxxxxxx>
Sent: Thursday, January 14, 2016 2:31:25 PM
Subject: Re: RPG prototype for C-language FILE *

Jay,

Here are the definitions I use for the fopen(), et al, APIs in RPG:
http://www.scottklement.com/rpg/copybooks/stdio_h.rpgle.txt

However, it might be worth noting that these APIs call the other ones
(open() and friends) under the covers. They add a layer of buffering on
top of the standard IFS APIs, which can be useful... but they aren't
any better at handling "binary data".

I've never had an issue with open() and friends handling binary...
works flawlessly, just don't add the O_TEXTDATA option. (That option
tells the API that it's text, not binary...)

With the fopen() APIs, I've had problems with binary data... namely, if
you use fgets, it seems to treat it as text, even if you specified the
'b' flag on fopen(). This was not a problem if I used fread() instead.
And, this was a long time ago (10ish years ago) so it's possible that
they already fixed it. But, the point here, is that I've actually found
binary works better with open() and friends vs. fopen().

If you're having trouble with not preserving the byte values of your
file, I think it's likely that there's a bug in your code rather than
the IFS APIs.

-SK



On 1/14/2016 7:16 AM, tegger@xxxxxxxxxxx wrote:
Anyone come across a good prototype for C's FILE structure?

I need to read/write binary files on the IFS and the standard open() isn't cutting it. The files are getting trashed. From my C-programming days, I know the fopen/fgetc/fputc/fclose process will do exactly what I need regardless of the nature of the file.


Jay


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.