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