From a9b81bfd1c7a9b3d4c92af99aee9a284d1133b9e Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 11 Feb 2016 20:49:05 +0100 Subject: avutil/avstring: add a "ALL" entry and the possibility to negate matches to av_match_name() This will extend the whitelist features to allow blacklisting individual protocols and to explicitly force everything to be enabled. Reviewed-by: Stefano Sabatini Signed-off-by: Michael Niedermayer --- libavutil/avstring.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'libavutil/avstring.c') diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 57fe74d252..85fb3e921e 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -326,13 +326,18 @@ int av_match_name(const char *name, const char *names) return 0; namelen = strlen(name); - while ((p = strchr(names, ','))) { + while (*names) { + int negate = '-' == *names; + p = strchr(names, ','); + if (!p) + p = names + strlen(names); + names += negate; len = FFMAX(p - names, namelen); - if (!av_strncasecmp(name, names, len)) - return 1; - names = p + 1; + if (!av_strncasecmp(name, names, len) || !strncmp("ALL", names, FFMAX(3, p - names))) + return !negate; + names = p + (*p == ','); } - return !av_strcasecmp(name, names); + return 0; } int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end, -- cgit v1.2.3