Add to git.
[c2lib.git] / doc / pgetline.3.html
1 <html>
2 <head>
3 <meta name="generator" content="groff -Thtml, see www.gnu.org">
4 <meta name="Content-Style" content="text/css">
5 <title>pgetline</title>
6 </head>
7 <body>
8
9 <h1 align=center>pgetline</h1>
10 <a href="#NAME">NAME</a><br>
11 <a href="#SYNOPSIS">SYNOPSIS</a><br>
12 <a href="#DESCRIPTION">DESCRIPTION</a><br>
13 <a href="#AUTHOR">AUTHOR</a><br>
14 <a href="#LICENSE">LICENSE</a><br>
15 <a href="#VERSION">VERSION</a><br>
16 <a href="#SEE ALSO">SEE ALSO</a><br>
17
18 <hr>
19 <!-- Creator     : groff version 1.17.2 -->
20 <!-- CreationDate: Fri May  3 14:57:22 2002 -->
21 <a name="NAME"></a>
22 <h2>NAME</h2>
23 <table width="100%" border=0 rules="none" frame="void"
24        cols="2" cellspacing="0" cellpadding="0">
25 <tr valign="top" align="left">
26 <td width="10%"></td><td width="90%">
27 pgetline, pgetlinex, pgetlinec - read a line from a file, optionally removing comments</td></table>
28 <a name="SYNOPSIS"></a>
29 <h2>SYNOPSIS</h2>
30
31 <table width="100%" border=0 rules="none" frame="void"
32        cols="2" cellspacing="0" cellpadding="0">
33 <tr valign="top" align="left">
34 <td width="10%"></td><td width="90%">
35 <pre><b>#include &lt;pstring.h&gt;
36
37 char *pgetline (pool, FILE *fp, char *line);
38 char *pgetlinex (pool, FILE *fp, char *line, const char *comment_set, int flags);
39 #define pgetlinec(p,fp,line) pgetlinex ((p), (fp), (line),</b> <i>#&quot;,</i><b>0)&quot;
40 </b></pre></td></table>
41 <a name="DESCRIPTION"></a>
42 <h2>DESCRIPTION</h2>
43
44 <table width="100%" border=0 rules="none" frame="void"
45        cols="2" cellspacing="0" cellpadding="0">
46 <tr valign="top" align="left">
47 <td width="10%"></td><td width="90%">
48 <b>pgetline</b> reads a single line from a file and returns
49 it. It allocates enough space to read lines of arbitrary'
50 and '0) are length. Line ending characters (' automatically
51 removed from the end of the line.</td></table>
52
53 <table width="100%" border=0 rules="none" frame="void"
54        cols="2" cellspacing="0" cellpadding="0">
55 <tr valign="top" align="left">
56 <td width="10%"></td><td width="90%">
57 The <b>pool</b> argument is a pool for allocating the line.
58 The <b>fp</b> argument is the C <b>FILE</b> pointer. The
59 <b>line</b> argument is a pointer to a string allocated in
60 pool which will be reallocated and filled with the contents
61 of the line. You may pass <b>line</b> as <b>NULL</b> to get
62 a newly allocated buffer.</td></table>
63
64 <table width="100%" border=0 rules="none" frame="void"
65        cols="2" cellspacing="0" cellpadding="0">
66 <tr valign="top" align="left">
67 <td width="10%"></td><td width="90%">
68 Use <b>pgetline</b> in one of the following two
69 ways:</td></table>
70
71 <table width="100%" border=0 rules="none" frame="void"
72        cols="2" cellspacing="0" cellpadding="0">
73 <tr valign="top" align="left">
74 <td width="10%"></td><td width="90%">
75 <b>line = pgetline (pool, fp, line);</b></td></table>
76
77 <table width="100%" border=0 rules="none" frame="void"
78        cols="2" cellspacing="0" cellpadding="0">
79 <tr valign="top" align="left">
80 <td width="10%"></td><td width="90%">
81 or</td></table>
82
83 <table width="100%" border=0 rules="none" frame="void"
84        cols="2" cellspacing="0" cellpadding="0">
85 <tr valign="top" align="left">
86 <td width="10%"></td><td width="90%">
87 <b>line = pgetline (pool, fp, NULL);</b></td></table>
88
89 <table width="100%" border=0 rules="none" frame="void"
90        cols="2" cellspacing="0" cellpadding="0">
91 <tr valign="top" align="left">
92 <td width="10%"></td><td width="90%">
93 <b>pgetlinex</b> is a more advanced function which reads a
94 line from a file, optionally removing comments,
95 concatenating together lines which have been split with a
96 backslash, and ignoring blank lines. <b>pgetlinex</b> (and
97 the related macro <b>pgetlinec</b>) are very useful for
98 reading lines of input from a configuration
99 file.</td></table>
100
101 <table width="100%" border=0 rules="none" frame="void"
102        cols="2" cellspacing="0" cellpadding="0">
103 <tr valign="top" align="left">
104 <td width="10%"></td><td width="90%">
105 The <b>pool</b> argument is a pool for allocating the line.
106 The <b>fp</b> argument is the C <b>FILE</b> pointer. The
107 <b>line</b> argument is a buffer allocated in pool which
108 will be reallocated and filled with the result.
109 <b>comment_set</b> is the set of possible comment characters
110 -- eg. <b>&quot;#!&quot;</b> to allow either <b>#</b> or
111 <b>!</b> to be used to introduce comments. <b>flags</b> is
112 zero or more of the following flags OR-ed
113 together:</td></table>
114
115 <table width="100%" border=0 rules="none" frame="void"
116        cols="2" cellspacing="0" cellpadding="0">
117 <tr valign="top" align="left">
118 <td width="10%"></td><td width="90%">
119 <b>PGETL_NO_CONCAT</b>: Don't concatenate lines which have
120 been split with trailing backslash characters.</td></table>
121
122 <table width="100%" border=0 rules="none" frame="void"
123        cols="2" cellspacing="0" cellpadding="0">
124 <tr valign="top" align="left">
125 <td width="10%"></td><td width="90%">
126 <b>PGETL_INLINE_COMMENTS</b>: Treat everything following a
127 comment character as a comment. The default is to only allow
128 comments which appear on a line on their own.</td></table>
129
130 <table width="100%" border=0 rules="none" frame="void"
131        cols="2" cellspacing="0" cellpadding="0">
132 <tr valign="top" align="left">
133 <td width="10%"></td><td width="90%">
134 <b>pgetlinec</b> is a helper macro which calls
135 <b>pgetlinex</b> with <b>comment_set == &quot;#&quot;</b>
136 and <b>flags == 0</b>.</td></table>
137 <a name="AUTHOR"></a>
138 <h2>AUTHOR</h2>
139
140 <table width="100%" border=0 rules="none" frame="void"
141        cols="2" cellspacing="0" cellpadding="0">
142 <tr valign="top" align="left">
143 <td width="10%"></td><td width="90%">
144 Richard Jones &lt;rich@annexia.org&gt;</td></table>
145 <a name="LICENSE"></a>
146 <h2>LICENSE</h2>
147
148 <table width="100%" border=0 rules="none" frame="void"
149        cols="2" cellspacing="0" cellpadding="0">
150 <tr valign="top" align="left">
151 <td width="10%"></td><td width="90%">
152 GNU LGPL (see http://www.gnu.org/)</td></table>
153 <a name="VERSION"></a>
154 <h2>VERSION</h2>
155
156 <table width="100%" border=0 rules="none" frame="void"
157        cols="2" cellspacing="0" cellpadding="0">
158 <tr valign="top" align="left">
159 <td width="10%"></td><td width="90%">
160 c2lib-1.2.13</td></table>
161 <a name="SEE ALSO"></a>
162 <h2>SEE ALSO</h2>
163
164 <table width="100%" border=0 rules="none" frame="void"
165        cols="2" cellspacing="0" cellpadding="0">
166 <tr valign="top" align="left">
167 <td width="10%"></td><td width="90%">
168 <b>pmatch(3)</b>.</td></table>
169 <hr>
170 </body>
171 </html>