X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_string.c;h=effaf32a6580d5f74201c35310a0ac08f514597c;hp=9160e415f7f0caeda7cb02b271dd1be1d31f3040;hb=123a1ba27ea09c8fa77a1b36ce625b43d7c48b14;hpb=0e097100a26bc43eb8964734fa43130fc4c71429 diff --git a/palacios/src/palacios/vmm_string.c b/palacios/src/palacios/vmm_string.c index 9160e41..effaf32 100644 --- a/palacios/src/palacios/vmm_string.c +++ b/palacios/src/palacios/vmm_string.c @@ -152,6 +152,22 @@ int strcmp(const char * s1, const char * s2) { } #endif +#ifdef CONFIG_BUILT_IN_STRCASECMP +int strcasecmp(const char * s1, const char * s2) { + while (1) { + int cmp = (tolower(*s1) - tolower(*s2)); + + if ((cmp != 0) || (*s1 == '\0') || (*s2 == '\0')) { + return cmp; + } + + ++s1; + ++s2; + } +} + +#endif + #ifdef CONFIG_BUILT_IN_STRNCMP int strncmp(const char * s1, const char * s2, size_t limit) { @@ -174,6 +190,26 @@ int strncmp(const char * s1, const char * s2, size_t limit) { } #endif +#ifdef CONFIG_BUILT_IN_STRNCASECMP +int strncasecmp(const char * s1, const char * s2, size_t limit) { + size_t i = 0; + + while (i < limit) { + int cmp = (tolower(*s1) - tolower(*s2)); + + if ((cmp != 0) || (*s1 == '\0') || (*s2 == '\0')) { + return cmp; + } + + ++s1; + ++s2; + ++i; + } + + return 0; +} +#endif + #ifdef CONFIG_BUILT_IN_STRCAT char * strcat(char * s1, const char * s2) { @@ -294,6 +330,10 @@ int strtoi(const char * nptr, char ** endptr) { uint64_t atox(const char * buf) { uint64_t ret = 0; + if (*(buf + 1) == 'x') { + buf += 2; + } + while (isxdigit(*buf)) { ret <<= 4; @@ -313,6 +353,10 @@ uint64_t strtox(const char * nptr, char ** endptr) { uint64_t ret = 0; char * buf = (char *)nptr; + if (*(buf + 1) == 'x') { + buf += 2; + } + while (isxdigit(*buf)) { ret <<= 4; @@ -445,3 +489,23 @@ char *strstr(const char *haystack, const char *needle) return NULL; } #endif + + +void str_tolower(char * s) { + while (isalpha(*s)) { + if (!islower(*s)) { + *s = tolower(*s); + } + s++; + } +} + + +void str_toupper(char * s) { + while (isalpha(*s)) { + if (!isupper(*s)) { + *s = toupper(*s); + } + s++; + } +}