wmii/lib/libstuff/util/stokenize.c

23 lines
373 B
C
Raw Normal View History

2010-05-22 06:52:47 +04:00
/* Written by Kris Maglione <maglione.k at Gmail> */
/* Public domain */
#include <string.h>
#include "util.h"
uint
stokenize(char *res[], uint reslen, char *str, char *delim) {
char *s;
uint i;
i = 0;
s = str;
while(i < reslen && *s) {
while(strchr(delim, *s))
*(s++) = '\0';
if(*s)
res[i++] = s;
while(*s && !strchr(delim, *s))
s++;
}
return i;
}