Next: , Previous: fget_rec_read, Up: I/O


7.4 fget_rec

Read a record of arbitrary length.

Synopsis

     #include <suplib/io.h>
     
     
     
char *fget_rec( FILE *fin, void *recbuf );

Parameters

FILE *fin
the input stream from which to read the data
void *recbuf
an fget_rec buffer structure, created by fget_rec_new

Description

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.

Returns

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).

Author

Diab Jerius