7 * streq - Are two strings equal?
11 * This macro is arguably more readable than "!strcmp(a, b)".
14 * if (streq(somestring, ""))
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(somestring, "foo"))
26 * printf("String %s begins with 'foo'!\n", somestring);
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(somestring, "foo"))
37 * printf("String %s end with 'foo'!\n", somestring);
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);
48 * stringify - Turn expression into a string literal
49 * @expr: any C expression
52 * #define PRINT_COND_IF_FALSE(cond) \
53 * ((cond) || printf("%s is false!", stringify(cond)))
55 #define stringify(expr) stringify_1(expr)
56 /* Double-indirection required to stringify expansions */
57 #define stringify_1(expr) #expr
58 #endif /* CCAN_STR_H */