revert between 56095 -> 55830 in arch
[AROS.git] / workbench / prefs / wanderer / entryelements.c
blobb41ed6e1fea9191763267eecbf0981a5930375a2
1 /*
2 Copyright 2004-2019, 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 strcpy(current_Node->EE_E_Name, entry_Name);
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;