8dd308aea7c05f20b5519caa5376e6d289a73403
[free-sw/xcb/libxcb] / src / xcb.h
1 /*
2  * Copyright (C) 2001-2004 Bart Massey, Jamey Sharp, and Josh Triplett.
3  * All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  * 
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  * 
22  * Except as contained in this notice, the names of the authors or their
23  * institutions shall not be used in advertising or otherwise to promote the
24  * sale, use or other dealings in this Software without prior written
25  * authorization from the authors.
26  */
27
28 #ifndef __XCB_H
29 #define __XCB_H
30 #include <X11/Xmd.h>
31 #include <X11/X.h>
32 #include <sys/uio.h>
33 #include <pthread.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
40 #define deprecated __attribute__((__deprecated__))
41 #else
42 #define deprecated
43 #endif
44
45 /* Pre-defined constants */
46
47 /* current protocol version */
48 #define X_PROTOCOL 11
49
50 /* current minor version */
51 #define X_PROTOCOL_REVISION 0
52
53 /* X_TCP_PORT + display number = server port for TCP transport */
54 #define X_TCP_PORT 6000
55
56 #define XCB_TYPE_PAD(T,I) (-(I) & (sizeof(T) > 4 ? 3 : sizeof(T) - 1))
57
58
59 /* Opaque structures */
60
61 typedef struct XCBConnection XCBConnection;
62
63
64 /* Other types */
65
66 typedef struct {
67     void *data;
68     int rem;
69     int index;
70 } XCBGenericIter;
71
72 typedef struct {
73     BYTE response_type;
74     CARD8 pad0;
75     CARD16 sequence;
76     CARD32 length;
77 } XCBGenericRep;
78
79 typedef struct {
80     BYTE response_type;
81     CARD8 pad0;
82     CARD16 sequence;
83 } XCBGenericEvent;
84
85 typedef struct {
86     BYTE response_type;
87     BYTE error_code;
88     CARD16 sequence;
89 } XCBGenericError;
90
91 typedef struct {
92     unsigned int sequence;
93 } XCBVoidCookie;
94
95
96 /* Include the generated xproto and xcb_types headers. */
97 #include "xcb_types.h"
98 #include "xproto.h"
99
100
101 /* xcb_auth.c */
102
103 typedef struct XCBAuthInfo {
104     int namelen;
105     char *name;
106     int datalen;
107     char *data;
108 } XCBAuthInfo;
109
110 int XCBGetAuthInfo(int fd, XCBAuthInfo *info) deprecated;
111
112
113 /* xcb_out.c */
114
115 int XCBFlush(XCBConnection *c);
116 CARD32 XCBGetMaximumRequestLength(XCBConnection *c);
117
118
119 /* xcb_in.c */
120
121 XCBGenericEvent *XCBWaitEvent(XCBConnection *c) deprecated;
122 XCBGenericEvent *XCBWaitForEvent(XCBConnection *c);
123 XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error);
124 unsigned int XCBGetRequestRead(XCBConnection *c);
125
126
127 /* xcb_ext.c */
128
129 typedef struct XCBExtension XCBExtension;
130
131 /* Do not free the returned XCBQueryExtensionRep - on return, it's aliased
132  * from the cache. */
133 const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension *ext);
134
135 void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext);
136
137
138 /* xcb_conn.c */
139
140 XCBConnSetupSuccessRep *XCBGetSetup(XCBConnection *c);
141 int XCBGetFileDescriptor(XCBConnection *c);
142
143 XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info);
144 void XCBDisconnect(XCBConnection *c);
145
146
147 /* xcb_util.c */
148
149 int XCBParseDisplay(const char *name, char **host, int *display, int *screen);
150 int XCBOpen(const char *host, int display) deprecated;
151 int XCBOpenTCP(const char *host, unsigned short port) deprecated;
152 int XCBOpenUnix(const char *file) deprecated;
153
154 XCBConnection *XCBConnectBasic(void) deprecated;
155 XCBConnection *XCBConnect(const char *displayname, int *screenp);
156 XCBConnection *XCBConnectToDisplayWithAuthInfo(const char *display, XCBAuthInfo *auth, int *screen);
157
158 int XCBSync(XCBConnection *c, XCBGenericError **e);
159
160
161 #ifdef __cplusplus
162 }
163 #endif
164
165 #endif