From 19028ebab4f3c097c8e87d3b532b80a5c1369eae Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Wed, 25 Jan 2017 20:27:13 -0500 Subject: Fix sharkd compiling on Windows Change-Id: I8c614189159f1263d9452d495cee34d1a2c1bfcb Reviewed-on: https://code.wireshark.org/review/19790 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- sharkd_daemon.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'sharkd_daemon.c') diff --git a/sharkd_daemon.c b/sharkd_daemon.c index 1f7981b9ed..408c6dbd8d 100644 --- a/sharkd_daemon.c +++ b/sharkd_daemon.c @@ -30,13 +30,40 @@ #include #include #include + +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_SYS_SOCKET_H #include -#include +#endif + +#ifdef HAVE_NETINET_IN_H #include +#endif + +#ifndef _WIN32 +#include #include +#endif + +/* +#if defined(_WIN32) + #ifdef HAVE_WINDOWS_H + #include + #endif + + #include + + #ifdef HAVE_WINSOCK2_H + #include + #endif +#endif +*/ +#ifdef HAVE_ARPA_INET_H #include +#endif #include @@ -49,6 +76,7 @@ socket_init(char *path) { int fd = -1; +#ifndef _WIN32 if (!strncmp(path, "unix:", 5)) { struct sockaddr_un s_un; @@ -79,8 +107,9 @@ socket_init(char *path) } } +#endif #ifdef SHARKD_TCP_SUPPORT - else if (!strncmp(path, "tcp:", 4)) + if (!strncmp(path, "tcp:", 4)) { struct sockaddr_in s_in; int one = 1; @@ -115,24 +144,28 @@ socket_init(char *path) return -1; } } -#endif else { +#endif return -1; +#ifdef SHARKD_TCP_SUPPORT } +#endif +#ifndef _WIN32 if (listen(fd, SOMAXCONN)) { close(fd); return -1; } - +#endif return fd; } int sharkd_init(int argc, char **argv) { +#ifndef _WIN32 int fd; pid_t pid; @@ -168,12 +201,14 @@ sharkd_init(int argc, char **argv) } _server_fd = fd; +#endif return 0; } int sharkd_loop(void) { +#ifndef _WIN32 while (1) { int fd; @@ -205,7 +240,7 @@ sharkd_loop(void) close(fd); } - +#endif return 0; } -- cgit v1.2.1