CMake support + fixed windows build.
- Finalized CMake support (tested on windows only so far).
- Uses a generated lws_config.h that is included in
private-libwebsocket to pass defines, only used if CMAKE_BUILD is set.
- Support for SSL on Windows.
- Initial support for CyaSSL replacement of OpenSSL (This has been added
to my older CMake-fork but haven't been tested on this version yet).
- Fixed windows build (see below for details).
- Fixed at least the 32-bit Debug build for the existing Visual Studio
Project. (Not to keen fixing all the others when we have CMake support
anyway (which can generate much better project files)...)
- BUGFIXES:
- handshake.c
- used C99 definition of handshake_0405 function
- libwebsocket.c
- syslog not available on windows, put in ifdefs.
- Fixed previous known crash bug on Windows where WSAPoll in
Ws2_32.dll would not be present, causing the poll function pointer
being set to NULL.
- Uninitialized variable context->listen_service_extraseen would
result in stack overflow because of infinite recursion. Fixed by
initializing in libwebsocket_create_context
- SO_REUSADDR means something different on Windows compared to Unix.
- Setting a socket to nonblocking is done differently on Windows.
(This should probably broken out into a helper function instead)
- lwsl_emit_syslog -> lwsl_emit_stderr on Windows.
- private-libwebsocket.h
- PATH_MAX is not available on Windows, define as MAX_PATH
- Always define LWS_NO_DAEMONIZE on windows.
- Don't define lws_latency as inline that does nothing. inline is not
support by the Microsoft compiler, replaced with an empty define
instead. (It's __inline in MSVC)
- server.c
- Fixed nonblock call on windows
- test-ping.c
- Don't use C99 features (Microsoft compiler does not support it).
- Move non-win32 headers into ifdefs.
- Skip use of sighandler on Windows.
- test-server.c
- ifdef syslog parts on Windows.
diff --git a/test-server/test-ping.c b/test-server/test-ping.c
index ec2df1f..f83fe92 100644
--- a/test-server/test-ping.c
+++ b/test-server/test-ping.c
@@ -29,13 +29,15 @@
#include <sys/time.h>
#include <sys/types.h>
+#ifndef WIN32
#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <poll.h>
+#endif
+
#include <netdb.h>
-#include <sys/ioctl.h>
-
#include "../lib/libwebsockets.h"
-#include <poll.h>
/*
* this is specified in the 04 standard, control frames can only have small
@@ -278,13 +280,13 @@
static struct libwebsocket_protocols protocols[] = {
- [PROTOCOL_LWS_MIRROR] = {
- .name = "lws-mirror-protocol",
- .callback = callback_lws_mirror,
- .per_session_data_size = sizeof (struct per_session_data__ping),
+ {
+ "lws-mirror-protocol",
+ callback_lws_mirror,
+ sizeof (struct per_session_data__ping),
},
- [DEMO_PROTOCOL_COUNT] = { /* end of list */
- .callback = NULL
+ {
+ NULL, NULL, 0/* end of list */
}
};
@@ -304,7 +306,7 @@
{ NULL, 0, 0, 0 }
};
-
+#ifndef WIN32
static void
signal_handler(int sig, siginfo_t *si, void *v)
{
@@ -313,7 +315,7 @@
gettimeofday(&tv, NULL);
interrupted_time = (tv.tv_sec * 1000000) + tv.tv_usec;
}
-
+#endif
int main(int argc, char **argv)
{
@@ -323,9 +325,11 @@
struct libwebsocket_context *context;
char protocol_name[256];
char ip[30];
+#ifndef WIN32
struct sigaction sa;
- struct timeval tv;
struct winsize w;
+#endif
+ struct timeval tv;
unsigned long oldus = 0;
unsigned long l;
int ietf_version = -1;
@@ -401,11 +405,12 @@
}
}
-
+#ifndef WIN32
if (isatty(STDOUT_FILENO))
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1)
if (w.ws_col > 0)
screen_width = w.ws_col;
+#endif
context = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,
protocols,
@@ -441,12 +446,13 @@
fprintf(stderr, "Websocket PING %s (%s) %d bytes of data.\n",
peer_name, ip, size);
+#ifndef WIN32
/* set the ^C handler */
-
sa.sa_sigaction = signal_handler;
sa.sa_flags = SA_SIGINFO;
sigemptyset(&sa.sa_mask);
sigaction(SIGINT, &sa, NULL);
+#endif
gettimeofday(&tv, NULL);
started = (tv.tv_sec * 1000000) + tv.tv_usec;