xen: Add new string function
authorJulien Grall <julien.grall@linaro.org>
Wed, 28 Aug 2013 14:47:20 +0000 (15:47 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 10 Sep 2013 10:44:01 +0000 (11:44 +0100)
Add strcasecmp. The code is copied from Linux.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/common/string.c
xen/include/xen/string.h

index db9d9d51990c27146bedfb745a494f542a8ad4f6..9a5a4ba5e8a89e3493bd019699e652401a0cf7d2 100644 (file)
@@ -41,6 +41,21 @@ int strnicmp(const char *s1, const char *s2, size_t len)
 }
 #endif
 
+#ifndef __HAVE_ARCH_STRCASECMP
+int strcasecmp(const char *s1, const char *s2)
+{
+    int c1, c2;
+
+    do
+    {
+        c1 = tolower(*s1++);
+        c2 = tolower(*s2++);
+    } while ( c1 == c2 && c1 != 0 );
+
+    return c1 - c2;
+}
+#endif
+
 #ifndef __HAVE_ARCH_STRLCPY
 /**
  * strlcpy - Copy a %NUL terminated string into a sized buffer
index f26b9949b207793013c762df6fa3c6e62bd538e8..f35934e2878de4129d9a3001b7b61d54b3517a99 100644 (file)
@@ -43,6 +43,9 @@ extern int strncmp(const char *,const char *,__kernel_size_t);
 #ifndef __HAVE_ARCH_STRNICMP
 extern int strnicmp(const char *, const char *, __kernel_size_t);
 #endif
+#ifndef __HAVE_ARCH_STRCASECMP
+extern int strcasecmp(const char *, const char *);
+#endif
 #ifndef __HAVE_ARCH_STRCHR
 extern char * strchr(const char *,int);
 #endif