avutil/avstring: Factor av_match_list() out

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer
2014-09-30 19:00:52 +02:00
parent 6ea357ea83
commit 0d92b0d5f4
5 changed files with 36 additions and 19 deletions

View File

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