- Don't set DHCP in interface file if interface is PPP. Otherwise dhclient
[AROS.git] / tools / MetaMake / list.h
blob4eb98ace7fb019ad4cf37fab3b445ecef22643b4
1 #ifndef __MMAKE_LIST_H
2 #define __MMAKE_LIST_H
4 /* MetaMake - A Make extension
5 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
7 This file is part of MetaMake.
9 MetaMake is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
14 MetaMake is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
24 #include <stddef.h>
26 /* This file specifies the API for the list functions */
28 /* Types */
29 struct Node
31 struct Node * next,
32 * prev;
33 char * name;
36 struct List
38 struct Node * first,
39 * last,
40 * prelast;
42 List;
44 /* Macros */
45 # define NewList(l) (((struct List *)l)->prelast = (struct Node *)(l), \
46 ((struct List *)l)->last = 0, \
47 ((struct List *)l)->first = (struct Node *)&(((struct List *)l)->last))
49 # define AddHead(l,n) ((void)(\
50 ((struct Node *)n)->next = ((struct List *)l)->first, \
51 ((struct Node *)n)->prev = (struct Node *)&((struct List *)l)->first, \
52 ((struct List *)l)->first->prev = ((struct Node *)n), \
53 ((struct List *)l)->first = ((struct Node *)n)))
55 # define AddTail(l,n) ((void)(\
56 ((struct Node *)n)->next = (struct Node *)&((struct List *)l)->last, \
57 ((struct Node *)n)->prev = ((struct List *)l)->prelast, \
58 ((struct List *)l)->prelast->next = ((struct Node *)n), \
59 ((struct List *)l)->prelast = ((struct Node *)n) ))
61 # define Remove(n) ((void)(\
62 ((struct Node *)n)->prev->next = ((struct Node *)n)->next,\
63 ((struct Node *)n)->next->prev = ((struct Node *)n)->prev ))
65 # define GetHead(l) (void *)(((struct List *)l)->first->next \
66 ? ((struct List *)l)->first \
67 : (struct Node *)0)
68 # define GetTail(l) (void *)(((struct List *)l)->prelast->prev \
69 ? ((struct List *)l)->prelast \
70 : (struct Node *)0)
71 # define GetNext(n) (void *)(((struct Node *)n)->next->next \
72 ? ((struct Node *)n)->next \
73 : (struct Node *)0)
74 # define GetPrev(n) (void *)(((struct Node *)n)->prev->prev \
75 ? ((struct Node *)n)->prev \
76 : (struct Node *)0)
77 # define ForeachNode(l,n) \
78 for (n=(void *)(((struct List *)(l))->first); \
79 ((struct Node *)(n))->next; \
80 n=(void *)(((struct Node *)(n))->next))
81 # define ForeachNodeSafe(l,node,nextnode) \
82 for (node=(void *)(((struct List *)(l))->first); \
83 ((nextnode)=(void*)((struct Node *)(node))->next); \
84 (node)=(void *)(nextnode))
86 /* Functions */
87 void AssignList (struct List * dest, struct List * src); /* After assignment only dest may be used !!! */
88 void *FindNode (const struct List * l, const char * name);
89 void printlist (struct List * l);
90 void freelist (struct List * l);
91 struct Node *newnode (const char * name);
92 void *newnodesize (const char * name, size_t size);
93 struct Node *addnodeonce (struct List * l, const char * name);
94 void *addnodeoncesize (struct List * l, const char * name, size_t size);
96 #endif /* __MMAKE_LIST_H */