Merge from vendor branch OPENSSL:
[dragonfly.git] / contrib / cvs-1.12.9 / lib / getndelim2.h
1 /* getndelim2 - Read n characters or less from a stream, stopping at one of up
2    to two specified delimiters.
3
4    Copyright (C) 2003 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 2, or (at your option)
9    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, write to the Free Software Foundation,
18    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19
20 #ifndef GETNDELIM2_H
21 #define GETNDELIM2_H 1
22
23 #include <stddef.h>
24 #include <stdio.h>
25
26 /* Get ssize_t.  */
27 #include <sys/types.h>
28
29 #define GETNDELIM_NO_LIMIT (ssize_t)-1
30
31 /* Read up to (and including) a delimiter DELIM1 from STREAM into *LINEPTR
32    + OFFSET (and NUL-terminate it).  If DELIM2 is non-zero, then read up
33    and including the first occurrence of DELIM1 or DELIM2.  *LINEPTR is
34    a pointer returned from malloc (or NULL), pointing to *LINESIZE bytes of
35    space.  It is realloc'd as necessary.  Read no more than LIMIT bytes.
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 _limit, int _delim1, int _delim2,
40                            FILE *_stream);
41
42 #endif /* GETNDELIM2_H */