7 * streq - Are two strings equal?
11 * This macro is arguably more readable than "!strcmp(a, b)".
15 * printf("String is empty!\n");
17 #define streq(a,b) (strcmp((a),(b)) == 0)
20 * strstarts - Does this string start with this prefix?
21 * @str: string to test
22 * @prefix: prefix to look for at start of str
25 * if (strstarts(str, "foo"))
26 * printf("String %s begins with 'foo'!\n", str);
28 #define strstarts(str,prefix) (strncmp((str),(prefix),strlen(prefix)) == 0)
31 * strends - Does this string end with this postfix?
32 * @str: string to test
33 * @postfix: postfix to look for at end of str
36 * if (strends(str, "foo"))
37 * printf("String %s end with 'foo'!\n", str);
39 static inline bool strends(const char *str, const char *postfix)
41 if (strlen(str) < strlen(postfix))
44 return streq(str + strlen(str) - strlen(postfix), postfix);
46 #endif /* CCAN_STR_H */