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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4463
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* getndelim2 - Read a line from a stream, stopping at one of 2 delimiters,
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 with bounded memory allocation.
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 This program is distributed in the hope that it will be useful,
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 GNU General Public License for more details.
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #ifndef GETNDELIM2_H
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #define GETNDELIM2_H 1
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include <stdio.h>
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <sys/types.h>
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 Return the number of bytes read and stored at *LINEPTR + OFFSET (not
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41
7564fca8961e New module 'getndelim2'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 #endif /* GETNDELIM2_H */