Statistics
| Branch: | Revision:

iof-bird-daemon / lib / lists.h @ 18c8241a

History | View | Annotate | Download (935 Bytes)

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

    
12
typedef struct node {
13
  struct node *next, *prev;
14
} node;
15

    
16
typedef 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

    
27
void add_tail(list *, node *);
28
void add_head(list *, node *);
29
void rem_node(node *);
30
void add_tail_list(list *, list *);
31
void init_list(list *);
32
void 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