3.30 Example: unitok
/* extok.c - Sample code for unitok.
Returns next component of string as defined by tokens.
*/
#include <nunicode.h>
#include <assert.h>
void main(void)
{
unicode str[30];
unicode tokens[4] = { ’.’, ’:’, ’\\’, 0 };
punicode ret;
unicpy(str, L"server\\vol:file.ext");
ret = unitok(str, tokens);
assert (unicmp(ret, L"server") == 0);
ret = unitok(NULL, tokens);
assert (unicmp(ret, L"vol") == 0);
ret = unitok(NULL, tokens);
assert (unicmp(ret, L"file") == 0);
ret = unitok(NULL, tokens);
assert (unicmp(ret, L"ext") == 0);
ret = unitok(NULL, tokens);
assert (ret == NULL);
}