1FPARSELN(3bsd)                       LOCAL                      FPARSELN(3bsd)
2

NAME

4     fparseln — return the next logical line from a stream
5

LIBRARY

7     Utility functions from BSD systems (libbsd, -lbsd)
8

SYNOPSIS

10     #include <stdio.h>
11     (See libbsd(7) for include usage.)
12
13     char *
14     fparseln(FILE *stream, size_t *len, size_t *lineno, const char delim[3],
15         int flags);
16

DESCRIPTION

18     The fparseln() function returns a pointer to the next logical line from
19     the stream referenced by stream.  This string is NUL terminated and it is
20     dynamically allocated on each invocation.  It is the responsibility of
21     the caller to free the pointer.
22
23     By default, if a character is escaped, both it and the preceding escape
24     character will be present in the returned string.  Various flags alter
25     this behaviour.
26
27     The meaning of the arguments is as follows:
28
29     stream  The stream to read from.
30
31     len     If not NULL, the length of the string is stored in the memory
32             location to which it points.
33
34     lineno  If not NULL, the value of the memory location to which is pointed
35             to, is incremented by the number of lines actually read from the
36             file.
37
38     delim   Contains the escape, continuation, and comment characters.  If a
39             character is NUL then processing for that character is disabled.
40             If NULL, all characters default to values specified below.  The
41             contents of delim is as follows:
42
43             delim[0]  The escape character, which defaults to \, is used to
44                       remove any special meaning from the next character.
45
46             delim[1]  The continuation character, which defaults to \, is
47                       used to indicate that the next line should be concate‐
48                       nated with the current one if this character is the
49                       last character on the current line and is not escaped.
50
51             delim[2]  The comment character, which defaults to #, if not
52                       escaped indicates the beginning of a comment that
53                       extends until the end of the current line.
54
55     flags   If non-zero, alter the operation of fparseln().  The various
56             flags, which may be or-ed together, are:
57
58             FPARSELN_UNESCCOMM  Remove escape preceding an escaped comment.
59
60             FPARSELN_UNESCCONT  Remove escape preceding an escaped continua‐
61                                 tion.
62
63             FPARSELN_UNESCESC   Remove escape preceding an escaped escape.
64
65             FPARSELN_UNESCREST  Remove escape preceding any other character.
66
67             FPARSELN_UNESCALL   All of the above.
68

RETURN VALUES

70     Upon successful completion a pointer to the parsed line is returned; oth‐
71     erwise, NULL is returned.
72
73     The fparseln() function uses internally getline(3), so all error condi‐
74     tions that apply to getline(3), apply to fparseln().  In addition
75     fparseln() may set errno to [ENOMEM] and return NULL if it runs out of
76     memory.
77

SEE ALSO

79     getline(3)
80

HISTORY

82     The fparseln() function first appeared in NetBSD 1.4.
83
84BSD                            November 30, 2002                           BSD
Impressum