strcasecmp.h 678 B

123456789101112131415161718192021222324252627282930
  1. /// @file
  2. /// @brief platform abstraction for case-insensitive string functions
  3. /// @ingroup cgraph_utils
  4. #pragma once
  5. #include <stddef.h>
  6. #ifdef _MSC_VER
  7. // redirect these to the Windows alternatives
  8. #include <string.h>
  9. // some third-party libraries like libgd provide their own macro-based
  10. // `strcasecmp` shim, so only define our own if their’s is not in scope
  11. #ifndef strcasecmp
  12. static inline int strcasecmp(const char *s1, const char *s2) {
  13. return _stricmp(s1, s2);
  14. }
  15. #endif
  16. static inline int strncasecmp(const char *s1, const char *s2, size_t n) {
  17. return _strnicmp(s1, s2, n);
  18. }
  19. #else
  20. // other platforms define these in strings.h
  21. #include <strings.h>
  22. #endif