strcase.c 434 B

12345678910111213141516171819202122232425
  1. #include <linux/types.h>
  2. #include <linux/ctype.h>
  3. #include <linux/string.h>
  4. int strcasecmp(const char *s1, const char *s2)
  5. {
  6. int c1, c2;
  7. do {
  8. c1 = tolower(*s1++);
  9. c2 = tolower(*s2++);
  10. } while (c1 == c2 && c1 != 0);
  11. return c1 - c2;
  12. }
  13. int strncasecmp(const char *s1, const char *s2, size_t n)
  14. {
  15. int c1, c2;
  16. do {
  17. c1 = tolower(*s1++);
  18. c2 = tolower(*s2++);
  19. } while ((--n > 0) && c1 == c2 && c1 != 0);
  20. return c1 - c2;
  21. }