diff options
Diffstat (limited to 'bstr.c')
-rw-r--r-- | bstr.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -19,6 +19,7 @@ #include <string.h> #include <libavutil/avutil.h> #include <assert.h> +#include <ctype.h> #include "talloc.h" @@ -70,6 +71,14 @@ int bstrrchr(struct bstr str, int c) return -1; } +int bstr_find(struct bstr haystack, struct bstr needle) +{ + for (int i = 0; i < haystack.len; i++) + if (bstr_startswith(bstr_splice(haystack, i, haystack.len), needle)) + return i; + return -1; +} + struct bstr bstr_strip(struct bstr str) { while (str.len && isspace(*str.start)) { @@ -148,3 +157,9 @@ struct bstr *bstr_splitlines(void *talloc_ctx, struct bstr str) r[count - 1].len = str.start + str.len - p; return r; } + +void bstr_lower(struct bstr str) +{ + for (int i = 0; i < str.len; i++) + str.start[i] = tolower(str.start[i]); +} |