Imported Upstream version 4.5.14
[platform/upstream/findutils.git] / lib / splitstring.h
1 /* splitstring.h -- split a const string into fields.
2    Copyright (C) 2011 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 /*
18  * Written by James Youngman.
19  */
20
21 /* Split a string into fields.   The string is never modified.
22  *
23  * A false return value indicates that there are no more fields.
24  * Otherwise the next field is at the poisition indicated by *POS and
25  * has length *LEN.
26  *
27  * Set FIRST to true only on the first call for any given value of s.
28  * *POS and *LEN do not need to be initialized in this case.
29  * On subsequent calls, these values should be left at the values
30  * set by the last call.
31  *
32  * Any character in SEPARATORS is taken to be a field separator.
33  * Consecutive field separators are taken to indicate the presence of
34  * an empty field.
35  */
36 #include <stdbool.h>
37 #include <stddef.h>
38
39 bool splitstring(const char *s, const char *separators,
40                  bool first, size_t *pos, size_t *len);