Merge branch 'master' of git://github.com/topcat/xcb-win32
authorPeter Harris <pharris@opentext.com>
Tue, 31 Aug 2010 22:33:36 +0000 (18:33 -0400)
committerPeter Harris <pharris@opentext.com>
Tue, 31 Aug 2010 22:35:20 +0000 (18:35 -0400)
Conflicts:
src/xcb_conn.c
src/xcb_util.c

Signed-off-by: Peter Harris <pharris@opentext.com>
1  2 
src/xcb_auth.c
src/xcb_conn.c
src/xcb_in.c
src/xcb_util.c

diff --cc src/xcb_auth.c
Simple merge
diff --cc src/xcb_conn.c
  #include <sys/select.h>
  #endif
  
+ #ifdef _WIN32
+ #include "xcb_windefs.h"
+ #else
+ #include <netinet/in.h>
+ #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
  #include "xcbint.h"
  #if USE_POLL
  #include <poll.h>
- #else
 -#elif !defined _WIN32
++#endif
++#ifndef _WIN32
  #include <sys/select.h>
+ #include <sys/socket.h>
  #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
  
  #include <assert.h>
  #include <sys/types.h>
- #include <sys/socket.h>
 +#include <limits.h>
- #include <sys/un.h>
- #include <netinet/in.h>
- #include <netinet/tcp.h>
  #ifdef DNETCONN
  #include <netdnet/dnetdb.h>
  #include <netdnet/dn.h>
@@@ -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)