/etc/mail: Install 4 sample mailer.conf files
[dragonfly.git] / lib / libutil / fparseln.3
1 .\"     $NetBSD: fparseln.3,v 1.7 1999/07/02 15:49:12 simonb Exp $
2 .\" $FreeBSD: head/lib/libutil/fparseln.3 140081 2005-01-11 20:50:51Z ru $
3 .\"
4 .\" Copyright (c) 1997 Christos Zoulas.  All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\"    must display the following acknowledgement:
16 .\"     This product includes software developed by Christos Zoulas.
17 .\" 4. The name of the author may not be used to endorse or promote products
18 .\"    derived from this software without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 .\"
31 .Dd December 1, 1997
32 .Dt FPARSELN 3
33 .Os
34 .Sh NAME
35 .Nm fparseln
36 .Nd return the next logical line from a stream
37 .Sh LIBRARY
38 .Lb libutil
39 .Sh SYNOPSIS
40 .In sys/types.h
41 .In stdio.h
42 .In libutil.h
43 .Ft "char *"
44 .Fo fparseln
45 .Fa "FILE *stream" "size_t *len" "size_t *lineno"
46 .Fa "const char delim[3]" "int flags"
47 .Fc
48 .Sh DESCRIPTION
49 The
50 .Fn fparseln
51 function
52 returns a pointer to the next logical line from the stream referenced by
53 .Fa stream .
54 This string is
55 .Dv NUL
56 terminated and it is dynamically allocated on each invocation.
57 It is the
58 responsibility of the caller to free the pointer.
59 .Pp
60 By default, if a character is escaped, both it and the preceding escape
61 character will be present in the returned string.
62 Various
63 .Fa flags
64 alter this behaviour.
65 .Pp
66 The meaning of the arguments is as follows:
67 .Bl -tag -width "lineno"
68 .It Fa stream
69 The stream to read from.
70 .It Fa len
71 If not
72 .Dv NULL ,
73 the length of the string is stored in the memory location to which it
74 points.
75 .It Fa lineno
76 If not
77 .Dv NULL ,
78 the value of the memory location to which is pointed to, is incremented
79 by the number of lines actually read from the file.
80 .It Fa delim
81 Contains the escape, continuation, and comment characters.
82 If a character is
83 .Dv NUL
84 then processing for that character is disabled.
85 If
86 .Dv NULL ,
87 all characters default to values specified below.
88 The contents of
89 .Fa delim
90 is as follows:
91 .Bl -tag -width "delim[0]"
92 .It Fa delim[0]
93 The escape character, which defaults to
94 .Cm \e ,
95 is used to remove any special meaning from the next character.
96 .It Fa delim[1]
97 The continuation character, which defaults to
98 .Cm \e ,
99 is used to indicate that the next line should be concatenated with the
100 current one if this character is the last character on the current line
101 and is not escaped.
102 .It Fa delim[2]
103 The comment character, which defaults to
104 .Cm # ,
105 if not escaped indicates the beginning of a comment that extends until the
106 end of the current line.
107 .El
108 .It Fa flags
109 If non-zero, alter the operation of
110 .Fn fparseln .
111 The various flags, which may be
112 .Em or Ns -ed
113 together, are:
114 .Bl -tag -width "FPARSELN_UNESCCOMM"
115 .It Dv FPARSELN_UNESCCOMM
116 Remove escape preceding an escaped comment.
117 .It Dv FPARSELN_UNESCCONT
118 Remove escape preceding an escaped continuation.
119 .It Dv FPARSELN_UNESCESC
120 Remove escape preceding an escaped escape.
121 .It Dv FPARSELN_UNESCREST
122 Remove escape preceding any other character.
123 .It Dv FPARSELN_UNESCALL
124 All of the above.
125 .El
126 .El
127 .Sh RETURN VALUES
128 Upon successful completion a pointer to the parsed line is returned;
129 otherwise,
130 .Dv NULL
131 is returned.
132 .Pp
133 The
134 .Fn fparseln
135 function uses internally
136 .Xr fgetln 3 ,
137 so all error conditions that apply to
138 .Xr fgetln 3 ,
139 apply to
140 .Fn fparseln .
141 In addition
142 .Fn fparseln
143 may set
144 .Va errno
145 to
146 .Er ENOMEM
147 and return
148 .Dv NULL
149 if it runs out of memory.
150 .Sh SEE ALSO
151 .Xr fgetln 3
152 .Sh HISTORY
153 The
154 .Fn fparseln
155 function first appeared in
156 .Nx 1.4
157 and
158 .Fx 4.0 .