HasPrefix returns true if non-NULL s starts with non-NULL prefix.
char *rfind_str (const char [], size_t, const char *);
char *nmh_strcasestr (const char *, const char *);
+bool HasPrefix(const char *s, const char *prefix);
bool HasSuffixC(char *s, int c);
void TrimSuffixC(char *s, int c);
void ToLower(char *s);
}
+/* HasPrefix returns true if non-NULL s starts with non-NULL prefix. */
+bool HasPrefix(const char *s, const char *prefix)
+{
+ while (*s && *s == *prefix) {
+ s++;
+ prefix++;
+ }
+
+ return *prefix == '\0';
+}
+
+
/* HasSuffixC returns true if non-NULL string s ends with a c before the
* terminating NUL. */
bool HasSuffixC(char *s, int c)