| FPARSELN(3) | Library Functions Manual | FPARSELN(3) |
fparseln — return
the next logical line from a stream
System Utilities Library (libutil, -lutil)
#include <stdio.h>
#include <util.h>
char *
fparseln(FILE *stream,
size_t *len, size_t *lineno,
const char delim[3], int
flags);
The
fparseln()
function returns a pointer to the next logical line from the stream
referenced by stream. This string is null terminated,
contains no trailing newline, and is dynamically allocated on each
invocation. It is the responsibility of the caller to free the pointer.
By default, if a character is escaped, both it and the preceding escape character will be present in the returned string. Various flags alter this behaviour.
The meaning of the arguments is as follows:
NULL, the length of the string is stored in
the memory location referenced by len.NULL, the value of the memory location to
which lineno references is incremented by the number
of lines actually read from the file.NULL, all characters default to values specified
below. The contents of delim is as follows:
\’, is used to remove any
special meaning from the next character.\’, is used to indicate that
the next line should be concatenated with the current one if this
character is the last character on the current line and is not
escaped.#’, if not escaped indicates
the beginning of a comment that extends until the end of the current
line.fparseln().
The various flags, which may be OR'ed together, are:
FPARSELN_UNESCCOMMFPARSELN_UNESCCONTFPARSELN_UNESCESCFPARSELN_UNESCRESTFPARSELN_UNESCALLUpon successful completion a pointer to the parsed line is
returned; otherwise, NULL is returned.
Internally, the fparseln() function uses
fgetln(3), so all error conditions that apply to
fgetln(3) apply to fparseln() as
well. In addition fparseln() may set
errno to ENOMEM and return
NULL if it runs out of memory.
| June 13, 2025 | Debian |