try to make sure compiler/include/mmakefile is always refreshed correctly.
[AROS.git] / rom / exec / findname.c
blob47701bbfdfc5d39905a3bfcf92fc550db2aec1c1
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Search for a node by name.
6 Lang: english
7 */
8 #include <string.h>
9 #include <aros/debug.h>
11 #include "exec_intern.h"
12 #include "exec_debug.h"
14 /*****************************************************************************
16 NAME */
17 #include <exec/lists.h>
18 #include <proto/exec.h>
20 AROS_LH2I(struct Node *, FindName,
22 /* SYNOPSIS */
23 AROS_LHA(struct List *, list, A0),
24 AROS_LHA(CONST_STRPTR, name, A1),
26 /* LOCATION */
27 struct ExecBase *, SysBase, 46, Exec)
29 /* FUNCTION
30 Look for a node with a certain name in a list.
32 INPUTS
33 list - Search this list.
34 name - This is the name to look for.
36 RESULT
38 NOTES
39 The search is case-sensitive, so "Hello" will not find a node
40 named "hello".
42 The list must contain complete Nodes and no MinNodes.
44 When supplied with a NULL list argument, defaults to the exec port list.
46 EXAMPLE
47 struct List * list;
48 struct Node * node;
50 // Look for a node with the name "Hello"
51 node = FindName (list, "Hello");
53 BUGS
55 SEE ALSO
57 INTERNALS
59 ******************************************************************************/
61 AROS_LIBFUNC_INIT
62 struct Node * node;
63 /* FIX !
64 FindName supplied with a NULL list defaults to the exec port list
65 Changed in lists.c as well....
67 if( !list )
69 #if defined(__AROSEXEC_SMP__)
70 bug("[EXEC] %s: called with NULL list!\n", __func__);
71 #endif
72 list = &SysBase->PortList;
75 /* ASSERT(list != NULL); */
76 ASSERT(name);
78 /* Look through the list */
79 for (node=GetHead(list); node; node=GetSucc(node))
81 /* Only compare the names if this node has one. */
82 if(node->ln_Name)
84 /* Check the node. If we found it, stop. */
85 if (!strcmp (node->ln_Name, name))
86 break;
91 If we found a node, this will contain the pointer to it. If we
92 didn't, this will be NULL (either because the list was
93 empty or because we tried all nodes in the list)
95 return node;
96 AROS_LIBFUNC_EXIT
97 } /* FindName */