unitok_r

Finds the next token in a Unicode string (thread-safe version).

Library:LibC
Service:Characters and Strings

Syntax

  #include <unilib.h> 
   
  unicode_t *unitok_r (
     unicode_t          *string,
     const unicode_t    *sepset,
     unicode_t         **last);
  

Parameters

string

(IN) Points to the string to parse. On subsequent calls, must be set to NULL.

sepset

(IN) Points to a null-terminated set of delimiter values. This string might be different from call to call.

last

(IN/OUT) Points to value returned by unitok_r, which records its progress through the string. On the first call to unitok_r, this parameter is ignored.

Return Values

If a delimiter is found, returns a pointer to the first byte of a token. On subsequent iterations, if no delimiter is found, returns a NULL pointer.

If the string does not contain any of the delimiters specified in sepset, returns a pointer to the string. All of the string is considered to be a token.

Remarks

The unitok_r function considers the string pointed to by the string parameter to consist of a sequence of zero or more text tokens, separated from the delimiter pointed to by the sepset parameter by spans of one or more characters.

The first call to unitok_r returns a pointer to the first character of the first token in the string parameter and writes a null-terminating character into the string parameter immediately following the returned token. The unitok_r function sets the string parameter to a NULL pointer, which allows unitok_r, on subsequent calls, to search through the string and return successive tokens, until no tokens remain.

Because the unitok_r function can modify the string by writing a null-terminating character to terminate a token, the string should be duplicated if the string is to be reused.

The unitok_r function corresponds to the strtok_r function.

See Also