jpeg pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=8f4834e12cad2c06881af11f8f9163cd3e0ab4d4
commit 8f4834e12cad2c06881af11f8f9163cd3e0ab4d4 Author: Vincent Torri <vincent dot torri at gmail dot com> Date: Tue Dec 15 14:48:36 2015 +0900 Example, Ecore: fix compilation on Windows Summary: The socket API is different on Windows and on Linux. This is the perfect example where we need to abstract the socket API in Eina : 1) to avoid all these includes specific to sockets 2) to avoid on Windows undefined behavior : close(socket); is undefined behavior if socket is indeed a socket Reviewers: jpeg Reviewed By: jpeg Subscribers: cedric, jpeg Projects: #efl Differential Revision: https://phab.enlightenment.org/D3441 --- .../ecore/ecore_fd_handler_gnutls_example.c | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/examples/ecore/ecore_fd_handler_gnutls_example.c b/src/examples/ecore/ecore_fd_handler_gnutls_example.c index 078b5d7..aa8ff3a 100644 --- a/src/examples/ecore/ecore_fd_handler_gnutls_example.c +++ b/src/examples/ecore/ecore_fd_handler_gnutls_example.c @@ -1,15 +1,27 @@ //Compile with: // gcc -o ecore_fd_handler_gnutls_example ecore_fd_handler_gnutls_example.c `pkg-config --cflags --libs ecore gnutls` -#include <Ecore.h> +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <fcntl.h> -#include <netinet/tcp.h> -#include <netinet/in.h> -#include <sys/socket.h> -#include <arpa/inet.h> +#ifdef HAVE_NETINET_TCP_H +# include <netinet/tcp.h> +#endif +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif +#ifdef HAVE_SYS_SOCKET_H +# include <sys/socket.h> +#endif +#ifdef HAVE_ARPA_INET_H +# include <arpa/inet.h> +#endif #include <errno.h> #include <unistd.h> #include <gnutls/gnutls.h> +#include <Ecore.h> /* Ecore_Fd_Handler example * 2010 Mike Blumenkrantz @@ -109,8 +121,13 @@ tcp_connect(void) static void tcp_close(int sd) { +#ifdef _WIN32 + shutdown(sd, SD_BOTH); /* no more receptions */ + closesocket(sd); +#else shutdown(sd, SHUT_RDWR); /* no more receptions */ close(sd); +#endif } static Eina_Bool @@ -185,7 +202,7 @@ main(void) sd = tcp_connect(); /* associate gnutls with socket */ - gnutls_transport_set_ptr(client, (gnutls_transport_ptr_t)sd); + gnutls_transport_set_ptr(client, (gnutls_transport_ptr_t)(uintptr_t)sd); /* add a callback for data being available for send/receive on socket */ if (!ecore_main_fd_handler_add(sd, ECORE_FD_READ | ECORE_FD_WRITE, (Ecore_Fd_Cb)_process_data, client, NULL, NULL)) { --