From 0d92b0d5f445d4f26fb9d9d7cbf83c415c8d2279 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 30 Sep 2014 19:00:52 +0200 Subject: avutil/avstring: Factor av_match_list() out Signed-off-by: Michael Niedermayer --- libavutil/avstring.c | 21 +++++++++++++++++++++ libavutil/avstring.h | 7 +++++++ libavutil/version.h | 4 ++-- 3 files changed, 30 insertions(+), 2 deletions(-) (limited to 'libavutil') diff --git a/libavutil/avstring.c b/libavutil/avstring.c index fd010e407c..ac7f98ae74 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -402,6 +402,27 @@ end: return ret; } +int av_match_list(const char *name, const char *list, char separator) +{ + const char *p; + char ext1[128], *q; + int i; + + p = list; + for (i = 1;; i++) { + q = ext1; + while (*p != '\0' && *p != separator && q - ext1 < sizeof(ext1) - 1) + *q++ = *p++; + *q = '\0'; + if (!av_strcasecmp(ext1, name)) + return i; + if (*p == '\0') + break; + p++; + } + return 0; +} + #ifdef TEST int main(void) diff --git a/libavutil/avstring.h b/libavutil/avstring.h index 616c0662fc..ea7d1dcb43 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -357,6 +357,13 @@ int av_escape(char **dst, const char *src, const char *special_chars, int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end, unsigned int flags); +/** + * Check if a name is in a list. + * @returns 0 if not found, or the 1 based index where it has been found in the + * list. + */ +int av_match_list(const char *name, const char *list, char separator); + /** * @} */ diff --git a/libavutil/version.h b/libavutil/version.h index 14242f9b1c..9e138b5fab 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -56,8 +56,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 54 -#define LIBAVUTIL_VERSION_MINOR 7 -#define LIBAVUTIL_VERSION_MICRO 101 +#define LIBAVUTIL_VERSION_MINOR 8 +#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ -- cgit v1.2.3