PatchworkOS
Loading...
Searching...
No Matches
strncasecmp.c
Go to the documentation of this file.
1#include <ctype.h>
2#include <strings.h>
3
4int strncasecmp(const char* s1, const char* s2, size_t n)
5{
6 unsigned char c1, c2;
7
8 if (s1 == s2 || n == 0)
9 {
10 return 0;
11 }
12
13 do
14 {
15 c1 = tolower((unsigned char)*s1++);
16 c2 = tolower((unsigned char)*s2++);
17 n--;
18
19 if (c1 != c2)
20 {
21 return c1 - c2;
22 }
23
24 if (c1 == '\0' || n == 0)
25 {
26 return 0;
27 }
28 } while (1);
29}
_PUBLIC int tolower(int c)
Definition tolower.c:5
int strncasecmp(const char *s1, const char *s2, size_t n)
Definition strncasecmp.c:4