summaryrefslogtreecommitdiff
path: root/test-server
diff options
context:
space:
mode:
authorPeter Hinz <cerebusrc@gmail.com>2011-03-02 22:03:47 +0000
committerAndy Green <andy@warmcat.com>2011-03-02 22:03:47 +0000
commit56885f308437645d75f9cae9c6c5cdcbeaa7371d (patch)
treea0a9ba7444220b7d05704af08b1944e5665ec4f8 /test-server
parent385e7ad0344f740ef4edb1790827096df96d5583 (diff)
introduce win32 build capability
This adds win32 build compatability to libwebsockets. The patch is from Peter Hinz, Andy Green has cleaned it up a bit and possibly broken win32 compatability since I can't test it, so there may be followup patches. It compiles fine under Linux after this patch anyway. Much of the patch is changing a reserved keyword for Visual C compiler "this" to "context", but there is no real C99 support in the MSFT compiler even though it is 2011 so C99 style array declarations have been mangled back into "ancient C" style. Some windows-isms are also added like closesocket() but these are quite localized. Win32 random is just using C library random() call at the moment vs Linux /dev/urandom. canonical hostname detection is broken in win32 at the moment. Signed-off-by: Peter Hinz <cerebusrc@gmail.com> Signed-off-by: Andy Green <andy@warmcat.com>
Diffstat (limited to 'test-server')
-rw-r--r--test-server/test-client.c22
-rw-r--r--test-server/test-server-extpoll.c30
-rw-r--r--test-server/test-server.c72
3 files changed, 63 insertions, 61 deletions
diff --git a/test-server/test-client.c b/test-server/test-client.c
index 09528c2..c1abff7 100644
--- a/test-server/test-client.c
+++ b/test-server/test-client.c
@@ -26,7 +26,6 @@
#include <string.h>
#include "../lib/libwebsockets.h"
-#include <poll.h>
static unsigned int opts;
static int was_closed;
@@ -147,17 +146,20 @@ callback_lws_mirror(struct libwebsocket_context * this,
/* list of supported protocols and callbacks */
static struct libwebsocket_protocols protocols[] = {
-
- [PROTOCOL_DUMB_INCREMENT] = {
- .name = "dumb-increment-protocol",
- .callback = callback_dumb_increment,
+ {
+ "dumb-increment-protocol",
+ callback_dumb_increment,
+ 0,
},
- [PROTOCOL_LWS_MIRROR] = {
- .name = "lws-mirror-protocol",
- .callback = callback_lws_mirror,
+ {
+ "lws-mirror-protocol",
+ callback_lws_mirror,
+ 0,
},
- [DEMO_PROTOCOL_COUNT] = { /* end of list */
- .callback = NULL
+ { /* end of list */
+ NULL,
+ NULL,
+ 0
}
};
diff --git a/test-server/test-server-extpoll.c b/test-server/test-server-extpoll.c
index 29595a1..803d5dc 100644
--- a/test-server/test-server-extpoll.c
+++ b/test-server/test-server-extpoll.c
@@ -393,24 +393,24 @@ callback_lws_mirror(struct libwebsocket_context * this,
static struct libwebsocket_protocols protocols[] = {
/* first protocol must always be HTTP handler */
- [PROTOCOL_HTTP] = {
- .name = "http-only",
- .callback = callback_http,
+
+ {
+ "http-only", /* name */
+ callback_http, /* callback */
+ 0 /* per_session_data_size */
},
- [PROTOCOL_DUMB_INCREMENT] = {
- .name = "dumb-increment-protocol",
- .callback = callback_dumb_increment,
- .per_session_data_size =
- sizeof(struct per_session_data__dumb_increment),
+ {
+ "dumb-increment-protocol",
+ callback_dumb_increment,
+ sizeof(struct per_session_data__dumb_increment),
},
- [PROTOCOL_LWS_MIRROR] = {
- .name = "lws-mirror-protocol",
- .callback = callback_lws_mirror,
- .per_session_data_size =
- sizeof(struct per_session_data__lws_mirror),
+ {
+ "lws-mirror-protocol",
+ callback_lws_mirror,
+ sizeof(struct per_session_data__lws_mirror)
},
- [DEMO_PROTOCOL_COUNT] = { /* end of list */
- .callback = NULL
+ {
+ NULL, NULL, 0 /* End of list */
}
};
diff --git a/test-server/test-server.c b/test-server/test-server.c
index 2620908..3cecb7f 100644
--- a/test-server/test-server.c
+++ b/test-server/test-server.c
@@ -60,7 +60,7 @@ enum demo_protocols {
/* this protocol server (always the first one) just knows how to do HTTP */
-static int callback_http(struct libwebsocket_context * this,
+static int callback_http(struct libwebsocket_context * context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
void *in, size_t len)
@@ -124,29 +124,29 @@ dump_handshake_info(struct lws_tokens *lwst)
{
int n;
static const char *token_names[] = {
- [WSI_TOKEN_GET_URI] = "GET URI",
- [WSI_TOKEN_HOST] = "Host",
- [WSI_TOKEN_CONNECTION] = "Connection",
- [WSI_TOKEN_KEY1] = "key 1",
- [WSI_TOKEN_KEY2] = "key 2",
- [WSI_TOKEN_PROTOCOL] = "Protocol",
- [WSI_TOKEN_UPGRADE] = "Upgrade",
- [WSI_TOKEN_ORIGIN] = "Origin",
- [WSI_TOKEN_DRAFT] = "Draft",
- [WSI_TOKEN_CHALLENGE] = "Challenge",
+ /*[WSI_TOKEN_GET_URI] =*/ "GET URI",
+ /*[WSI_TOKEN_HOST] =*/ "Host",
+ /*[WSI_TOKEN_CONNECTION] =*/ "Connection",
+ /*[WSI_TOKEN_KEY1] =*/ "key 1",
+ /*[WSI_TOKEN_KEY2] =*/ "key 2",
+ /*[WSI_TOKEN_PROTOCOL] =*/ "Protocol",
+ /*[WSI_TOKEN_UPGRADE] =*/ "Upgrade",
+ /*[WSI_TOKEN_ORIGIN] =*/ "Origin",
+ /*[WSI_TOKEN_DRAFT] =*/ "Draft",
+ /*[WSI_TOKEN_CHALLENGE] =*/ "Challenge",
/* new for 04 */
- [WSI_TOKEN_KEY] = "Key",
- [WSI_TOKEN_VERSION] = "Version",
- [WSI_TOKEN_SWORIGIN] = "Sworigin",
+ /*[WSI_TOKEN_KEY] =*/ "Key",
+ /*[WSI_TOKEN_VERSION] =*/ "Version",
+ /*[WSI_TOKEN_SWORIGIN] =*/ "Sworigin",
/* new for 05 */
- [WSI_TOKEN_EXTENSIONS] = "Extensions",
+ /*[WSI_TOKEN_EXTENSIONS] =*/ "Extensions",
/* client receives these */
- [WSI_TOKEN_ACCEPT] = "Accept",
- [WSI_TOKEN_NONCE] = "Nonce",
- [WSI_TOKEN_HTTP] = "Http",
+ /*[WSI_TOKEN_ACCEPT] =*/ "Accept",
+ /*[WSI_TOKEN_NONCE] =*/ "Nonce",
+ /*[WSI_TOKEN_HTTP] =*/ "Http",
};
for (n = 0; n < WSI_TOKEN_COUNT; n++) {
@@ -172,7 +172,7 @@ struct per_session_data__dumb_increment {
};
static int
-callback_dumb_increment(struct libwebsocket_context * this,
+callback_dumb_increment(struct libwebsocket_context * context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
void *user, void *in, size_t len)
@@ -249,7 +249,7 @@ static int ringbuffer_head;
static int
-callback_lws_mirror(struct libwebsocket_context * this,
+callback_lws_mirror(struct libwebsocket_context * context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason,
void *user, void *in, size_t len)
@@ -286,7 +286,7 @@ callback_lws_mirror(struct libwebsocket_context * this,
MAX_MESSAGE_QUEUE) < (MAX_MESSAGE_QUEUE - 15))
libwebsocket_rx_flow_control(wsi, 1);
- libwebsocket_callback_on_writable(this, wsi);
+ libwebsocket_callback_on_writable(context, wsi);
}
break;
@@ -343,24 +343,24 @@ callback_lws_mirror(struct libwebsocket_context * this,
static struct libwebsocket_protocols protocols[] = {
/* first protocol must always be HTTP handler */
- [PROTOCOL_HTTP] = {
- .name = "http-only",
- .callback = callback_http,
+
+ {
+ "http-only", /* name */
+ callback_http, /* callback */
+ 0 /* per_session_data_size */
},
- [PROTOCOL_DUMB_INCREMENT] = {
- .name = "dumb-increment-protocol",
- .callback = callback_dumb_increment,
- .per_session_data_size =
- sizeof(struct per_session_data__dumb_increment),
+ {
+ "dumb-increment-protocol",
+ callback_dumb_increment,
+ sizeof(struct per_session_data__dumb_increment),
},
- [PROTOCOL_LWS_MIRROR] = {
- .name = "lws-mirror-protocol",
- .callback = callback_lws_mirror,
- .per_session_data_size =
- sizeof(struct per_session_data__lws_mirror),
+ {
+ "lws-mirror-protocol",
+ callback_lws_mirror,
+ sizeof(struct per_session_data__lws_mirror)
},
- [DEMO_PROTOCOL_COUNT] = { /* end of list */
- .callback = NULL
+ {
+ NULL, NULL, 0 /* End of list */
}
};