Added AROS port of all shell applications:
[cake.git] / rom / utility / nexttagitem.c
blobab1a97c04216a026f3f78e1b3f0da1587335df70
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$ $Log
4 */
5 #include "intern.h"
7 /*****************************************************************************
9 NAME */
10 #include <utility/tagitem.h>
11 #include <proto/utility.h>
13 AROS_LH1(struct TagItem *, NextTagItem,
15 /* SYNOPSIS */
16 AROS_LHA(const struct TagItem **, tagListPtr, A0),
18 /* LOCATION */
19 struct Library *, UtilityBase, 8, Utility)
21 /* FUNCTION
22 Returns the address of the next tag-item in the list. This
23 routine correctly handles TAG_END, TAG_DONE, TAG_MORE,
24 TAG_IGNORE and TAG_SKIP.
26 TAG_END and TAG_DONE both terminate a TagItems-array (in
27 fact, TAG_DONE is the same as TAG_END).
29 With TAG_MORE, you can redirect the processing to a new list
30 of tags. Note that the processing will not return to the previous
31 list when a TAG_END/TAG_DONE is encountered.
33 TAG_IGNORE disables the processing of an entry in the list.
34 This entry is just ignored (We use this technique for filtering).
36 TAG_SKIP skips this tagitem, and the next number of tagitems as
37 indicated in the tag's ti_Data field.
39 INPUTS
40 tagListPtr - Pointer to an element in a taglist.
42 RESULT
43 Next tag item or NULL if you reached the end of the list.
45 NOTES
46 - TAG_MORE works like "go on with new list" instead of "read new
47 list and go on with the current one".
49 EXAMPLE
51 BUGS
53 SEE ALSO
55 INTERNALS
57 *****************************************************************************/
59 AROS_LIBFUNC_INIT
61 if(!(*tagListPtr)) return NULL;
63 /* Gosh, can't enable these because we get LOTS of hits at startup time
65 * ASSERT_VALID_PTR(tagListPtr);
66 * ASSERT_VALID_PTR(*tagListPtr);
69 while (TRUE)
71 switch ((*tagListPtr)->ti_Tag)
73 case TAG_MORE:
74 if (!((*tagListPtr) = (struct TagItem *)(*tagListPtr)->ti_Data))
75 return NULL;
76 continue;
78 case TAG_IGNORE:
79 break;
81 case TAG_END:
82 (*tagListPtr) = NULL;
83 return NULL;
85 case TAG_SKIP:
86 (*tagListPtr) += (*tagListPtr)->ti_Data + 1;
87 continue;
89 default:
90 /* Use post-increment (return will return the current value and
91 then tagListPtr will be incremented) */
92 return (struct TagItem *)(*tagListPtr)++;
95 (*tagListPtr) ++;
98 AROS_LIBFUNC_EXIT
99 } /* NextTagItem */