Guardian Native C Library Calls Reference Manual (G06.28+, H06.05+)

freopen64_oss(3) Guardian Native C Library Calls Ref
erence Manual
The original stream is closed regardless of whether the open64() function succeeds with the
named le. 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 les.
The mode parameter controls the access allowed to the stream. It can have one of these values:
r Open an existing le for read-only access.
w Create a le (or truncate an existing le to length zero) and open it for write-only
access.
a Create a le (or open an existing le) and open it for append (write at the end of
the le) access.
r+ Open an existing le for update access (reading and writing).
w+ Create a le (or truncate an existing le to length zero) and open it for update
access.
a+ Create a le (or open an existing le) and open it for update access with writing
at the end of the le.
The OSS version of freopen64() does not distinguish between text and binary les. Specifying a
value of mode that consists of an r, w,ora followed by a b indicates a binary le. However, the
OSS version of the freopen64 function ignores the b in the value of mode.
When you open a le 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 fush( ) function call or a le-positioning operation (fseek(), fsetpos( ),orrewind()
function). Also, an output operation cannot directly follow an input operation without an inter-
vening ush or le-positioning operation, unless the input operation encounters the end of the
le.
When you open a le for append (that is, when the mode parameter is a or a+), it is impossible to
overwrite information already in the le. You can use the fseek() function to reposition the le
pointer to any position in the le, but when output is written to the le, the current le pointer is
ignored. All output is written at the end of the le and the le pointer is repositioned to the end
of the output.
If two separate processes open the same le for append, each process can write freely to the le
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 le. If the data is buffered, it is not actually
written until it is ushed.
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 le naming conventions and structures
of the OSS and Guardian le systems, respectively.
Explicit calls to the freopen64_oss() and freopen64_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.
278 Hewlett-Packard Company 527192-007