X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibc.so_src%2Fstring.c;h=0757c24ad3ee46432d3cc7f1232017dfe06cb968;hb=aa5e13445f3d9ab6e0c0049780f38daed443104f;hp=6ee6d6cadf58022c8f3283b0d198152cd064f89a;hpb=c7946415abcd9c7a86ecde867d44cb50a249c349;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libc.so_src/string.c b/Usermode/Libraries/libc.so_src/string.c index 6ee6d6ca..0757c24a 100644 --- a/Usermode/Libraries/libc.so_src/string.c +++ b/Usermode/Libraries/libc.so_src/string.c @@ -7,6 +7,7 @@ #include #include #include "lib.h" +#include /** * \fn EXPORT int strcmp(const char *s1, const char *s2) @@ -367,3 +368,48 @@ EXPORT size_t strspn(const char *haystack, const char *accept) } return ret; } + +EXPORT char *strpbrk(const char *haystack, const char *accept) +{ + while( *haystack ) + { + for( int i = 0; accept[i]; i ++ ) + { + if( accept[i] == *haystack ) + return (char*)haystack; + } + } + return NULL; +} + +char *strtok(char *str, const char *delim) +{ + static char *__saveptr; + return strtok_r(str, delim, &__saveptr); +} +char *strtok_r(char *str, const char *delim, char **saveptr) +{ + char *pos = (str ? str : *saveptr); + + while( strchr(delim, *pos) ) + pos ++; + + if( *pos == '\0' ) + return NULL; + + char *ret = pos; + while( !strchr(delim, *pos) ) + pos ++; + + // Cap the returned string + // - If we're at the end of the original string, don't shift pos + if( *pos != '\0' ) { + *pos = '\0'; + pos ++; + } + + *saveptr = pos; + + return ret; +} +