1 /*
2 * This file generated automatically from record.xml by c_client.py.
3 * Edit at your peril.
4 */
5
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #endif
9 #include <stdlib.h>
10 #include <string.h>
11 #include <assert.h>
12 #include <stddef.h> /* for offsetof() */
13 #include "xcbext.h"
14 #include "record.h"
15
16 #define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)
17
18 xcb_extension_t xcb_record_id = { "RECORD", 0 };
19
20 void
xcb_record_context_next(xcb_record_context_iterator_t * i)21 xcb_record_context_next (xcb_record_context_iterator_t *i)
22 {
23 --i->rem;
24 ++i->data;
25 i->index += sizeof(xcb_record_context_t);
26 }
27
28 xcb_generic_iterator_t
xcb_record_context_end(xcb_record_context_iterator_t i)29 xcb_record_context_end (xcb_record_context_iterator_t i)
30 {
31 xcb_generic_iterator_t ret;
32 ret.data = i.data + i.rem;
33 ret.index = i.index + ((char *) ret.data - (char *) i.data);
34 ret.rem = 0;
35 return ret;
36 }
37
38 void
xcb_record_range_8_next(xcb_record_range_8_iterator_t * i)39 xcb_record_range_8_next (xcb_record_range_8_iterator_t *i)
40 {
41 --i->rem;
42 ++i->data;
43 i->index += sizeof(xcb_record_range_8_t);
44 }
45
46 xcb_generic_iterator_t
xcb_record_range_8_end(xcb_record_range_8_iterator_t i)47 xcb_record_range_8_end (xcb_record_range_8_iterator_t i)
48 {
49 xcb_generic_iterator_t ret;
50 ret.data = i.data + i.rem;
51 ret.index = i.index + ((char *) ret.data - (char *) i.data);
52 ret.rem = 0;
53 return ret;
54 }
55
56 void
xcb_record_range_16_next(xcb_record_range_16_iterator_t * i)57 xcb_record_range_16_next (xcb_record_range_16_iterator_t *i)
58 {
59 --i->rem;
60 ++i->data;
61 i->index += sizeof(xcb_record_range_16_t);
62 }
63
64 xcb_generic_iterator_t
xcb_record_range_16_end(xcb_record_range_16_iterator_t i)65 xcb_record_range_16_end (xcb_record_range_16_iterator_t i)
66 {
67 xcb_generic_iterator_t ret;
68 ret.data = i.data + i.rem;
69 ret.index = i.index + ((char *) ret.data - (char *) i.data);
70 ret.rem = 0;
71 return ret;
72 }
73
74 void
xcb_record_ext_range_next(xcb_record_ext_range_iterator_t * i)75 xcb_record_ext_range_next (xcb_record_ext_range_iterator_t *i)
76 {
77 --i->rem;
78 ++i->data;
79 i->index += sizeof(xcb_record_ext_range_t);
80 }
81
82 xcb_generic_iterator_t
xcb_record_ext_range_end(xcb_record_ext_range_iterator_t i)83 xcb_record_ext_range_end (xcb_record_ext_range_iterator_t i)
84 {
85 xcb_generic_iterator_t ret;
86 ret.data = i.data + i.rem;
87 ret.index = i.index + ((char *) ret.data - (char *) i.data);
88 ret.rem = 0;
89 return ret;
90 }
91
92 void
xcb_record_range_next(xcb_record_range_iterator_t * i)93 xcb_record_range_next (xcb_record_range_iterator_t *i)
94 {
95 --i->rem;
96 ++i->data;
97 i->index += sizeof(xcb_record_range_t);
98 }
99
100 xcb_generic_iterator_t
xcb_record_range_end(xcb_record_range_iterator_t i)101 xcb_record_range_end (xcb_record_range_iterator_t i)
102 {
103 xcb_generic_iterator_t ret;
104 ret.data = i.data + i.rem;
105 ret.index = i.index + ((char *) ret.data - (char *) i.data);
106 ret.rem = 0;
107 return ret;
108 }
109
110 void
xcb_record_element_header_next(xcb_record_element_header_iterator_t * i)111 xcb_record_element_header_next (xcb_record_element_header_iterator_t *i)
112 {
113 --i->rem;
114 ++i->data;
115 i->index += sizeof(xcb_record_element_header_t);
116 }
117
118 xcb_generic_iterator_t
xcb_record_element_header_end(xcb_record_element_header_iterator_t i)119 xcb_record_element_header_end (xcb_record_element_header_iterator_t i)
120 {
121 xcb_generic_iterator_t ret;
122 ret.data = i.data + i.rem;
123 ret.index = i.index + ((char *) ret.data - (char *) i.data);
124 ret.rem = 0;
125 return ret;
126 }
127
128 void
xcb_record_client_spec_next(xcb_record_client_spec_iterator_t * i)129 xcb_record_client_spec_next (xcb_record_client_spec_iterator_t *i)
130 {
131 --i->rem;
132 ++i->data;
133 i->index += sizeof(xcb_record_client_spec_t);
134 }
135
136 xcb_generic_iterator_t
xcb_record_client_spec_end(xcb_record_client_spec_iterator_t i)137 xcb_record_client_spec_end (xcb_record_client_spec_iterator_t i)
138 {
139 xcb_generic_iterator_t ret;
140 ret.data = i.data + i.rem;
141 ret.index = i.index + ((char *) ret.data - (char *) i.data);
142 ret.rem = 0;
143 return ret;
144 }
145
146 int
xcb_record_client_info_sizeof(const void * _buffer)147 xcb_record_client_info_sizeof (const void *_buffer)
148 {
149 char *xcb_tmp = (char *)_buffer;
150 const xcb_record_client_info_t *_aux = (xcb_record_client_info_t *)_buffer;
151 unsigned int xcb_buffer_len = 0;
152 unsigned int xcb_block_len = 0;
153 unsigned int xcb_pad = 0;
154 unsigned int xcb_align_to = 0;
155
156
157 xcb_block_len += sizeof(xcb_record_client_info_t);
158 xcb_tmp += xcb_block_len;
159 xcb_buffer_len += xcb_block_len;
160 xcb_block_len = 0;
161 /* ranges */
162 xcb_block_len += _aux->num_ranges * sizeof(xcb_record_range_t);
163 xcb_tmp += xcb_block_len;
164 xcb_align_to = ALIGNOF(xcb_record_range_t);
165 /* insert padding */
166 xcb_pad = -xcb_block_len & (xcb_align_to - 1);
167 xcb_buffer_len += xcb_block_len + xcb_pad;
168 if (0 != xcb_pad) {
169 xcb_tmp += xcb_pad;
170 xcb_pad = 0;
171 }
172 xcb_block_len = 0;
173
174 return xcb_buffer_len;
175 }
176
177 xcb_record_range_t *
xcb_record_client_info_ranges(const xcb_record_client_info_t * R)178 xcb_record_client_info_ranges (const xcb_record_client_info_t *R)
179 {
180 return (xcb_record_range_t *) (R + 1);
181 }
182
183 int
xcb_record_client_info_ranges_length(const xcb_record_client_info_t * R)184 xcb_record_client_info_ranges_length (const xcb_record_client_info_t *R)
185 {
186 return R->num_ranges;
187 }
188
189 xcb_record_range_iterator_t
xcb_record_client_info_ranges_iterator(const xcb_record_client_info_t * R)190 xcb_record_client_info_ranges_iterator (const xcb_record_client_info_t *R)
191 {
192 xcb_record_range_iterator_t i;
193 i.data = (xcb_record_range_t *) (R + 1);
194 i.rem = R->num_ranges;
195 i.index = (char *) i.data - (char *) R;
196 return i;
197 }
198
199 void
xcb_record_client_info_next(xcb_record_client_info_iterator_t * i)200 xcb_record_client_info_next (xcb_record_client_info_iterator_t *i)
201 {
202 xcb_record_client_info_t *R = i->data;
203 xcb_generic_iterator_t child;
204 child.data = (xcb_record_client_info_t *)(((char *)R) + xcb_record_client_info_sizeof(R));
205 i->index = (char *) child.data - (char *) i->data;
206 --i->rem;
207 i->data = (xcb_record_client_info_t *) child.data;
208 }
209
210 xcb_generic_iterator_t
xcb_record_client_info_end(xcb_record_client_info_iterator_t i)211 xcb_record_client_info_end (xcb_record_client_info_iterator_t i)
212 {
213 xcb_generic_iterator_t ret;
214 while(i.rem > 0)
215 xcb_record_client_info_next(&i);
216 ret.data = i.data;
217 ret.rem = i.rem;
218 ret.index = i.index;
219 return ret;
220 }
221
222 xcb_record_query_version_cookie_t
xcb_record_query_version(xcb_connection_t * c,uint16_t major_version,uint16_t minor_version)223 xcb_record_query_version (xcb_connection_t *c,
224 uint16_t major_version,
225 uint16_t minor_version)
226 {
227 static const xcb_protocol_request_t xcb_req = {
228 .count = 2,
229 .ext = &xcb_record_id,
230 .opcode = XCB_RECORD_QUERY_VERSION,
231 .isvoid = 0
232 };
233
234 struct iovec xcb_parts[4];
235 xcb_record_query_version_cookie_t xcb_ret;
236 xcb_record_query_version_request_t xcb_out;
237
238 xcb_out.major_version = major_version;
239 xcb_out.minor_version = minor_version;
240
241 xcb_parts[2].iov_base = (char *) &xcb_out;
242 xcb_parts[2].iov_len = sizeof(xcb_out);
243 xcb_parts[3].iov_base = 0;
244 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
245
246 xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
247 return xcb_ret;
248 }
249
250 xcb_record_query_version_cookie_t
xcb_record_query_version_unchecked(xcb_connection_t * c,uint16_t major_version,uint16_t minor_version)251 xcb_record_query_version_unchecked (xcb_connection_t *c,
252 uint16_t major_version,
253 uint16_t minor_version)
254 {
255 static const xcb_protocol_request_t xcb_req = {
256 .count = 2,
257 .ext = &xcb_record_id,
258 .opcode = XCB_RECORD_QUERY_VERSION,
259 .isvoid = 0
260 };
261
262 struct iovec xcb_parts[4];
263 xcb_record_query_version_cookie_t xcb_ret;
264 xcb_record_query_version_request_t xcb_out;
265
266 xcb_out.major_version = major_version;
267 xcb_out.minor_version = minor_version;
268
269 xcb_parts[2].iov_base = (char *) &xcb_out;
270 xcb_parts[2].iov_len = sizeof(xcb_out);
271 xcb_parts[3].iov_base = 0;
272 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
273
274 xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
275 return xcb_ret;
276 }
277
278 xcb_record_query_version_reply_t *
xcb_record_query_version_reply(xcb_connection_t * c,xcb_record_query_version_cookie_t cookie,xcb_generic_error_t ** e)279 xcb_record_query_version_reply (xcb_connection_t *c,
280 xcb_record_query_version_cookie_t cookie /**< */,
281 xcb_generic_error_t **e)
282 {
283 return (xcb_record_query_version_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
284 }
285
286 int
xcb_record_create_context_sizeof(const void * _buffer)287 xcb_record_create_context_sizeof (const void *_buffer)
288 {
289 char *xcb_tmp = (char *)_buffer;
290 const xcb_record_create_context_request_t *_aux = (xcb_record_create_context_request_t *)_buffer;
291 unsigned int xcb_buffer_len = 0;
292 unsigned int xcb_block_len = 0;
293 unsigned int xcb_pad = 0;
294 unsigned int xcb_align_to = 0;
295
296
297 xcb_block_len += sizeof(xcb_record_create_context_request_t);
298 xcb_tmp += xcb_block_len;
299 xcb_buffer_len += xcb_block_len;
300 xcb_block_len = 0;
301 /* client_specs */
302 xcb_block_len += _aux->num_client_specs * sizeof(xcb_record_client_spec_t);
303 xcb_tmp += xcb_block_len;
304 xcb_align_to = ALIGNOF(xcb_record_client_spec_t);
305 /* insert padding */
306 xcb_pad = -xcb_block_len & (xcb_align_to - 1);
307 xcb_buffer_len += xcb_block_len + xcb_pad;
308 if (0 != xcb_pad) {
309 xcb_tmp += xcb_pad;
310 xcb_pad = 0;
311 }
312 xcb_block_len = 0;
313 /* ranges */
314 xcb_block_len += _aux->num_ranges * sizeof(xcb_record_range_t);
315 xcb_tmp += xcb_block_len;
316 xcb_align_to = ALIGNOF(xcb_record_range_t);
317 /* insert padding */
318 xcb_pad = -xcb_block_len & (xcb_align_to - 1);
319 xcb_buffer_len += xcb_block_len + xcb_pad;
320 if (0 != xcb_pad) {
321 xcb_tmp += xcb_pad;
322 xcb_pad = 0;
323 }
324 xcb_block_len = 0;
325
326 return xcb_buffer_len;
327 }
328
329 xcb_void_cookie_t
xcb_record_create_context_checked(xcb_connection_t * c,xcb_record_context_t context,xcb_record_element_header_t element_header,uint32_t num_client_specs,uint32_t num_ranges,const xcb_record_client_spec_t * client_specs,const xcb_record_range_t * ranges)330 xcb_record_create_context_checked (xcb_connection_t *c,
331 xcb_record_context_t context,
332 xcb_record_element_header_t element_header,
333 uint32_t num_client_specs,
334 uint32_t num_ranges,
335 const xcb_record_client_spec_t *client_specs,
336 const xcb_record_range_t *ranges)
337 {
338 static const xcb_protocol_request_t xcb_req = {
339 .count = 6,
340 .ext = &xcb_record_id,
341 .opcode = XCB_RECORD_CREATE_CONTEXT,
342 .isvoid = 1
343 };
344
345 struct iovec xcb_parts[8];
346 xcb_void_cookie_t xcb_ret;
347 xcb_record_create_context_request_t xcb_out;
348
349 xcb_out.context = context;
350 xcb_out.element_header = element_header;
351 memset(xcb_out.pad0, 0, 3);
352 xcb_out.num_client_specs = num_client_specs;
353 xcb_out.num_ranges = num_ranges;
354
355 xcb_parts[2].iov_base = (char *) &xcb_out;
356 xcb_parts[2].iov_len = sizeof(xcb_out);
357 xcb_parts[3].iov_base = 0;
358 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
359 /* xcb_record_client_spec_t client_specs */
360 xcb_parts[4].iov_base = (char *) client_specs;
361 xcb_parts[4].iov_len = num_client_specs * sizeof(xcb_record_client_spec_t);
362 xcb_parts[5].iov_base = 0;
363 xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
364 /* xcb_record_range_t ranges */
365 xcb_parts[6].iov_base = (char *) ranges;
366 xcb_parts[6].iov_len = num_ranges * sizeof(xcb_record_range_t);
367 xcb_parts[7].iov_base = 0;
368 xcb_parts[7].iov_len = -xcb_parts[6].iov_len & 3;
369
370 xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
371 return xcb_ret;
372 }
373
374 xcb_void_cookie_t
xcb_record_create_context(xcb_connection_t * c,xcb_record_context_t context,xcb_record_element_header_t element_header,uint32_t num_client_specs,uint32_t num_ranges,const xcb_record_client_spec_t * client_specs,const xcb_record_range_t * ranges)375 xcb_record_create_context (xcb_connection_t *c,
376 xcb_record_context_t context,
377 xcb_record_element_header_t element_header,
378 uint32_t num_client_specs,
379 uint32_t num_ranges,
380 const xcb_record_client_spec_t *client_specs,
381 const xcb_record_range_t *ranges)
382 {
383 static const xcb_protocol_request_t xcb_req = {
384 .count = 6,
385 .ext = &xcb_record_id,
386 .opcode = XCB_RECORD_CREATE_CONTEXT,
387 .isvoid = 1
388 };
389
390 struct iovec xcb_parts[8];
391 xcb_void_cookie_t xcb_ret;
392 xcb_record_create_context_request_t xcb_out;
393
394 xcb_out.context = context;
395 xcb_out.element_header = element_header;
396 memset(xcb_out.pad0, 0, 3);
397 xcb_out.num_client_specs = num_client_specs;
398 xcb_out.num_ranges = num_ranges;
399
400 xcb_parts[2].iov_base = (char *) &xcb_out;
401 xcb_parts[2].iov_len = sizeof(xcb_out);
402 xcb_parts[3].iov_base = 0;
403 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
404 /* xcb_record_client_spec_t client_specs */
405 xcb_parts[4].iov_base = (char *) client_specs;
406 xcb_parts[4].iov_len = num_client_specs * sizeof(xcb_record_client_spec_t);
407 xcb_parts[5].iov_base = 0;
408 xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
409 /* xcb_record_range_t ranges */
410 xcb_parts[6].iov_base = (char *) ranges;
411 xcb_parts[6].iov_len = num_ranges * sizeof(xcb_record_range_t);
412 xcb_parts[7].iov_base = 0;
413 xcb_parts[7].iov_len = -xcb_parts[6].iov_len & 3;
414
415 xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
416 return xcb_ret;
417 }
418
419 xcb_record_client_spec_t *
xcb_record_create_context_client_specs(const xcb_record_create_context_request_t * R)420 xcb_record_create_context_client_specs (const xcb_record_create_context_request_t *R)
421 {
422 return (xcb_record_client_spec_t *) (R + 1);
423 }
424
425 int
xcb_record_create_context_client_specs_length(const xcb_record_create_context_request_t * R)426 xcb_record_create_context_client_specs_length (const xcb_record_create_context_request_t *R)
427 {
428 return R->num_client_specs;
429 }
430
431 xcb_generic_iterator_t
xcb_record_create_context_client_specs_end(const xcb_record_create_context_request_t * R)432 xcb_record_create_context_client_specs_end (const xcb_record_create_context_request_t *R)
433 {
434 xcb_generic_iterator_t i;
435 i.data = ((xcb_record_client_spec_t *) (R + 1)) + (R->num_client_specs);
436 i.rem = 0;
437 i.index = (char *) i.data - (char *) R;
438 return i;
439 }
440
441 xcb_record_range_t *
xcb_record_create_context_ranges(const xcb_record_create_context_request_t * R)442 xcb_record_create_context_ranges (const xcb_record_create_context_request_t *R)
443 {
444 xcb_generic_iterator_t prev = xcb_record_create_context_client_specs_end(R);
445 return (xcb_record_range_t *) ((char *) prev.data + XCB_TYPE_PAD(xcb_record_range_t, prev.index) + 0);
446 }
447
448 int
xcb_record_create_context_ranges_length(const xcb_record_create_context_request_t * R)449 xcb_record_create_context_ranges_length (const xcb_record_create_context_request_t *R)
450 {
451 return R->num_ranges;
452 }
453
454 xcb_record_range_iterator_t
xcb_record_create_context_ranges_iterator(const xcb_record_create_context_request_t * R)455 xcb_record_create_context_ranges_iterator (const xcb_record_create_context_request_t *R)
456 {
457 xcb_record_range_iterator_t i;
458 xcb_generic_iterator_t prev = xcb_record_create_context_client_specs_end(R);
459 i.data = (xcb_record_range_t *) ((char *) prev.data + XCB_TYPE_PAD(xcb_record_range_t, prev.index));
460 i.rem = R->num_ranges;
461 i.index = (char *) i.data - (char *) R;
462 return i;
463 }
464
465 int
xcb_record_register_clients_sizeof(const void * _buffer)466 xcb_record_register_clients_sizeof (const void *_buffer)
467 {
468 char *xcb_tmp = (char *)_buffer;
469 const xcb_record_register_clients_request_t *_aux = (xcb_record_register_clients_request_t *)_buffer;
470 unsigned int xcb_buffer_len = 0;
471 unsigned int xcb_block_len = 0;
472 unsigned int xcb_pad = 0;
473 unsigned int xcb_align_to = 0;
474
475
476 xcb_block_len += sizeof(xcb_record_register_clients_request_t);
477 xcb_tmp += xcb_block_len;
478 xcb_buffer_len += xcb_block_len;
479 xcb_block_len = 0;
480 /* client_specs */
481 xcb_block_len += _aux->num_client_specs * sizeof(xcb_record_client_spec_t);
482 xcb_tmp += xcb_block_len;
483 xcb_align_to = ALIGNOF(xcb_record_client_spec_t);
484 /* insert padding */
485 xcb_pad = -xcb_block_len & (xcb_align_to - 1);
486 xcb_buffer_len += xcb_block_len + xcb_pad;
487 if (0 != xcb_pad) {
488 xcb_tmp += xcb_pad;
489 xcb_pad = 0;
490 }
491 xcb_block_len = 0;
492 /* ranges */
493 xcb_block_len += _aux->num_ranges * sizeof(xcb_record_range_t);
494 xcb_tmp += xcb_block_len;
495 xcb_align_to = ALIGNOF(xcb_record_range_t);
496 /* insert padding */
497 xcb_pad = -xcb_block_len & (xcb_align_to - 1);
498 xcb_buffer_len += xcb_block_len + xcb_pad;
499 if (0 != xcb_pad) {
500 xcb_tmp += xcb_pad;
501 xcb_pad = 0;
502 }
503 xcb_block_len = 0;
504
505 return xcb_buffer_len;
506 }
507
508 xcb_void_cookie_t
xcb_record_register_clients_checked(xcb_connection_t * c,xcb_record_context_t context,xcb_record_element_header_t element_header,uint32_t num_client_specs,uint32_t num_ranges,const xcb_record_client_spec_t * client_specs,const xcb_record_range_t * ranges)509 xcb_record_register_clients_checked (xcb_connection_t *c,
510 xcb_record_context_t context,
511 xcb_record_element_header_t element_header,
512 uint32_t num_client_specs,
513 uint32_t num_ranges,
514 const xcb_record_client_spec_t *client_specs,
515 const xcb_record_range_t *ranges)
516 {
517 static const xcb_protocol_request_t xcb_req = {
518 .count = 6,
519 .ext = &xcb_record_id,
520 .opcode = XCB_RECORD_REGISTER_CLIENTS,
521 .isvoid = 1
522 };
523
524 struct iovec xcb_parts[8];
525 xcb_void_cookie_t xcb_ret;
526 xcb_record_register_clients_request_t xcb_out;
527
528 xcb_out.context = context;
529 xcb_out.element_header = element_header;
530 memset(xcb_out.pad0, 0, 3);
531 xcb_out.num_client_specs = num_client_specs;
532 xcb_out.num_ranges = num_ranges;
533
534 xcb_parts[2].iov_base = (char *) &xcb_out;
535 xcb_parts[2].iov_len = sizeof(xcb_out);
536 xcb_parts[3].iov_base = 0;
537 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
538 /* xcb_record_client_spec_t client_specs */
539 xcb_parts[4].iov_base = (char *) client_specs;
540 xcb_parts[4].iov_len = num_client_specs * sizeof(xcb_record_client_spec_t);
541 xcb_parts[5].iov_base = 0;
542 xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
543 /* xcb_record_range_t ranges */
544 xcb_parts[6].iov_base = (char *) ranges;
545 xcb_parts[6].iov_len = num_ranges * sizeof(xcb_record_range_t);
546 xcb_parts[7].iov_base = 0;
547 xcb_parts[7].iov_len = -xcb_parts[6].iov_len & 3;
548
549 xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
550 return xcb_ret;
551 }
552
553 xcb_void_cookie_t
xcb_record_register_clients(xcb_connection_t * c,xcb_record_context_t context,xcb_record_element_header_t element_header,uint32_t num_client_specs,uint32_t num_ranges,const xcb_record_client_spec_t * client_specs,const xcb_record_range_t * ranges)554 xcb_record_register_clients (xcb_connection_t *c,
555 xcb_record_context_t context,
556 xcb_record_element_header_t element_header,
557 uint32_t num_client_specs,
558 uint32_t num_ranges,
559 const xcb_record_client_spec_t *client_specs,
560 const xcb_record_range_t *ranges)
561 {
562 static const xcb_protocol_request_t xcb_req = {
563 .count = 6,
564 .ext = &xcb_record_id,
565 .opcode = XCB_RECORD_REGISTER_CLIENTS,
566 .isvoid = 1
567 };
568
569 struct iovec xcb_parts[8];
570 xcb_void_cookie_t xcb_ret;
571 xcb_record_register_clients_request_t xcb_out;
572
573 xcb_out.context = context;
574 xcb_out.element_header = element_header;
575 memset(xcb_out.pad0, 0, 3);
576 xcb_out.num_client_specs = num_client_specs;
577 xcb_out.num_ranges = num_ranges;
578
579 xcb_parts[2].iov_base = (char *) &xcb_out;
580 xcb_parts[2].iov_len = sizeof(xcb_out);
581 xcb_parts[3].iov_base = 0;
582 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
583 /* xcb_record_client_spec_t client_specs */
584 xcb_parts[4].iov_base = (char *) client_specs;
585 xcb_parts[4].iov_len = num_client_specs * sizeof(xcb_record_client_spec_t);
586 xcb_parts[5].iov_base = 0;
587 xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
588 /* xcb_record_range_t ranges */
589 xcb_parts[6].iov_base = (char *) ranges;
590 xcb_parts[6].iov_len = num_ranges * sizeof(xcb_record_range_t);
591 xcb_parts[7].iov_base = 0;
592 xcb_parts[7].iov_len = -xcb_parts[6].iov_len & 3;
593
594 xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
595 return xcb_ret;
596 }
597
598 xcb_record_client_spec_t *
xcb_record_register_clients_client_specs(const xcb_record_register_clients_request_t * R)599 xcb_record_register_clients_client_specs (const xcb_record_register_clients_request_t *R)
600 {
601 return (xcb_record_client_spec_t *) (R + 1);
602 }
603
604 int
xcb_record_register_clients_client_specs_length(const xcb_record_register_clients_request_t * R)605 xcb_record_register_clients_client_specs_length (const xcb_record_register_clients_request_t *R)
606 {
607 return R->num_client_specs;
608 }
609
610 xcb_generic_iterator_t
xcb_record_register_clients_client_specs_end(const xcb_record_register_clients_request_t * R)611 xcb_record_register_clients_client_specs_end (const xcb_record_register_clients_request_t *R)
612 {
613 xcb_generic_iterator_t i;
614 i.data = ((xcb_record_client_spec_t *) (R + 1)) + (R->num_client_specs);
615 i.rem = 0;
616 i.index = (char *) i.data - (char *) R;
617 return i;
618 }
619
620 xcb_record_range_t *
xcb_record_register_clients_ranges(const xcb_record_register_clients_request_t * R)621 xcb_record_register_clients_ranges (const xcb_record_register_clients_request_t *R)
622 {
623 xcb_generic_iterator_t prev = xcb_record_register_clients_client_specs_end(R);
624 return (xcb_record_range_t *) ((char *) prev.data + XCB_TYPE_PAD(xcb_record_range_t, prev.index) + 0);
625 }
626
627 int
xcb_record_register_clients_ranges_length(const xcb_record_register_clients_request_t * R)628 xcb_record_register_clients_ranges_length (const xcb_record_register_clients_request_t *R)
629 {
630 return R->num_ranges;
631 }
632
633 xcb_record_range_iterator_t
xcb_record_register_clients_ranges_iterator(const xcb_record_register_clients_request_t * R)634 xcb_record_register_clients_ranges_iterator (const xcb_record_register_clients_request_t *R)
635 {
636 xcb_record_range_iterator_t i;
637 xcb_generic_iterator_t prev = xcb_record_register_clients_client_specs_end(R);
638 i.data = (xcb_record_range_t *) ((char *) prev.data + XCB_TYPE_PAD(xcb_record_range_t, prev.index));
639 i.rem = R->num_ranges;
640 i.index = (char *) i.data - (char *) R;
641 return i;
642 }
643
644 int
xcb_record_unregister_clients_sizeof(const void * _buffer)645 xcb_record_unregister_clients_sizeof (const void *_buffer)
646 {
647 char *xcb_tmp = (char *)_buffer;
648 const xcb_record_unregister_clients_request_t *_aux = (xcb_record_unregister_clients_request_t *)_buffer;
649 unsigned int xcb_buffer_len = 0;
650 unsigned int xcb_block_len = 0;
651 unsigned int xcb_pad = 0;
652 unsigned int xcb_align_to = 0;
653
654
655 xcb_block_len += sizeof(xcb_record_unregister_clients_request_t);
656 xcb_tmp += xcb_block_len;
657 xcb_buffer_len += xcb_block_len;
658 xcb_block_len = 0;
659 /* client_specs */
660 xcb_block_len += _aux->num_client_specs * sizeof(xcb_record_client_spec_t);
661 xcb_tmp += xcb_block_len;
662 xcb_align_to = ALIGNOF(xcb_record_client_spec_t);
663 /* insert padding */
664 xcb_pad = -xcb_block_len & (xcb_align_to - 1);
665 xcb_buffer_len += xcb_block_len + xcb_pad;
666 if (0 != xcb_pad) {
667 xcb_tmp += xcb_pad;
668 xcb_pad = 0;
669 }
670 xcb_block_len = 0;
671
672 return xcb_buffer_len;
673 }
674
675 xcb_void_cookie_t
xcb_record_unregister_clients_checked(xcb_connection_t * c,xcb_record_context_t context,uint32_t num_client_specs,const xcb_record_client_spec_t * client_specs)676 xcb_record_unregister_clients_checked (xcb_connection_t *c,
677 xcb_record_context_t context,
678 uint32_t num_client_specs,
679 const xcb_record_client_spec_t *client_specs)
680 {
681 static const xcb_protocol_request_t xcb_req = {
682 .count = 4,
683 .ext = &xcb_record_id,
684 .opcode = XCB_RECORD_UNREGISTER_CLIENTS,
685 .isvoid = 1
686 };
687
688 struct iovec xcb_parts[6];
689 xcb_void_cookie_t xcb_ret;
690 xcb_record_unregister_clients_request_t xcb_out;
691
692 xcb_out.context = context;
693 xcb_out.num_client_specs = num_client_specs;
694
695 xcb_parts[2].iov_base = (char *) &xcb_out;
696 xcb_parts[2].iov_len = sizeof(xcb_out);
697 xcb_parts[3].iov_base = 0;
698 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
699 /* xcb_record_client_spec_t client_specs */
700 xcb_parts[4].iov_base = (char *) client_specs;
701 xcb_parts[4].iov_len = num_client_specs * sizeof(xcb_record_client_spec_t);
702 xcb_parts[5].iov_base = 0;
703 xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
704
705 xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
706 return xcb_ret;
707 }
708
709 xcb_void_cookie_t
xcb_record_unregister_clients(xcb_connection_t * c,xcb_record_context_t context,uint32_t num_client_specs,const xcb_record_client_spec_t * client_specs)710 xcb_record_unregister_clients (xcb_connection_t *c,
711 xcb_record_context_t context,
712 uint32_t num_client_specs,
713 const xcb_record_client_spec_t *client_specs)
714 {
715 static const xcb_protocol_request_t xcb_req = {
716 .count = 4,
717 .ext = &xcb_record_id,
718 .opcode = XCB_RECORD_UNREGISTER_CLIENTS,
719 .isvoid = 1
720 };
721
722 struct iovec xcb_parts[6];
723 xcb_void_cookie_t xcb_ret;
724 xcb_record_unregister_clients_request_t xcb_out;
725
726 xcb_out.context = context;
727 xcb_out.num_client_specs = num_client_specs;
728
729 xcb_parts[2].iov_base = (char *) &xcb_out;
730 xcb_parts[2].iov_len = sizeof(xcb_out);
731 xcb_parts[3].iov_base = 0;
732 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
733 /* xcb_record_client_spec_t client_specs */
734 xcb_parts[4].iov_base = (char *) client_specs;
735 xcb_parts[4].iov_len = num_client_specs * sizeof(xcb_record_client_spec_t);
736 xcb_parts[5].iov_base = 0;
737 xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
738
739 xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
740 return xcb_ret;
741 }
742
743 xcb_record_client_spec_t *
xcb_record_unregister_clients_client_specs(const xcb_record_unregister_clients_request_t * R)744 xcb_record_unregister_clients_client_specs (const xcb_record_unregister_clients_request_t *R)
745 {
746 return (xcb_record_client_spec_t *) (R + 1);
747 }
748
749 int
xcb_record_unregister_clients_client_specs_length(const xcb_record_unregister_clients_request_t * R)750 xcb_record_unregister_clients_client_specs_length (const xcb_record_unregister_clients_request_t *R)
751 {
752 return R->num_client_specs;
753 }
754
755 xcb_generic_iterator_t
xcb_record_unregister_clients_client_specs_end(const xcb_record_unregister_clients_request_t * R)756 xcb_record_unregister_clients_client_specs_end (const xcb_record_unregister_clients_request_t *R)
757 {
758 xcb_generic_iterator_t i;
759 i.data = ((xcb_record_client_spec_t *) (R + 1)) + (R->num_client_specs);
760 i.rem = 0;
761 i.index = (char *) i.data - (char *) R;
762 return i;
763 }
764
765 int
xcb_record_get_context_sizeof(const void * _buffer)766 xcb_record_get_context_sizeof (const void *_buffer)
767 {
768 char *xcb_tmp = (char *)_buffer;
769 const xcb_record_get_context_reply_t *_aux = (xcb_record_get_context_reply_t *)_buffer;
770 unsigned int xcb_buffer_len = 0;
771 unsigned int xcb_block_len = 0;
772 unsigned int xcb_pad = 0;
773 unsigned int xcb_align_to = 0;
774
775 unsigned int i;
776 unsigned int xcb_tmp_len;
777
778 xcb_block_len += sizeof(xcb_record_get_context_reply_t);
779 xcb_tmp += xcb_block_len;
780 xcb_buffer_len += xcb_block_len;
781 xcb_block_len = 0;
782 /* intercepted_clients */
783 for(i=0; i<_aux->num_intercepted_clients; i++) {
784 xcb_tmp_len = xcb_record_client_info_sizeof(xcb_tmp);
785 xcb_block_len += xcb_tmp_len;
786 xcb_tmp += xcb_tmp_len;
787 }
788 xcb_align_to = ALIGNOF(xcb_record_client_info_t);
789 /* insert padding */
790 xcb_pad = -xcb_block_len & (xcb_align_to - 1);
791 xcb_buffer_len += xcb_block_len + xcb_pad;
792 if (0 != xcb_pad) {
793 xcb_tmp += xcb_pad;
794 xcb_pad = 0;
795 }
796 xcb_block_len = 0;
797
798 return xcb_buffer_len;
799 }
800
801 xcb_record_get_context_cookie_t
xcb_record_get_context(xcb_connection_t * c,xcb_record_context_t context)802 xcb_record_get_context (xcb_connection_t *c,
803 xcb_record_context_t context)
804 {
805 static const xcb_protocol_request_t xcb_req = {
806 .count = 2,
807 .ext = &xcb_record_id,
808 .opcode = XCB_RECORD_GET_CONTEXT,
809 .isvoid = 0
810 };
811
812 struct iovec xcb_parts[4];
813 xcb_record_get_context_cookie_t xcb_ret;
814 xcb_record_get_context_request_t xcb_out;
815
816 xcb_out.context = context;
817
818 xcb_parts[2].iov_base = (char *) &xcb_out;
819 xcb_parts[2].iov_len = sizeof(xcb_out);
820 xcb_parts[3].iov_base = 0;
821 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
822
823 xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
824 return xcb_ret;
825 }
826
827 xcb_record_get_context_cookie_t
xcb_record_get_context_unchecked(xcb_connection_t * c,xcb_record_context_t context)828 xcb_record_get_context_unchecked (xcb_connection_t *c,
829 xcb_record_context_t context)
830 {
831 static const xcb_protocol_request_t xcb_req = {
832 .count = 2,
833 .ext = &xcb_record_id,
834 .opcode = XCB_RECORD_GET_CONTEXT,
835 .isvoid = 0
836 };
837
838 struct iovec xcb_parts[4];
839 xcb_record_get_context_cookie_t xcb_ret;
840 xcb_record_get_context_request_t xcb_out;
841
842 xcb_out.context = context;
843
844 xcb_parts[2].iov_base = (char *) &xcb_out;
845 xcb_parts[2].iov_len = sizeof(xcb_out);
846 xcb_parts[3].iov_base = 0;
847 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
848
849 xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
850 return xcb_ret;
851 }
852
853 int
xcb_record_get_context_intercepted_clients_length(const xcb_record_get_context_reply_t * R)854 xcb_record_get_context_intercepted_clients_length (const xcb_record_get_context_reply_t *R)
855 {
856 return R->num_intercepted_clients;
857 }
858
859 xcb_record_client_info_iterator_t
xcb_record_get_context_intercepted_clients_iterator(const xcb_record_get_context_reply_t * R)860 xcb_record_get_context_intercepted_clients_iterator (const xcb_record_get_context_reply_t *R)
861 {
862 xcb_record_client_info_iterator_t i;
863 i.data = (xcb_record_client_info_t *) (R + 1);
864 i.rem = R->num_intercepted_clients;
865 i.index = (char *) i.data - (char *) R;
866 return i;
867 }
868
869 xcb_record_get_context_reply_t *
xcb_record_get_context_reply(xcb_connection_t * c,xcb_record_get_context_cookie_t cookie,xcb_generic_error_t ** e)870 xcb_record_get_context_reply (xcb_connection_t *c,
871 xcb_record_get_context_cookie_t cookie /**< */,
872 xcb_generic_error_t **e)
873 {
874 return (xcb_record_get_context_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
875 }
876
877 int
xcb_record_enable_context_sizeof(const void * _buffer)878 xcb_record_enable_context_sizeof (const void *_buffer)
879 {
880 char *xcb_tmp = (char *)_buffer;
881 const xcb_record_enable_context_reply_t *_aux = (xcb_record_enable_context_reply_t *)_buffer;
882 unsigned int xcb_buffer_len = 0;
883 unsigned int xcb_block_len = 0;
884 unsigned int xcb_pad = 0;
885 unsigned int xcb_align_to = 0;
886
887
888 xcb_block_len += sizeof(xcb_record_enable_context_reply_t);
889 xcb_tmp += xcb_block_len;
890 xcb_buffer_len += xcb_block_len;
891 xcb_block_len = 0;
892 /* data */
893 xcb_block_len += (_aux->length * 4) * sizeof(uint8_t);
894 xcb_tmp += xcb_block_len;
895 xcb_align_to = ALIGNOF(uint8_t);
896 /* insert padding */
897 xcb_pad = -xcb_block_len & (xcb_align_to - 1);
898 xcb_buffer_len += xcb_block_len + xcb_pad;
899 if (0 != xcb_pad) {
900 xcb_tmp += xcb_pad;
901 xcb_pad = 0;
902 }
903 xcb_block_len = 0;
904
905 return xcb_buffer_len;
906 }
907
908 xcb_record_enable_context_cookie_t
xcb_record_enable_context(xcb_connection_t * c,xcb_record_context_t context)909 xcb_record_enable_context (xcb_connection_t *c,
910 xcb_record_context_t context)
911 {
912 static const xcb_protocol_request_t xcb_req = {
913 .count = 2,
914 .ext = &xcb_record_id,
915 .opcode = XCB_RECORD_ENABLE_CONTEXT,
916 .isvoid = 0
917 };
918
919 struct iovec xcb_parts[4];
920 xcb_record_enable_context_cookie_t xcb_ret;
921 xcb_record_enable_context_request_t xcb_out;
922
923 xcb_out.context = context;
924
925 xcb_parts[2].iov_base = (char *) &xcb_out;
926 xcb_parts[2].iov_len = sizeof(xcb_out);
927 xcb_parts[3].iov_base = 0;
928 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
929
930 xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
931 return xcb_ret;
932 }
933
934 xcb_record_enable_context_cookie_t
xcb_record_enable_context_unchecked(xcb_connection_t * c,xcb_record_context_t context)935 xcb_record_enable_context_unchecked (xcb_connection_t *c,
936 xcb_record_context_t context)
937 {
938 static const xcb_protocol_request_t xcb_req = {
939 .count = 2,
940 .ext = &xcb_record_id,
941 .opcode = XCB_RECORD_ENABLE_CONTEXT,
942 .isvoid = 0
943 };
944
945 struct iovec xcb_parts[4];
946 xcb_record_enable_context_cookie_t xcb_ret;
947 xcb_record_enable_context_request_t xcb_out;
948
949 xcb_out.context = context;
950
951 xcb_parts[2].iov_base = (char *) &xcb_out;
952 xcb_parts[2].iov_len = sizeof(xcb_out);
953 xcb_parts[3].iov_base = 0;
954 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
955
956 xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
957 return xcb_ret;
958 }
959
960 uint8_t *
xcb_record_enable_context_data(const xcb_record_enable_context_reply_t * R)961 xcb_record_enable_context_data (const xcb_record_enable_context_reply_t *R)
962 {
963 return (uint8_t *) (R + 1);
964 }
965
966 int
xcb_record_enable_context_data_length(const xcb_record_enable_context_reply_t * R)967 xcb_record_enable_context_data_length (const xcb_record_enable_context_reply_t *R)
968 {
969 return (R->length * 4);
970 }
971
972 xcb_generic_iterator_t
xcb_record_enable_context_data_end(const xcb_record_enable_context_reply_t * R)973 xcb_record_enable_context_data_end (const xcb_record_enable_context_reply_t *R)
974 {
975 xcb_generic_iterator_t i;
976 i.data = ((uint8_t *) (R + 1)) + ((R->length * 4));
977 i.rem = 0;
978 i.index = (char *) i.data - (char *) R;
979 return i;
980 }
981
982 xcb_record_enable_context_reply_t *
xcb_record_enable_context_reply(xcb_connection_t * c,xcb_record_enable_context_cookie_t cookie,xcb_generic_error_t ** e)983 xcb_record_enable_context_reply (xcb_connection_t *c,
984 xcb_record_enable_context_cookie_t cookie /**< */,
985 xcb_generic_error_t **e)
986 {
987 return (xcb_record_enable_context_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
988 }
989
990 xcb_void_cookie_t
xcb_record_disable_context_checked(xcb_connection_t * c,xcb_record_context_t context)991 xcb_record_disable_context_checked (xcb_connection_t *c,
992 xcb_record_context_t context)
993 {
994 static const xcb_protocol_request_t xcb_req = {
995 .count = 2,
996 .ext = &xcb_record_id,
997 .opcode = XCB_RECORD_DISABLE_CONTEXT,
998 .isvoid = 1
999 };
1000
1001 struct iovec xcb_parts[4];
1002 xcb_void_cookie_t xcb_ret;
1003 xcb_record_disable_context_request_t xcb_out;
1004
1005 xcb_out.context = context;
1006
1007 xcb_parts[2].iov_base = (char *) &xcb_out;
1008 xcb_parts[2].iov_len = sizeof(xcb_out);
1009 xcb_parts[3].iov_base = 0;
1010 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
1011
1012 xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
1013 return xcb_ret;
1014 }
1015
1016 xcb_void_cookie_t
xcb_record_disable_context(xcb_connection_t * c,xcb_record_context_t context)1017 xcb_record_disable_context (xcb_connection_t *c,
1018 xcb_record_context_t context)
1019 {
1020 static const xcb_protocol_request_t xcb_req = {
1021 .count = 2,
1022 .ext = &xcb_record_id,
1023 .opcode = XCB_RECORD_DISABLE_CONTEXT,
1024 .isvoid = 1
1025 };
1026
1027 struct iovec xcb_parts[4];
1028 xcb_void_cookie_t xcb_ret;
1029 xcb_record_disable_context_request_t xcb_out;
1030
1031 xcb_out.context = context;
1032
1033 xcb_parts[2].iov_base = (char *) &xcb_out;
1034 xcb_parts[2].iov_len = sizeof(xcb_out);
1035 xcb_parts[3].iov_base = 0;
1036 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
1037
1038 xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
1039 return xcb_ret;
1040 }
1041
1042 xcb_void_cookie_t
xcb_record_free_context_checked(xcb_connection_t * c,xcb_record_context_t context)1043 xcb_record_free_context_checked (xcb_connection_t *c,
1044 xcb_record_context_t context)
1045 {
1046 static const xcb_protocol_request_t xcb_req = {
1047 .count = 2,
1048 .ext = &xcb_record_id,
1049 .opcode = XCB_RECORD_FREE_CONTEXT,
1050 .isvoid = 1
1051 };
1052
1053 struct iovec xcb_parts[4];
1054 xcb_void_cookie_t xcb_ret;
1055 xcb_record_free_context_request_t xcb_out;
1056
1057 xcb_out.context = context;
1058
1059 xcb_parts[2].iov_base = (char *) &xcb_out;
1060 xcb_parts[2].iov_len = sizeof(xcb_out);
1061 xcb_parts[3].iov_base = 0;
1062 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
1063
1064 xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
1065 return xcb_ret;
1066 }
1067
1068 xcb_void_cookie_t
xcb_record_free_context(xcb_connection_t * c,xcb_record_context_t context)1069 xcb_record_free_context (xcb_connection_t *c,
1070 xcb_record_context_t context)
1071 {
1072 static const xcb_protocol_request_t xcb_req = {
1073 .count = 2,
1074 .ext = &xcb_record_id,
1075 .opcode = XCB_RECORD_FREE_CONTEXT,
1076 .isvoid = 1
1077 };
1078
1079 struct iovec xcb_parts[4];
1080 xcb_void_cookie_t xcb_ret;
1081 xcb_record_free_context_request_t xcb_out;
1082
1083 xcb_out.context = context;
1084
1085 xcb_parts[2].iov_base = (char *) &xcb_out;
1086 xcb_parts[2].iov_len = sizeof(xcb_out);
1087 xcb_parts[3].iov_base = 0;
1088 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
1089
1090 xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
1091 return xcb_ret;
1092 }
1093
1094