diff options
Diffstat (limited to 'src/util/string.h')
| -rw-r--r-- | src/util/string.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/util/string.h b/src/util/string.h index 1ef07d1..b75e783 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -1,9 +1,14 @@ #ifndef _SK_UTIL_STRING_H #define _SK_UTIL_STRING_H +#if HAVE_STDBOOL_H +#include <stdbool.h> +#endif + #include "array.h" #include <stddef.h> +#include <string.h> /** * stringize: @@ -36,6 +41,25 @@ #define boolstr(b) (b ? "true" : "false") /** + * is_empty_string: + * Checks if the given string is empty (""). + * + * @param s: the string to check + * @return: true if @s is the empty string (""), false otherwise. + */ +#define is_empty_string(s) ('\0' == *s) + +/** + * string_starts_with: + * Checks if the given string starts with a given prefix. + * + * @param s: the string to check. + * @param p: the prefix. + * @return true if @s starts with @p, false otherwise. + */ +#define string_starts_with(s, p) (strncmp(s, p, strlen(p))) + +/** * strdup: * like strdup(3p). */ |
