From 8bb2da063f59e7586c61f88c1fb2d268e6191e5c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 3 Nov 2008 18:24:00 +0100 Subject: tag: added function tag_has_type() tag_has_type() checks whether the tag contains one or more items with the specified type. --- src/tag.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/tag.c') diff --git a/src/tag.c b/src/tag.c index 2ec4986ab..5e2a3620e 100644 --- a/src/tag.c +++ b/src/tag.c @@ -319,6 +319,18 @@ struct tag *tag_dup(const struct tag *tag) return ret; } +bool tag_has_type(const struct tag *tag, enum tag_type type) +{ + assert(tag != NULL); + assert(type < TAG_NUM_OF_ITEM_TYPES); + + for (unsigned i = 0; i < tag->numOfItems; i++) + if (tag->items[i]->type == type) + return true; + + return false; +} + int tag_equal(const struct tag *tag1, const struct tag *tag2) { int i; -- cgit v1.2.3