Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

Guardian Native C Library Calls (f) freopen64_oss(3)
function.
The original stream is closed regardless of whether the open64() function succeeds with the
named file. The freopen64() function returns a pointer to the FILE structure associated with the
stream parameter. The freopen64() function is typically used to attach the preopened streams
associated with stdin, stdout, and stderr to other files.
The mode parameter controls the access allowed to the stream. It can have one of these values:
r Open an existing file for read-only access.
w Create a file (or truncate an existing file to length zero) and open it for write-only
access.
a Create a file (or open an existing file) and open it for append (write at the end of
the file) access.
r+ Open an existing file for update access (reading and writing).
w+ Create a file (or truncate an existing file to length zero) and open it for update
access.
a+ Create a file (or open an existing file) and open it for update access with writing
at the end of the file.
The OSS version of freopen64() does not distinguish between text and binary files. Specifying a
value of mode that consists of an r, w,ora followed by a b indicates a binary file. However, the
OSS version of the freopen64 function ignores the b in the value of mode.
When you open a file for update, you can perform both input and output operations on the result-
ing stream. However, an input operation cannot directly follow an output operation without an
intervening fflush( ) function call or a file-positioning operation (fseek(), fsetpos(),orrewind()
function). Also, an output operation cannot directly follow an input operation without an inter-
vening 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. 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 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 freopen64() function: freopen64_oss() and
freopen64_guardian(). The variants support the unique file naming conventions and structures
of the OSS and Guardian file systems, respectively.
Explicit calls to the freopen64_oss()
and f
reopen64_guardian() variants in source code are
only made when the behavior of one environment is desired from the other environment.
freopen64_oss() is functionally identical to the freopen64() 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.
527192-018 Hewlett-Packard Company 2115