Guardian C Library Calls Reference Manual
Reference to Library Calls
Guardian TNS C Library Calls Reference Manual—128833 3-129
__ns_fget_file_state (supplementary)
__ns_fget_file_state (supplementary)
The __ns_fget_file_state function returns the state information for a file open for ANSI
I/O.
stream
denotes a file opened for ANSI I/O.
file_state
points to a variable that stores the file state information.
Return Value
0 if the operation is successful, -1 if an error occurs.
Usage Guidelines
•
This function is called from the primary process to retrieve the current file state
information. The primary process sends the state information through the
$RECEIVE facility to the backup process. The backup process calls the
__ns_fset_file_state function to update its state information for the file.
•
The variable containing the file state information, not the pointer to the variable,
must be sent through the $RECEIVE facility from the primary process to the backup
process.
•
If the file specified in the stream argument is not open, errno is set to ENONSTOP.
•
The only meaningful operations on file state information are retrieving with the
__ns_fget_file_state function, setting with the __ns_fset_file_state function, and
copying with an assignment statement or a copy function from the C run-time
library. The results of manipulating components of the file state information are
undefined.
•
The buffer for file operations is not part of the file state. This affects the input and
output streams:
•
For input streams, the file position is a component of the file state. The
__ns_fset_file_state function updates the file position for the backup process to the
file position of the primary process at the time the __ns_fget_file_state function was
called. Thus, buffering is not an issue for an input stream from a disk device. For all
other input streams, buffered but unread input is lost. For these nondisk input
streams, you can disable buffering with either the setvbuf or setnbuf function, ignore
the lost information, or manage the buffer yourself.
#include <nonstoph>
long __ns_fget_file_state(
FILE *stream,
__ns_std_io_file_state *file_state);