summaryrefslogtreecommitdiffstats
path: root/bstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'bstr.c')
-rw-r--r--bstr.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/bstr.c b/bstr.c
index f4d3bdef42..68342fabfe 100644
--- a/bstr.c
+++ b/bstr.c
@@ -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]);
+}