2 * nazghul - an old-school RPG engine
3 * Copyright (C) 2002, 2003, 2004 Gordon McNutt
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Foundation, Inc., 59 Temple Place,
17 * Suite 330, Boston, MA 02111-1307 USA
20 * gmcnutt@users.sourceforge.net
38 #define nodelst(n) (&((n)->olist.list))
39 #define nodekeyedlst(n) (&((n)->olist))
40 #define node_next(n) ((struct node *)((n)->olist.list.next))
41 #define node_prev(n) ((struct node *)((n)->olist.list.prev))
42 #define node_key(n) ((n)->olist.key)
43 #define node_add(n1,n2) list_add(nodelst(n1), nodelst(n2))
44 #define node_addref(n) ((n)->ref++)
45 #define node_add_keyed(n1, n2) olist_add(nodekeyedlst(n1), nodekeyedlst(n2))
46 #define node_add_tail(n1,n2) list_add_tail(nodelst(n1), nodelst(n2))
47 #define node_for_each(head,ptr) \
48 for ((ptr) = node_next(head); (ptr) != (head); (ptr) = node_next(ptr))
49 #define node_init(n) { list_init(nodelst(n)); (n)->ptr = NULL; }
50 #define node_list_empty(n) (list_empty(nodelst(n)))
51 #define node_remove(n) list_remove(nodelst(n))
52 #define node_switch(a,b) (list_switch(nodelst(a), nodelst(b)))
53 #define node_lookup(n, key) (struct node*)(olist_lookup(nodekeyedlst(n),(key), 0))
55 extern struct node *node_new(void *data);
56 extern struct node *node_new_keyed(void *data, int key);
57 extern void node_unref(struct node *node);
58 extern void node_foldr(struct node *node,
59 void (*fx)(struct node *node, void *data),
61 extern int node_list_len(struct node *head);
62 extern void node_list_unlink_and_unref(struct node *head);