NWLstrtok

Finds the next token in a specified string

NetWare Server:4.x, 5.x, 6.x
Platform:NLM, Windows NT, Windows 95, Windows 98
Library:Cross-Platform Localization (LOC*.*)
Service:Internationalization

Syntax

  #include <nwlocale.h> 
   
  pnstr N_API NWLstrtok  ( 
     pnstr   parse,  
     const nstr N_FAR  *delim); 
  
  

Pascal Syntax

  uses netwin32 
   
  Function NWLstrtok 
    (parse : pnstr; 
     delim : pnstr 
  ) : pnstr; 
  
  

Parameters

parse
(IN/OUT) Points to the string containing the token(s).
delim
(IN) Points to the string containing delimiters (can include double-byte characters).

Return Values

Returns a pointer to the next token found in the parse parameter.

Returns NULL when no more tokens are found.

Remarks

Every time NWLstrtok is called, it modifies the parse parameter by substituting a NULL character for each delimiter that is found.

Sequentially calling NWLstrtok breaks the string pointed to by the parse parameter into a sequence of tokens, each of which is delimited by a character from the string pointed to by the delim parameter. The first time NWLstrtok is called in the sequence, the parse parameter is its first parameter. It will be followed by calling NWLstrtok additional times with a NULL pointer as the first parameter. The separator string pointed to by the delim parameter might be different each time NWLstrtok is called.

The first time in the sequence that NWLstrtok is called, it searches the string pointed to by the parse parameter for the first character that is NOT contained in the current separator string pointed to by the delim parameter. If no such character is found, there are no tokens in the string and NWLstrtok returns a NULL pointer. If such a character is found, the character is the start of the first token.

NWLstrtok continues searching, beginning at the token found for a character that IS contained in the current separator string. If no such character is found, the current token extends to the end of the string pointed to by the parse parameter. Subsequent searches for a token will return a NULL pointer. If such a character is found, it is overwritten by a NULL character, which terminates the current token. NWLstrtok saves a pointer to the following character, from which the next search for a token will start.

Each subsequent call, with a NULL pointer as the value of the first parameter, starts searching from the saved pointer as described.

WARNING:NWLstrtok uses a static variable for maintaining the last next token location. If multiple or simultaneous calls are made to NWLstrtok, a high potential for data corruption and incorrect results exists.

Do not attempt to call NWLstrtok simultaneously for different strings. Be aware of calling NWLstrtok from within a loop where another application might also be calling NWLstrtok.

In a multi-threaded, multi-processor environment, use the NWLstrtok_r function.

See Also

NWLstrspn, NWLstrcspn, NWLstrtok_r