Operating System - OpenVMS
1753400 Members
7360 Online
108792 Solutions
New Discussion юеВ

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