diff options
Diffstat (limited to 'src/common.c')
| -rw-r--r-- | src/common.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c index 61b2805..af35064 100644 --- a/src/common.c +++ b/src/common.c @@ -13,6 +13,14 @@ void fatal_error(const char* msg, ...) { exit(1); } +bool str_starts_with(const char* s, const char* prefix) { + size_t l1 = strlen(s); + size_t l2 = strlen(prefix); + if (l1 < l2) + return false; + return strncmp(s, prefix, l2) == 0; +} + bool str_ends_with(const char* s, const char* suffix) { size_t l1 = strlen(s); size_t l2 = strlen(suffix); |
