From 69e7336b8e16ee65226fc20381baf537f4b125e6 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Tue, 29 Jul 2014 14:29:13 +0100 Subject: avstring: Expose the simple name match function Signed-off-by: Vittorio Giovara --- libavutil/avstring.c | 20 ++++++++++++++++++++ libavutil/avstring.h | 9 +++++++++ libavutil/version.h | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) (limited to 'libavutil') diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 3ea7be0e1d..eb5c95a01c 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -234,6 +234,26 @@ int av_isxdigit(int c) return av_isdigit(c) || (c >= 'a' && c <= 'f'); } +int av_match_name(const char *name, const char *names) +{ + const char *p; + int len, namelen; + + if (!name || !names) + return 0; + + namelen = strlen(name); + while ((p = strchr(names, ','))) { + len = FFMAX(p - names, namelen); + if (!av_strncasecmp(name, names, len)) + return 1; + names = p + 1; + } + return !av_strcasecmp(name, names); +} + + + #ifdef TEST int main(void) diff --git a/libavutil/avstring.h b/libavutil/avstring.h index b7d10983c3..9a18ddd893 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -219,6 +219,15 @@ const char *av_basename(const char *path); */ const char *av_dirname(char *path); + +/** + * Match instances of a name in a comma-separated list of names. + * @param name Name to look for. + * @param names List of names. + * @return 1 on match, 0 otherwise. + */ +int av_match_name(const char *name, const char *names); + /** * @} */ diff --git a/libavutil/version.h b/libavutil/version.h index a2625b5ee5..e981948b3f 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -54,7 +54,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 53 -#define LIBAVUTIL_VERSION_MINOR 18 +#define LIBAVUTIL_VERSION_MINOR 19 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- cgit v1.2.3