00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _DLINKLIST_H
00025 #define _DLINKLIST_H
00026
00027
00028
00029 #define DLIST_ADD(list, p) \
00030 do { \
00031 if (!(list)) { \
00032 (list) = (p); \
00033 (p)->next = (p)->prev = NULL; \
00034 } else { \
00035 (list)->prev = (p); \
00036 (p)->next = (list); \
00037 (p)->prev = NULL; \
00038 (list) = (p); \
00039 }\
00040 } while (0)
00041
00042
00043 #define DLIST_REMOVE(list, p) \
00044 do { \
00045 if ((p) == (list)) { \
00046 (list) = (p)->next; \
00047 if (list) (list)->prev = NULL; \
00048 } else { \
00049 if ((p)->prev) (p)->prev->next = (p)->next; \
00050 if ((p)->next) (p)->next->prev = (p)->prev; \
00051 } \
00052 if ((p) != (list)) (p)->next = (p)->prev = NULL; \
00053 } while (0)
00054
00055
00056 #define DLIST_PROMOTE(list, p) \
00057 do { \
00058 DLIST_REMOVE(list, p); \
00059 DLIST_ADD(list, p); \
00060 } while (0)
00061
00062
00063 #define DLIST_ADD_END(list, p, type) \
00064 do { \
00065 if (!(list)) { \
00066 (list) = (p); \
00067 (p)->next = (p)->prev = NULL; \
00068 } else { \
00069 type tmp; \
00070 for (tmp = (list); tmp->next; tmp = tmp->next) ; \
00071 tmp->next = (p); \
00072 (p)->next = NULL; \
00073 (p)->prev = tmp; \
00074 } \
00075 } while (0)
00076
00077
00078
00079 #define DLIST_ADD_AFTER(list, p, el) \
00080 do { \
00081 if (!(list) || !(el)) { \
00082 DLIST_ADD(list, p); \
00083 } else { \
00084 p->prev = el; \
00085 p->next = el->next; \
00086 el->next = p; \
00087 if (p->next) p->next->prev = p; \
00088 }\
00089 } while (0)
00090
00091
00092 #define DLIST_DEMOTE(list, p, tmp) \
00093 do { \
00094 DLIST_REMOVE(list, p); \
00095 DLIST_ADD_END(list, p, tmp); \
00096 } while (0)
00097
00098
00099
00100 #define DLIST_CONCATENATE(list1, list2, type) \
00101 do { \
00102 if (!(list1)) { \
00103 (list1) = (list2); \
00104 } else { \
00105 type tmp; \
00106 for (tmp = (list1); tmp->next; tmp = tmp->next) ; \
00107 tmp->next = (list2); \
00108 if (list2) { \
00109 (list2)->prev = tmp; \
00110 } \
00111 } \
00112 } while (0)
00113
00114 #endif
00115
00116 const char **ev_str_list_add(const char **list, const char *s);
00117 int ev_set_blocking(int fd, bool set);
00118 size_t ev_str_list_length(const char **list);
00119
00120
00121
00122 #ifndef TALLOC_FREE
00123 #define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
00124 #endif