READFILEDATA(3A) READFILEDATA(3A)
NAME
ReadFileData - asynchronously read a block of data from a
file
SYNOPSIS
int ReadFileData (ready, error, arg, size, name)
int (*ready)();
char *(*error)();
int arg;
int size;
char *name;
DESCRIPTION
ReadFileData reads a file for binary data. The name of the
file to read is in name. The number of bytes to read is in
size. If size is zero, the entire file is read. The
function ready is called when the data has been read, and
the function error is called upon an error. Either function
may be NULL, in which case it will not be called. When
there is an error, the file is closed, so exactly one of the
two functions ready and error is called. The argument arg
is passed to both routines.
The calling sequence for ready is as follows:
ready (arg, buf, length)
int arg;
char *buf;
int length;
The first argument arg is the argument supplied to
ReadFileData, buf is the data in allocated memory, and
length is the number of bytes read. The application is
responsible for freeing the buffer when done with it using
the library routine free (3).
The calling sequence for error is as follows:
error (arg, errno)
Page 1 (printed 9/3/91)
READFILEDATA(3A) READFILEDATA(3A)
int arg;
int errno;
The user-supplied data to ReadFileData is passed in arg and
an error code interpreted the same as the system global
variable errno is passed in errno.
ReadFileData returns -1 if there was an error setting up the
I/O procedure, or zero on success.
NOTES
There are lower-level asynchronous I/O routines AddIoProc
and RemoveIoProc that provide greater flexibility at the
expense of greater coding effort. ReadFileData uses these
routines to set up an asynchronous read procedure.
SEE ALSO
XtAppAddInput(3Xt), XtRemoveInput(3Xt), AddIoProc(3A),
RemoveIoProc(3A), ReadFileLines(3A), ReadFileStrings(3A),
ReadPipeData(3A), ReadPipeLines(3A), ReadPipeStrings(3A),
WriteFileData(3A), WriteFileLines(3A), WritePipeData(3A),
WritePipeLines(3A)
Page 2 (printed 9/3/91)