X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibc.so_src%2Fstring.c;h=86ecb6f9416eb2cdaf0645cc57217783b089f6e2;hb=c1771fb9d6e85a8453a0f4553b3878959901b613;hp=1c052366dfc984a5560a3adacfe75c870c11591e;hpb=cd0a4d84497fe89a8680ac0b881007ab6e97f44d;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libc.so_src/string.c b/Usermode/Libraries/libc.so_src/string.c index 1c052366..86ecb6f9 100644 --- a/Usermode/Libraries/libc.so_src/string.c +++ b/Usermode/Libraries/libc.so_src/string.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "lib.h" /** @@ -32,6 +33,25 @@ EXPORT int strncmp(const char *s1, const char *s2, size_t n) return (int)*s1 - (int)*s2; } +EXPORT int strcasecmp(const char *s1, const char *s2) +{ + int rv; + while( (rv = toupper(*s1) - toupper(*s2)) == 0 && *s1 != '\0' && *s2 != '\0' ) { + s1++; s2++; + } + return rv; +} + +EXPORT int strncasecmp(const char *s1, const char *s2, size_t n) +{ + int rv = 0; + if( n == 0 ) return 0; + while(n -- && (rv = toupper(*s1) - toupper(*s2)) == 0 && *s1 != '\0' && *s2 != '\0') { + s1++; s2++; + } + return rv; +} + /** * \fn EXPORT char *strcpy(char *dst, const char *src) * \brief Copy a string to another @@ -253,3 +273,31 @@ EXPORT void *memchr(const void *ptr, int value, size_t num) } return NULL; } + +EXPORT size_t strcspn(const char *haystack, const char *reject) +{ + size_t ret = 0; + int i; + while( *haystack ) + { + for( i = 0; reject[i] && reject[i] == *haystack; i ++ ); + + if( reject[i] ) return ret; + ret ++; + } + return ret; +} + +EXPORT size_t strspn(const char *haystack, const char *accept) +{ + size_t ret = 0; + int i; + while( *haystack ) + { + for( i = 0; accept[i] && accept[i] == *haystack; i ++ ); + + if( !accept[i] ) return ret; + ret ++; + } + return ret; +}