* verify.h (verify_true): Provide alternative definition for C++.
[gnulib.git] / lib / strtok_r.h
1 /* Split string into tokens
2    Copyright (C) 2004-2005 Free Software Foundation, Inc.
3    Written by Simon Josefsson.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License along
16    with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #ifndef STRTOK_R_H
20 #define STRTOK_R_H
21
22 /* Get strtok_r declaration, if available.  */
23 #include <string.h>
24
25 /* Parse S into tokens separated by characters in DELIM.
26    If S is NULL, the saved pointer in SAVE_PTR is used as
27    the next starting point.  For example:
28         char s[] = "-abc-=-def";
29         char *sp;
30         x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
31         x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
32         x = strtok_r(NULL, "=", &sp);   // x = NULL
33                 // s = "abc\0-def\0"
34
35    This is a variant of strtok() that is multithread-safe.
36
37    For the POSIX documentation for this function, see:
38    http://www.opengroup.org/susv3xsh/strtok.html
39
40    Caveat: It modifies the original string.
41    Caveat: These functions cannot be used on constant strings.
42    Caveat: The identity of the delimiting character is lost.
43    Caveat: It doesn't work with multibyte strings unless all of the delimiter
44            characters are ASCII characters < 0x30.
45
46    See also strsep().
47 */
48 #if defined HAVE_DECL_STRTOK_R && !HAVE_DECL_STRTOK_R
49 extern char *strtok_r(char *restrict s, const char *restrict sep,
50                       char **restrict lasts);
51 #endif
52
53 #endif /* STRTOK_R_H */