Mercurial > hg > octave-kai > gnulib-hg
annotate lib/getndelim2.h @ 17476:6057744acd2c default tip master
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Fri, 16 Aug 2013 06:32:22 -0700 |
parents | e542fd46ad6f |
children |
rev | line source |
---|---|
4463 | 1 /* getndelim2 - Read a line from a stream, stopping at one of 2 delimiters, |
2 with bounded memory allocation. | |
3 | |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16201
diff
changeset
|
4 Copyright (C) 2003-2004, 2006, 2009-2013 Free Software Foundation, Inc. |
4463 | 5 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
6939
diff
changeset
|
6 This program is free software: you can redistribute it and/or modify |
4463 | 7 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
6939
diff
changeset
|
8 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
6939
diff
changeset
|
9 (at your option) any later version. |
4463 | 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 | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
6939
diff
changeset
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
4463 | 18 |
19 #ifndef GETNDELIM2_H | |
20 #define GETNDELIM2_H 1 | |
21 | |
22 #include <stdio.h> | |
23 #include <sys/types.h> | |
24 | |
5062
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
25 #define GETNLINE_NO_LIMIT ((size_t) -1) |
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
26 |
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
27 /* Read into a buffer *LINEPTR returned from malloc (or NULL), |
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
28 pointing to *LINESIZE bytes of space. Store the input bytes |
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
29 starting at *LINEPTR + OFFSET, and null-terminate them. Reallocate |
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
30 the buffer as necessary, but if NMAX is not GETNLINE_NO_LIMIT |
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
31 then do not allocate more than NMAX bytes; if the line is longer |
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
32 than that, read and discard the extra bytes. Stop reading after |
6939
c34c3fd8f414
Commentary sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
33 the first occurrence of DELIM1 or DELIM2, whichever comes first; |
c34c3fd8f414
Commentary sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
34 a delimiter equal to EOF stands for no delimiter. Read the |
5062
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
35 input bytes from STREAM. |
4463 | 36 Return the number of bytes read and stored at *LINEPTR + OFFSET (not |
37 including the NUL terminator), or -1 on error or EOF. */ | |
5062
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
38 extern ssize_t getndelim2 (char **lineptr, size_t *linesize, size_t offset, |
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
39 size_t nmax, int delim1, int delim2, |
aa119e787246
getline cleanup. This changes the getndelim2 API: both order of arguments,
Paul Eggert <eggert@cs.ucla.edu>
parents:
4463
diff
changeset
|
40 FILE *stream); |
4463 | 41 |
42 #endif /* GETNDELIM2_H */ |