diff options
| author | Dennis Camera <skonfig@dtnr.ch> | 2022-08-22 00:27:47 +0200 |
|---|---|---|
| committer | Dennis Camera <skonfig@dtnr.ch> | 2022-08-22 00:27:47 +0200 |
| commit | 2f425cb9e9d28c8e7f017a4fbe1203c7431e745b (patch) | |
| tree | 9ac97abaebdbe3363ee71c6a9f3210799d4494ab /src/util/string.h | |
| parent | 580b957769a5ee4ab7522e474f3996c03426a286 (diff) | |
| download | skonfig-c-2f425cb9e9d28c8e7f017a4fbe1203c7431e745b.tar.gz skonfig-c-2f425cb9e9d28c8e7f017a4fbe1203c7431e745b.zip | |
Implement command execution
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). */ |
