grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / iffparse / findlocalitem.c
blob407d50e7c760f6435dd3f8bca8e65a099a3ddd29
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
7 #include <aros/debug.h>
8 #include "iffparse_intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <proto/iffparse.h>
15 AROS_LH4(struct LocalContextItem *, FindLocalItem,
17 /* SYNOPSIS */
18 AROS_LHA(struct IFFHandle *, iff, A0),
19 AROS_LHA(LONG , type, D0),
20 AROS_LHA(LONG , id, D1),
21 AROS_LHA(LONG , ident, D2),
23 /* LOCATION */
24 struct Library *, IFFParseBase, 35, IFFParse)
26 /* FUNCTION
27 Goes through the whole context node stack starting at the top
28 searching the contecnodes for attached LocalContextItems with the
29 specified type, id and ident codes.
31 INPUTS
32 iff - pointer to an IFFHandle struct.
33 type - type code for item to find.
34 id - identifier code for item to find.
35 ident - ident code for the class of context item to find.
37 RESULT
38 lci - pointer to a local context item if found, or NULL if
39 none is found.
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
48 StoreLocalItem()
50 INTERNALS
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
55 struct IntContextNode *cn_node,
56 *cn_nextnode;
57 struct LocalContextItem *lci_node,
58 *lci_nextnode;
60 (void) IFFParseBase;
62 DEBUG_FINDLOCALITEM(dprintf("FindLocalItem: iff 0x%lx type 0x%08lx (%c%c%c%c) id 0x%08lx (%c%c%c%c) ident 0x%08lx (%c%c%c%c)\n",
63 iff, type, dmkid(type), id, dmkid(id), ident, dmkid(ident)));
65 D(bug("FindLocalItem (iff=%p, type=%c%c%c%c, id=%c%c%c%c, ident=%c%c%c%c)\n",
66 iff,
67 dmkid(type),
68 dmkid(id),
69 dmkid(ident)
70 ));
72 /* Get contextnode at top */
73 cn_node = (struct IntContextNode*)TopChunk(iff);
75 while ((cn_nextnode = (struct IntContextNode*)cn_node->CN.cn_Node.mln_Succ))
77 #if DEBUG
78 if (cn_node)
80 DB2(bug(" node=%p (%c%c%c%c)\n",
81 cn_node,
82 dmkid(cn_node->CN.cn_Type)
83 ));
85 else
87 DB2(bug(" node=%p (----)\n", cn_node));
89 #endif
91 /* Get LCI at top inside contextnode */
92 lci_node = (struct LocalContextItem*)cn_node->cn_LCIList.mlh_Head;
94 while ((lci_nextnode = (struct LocalContextItem*)lci_node->lci_Node.mln_Succ))
96 #if DEBUG
97 if (lci_node)
99 DB2(bug(" lci_node=%p (%c%c%c%c, %c%c%c%c, %c%c%c%c)\n",
100 lci_node,
101 dmkid(lci_node->lci_Type),
102 dmkid(lci_node->lci_ID),
103 dmkid(lci_node->lci_Ident)
106 else
108 DB2(bug(" lci_node=%p (----, ----, ----)\n",
109 lci_node
112 #endif
114 /* Do we have a match ? */
117 (lci_node->lci_Type == type )
119 (lci_node->lci_ID == id )
121 (lci_node->lci_Ident == ident)
123 ReturnPtr ("FindLocalItem",struct LocalContextItem *,lci_node);
125 lci_node = lci_nextnode;
128 cn_node = cn_nextnode;
131 ReturnPtr ("FindLocalItem",struct LocalContextItem *,NULL);
132 AROS_LIBFUNC_EXIT
133 } /* FindLocalItem */