Indentation fix, cleanup.
[AROS.git] / rom / exec / findname.c
blobc9a41124446fc068524f23bb24efff0ceb1ddf23
1 /*
2 Copyright © 1995-2001, 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 /*****************************************************************************
13 NAME */
14 #include <exec/lists.h>
15 #include <proto/exec.h>
17 AROS_LH2I(struct Node *, FindName,
19 /* SYNOPSIS */
20 AROS_LHA(struct List *, list, A0),
21 AROS_LHA(CONST_STRPTR, name, A1),
23 /* LOCATION */
24 struct ExecBase *, SysBase, 46, Exec)
26 /* FUNCTION
27 Look for a node with a certain name in a list.
29 INPUTS
30 list - Search this list.
31 name - This is the name to look for.
33 RESULT
35 NOTES
36 The search is case-sensitive, so "Hello" will not find a node
37 named "hello".
39 The list must contain complete Nodes and no MinNodes.
41 When supplied with a NULL list argument, defaults to the exec port list.
43 EXAMPLE
44 struct List * list;
45 struct Node * node;
47 // Look for a node with the name "Hello"
48 node = FindName (list, "Hello");
50 BUGS
52 SEE ALSO
54 INTERNALS
56 ******************************************************************************/
58 AROS_LIBFUNC_INIT
59 struct Node * node;
60 /* FIX !
61 FindName supplied with a NULL list defaults to the exec port list
62 Changed in lists.c as well....
64 if( !list )
65 list = &SysBase->PortList;
67 /* ASSERT(list != NULL); */
68 ASSERT(name);
70 /* Look through the list */
71 for (node=GetHead(list); node; node=GetSucc(node))
73 /* Only compare the names if this node has one. */
74 if(node->ln_Name)
76 /* Check the node. If we found it, stop. */
77 if (!strcmp (node->ln_Name, name))
78 break;
83 If we found a node, this will contain the pointer to it. If we
84 didn't, this will be NULL (either because the list was
85 empty or because we tried all nodes in the list)
87 return node;
88 AROS_LIBFUNC_EXIT
89 } /* FindName */