FFREAD(3C) Last changed: 3-5-98
ffread, ffwrite, ffweof, ffweod, ffreadf, ffwritef, ffweodf, ffweoff,
ffflush - Provides flexible file I/O
#include <ffio.h>
UNICOS and UNICOS/mk systems:
int ffread (int fd, void *buf, size_t nb [, struct ffsw *stat [,
int fulp [, int *ubc]]]);
int ffwrite (int fd, const void *buf, size_t nb [, struct ffsw
*stat [, int fulp [, int *ubc]]]);
int ffweof (int fd [, struct ffsw *stat]);
int ffweod (int fd [, struct ffsw *stat]);
int ffflush (int fd [, struct ffsw *stat]);
IRIX systems:
ssize_t ffread (int fd, void *buf, size_t nb);
ssize_t ffwrite (int fd, const void *buf, size_t nb);
int ffweof (int fd);
int ffweod (int fd);
int ffflush (int fd);
All systems:
size_t ffreadf (int fd, void *buf, size_t nb , struct ffsw *stat,
int fulp, int *ubc);
size_t ffwritef (int fd, const void *buf, size_t nb , struct ffsw
*stat, int fulp, int *ubc);
int ffweoff (int fd, struct ffsw *stat);
int ffweodf (int fd, struct ffsw *stat);
int ffflush (int fd, struct ffsw *stat);
UNICOS, UNICOS/mk, and IRIX systems
The ffread and ffwrite functions provide flexible file I/O (FFIO) to
record-oriented or byte stream-oriented data in an
application-transparent manner.
Function ffweof writes an end-of-file (EOF) if the function is
supported for the layer in use.
Function ffweod writes an end-of-data (EOD). If the FFIO
specification is stream oriented, this requests truncation of the file
at the current position.
Function ffflush instructs the layer to flush as much data to the file
as is convenient. For some layers, and layers which do no buffering
(for example, the syscall layer), this operation does nothing. For
record layers, the ffflush function will not terminate any partiallywritten
records. This function is intended for use on files which are
being written. It is undefined for files which are being read.
The arguments are as follows:
fd Number returned by ffopen(3C).
buf Pointer to the user data buffer.
nb Requested number of bytes to be read or written.
stat Pointer to the returned status structure.
fulp Either FULL or PARTIAL (defined in header file ffio.h);
indicates whether I/O should be performed in full or partial
record mode.
ubc Unused bit count. The word pointed to by this pointer is in
the range of 0 through 7; it is used to specify how many bits
in the last byte are not valid data.
The nb and ubc arguments are used together to determine an exact
number of bits to be transferred. nb always indicates the number of
bytes affected by the data transfer, even if only one bit is
transferred in that byte.
If argument ubc is omitted, it is assumed to be 0.
If ubc is specified, it functions as both an input and output
argument. It is passed to ffread or ffwrite as a request to omit
processing the specified number of bits in the last byte of the
request. For example, to read 2 bits from a file, you should set nb
to 1, set the word at ubc to 6, and call ffread. On completion of the
ffread request, the word pointed to by ubc is set by ffread to
indicate the number of unused bits in the last byte read. As in the
preceding example, if only one bit were available to be read, then the
word at ubc would be set to 7 by ffread.
For ffwrite, ubc is an input argument specifying the number of bits in
the last byte transferred that should not be written to the file.
Function ffwrite normally will not change the value of the word at
ubc, because, if the specified number of bits is not written, an error
is returned.
Upon successful completion, a non-negative value is returned.
Otherwise, -1 is returned and, if the stat argument is passed, the
error value is found in stat.sw_error. If the stat parameter is not
provided, the error code is found in errno.
If the stat parameter is passed, the sw_stat field is set to one of
the following values, indicating the condition that terminated the
operation:
Value Description
FFERR An error was encountered.
FFEOR An end-of-record (EOR) was encountered.
FFEOF An end-of-file (EOF) was encountered.
FFEOD An end-of-data (EOD) was encountered.
FFCNT For layers without record handling, some data was read before
an EOF or EOD was encountered.
For layers with record handling, the count was satisfied
before an EOR was encountered. If the count was satisfied
simultaneously with encountering an EOR, the FFEOR status is
returned.
The FFSTAT macro, defined in ffio.h, can be used to obtain the value
of the sw_stat field.
ffopen(3C), ffseek(3C)
asgcmd(1)
Application Programmer's I/O Guide, publication SG-2168
Application Programmer's Library Reference Manual, publication
SR-2165, for the printed version of this man page.
[ Back ]
|