tag_ape: support multiple values

One APE tag may contain more than one value, separated by null bytes.
This commit is contained in:
Max Kellermann
2010-11-24 08:59:04 +01:00
parent 1ab46472ab
commit 429ed24c99
2 changed files with 16 additions and 1 deletions

View File

@@ -52,7 +52,21 @@ tag_ape_import_item(struct tag *tag, unsigned long flags,
if (tag == NULL)
tag = tag_new();
tag_add_item_n(tag, type, value, value_length);
const char *end = value + value_length;
while (true) {
/* multiple values are separated by null bytes */
const char *n = memchr(value, 0, end - value);
if (n != NULL) {
if (n > value)
tag_add_item_n(tag, type, value, n - value);
value = n + 1;
} else {
if (end > value)
tag_add_item_n(tag, type, value, end - value);
break;
}
}
return tag;
}