wmii/lib/libstuff/util/tokenize.c

22 lines
338 B
C

/* Written by Kris Maglione <maglione.k at Gmail> */
/* Public domain */
#include "util.h"
uint
tokenize(char *res[], uint reslen, char *str, char delim) {
char *s;
uint i;
i = 0;
s = str;
while(i < reslen && *s) {
while(*s == delim)
*(s++) = '\0';
if(*s)
res[i++] = s;
while(*s && *s != delim)
s++;
}
return i;
}