Next: fget_rec_append, Previous: fget_rec_read, Up: I/O
Read a record of arbitrary length.
#include <suplib/io.h>char *fget_rec( FILE *fin, void *recbuf );
FILE *fin
- the input stream from which to read the data
void *recbuf
- an
fget_rec
buffer structure, created byfget_rec_new
fget_rec
reads data from the passed stream until either an
end of line character or the end of file is reached. It removes any
end of line character from the string. It writes the data into a
user provided buffer, and extends the buffer as necessary to hold a
complete input record. The end of the buffer is terminated with a
'\0'. The buffer structure should created by fget_rec_new
and deleted with fget_rec_delete
.
This is essentially a wrapper around fget_rec_read
, with
start = 0
.
It normally returns a pointer to the data that has been read.
Upon end of file, it returns NULL
. If it cannot extend
the record, it returns NULL
and sets errno
to
ENOMEM
. If there was a read error on the stream, it
returns NULL
and the stream's error flag is set (use
ferror
to check it).
Diab Jerius