Remove websock-w32.h
authorPatrick Gansterer <paroga@paroga.com>
Sat, 29 Mar 2014 07:25:58 +0000 (08:25 +0100)
committerPatrick Gansterer <paroga@paroga.com>
Sat, 29 Mar 2014 07:25:58 +0000 (08:25 +0100)
CMakeLists.txt
lib/client-handshake.c
lib/client.c
lib/libwebsockets.c
lib/libwebsockets.h
lib/private-libwebsockets.h
lib/server.c
win32port/win32helpers/websock-w32.h [deleted file]

index 9d02dce..f297c58 100644 (file)
@@ -296,10 +296,6 @@ endif()
 # Add helper files for Windows.
 if (WIN32)
        set(WIN32_HELPERS_PATH win32port/win32helpers)
-
-       list(APPEND HDR_PUBLIC
-               ${WIN32_HELPERS_PATH}/websock-w32.h
-               )
        include_directories(${WIN32_HELPERS_PATH})
 else(WIN32)
        # Unix.
@@ -493,7 +489,7 @@ if (NOT LWS_WITHOUT_TESTAPPS)
        #
        # Helper function for adding a test app.
        #
-       macro(create_test_app TEST_NAME MAIN_SRC WIN32_SRCS WIN32_HDRS)
+       macro(create_test_app TEST_NAME MAIN_SRC)
                
                set(TEST_SRCS ${MAIN_SRC})
                set(TEST_HDR)
@@ -503,12 +499,12 @@ if (NOT LWS_WITHOUT_TESTAPPS)
                                ${WIN32_HELPERS_PATH}/getopt.c
                                ${WIN32_HELPERS_PATH}/getopt_long.c
                                ${WIN32_HELPERS_PATH}/gettimeofday.c
-                               ${WIN32_SRCS})
+                       )
 
                        list(APPEND TEST_HDR 
                                ${WIN32_HELPERS_PATH}/getopt.h
                                ${WIN32_HELPERS_PATH}/gettimeofday.h
-                               ${WIN32_HDRS})
+                       )
                endif(WIN32)
 
                source_group("Headers Private"   FILES ${TEST_HDR})
@@ -549,20 +545,14 @@ if (NOT LWS_WITHOUT_TESTAPPS)
                # test-server
                #
                if (NOT LWS_WITHOUT_TEST_SERVER)
-                       create_test_app(test-server
-                               "test-server/test-server.c"
-                               ""
-                               "${WIN32_HELPERS_PATH}/websock-w32.h")
+                       create_test_app(test-server "test-server/test-server.c")
                endif()
 
                #
                # test-server-extpoll
                #
                if (NOT LWS_WITHOUT_TEST_SERVER_EXTPOLL)
