blob: 2e6211f970f48a6a55ebb8e03f71ea12dd65f13a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
<refentry id="reftok">
<refmeta>
<refentrytitle>ne_token</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>ne_token</refname>
<refname>ne_qtoken</refname>
<refpurpose>string tokenizers</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include <ne_string.h></funcsynopsisinfo>
<funcprototype>
<funcdef>char *<function>ne_token</function></funcdef>
<paramdef>char **<parameter>str</parameter></paramdef>
<paramdef>char <parameter>sep</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>char *<function>ne_qtoken</function></funcdef>
<paramdef>char **<parameter>str</parameter></paramdef>
<paramdef>char <parameter>sep</parameter></paramdef>
<paramdef>const char *<parameter>quotes</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<!-- FIXME: italics on tokenize -->
<para><function>ne_token</function> and
<function>ne_qtoken</function> tokenize the string at the location
stored in the pointer <parameter>str</parameter>. Each time the
function is called, it returns the next token, and modifies the
<parameter>str</parameter> pointer to point to the remainer of the
string, or &null; if there are no more tokens in the string. A token
is delimited by the separator character <parameter>sep</parameter>; if
<function>ne_qtoken</function> is used any quoted segments of the
string are skipped when searching for a separator. A quoted segment
is enclosed in a pair of one of the characters given in the
<parameter>quotes</parameter> string.</para>
<para>The string being tokenized is modified each time
the tokenizing function is called; replacing the next separator
character with a &nul; terminator.</para>
</refsect1>
<refsect1>
<title>Examples</title>
<para>The following function prints out each token in a
comma-separated string <parameter>list</parameter>, which is
modified in-place:</para>
<programlisting>static void splitter(char *list)
{
do {
printf("Token: %s\n", ne_token(&list, ','));
while (list);
}</programlisting>
</refsect1>
</refentry>
|