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