include/libtu/dlist.h

Wed, 16 Apr 2003 09:09:34 +0200

author
tuomov
date
Wed, 16 Apr 2003 09:09:34 +0200
changeset 52
0228b3741a42
parent 43
aad48c3d4966
child 53
f8f9366b359c
permissions
-rw-r--r--

trunk: changeset 56
set_warn_handler returns default_warn_handler instead of NULL when no
other warn handlers are set.

11
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
1 /*
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
2 * libtu/common.h
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
3 *
36
63cd573ffbcf trunk: changeset 39
tuomov
parents: 11
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2002.
11
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
5 * See the included file LICENSE for details.
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
6 */
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
7
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
8 #ifndef LIBTU_DLIST_H
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
9 #define LIBTU_DLIST_H
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
10
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
11 #define LINK_ITEM(LIST, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
12 (ITEM)->NEXT=NULL; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
13 if((LIST)==NULL){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
14 (LIST)=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
15 (ITEM)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
16 }else{ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
17 (ITEM)->PREV=(LIST)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
18 (ITEM)->PREV->NEXT=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
19 (LIST)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
20 }
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
21
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
22
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
23 #define LINK_ITEM_FIRST(LIST, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
24 (ITEM)->NEXT=(LIST); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
25 if((LIST)==NULL){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
26 (ITEM)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
27 }else{ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
28 (ITEM)->PREV=(LIST)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
29 (LIST)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
30 } \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
31 (LIST)=(ITEM);
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
32
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
33
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
34 #define LINK_ITEM_LIST LINK_ITEM
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
35
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
36
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
37 #define LINK_ITEM_BEFORE(LIST, BEFORE, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
38 (ITEM)->NEXT=(BEFORE); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
39 (ITEM)->PREV=(BEFORE)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
40 (BEFORE)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
41 if((BEFORE)==(LIST)) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
42 (LIST)=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
43 else \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
44 (ITEM)->PREV->NEXT=(ITEM)
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
45
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
46
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
47 #define LINK_ITEM_AFTER(LIST, AFTER, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
48 (ITEM)->NEXT=(AFTER)->NEXT; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
49 (ITEM)->PREV=(AFTER); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
50 (AFTER)->NEXT=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
51 if((ITEM)->NEXT==NULL) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
52 (LIST)->PREV=(ITEM); \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
53 else \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
54 (ITEM)->NEXT->PREV=ITEM;
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
55
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
56
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
57 #define UNLINK_ITEM(LIST, ITEM, NEXT, PREV) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
58 if((ITEM)==(LIST)){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
59 (LIST)=(ITEM)->NEXT; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
60 if((LIST)!=NULL) \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
61 (LIST)->PREV=(ITEM)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
62 }else if((ITEM)->NEXT==NULL){ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
63 (ITEM)->PREV->NEXT=NULL; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
64 (LIST)->PREV=(ITEM)->PREV; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
65 }else{ \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
66 (ITEM)->PREV->NEXT=(ITEM)->NEXT; \
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
67 (ITEM)->NEXT->PREV=(ITEM)->PREV; \
43
aad48c3d4966 trunk: changeset 46
tuomov
parents: 36
diff changeset
68 } \
aad48c3d4966 trunk: changeset 46
tuomov
parents: 36
diff changeset
69 (ITEM)->NEXT=NULL; \
aad48c3d4966 trunk: changeset 46
tuomov
parents: 36
diff changeset
70 (ITEM)->PREV=NULL;
11
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
71
3ea4e7930c5b trunk: changeset 14
tuomov
parents:
diff changeset
72 #endif /* LIBTU_DLIST_H */

mercurial