Guardian Native C Library Calls Reference Manual (G06.28+, H06.05+)
Guardian Native C Library Calls (f) freopen_oss(3)
r Opens the file for reading.
w Creates a new file for writing, or opens and truncates a file to zero length.
a Appends (opens a file for writing at the end of the file, or creates a file for writ-
ing).
r+ Opens a file for update (reading and writing).
w+ Truncates or creates a file for update.
a+ Appends (opens a file for update, writing at the end of the file, or creates a file for
writing).
The OSS version of freopen( ) does not distinguish between text and binary files. Specifying a
value of mode that consists of a r, w,ora followed by a b indicates a binary file.
When you open a file for update, you can perform both input and output operations on the result-
ing stream. However, an output operation cannot be directly followed by an input operation
without an intervening fflush() function call or a file positioning operation (fseek(), fsetpos(),or
rewind() function). Also, an input operation cannot be directly followed by an output operation
without an intervening flush or file positioning operation, unless the input operation encounters
the end of the file.
When you open a file for append (that is, when the mode parameter is a or a+), it is impossible to
overwrite information already in the file. You can use the fseek() function to reposition the file
pointer to any position in the file, but when output is written to the file, the current file pointer is
ignored. All output is written at the end of the file and the file pointer is repositioned to the end
of the output.
If two separate processes open the same file for append, each process can write freely to the file
without destroying the output being written by the other. The output from the two processes is
intermixed in the order in which it is written to the file. Note that if the data is buffered, it is not
actually written until it is flushed.
When opened, a stream is fully buffered if and only if it can be determined that it does not refer
to an interactive device. The error and End-of-File indicators for the stream are cleared.
Interoperability Variants
The C run-time library supports two variants of the freopen() function: freopen_oss() and
freopen_guardian(). The variants support the unique file naming conventions and structures of
the OSS and Guardian file systems, respectively.
For the TNS C runtime library only, the header file maps calls to freopen( ) to the variant that
matches the target compilation environment. The target environment is set with the systype
pragma.
Explicit calls to the freopen_oss() and freopen_guardian() variants in source code are only
made when the behavior of one environment is desired from the other environment.
freopen_oss() is functionally identical to the freopen( ) function of the OSS environment. It is
the same as setting systype oss at compile-time. systype oss is the default setting for c89
in the OSS environment and on UNIX workstations.
freopen_guardian() is functionally identical to the freopen() function of the Guardian environ-
ment. It is the same as setting systype guardian at compile-time. systype guardian is
the default setting for the C and C++ compilers in the Guardian environment.
To use the freopen_oss() or freopen_guardian() functions, specify the _TANDEM_SOURCE
feature test macro.
527192-007 Hewlett-Packard Company 2−85