TB_SETBUTTONSIZE messages must be taken into account even after
[wine/dcerpc.git] / dlls / dplayx / dplayx_queue.h
blob0ef9b46ee7ed5ea3b0ec3a2cf0547c7cedfbb044
1 /* A queue definition based on sys/queue.h TAILQ definitions
2 *
3 * Blame any implementation mistakes on Peter Hunnisett
4 * <hunnise@nortelnetworks.com>
5 */
7 #ifndef __WINE_DPLAYX_QUEUE_H
8 #define __WINE_DPLAYX_QUEUE_H
10 #include "winbase.h"
12 #define DPQ_INSERT(a,b,c) DPQ_INSERT_IN_TAIL(a,b,c)
15 * Tail queue definitions.
17 #define DPQ_HEAD(type) \
18 struct { \
19 struct type *lpQHFirst; /* first element */ \
20 struct type **lpQHLast; /* addr of last next element */ \
23 #define DPQ_ENTRY(type) \
24 struct { \
25 struct type *lpQNext; /* next element */ \
26 struct type **lpQPrev; /* address of previous next element */ \
30 * Tail queue functions.
32 #define DPQ_INIT(head) \
33 do{ \
34 (head).lpQHFirst = NULL; \
35 (head).lpQHLast = &(head).lpQHFirst; \
36 } while(0)
38 /* Front of the queue */
39 #define DPQ_FIRST( head ) ( (head).lpQHFirst )
41 /* Check if the queue has any elements */
42 #define DPQ_IS_EMPTY( head ) ( DPQ_FIRST(head) == NULL )
44 /* Next entry -- FIXME: Convert everything over to this macro ... */
45 #define DPQ_NEXT( elem ) (elem).lpQNext
47 #define DPQ_IS_ENDOFLIST( elem ) \
48 ( DPQ_NEXT(elem) == NULL )
50 /* Insert element at end of queue */
51 #define DPQ_INSERT_IN_TAIL(head, elm, field) \
52 do { \
53 (elm)->field.lpQNext = NULL; \
54 (elm)->field.lpQPrev = (head).lpQHLast; \
55 *(head).lpQHLast = (elm); \
56 (head).lpQHLast = &(elm)->field.lpQNext; \
57 } while(0)
59 /* Remove element from the queue */
60 #define DPQ_REMOVE(head, elm, field) \
61 do { \
62 if (((elm)->field.lpQNext) != NULL) \
63 (elm)->field.lpQNext->field.lpQPrev = \
64 (elm)->field.lpQPrev; \
65 else \
66 (head).lpQHLast = (elm)->field.lpQPrev; \
67 *(elm)->field.lpQPrev = (elm)->field.lpQNext; \
68 } while(0)
70 /* head - pointer to DPQ_HEAD struct
71 * elm - how to find the next element
72 * field - to be concatenated to rc to compare with fieldToCompare
73 * fieldToCompare - The value that we're comparing against
74 * fieldCompareOperator - The logical operator to compare field and
75 * fieldToCompare.
76 * rc - Variable to put the return code. Same type as (head).lpQHFirst
78 #define DPQ_FIND_ENTRY( head, elm, field, fieldCompareOperator, fieldToCompare, rc )\
79 do { \
80 (rc) = DPQ_FIRST(head); /* NULL head? */ \
82 while( rc ) \
83 { \
84 /* What we're searching for? */ \
85 if( (rc)->field fieldCompareOperator (fieldToCompare) ) \
86 { \
87 break; /* rc == correct element */ \
88 } \
90 /* End of list check */ \
91 if( ( (rc) = (rc)->elm.lpQNext ) == (head).lpQHFirst ) \
92 { \
93 rc = NULL; \
94 break; \
95 } \
96 } \
97 } while(0)
99 /* head - pointer to DPQ_HEAD struct
100 * elm - how to find the next element
101 * field - to be concatenated to rc to compare with fieldToCompare
102 * fieldToCompare - The value that we're comparing against
103 * compare_cb - Callback to invoke to determine if comparision should continue.
104 * Callback must be defined with DPQ_DECL_COMPARECB.
105 * rc - Variable to put the return code. Same type as (head).lpQHFirst
107 #define DPQ_FIND_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc )\
108 do { \
109 (rc) = DPQ_FIRST(head); /* NULL head? */ \
111 while( rc ) \
113 /* What we're searching for? */ \
114 if( compare_cb( &((rc)->field), &(fieldToCompare) ) ) \
116 break; /* no more */ \
119 /* End of list check */ \
120 if( ( (rc) = (rc)->elm.lpQNext ) == (head).lpQHFirst ) \
122 rc = NULL; \
123 break; \
126 } while(0)
128 /* How to define the method to be passed to DPQ_DELETEQ */
129 #define DPQ_DECL_COMPARECB( name, type ) BOOL name( const type* elem1, const type* elem2 )
132 /* head - pointer to DPQ_HEAD struct
133 * elm - how to find the next element
134 * field - to be concatenated to rc to compare with fieldToEqual
135 * fieldToCompare - The value that we're comparing against
136 * fieldCompareOperator - The logical operator to compare field and
137 * fieldToCompare.
138 * rc - Variable to put the return code. Same type as (head).lpQHFirst
140 #define DPQ_REMOVE_ENTRY( head, elm, field, fieldCompareOperator, fieldToCompare, rc )\
141 do { \
142 DPQ_FIND_ENTRY( head, elm, field, fieldCompareOperator, fieldToCompare, rc );\
144 /* Was the element found? */ \
145 if( rc ) \
147 DPQ_REMOVE( head, rc, elm ); \
149 } while(0)
151 /* head - pointer to DPQ_HEAD struct
152 * elm - how to find the next element
153 * field - to be concatenated to rc to compare with fieldToCompare
154 * fieldToCompare - The value that we're comparing against
155 * compare_cb - Callback to invoke to determine if comparision should continue.
156 * Callback must be defined with DPQ_DECL_COMPARECB.
157 * rc - Variable to put the return code. Same type as (head).lpQHFirst
159 #define DPQ_REMOVE_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc )\
160 do { \
161 DPQ_FIND_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc );\
163 /* Was the element found? */ \
164 if( rc ) \
166 DPQ_REMOVE( head, rc, elm ); \
168 } while(0)
171 /* Delete the entire queue
172 * head - pointer to the head of the queue
173 * field - field to access the next elements of the queue
174 * type - type of the pointer to the element element
175 * df - a delete function to be called. Declared with DPQ_DECL_DELETECB.
177 #define DPQ_DELETEQ( head, field, type, df ) \
178 do \
180 while( !DPQ_IS_EMPTY(head) ) \
182 type holder = DPQ_FIRST(head); \
183 DPQ_REMOVE( head, holder, field ); \
184 df( holder ); \
186 } while(0)
188 /* How to define the method to be passed to DPQ_DELETEQ */
189 #define DPQ_DECL_DELETECB( name, type ) void name( type elem )
191 /* Prototype of a method which just performs a HeapFree on the elem */
192 DPQ_DECL_DELETECB( cbDeleteElemFromHeap, LPVOID );
194 #endif /* __WINE_DPLAYX_QUEUE_H */