]> git.ipfire.org Git - thirdparty/bird.git/blame - lib/lists.h
First look at data structures. More to come tomorrow...
[thirdparty/bird.git] / lib / lists.h
CommitLineData
58ef912c
MM
1/*
2 * BIRD Library -- Linked Lists
3 *
4 * (c) 1998 Martin Mares <mj@ucw.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9#ifndef _BIRD_LISTS_H_
10#define _BIRD_LISTS_H_
11
12typedef struct node {
13 struct node *next, *prev;
14} node;
15
16typedef struct list { /* In fact two overlayed nodes */
17 struct node *head, *null, *tail;
18} list;
19
20#define NODE (node *)
21#define HEAD(list) ((void *)((list).head))
22#define TAIL(list) ((void *)((list).tail))
23#define WALK_LIST(n,list) for((n)=HEAD(list);(NODE (n))->next; \
24 n=(void *)((NODE (n))->next))
25#define EMPTY_LIST(list) (!(list).head->next)
26
27void add_tail(list *, node *);
28void add_head(list *, node *);
29void rem_node(node *);
30void add_tail_list(list *, list *);
31void init_list(list *);
32void insert_node(node *, node *);
33
34#ifndef _BIRD_LISTS_C_
35#define LIST_INLINE extern inline
36#include <lib/lists.c>
37#undef LIST_INLINE
38#else
39#define LIST_INLINE
40#endif
41
42#endif