summaryrefslogtreecommitdiff
path: root/firmware/common/strcasecmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common/strcasecmp.c')
-rw-r--r--firmware/common/strcasecmp.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/firmware/common/strcasecmp.c b/firmware/common/strcasecmp.c
new file mode 100644
index 0000000000..7bd0d61dd5
--- /dev/null
+++ b/firmware/common/strcasecmp.c
@@ -0,0 +1,28 @@
1
2#include <string.h>
3#include <ctype.h>
4
5int strcasecmp(const char *s1, const char *s2)
6{
7 while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) {
8 s1++;
9 s2++;
10 }
11
12 return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
13}
14
15int strncasecmp(const char *s1, const char *s2, size_t n)
16{
17 if(!n)
18 return 0;
19
20 while (n-- != 0 && tolower(*s1) == tolower(*s2)) {
21 if(n == 0 || *s1 == '\0')
22 break;
23 s1++;
24 s2++;
25 }
26
27 return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
28}