1
/* getndelim2 - Read a line from a stream, stopping at one of 2 delimiters,
2
with bounded memory allocation.
4
Copyright (C) 2003 Free Software Foundation, Inc.
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software Foundation,
18
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
#define GETNDELIM2_H 1
27
#include <sys/types.h>
29
/* Read up to (and including) a delimiter DELIM1 from STREAM into *LINEPTR
30
+ OFFSET (and NUL-terminate it). If DELIM2 is non-zero, then read up
31
and including the first occurrence of DELIM1 or DELIM2. *LINEPTR is
32
a pointer returned from malloc (or NULL), pointing to *LINESIZE bytes of
33
space. It is realloc'd as necessary. Reallocation is limited to
34
NMAX bytes; if the line is longer than that, the extra bytes are read but
36
Return the number of bytes read and stored at *LINEPTR + OFFSET (not
37
including the NUL terminator), or -1 on error or EOF. */
38
extern ssize_t getndelim2 (char **lineptr, size_t *linesize, size_t nmax,
39
FILE *stream, int delim1, int delim2,
42
#endif /* GETNDELIM2_H */