aboutsummaryrefslogtreecommitdiffstats
path: root/l4str.c
diff options
context:
space:
mode:
Diffstat (limited to 'l4str.c')
-rw-r--r--l4str.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/l4str.c b/l4str.c
index 83cecae..4324056 100644
--- a/l4str.c
+++ b/l4str.c
@@ -7,6 +7,22 @@
#include <stdlib.h>
#include <string.h>
+bool lbs_str_has_prefix (const char* str, const char* prefix) {
+ int i;
+ for (i = 0; str[i] != '\0' && prefix[i] != '\0'; i++) {
+ if (str[i] != prefix[i]) {
+ return false;
+ }
+ }
+ if (str[i] == '\0' && prefix[i] == '\0') {
+ return true;
+ }
+ if (str[i] == '\0') {
+ return false;
+ }
+ return true;
+}
+
bool lbs_str_has_suffix (const char* str, const char* suffix) {
size_t len = strlen (str);
size_t suflen = strlen (suffix);