diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-04-19 06:53:56 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-04-20 04:22:53 +0300 |
commit | a2d28010cc7804cf4062f80eef5271c7e3eeb469 (patch) | |
tree | ff91e9a1203cecabddd009f2c27c63deabe90e81 /bstr.h | |
parent | 52d60a7334a731278e9f68d80e0f7cc5639437c4 (diff) | |
download | mpv-a2d28010cc7804cf4062f80eef5271c7e3eeb469.tar.bz2 mpv-a2d28010cc7804cf4062f80eef5271c7e3eeb469.tar.xz |
cleanup: find_subfiles.c: simplify (mainly using bstr)
Diffstat (limited to 'bstr.h')
-rw-r--r-- | bstr.h | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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 |