diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/c-client.xsl | 426 | ||||
-rw-r--r-- | src/xcb.h | 146 | ||||
-rw-r--r-- | src/xcb_auth.c | 6 | ||||
-rw-r--r-- | src/xcb_conn.c | 60 | ||||
-rw-r--r-- | src/xcb_ext.c | 22 | ||||
-rw-r--r-- | src/xcb_in.c | 72 | ||||
-rw-r--r-- | src/xcb_list.c | 2 | ||||
-rw-r--r-- | src/xcb_out.c | 52 | ||||
-rw-r--r-- | src/xcb_util.c | 28 | ||||
-rw-r--r-- | src/xcb_xid.c | 12 | ||||
-rw-r--r-- | src/xcb_xlib.c | 4 | ||||
-rw-r--r-- | src/xcbext.h | 22 | ||||
-rw-r--r-- | src/xcbint.h | 42 | ||||
-rw-r--r-- | src/xcbxlib.h | 4 |
14 files changed, 506 insertions, 392 deletions
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. --> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" - xmlns:e="http://exslt.org/common"> + 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"> <xsl:output method="text" /> @@ -49,6 +53,8 @@ authorization from the authors. <xsl:variable name="ucase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" /> <xsl:variable name="lcase" select="'abcdefghijklmnopqrstuvwxyz'" /> + <xsl:variable name="letters" select="concat($ucase, $lcase)" /> + <xsl:variable name="digits" select="'0123456789'" /> <xsl:variable name="header" select="/xcb/@header" /> <xsl:variable name="ucase-header" @@ -80,19 +86,134 @@ authorization from the authors. <xcb> <xsl:copy-of select="@*" /> <xsl:if test="$ext"> - <constant type="XCBExtension" name="XCB{$ext}Id"> + <constant type="xcb_extension_t" name="{xcb:xcb-prefix()}_id"> <xsl:attribute name="value">{ "<xsl:value-of select="@extension-xname" />" }</xsl:attribute> </constant> - <function type="const XCBQueryExtensionRep *" name="XCB{$ext}Init"> - <field type="XCBConnection *" name="c" /> - <l>return XCBGetExtensionData(c, &XCB<!-- - --><xsl:value-of select="$ext" />Id);</l> + <function type="const xcb_query_extension_reply_t *" name="{xcb:xcb-prefix('init')}"> + <field type="xcb_connection_t *" name="c" /> + <l>return xcb_get_extension_data(c, &<!-- + --><xsl:value-of select="xcb:xcb-prefix()" />_id);</l> </function> </xsl:if> <xsl:apply-templates mode="pass1" /> </xcb> </xsl:template> + <func:function name="xcb:xcb-prefix"> + <xsl:param name="name" /> + <func:result> + <xsl:text>xcb</xsl:text> + <xsl:choose> + <xsl:when test="/xcb/@extension-name = 'RandR'"> + <xsl:text>_randr</xsl:text> + </xsl:when> + <xsl:when test="/xcb/@extension-name = 'ScreenSaver'"> + <xsl:text>_screensaver</xsl:text> + </xsl:when> + <xsl:when test="/xcb/@extension-name = 'XF86Dri'"> + <xsl:text>_xf86dri</xsl:text> + </xsl:when> + <xsl:when test="/xcb/@extension-name = 'XFixes'"> + <xsl:text>_xfixes</xsl:text> + </xsl:when> + <xsl:when test="/xcb/@extension-name = 'XvMC'"> + <xsl:text>_xvmc</xsl:text> + </xsl:when> + <xsl:when test="/xcb/@extension-name"> + <xsl:text>_</xsl:text> + <xsl:call-template name="camelcase-to-underscore"> + <xsl:with-param name="camelcase" select="/xcb/@extension-name" /> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + </xsl:otherwise> + </xsl:choose> + <xsl:if test="$name"> + <xsl:text>_</xsl:text> + <xsl:call-template name="camelcase-to-underscore"> + <xsl:with-param name="camelcase" select="$name" /> + </xsl:call-template> + </xsl:if> + </func:result> + </func:function> + + <func:function name="xcb:lowercase"> + <xsl:param name="name" /> + <func:result> + <xsl:call-template name="camelcase-to-underscore"> + <xsl:with-param name="camelcase" select="$name" /> + </xsl:call-template> + </func:result> + </func:function> + + <func:function name="xcb:get-char-void"> + <xsl:param name="name" /> + <xsl:variable name="ctype" select="substring-before($name, '_t')" /> + <func:result> + <xsl:choose> + <xsl:when test="$ctype = 'char' or $ctype = 'void' or $ctype = 'float' or $ctype = 'double'"> + <xsl:value-of select="$ctype" /> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$name" /> + </xsl:otherwise> + </xsl:choose> + </func:result> + </func:function> + + <func:function name="xcb:remove-void"> + <xsl:param name="name" /> + <xsl:variable name="ctype" select="substring-before($name, '_t')" /> + <func:result> + <xsl:choose> + <xsl:when test="$ctype = 'char' or $ctype = 'void' or $ctype = 'float' or $ctype = 'double'"> + <xsl:choose> + <xsl:when test="$ctype = 'void'"> + <xsl:text>char</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$ctype" /> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$name" /> + </xsl:otherwise> + </xsl:choose> + </func:result> + </func:function> + + <!-- split camel case into words and insert underscore --> + <xsl:template name="camelcase-to-underscore"> + <xsl:param name="camelcase"/> + <xsl:choose> + <xsl:when test="$camelcase='CHAR2B' or $camelcase='INT64' + or $camelcase='FLOAT32' or $camelcase='FLOAT64' + or $camelcase='BOOL32' or $camelcase='STRING8' + or $camelcase='Family_DECnet'"> + <xsl:value-of select="translate($camelcase, $ucase, $lcase)"/> + </xsl:when> + <xsl:otherwise> + <xsl:for-each select="str:split($camelcase, '')"> + <xsl:variable name="a" select="."/> + <xsl:variable name="b" select="following::*[1]"/> + <xsl:variable name="c" select="following::*[2]"/> + <xsl:value-of select="translate(., $ucase, $lcase)"/> + <xsl:if test="($b and contains($lcase, $a) and contains($ucase, $b)) + or ($b and contains($digits, $a) + and contains($letters, $b)) + or ($b and contains($letters, $a) + and contains($digits, $b)) + or ($c and contains($ucase, $a) + and contains($ucase, $b) + and contains($lcase, $c))"> + <xsl:text>_</xsl:text> + </xsl:if> + </xsl:for-each> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <!-- Modify names that conflict with C++ keywords by prefixing them with an underscore. If the name parameter is not specified, it defaults to the value of the name attribute on the context node. --> @@ -107,27 +228,26 @@ authorization from the authors. <!-- List of core types, for use in canonical-type-name. --> <xsl:variable name="core-types-rtf"> - <type name="BOOL" /> - <type name="BYTE" /> - <type name="CARD8" /> - <type name="CARD16" /> - <type name="CARD32" /> - <type name="INT8" /> - <type name="INT16" /> - <type name="INT32" /> - - <type name="char" /> - <type name="void" /> - <type name="float" /> - <type name="double" /> - <type name="XID" /> + <type name="BOOL" newname="uint8" /> + <type name="BYTE" newname="uint8" /> + <type name="CARD8" newname="uint8" /> + <type name="CARD16" newname="uint16" /> + <type name="CARD32" newname="uint32" /> + <type name="INT8" newname="int8" /> + <type name="INT16" newname="int16" /> + <type name="INT32" newname="int32" /> + + <type name="char" newname="char" /> + <type name="void" newname="void" /> + <type name="float" newname="float" /> + <type name="double" newname="double" /> </xsl:variable> <xsl:variable name="core-types" select="e:node-set($core-types-rtf)" /> <!-- Output the canonical name for a type. This will be - XCB{extension-containing-Type-if-any}Type, wherever the type is found in - the search path, or just Type if not found. If the type parameter is not + xcb_{extension-containing-type-if-any}_type, wherever the type is found in + the search path, or just type if not found. If the type parameter is not specified, it defaults to the value of the type attribute on the context node. --> @@ -149,7 +269,7 @@ authorization from the authors. <xsl:choose> <xsl:when test="$is-unqualified and $core-types/type[@name=$type]"> - <xsl:value-of select="$type" /> + <xsl:value-of select="$core-types/type[@name=$type]/@newname" /> </xsl:when> <xsl:otherwise> <xsl:variable name="type-definitions" @@ -165,9 +285,7 @@ authorization from the authors. <xsl:choose> <xsl:when test="count($type-definitions) = 1"> <xsl:for-each select="$type-definitions"> - <xsl:text>XCB</xsl:text> - <xsl:value-of select="concat(/xcb/@extension-name, - $unqualified-type)" /> + <xsl:value-of select="xcb:xcb-prefix($unqualified-type)" /> </xsl:for-each> </xsl:when> <xsl:when test="count($type-definitions) > 1"> @@ -205,16 +323,15 @@ authorization from the authors. context node. --> <xsl:template name="cookie-type"> <xsl:param name="request" select="." /> - <xsl:text>XCB</xsl:text> <xsl:choose> <xsl:when test="$request/reply"> - <xsl:value-of select="concat($ext, $request/@name)" /> + <xsl:value-of select="xcb:xcb-prefix($request/@name)" /> </xsl:when> <xsl:otherwise> - <xsl:text>Void</xsl:text> + <xsl:text>xcb_void</xsl:text> </xsl:otherwise> </xsl:choose> - <xsl:text>Cookie</xsl:text> + <xsl:text>_cookie_t</xsl:text> </xsl:template> <xsl:template name="request-function"> @@ -222,20 +339,18 @@ authorization from the authors. <xsl:param name="req" /> <function> <xsl:attribute name="name"> - <xsl:text>XCB</xsl:text> - <xsl:value-of select="$ext" /> - <xsl:value-of select="$req/@name" /> - <xsl:if test="$checked='true' and not($req/reply)">Checked</xsl:if> - <xsl:if test="$checked='false' and $req/reply">Unchecked</xsl:if> + <xsl:value-of select="xcb:xcb-prefix($req/@name)" /> + <xsl:if test="$checked='true' and not($req/reply)">_checked</xsl:if> + <xsl:if test="$checked='false' and $req/reply">_unchecked</xsl:if> </xsl:attribute> <xsl:attribute name="type"> <xsl:call-template name="cookie-type"> <xsl:with-param name="request" select="$req" /> </xsl:call-template> </xsl:attribute> - <field type="XCBConnection *" name="c" /> + <field type="xcb_connection_t *" name="c" /> <xsl:apply-templates select="$req/*[not(self::reply)]" mode="param" /> - <do-request ref="XCB{$ext}{$req/@name}Req" opcode="{$req/@opcode}" + <do-request ref="{xcb:xcb-prefix($req/@name)}_request_t" opcode="{$req/@opcode}" checked="{$checked}"> <xsl:if test="$req/reply"> <xsl:attribute name="has-reply">true</xsl:attribute> @@ -247,18 +362,18 @@ authorization from the authors. <xsl:template match="request" mode="pass1"> <xsl:variable name="req" select="." /> <xsl:if test="reply"> - <struct name="XCB{$ext}{@name}Cookie"> + <struct name="{xcb:xcb-prefix(@name)}_cookie_t"> <field type="unsigned int" name="sequence" /> </struct> </xsl:if> - <struct name="XCB{$ext}{@name}Req"> - <field type="CARD8" name="major_opcode" no-assign="true" /> + <struct name="{xcb:xcb-prefix(@name)}_request_t"> + <field type="uint8_t" name="major_opcode" no-assign="true" /> <xsl:if test="$ext"> - <field type="CARD8" name="minor_opcode" no-assign="true" /> + <field type="uint8_t" name="minor_opcode" no-assign="true" /> </xsl:if> <xsl:apply-templates select="*[not(self::reply)]" mode="field" /> <middle> - <field type="CARD16" name="length" no-assign="true" /> + <field type="uint16_t" name="length" no-assign="true" /> </middle> </struct> <xsl:call-template name="request-function"> @@ -270,83 +385,83 @@ authorization from the authors. <xsl:with-param name="req" select="$req" /> </xsl:call-template> <xsl:if test="reply"> - <struct name="XCB{$ext}{@name}Rep"> - <field type="BYTE" name="response_type" /> + <struct name="{xcb:xcb-prefix(@name)}_reply_t"> + <field type="uint8_t" name="response_type" /> <xsl:apply-templates select="reply/*" mode="field" /> <middle> - <field type="CARD16" name="sequence" /> - <field type="CARD32" name="length" /> + <field type="uint16_t" name="sequence" /> + <field type="uint32_t" name="length" /> </middle> </struct> - <iterator-functions ref="XCB{$ext}{@name}" kind="Rep" /> - <function type="XCB{$ext}{@name}Rep *" name="XCB{$ext}{@name}Reply"> - <field type="XCBConnection *" name="c" /> + <iterator-functions ref="{xcb:xcb-prefix(@name)}" kind="_reply" /> + <function type="{xcb:xcb-prefix(@name)}_reply_t *" name="{xcb:xcb-prefix(@name)}_reply"> + <field type="xcb_connection_t *" name="c" /> <field name="cookie"> <xsl:attribute name="type"> <xsl:call-template name="cookie-type" /> </xsl:attribute> </field> - <field type="XCBGenericError **" name="e" /> - <l>return (XCB<xsl:value-of select="concat($ext, @name)" />Rep *)<!-- - --> XCBWaitForReply(c, cookie.sequence, e);</l> + <field type="xcb_generic_error_t **" name="e" /> + <l>return (<xsl:value-of select="xcb:xcb-prefix(@name)" />_reply_t *)<!-- + --> xcb_wait_for_reply(c, cookie.sequence, e);</l> </function> </xsl:if> </xsl:template> <xsl:template match="xidtype" mode="pass1"> - <struct name="XCB{$ext}{@name}"> - <field type="CARD32" name="xid" /> + <struct name="{xcb:xcb-prefix(@name)}_t"> + <field type="uint32_t" name="xid" /> </struct> - <iterator ref="XCB{$ext}{@name}" /> - <iterator-functions ref="XCB{$ext}{@name}" /> - <function type="XCB{$ext}{@name}" name="XCB{$ext}{@name}New"> - <field type="XCBConnection *" name="c" /> - <l>XCB<xsl:value-of select="concat($ext, @name)" /> ret;</l> - <l>ret.xid = XCBGenerateID(c);</l> + <iterator ref="{xcb:xcb-prefix(@name)}" /> + <iterator-functions ref="{xcb:xcb-prefix(@name)}" /> + <function type="{xcb:xcb-prefix(@name)}_t" name="{xcb:xcb-prefix(@name)}_new"> + <field type="xcb_connection_t *" name="c" /> + <l><xsl:value-of select="concat(xcb:xcb-prefix(@name), '_t')" /> ret;</l> + <l>ret.xid = xcb_generate_id(c);</l> <l>return ret;</l> </function> </xsl:template> <xsl:template match="struct|union" mode="pass1"> - <struct name="XCB{$ext}{@name}"> + <struct name="{xcb:xcb-prefix(@name)}_t"> <xsl:if test="self::union"> <xsl:attribute name="kind">union</xsl:attribute> </xsl:if> <xsl:apply-templates select="*" mode="field" /> </struct> - <iterator ref="XCB{$ext}{@name}" /> - <iterator-functions ref="XCB{$ext}{@name}" /> + <iterator ref="{xcb:xcb-prefix(@name)}" /> + <iterator-functions ref="{xcb:xcb-prefix(@name)}" /> </xsl:template> <xsl:template match="event|eventcopy|error|errorcopy" mode="pass1"> <xsl:variable name="suffix"> <xsl:choose> <xsl:when test="self::event|self::eventcopy"> - <xsl:text>Event</xsl:text> + <xsl:text>_event_t</xsl:text> </xsl:when> <xsl:when test="self::error|self::errorcopy"> - <xsl:text>Error</xsl:text> + <xsl:text>_error_t</xsl:text> </xsl:when> </xsl:choose> </xsl:variable> - <constant type="number" name="XCB{$ext}{@name}" value="{@number}" /> + <constant type="number" name="{xcb:xcb-prefix(@name)}" value="{@number}" /> <xsl:choose> <xsl:when test="self::event|self::error"> - <struct name="XCB{$ext}{@name}{$suffix}"> - <field type="BYTE" name="response_type" /> + <struct name="{xcb:xcb-prefix(@name)}{$suffix}"> + <field type="uint8_t" name="response_type" /> <xsl:if test="self::error"> - <field type="BYTE" name="error_code" /> + <field type="uint8_t" name="error_code" /> </xsl:if> <xsl:apply-templates select="*" mode="field" /> <xsl:if test="not(self::event and boolean(@no-sequence-number))"> <middle> - <field type="CARD16" name="sequence" /> + <field type="uint16_t" name="sequence" /> </middle> </xsl:if> </struct> </xsl:when> <xsl:when test="self::eventcopy|self::errorcopy"> - <typedef newname="XCB{$ext}{@name}{$suffix}"> + <typedef newname="{xcb:xcb-prefix(@name)}{$suffix}"> <xsl:attribute name="oldname"> <xsl:call-template name="canonical-type-name"> <xsl:with-param name="type" select="@ref" /> @@ -364,21 +479,23 @@ authorization from the authors. <xsl:call-template name="canonical-type-name"> <xsl:with-param name="type" select="@oldname" /> </xsl:call-template> + <xsl:text>_t</xsl:text> </xsl:attribute> <xsl:attribute name="newname"> <xsl:call-template name="canonical-type-name"> <xsl:with-param name="type" select="@newname" /> </xsl:call-template> + <xsl:text>_t</xsl:text> </xsl:attribute> </typedef> - <iterator ref="XCB{$ext}{@newname}" /> - <iterator-functions ref="XCB{$ext}{@newname}" /> + <iterator ref="{xcb:xcb-prefix(@newname)}" /> + <iterator-functions ref="{xcb:xcb-prefix(@newname)}" /> </xsl:template> <xsl:template match="enum" mode="pass1"> - <enum name="XCB{$ext}{@name}"> + <enum name="{xcb:xcb-prefix(@name)}_t"> <xsl:for-each select="item"> - <item name="XCB{$ext}{../@name}{@name}"> + <item name="{translate(xcb:xcb-prefix(concat(../@name, concat('_', @name))), $lcase, $ucase)}"> <xsl:copy-of select="*" /> </item> </xsl:for-each> @@ -397,6 +514,7 @@ authorization from the authors. <xsl:copy> <xsl:attribute name="type"> <xsl:call-template name="canonical-type-name" /> + <xsl:text>_t</xsl:text> </xsl:attribute> <xsl:attribute name="name"> <xsl:call-template name="canonical-var-name" /> @@ -407,7 +525,8 @@ authorization from the authors. <xsl:template match="list" mode="field"> <xsl:variable name="type"><!-- - --><xsl:call-template name="canonical-type-name" /><!-- + --><xsl:call-template name="canonical-type-name" /> + <xsl:text>_t</xsl:text><!-- --></xsl:variable> <list type="{$type}"> <xsl:attribute name="name"> @@ -458,6 +577,7 @@ authorization from the authors. <xsl:call-template name="canonical-type-name"> <xsl:with-param name="type" select="@value-mask-type" /> </xsl:call-template> + <xsl:text>_t</xsl:text> </xsl:attribute> <xsl:attribute name="name"> <xsl:call-template name="canonical-var-name"> @@ -465,13 +585,13 @@ authorization from the authors. </xsl:call-template> </xsl:attribute> </field> - <list type="CARD32"> + <list type="uint32_t"> <xsl:attribute name="name"> <xsl:call-template name="canonical-var-name"> <xsl:with-param name="name" select="@value-list-name" /> </xsl:call-template> </xsl:attribute> - <function-call name="XCBPopcount"> + <function-call name="xcb_popcount"> <param> <fieldref> <xsl:call-template name="canonical-var-name"> @@ -487,6 +607,7 @@ authorization from the authors. <field> <xsl:attribute name="type"> <xsl:call-template name="canonical-type-name" /> + <xsl:text>_t</xsl:text> </xsl:attribute> <xsl:attribute name="name"> <xsl:call-template name="canonical-var-name" /> @@ -497,12 +618,18 @@ authorization from the authors. <xsl:template match="list" mode="param"> <!-- If no length expression is provided, use a CARD32 localfield. --> <xsl:if test="not(node())"> - <field type="CARD32" name="{@name}_len" /> + <field type="uint32_t" name="{@name}_len" /> </xsl:if> <field> + <xsl:variable name="ctype"> + <xsl:call-template name="canonical-type-name" /> + </xsl:variable> <xsl:attribute name="type"> <xsl:text>const </xsl:text> <xsl:call-template name="canonical-type-name" /> + <xsl:if test="not($ctype='char') and not($ctype='void')"> + <xsl:text>_t</xsl:text> + </xsl:if> <xsl:text> *</xsl:text> </xsl:attribute> <xsl:attribute name="name"> @@ -517,6 +644,7 @@ authorization from the authors. <xsl:call-template name="canonical-type-name"> <xsl:with-param name="type" select="@value-mask-type" /> </xsl:call-template> + <xsl:text>_t</xsl:text> </xsl:attribute> <xsl:attribute name="name"> <xsl:call-template name="canonical-var-name"> @@ -524,7 +652,7 @@ authorization from the authors. </xsl:call-template> </xsl:attribute> </field> - <field type="const CARD32 *"> + <field type="const uint32_t *"> <xsl:attribute name="name"> <xsl:call-template name="canonical-var-name"> <xsl:with-param name="name" select="@value-list-name" /> @@ -585,14 +713,14 @@ authorization from the authors. <xsl:variable name="num-parts" select="(1+count($struct/list))*2" /> - <l>static const XCBProtocolRequest xcb_req = {</l> + <l>static const xcb_protocol_request_t xcb_req = {</l> <indent> <l>/* count */ <xsl:value-of select="$num-parts" />,</l> <l>/* ext */ <xsl:choose> <xsl:when test="$ext"> - <xsl:text>&XCB</xsl:text> - <xsl:value-of select="$ext" /> - <xsl:text>Id</xsl:text> + <xsl:text>&</xsl:text> + <xsl:value-of select="xcb:xcb-prefix()" /> + <xsl:text>_id</xsl:text> </xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose>,</l> @@ -621,17 +749,24 @@ authorization from the authors. <l>xcb_parts[<xsl:value-of select="2 + position() * 2"/>].iov_base = (char *) <!-- --><xsl:value-of select="@name" />;</l> <l>xcb_parts[<xsl:value-of select="2 + position() * 2"/>].iov_len = <!-- - --><xsl:apply-templates mode="output-expression" /><!-- - --><xsl:if test="not(@type = 'void')"> + --><xsl:apply-templates mode="output-expression" /> + <xsl:if test="not(@type = 'void_t')"> <xsl:text> * sizeof(</xsl:text> - <xsl:value-of select="@type" /> + <xsl:choose> + <xsl:when test="@type='char_t'"> + <xsl:text>char</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@type" /> + </xsl:otherwise> + </xsl:choose> <xsl:text>)</xsl:text> </xsl:if>;</l> <l>xcb_parts[<xsl:value-of select="3 + position() * 2"/>].iov_base = 0;</l> <l>xcb_parts[<xsl:value-of select="3 + position() * 2"/>].iov_len = -xcb_parts[<xsl:value-of select="2 + position() * 2"/>].iov_len & 3;</l> </xsl:for-each> - <l>xcb_ret.sequence = XCBSendRequest(c, <!-- + <l>xcb_ret.sequence = xcb_send_request(c, <!-- --><xsl:choose> <xsl:when test="@checked='true'">XCB_REQUEST_CHECKED</xsl:when> <xsl:otherwise>0</xsl:otherwise> @@ -660,50 +795,30 @@ authorization from the authors. </xsl:template> <xsl:template match="iterator" mode="pass2"> - <struct name="{@ref}Iter"> - <field type="{@ref} *" name="data" /> + <struct name="{@ref}_iterator_t"> + <field type="{@ref}_t *" name="data" /> <field type="int" name="rem" /> <field type="int" name="index" /> </struct> </xsl:template> - <!-- Change a_name_like_this to ANameLikeThis. If the parameter name is not - given, it defaults to the name attribute of the context node. --> - <xsl:template name="capitalize"> - <xsl:param name="name" select="string(@name)" /> - <xsl:if test="$name"> - <xsl:value-of select="translate(substring($name,1,1), $lcase, $ucase)" /> - <xsl:choose> - <xsl:when test="contains($name, '_')"> - <xsl:value-of select="substring(substring-before($name, '_'), 2)" /> - <xsl:call-template name="capitalize"> - <xsl:with-param name="name" select="substring-after($name, '_')" /> - </xsl:call-template> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="substring($name, 2)" /> - </xsl:otherwise> - </xsl:choose> - </xsl:if> - </xsl:template> - <xsl:template match="iterator-functions" mode="pass2"> <xsl:variable name="ref" select="@ref" /> <xsl:variable name="kind" select="@kind" /> <xsl:variable name="struct" - select="$pass1/xcb/struct[@name=concat($ref,$kind)]" /> + select="$pass1/xcb/struct[@name=concat($ref, $kind, '_t')]" /> <xsl:variable name="nextfields-rtf"> <nextfield>R + 1</nextfield> <xsl:for-each select="$struct/list[not(@fixed)]"> <xsl:choose> - <xsl:when test="substring(@type, 1, 3) = 'XCB'"> - <nextfield><xsl:value-of select="@type" />End(<!-- - --><xsl:value-of select="$ref" /><!-- - --><xsl:call-template name="capitalize" />Iter(R))</nextfield> + <xsl:when test="substring(@type, 1, 3) = 'xcb'"> + <nextfield><xsl:value-of select="substring(@type, 1, string-length(@type)-2)" />_end(<!-- + --><xsl:value-of select="$ref" />_<!-- + --><xsl:value-of select="string(@name)" />_iterator(R))</nextfield> </xsl:when> <xsl:otherwise> - <nextfield><xsl:value-of select="$ref" /><!-- - --><xsl:call-template name="capitalize" />End(R)</nextfield> + <nextfield><xsl:value-of select="$ref" />_<!-- + --><xsl:value-of select="string(@name)" />_end(R)</nextfield> </xsl:otherwise> </xsl:choose> </xsl:for-each> @@ -715,52 +830,51 @@ authorization from the authors. <xsl:variable name="nextfield" select="$nextfields/nextfield[$number]" /> <xsl:variable name="is-first" select="not(preceding-sibling::list[not(@fixed)])" /> - <xsl:variable name="field-name"><!-- - --><xsl:call-template name="capitalize" /><!-- - --></xsl:variable> + <xsl:variable name="field-name" select="@name" /> <xsl:variable name="is-variable" select="$pass1/xcb/struct[@name=current()/@type]/list or document($search-path)/xcb - /struct[concat('XCB', - ancestor::xcb/@extension-name, - @name) = current()/@type] - /*[self::valueparam or self::list]" /> + /struct[concat(xcb:xcb-prefix(@name), '_t') + = current()/@type] + /*[self::valueparam + or self::list[.//*[not(self::value + or self::op)]]]" /> <xsl:if test="not($is-variable)"> - <function type="{@type} *" name="{$ref}{$field-name}"> - <field type="const {$ref}{$kind} *" name="R" /> + <function type="{xcb:get-char-void(@type)} *" name="{$ref}_{xcb:lowercase($field-name)}"> + <field type="const {$ref}{$kind}_t *" name="R" /> <xsl:choose> <xsl:when test="$is-first"> - <l>return (<xsl:value-of select="@type" /> *) <!-- + <l>return (<xsl:value-of select="xcb:get-char-void(@type)" /> *) <!-- -->(<xsl:value-of select="$nextfield" />);</l> </xsl:when> <xsl:otherwise> - <l>XCBGenericIter prev = <!-- + <l>xcb_generic_iterator_t prev = <!-- --><xsl:value-of select="$nextfield" />;</l> - <l>return (<xsl:value-of select="@type" /> *) <!-- + <l>return (<xsl:value-of select="xcb:get-char-void(@type)" /> *) <!-- -->((char *) prev.data + XCB_TYPE_PAD(<!-- - --><xsl:value-of select="@type" />, prev.index));</l> + --><xsl:value-of select="xcb:get-char-void(@type)" />, prev.index));</l> </xsl:otherwise> </xsl:choose> </function> </xsl:if> - <function type="int" name="{$ref}{$field-name}Length"> - <field type="const {$ref}{$kind} *" name="R" /> + <function type="int" name="{$ref}_{xcb:lowercase($field-name)}_length"> + <field type="const {$ref}{$kind}_t *" name="R" /> <l>return <xsl:apply-templates mode="output-expression"> <xsl:with-param name="field-prefix" select="'R->'" /> </xsl:apply-templates>;</l> </function> <xsl:choose> - <xsl:when test="substring(@type, 1, 3) = 'XCB'"> - <function type="{@type}Iter" name="{$ref}{$field-name}Iter"> - <field type="const {$ref}{$kind} *" name="R" /> - <l><xsl:value-of select="@type" />Iter i;</l> + <xsl:when test="substring(@type, 1, 3) = 'xcb'"> + <function type="{substring(@type, 1, string-length(@type)-2)}_iterator_t" name="{$ref}_{xcb:lowercase($field-name)}_iterator"> + <field type="const {$ref}{$kind}_t *" name="R" /> + <l><xsl:value-of select="substring(@type, 1, string-length(@type)-2)" />_iterator_t i;</l> <xsl:choose> <xsl:when test="$is-first"> <l>i.data = (<xsl:value-of select="@type" /> *) <!-- -->(<xsl:value-of select="$nextfield" />);</l> </xsl:when> <xsl:otherwise> - <l>XCBGenericIter prev = <!-- + <l>xcb_generic_iterator_t prev = <!-- --><xsl:value-of select="$nextfield" />;</l> <l>i.data = (<xsl:value-of select="@type" /> *) <!-- -->((char *) prev.data + XCB_TYPE_PAD(<!-- @@ -781,21 +895,21 @@ authorization from the authors. <xsl:otherwise><xsl:value-of select="@type" /></xsl:otherwise> </xsl:choose> </xsl:variable> - <function type="XCBGenericIter" name="{$ref}{$field-name}End"> - <field type="const {$ref}{$kind} *" name="R" /> - <l>XCBGenericIter i;</l> + <function type="xcb_generic_iterator_t" name="{$ref}_{xcb:lowercase($field-name)}_end"> + <field type="const {$ref}{$kind}_t *" name="R" /> + <l>xcb_generic_iterator_t i;</l> <xsl:choose> <xsl:when test="$is-first"> - <l>i.data = ((<xsl:value-of select="$cast" /> *) <!-- + <l>i.data = ((<xsl:value-of select="xcb:remove-void($cast)" /> *) <!-- -->(<xsl:value-of select="$nextfield" />)) + (<!-- --><xsl:apply-templates mode="output-expression"> <xsl:with-param name="field-prefix" select="'R->'" /> </xsl:apply-templates>);</l> </xsl:when> <xsl:otherwise> - <l>XCBGenericIter child = <!-- + <l>xcb_generic_iterator_t child = <!-- --><xsl:value-of select="$nextfield" />;</l> - <l>i.data = ((<xsl:value-of select="$cast" /> *) <!-- + <l>i.data = ((<xsl:value-of select="xcb:get-char-void($cast)" /> *) <!-- -->child.data) + (<!-- --><xsl:apply-templates mode="output-expression"> <xsl:with-param name="field-prefix" select="'R->'" /> @@ -810,32 +924,32 @@ authorization from the authors. </xsl:choose> </xsl:for-each> <xsl:if test="not($kind)"> - <function type="void" name="{$ref}Next"> - <field type="{$ref}Iter *" name="i" /> + <function type="void" name="{$ref}_next"> + <field type="{$ref}_iterator_t *" name="i" /> <xsl:choose> <xsl:when test="$struct/list[not(@fixed)]"> - <l><xsl:value-of select="$ref" /> *R = i->data;</l> - <l>XCBGenericIter child = <!-- + <l><xsl:value-of select="$ref" />_t *R = i->data;</l> + <l>xcb_generic_iterator_t child = <!-- --><xsl:value-of select="$nextfields/nextfield[last()]" />;</l> <l>--i->rem;</l> - <l>i->data = (<xsl:value-of select="$ref" /> *) child.data;</l> + <l>i->data = (<xsl:value-of select="$ref" />_t *) child.data;</l> <l>i->index = child.index;</l> </xsl:when> <xsl:otherwise> <l>--i->rem;</l> <l>++i->data;</l> - <l>i->index += sizeof(<xsl:value-of select="$ref" />);</l> + <l>i->index += sizeof(<xsl:value-of select="$ref" />_t);</l> </xsl:otherwise> </xsl:choose> </function> - <function type="XCBGenericIter" name="{$ref}End"> - <field type="{$ref}Iter" name="i" /> - <l>XCBGenericIter ret;</l> + <function type="xcb_generic_iterator_t" name="{$ref}_end"> + <field type="{$ref}_iterator_t" name="i" /> + <l>xcb_generic_iterator_t ret;</l> <xsl:choose> <xsl:when test="$struct/list[not(@fixed)]"> <l>while(i.rem > 0)</l> <indent> - <l><xsl:value-of select="$ref" />Next(&i);</l> + <l><xsl:value-of select="$ref" />_next(&i);</l> </indent> <l>ret.data = i.data;</l> <l>ret.rem = i.rem;</l> @@ -915,7 +1029,7 @@ authorization from the authors. <xsl:when test="@type = 'number'"> <xsl:if test="$h"> <xsl:text>#define </xsl:text> - <xsl:value-of select="@name" /> + <xsl:value-of select="translate(@name, $lcase, $ucase)" /> <xsl:text> </xsl:text> <xsl:value-of select="@value" /> <xsl:text> @@ -958,7 +1072,7 @@ authorization from the authors. <xsl:template match="typedef" mode="output"> <xsl:if test="$h"> <xsl:text>typedef </xsl:text> - <xsl:value-of select="@oldname" /> + <xsl:value-of select="xcb:get-char-void(@oldname)" /> <xsl:text> </xsl:text> <xsl:value-of select="@newname" /> <xsl:text>; @@ -1159,7 +1273,7 @@ authorization from the authors. <xsl:variable name="padnum"><xsl:number /></xsl:variable> <xsl:call-template name="type-and-name"> - <xsl:with-param name="type" select="'CARD8'" /> + <xsl:with-param name="type" select="'uint8_t'" /> <xsl:with-param name="name"> <xsl:text>pad</xsl:text> <xsl:value-of select="$padnum - 1" /> @@ -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 <sys/uio.h> @@ -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 |