X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lib%2Fstr.h;h=86fd7584a5d87f6a1a7d1112e9cefda51af3af48;hp=0136569520486f3e5fc8d4ded9a6a461117412f3;hb=6729a8ab646a00a661858b7ac7ee21f770bff3d3;hpb=84dadd88f9d900c76451ac97b74c9187fab0dd09 diff --git a/lib-lib/str.h b/lib-lib/str.h index 0136569..86fd758 100644 --- a/lib-lib/str.h +++ b/lib-lib/str.h @@ -209,6 +209,28 @@ ssize_t m_strwidth(const char *s); /* comparisons */ /****************************************************************************/ +/** \brief Tells whether s begins with p. + * + * \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_strstart(const char *s, const char *p, const char **pp) +{ + if (!s) + return 0; + + while (*p) { + if (*s++ != *p++) + return 0; + } + if (pp) + *pp = s; + return 1; +} + /** \brief \c NULL resistant strcmp. * \param[in] a the first string. * \param[in] b the second string.