squashed commit of private hostlib-resource branch
[tangerine.git] / test / oop2 / support.c
blobdc0421d07d3b04139b6174d96ba9ccaac697f225
1 /*
2 Copyright © 1997-98, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Demo of new OOP system
6 Lang: english
7 */
8 #include "support.h"
9 #include <string.h>
11 VOID AddTail(struct List *list, struct Node *node)
13 assert (node);
14 assert (list);
16 node->ln_Succ = (struct Node *)&list->lh_Tail;
17 node->ln_Pred = list->lh_TailPred;
19 list->lh_TailPred->ln_Succ = node;
20 list->lh_TailPred = node;
24 struct Node *FindName(struct List *list, STRPTR name)
26 struct Node * node;
28 assert (list);
29 assert (name);
31 /* Look through the list */
32 for (node=GetHead(list); node; node=GetSucc(node))
34 /* Only compare the names if this node has one. */
35 if(node->ln_Name)
37 /* Check the node. If we found it, stop. */
38 if (!strcmp (node->ln_Name, name))
39 break;
44 If we found a node, this will contain the pointer to it. If we
45 didn't, this will be NULL (either because the list was
46 empty or because we tried all nodes in the list)
48 return node;
51 VOID Remove(struct Node *node)
53 node->ln_Pred->ln_Succ = node->ln_Succ;
54 node->ln_Succ->ln_Pred = node->ln_Pred;
56 return;