FGETMFS(3)

NAME
fgetmfs - read an arbitrarily long, possibly continued line

SYNOPSIS
#include <stdio.h>
#include <fgetmfs.h>

char *fgetmfs(stream, limit, cont)
FILE *stream;
int limit, cont;

char *fgetms(stream)
FILE *stream;

char *cfgetms(stream)
FILE *stream;

DESCRIPTION
Fgetmfs reads an arbitrarily long line from stream, allocating memory via malloc(3) as needed. If limit is non-negative, fgetmfs will read no more than limit bytes from stream. For efficiency, if cont is not CONT_NO, such as CONT_NOSPC or CONT_SPC, occurrences of a backslash and a newline together and in that order will be deleted from the input stream; if cont is CONT_NOSPC, any whitespace after the newline in the input stream will also be deleted from it.

The macros fgetms (to read without continuations) and cfgetms (to read with continuations and remove leading whitespace) should be used instead when the limit is not needed.

Fgetmfs is intended to provide a reliable mechanism for reading input containing lines of arbitrary length, rather than trusting that no line with be longer than some arbitrary tolerance.

The memory returned by fgetmfs should be returned when no longer needed via free(3).

SEE ALSO
malloc(3), fgets(3)

DIAGNOSTICS
Returns NULL (0) if memory cannot be allocated or upon reading end-of-file; use feof(stream) to distinguish.

HISTORY
Written by Geoff Collyer at the University of Toronto as part of the C news project.

BUGS
It's too slow.
The meaning of the cont flag is ugly, but layering this form of continuation on top is even slower.