More string and buffer functions.
[apps/madmutt.git] / lib-lib / str.h
index d455666..f9ef19f 100644 (file)
@@ -218,6 +218,28 @@ ssize_t m_strwidth(const char *s);
  * \return 1 if a match is found, 0 otherwise.
  */
 static inline int m_strstart(const char *s, const char *p, const char **pp)
+{
+    if (!s)
+        return 0;
+
+    while (*p) {
+        if (ascii_tolower(*s++) != ascii_tolower(*p++))
+            return 0;
+    }
+    if (pp)
+        *pp = s;
+    return 1;
+}
+
+/** \brief Tells whether s begins with p, case insensitive.
+ *
+ * \param[in]  s     the input string
+ * \param[in]  p     the prefix
+ * \param[out] pp    position in s
+ *
+ * \return 1 if a match is found, 0 otherwise.
+ */
+static inline int m_strcasestart(const char *s, const char *p, const char **pp)
 {
     if (!s)
         return 0;