tok.xml 2.2 KB

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