Commit 8a8e4e86 authored by rswindell's avatar rswindell
Browse files

Create a strcasestr() implementation for MSVC (Windows) builds.

parent 41543335
......@@ -78,6 +78,25 @@ int DLLCALL safe_snprintf(char *dst, size_t size, const char *fmt, ...)
return(numchars);
}
#ifdef _MSC_VER
/****************************************************************************/
/* Case insensitive version of strstr() */
/****************************************************************************/
char* DLLCALL strcasestr(const char* haystack, const char* needle)
{
char* h = strdup(haystack);
char* n = strdup(needle);
char* p = NULL;
if(h != NULL && n != NULL)
p = strstr(strupr(h), strupr(n));
FREE_AND_NULL(h);
FREE_AND_NULL(n);
if(p == NULL)
return NULL;
return (char*)haystack + (p-h);
}
#endif
/****************************************************************************/
/* Return last character of string */
/****************************************************************************/
......
......@@ -244,6 +244,10 @@ extern "C" {
#endif
#endif
#if defined(_MSC_VER)
DLLEXPORT char* DLLCALL strcasestr(const char* haystack, const char* needle);
#endif
/* Skip white-space chars at beginning of string */
DLLEXPORT char* DLLCALL skipsp(char* str);
/* Truncate white-space chars off end of string */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment