From a3bd6f4760b5b3f5f360a690920839646e2b9d06 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 23 Sep 2006 12:22:22 -0700 Subject: The Great XCB Renaming Rename API to follow a new naming convention: * XCB_CONSTANTS_UPPERCASE_WITH_UNDERSCORES * xcb_functions_lowercase_with_underscores * xcb_types_lowercase_with_underscores_and_suffix_t * expand all abbreviations like "req", "rep", and "iter" Word boundaries for the names in the protocol descriptions fall: * Wherever the protocol descriptions already have an underscore * Between a lowercase letter and a subsequent uppercase letter * Before the last uppercase letter in a string of uppercase letters followed by a lowercase letter (such as in LSBFirst between LSB and First) * Before and after a string of digits (with exceptions for sized types like xcb_char2b_t and xcb_glx_float32_t to match the stdint.h convention) Also fix up some particular naming issues: * Rename shape_op and shape_kind to drop the "shape_" prefix, since otherwise these types end up as xcb_shape_shape_{op,kind}_t. * Remove leading underscores from enums in the GLX protocol description, previously needed to ensure a word separator, but now redundant. This renaming breaks code written for the previous API naming convention. The scripts in XCB's tools directory will convert code written for the old API to use the new API; they work well enough that we used them to convert the non-program-generated code in XCB, and when run on the old program-generated code, they almost exactly reproduce the new program-generated code (modulo whitespace and bugs in the old code generator). Authors: Vincent Torri, Thomas Hunger, Josh Triplett --- src/c-client.xsl | 426 +++++++++++++++++++++++++++++++++++-------------------- src/xcb.h | 146 +++++++++---------- src/xcb_auth.c | 6 +- src/xcb_conn.c | 60 ++++---- src/xcb_ext.c | 22 +-- src/xcb_in.c | 72 +++++----- src/xcb_list.c | 2 +- src/xcb_out.c | 52 +++---- src/xcb_util.c | 28 ++-- src/xcb_xid.c | 12 +- src/xcb_xlib.c | 4 +- src/xcbext.h | 22 +-- src/xcbint.h | 42 +++--- src/xcbxlib.h | 4 +- 14 files changed, 506 insertions(+), 392 deletions(-) (limited to 'src') diff --git a/src/c-client.xsl b/src/c-client.xsl index 218e093..188e8b0 100644 --- a/src/c-client.xsl +++ b/src/c-client.xsl @@ -26,7 +26,11 @@ authorization from the authors. --> + xmlns:e="http://exslt.org/common" + xmlns:func="http://exslt.org/functions" + xmlns:str="http://exslt.org/strings" + xmlns:xcb="http://xcb.freedesktop.org" + extension-element-prefixes="func str xcb"> @@ -49,6 +53,8 @@ authorization from the authors. + + - + { "" } - - - return XCBGetExtensionData(c, &XCBId); + + + return xcb_get_extension_data(c, &_id); + + + + xcb + + + _randr + + + _screensaver + + + _xf86dri + + + _xfixes + + + _xvmc + + + _ + + + + + + + + + _ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + char + + + + + + + + + + + + + + + + + + + + + + + + + + + + _ + + + + + + @@ -107,27 +228,26 @@ authorization from the authors. - - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -149,7 +269,7 @@ authorization from the authors. - + - XCB - + @@ -205,16 +323,15 @@ authorization from the authors. context node. --> - XCB - + - Void + xcb_void - Cookie + _cookie_t @@ -222,20 +339,18 @@ authorization from the authors. - XCB - - - Checked - Unchecked + + _checked + _unchecked - + - true @@ -247,18 +362,18 @@ authorization from the authors. - + - - + + - + - + @@ -270,83 +385,83 @@ authorization from the authors. - - + + - - + + - - - + + + - - return (XCBRep *) XCBWaitForReply(c, cookie.sequence, e); + + return (_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e); - - + + - - - - - XCB ret; - ret.xid = XCBGenerateID(c); + + + + + ret; + ret.xid = xcb_generate_id(c); return ret; - + union - - + + - Event + _event_t - Error + _error_t - + - - + + - + - + - + @@ -364,21 +479,23 @@ authorization from the authors. + _t + _t - - + + - + - + @@ -397,6 +514,7 @@ authorization from the authors. + _t @@ -407,7 +525,8 @@ authorization from the authors. + _t @@ -458,6 +577,7 @@ authorization from the authors. + _t @@ -465,13 +585,13 @@ authorization from the authors. - + - + @@ -487,6 +607,7 @@ authorization from the authors. + _t @@ -497,12 +618,18 @@ authorization from the authors. - + + + + const + + _t + * @@ -517,6 +644,7 @@ authorization from the authors. + _t @@ -524,7 +652,7 @@ authorization from the authors. - + @@ -585,14 +713,14 @@ authorization from the authors. - static const XCBProtocolRequest xcb_req = { + static const xcb_protocol_request_t xcb_req = { /* count */ , /* ext */ - &XCB - - Id + & + + _id 0 , @@ -621,17 +749,24 @@ authorization from the authors. xcb_parts[].iov_base = (char *) ; xcb_parts[].iov_len = + --> + * sizeof( - + + + char + + + + + ) ; xcb_parts[].iov_base = 0; xcb_parts[].iov_len = -xcb_parts[].iov_len & 3; - xcb_ret.sequence = XCBSendRequest(c, XCB_REQUEST_CHECKED 0 @@ -660,50 +795,30 @@ authorization from the authors. - - + + - - - - - - - - - - - - - - - - - - - + select="$pass1/xcb/struct[@name=concat($ref, $kind, '_t')]" /> R + 1 - - End(Iter(R)) + + _end(__iterator(R)) - End(R) + __end(R) @@ -715,52 +830,51 @@ authorization from the authors. - + + /struct[concat(xcb:xcb-prefix(@name), '_t') + = current()/@type] + /*[self::valueparam + or self::list[.//*[not(self::value + or self::op)]]]" /> - - + + - return ( *) (); - XCBGenericIter prev = ; - return ( *) ((char *) prev.data + XCB_TYPE_PAD(, prev.index)); + -->, prev.index)); - - + + return ; - - - - Iter i; + + + + _iterator_t i; i.data = ( *) (); - XCBGenericIter prev = ; i.data = ( *) ((char *) prev.data + XCB_TYPE_PAD(()) + ( ); - XCBGenericIter child = ; - i.data = (( *) child.data) + ( @@ -810,32 +924,32 @@ authorization from the authors. - - + + - *R = i->data; - XCBGenericIter child = ; --i->rem; - i->data = ( *) child.data; + i->data = (_t *) child.data; i->index = child.index; --i->rem; ++i->data; - i->index += sizeof(); + i->index += sizeof(_t); - - - XCBGenericIter ret; + + + xcb_generic_iterator_t ret; while(i.rem > 0) - Next(&i); + _next(&i); ret.data = i.data; ret.rem = i.rem; @@ -915,7 +1029,7 @@ authorization from the authors. #define - + @@ -958,7 +1072,7 @@ authorization from the authors. typedef - + ; @@ -1159,7 +1273,7 @@ authorization from the authors. - + pad diff --git a/src/xcb.h b/src/xcb.h index 3d193e1..ed4d4b9 100644 --- a/src/xcb.h +++ b/src/xcb.h @@ -37,14 +37,14 @@ /* FIXME: these names conflict with those defined in Xmd.h. */ #ifndef XMD_H -typedef uint8_t BYTE; -typedef uint8_t BOOL; -typedef uint8_t CARD8; -typedef uint16_t CARD16; -typedef uint32_t CARD32; -typedef int8_t INT8; -typedef int16_t INT16; -typedef int32_t INT32; +typedef uint8_t uint8_t; +typedef uint8_t uint8_t; +typedef uint8_t uint8_t; +typedef uint16_t uint16_t; +typedef uint32_t uint32_t; +typedef int8_t int8_t; +typedef int16_t int16_t; +typedef int32_t int32_t; #endif /* XMD_H */ #include @@ -60,7 +60,7 @@ extern "C" { */ /** - * @defgroup XCB_Core_Api XCB Core API + * @defgroup xcb__core_api_t XCB Core API * @brief Core API of the XCB library. * * @{ @@ -86,7 +86,7 @@ extern "C" { * * A structure that contain all data that XCB needs to communicate with an X server. */ -typedef struct XCBConnection XCBConnection; /**< Opaque structure containing all data that XCB needs to communicate with an X server. */ +typedef struct xcb_connection_t xcb_connection_t; /**< Opaque structure containing all data that XCB needs to communicate with an X server. */ /* Other types */ @@ -100,7 +100,7 @@ typedef struct { void *data; /**< Data of the current iterator */ int rem; /**< remaining elements */ int index; /**< index of the current iterator */ -} XCBGenericIter; +} xcb_generic_iterator_t; /** * @brief Generic reply. @@ -108,11 +108,11 @@ typedef struct { * A generic reply structure. */ typedef struct { - BYTE response_type; /**< Type of the response */ - CARD8 pad0; /**< Padding */ - CARD16 sequence; /**< Sequence number */ - CARD32 length; /**< Length of the response */ -} XCBGenericRep; + uint8_t response_type; /**< Type of the response */ + uint8_t pad0; /**< Padding */ + uint16_t sequence; /**< Sequence number */ + uint32_t length; /**< Length of the response */ +} xcb_generic_reply_t; /** * @brief Generic event. @@ -120,12 +120,12 @@ typedef struct { * A generic event structure. */ typedef struct { - BYTE response_type; /**< Type of the response */ - CARD8 pad0; /**< Padding */ - CARD16 sequence; /**< Sequence number */ - CARD32 pad[7]; /**< Padding */ - CARD32 full_sequence; -} XCBGenericEvent; + uint8_t response_type; /**< Type of the response */ + uint8_t pad0; /**< Padding */ + uint16_t sequence; /**< Sequence number */ + uint32_t pad[7]; /**< Padding */ + uint32_t full_sequence; +} xcb_generic_event_t; /** * @brief Generic error. @@ -133,12 +133,12 @@ typedef struct { * A generic error structure. */ typedef struct { - BYTE response_type; /**< Type of the response */ - BYTE error_code; /**< Error code */ - CARD16 sequence; /**< Sequence number */ - CARD32 pad[7]; /**< Padding */ - CARD32 full_sequence; -} XCBGenericError; + uint8_t response_type; /**< Type of the response */ + uint8_t error_code; /**< Error code */ + uint16_t sequence; /**< Sequence number */ + uint32_t pad[7]; /**< Padding */ + uint32_t full_sequence; +} xcb_generic_error_t; /** * @brief Generic cookie. @@ -147,24 +147,24 @@ typedef struct { */ typedef struct { unsigned int sequence; /**< Sequence number */ -} XCBVoidCookie; +} xcb_void_cookie_t; /* Include the generated xproto header. */ #include "xproto.h" -/** XCBNone is the universal null resource or null atom parameter value for many core X requests */ -#define XCBNone 0L +/** XCB_NONE is the universal null resource or null atom parameter value for many core X requests */ +#define XCB_NONE 0L -/** XCBCopyFromParent can be used for many CreateWindow parameters */ -#define XCBCopyFromParent 0L +/** XCB_COPY_FROM_PARENT can be used for many CreateWindow parameters */ +#define XCB_COPY_FROM_PARENT 0L -/** XCBCurrentTime can be used in most requests that take an XCBTIMESTAMP */ -#define XCBCurrentTime 0L +/** XCB_CURRENT_TIME can be used in most requests that take an xcb_timestamp_t */ +#define XCB_CURRENT_TIME 0L -/** XCBNoSymbol fills in unused entries in XCBKEYSYM tables */ -#define XCBNoSymbol 0L +/** XCB_NO_SYMBOL fills in unused entries in xcb_keysym_t tables */ +#define XCB_NO_SYMBOL 0L /* xcb_auth.c */ @@ -174,12 +174,12 @@ typedef struct { * * A container for authorization information to be sent to the X server. */ -typedef struct XCBAuthInfo { +typedef struct xcb_auth_info_t { int namelen; /**< Length of the string name (as returned by strlen). */ char *name; /**< String containing the authentication protocol name, such as "MIT-MAGIC-COOKIE-1" or "XDM-AUTHORIZATION-1". */ int datalen; /**< Length of the data member. */ char *data; /**< Data interpreted in a protocol-specific manner. */ -} XCBAuthInfo; +} xcb_auth_info_t; /* xcb_out.c */ @@ -192,7 +192,7 @@ typedef struct XCBAuthInfo { * Forces any buffered output to be written to the server. Blocks * until the write is complete. */ -int XCBFlush(XCBConnection *c); +int xcb_flush(xcb_connection_t *c); /** * @brief Returns the maximum request length field from the connection @@ -210,7 +210,7 @@ int XCBFlush(XCBConnection *c); * theoretical maximum lengths roughly 256kB without BIG-REQUESTS and * 16GB with. */ -CARD32 XCBGetMaximumRequestLength(XCBConnection *c); +uint32_t xcb_get_maximum_request_length(xcb_connection_t *c); /* xcb_in.c */ @@ -224,7 +224,7 @@ CARD32 XCBGetMaximumRequestLength(XCBConnection *c); * the event of an I/O error. Blocks until either an event or error * arrive, or an I/O error occurs. */ -XCBGenericEvent *XCBWaitForEvent(XCBConnection *c); +xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c); /** * @brief Returns the next event or error from the server. @@ -241,7 +241,7 @@ XCBGenericEvent *XCBWaitForEvent(XCBConnection *c); * operation. If @p error is @c NULL, terminates the application when an * I/O error occurs. */ -XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error); +xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c, int *error); /** * @brief Return the error for a request, or NULL if none can ever arrive. @@ -249,7 +249,7 @@ XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error); * @param cookie: The request cookie. * @return The error for the request, or NULL if none can ever arrive. * - * The XCBVoidCookie cookie supplied to this function must have resulted from + * The xcb_void_cookie_t cookie supplied to this function must have resulted from * a call to XCB[RequestName]Checked(). This function will block until one of * two conditions happens. If an error is received, it will be returned. If * a reply to a subsequent request has already arrived, no error can arrive @@ -259,33 +259,33 @@ XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error); * sequence number will advance beyond that provided in cookie; this is a * convenience to avoid races in determining whether the sync is needed. */ -XCBGenericError *XCBRequestCheck(XCBConnection *c, XCBVoidCookie cookie); +xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie); /* xcb_ext.c */ /** - * @typedef typedef struct XCBExtension XCBExtension + * @typedef typedef struct xcb_extension_t xcb_extension_t */ -typedef struct XCBExtension XCBExtension; /**< Opaque structure used as key for XCBGetExtensionData. */ +typedef struct xcb_extension_t xcb_extension_t; /**< Opaque structure used as key for xcb_get_extension_data_t. */ /** * @brief Caches reply information from QueryExtension requests. * @param c: The connection. * @param ext: The extension data. - * @return A pointer to the XCBQueryExtensionRep for the extension. + * @return A pointer to the xcb_query_extension_reply_t for the extension. * * This function is the primary interface to the "extension cache", * which caches reply information from QueryExtension * requests. Invoking this function may cause a call to - * XCBQueryExtension to retrieve extension information from the + * xcb_query_extension_t to retrieve extension information from the * server, and may block until extension data is received from the * server. * * The result must not be freed. This storage is managed by the cache * itself. */ -const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension *ext); +const xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext); /** * @brief Prefetch of extension data into the extension cache @@ -294,11 +294,11 @@ const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension * * * This function allows a "prefetch" of extension data into the * extension cache. Invoking the function may cause a call to - * XCBQueryExtension, but will not block waiting for the - * reply. XCBGetExtensionData will return the prefetched data after + * xcb_query_extension_t, but will not block waiting for the + * reply. xcb_get_extension_data_t will return the prefetched data after * possibly blocking while it is retrieved. */ -void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext); +void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext); /* xcb_conn.c */ @@ -306,9 +306,9 @@ void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext); /** * @brief Access the data returned by the server. * @param c: The connection. - * @return A pointer to an XCBSetup structure. + * @return A pointer to an xcb_setup_t structure. * - * Accessor for the data returned by the server when the XCBConnection + * Accessor for the data returned by the server when the xcb_connection_t * was initialized. This data includes * - the server's required format for images, * - a list of available visuals, @@ -321,7 +321,7 @@ void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext); * * The result must not be freed. */ -const XCBSetup *XCBGetSetup(XCBConnection *c); +const xcb_setup_t *xcb_get_setup(xcb_connection_t *c); /** * @brief Access the file descriptor of the connection. @@ -329,39 +329,39 @@ const XCBSetup *XCBGetSetup(XCBConnection *c); * @return The file descriptor. * * Accessor for the file descriptor that was passed to the - * XCBConnectToFD call that returned @p c. + * xcb_connect_to_fd_t call that returned @p c. */ -int XCBGetFileDescriptor(XCBConnection *c); +int xcb_get_file_descriptor(xcb_connection_t *c); /** * @brief Test whether the connection has shut down due to a fatal error. * @param c: The connection. * @return 1 if the connection is in an error state; 0 otherwise. * - * Some errors that occur in the context of an XCBConnection + * Some errors that occur in the context of an xcb_connection_t * are unrecoverable. When such an error occurs, the * connection is shut down and further operations on the - * XCBConnection have no effect. + * xcb_connection_t have no effect. * * @todo Other functions should document the conditions in * which they shut down the connection. */ -int XCBConnectionHasError(XCBConnection *c); +int xcb_connection_has_error(xcb_connection_t *c); /** * @brief Connects to the X server. * @param fd: The file descriptor. * @param auth_info: Authentication data. - * @return A newly allocated XCBConnection structure. + * @return A newly allocated xcb_connection_t structure. * * Connects to an X server, given the open socket @p fd and the - * XCBAuthInfo @p auth_info. The file descriptor @p fd is - * bidirectionally connected to an X server. XCBGetTCPFD and - * XCBGetUnixFD return appropriate file descriptors. If the connection + * xcb_auth_info_t @p auth_info. The file descriptor @p fd is + * bidirectionally connected to an X server. xcb_get_tcpfd_t and + * xcb_get_unix_fd_t return appropriate file descriptors. If the connection * should be unauthenticated, @p auth_info must be @c - * NULL. XCBGetAuthInfo returns appropriate authentication data. + * NULL. xcb_get_auth_info_t returns appropriate authentication data. */ -XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info); +xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info); /** * @brief Closes the connection. @@ -370,7 +370,7 @@ XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info); * Closes the file descriptor and frees all memory associated with the * connection @c c. */ -void XCBDisconnect(XCBConnection *c); +void xcb_disconnect(xcb_connection_t *c); /* xcb_util.c */ @@ -392,13 +392,13 @@ void XCBDisconnect(XCBConnection *c); * can be @c NULL. If @p displayname does not contain a screen number, * it is set to @c 0. */ -int XCBParseDisplay(const char *name, char **host, int *display, int *screen); +int xcb_parse_display(const char *name, char **host, int *display, int *screen); /** * @brief Connects to the X server. * @param displayname: The name of the display. * @param screenp: A pointer to a preferred screen number. - * @return A newly allocated XCBConnection structure. + * @return A newly allocated xcb_connection_t structure. * * Connects to the X server specified by @p displayname. If @p * displayname is @c NULL, uses the value of the DISPLAY environment @@ -406,21 +406,21 @@ int XCBParseDisplay(const char *name, char **host, int *display, int *screen); * int pointed to by @p screenp (if not @c NULL) will be set to that * screen; otherwise the screen will be set to 0. */ -XCBConnection *XCBConnect(const char *displayname, int *screenp); +xcb_connection_t *xcb_connect(const char *displayname, int *screenp); /** * @brief Connects to the X server, using an authorization information. * @param displayname: The name of the display. * @param auth: The authorization information. * @param screenp: A pointer to a preferred screen number. - * @return A newly allocated XCBConnection structure. + * @return A newly allocated xcb_connection_t structure. * * Connects to the X server specified by @p displayname, using the * authorization @p auth. If a particular screen on that server is * preferred, the int pointed to by @p screenp (if not @c NULL) will * be set to that screen; otherwise @p screenp will be set to 0. */ -XCBConnection *XCBConnectToDisplayWithAuthInfo(const char *display, XCBAuthInfo *auth, int *screen); +xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb_auth_info_t *auth, int *screen); /** diff --git a/src/xcb_auth.c b/src/xcb_auth.c index 46c85fd..42a3d86 100644 --- a/src/xcb_auth.c +++ b/src/xcb_auth.c @@ -105,7 +105,7 @@ static Xauth *get_authptr(struct sockaddr *sockname, unsigned int socknamelen) addr = (char *) &si->sin_addr; addrlen = 4; if (ntohl(si->sin_addr.s_addr) != 0x7f000001) - family = XCBFamilyInternet; + family = XCB_FAMILY_INTERNET; snprintf(dispbuf, sizeof(dispbuf), "%d", ntohs(si->sin_port) - X_TCP_PORT); display = dispbuf; } @@ -158,7 +158,7 @@ static void do_append(char *buf, int *idxp, void *val, size_t valsize) { } #endif -static int compute_auth(XCBAuthInfo *info, Xauth *authptr, struct sockaddr *sockname) +static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *sockname) { if (authname_match(AUTH_MC1, authptr->name, authptr->name_length)) { info->datalen = memdup(&info->data, authptr->data, authptr->data_length); @@ -216,7 +216,7 @@ static int compute_auth(XCBAuthInfo *info, Xauth *authptr, struct sockaddr *sock return 0; /* Unknown authorization type */ } -int _xcb_get_auth_info(int fd, XCBAuthInfo *info) +int _xcb_get_auth_info(int fd, xcb_auth_info_t *info) { /* code adapted from Xlib/ConnDis.c, xtrans/Xtranssocket.c, xtrans/Xtransutils.c */ diff --git a/src/xcb_conn.c b/src/xcb_conn.c index c00eccf..9aa7cdf 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -39,10 +39,10 @@ #include "xcbint.h" typedef struct { - CARD8 status; - CARD8 pad0[5]; - CARD16 length; -} XCBSetupGeneric; + uint8_t status; + uint8_t pad0[5]; + uint16_t length; +} xcb_setup_generic_t; static const int error_connection = 1; @@ -59,10 +59,10 @@ static int set_fd_flags(const int fd) return 1; } -static int write_setup(XCBConnection *c, XCBAuthInfo *auth_info) +static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info) { static const char pad[3]; - XCBSetupRequest out; + xcb_setup_request_t out; struct iovec parts[6]; int count = 0; int endian = 0x01020304; @@ -79,9 +79,9 @@ static int write_setup(XCBConnection *c, XCBAuthInfo *auth_info) out.protocol_minor_version = X_PROTOCOL_REVISION; out.authorization_protocol_name_len = 0; out.authorization_protocol_data_len = 0; - parts[count].iov_len = sizeof(XCBSetupRequest); + parts[count].iov_len = sizeof(xcb_setup_request_t); parts[count++].iov_base = &out; - parts[count].iov_len = XCB_PAD(sizeof(XCBSetupRequest)); + parts[count].iov_len = XCB_PAD(sizeof(xcb_setup_request_t)); parts[count++].iov_base = (char *) pad; if(auth_info) @@ -106,24 +106,24 @@ static int write_setup(XCBConnection *c, XCBAuthInfo *auth_info) return ret; } -static int read_setup(XCBConnection *c) +static int read_setup(xcb_connection_t *c) { /* Read the server response */ - c->setup = malloc(sizeof(XCBSetupGeneric)); + c->setup = malloc(sizeof(xcb_setup_generic_t)); if(!c->setup) return 0; - if(_xcb_in_read_block(c, c->setup, sizeof(XCBSetupGeneric)) != sizeof(XCBSetupGeneric)) + if(_xcb_in_read_block(c, c->setup, sizeof(xcb_setup_generic_t)) != sizeof(xcb_setup_generic_t)) return 0; { - void *tmp = realloc(c->setup, c->setup->length * 4 + sizeof(XCBSetupGeneric)); + void *tmp = realloc(c->setup, c->setup->length * 4 + sizeof(xcb_setup_generic_t)); if(!tmp) return 0; c->setup = tmp; } - if(_xcb_in_read_block(c, (char *) c->setup + sizeof(XCBSetupGeneric), c->setup->length * 4) <= 0) + if(_xcb_in_read_block(c, (char *) c->setup + sizeof(xcb_setup_generic_t), c->setup->length * 4) <= 0) return 0; /* 0 = failed, 2 = authenticate, 1 = success */ @@ -131,15 +131,15 @@ static int read_setup(XCBConnection *c) { case 0: /* failed */ { - XCBSetupFailed *setup = (XCBSetupFailed *) c->setup; - write(STDERR_FILENO, XCBSetupFailedReason(setup), XCBSetupFailedReasonLength(setup)); + xcb_setup_failed_t *setup = (xcb_setup_failed_t *) c->setup; + write(STDERR_FILENO, xcb_setup_failed_reason(setup), xcb_setup_failed_reason_length(setup)); return 0; } case 2: /* authenticate */ { - XCBSetupAuthenticate *setup = (XCBSetupAuthenticate *) c->setup; - write(STDERR_FILENO, XCBSetupAuthenticateReason(setup), XCBSetupAuthenticateReasonLength(setup)); + xcb_setup_authenticate_t *setup = (xcb_setup_authenticate_t *) c->setup; + write(STDERR_FILENO, xcb_setup_authenticate_reason(setup), xcb_setup_authenticate_reason_length(setup)); return 0; } } @@ -148,7 +148,7 @@ static int read_setup(XCBConnection *c) } /* precondition: there must be something for us to write. */ -static int write_vec(XCBConnection *c, struct iovec **vector, int *count) +static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count) { int n; assert(!c->out.queue_len); @@ -180,7 +180,7 @@ static int write_vec(XCBConnection *c, struct iovec **vector, int *count) /* Public interface */ -const XCBSetup *XCBGetSetup(XCBConnection *c) +const xcb_setup_t *xcb_get_setup(xcb_connection_t *c) { if(c->has_error) return 0; @@ -188,7 +188,7 @@ const XCBSetup *XCBGetSetup(XCBConnection *c) return c->setup; } -int XCBGetFileDescriptor(XCBConnection *c) +int xcb_get_file_descriptor(xcb_connection_t *c) { if(c->has_error) return -1; @@ -196,19 +196,19 @@ int XCBGetFileDescriptor(XCBConnection *c) return c->fd; } -int XCBConnectionHasError(XCBConnection *c) +int xcb_connection_has_error(xcb_connection_t *c) { /* doesn't need locking because it's read and written atomically. */ return c->has_error; } -XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info) +xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info) { - XCBConnection* c; + xcb_connection_t* c; - c = calloc(1, sizeof(XCBConnection)); + c = calloc(1, sizeof(xcb_connection_t)); if(!c) - return (XCBConnection *) &error_connection; + return (xcb_connection_t *) &error_connection; c->fd = fd; @@ -223,14 +223,14 @@ XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info) _xcb_xid_init(c) )) { - XCBDisconnect(c); - return (XCBConnection *) &error_connection; + xcb_disconnect(c); + return (xcb_connection_t *) &error_connection; } return c; } -void XCBDisconnect(XCBConnection *c) +void xcb_disconnect(xcb_connection_t *c) { if(c->has_error) return; @@ -250,12 +250,12 @@ void XCBDisconnect(XCBConnection *c) /* Private interface */ -void _xcb_conn_shutdown(XCBConnection *c) +void _xcb_conn_shutdown(xcb_connection_t *c) { c->has_error = 1; } -int _xcb_conn_wait(XCBConnection *c, pthread_cond_t *cond, struct iovec **vector, int *count) +int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count) { int ret; fd_set rfds, wfds; diff --git a/src/xcb_ext.c b/src/xcb_ext.c index 3732515..9655dd8 100644 --- a/src/xcb_ext.c +++ b/src/xcb_ext.c @@ -35,12 +35,12 @@ typedef struct lazyreply { enum { LAZY_NONE = 0, LAZY_COOKIE, LAZY_FORCED } tag; union { - XCBQueryExtensionCookie cookie; - XCBQueryExtensionRep *reply; + xcb_query_extension_cookie_t cookie; + xcb_query_extension_reply_t *reply; } value; } lazyreply; -static lazyreply *get_index(XCBConnection *c, int index) +static lazyreply *get_index(xcb_connection_t *c, int index) { if(index > c->ext.extensions_size) { @@ -55,7 +55,7 @@ static lazyreply *get_index(XCBConnection *c, int index) return c->ext.extensions + index - 1; } -static lazyreply *get_lazyreply(XCBConnection *c, XCBExtension *ext) +static lazyreply *get_lazyreply(xcb_connection_t *c, xcb_extension_t *ext) { static pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER; static int next_global_id; @@ -72,16 +72,16 @@ static lazyreply *get_lazyreply(XCBConnection *c, XCBExtension *ext) { /* cache miss: query the server */ data->tag = LAZY_COOKIE; - data->value.cookie = XCBQueryExtension(c, strlen(ext->name), ext->name); + data->value.cookie = xcb_query_extension(c, strlen(ext->name), ext->name); } return data; } /* Public interface */ -/* Do not free the returned XCBQueryExtensionRep - on return, it's aliased +/* Do not free the returned xcb_query_extension_reply_t - on return, it's aliased * from the cache. */ -const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension *ext) +const xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext) { lazyreply *data; if(c->has_error) @@ -92,14 +92,14 @@ const XCBQueryExtensionRep *XCBGetExtensionData(XCBConnection *c, XCBExtension * if(data && data->tag == LAZY_COOKIE) { data->tag = LAZY_FORCED; - data->value.reply = XCBQueryExtensionReply(c, data->value.cookie, 0); + data->value.reply = xcb_query_extension_reply(c, data->value.cookie, 0); } pthread_mutex_unlock(&c->ext.lock); return data ? data->value.reply : 0; } -void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext) +void xcb_prefetch_extension_data(xcb_connection_t *c, xcb_extension_t *ext) { if(c->has_error) return; @@ -110,14 +110,14 @@ void XCBPrefetchExtensionData(XCBConnection *c, XCBExtension *ext) /* Private interface */ -int _xcb_ext_init(XCBConnection *c) +int _xcb_ext_init(xcb_connection_t *c) { if(pthread_mutex_init(&c->ext.lock, 0)) return 0; return 1; } -void _xcb_ext_destroy(XCBConnection *c) +void _xcb_ext_destroy(xcb_connection_t *c) { pthread_mutex_destroy(&c->ext.lock); while(c->ext.extensions_size-- > 0) diff --git a/src/xcb_in.c b/src/xcb_in.c index 2ac1e52..690f623 100644 --- a/src/xcb_in.c +++ b/src/xcb_in.c @@ -37,11 +37,11 @@ #include "xcbext.h" #include "xcbint.h" -#define XCBError 0 -#define XCBReply 1 +#define XCB_ERROR 0 +#define XCB_REPLY 1 struct event_list { - XCBGenericEvent *event; + xcb_generic_event_t *event; struct event_list *next; }; @@ -63,7 +63,7 @@ typedef struct reader_list { struct reader_list *next; } reader_list; -static void wake_up_next_reader(XCBConnection *c) +static void wake_up_next_reader(xcb_connection_t *c) { int pthreadret; if(c->in.readers) @@ -73,9 +73,9 @@ static void wake_up_next_reader(XCBConnection *c) assert(pthreadret == 0); } -static int read_packet(XCBConnection *c) +static int read_packet(xcb_connection_t *c) { - XCBGenericRep genrep; + xcb_generic_reply_t genrep; int length = 32; void *buf; pending_reply *pend = 0; @@ -89,7 +89,7 @@ static int read_packet(XCBConnection *c) memcpy(&genrep, c->in.queue, sizeof(genrep)); /* Compute 32-bit sequence number of this packet. */ - if((genrep.response_type & 0x7f) != XCBKeymapNotify) + if((genrep.response_type & 0x7f) != XCB_KEYMAP_NOTIFY) { unsigned int lastread = c->in.request_read; c->in.request_read = (lastread & 0xffff0000) | genrep.sequence; @@ -108,7 +108,7 @@ static int read_packet(XCBConnection *c) } c->in.request_completed = c->in.request_read - 1; } - if(genrep.response_type == XCBError) + if(genrep.response_type == XCB_ERROR) c->in.request_completed = c->in.request_read; while(c->in.pending_replies && @@ -122,7 +122,7 @@ static int read_packet(XCBConnection *c) } } - if(genrep.response_type == XCBError || genrep.response_type == XCBReply) + if(genrep.response_type == XCB_ERROR || genrep.response_type == XCB_REPLY) { pend = c->in.pending_replies; if(pend && pend->request != c->in.request_read) @@ -130,17 +130,17 @@ static int read_packet(XCBConnection *c) } /* For reply packets, check that the entire packet is available. */ - if(genrep.response_type == XCBReply) + if(genrep.response_type == XCB_REPLY) { if(pend && pend->workaround == WORKAROUND_GLX_GET_FB_CONFIGS_BUG) { - CARD32 *p = (CARD32 *) c->in.queue; + uint32_t *p = (uint32_t *) c->in.queue; genrep.length = p[2] * p[3] * 2; } length += genrep.length * 4; } - buf = malloc(length + (genrep.response_type == XCBReply ? 0 : sizeof(CARD32))); + buf = malloc(length + (genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t))); if(!buf) { _xcb_conn_shutdown(c); @@ -157,12 +157,12 @@ static int read_packet(XCBConnection *c) return 1; } - if(genrep.response_type != XCBReply) - ((XCBGenericEvent *) buf)->full_sequence = c->in.request_read; + if(genrep.response_type != XCB_REPLY) + ((xcb_generic_event_t *) buf)->full_sequence = c->in.request_read; /* reply, or checked error */ - if( genrep.response_type == XCBReply || - (genrep.response_type == XCBError && pend && (pend->flags & XCB_REQUEST_CHECKED))) + if( genrep.response_type == XCB_REPLY || + (genrep.response_type == XCB_ERROR && pend && (pend->flags & XCB_REQUEST_CHECKED))) { reader_list *reader; struct reply_list *cur = malloc(sizeof(struct reply_list)); @@ -205,10 +205,10 @@ static int read_packet(XCBConnection *c) return 1; /* I have something for you... */ } -static XCBGenericEvent *get_event(XCBConnection *c) +static xcb_generic_event_t *get_event(xcb_connection_t *c) { struct event_list *cur = c->in.events; - XCBGenericEvent *ret; + xcb_generic_event_t *ret; if(!c->in.events) return 0; ret = cur->event; @@ -253,7 +253,7 @@ static int read_block(const int fd, void *buf, const size_t len) return len; } -static int poll_for_reply(XCBConnection *c, unsigned int request, void **reply, XCBGenericError **error) +static int poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error) { struct reply_list *head; @@ -292,7 +292,7 @@ static int poll_for_reply(XCBConnection *c, unsigned int request, void **reply, if(head) { - if(((XCBGenericRep *) head->reply)->response_type == XCBError) + if(((xcb_generic_reply_t *) head->reply)->response_type == XCB_ERROR) { if(error) *error = head->reply; @@ -310,7 +310,7 @@ static int poll_for_reply(XCBConnection *c, unsigned int request, void **reply, /* Public interface */ -void *XCBWaitForReply(XCBConnection *c, unsigned int request, XCBGenericError **e) +void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e) { void *ret = 0; if(e) @@ -362,7 +362,7 @@ void *XCBWaitForReply(XCBConnection *c, unsigned int request, XCBGenericError ** return ret; } -int XCBPollForReply(XCBConnection *c, unsigned int request, void **reply, XCBGenericError **error) +int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error) { int ret; if(c->has_error) @@ -379,9 +379,9 @@ int XCBPollForReply(XCBConnection *c, unsigned int request, void **reply, XCBGen return ret; } -XCBGenericEvent *XCBWaitForEvent(XCBConnection *c) +xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c) { - XCBGenericEvent *ret; + xcb_generic_event_t *ret; if(c->has_error) return 0; pthread_mutex_lock(&c->iolock); @@ -395,11 +395,11 @@ XCBGenericEvent *XCBWaitForEvent(XCBConnection *c) return ret; } -XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error) +xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c, int *error) { if(!c->has_error) { - XCBGenericEvent *ret = 0; + xcb_generic_event_t *ret = 0; int success; pthread_mutex_lock(&c->iolock); /* FIXME: follow X meets Z architecture changes. */ @@ -418,28 +418,28 @@ XCBGenericEvent *XCBPollForEvent(XCBConnection *c, int *error) *error = -1; else { - fprintf(stderr, "XCBPollForEvent: I/O error occured, but no handler provided.\n"); + fprintf(stderr, "xcb_poll_for_event_t: I/O error occured, but no handler provided.\n"); abort(); } return 0; } -XCBGenericError *XCBRequestCheck(XCBConnection *c, XCBVoidCookie cookie) +xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie) { /* FIXME: this could hold the lock to avoid syncing unnecessarily, but - * that would require factoring the locking out of XCBGetInputFocus, - * XCBGetInputFocusReply, and XCBWaitForReply. */ - XCBGenericError *ret; + * that would require factoring the locking out of xcb_get_input_focus_t, + * xcb_get_input_focus_reply_t, and xcb_wait_for_reply_t. */ + xcb_generic_error_t *ret; void *reply; if(c->has_error) return 0; if(XCB_SEQUENCE_COMPARE(cookie.sequence,>,c->in.request_expected) && XCB_SEQUENCE_COMPARE(cookie.sequence,>,c->in.request_completed)) { - free(XCBGetInputFocusReply(c, XCBGetInputFocus(c), &ret)); + free(xcb_get_input_focus_reply(c, xcb_get_input_focus(c), &ret)); assert(!ret); } - reply = XCBWaitForReply(c, cookie.sequence, &ret); + reply = xcb_wait_for_reply(c, cookie.sequence, &ret); assert(!reply); return ret; } @@ -488,7 +488,7 @@ void _xcb_in_destroy(_xcb_in *in) } } -int _xcb_in_expect_reply(XCBConnection *c, unsigned int request, enum workarounds workaround, int flags) +int _xcb_in_expect_reply(xcb_connection_t *c, unsigned int request, enum workarounds workaround, int flags) { pending_reply *pend = malloc(sizeof(pending_reply)); assert(workaround != WORKAROUND_NONE || flags != 0); @@ -506,7 +506,7 @@ int _xcb_in_expect_reply(XCBConnection *c, unsigned int request, enum workaround return 1; } -int _xcb_in_read(XCBConnection *c) +int _xcb_in_read(xcb_connection_t *c) { int n = read(c->fd, c->in.queue + c->in.queue_len, sizeof(c->in.queue) - c->in.queue_len); if(n > 0) @@ -519,7 +519,7 @@ int _xcb_in_read(XCBConnection *c) return 0; } -int _xcb_in_read_block(XCBConnection *c, void *buf, int len) +int _xcb_in_read_block(xcb_connection_t *c, void *buf, int len) { int done = c->in.queue_len; if(len < done) diff --git a/src/xcb_list.c b/src/xcb_list.c index 9854ead..3a18d90 100644 --- a/src/xcb_list.c +++ b/src/xcb_list.c @@ -54,7 +54,7 @@ _xcb_map *_xcb_map_new() return list; } -void _xcb_map_delete(_xcb_map *list, XCBListFreeFunc do_free) +void _xcb_map_delete(_xcb_map *list, xcb_list_free_func_t do_free) { if(!list) return; diff --git a/src/xcb_out.c b/src/xcb_out.c index 1b68215..edb0aa9 100644 --- a/src/xcb_out.c +++ b/src/xcb_out.c @@ -35,7 +35,7 @@ #include "xcbint.h" #include "extensions/bigreq.h" -static int write_block(XCBConnection *c, struct iovec *vector, int count) +static int write_block(xcb_connection_t *c, struct iovec *vector, int count) { while(count && c->out.queue_len + vector[0].iov_len <= sizeof(c->out.queue)) { @@ -57,19 +57,19 @@ static int write_block(XCBConnection *c, struct iovec *vector, int count) /* Public interface */ -CARD32 XCBGetMaximumRequestLength(XCBConnection *c) +uint32_t xcb_get_maximum_request_length(xcb_connection_t *c) { if(c->has_error) return 0; pthread_mutex_lock(&c->out.reqlenlock); if(!c->out.maximum_request_length) { - const XCBQueryExtensionRep *ext; + const xcb_query_extension_reply_t *ext; c->out.maximum_request_length = c->setup->maximum_request_length; - ext = XCBGetExtensionData(c, &XCBBigRequestsId); + ext = xcb_get_extension_data(c, &xcb_big_requests_id); if(ext && ext->present) { - XCBBigRequestsEnableRep *r = XCBBigRequestsEnableReply(c, XCBBigRequestsEnable(c), 0); + xcb_big_requests_enable_reply_t *r = xcb_big_requests_enable_reply(c, xcb_big_requests_enable(c), 0); c->out.maximum_request_length = r->maximum_request_length; free(r); } @@ -78,18 +78,18 @@ CARD32 XCBGetMaximumRequestLength(XCBConnection *c) return c->out.maximum_request_length; } -unsigned int XCBSendRequest(XCBConnection *c, int flags, struct iovec *vector, const XCBProtocolRequest *req) +unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req) { static const union { struct { - CARD8 major; - CARD8 pad; - CARD16 len; + uint8_t major; + uint8_t pad; + uint16_t len; } fields; - CARD32 packet; + uint32_t packet; } sync = { { /* GetInputFocus */ 43, 0, 1 } }; unsigned int request; - CARD32 prefix[3] = { 0 }; + uint32_t prefix[3] = { 0 }; int veclen = req->count; enum workarounds workaround = WORKAROUND_NONE; @@ -104,23 +104,23 @@ unsigned int XCBSendRequest(XCBConnection *c, int flags, struct iovec *vector, c { static const char pad[3]; int i; - CARD16 shortlen = 0; + uint16_t shortlen = 0; size_t longlen = 0; assert(vector[0].iov_len >= 4); /* set the major opcode, and the minor opcode for extensions */ if(req->ext) { - const XCBQueryExtensionRep *extension = XCBGetExtensionData(c, req->ext); + const xcb_query_extension_reply_t *extension = xcb_get_extension_data(c, req->ext); if(!(extension && extension->present)) { _xcb_conn_shutdown(c); return 0; } - ((CARD8 *) vector[0].iov_base)[0] = extension->major_opcode; - ((CARD8 *) vector[0].iov_base)[1] = req->opcode; + ((uint8_t *) vector[0].iov_base)[0] = extension->major_opcode; + ((uint8_t *) vector[0].iov_base)[1] = req->opcode; } else - ((CARD8 *) vector[0].iov_base)[0] = req->opcode; + ((uint8_t *) vector[0].iov_base)[0] = req->opcode; /* put together the length field, possibly using BIGREQUESTS */ for(i = 0; i < req->count; ++i) @@ -141,14 +141,14 @@ unsigned int XCBSendRequest(XCBConnection *c, int flags, struct iovec *vector, c shortlen = longlen; longlen = 0; } - else if(longlen > XCBGetMaximumRequestLength(c)) + else if(longlen > xcb_get_maximum_request_length(c)) { _xcb_conn_shutdown(c); return 0; /* server can't take this; maybe need BIGREQUESTS? */ } /* set the length field. */ - ((CARD16 *) vector[0].iov_base)[1] = shortlen; + ((uint16_t *) vector[0].iov_base)[1] = shortlen; if(!shortlen) prefix[2] = ++longlen; } @@ -158,7 +158,7 @@ unsigned int XCBSendRequest(XCBConnection *c, int flags, struct iovec *vector, c /* XXX: GetFBConfigs won't use BIG-REQUESTS in any sane * configuration, but that should be handled here anyway. */ if(req->ext && !req->isvoid && !strcmp(req->ext->name, "GLX") && - ((req->opcode == 17 && ((CARD32 *) vector[0].iov_base)[1] == 0x10004) || + ((req->opcode == 17 && ((uint32_t *) vector[0].iov_base)[1] == 0x10004) || req->opcode == 21)) workaround = WORKAROUND_GLX_GET_FB_CONFIGS_BUG; @@ -194,11 +194,11 @@ unsigned int XCBSendRequest(XCBConnection *c, int flags, struct iovec *vector, c --vector, ++veclen; if(prefix[2]) { - prefix[1] = ((CARD32 *) vector[1].iov_base)[0]; - vector[1].iov_base = (CARD32 *) vector[1].iov_base + 1; - vector[1].iov_len -= sizeof(CARD32); + prefix[1] = ((uint32_t *) vector[1].iov_base)[0]; + vector[1].iov_base = (uint32_t *) vector[1].iov_base + 1; + vector[1].iov_len -= sizeof(uint32_t); } - vector[0].iov_len = sizeof(CARD32) * (prefix[0] ? 1 : 0 | prefix[2] ? 2 : 0); + vector[0].iov_len = sizeof(uint32_t) * (prefix[0] ? 1 : 0 | prefix[2] ? 2 : 0); vector[0].iov_base = prefix + !prefix[0]; } @@ -211,7 +211,7 @@ unsigned int XCBSendRequest(XCBConnection *c, int flags, struct iovec *vector, c return request; } -int XCBFlush(XCBConnection *c) +int xcb_flush(xcb_connection_t *c) { int ret; if(c->has_error) @@ -248,7 +248,7 @@ void _xcb_out_destroy(_xcb_out *out) pthread_mutex_destroy(&out->reqlenlock); } -int _xcb_out_send(XCBConnection *c, struct iovec **vector, int *count) +int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count) { int ret = 1; while(ret && *count) @@ -258,7 +258,7 @@ int _xcb_out_send(XCBConnection *c, struct iovec **vector, int *count) return ret; } -int _xcb_out_flush_to(XCBConnection *c, unsigned int request) +int _xcb_out_flush_to(xcb_connection_t *c, unsigned int request) { assert(XCB_SEQUENCE_COMPARE(request, <=, c->out.request)); if(XCB_SEQUENCE_COMPARE(c->out.request_written, >=, request)) diff --git a/src/xcb_util.c b/src/xcb_util.c index d93353b..3eab06a 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -47,7 +47,7 @@ static const int error_connection = 1; -int XCBPopcount(CARD32 mask) +int xcb_popcount(uint32_t mask) { unsigned long y; y = (mask >> 1) & 033333333333; @@ -55,7 +55,7 @@ int XCBPopcount(CARD32 mask) return ((y + (y >> 3)) & 030707070707) % 077; } -int XCBParseDisplay(const char *name, char **host, int *displayp, int *screenp) +int xcb_parse_display(const char *name, char **host, int *displayp, int *screenp) { int len, display, screen; char *colon, *dot, *end; @@ -206,38 +206,38 @@ static int _xcb_open_unix(const char *file) return fd; } -XCBConnection *XCBConnect(const char *displayname, int *screenp) +xcb_connection_t *xcb_connect(const char *displayname, int *screenp) { int fd, display = 0; char *host; - XCBConnection *c; - XCBAuthInfo auth; + xcb_connection_t *c; + xcb_auth_info_t auth; - if(!XCBParseDisplay(displayname, &host, &display, screenp)) - return (XCBConnection *) &error_connection; + if(!xcb_parse_display(displayname, &host, &display, screenp)) + return (xcb_connection_t *) &error_connection; fd = _xcb_open(host, display); free(host); if(fd == -1) - return (XCBConnection *) &error_connection; + return (xcb_connection_t *) &error_connection; _xcb_get_auth_info(fd, &auth); - c = XCBConnectToFD(fd, &auth); + c = xcb_connect_to_fd(fd, &auth); free(auth.name); free(auth.data); return c; } -XCBConnection *XCBConnectToDisplayWithAuthInfo(const char *displayname, XCBAuthInfo *auth, int *screenp) +xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname, xcb_auth_info_t *auth, int *screenp) { int fd, display = 0; char *host; - if(!XCBParseDisplay(displayname, &host, &display, screenp)) - return (XCBConnection *) &error_connection; + if(!xcb_parse_display(displayname, &host, &display, screenp)) + return (xcb_connection_t *) &error_connection; fd = _xcb_open(host, display); free(host); if(fd == -1) - return (XCBConnection *) &error_connection; + return (xcb_connection_t *) &error_connection; - return XCBConnectToFD(fd, auth); + return xcb_connect_to_fd(fd, auth); } diff --git a/src/xcb_xid.c b/src/xcb_xid.c index a2e7dec..6ca6bd9 100644 --- a/src/xcb_xid.c +++ b/src/xcb_xid.c @@ -33,16 +33,16 @@ /* Public interface */ -CARD32 XCBGenerateID(XCBConnection *c) +uint32_t xcb_generate_id(xcb_connection_t *c) { - CARD32 ret; + uint32_t ret; if(c->has_error) return -1; pthread_mutex_lock(&c->xid.lock); if(c->xid.last == c->xid.max) { - XCBXCMiscGetXIDRangeRep *range; - range = XCBXCMiscGetXIDRangeReply(c, XCBXCMiscGetXIDRange(c), 0); + xcb_xc_misc_get_xid_range_reply_t *range; + range = xcb_xc_misc_get_xid_range_reply(c, xcb_xc_misc_get_xid_range(c), 0); if(!range) { pthread_mutex_unlock(&c->xid.lock); @@ -60,7 +60,7 @@ CARD32 XCBGenerateID(XCBConnection *c) /* Private interface */ -int _xcb_xid_init(XCBConnection *c) +int _xcb_xid_init(xcb_connection_t *c) { if(pthread_mutex_init(&c->xid.lock, 0)) return 0; @@ -71,7 +71,7 @@ int _xcb_xid_init(XCBConnection *c) return 1; } -void _xcb_xid_destroy(XCBConnection *c) +void _xcb_xid_destroy(xcb_connection_t *c) { pthread_mutex_destroy(&c->xid.lock); } diff --git a/src/xcb_xlib.c b/src/xcb_xlib.c index 054bc2e..5e56426 100644 --- a/src/xcb_xlib.c +++ b/src/xcb_xlib.c @@ -26,14 +26,14 @@ #include "xcbxlib.h" #include "xcbint.h" -unsigned int XCBGetRequestSent(XCBConnection *c) +unsigned int xcb_get_request_sent(xcb_connection_t *c) { if(c->has_error) return 0; return c->out.request; } -pthread_mutex_t *XCBGetIOLock(XCBConnection *c) +pthread_mutex_t *xcb_get_io_lock(xcb_connection_t *c) { if(c->has_error) return 0; diff --git a/src/xcbext.h b/src/xcbext.h index 508ebf0..4824660 100644 --- a/src/xcbext.h +++ b/src/xcbext.h @@ -36,7 +36,7 @@ extern "C" { /* xcb_ext.c */ -struct XCBExtension { +struct xcb_extension_t { const char *name; int global_id; }; @@ -46,34 +46,34 @@ struct XCBExtension { typedef struct { size_t count; - XCBExtension *ext; - CARD8 opcode; - BOOL isvoid; -} XCBProtocolRequest; + xcb_extension_t *ext; + uint8_t opcode; + uint8_t isvoid; +} xcb_protocol_request_t; -enum XCBSendRequestFlags { +enum xcb_send_request_flags_t { XCB_REQUEST_CHECKED = 1 << 0, XCB_REQUEST_RAW = 1 << 1, XCB_REQUEST_DISCARD_REPLY = 1 << 2 }; -unsigned int XCBSendRequest(XCBConnection *c, int flags, struct iovec *vector, const XCBProtocolRequest *request); +unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request); /* xcb_in.c */ -void *XCBWaitForReply(XCBConnection *c, unsigned int request, XCBGenericError **e); -int XCBPollForReply(XCBConnection *c, unsigned int request, void **reply, XCBGenericError **error); +void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e); +int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error); /* xcb_xid.c */ -CARD32 XCBGenerateID(XCBConnection *c); +uint32_t xcb_generate_id(xcb_connection_t *c); /* xcb_util.c */ -int XCBPopcount(CARD32 mask); +int xcb_popcount(uint32_t mask); #ifdef __cplusplus } diff --git a/src/xcbint.h b/src/xcbint.h index 01d8a20..1a71696 100644 --- a/src/xcbint.h +++ b/src/xcbint.h @@ -47,12 +47,12 @@ enum workarounds { /* xcb_list.c */ -typedef void (*XCBListFreeFunc)(void *); +typedef void (*xcb_list_free_func_t)(void *); typedef struct _xcb_map _xcb_map; _xcb_map *_xcb_map_new(void); -void _xcb_map_delete(_xcb_map *q, XCBListFreeFunc do_free); +void _xcb_map_delete(_xcb_map *q, xcb_list_free_func_t do_free); int _xcb_map_put(_xcb_map *q, unsigned int key, void *data); void *_xcb_map_remove(_xcb_map *q, unsigned int key); @@ -70,14 +70,14 @@ typedef struct _xcb_out { unsigned int request_written; pthread_mutex_t reqlenlock; - CARD32 maximum_request_length; + uint32_t maximum_request_length; } _xcb_out; int _xcb_out_init(_xcb_out *out); void _xcb_out_destroy(_xcb_out *out); -int _xcb_out_send(XCBConnection *c, struct iovec **vector, int *count); -int _xcb_out_flush_to(XCBConnection *c, unsigned int request); +int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count); +int _xcb_out_flush_to(xcb_connection_t *c, unsigned int request); /* xcb_in.c */ @@ -107,24 +107,24 @@ typedef struct _xcb_in { int _xcb_in_init(_xcb_in *in); void _xcb_in_destroy(_xcb_in *in); -int _xcb_in_expect_reply(XCBConnection *c, unsigned int request, enum workarounds workaround, int flags); +int _xcb_in_expect_reply(xcb_connection_t *c, unsigned int request, enum workarounds workaround, int flags); -int _xcb_in_read(XCBConnection *c); -int _xcb_in_read_block(XCBConnection *c, void *buf, int nread); +int _xcb_in_read(xcb_connection_t *c); +int _xcb_in_read_block(xcb_connection_t *c, void *buf, int nread); /* xcb_xid.c */ typedef struct _xcb_xid { pthread_mutex_t lock; - CARD32 last; - CARD32 base; - CARD32 max; - CARD32 inc; + uint32_t last; + uint32_t base; + uint32_t max; + uint32_t inc; } _xcb_xid; -int _xcb_xid_init(XCBConnection *c); -void _xcb_xid_destroy(XCBConnection *c); +int _xcb_xid_init(xcb_connection_t *c); +void _xcb_xid_destroy(xcb_connection_t *c); /* xcb_ext.c */ @@ -135,17 +135,17 @@ typedef struct _xcb_ext { int extensions_size; } _xcb_ext; -int _xcb_ext_init(XCBConnection *c); -void _xcb_ext_destroy(XCBConnection *c); +int _xcb_ext_init(xcb_connection_t *c); +void _xcb_ext_destroy(xcb_connection_t *c); /* xcb_conn.c */ -struct XCBConnection { +struct xcb_connection_t { int has_error; /* constant data */ - XCBSetup *setup; + xcb_setup_t *setup; int fd; /* I/O data */ @@ -158,13 +158,13 @@ struct XCBConnection { _xcb_xid xid; }; -void _xcb_conn_shutdown(XCBConnection *c); -int _xcb_conn_wait(XCBConnection *c, pthread_cond_t *cond, struct iovec **vector, int *count); +void _xcb_conn_shutdown(xcb_connection_t *c); +int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count); /* xcb_auth.c */ -int _xcb_get_auth_info(int fd, XCBAuthInfo *info); +int _xcb_get_auth_info(int fd, xcb_auth_info_t *info); #ifdef GCC_HAS_VISIBILITY #pragma GCC visibility pop diff --git a/src/xcbxlib.h b/src/xcbxlib.h index 59dd2a5..7e050c2 100644 --- a/src/xcbxlib.h +++ b/src/xcbxlib.h @@ -32,8 +32,8 @@ #include "xcb.h" /* This function must be called with the IOLock held. */ -unsigned int XCBGetRequestSent(XCBConnection *c); +unsigned int xcb_get_request_sent(xcb_connection_t *c); -pthread_mutex_t *XCBGetIOLock(XCBConnection *c); +pthread_mutex_t *xcb_get_io_lock(xcb_connection_t *c); #endif -- cgit v1.2.3