6 putlog(MMLOG_ERROR, "ASSERTION: %s:%d in function %s", __FILE__, __LINE__, __FUNCTION__); \
11 #define ALIGN2(x, y) ( ((x) + (y) - 1) & ~((y) - 1) )
13 #define STRIP_CRLF(x) { \
15 for (crlf_ptr = x; *crlf_ptr; crlf_ptr++) { \
16 if (*crlf_ptr == '\r' || *crlf_ptr == '\n') { \
23 #define FREE_AND_STRDUP(x, a) { \
24 if ((x) != NULL) xfree(x); \
25 (x) = ((a) != NULL) ? xstrdup(a) : NULL; \
28 #define FREE_AND_NULL(x) { \
35 #define XML_LIST_LOOP(x, y) \
36 while (x && (x = x->next) && x->item && strcasecmp(&x->item[2], &y[1]))
38 #define XML_LIST_CMP(x, y) \
39 if (x && x->item && !strcasecmp(x->item, y))
41 #define PUSH(x, y) { \
44 x = xmalloc(sizeof(STACK)); \
47 x->next = xmalloc(sizeof(STACK)); \
52 x->data = xstrdup(y); \
60 if (x->prev != NULL) { \
73 this macro will move a node from anywhere in one list to the end of another
75 #define MOVENODE(t, a, x, y) { \
77 if (a->next != NULL) \
78 a->next->prev = a->prev; \
79 if (a->prev != NULL) \
80 a->prev->next = a->next; \
81 if (a == x) x = a->next; \
88 for (tmpnode = y; tmpnode->next; tmpnode = tmpnode->next); \
89 if (tmpnode->next != NULL) { \
90 tmpnode->next->next = a; \
91 tmpnode->next->next->prev = tmpnode->next; \
94 tmpnode->next->prev = tmpnode; \
101 this macro will shift a node in a linked list up or down one
103 #define SHIFTNODE(t, x, a, d) { \
106 if (d == UP && a != (x)) { \
107 if ((x) == a->prev) (x) = a; \
108 if (a->prev->prev != NULL) a->prev->prev->next = a; \
109 tmp_node = a->prev->prev; \
110 a->prev->next = a->next; \
112 if (a->next != NULL) a->next->prev = a->prev; \
114 a->prev = tmp_node; \
115 } else if (d == DOWN && a->next != NULL) { \
116 if ((x) == a) (x) = a->next; \
117 if (a->next->next != NULL) a->next->next->prev = a; \
118 tmp_node = a->next->next; \
119 a->next->prev = a->prev; \
121 if (a->prev != NULL) a->prev->next = a->next; \
123 a->next = tmp_node; \
129 this macro moves a list node to top or bottom of list
131 #define SETNODE(t, x, a, d) { \
134 if (d == TOP && a != (x)) { \
135 if (a->next != NULL) a->next->prev = a->prev; \
136 a->prev->next = a->next; \
141 } else if (d == DOWN && a->next != NULL) { \
143 while (tmp_node->next != NULL) tmp_node = tmp_node->next; \
144 if (tmp_node != a) { \
145 a->next->prev = a->prev; \
146 if (a->prev != NULL) \
147 a->prev->next = a->next; \
150 a->prev = tmp_node; \
152 tmp_node->next = a; \
158 #endif /* MACROS_H */