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