* Compare two strings with fixed length. * * @param s1 The first string. * @param s2 The second string. * @param maxlen Return at most maxlen characters as length of the string. * @return A non-zero value if s1 and s2 differ, or zero if s1 equals s2. */
| 66 | * @return A non-zero value if s1 and s2 differ, or zero if s1 equals s2. |
| 67 | */ |
| 68 | int strncasecmp(const char *s1, const char *s2, size_t maxlen) |
| 69 | { |
| 70 | int res = 0; |
| 71 | |
| 72 | for (size_t i = 0; i < maxlen; i++) { |
| 73 | res = tolower(s1[i]) - tolower(s2[i]); |
| 74 | if (res || (s1[i] == '\0')) |
| 75 | break; |
| 76 | } |
| 77 | |
| 78 | return res; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Compare two strings. |
no test coverage detected