1 /*
2  * Copyright (C) 2013 James Miller <james@aatch.net>
3  * Copyright (c) 2016
4  *         Remi Thebault <remi.thebault@gmail.com>
5  *         Thomas Bracht Laumann Jespersen <laumann.thomas@gmail.com>
6  *
7  * Permission is hereby granted, free of charge, to any
8  * person obtaining a copy of this software and associated
9  * documentation files (the "Software"), to deal in the
10  * Software without restriction, including without
11  * limitation the rights to use, copy, modify, merge,
12  * publish, distribute, sublicense, and/or sell copies of
13  * the Software, and to permit persons to whom the Software
14  * is furnished to do so, subject to the following
15  * conditions:
16  *
17  * The above copyright notice and this permission notice
18  * shall be included in all copies or substantial portions
19  * of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
22  * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
23  * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24  * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
25  * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
26  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
testbuftestbuf28  * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  */
31 
32 
33 use libc::{c_int, c_uint, c_void};
34 use ffi::base::*;
35 use ffi::xproto;
36 
ebacktestbuf37 
38 
39 #[repr(C)]
40 pub struct xcb_extension_t {
41     name:      *const c_char,
42     global_id: c_int
43 }
44 
45 #[repr(C)]
46 pub struct xcb_protocol_request_t {
47     count:  usize,
48     ext:    *mut xcb_extension_t,
49     opcode: u8,
50     isvoid: u8
51 }
52 
53 
54 #[repr(C)]
55 pub enum xcb_send_request_flags_t {
56     XCB_REQUEST_CHECKED       = 0x01,
57     XCB_REQUEST_RAW           = 0x02,
58     XCB_REQUEST_DISCARD_REPLY = 0x04,
59     XCB_REQUEST_REPLY_FDS     = 0x08
60 }
61 
62 #[link(name="xcb")]
63 extern {
64 
65     pub fn xcb_send_request(c: *mut xcb_connection_t,
66                             flags: c_int,
67                             vector: *mut iovec,
68                             request: *const xcb_protocol_request_t)
69             -> c_uint;
70 
71     pub fn xcb_send_request64(c: *mut xcb_connection_t,
72                               flags: c_int,
73                               vector: *mut iovec,
74                               request: *const xcb_protocol_request_t)
75             -> u64;
76 
77     pub fn xcb_send_fd(c: *mut xcb_connection_t,
78                        fd: c_int);
79 
80     pub fn xcb_take_socket(c: *mut xcb_connection_t,
81                            return_socket: extern fn(closure: *mut c_void),
82                            closure: *mut c_void,
83                            flags: c_int,
84                            sent: *mut u64)
85             -> c_int;
86 
87     pub fn xcb_writev(c: *mut xcb_connection_t,
88                       vector: *mut iovec,
89                       count: c_int,
90                       requests: u64)
91             -> c_int;
92 
93     pub fn xcb_wait_for_reply(c: *mut xcb_connection_t,
94                               request: c_uint,
95                               e: *mut *mut xcb_generic_error_t)
96             -> *mut c_void;
97 
98     pub fn xcb_wait_for_reply64(c: *mut xcb_connection_t,
99                                 request: u64,
100                                 e: *mut *mut xcb_generic_error_t)
101             -> *mut c_void;
102 
103     pub fn xcb_poll_for_reply(c: *mut xcb_connection_t,
104                               request: c_uint,
105                               reply: *mut *mut c_void,
106                               error: *mut *mut xcb_generic_error_t)
107             -> c_int;
108 
109     pub fn xcb_poll_for_reply64(c: *mut xcb_connection_t,
110                                 request: u64,
111                                 reply: *mut *mut c_void,
112                                 error: *mut *mut xcb_generic_error_t)
113             -> c_int;
114 
115     pub fn xcb_get_reply_fds(c: *mut xcb_connection_t,
116                              reply: *mut c_void,
117                              replylen: usize)
118             -> *mut c_int;
119 
120     pub fn xcb_popcount(mask: u32) -> c_int;
121 
122     pub fn xcb_sumof(list: *mut u8, len: c_int) -> c_int;
123 
124 }
125 
126