From: Peter Harris Date: Tue, 31 Aug 2010 22:33:36 +0000 (-0400) Subject: Merge branch 'master' of git://github.com/topcat/xcb-win32 X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;h=20da10490f8dac75ec9fe1df28cb9e862e171be5;p=free-sw%2Fxcb%2Flibxcb Merge branch 'master' of git://github.com/topcat/xcb-win32 Conflicts: src/xcb_conn.c src/xcb_util.c Signed-off-by: Peter Harris --- 20da10490f8dac75ec9fe1df28cb9e862e171be5 diff --cc src/xcb_conn.c index 803f7aa,870c438..ebaa6e2 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@@ -42,11 -41,12 +41,17 @@@ #include #endif + #ifdef _WIN32 + #include "xcb_windefs.h" + #else + #include + #endif /* _WIN32 */ + +/* SHUT_RDWR is fairly recent and is not available on all platforms */ +#if !defined(SHUT_RDWR) +#define SHUT_RDWR 2 +#endif + typedef struct { uint8_t status; uint8_t pad0[5]; diff --cc src/xcb_in.c index 5a87466,e2f9936..57d7e01 --- a/src/xcb_in.c +++ b/src/xcb_in.c @@@ -37,10 -37,15 +37,16 @@@ #include "xcbint.h" #if USE_POLL #include - #else -#elif !defined _WIN32 ++#endif ++#ifndef _WIN32 #include + #include #endif + #ifdef _WIN32 + #include "xcb_windefs.h" + #endif /* _WIN32 */ + #define XCB_ERROR 0 #define XCB_REPLY 1 #define XCB_XGE_EVENT 35 diff --cc src/xcb_util.c index 5a82ac1,e08a320..0e3728a --- a/src/xcb_util.c +++ b/src/xcb_util.c @@@ -27,11 -27,6 +27,7 @@@ #include #include - #include +#include - #include - #include - #include #ifdef DNETCONN #include #include @@@ -138,8 -126,10 +143,10 @@@ int xcb_parse_display(const char *name return _xcb_parse_display(name, host, NULL, displayp, screenp); } -static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port); +static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short port); + #ifndef _WIN32 static int _xcb_open_unix(char *protocol, const char *file); + #endif /* !WIN32 */ #ifdef DNETCONN static int _xcb_open_decnet(const char *host, char *protocol, const unsigned short port); #endif @@@ -187,39 -169,21 +194,42 @@@ static int _xcb_open(const char *host, return _xcb_open_tcp(host, protocol, port); } } + + #ifndef _WIN32 + filelen = strlen(base) + 1 + sizeof(display) * 3 + 1; + file = malloc(filelen); + if(file == NULL) + return -1; + /* display specifies Unix socket */ - filelen = snprintf(file, sizeof(file), "%s%d", base, display); - if(filelen < 0) +#ifdef HAVE_LAUNCHD + if(strncmp(base, "/tmp/launch", 11) == 0) + actual_filelen = snprintf(file, filelen, "%s:%d", base, display); + else +#endif + actual_filelen = snprintf(file, filelen, "%s%d", base, display); + if(actual_filelen < 0) + { + free(file); return -1; + } /* snprintf may truncate the file */ - filelen = MIN(filelen, sizeof(file) - 1); + filelen = MIN(actual_filelen, filelen - 1); #ifdef HAVE_ABSTRACT_SOCKETS fd = _xcb_open_abstract(protocol, file, filelen); if (fd >= 0 || (errno != ENOENT && errno != ECONNREFUSED)) + { + free(file); return fd; + } + #endif - return _xcb_open_unix(protocol, file); + fd = _xcb_open_unix(protocol, file); + free(file); + + return fd; + #endif /* !_WIN32 */ + return -1; /* if control reaches here then something has gone wrong */ } static int _xcb_socket(int family, int type, int proto)