X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lib%2Fstr.h;h=f9ef19f1c6382eb914da7e1ab46b01d4dde4c96d;hp=d4556664c9358571e166b7878dedb3c9321dbf55;hb=6d838d9aef36d95fa439b3f7cc06d4e81c8581bd;hpb=db3bd72d8b48f1f9b49899da081ffbec4ce2c1c6 diff --git a/lib-lib/str.h b/lib-lib/str.h index d455666..f9ef19f 100644 --- a/lib-lib/str.h +++ b/lib-lib/str.h @@ -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;