dlist.h

Mon, 17 Jan 2005 22:02:09 +0100

author
tuomov
date
Mon, 17 Jan 2005 22:02:09 +0100
changeset 85
9f94b2e96e3b
parent 62
aae5facf9fc5
child 87
95553f8ea540
permissions
-rw-r--r--

trunk: changeset 1934
Fixed everything that requires locale stuff to check CF_NO_LOCALE.

58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
1 /*
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
2 * libtu/common.h
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
3 *
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2002.
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
5 *
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
6 * You may distribute and modify this library under the terms of either
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
8 */
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
9
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
10 #ifndef LIBTU_DLIST_H
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
11 #define LIBTU_DLIST_H
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
12
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
13 #define LINK_ITEM(LIST, ITEM, NEXT, PREV) \
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
14 (ITEM)->NEXT=NULL; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
15 if((LIST)==NULL){ \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
16 (LIST)=(ITEM); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
17 (ITEM)->PREV=(ITEM); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
18 }else{ \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
19 (ITEM)->PREV=(LIST)->PREV; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
20 (ITEM)->PREV->NEXT=(ITEM); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
21 (LIST)->PREV=(ITEM); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
22 }
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
23
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
24
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
25 #define LINK_ITEM_FIRST(LIST, ITEM, NEXT, PREV) \
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
26 (ITEM)->NEXT=(LIST); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
27 if((LIST)==NULL){ \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
28 (ITEM)->PREV=(ITEM); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
29 }else{ \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
30 (ITEM)->PREV=(LIST)->PREV; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
31 (LIST)->PREV=(ITEM); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
32 } \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
33 (LIST)=(ITEM);
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
34
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
35
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
36 #define LINK_ITEM_LIST LINK_ITEM
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
37
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
38
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
39 #define LINK_ITEM_BEFORE(LIST, BEFORE, ITEM, NEXT, PREV) \
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
40 (ITEM)->NEXT=(BEFORE); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
41 (ITEM)->PREV=(BEFORE)->PREV; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
42 (BEFORE)->PREV=(ITEM); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
43 if((BEFORE)==(LIST)) \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
44 (LIST)=(ITEM); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
45 else \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
46 (ITEM)->PREV->NEXT=(ITEM)
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
47
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
48
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
49 #define LINK_ITEM_AFTER(LIST, AFTER, ITEM, NEXT, PREV) \
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
50 (ITEM)->NEXT=(AFTER)->NEXT; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
51 (ITEM)->PREV=(AFTER); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
52 (AFTER)->NEXT=(ITEM); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
53 if((ITEM)->NEXT==NULL) \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
54 (LIST)->PREV=(ITEM); \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
55 else \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
56 (ITEM)->NEXT->PREV=ITEM;
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
57
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
59 #define UNLINK_ITEM(LIST, ITEM, NEXT, PREV) \
62
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
60 if((ITEM)->PREV!=NULL){ \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
61 if((ITEM)==(LIST)){ \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
62 (LIST)=(ITEM)->NEXT; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
63 if((LIST)!=NULL) \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
64 (LIST)->PREV=(ITEM)->PREV; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
65 }else if((ITEM)->NEXT==NULL){ \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
66 (ITEM)->PREV->NEXT=NULL; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
67 (LIST)->PREV=(ITEM)->PREV; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
68 }else{ \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
69 (ITEM)->PREV->NEXT=(ITEM)->NEXT; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
70 (ITEM)->NEXT->PREV=(ITEM)->PREV; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
71 } \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
72 } \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
73 (ITEM)->NEXT=NULL; \
aae5facf9fc5 trunk: changeset 1318
tuomov
parents: 58
diff changeset
74 (ITEM)->PREV=NULL;
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
75
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
76 #endif /* LIBTU_DLIST_H */

mercurial