Subversion Repositories Kolibri OS

Rev

Rev 4874 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4921 Serge 1
/*
2
FUNCTION
3
	<>, <>, <>---get next token from a string
4
 
5
INDEX
6
	strtok
7
 
8
INDEX
9
	strtok_r
10
 
11
INDEX
12
	strsep
13
 
14
ANSI_SYNOPSIS
15
	#include 
16
      	char *strtok(char *restrict <[source]>,
17
                     const char *restrict <[delimiters]>)
18
      	char *strtok_r(char *restrict <[source]>,
19
                       const char *restrict <[delimiters]>,
20
                       char **<[lasts]>)
21
      	char *strsep(char **<[source_ptr]>, const char *<[delimiters]>)
22
 
23
TRAD_SYNOPSIS
24
	#include 
25
	char *strtok(<[source]>, <[delimiters]>)
26
	char *<[source]>;
27
	char *<[delimiters]>;
28
 
29
	char *strtok_r(<[source]>, <[delimiters]>, <[lasts]>)
30
	char *<[source]>;
31
	char *<[delimiters]>;
32
	char **<[lasts]>;
33
 
34
	char *strsep(<[source_ptr]>, <[delimiters]>)
35
	char **<[source_ptr]>;
36
	char *<[delimiters]>;
37
 
38
DESCRIPTION
39
	The <> function is used to isolate sequential tokens in a
40
	null-terminated string, <<*<[source]>>>. These tokens are delimited
41
	in the string by at least one of the characters in <<*<[delimiters]>>>.
42
	The first time that <> is called, <<*<[source]>>> should be
43
	specified; subsequent calls, wishing to obtain further tokens from
44
	the same string, should pass a null pointer instead.  The separator
45
	string, <<*<[delimiters]>>>, must be supplied each time and may
46
	change between calls.
47
 
48
	The <> function returns a pointer to the beginning of each
49
	subsequent token in the string, after replacing the separator
50
	character itself with a null character.  When no more tokens remain,
51
	a null pointer is returned.
52
 
53
	The <> function has the same behavior as <>, except
54
	a pointer to placeholder <<*<[lasts]>>> must be supplied by the caller.
55
 
56
	The <> function is similar in behavior to <>, except
57
	a pointer to the string pointer must be supplied <<<[source_ptr]>>> and
58
	the function does not skip leading delimiters.  When the string starts
59
	with a delimiter, the delimiter is changed to the null character and
60
	the empty string is returned.  Like <> and <>, the
61
	<<*<[source_ptr]>>> is updated to the next character following the
62
	last delimiter found or NULL if the end of string is reached with
63
	no more delimiters.
64
 
65
RETURNS
66
	<>, <>, and <> all return a pointer to the
67
	next token, or <> if no more tokens can be found.  For
68
	<>, a token may be the empty string.
69
 
70
NOTES
71
	<> is unsafe for multi-threaded applications.  <>
72
	and <> are thread-safe and should be used instead.
73
 
74
PORTABILITY
75
<> is ANSI C.
76
<> is POSIX.
77
<> is a BSD extension.
78
 
79
<>, <>, and <> require no supporting OS subroutines.
80
 
81
QUICKREF
82
	strtok ansi impure
83
*/
84
 
85
/* undef STRICT_ANSI so that strtok_r prototype will be defined */
86
#undef  __STRICT_ANSI__
87
#include 
88
#include <_ansi.h>
89
#include 
90
 
91
#ifndef _REENT_ONLY
92
 
93
extern char *__strtok_r (char *, const char *, char **, int);
94
 
95
char *
96
_DEFUN (strtok, (s, delim),
97
	register char *__restrict s _AND
98
	register const char *__restrict delim)
99
{
100
	struct _reent *reent = _REENT;
101
 
102
	_REENT_CHECK_MISC(reent);
103
	return __strtok_r (s, delim, &(_REENT_STRTOK_LAST(reent)), 1);
104
}
105
#endif