gcc-4.6.2: Update with patch for gengtype.c
[AROS.git] / rom / utility / filtertagitems.c
blob82cbe8573773d911b309790844231e0e000dc6e4
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: FilterTagItems() - filter an array of TagItems.
6 Lang: english
7 */
8 #include "intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <proto/utility.h>
15 AROS_LH3(ULONG, FilterTagItems,
17 /* SYNOPSIS */
18 AROS_LHA(struct TagItem *, tagList, A0),
19 AROS_LHA(Tag *, filterArray, A1),
20 AROS_LHA(ULONG , logic, D0),
22 /* LOCATION */
23 struct Library *, UtilityBase, 16, Utility)
25 /* FUNCTION
26 Scans a tag list and removes tag items from the list depending
27 upon whether the tag's Tag value is found in an array of tag
28 values.
30 If 'logic' is TAGFILTER_AND, then all the tags that are NOT
31 in the array filterArray will be removed from the tagList.
33 If 'logic' is TAGFILTER_NOT, then all the tags that ARE in
34 the array filterArray will be removed from the tagList.
36 Tags are removed by setting their ti_Tag value to TAG_IGNORE.
38 INPUTS
39 tagList - A TagList to filter items from.
40 filterArray - An array (as described by TagInArray())
41 to determine which tag items are to be
42 removed.
43 logic - Whether the tags in filterArray are to be
44 included or excluded from the tag list.
46 RESULT
47 The number of valid items left in the resulting filtered list.
49 NOTES
51 EXAMPLE
53 BUGS
55 SEE ALSO
56 TagInArray()
58 INTERNALS
60 HISTORY
61 29-10-95 digulla automatically created from
62 utility_lib.fd and clib/utility_protos.h
64 *****************************************************************************/
66 AROS_LIBFUNC_INIT
68 ULONG valid = 0;
69 if(tagList && filterArray)
71 struct TagItem *ti;
73 while((ti = NextTagItem(&tagList)))
75 if(logic == TAGFILTER_AND)
77 if(TagInArray(ti->ti_Tag, filterArray))
78 valid++;
79 else
80 ti->ti_Tag = TAG_IGNORE;
82 else if(logic == TAGFILTER_NOT)
84 if(TagInArray(ti->ti_Tag, filterArray))
85 ti->ti_Tag = TAG_IGNORE;
86 else
87 valid++;
91 return valid;
93 AROS_LIBFUNC_EXIT
94 } /* FilterTagItems */