grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / prefs / wanderer / entryelements.c
blob6c4101213e26fc8f84d52ec87cf54970aedce792
1 /*
2 Copyright 2004-2007, The AROS Development Team. All rights reserved.
3 This file is part of the Wanderer Preferences program, which is distributed
4 under the terms of version 2 of the GNU General Public License.
6 $Id$
7 */
9 #include <proto/exec.h>
10 #include <proto/utility.h>
11 #include <proto/dos.h>
13 #include <clib/alib_protos.h>
14 #include <stdio.h>
15 #include <string.h>
17 #define HAVE_ELEMENTFUNCS
18 #include "entryelements.h"
20 ULONG EntryElementCount(struct List *entry_List)
22 ULONG count = 0;
23 struct EntryElement__Entry *current_Node = NULL;
25 ForeachNode(entry_List, current_Node)
27 count += 1;
29 return count;
32 BOOL EntryElementRegister(struct List *entry_List, ULONG entry_ID, CONST_STRPTR entry_Name)
34 struct EntryElement__Entry *current_Node = NULL;
35 IPTR element_NameLen = strlen(entry_Name) ;
37 //If the element already exists fail ..
38 ForeachNode(entry_List, current_Node)
40 if ((current_Node->EE_E_ID == (IPTR)entry_ID) ||
41 (strcmp(current_Node->EE_E_Name, entry_Name) == 0))
42 return FALSE;
45 current_Node = AllocVec(sizeof(struct EntryElement__Entry), MEMF_PUBLIC|MEMF_CLEAR);
46 current_Node->EE_E_Name = AllocVec(element_NameLen + 1, MEMF_PUBLIC|MEMF_CLEAR);
47 strncpy(current_Node->EE_E_Name, entry_Name, element_NameLen);
49 current_Node->EE_E_ID = (IPTR)entry_ID;
50 AddTail(entry_List, (struct Node *)current_Node);
52 return TRUE;
55 void EntryElementRemove(struct List *entry_List, ULONG entry_ID)
57 struct EntryElement__Entry *current_Node = NULL;
59 ForeachNode(entry_List, current_Node)
61 if (current_Node->EE_E_ID == (IPTR)entry_ID)
63 /* TODO: remove the elements node and free its storage */
68 IPTR EntryElementFindNode(struct List *entry_List, ULONG entry_ID)
70 struct EntryElement__Entry *current_Node = NULL;
72 ForeachNode(entry_List, current_Node)
74 if (current_Node->EE_E_ID == (IPTR)entry_ID)
75 return (IPTR)current_Node;
77 return 0;
80 IPTR EntryElementFindNamedNode(struct List *entry_List, char * entry_Name)
82 struct EntryElement__Entry *current_Node = NULL;
84 ForeachNode(entry_List, current_Node)
86 if (strcmp(current_Node->EE_E_Name, entry_Name) == 0)
87 return (IPTR)current_Node;
89 return 0;
92 IPTR GetEntryElementName(IPTR entry)
94 return (IPTR)(((struct EntryElement__Entry *)entry)->EE_E_Name);
97 IPTR GetEntryElementID(IPTR entry)
99 return ((struct EntryElement__Entry *)entry)->EE_E_ID;