#ifndef HAVE_STRCASECMP extern int strcasecmp (const char *p, const char *q); #endif /* HAVE STRCASECMP */ #ifndef HAVE_STRNCASECMP extern int strncasecmp (const char *p, const char *q, size_t n); #endif /* HAVE_STRNCASECMP */ /* * strcmp that ignores case */ #define FOLD_TO_UPPER(a) (toupper ((unsigned char)(a))) #ifndef HAVE_STRCASECMP int strcasecmp ( const char *p, const char *q) { int r; for (; (r = FOLD_TO_UPPER (*p) - FOLD_TO_UPPER (*q)) == 0; ++p, ++q) { if (*p == '\0') return (0); } return r; } #endif #ifndef HAVE_STRNCASECMP int strncasecmp( const char *p, const char *q, size_t n) { int r=0; for (; n && (r = (FOLD_TO_UPPER (*p) - FOLD_TO_UPPER (*q))) == 0; ++p, ++q, --n) { if (*p == '\0') return (0); } return n ? r : 0; } #endif