[Xcb-commit] 3 commits - src

Julien Danjou jdanjou at kemper.freedesktop.org
Wed Jan 11 09:07:48 PST 2012


 src/xcb_auth.c |    9 +++++----
 src/xcb_conn.c |    4 ++++
 src/xcb_util.c |   15 +++++++++++++--
 3 files changed, 22 insertions(+), 6 deletions(-)

New commits:
commit 31b57676e8d7ab6048dbfb145187833fac5e478c
Author: Ryan Pavlik <rpavlik at iastate.edu>
Date:   Wed Jan 11 18:06:50 2012 +0100

    Use WSAStartup()/WSACleanup() on WIN32
    
    The alternative is to use these in every WIN32 application which uses xcb. Doing
    it this way should be safe, as, according to MSDN, "There must be a call to
    WSACleanup for each successful call to WSAStartup. Only the final WSACleanup
    function call performs the actual cleanup. The preceding calls simply decrement
    an internal reference count"
    
    (We should probably also include ws2_32 in Libs.private for libxcb, as anything
    which links with libxcb will also need that, but there seems to be some pkg-config
    issues to resolve first...)
    
    v2: Check for errors so WSAStartup()/WSACleanup() uses are balanced
    v3: Use same indentation style as surrounding code
    
    Reviewed-by: Peter Harris <pharris at opentext.com>
    Signed-off-by: Julien Danjou <julien at danjou.info>

diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index f79de33..725502a 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -315,6 +315,10 @@ void xcb_disconnect(xcb_connection_t *c)
     _xcb_xid_destroy(c);
 
     free(c);
+
+#ifdef _WIN32
+    WSACleanup();
+#endif
 }
 
 /* Private interface */
diff --git a/src/xcb_util.c b/src/xcb_util.c
index 64a1f6d..9329b81 100644
--- a/src/xcb_util.c
+++ b/src/xcb_util.c
@@ -426,11 +426,22 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname,
     if(!parsed) {
         c = _xcb_conn_ret_error(XCB_CONN_CLOSED_PARSE_ERR);
         goto out;
-    } else
+    } else {
+#ifdef _WIN32
+        WSADATA wsaData;
+        if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
+            c = (xcb_connection_t *) &error_connection;
+            goto out;
+        }
+#endif
         fd = _xcb_open(host, protocol, display);
+    }
 
     if(fd == -1) {
         c = _xcb_conn_ret_error(XCB_CONN_ERROR);
+#ifdef _WIN32
+        WSACleanup();
+#endif
         goto out;
     }
 
commit 0e9246def562be97cc816f824f702233a826ec56
Author: Ryan Pavlik <rpavlik at iastate.edu>
Date:   Thu Jan 5 20:57:53 2012 +0000

    Fix include order with Xdmcp on WIN32
    
    Fix a redefinition problem due to include order which shows up when
    building for _WIN32 and libXdmcp is installed, so HASXDMAUTH is enabled
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Peter Harris <pharris at opentext.com>
    Signed-off-by: Julien Danjou <julien at danjou.info>

diff --git a/src/xcb_auth.c b/src/xcb_auth.c
index 21c26b8..ea4ad8f 100644
--- a/src/xcb_auth.c
+++ b/src/xcb_auth.c
@@ -36,6 +36,10 @@
 #include <rpc/types.h>
 #endif
 
+#ifdef HASXDMAUTH
+#include <X11/Xdmcp.h>
+#endif
+
 #ifdef _WIN32
 #include "xcb_windefs.h"
 #else
@@ -48,9 +52,6 @@
 #include "xcb.h"
 #include "xcbint.h"
 
-#ifdef HASXDMAUTH
-#include <X11/Xdmcp.h>
-#endif
 
 enum auth_protos {
 #ifdef HASXDMAUTH
commit 4aa7a2c849a9536febb2dc7773e06c12a69c5213
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Jan 5 20:57:52 2012 +0000

    Fix WIN32 compilation after commit 163c47bdc0d32785d831e4c93fea9ab7e023446b
    
    WIN32 does not have arpa/inet.h, so do not try to include it unless _WIN32 is
    not defined
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Peter Harris <pharris at opentext.com>
    Signed-off-by: Julien Danjou <julien at danjou.info>

diff --git a/src/xcb_auth.c b/src/xcb_auth.c
index 859ab8a..21c26b8 100644
--- a/src/xcb_auth.c
+++ b/src/xcb_auth.c
@@ -30,7 +30,6 @@
 #include <sys/param.h>
 #include <unistd.h>
 #include <stdlib.h>
-#include <arpa/inet.h>
 
 #ifdef __INTERIX
 /* _don't_ ask. interix has INADDR_LOOPBACK in here. */
@@ -40,6 +39,7 @@
 #ifdef _WIN32
 #include "xcb_windefs.h"
 #else
+#include <arpa/inet.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/un.h>
diff --git a/src/xcb_util.c b/src/xcb_util.c
index a55df16..64a1f6d 100644
--- a/src/xcb_util.c
+++ b/src/xcb_util.c
@@ -34,11 +34,11 @@
 #include <stddef.h>
 #include <unistd.h>
 #include <string.h>
-#include <arpa/inet.h>
 
 #ifdef _WIN32
 #include "xcb_windefs.h"
 #else
+#include <arpa/inet.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <netinet/in.h>


More information about the xcb-commit mailing list