-                       create_test_app(test-server-extpoll
-                               "test-server/test-server.c"
-                               ""
-                               "${WIN32_HELPERS_PATH}/websock-w32.h")
+                       create_test_app(test-server-extpoll "test-server/test-server.c")
                        # Set defines for this executable only.
                        set_property(
                                TARGET test-server-extpoll
@@ -658,39 +648,27 @@ if (NOT LWS_WITHOUT_TESTAPPS)
                # test-client
                #
                if (NOT LWS_WITHOUT_TEST_CLIENT)
-                       create_test_app(test-client
-                               "test-server/test-client.c"
-                               ""
-                               "")
+                       create_test_app(test-client "test-server/test-client.c")
                endif()
 
                #
                # test-fraggle
                #
                if (NOT LWS_WITHOUT_TEST_FRAGGLE)
-                       create_test_app(test-fraggle
-                               "test-server/test-fraggle.c"
-                               ""
-                               "")
+                       create_test_app(test-fraggle "test-server/test-fraggle.c")
                endif()
 
                #
                # test-ping
                #
                if (NOT LWS_WITHOUT_TEST_PING)
-                       create_test_app(test-ping
-                               "test-server/test-ping.c"
-                               ""
-                               "")
+                       create_test_app(test-ping "test-server/test-ping.c")
                endif()
                #
                # test-echo
                #
                if (NOT WITHOUT_TEST_ECHO)
-                       create_test_app(test-echo
-                               "test-server/test-echo.c"
-                               ""
-                               "")
+                       create_test_app(test-echo "test-server/test-echo.c")
                endif()
 
        endif(NOT LWS_WITHOUT_CLIENT)
index 061a4f9..88dfd0f 100644 (file)
@@ -4,7 +4,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
        struct libwebsocket_context *context,
        struct libwebsocket *wsi
 ) {
-       struct pollfd pfd;
+       struct libwebsocket_pollfd pfd;
 #ifdef LWS_USE_IPV6
        struct sockaddr_in6 server_addr6;
        struct sockaddr_in6 client_addr6;
index 79b0bbe..5108501 100644 (file)
@@ -35,7 +35,7 @@
 #endif
 
 int lws_client_socket_service(struct libwebsocket_context *context,
-                               struct libwebsocket *wsi, struct pollfd *pollfd)
+                               struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)
 {
        int n;
        char *p = (char *)&context->service_buffer[0];
index 5eefbb3..0845e07 100644 (file)
@@ -79,12 +79,12 @@ static const char * const log_level_names[] = {
 #ifndef LWS_NO_CLIENT
        extern int lws_client_socket_service(
                struct libwebsocket_context *context,
-               struct libwebsocket *wsi, struct pollfd *pollfd);
+               struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
 #endif
 #ifndef LWS_NO_SERVER
        extern int lws_server_socket_service(
                struct libwebsocket_context *context,
-               struct libwebsocket *wsi, struct pollfd *pollfd);
+               struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
 #endif
 
 
@@ -768,7 +768,7 @@ LWS_VISIBLE int lws_send_pipe_choked(struct libwebsocket *wsi)
 #ifdef _WIN32
        return wsi->sock_send_blocking;
 #else
-       struct pollfd fds;
+       struct libwebsocket_pollfd fds;
 
        /* treat the fact we got a truncated send pending as if we're choked */
        if (wsi->truncated_send_len)
@@ -792,7 +792,7 @@ LWS_VISIBLE int lws_send_pipe_choked(struct libwebsocket *wsi)
 
 int
 lws_handle_POLLOUT_event(struct libwebsocket_context *context,
-                               struct libwebsocket *wsi, struct pollfd *pollfd)
+                               struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)
 {
        int n;
 
@@ -978,7 +978,7 @@ libwebsocket_service_timeout_check(struct libwebsocket_context *context,
        return 0;
 }
 
-static int lws_poll_listen_fd(struct pollfd* fd)
+static int lws_poll_listen_fd(struct libwebsocket_pollfd* fd)
 {
 #ifdef _WIN32
        fd_set readfds;
@@ -1020,7 +1020,7 @@ static int lws_poll_listen_fd(struct pollfd* fd)
 
 LWS_VISIBLE int
 libwebsocket_service_fd(struct libwebsocket_context *context,
-                                                         struct pollfd *pollfd)
+                                                         struct libwebsocket_pollfd *pollfd)
 {
        struct libwebsocket *wsi;
        int n;
@@ -1318,7 +1318,7 @@ handled:
 LWS_VISIBLE void 
 libwebsocket_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
 {
-       struct pollfd eventfd;
+       struct libwebsocket_pollfd eventfd;
        struct lws_io_watcher *lws_io = (struct lws_io_watcher*)watcher;
        struct libwebsocket_context *context = lws_io->context;
 
@@ -1498,7 +1498,7 @@ libwebsocket_service(struct libwebsocket_context *context, int timeout_ms)
        int i;
        DWORD ev;
        WSANETWORKEVENTS networkevents;
-       struct pollfd *pfd;
+       struct libwebsocket_pollfd *pfd;
 #else
        int m;
        char buf;
@@ -1730,7 +1730,7 @@ lws_change_pollfd(struct libwebsocket *wsi, int _and, int _or)
        struct libwebsocket_context *context = wsi->protocol->owning_server;
        int tid;
        int sampled_tid;
-       struct pollfd *pfd;
+       struct libwebsocket_pollfd *pfd;
        struct libwebsocket_pollargs pa;
 #ifdef _WIN32
        long networkevents = FD_WRITE;
@@ -2263,13 +2263,13 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
        context->max_fds = getdtablesize();
        lwsl_notice(" static allocation: %u + (%u x %u fds) = %u bytes\n",
                sizeof(struct libwebsocket_context),
-               sizeof(struct pollfd) + sizeof(struct libwebsocket *),
+               sizeof(struct libwebsocket_pollfd) + sizeof(struct libwebsocket *),
                context->max_fds,
                sizeof(struct libwebsocket_context) +
-               ((sizeof(struct pollfd) + sizeof(struct libwebsocket *)) *
+               ((sizeof(struct libwebsocket_pollfd) + sizeof(struct libwebsocket *)) *
                                                             context->max_fds));
 
-       context->fds = (struct pollfd *)malloc(sizeof(struct pollfd) *
+       context->fds = (struct libwebsocket_pollfd *)malloc(sizeof(struct libwebsocket_pollfd) *
                                                              context->max_fds);
        if (context->fds == NULL) {
                lwsl_err("Unable to allocate fds array for %d connections\n",
index 5c41a57..5fae696 100644 (file)
@@ -36,7 +36,6 @@ extern "C" {
 #include <ws2tcpip.h>
 #include <stddef.h>
 #include <basetsd.h>
-#include "websock-w32.h"
 
 #define strcasecmp stricmp
 #define getdtablesize() 30000
@@ -204,6 +203,15 @@ struct libwebsocket_pollargs {
     int prev_events;   // the previous event mask
 };
 
+#ifdef _WIN32
+struct libwebsocket_pollfd {
+       SOCKET fd;
+       SHORT events;
+       SHORT revents;
+};
+#else
+#define libwebsocket_pollfd pollfd
+#endif
 
 #ifndef LWS_NO_EXTENSIONS
 enum libwebsocket_extension_callback_reasons {
@@ -990,7 +998,7 @@ libwebsocket_sigint_cb(
 
 LWS_VISIBLE LWS_EXTERN int
 libwebsocket_service_fd(struct libwebsocket_context *context,
-                                                        struct pollfd *pollfd);
+                                                        struct libwebsocket_pollfd *pollfd);
 
 LWS_VISIBLE LWS_EXTERN void *
 libwebsocket_context_user(struct libwebsocket_context *context);
index e8dce85..6116931 100644 (file)
@@ -70,6 +70,9 @@
 #define LWS_EWOULDBLOCK WSAEWOULDBLOCK
 #define LWS_POLLIN (FD_READ | FD_ACCEPT)
 #define LWS_POLLOUT (FD_WRITE)
+#define MSG_NOSIGNAL 0
+#define SHUT_RDWR SD_BOTH
+#define SOL_TCP IPPROTO_TCP
 
 #define compatible_close(fd) closesocket(fd);
 #ifdef __MINGW64__
 #include <winsock2.h>
 #include <windows.h>
 #define LWS_INVALID_FILE INVALID_HANDLE_VALUE
+
+#if defined(__MINGW32__) || defined(__MINGW64__) || _WIN32_WINNT < 0x0600
+#define POLLIN  0x01
+#define POLLOUT 0x04
+#define POLLERR 0x08
+#define POLLHUP 0x10
+#endif
 #else
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -287,7 +297,7 @@ struct libwebsocket_context {
 #ifdef _WIN32
        WSAEVENT *events;
 #endif
-       struct pollfd *fds;
+       struct libwebsocket_pollfd *fds;
        struct libwebsocket **lws_lookup; /* fd to wsi */
        int fds_count;
 #ifdef LWS_USE_LIBEV
@@ -570,7 +580,7 @@ libwebsockets_generate_client_handshake(struct libwebsocket_context *context,
 
 LWS_EXTERN int
 lws_handle_POLLOUT_event(struct libwebsocket_context *context,
-                             struct libwebsocket *wsi, struct pollfd *pollfd);
+                             struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
 #ifndef LWS_NO_EXTENSIONS
 LWS_EXTERN int
 lws_any_extension_handled(struct libwebsocket_context *context,
index edb9449..71aaabb 100644 (file)
@@ -99,7 +99,7 @@ libwebsocket_create_new_server_wsi(struct libwebsocket_context *context)
 }
 
 int lws_server_socket_service(struct libwebsocket_context *context,
-                       struct libwebsocket *wsi, struct pollfd *pollfd)
+                       struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)
 {
        struct libwebsocket *new_wsi;
        int accept_fd;
diff --git a/win32port/win32helpers/websock-w32.h b/win32port/win32helpers/websock-w32.h
deleted file mode 100644 (file)
index 9e30456..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef __WEB_SOCK_W32_H__
-#define __WEB_SOCK_W32_H__
-
-// Windows uses _DEBUG and NDEBUG
-#ifdef _DEBUG
-#undef DEBUG
-#define DEBUG 1
-#endif
-
-#pragma warning(disable : 4996)
-
-#define MSG_NOSIGNAL 0
-#define SHUT_RDWR SD_BOTH
-
-#define SOL_TCP IPPROTO_TCP
-
-#ifdef  __MINGW64__                                                             
-#define DEF_POLL_STUFF
-#endif
-#ifdef  __MINGW32__                                                             
-#define DEF_POLL_STUFF
-#endif
-
-#if _WIN32_WINNT < 0x0600
-#define DEF_POLL_STUFF
-#endif
-
-#ifdef DEF_POLL_STUFF
-
-#include <winsock2.h>
-
-typedef struct pollfd {
-       SOCKET fd;
-       short  events;
-       short  revents;
-} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
-
-#define POLLIN      0x0001      /* any readable data available   */
-#define POLLOUT     0x0004      /* file descriptor is writeable  */
-#define POLLERR     0x0008      /* some poll error occurred      */
-#define POLLHUP     0x0010      /* file descriptor was "hung up" */
-#define POLLNVAL    0x0020             /* requested events "invalid"    */
-
-#endif
-
-/* override configure because we are not using Makefiles */
-
-#define LWS_NO_FORK
-
-/* windows can't cope with this idea, needs assets in cwd */
-
-#ifndef INSTALL_DATADIR
-#define INSTALL_DATADIR "."
-#endif
-
-#endif