summaryrefslogtreecommitdiff
path: root/src/xcb_auth.c
diff options
context:
space:
mode:
authorPeter Harris <pharris@opentext.com>2021-02-01 17:43:52 -0500
committerPeter Harris <pharris@opentext.com>2021-06-04 14:31:13 +0000
commit4b0d9d3868aad8d5f4266821e9eda586e6c2bfa7 (patch)
treed31a073fa5d036d5ec404b539fac44cbc5be18d3 /src/xcb_auth.c
parentcd0fba98a2d0867d505ff1a7ca8d7a7c757acfa2 (diff)
Fix build on Windows
Notable changes: Protect include of unistd.h (and other POSIX headers). Use SOCKET (which is larger than int) and closesocket (because close is not compatible) for sockets. Use <stdint.h>'s intptr_t instead of the non-portable ssize_t. Signed-off-by: Peter Harris <pharris@opentext.com>
Diffstat (limited to 'src/xcb_auth.c')
-rw-r--r--src/xcb_auth.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/xcb_auth.c b/src/xcb_auth.c
index 6937afb..8ebe9a4 100644
--- a/src/xcb_auth.c
+++ b/src/xcb_auth.c
@@ -31,8 +31,6 @@
#include <assert.h>
#include <X11/Xauth.h>
-#include <sys/param.h>
-#include <unistd.h>
#include <stdlib.h>
#include <time.h>
@@ -49,6 +47,8 @@
#endif
#include "xcb_windefs.h"
#else
+#include <sys/param.h>
+#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -271,10 +271,17 @@ static int compute_auth(xcb_auth_info_t *info, Xauth *authptr, struct sockaddr *
to the value returned by either getpeername() or getsockname()
(according to POSIX, applications should not assume a particular
length for `sockaddr_un.sun_path') */
+#ifdef _WIN32
+static struct sockaddr *get_peer_sock_name(int(_stdcall *socket_func)(SOCKET,
+ struct sockaddr *,
+ socklen_t *),
+ int fd)
+#else
static struct sockaddr *get_peer_sock_name(int (*socket_func)(int,
struct sockaddr *,
socklen_t *),
int fd)
+#endif
{
socklen_t socknamelen = sizeof(struct sockaddr) + INITIAL_SOCKNAME_SLACK;
socklen_t actual_socknamelen = socknamelen;