diff options
Diffstat (limited to 'camel/string-utils.c')
-rw-r--r-- | camel/string-utils.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/camel/string-utils.c b/camel/string-utils.c index 4a28b199ef..584e2dad0d 100644 --- a/camel/string-utils.c +++ b/camel/string-utils.c @@ -207,3 +207,27 @@ strip (gchar *string, gchar c) return string; } + +char * +strstrcase (char *haystack, const char *needle) +{ + /* find the needle in the haystack neglecting case */ + const char *ptr; + guint len; + + g_return_val_if_fail (haystack != NULL, NULL); + g_return_val_if_fail (needle != NULL, NULL); + + len = strlen (needle); + if (len > strlen (haystack)) + return NULL; + + if (len == 0) + return (char *) haystack; + + for (ptr = haystack; *(ptr + len - 1) != '\0'; ptr++) + if (!g_strncasecmp (ptr, needle, len)) + return (char *) ptr; + + return NULL; +} |