The Question is:
The C RTL fopen() and creat() calls support optional RMS options specified as
additional parameters to the call. What, preciesly, do the CTX=STM and CTX=REC
options do? The CRTL Ref Manual (Table REF-3) simply states that they cause
they force stream or r
ecord mode access, and refers the reader to the RMS Reference Manual for
further information. The RMS manual has nothing about stream or record access
mode that I could find. Of course, the CTX field in RMS is used for user- or
so presumably the C RTL routines are using CTX as a placeholder to indicate the
access mode here.
Context: I'm porting an O-O language processor and development system from UNIX
to VMS, and I'm having some problems with illegal file specs that might be
resolved by using the VMS Porting library ("THE JACKETS"). However, when I use
the fopen jacket, whi
ch specifies CTX=STM, the system does not read the same stream of characters
that it gets when using an unmodified fopen() call. I'm trying to understand
precisely how the CTX=STM and CTX=REC options affect the data returned when
reading RMS files.
The Answer is :
Current versions of the C RTL when combined with the current compiler
and ODS-5 can translate many native UNIX file specifications -- though
not all -- into the specification format native to OpenVMS.
As you are undoubtedly aware, illegal file specifications are unlikely
related to the file access mode. As no details of the illegal file
specifications were included, no specific options can be provided.
Chapter one of the C RTL Reference Manual contains a detailed discussion
of the access context options. The core text:
"RMS sequential files can be opened in record mode or stream mode. By
default, STREAM_LF files are opened in stream mode; all other file
types are opened in record mode. When opening a file, you can override
these defaults by specifying the optional argument "ctx=rec" to force
record mode, or "ctx=stm" to force stream mode. RMS relative and
indexed files are always opened in record mode. The access mode
determines the behavior of various I/O functions in the Compaq C
Stream files are the closest organization to the native UNIX file system.
Files with record structures are native to OpenVMS, and provide for RMS
caching and various file organizations not necessarily found integrated
directly in other operating system platforms.
The OpenVMS Wizard often prefers direct RMS access when specific control
over RMS activities is required, as the C RTL provides an emulation of
UNIX I/O on C and mechanisms to control this emulation. While the C
RTL approach is quite functional, direct RMS access can be easier to
understand as there is no need to explicitly disable the RTL capabilities
and assumptions provided to support C norms and C applications written
for other platforms.