WRITEFILELINES(3A) WRITEFILELINES(3A)
NAME
WriteFileLines - asynchronously write lines of data to a
file
SYNOPSIS
int WriteFileLines (line, ready, error, arg, name)
int (*line)();
int (*ready)();
char *(*error)();
int arg;
char *name;
DESCRIPTION
WriteFileLines writes lines of data to a file. The name of
the file to write is in name. The function line is called
to obtain a line to write to the file. It will be called
from WriteFileLines to obtain the first line to write. The
function ready is called when the file has been closed, and
the function error is called upon an error. Any 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 line is as follows:
char *line (arg, error, buf, length)
int arg;
int error;
char *buf;
int length;
The user-supplied argument to WriteFileLines is in arg. The
error code, error, is always zero. The line and its length
are in buf and length. The length includes the terminating
newline, but not the zero byte. The line function returns a
buffer for the next line or NULL. The file will be closed
if NULL is returned, causing the ready function to be
called. The buffer may be the same address passed by the
Page 1 (printed 9/3/91)
WRITEFILELINES(3A) WRITEFILELINES(3A)
parameter buf, or it may be another malloced area of at
least BUFSIZ bytes. The application is responsible for
freeing the buffer, sometime after the next call to one of
the line or ready functions.
The calling sequence for ready is as follows:
ready (arg)
int arg;
The argument arg is the argument supplied to WriteFileLines.
The calling sequence for error is as follows:
error (arg, errno)
int arg;
int errno;
The user-supplied data to WriteFileLines is passed in arg
and an error code interpreted the same as the system global
variable errno is passed in errno .
WriteFileLines 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. WritePipeLines uses these
routines to set up an asynchronous write procedure.
SEE ALSO
XtAppAddInput(3Xt), XtRemoveInput(3Xt), AddIoProc(3A),
RemoveIoProc(3A), ReadFileData(3A), ReadFileLines(3A),
ReadFileStrings(3A), ReadPipeData(3A), ReadPipeLines(3A),
WriteFileData(3A), WritePipeData(3A), WritePipeLines(3A)
Page 2 (printed 9/3/91)