1/*
2 * This file generated automatically from shm.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 "shm.h"
15
16#define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)
17#include "xproto.h"
18
19xcb_extension_t xcb_shm_id = { "MIT-SHM", 0 };
20
21void
22xcb_shm_seg_next (xcb_shm_seg_iterator_t *i)
23{
24    --i->rem;
25    ++i->data;
26    i->index += sizeof(xcb_shm_seg_t);
27}
28
29xcb_generic_iterator_t
30xcb_shm_seg_end (xcb_shm_seg_iterator_t i)
31{
32    xcb_generic_iterator_t ret;
33    ret.data = i.data + i.rem;
34    ret.index = i.index + ((char *) ret.data - (char *) i.data);
35    ret.rem = 0;
36    return ret;
37}
38
39xcb_shm_query_version_cookie_t
40xcb_shm_query_version (xcb_connection_t *c)
41{
42    static const xcb_protocol_request_t xcb_req = {
43        .count = 2,
44        .ext = &xcb_shm_id,
45        .opcode = XCB_SHM_QUERY_VERSION,
46        .isvoid = 0
47    };
48
49    struct iovec xcb_parts[4];
50    xcb_shm_query_version_cookie_t xcb_ret;
51    xcb_shm_query_version_request_t xcb_out;
52
53
54    xcb_parts[2].iov_base = (char *) &xcb_out;
55    xcb_parts[2].iov_len = sizeof(xcb_out);
56    xcb_parts[3].iov_base = 0;
57    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
58
59    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
60    return xcb_ret;
61}
62
63xcb_shm_query_version_cookie_t
64xcb_shm_query_version_unchecked (xcb_connection_t *c)
65{
66    static const xcb_protocol_request_t xcb_req = {
67        .count = 2,
68        .ext = &xcb_shm_id,
69        .opcode = XCB_SHM_QUERY_VERSION,
70        .isvoid = 0
71    };
72
73    struct iovec xcb_parts[4];
74    xcb_shm_query_version_cookie_t xcb_ret;
75    xcb_shm_query_version_request_t xcb_out;
76
77
78    xcb_parts[2].iov_base = (char *) &xcb_out;
79    xcb_parts[2].iov_len = sizeof(xcb_out);
80    xcb_parts[3].iov_base = 0;
81    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
82
83    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
84    return xcb_ret;
85}
86
87xcb_shm_query_version_reply_t *
88xcb_shm_query_version_reply (xcb_connection_t                *c,
89                             xcb_shm_query_version_cookie_t   cookie  /**< */,
90                             xcb_generic_error_t            **e)
91{
92    return (xcb_shm_query_version_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
93}
94
95xcb_void_cookie_t
96xcb_shm_attach_checked (xcb_connection_t *c,
97                        xcb_shm_seg_t     shmseg,
98                        uint32_t          shmid,
99                        uint8_t           read_only)
100{
101    static const xcb_protocol_request_t xcb_req = {
102        .count = 2,
103        .ext = &xcb_shm_id,
104        .opcode = XCB_SHM_ATTACH,
105        .isvoid = 1
106    };
107
108    struct iovec xcb_parts[4];
109    xcb_void_cookie_t xcb_ret;
110    xcb_shm_attach_request_t xcb_out;
111
112    xcb_out.shmseg = shmseg;
113    xcb_out.shmid = shmid;
114    xcb_out.read_only = read_only;
115    memset(xcb_out.pad0, 0, 3);
116
117    xcb_parts[2].iov_base = (char *) &xcb_out;
118    xcb_parts[2].iov_len = sizeof(xcb_out);
119    xcb_parts[3].iov_base = 0;
120    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
121
122    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
123    return xcb_ret;
124}
125
126xcb_void_cookie_t
127xcb_shm_attach (xcb_connection_t *c,
128                xcb_shm_seg_t     shmseg,
129                uint32_t          shmid,
130                uint8_t           read_only)
131{
132    static const xcb_protocol_request_t xcb_req = {
133        .count = 2,
134        .ext = &xcb_shm_id,
135        .opcode = XCB_SHM_ATTACH,
136        .isvoid = 1
137    };
138
139    struct iovec xcb_parts[4];
140    xcb_void_cookie_t xcb_ret;
141    xcb_shm_attach_request_t xcb_out;
142
143    xcb_out.shmseg = shmseg;
144    xcb_out.shmid = shmid;
145    xcb_out.read_only = read_only;
146    memset(xcb_out.pad0, 0, 3);
147
148    xcb_parts[2].iov_base = (char *) &xcb_out;
149    xcb_parts[2].iov_len = sizeof(xcb_out);
150    xcb_parts[3].iov_base = 0;
151    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
152
153    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
154    return xcb_ret;
155}
156
157xcb_void_cookie_t
158xcb_shm_detach_checked (xcb_connection_t *c,
159                        xcb_shm_seg_t     shmseg)
160{
161    static const xcb_protocol_request_t xcb_req = {
162        .count = 2,
163        .ext = &xcb_shm_id,
164        .opcode = XCB_SHM_DETACH,
165        .isvoid = 1
166    };
167
168    struct iovec xcb_parts[4];
169    xcb_void_cookie_t xcb_ret;
170    xcb_shm_detach_request_t xcb_out;
171
172    xcb_out.shmseg = shmseg;
173
174    xcb_parts[2].iov_base = (char *) &xcb_out;
175    xcb_parts[2].iov_len = sizeof(xcb_out);
176    xcb_parts[3].iov_base = 0;
177    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
178
179    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
180    return xcb_ret;
181}
182
183xcb_void_cookie_t
184xcb_shm_detach (xcb_connection_t *c,
185                xcb_shm_seg_t     shmseg)
186{
187    static const xcb_protocol_request_t xcb_req = {
188        .count = 2,
189        .ext = &xcb_shm_id,
190        .opcode = XCB_SHM_DETACH,
191        .isvoid = 1
192    };
193
194    struct iovec xcb_parts[4];
195    xcb_void_cookie_t xcb_ret;
196    xcb_shm_detach_request_t xcb_out;
197
198    xcb_out.shmseg = shmseg;
199
200    xcb_parts[2].iov_base = (char *) &xcb_out;
201    xcb_parts[2].iov_len = sizeof(xcb_out);
202    xcb_parts[3].iov_base = 0;
203    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
204
205    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
206    return xcb_ret;
207}
208
209xcb_void_cookie_t
210xcb_shm_put_image_checked (xcb_connection_t *c,
211                           xcb_drawable_t    drawable,
212                           xcb_gcontext_t    gc,
213                           uint16_t          total_width,
214                           uint16_t          total_height,
215                           uint16_t          src_x,
216                           uint16_t          src_y,
217                           uint16_t          src_width,
218                           uint16_t          src_height,
219                           int16_t           dst_x,
220                           int16_t           dst_y,
221                           uint8_t           depth,
222                           uint8_t           format,
223                           uint8_t           send_event,
224                           xcb_shm_seg_t     shmseg,
225                           uint32_t          offset)
226{
227    static const xcb_protocol_request_t xcb_req = {
228        .count = 2,
229        .ext = &xcb_shm_id,
230        .opcode = XCB_SHM_PUT_IMAGE,
231        .isvoid = 1
232    };
233
234    struct iovec xcb_parts[4];
235    xcb_void_cookie_t xcb_ret;
236    xcb_shm_put_image_request_t xcb_out;
237
238    xcb_out.drawable = drawable;
239    xcb_out.gc = gc;
240    xcb_out.total_width = total_width;
241    xcb_out.total_height = total_height;
242    xcb_out.src_x = src_x;
243    xcb_out.src_y = src_y;
244    xcb_out.src_width = src_width;
245    xcb_out.src_height = src_height;
246    xcb_out.dst_x = dst_x;
247    xcb_out.dst_y = dst_y;
248    xcb_out.depth = depth;
249    xcb_out.format = format;
250    xcb_out.send_event = send_event;
251    xcb_out.pad0 = 0;
252    xcb_out.shmseg = shmseg;
253    xcb_out.offset = offset;
254
255    xcb_parts[2].iov_base = (char *) &xcb_out;
256    xcb_parts[2].iov_len = sizeof(xcb_out);
257    xcb_parts[3].iov_base = 0;
258    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
259
260    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
261    return xcb_ret;
262}
263
264xcb_void_cookie_t
265xcb_shm_put_image (xcb_connection_t *c,
266                   xcb_drawable_t    drawable,
267                   xcb_gcontext_t    gc,
268                   uint16_t          total_width,
269                   uint16_t          total_height,
270                   uint16_t          src_x,
271                   uint16_t          src_y,
272                   uint16_t          src_width,
273                   uint16_t          src_height,
274                   int16_t           dst_x,
275                   int16_t           dst_y,
276                   uint8_t           depth,
277                   uint8_t           format,
278                   uint8_t           send_event,
279                   xcb_shm_seg_t     shmseg,
280                   uint32_t          offset)
281{
282    static const xcb_protocol_request_t xcb_req = {
283        .count = 2,
284        .ext = &xcb_shm_id,
285        .opcode = XCB_SHM_PUT_IMAGE,
286        .isvoid = 1
287    };
288
289    struct iovec xcb_parts[4];
290    xcb_void_cookie_t xcb_ret;
291    xcb_shm_put_image_request_t xcb_out;
292
293    xcb_out.drawable = drawable;
294    xcb_out.gc = gc;
295    xcb_out.total_width = total_width;
296    xcb_out.total_height = total_height;
297    xcb_out.src_x = src_x;
298    xcb_out.src_y = src_y;
299    xcb_out.src_width = src_width;
300    xcb_out.src_height = src_height;
301    xcb_out.dst_x = dst_x;
302    xcb_out.dst_y = dst_y;
303    xcb_out.depth = depth;
304    xcb_out.format = format;
305    xcb_out.send_event = send_event;
306    xcb_out.pad0 = 0;
307    xcb_out.shmseg = shmseg;
308    xcb_out.offset = offset;
309
310    xcb_parts[2].iov_base = (char *) &xcb_out;
311    xcb_parts[2].iov_len = sizeof(xcb_out);
312    xcb_parts[3].iov_base = 0;
313    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
314
315    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
316    return xcb_ret;
317}
318
319xcb_shm_get_image_cookie_t
320xcb_shm_get_image (xcb_connection_t *c,
321                   xcb_drawable_t    drawable,
322                   int16_t           x,
323                   int16_t           y,
324                   uint16_t          width,
325                   uint16_t          height,
326                   uint32_t          plane_mask,
327                   uint8_t           format,
328                   xcb_shm_seg_t     shmseg,
329                   uint32_t          offset)
330{
331    static const xcb_protocol_request_t xcb_req = {
332        .count = 2,
333        .ext = &xcb_shm_id,
334        .opcode = XCB_SHM_GET_IMAGE,
335        .isvoid = 0
336    };
337
338    struct iovec xcb_parts[4];
339    xcb_shm_get_image_cookie_t xcb_ret;
340    xcb_shm_get_image_request_t xcb_out;
341
342    xcb_out.drawable = drawable;
343    xcb_out.x = x;
344    xcb_out.y = y;
345    xcb_out.width = width;
346    xcb_out.height = height;
347    xcb_out.plane_mask = plane_mask;
348    xcb_out.format = format;
349    memset(xcb_out.pad0, 0, 3);
350    xcb_out.shmseg = shmseg;
351    xcb_out.offset = offset;
352
353    xcb_parts[2].iov_base = (char *) &xcb_out;
354    xcb_parts[2].iov_len = sizeof(xcb_out);
355    xcb_parts[3].iov_base = 0;
356    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
357
358    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
359    return xcb_ret;
360}
361
362xcb_shm_get_image_cookie_t
363xcb_shm_get_image_unchecked (xcb_connection_t *c,
364                             xcb_drawable_t    drawable,
365                             int16_t           x,
366                             int16_t           y,
367                             uint16_t          width,
368                             uint16_t          height,
369                             uint32_t          plane_mask,
370                             uint8_t           format,
371                             xcb_shm_seg_t     shmseg,
372                             uint32_t          offset)
373{
374    static const xcb_protocol_request_t xcb_req = {
375        .count = 2,
376        .ext = &xcb_shm_id,
377        .opcode = XCB_SHM_GET_IMAGE,
378        .isvoid = 0
379    };
380
381    struct iovec xcb_parts[4];
382    xcb_shm_get_image_cookie_t xcb_ret;
383    xcb_shm_get_image_request_t xcb_out;
384
385    xcb_out.drawable = drawable;
386    xcb_out.x = x;
387    xcb_out.y = y;
388    xcb_out.width = width;
389    xcb_out.height = height;
390    xcb_out.plane_mask = plane_mask;
391    xcb_out.format = format;
392    memset(xcb_out.pad0, 0, 3);
393    xcb_out.shmseg = shmseg;
394    xcb_out.offset = offset;
395
396    xcb_parts[2].iov_base = (char *) &xcb_out;
397    xcb_parts[2].iov_len = sizeof(xcb_out);
398    xcb_parts[3].iov_base = 0;
399    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
400
401    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
402    return xcb_ret;
403}
404
405xcb_shm_get_image_reply_t *
406xcb_shm_get_image_reply (xcb_connection_t            *c,
407                         xcb_shm_get_image_cookie_t   cookie  /**< */,
408                         xcb_generic_error_t        **e)
409{
410    return (xcb_shm_get_image_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
411}
412
413xcb_void_cookie_t
414xcb_shm_create_pixmap_checked (xcb_connection_t *c,
415                               xcb_pixmap_t      pid,
416                               xcb_drawable_t    drawable,
417                               uint16_t          width,
418                               uint16_t          height,
419                               uint8_t           depth,
420                               xcb_shm_seg_t     shmseg,
421                               uint32_t          offset)
422{
423    static const xcb_protocol_request_t xcb_req = {
424        .count = 2,
425        .ext = &xcb_shm_id,
426        .opcode = XCB_SHM_CREATE_PIXMAP,
427        .isvoid = 1
428    };
429
430    struct iovec xcb_parts[4];
431    xcb_void_cookie_t xcb_ret;
432    xcb_shm_create_pixmap_request_t xcb_out;
433
434    xcb_out.pid = pid;
435    xcb_out.drawable = drawable;
436    xcb_out.width = width;
437    xcb_out.height = height;
438    xcb_out.depth = depth;
439    memset(xcb_out.pad0, 0, 3);
440    xcb_out.shmseg = shmseg;
441    xcb_out.offset = offset;
442
443    xcb_parts[2].iov_base = (char *) &xcb_out;
444    xcb_parts[2].iov_len = sizeof(xcb_out);
445    xcb_parts[3].iov_base = 0;
446    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
447
448    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
449    return xcb_ret;
450}
451
452xcb_void_cookie_t
453xcb_shm_create_pixmap (xcb_connection_t *c,
454                       xcb_pixmap_t      pid,
455                       xcb_drawable_t    drawable,
456                       uint16_t          width,
457                       uint16_t          height,
458                       uint8_t           depth,
459                       xcb_shm_seg_t     shmseg,
460                       uint32_t          offset)
461{
462    static const xcb_protocol_request_t xcb_req = {
463        .count = 2,
464        .ext = &xcb_shm_id,
465        .opcode = XCB_SHM_CREATE_PIXMAP,
466        .isvoid = 1
467    };
468
469    struct iovec xcb_parts[4];
470    xcb_void_cookie_t xcb_ret;
471    xcb_shm_create_pixmap_request_t xcb_out;
472
473    xcb_out.pid = pid;
474    xcb_out.drawable = drawable;
475    xcb_out.width = width;
476    xcb_out.height = height;
477    xcb_out.depth = depth;
478    memset(xcb_out.pad0, 0, 3);
479    xcb_out.shmseg = shmseg;
480    xcb_out.offset = offset;
481
482    xcb_parts[2].iov_base = (char *) &xcb_out;
483    xcb_parts[2].iov_len = sizeof(xcb_out);
484    xcb_parts[3].iov_base = 0;
485    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
486
487    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
488    return xcb_ret;
489}
490
491xcb_void_cookie_t
492xcb_shm_attach_fd_checked (xcb_connection_t *c,
493                           xcb_shm_seg_t     shmseg,
494                           int32_t           shm_fd,
495                           uint8_t           read_only)
496{
497    static const xcb_protocol_request_t xcb_req = {
498        .count = 2,
499        .ext = &xcb_shm_id,
500        .opcode = XCB_SHM_ATTACH_FD,
501        .isvoid = 1
502    };
503
504    struct iovec xcb_parts[4];
505    xcb_void_cookie_t xcb_ret;
506    xcb_shm_attach_fd_request_t xcb_out;
507    int fds[1];
508    int fd_index = 0;
509
510    xcb_out.shmseg = shmseg;
511    xcb_out.read_only = read_only;
512    memset(xcb_out.pad0, 0, 3);
513
514    xcb_parts[2].iov_base = (char *) &xcb_out;
515    xcb_parts[2].iov_len = sizeof(xcb_out);
516    xcb_parts[3].iov_base = 0;
517    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
518
519    fds[fd_index++] = shm_fd;
520    xcb_ret.sequence = xcb_send_request_with_fds(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req, 1, fds);
521    return xcb_ret;
522}
523
524xcb_void_cookie_t
525xcb_shm_attach_fd (xcb_connection_t *c,
526                   xcb_shm_seg_t     shmseg,
527                   int32_t           shm_fd,
528                   uint8_t           read_only)
529{
530    static const xcb_protocol_request_t xcb_req = {
531        .count = 2,
532        .ext = &xcb_shm_id,
533        .opcode = XCB_SHM_ATTACH_FD,
534        .isvoid = 1
535    };
536
537    struct iovec xcb_parts[4];
538    xcb_void_cookie_t xcb_ret;
539    xcb_shm_attach_fd_request_t xcb_out;
540    int fds[1];
541    int fd_index = 0;
542
543    xcb_out.shmseg = shmseg;
544    xcb_out.read_only = read_only;
545    memset(xcb_out.pad0, 0, 3);
546
547    xcb_parts[2].iov_base = (char *) &xcb_out;
548    xcb_parts[2].iov_len = sizeof(xcb_out);
549    xcb_parts[3].iov_base = 0;
550    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
551
552    fds[fd_index++] = shm_fd;
553    xcb_ret.sequence = xcb_send_request_with_fds(c, 0, xcb_parts + 2, &xcb_req, 1, fds);
554    return xcb_ret;
555}
556
557xcb_shm_create_segment_cookie_t
558xcb_shm_create_segment (xcb_connection_t *c,
559                        xcb_shm_seg_t     shmseg,
560                        uint32_t          size,
561                        uint8_t           read_only)
562{
563    static const xcb_protocol_request_t xcb_req = {
564        .count = 2,
565        .ext = &xcb_shm_id,
566        .opcode = XCB_SHM_CREATE_SEGMENT,
567        .isvoid = 0
568    };
569
570    struct iovec xcb_parts[4];
571    xcb_shm_create_segment_cookie_t xcb_ret;
572    xcb_shm_create_segment_request_t xcb_out;
573
574    xcb_out.shmseg = shmseg;
575    xcb_out.size = size;
576    xcb_out.read_only = read_only;
577    memset(xcb_out.pad0, 0, 3);
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
584    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED|XCB_REQUEST_REPLY_FDS, xcb_parts + 2, &xcb_req);
585    return xcb_ret;
586}
587
588xcb_shm_create_segment_cookie_t
589xcb_shm_create_segment_unchecked (xcb_connection_t *c,
590                                  xcb_shm_seg_t     shmseg,
591                                  uint32_t          size,
592                                  uint8_t           read_only)
593{
594    static const xcb_protocol_request_t xcb_req = {
595        .count = 2,
596        .ext = &xcb_shm_id,
597        .opcode = XCB_SHM_CREATE_SEGMENT,
598        .isvoid = 0
599    };
600
601    struct iovec xcb_parts[4];
602    xcb_shm_create_segment_cookie_t xcb_ret;
603    xcb_shm_create_segment_request_t xcb_out;
604
605    xcb_out.shmseg = shmseg;
606    xcb_out.size = size;
607    xcb_out.read_only = read_only;
608    memset(xcb_out.pad0, 0, 3);
609
610    xcb_parts[2].iov_base = (char *) &xcb_out;
611    xcb_parts[2].iov_len = sizeof(xcb_out);
612    xcb_parts[3].iov_base = 0;
613    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
614
615    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_REPLY_FDS, xcb_parts + 2, &xcb_req);
616    return xcb_ret;
617}
618
619xcb_shm_create_segment_reply_t *
620xcb_shm_create_segment_reply (xcb_connection_t                 *c,
621                              xcb_shm_create_segment_cookie_t   cookie  /**< */,
622                              xcb_generic_error_t             **e)
623{
624    return (xcb_shm_create_segment_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
625}
626
627int *
628xcb_shm_create_segment_reply_fds (xcb_connection_t                *c  /**< */,
629                                  xcb_shm_create_segment_reply_t  *reply)
630{
631    return xcb_get_reply_fds(c, reply, sizeof(xcb_shm_create_segment_reply_t) + 4 * reply->length);
632}
633
634