summaryrefslogtreecommitdiffstats
path: root/bstr.h
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-04-19 06:53:56 +0300
committerUoti Urpala <uau@mplayer2.org>2011-04-20 04:22:53 +0300
commita2d28010cc7804cf4062f80eef5271c7e3eeb469 (patch)
treeff91e9a1203cecabddd009f2c27c63deabe90e81 /bstr.h
parent52d60a7334a731278e9f68d80e0f7cc5639437c4 (diff)
downloadmpv-a2d28010cc7804cf4062f80eef5271c7e3eeb469.tar.bz2
mpv-a2d28010cc7804cf4062f80eef5271c7e3eeb469.tar.xz
cleanup: find_subfiles.c: simplify (mainly using bstr)
Diffstat (limited to 'bstr.h')
-rw-r--r--bstr.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/bstr.h b/bstr.h
index cbd96f49c9..47bde14739 100644
--- a/bstr.h
+++ b/bstr.h
@@ -38,11 +38,13 @@ int bstrcmp(struct bstr str1, struct bstr str2);
int bstrcasecmp(struct bstr str1, struct bstr str2);
int bstrchr(struct bstr str, int c);
int bstrrchr(struct bstr str, int c);
+int bstr_find(struct bstr haystack, struct bstr needle);
struct bstr *bstr_splitlines(void *talloc_ctx, struct bstr str);
struct bstr bstr_strip(struct bstr str);
struct bstr bstr_split(struct bstr str, char *sep, struct bstr *rest);
struct bstr bstr_splice(struct bstr str, int start, int end);
long long bstrtoll(struct bstr str, struct bstr *rest, int base);
+void bstr_lower(struct bstr str);
static inline struct bstr bstr_cut(struct bstr str, int n)
{
@@ -56,12 +58,20 @@ static inline bool bstr_startswith(struct bstr str, struct bstr prefix)
return !memcmp(str.start, prefix.start, prefix.len);
}
+// demux_rtp.cpp (live555) C++ compilation workaround
+#ifndef __cplusplus
static inline char *bstrdup0(void *talloc_ctx, struct bstr str)
{
- // cast is live555 C++ compilation workaround
return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
}
+static inline struct bstr bstrdup(void *talloc_ctx, struct bstr str)
+{
+ struct bstr r = { talloc_strndup(talloc_ctx, str.start, str.len), str.len };
+ return r;
+}
+#endif
+
// Create bstr compound literal from null-terminated string
#define BSTR(s) (struct bstr){(char *)(s), (s) ? strlen(s) : 0}
// create a pair (not single value!) for "%.*s" printf syntax