HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong declaraiton of fdopen() in <stdio.h>

 
WW304289
Frequent Advisor

Wrong declaraiton of fdopen() in <stdio.h>

$ libr/extra=crtl_class/out=tt sys$share:decc$rtldef.tlb
VMS_V83-016
$
According to CRTL Manual and online help, the fdopen() function must be called with access mode (e.g. "ctx=bin") that was specified in the original open() or creat() call.

However, the function is not declared as a function with variable number of arguments in . It makes it impossible to use the function for a file opened with explicitly specified access mode. Without the access mode, the function fails with EINVAL.

$ libr/extra=crtl_class/out=tt sys$share:decc$rtldef.tlb
VMS_V83-016
$

Thanks,
-Boris
3 REPLIES
Steven Schweda
Honored Contributor

Re: Wrong declaraiton of fdopen() in <stdio.h>

Wrong usage of fdopen() in user's code?

Around here, the actual HELP CRTL text is:

[...]
Note that the access mode specified must
agree with the mode used to originally open
the file. This includes binary/text access
mode ("b" mode on fdopen and the "ctx=bin"
option on creat or open).
[...]

I took this to mean that if one used
"ctx=bin" in his creat() or open(), then he
would need to use "b" in his fdopen().

Do you have a failing test case? I can't see
exactly what you're doing.

I seem to recall defining O_BINARY myself on
VMS, using it to identify a "ctx=bin" file,
and then supplying my own openfd_vms()
function which masks off that bit before
calling the real open(). Cdrtools, perhaps?
WW304289
Frequent Advisor

Re: Wrong declaraiton of fdopen() in <stdio.h>

"
This includes binary/text access
mode ("b" mode on fdopen and the "ctx=bin"
option on creat or open).
"

It may be a user error but it depends on how one interprets the word "includes" in the quote above: just "ctx=bin" or any access mode.

On VMS, I call open() with "ctx=stm" access mode and I thought that I need to specify it in a call to fdopen() also, as an optional argument, because "ctx=stm" does not map to any standard access mode. Now I don't think I need it.

Thanks for the reply. I'll close this thread. Perhaps, the documentation can be updated to make it clear that FILE pointer returned by fdopen() "inherits" properties of the original file descriptor: access mode, sharing, ... etc so there is no need to specify them explicitly on fdopen() call.

Thanks again,
-Boris
WW304289
Frequent Advisor

Re: Wrong declaraiton of fdopen() in <stdio.h>

Documentation issue, not a bug in the CRTL.