ne_token.3 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. '\" t
  2. .\" Title: ne_token
  3. .\" Author:
  4. .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
  5. .\" Date: 21 January 2023
  6. .\" Manual: neon API reference
  7. .\" Source: neon 0.32.5
  8. .\" Language: English
  9. .\"
  10. .TH "NE_TOKEN" "3" "21 January 2023" "neon 0.32.5" "neon API reference"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. ne_token, ne_qtoken \- string tokenizers
  32. .SH "SYNOPSIS"
  33. .sp
  34. .ft B
  35. .nf
  36. #include <ne_string\&.h>
  37. .fi
  38. .ft
  39. .HP \w'char\ *ne_token('u
  40. .BI "char *ne_token(char\ **" "str" ", char\ " "sep" ");"
  41. .HP \w'char\ *ne_qtoken('u
  42. .BI "char *ne_qtoken(char\ **" "str" ", char\ " "sep" ", const\ char\ *" "quotes" ");"
  43. .SH "DESCRIPTION"
  44. .PP
  45. \fBne_token\fR
  46. and
  47. \fBne_qtoken\fR
  48. tokenize the string at the location stored in the pointer
  49. \fIstr\fR\&. Each time the function is called, it returns the next token, and modifies the
  50. \fIstr\fR
  51. pointer to point to the remainder of the string, or
  52. NULL
  53. if there are no more tokens in the string\&. A token is delimited by the separator character
  54. \fIsep\fR; if
  55. \fBne_qtoken\fR
  56. 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
  57. \fIquotes\fR
  58. string\&.
  59. .PP
  60. The string being tokenized is modified each time the tokenizing function is called; replacing the next separator character with a
  61. NUL
  62. terminator\&.
  63. .SH "EXAMPLES"
  64. .PP
  65. The following function prints out each token in a comma\-separated string
  66. \fIlist\fR, which is modified in\-place:
  67. .sp
  68. .if n \{\
  69. .RS 4
  70. .\}
  71. .nf
  72. static void splitter(char *list)
  73. {
  74. do {
  75. printf("Token: %s\en", ne_token(&list, \*(Aq,\*(Aq));
  76. while (list);
  77. }
  78. .fi
  79. .if n \{\
  80. .RE
  81. .\}
  82. .SH "AUTHOR"
  83. .PP
  84. \fBJoe Orton\fR
  85. .RS 4
  86. Author.
  87. .RE
  88. .SH "COPYRIGHT"
  89. .br