maint: update copyright
[gnulib.git] / lib / getndelim2.h
1 /* getndelim2 - Read a line from a stream, stopping at one of 2 delimiters,
2    with bounded memory allocation.
3
4    Copyright (C) 2003-2004, 2006, 2009-2014 Free Software Foundation, Inc.
5
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 3 of the License, or
9    (at your option) any later version.
10
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.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
19 #ifndef GETNDELIM2_H
20 #define GETNDELIM2_H 1
21
22 #include <stdio.h>
23 #include <sys/types.h>
24
25 #define GETNLINE_NO_LIMIT ((size_t) -1)
26
27 /* Read into a buffer *LINEPTR returned from malloc (or NULL),
28    pointing to *LINESIZE bytes of space.  Store the input bytes
29    starting at *LINEPTR + OFFSET, and null-terminate them.  Reallocate
30    the buffer as necessary, but if NMAX is not GETNLINE_NO_LIMIT
31    then do not allocate more than NMAX bytes; if the line is longer
32    than that, read and discard the extra bytes.  Stop reading after
33    the first occurrence of DELIM1 or DELIM2, whichever comes first;
34    a delimiter equal to EOF stands for no delimiter.  Read the
35    input bytes from STREAM.
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 offset,
39                            size_t nmax, int delim1, int delim2,
40                            FILE *stream);
41
42 #endif /* GETNDELIM2_H */