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 <stefasab@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer
2016-02-11 20:49:05 +01:00
parent d18df8beb0
commit a9b81bfd1c
3 changed files with 16 additions and 6 deletions

View File

@ -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,