define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / tools / MetaMake / list.h
blob51a5d8dc35ebbc3c7b45e67376284feeb6323018
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 typedef struct _Node Node;
31 struct _Node
33 Node * next,
34 * prev;
35 char * name;
38 typedef struct
40 Node * first,
41 * last,
42 * prelast;
44 List;
46 /* Macros */
47 # define NewList(l) (((List *)l)->prelast = (Node *)(l), \
48 ((List *)l)->last = 0, \
49 ((List *)l)->first = (Node *)&(((List *)l)->last))
51 # define AddHead(l,n) ((void)(\
52 ((Node *)n)->next = ((List *)l)->first, \
53 ((Node *)n)->prev = (Node *)&((List *)l)->first, \
54 ((List *)l)->first->prev = ((Node *)n), \
55 ((List *)l)->first = ((Node *)n)))
57 # define AddTail(l,n) ((void)(\
58 ((Node *)n)->next = (Node *)&((List *)l)->last, \
59 ((Node *)n)->prev = ((List *)l)->prelast, \
60 ((List *)l)->prelast->next = ((Node *)n), \
61 ((List *)l)->prelast = ((Node *)n) ))
63 # define Remove(n) ((void)(\
64 ((Node *)n)->prev->next = ((Node *)n)->next,\
65 ((Node *)n)->next->prev = ((Node *)n)->prev ))
67 # define GetHead(l) (void *)(((List *)l)->first->next \
68 ? ((List *)l)->first \
69 : (Node *)0)
70 # define GetTail(l) (void *)(((List *)l)->prelast->prev \
71 ? ((List *)l)->prelast \
72 : (Node *)0)
73 # define GetNext(n) (void *)(((Node *)n)->next->next \
74 ? ((Node *)n)->next \
75 : (Node *)0)
76 # define GetPrev(n) (void *)(((Node *)n)->prev->prev \
77 ? ((Node *)n)->prev \
78 : (Node *)0)
79 # define ForeachNode(l,n) \
80 for (n=(void *)(((List *)(l))->first); \
81 ((Node *)(n))->next; \
82 n=(void *)(((Node *)(n))->next))
83 # define ForeachNodeSafe(l,node,nextnode) \
84 for (node=(void *)(((List *)(l))->first); \
85 ((nextnode)=(void*)((Node *)(node))->next); \
86 (node)=(void *)(nextnode))
88 /* Functions */
89 void AssignList (List * dest, List * src); /* After assignment only dest may be used !!! */
90 void *FindNode (const List * l, const char * name);
91 void printlist (List * l);
92 void freelist (List * l);
93 Node *newnode (const char * name);
94 void *newnodesize (const char * name, size_t size);
95 Node *addnodeonce (List * l, const char * name);
96 void *addnodeoncesize (List * l, const char * name, size_t size);
98 #endif /* __MMAKE_LIST_H */