1 /* Split string into tokens
2 Copyright (C) 2004-2005 Free Software Foundation, Inc.
3 Written by Simon Josefsson.
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)
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.
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. */
22 /* Get strtok_r declaration, if available. */
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";
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
35 This is a variant of strtok() that is multithread-safe.
37 For the POSIX documentation for this function, see:
38 http://www.opengroup.org/susv3xsh/strtok.html
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.
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
);
53 #endif /* STRTOK_R_H */