Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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