strcase.c 408 B

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