X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fxcb_util.c;h=c6c51891181bdc17678b7a39be61a644e2f857f6;hb=d6d44e1bf09cca8aefbf4ce9875d7f794bf19fb1;hp=3eacc0dab0370dd822561d8ae69ec0d1f9700b12;hpb=bcd1dcec9b242d7e2185c1ae83d3884844a2647f;p=free-sw%2Fxcb%2Flibxcb diff --git a/src/xcb_util.c b/src/xcb_util.c index 3eacc0d..c6c5189 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -201,14 +201,7 @@ static int _xcb_open_decnet(const char *host, const char *protocol, const unsign static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port) { int fd = -1; - struct addrinfo hints = { 0 -#ifdef AI_ADDRCONFIG - | AI_ADDRCONFIG -#endif -#ifdef AI_NUMERICSERV - | AI_NUMERICSERV -#endif - , AF_UNSPEC, SOCK_STREAM }; + struct addrinfo hints; char service[6]; /* "65535" with the trailing '\0' */ struct addrinfo *results, *addr; char *bracket; @@ -216,6 +209,16 @@ static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port) if (protocol && strcmp("tcp",protocol)) return -1; + memset(&hints, 0, sizeof(hints)); +#ifdef AI_ADDRCONFIG + hints.ai_flags |= AI_ADDRCONFIG; +#endif +#ifdef AI_NUMERICSERV + hints.ai_flags |= AI_NUMERICSERV; +#endif + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + #ifdef AF_INET6 /* Allow IPv6 addresses enclosed in brackets. */ if(host[0] == '[' && (bracket = strrchr(host, ']')) && bracket[1] == '\0') @@ -246,13 +249,16 @@ static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port) static int _xcb_open_unix(char *protocol, const char *file) { int fd; - struct sockaddr_un addr = { AF_UNIX }; + struct sockaddr_un addr; if (protocol && strcmp("unix",protocol)) return -1; strcpy(addr.sun_path, file); - + addr.sun_family = AF_UNIX; +#ifdef HAVE_SOCKADDR_SUN_LEN + addr.sun_len = SUN_LEN(&addr); +#endif fd = socket(AF_UNIX, SOCK_STREAM, 0); if(fd == -1) return -1;