1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

Fixed compilation on Windows.

This commit is contained in:
Joakim Soderberg 2013-02-11 17:52:23 +01:00 committed by Andy Green
parent 72dfd756d4
commit 63ff120ba5
8 changed files with 33 additions and 14 deletions

View file

@ -841,7 +841,11 @@ libwebsockets_generate_client_handshake(struct libwebsocket_context *context,
/* prepare the expected server accept response */
#ifdef WIN32
n = _snprintf(buf, sizeof(buf), "%s%s", key_b64, magic_websocket_guid);
#else
n = snprintf(buf, sizeof(buf), "%s%s", key_b64, magic_websocket_guid);
#endif
buf[sizeof(buf) - 1] = '\0';
SHA1((unsigned char *)buf, n, (unsigned char *)hash);

View file

@ -24,6 +24,7 @@
#ifdef WIN32
#include <tchar.h>
#include <io.h>
#include <mstcpip.h>
#else
#ifdef LWS_BUILTIN_GETIFADDRS
#include <getifaddrs.h>
@ -572,7 +573,18 @@ int lws_set_socket_options(struct libwebsocket_context *context, int fd)
* didn't find a way to set these per-socket, need to
* tune kernel systemwide values
*/
#elif WIN32
{
DWORD dwBytesRet;
struct tcp_keepalive alive;
alive.onoff = TRUE;
alive.keepalivetime = context->ka_time;
alive.keepaliveinterval = context->ka_interval;
if (WSAIoctl(fd, SIO_KEEPALIVE_VALS, &alive, sizeof(alive),
NULL, 0, &dwBytesRet, NULL, NULL))
return 1;
}
#else
/* set the keepalive conditions we want on it too */
optval = context->ka_time;
@ -2053,10 +2065,10 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
if (info->interface == NULL)
if (info->iface == NULL)
serv_addr.sin_addr.s_addr = INADDR_ANY;
else
interface_to_sa(info->interface, &serv_addr,
interface_to_sa(info->iface, &serv_addr,
sizeof(serv_addr));
serv_addr.sin_port = htons(info->port);

View file

@ -771,7 +771,7 @@ struct libwebsocket_extension {
struct lws_context_creation_info {
int port;
const char *interface;
const char *iface;
struct libwebsocket_protocols *protocols;
struct libwebsocket_extension *extensions;
const char *ssl_cert_filepath;

View file

@ -56,7 +56,13 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
goto bail;
}
n = snprintf((char *)context->service_buffer,
// TODO: Use a truly platform independent snprintf implementation isntead! http://www.ijs.si/software/snprintf/ maybe?
#ifdef WIN32
n = _snprintf(
#else
n = snprintf(
#endif
(char *)context->service_buffer,
sizeof(context->service_buffer),
"%s258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
lws_hdr_simple_ptr(wsi, WSI_TOKEN_KEY));

View file

@ -374,3 +374,4 @@ int lws_server_socket_service(struct libwebsocket_context *context,
}
return 0;
}

View file

@ -971,7 +971,6 @@ all sessions, etc, if it wants
<h2>struct lws_context_creation_info - </h2>
<b>struct lws_context_creation_info</b> {<br>
&nbsp; &nbsp; <i>int</i> <b>port</b>;<br>
&nbsp; &nbsp; <i>const char *</i> <b>interface</b>;<br>
&nbsp; &nbsp; <i>struct libwebsocket_protocols *</i> <b>protocols</b>;<br>
&nbsp; &nbsp; <i>struct libwebsocket_extension *</i> <b>extensions</b>;<br>
&nbsp; &nbsp; <i>const char *</i> <b>ssl_cert_filepath</b>;<br>
@ -991,9 +990,6 @@ all sessions, etc, if it wants
<dd>Port to listen on... you can use 0 to suppress listening on
any port, that's what you want if you are not running a
websocket server at all but just using it as a client
<dt><b>interface</b>
<dd>NULL to bind the listen socket to all interfaces, or the
interface name, eg, "eth2"
<dt><b>protocols</b>
<dd>Array of structures listing supported protocols and a protocol-
specific callback for each one. The list is ended with an

View file

@ -244,7 +244,7 @@ int main(int argc, char **argv)
struct libwebsocket_context *context;
int opts = 0;
char interface_name[128] = "";
const char *interface = NULL;
const char *iface = NULL;
struct libwebsocket *wsi;
const char *address;
int server_port = port;
@ -274,7 +274,7 @@ int main(int argc, char **argv)
case 'i':
strncpy(interface_name, optarg, sizeof interface_name);
interface_name[(sizeof interface_name) - 1] = '\0';
interface = interface_name;
iface = interface_name;
break;
case 'c':
client = 1;
@ -298,7 +298,7 @@ int main(int argc, char **argv)
}
info.port = server_port;
info.interface = interface;
info.iface = iface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
info.extensions = libwebsocket_internal_extensions;

View file

@ -506,7 +506,7 @@ int main(int argc, char **argv)
struct libwebsocket_context *context;
int opts = 0;
char interface_name[128] = "";
const char *interface = NULL;
const char *iface = NULL;
#ifndef WIN32
int syslog_options = LOG_PID | LOG_PERROR;
#endif
@ -546,7 +546,7 @@ int main(int argc, char **argv)
case 'i':
strncpy(interface_name, optarg, sizeof interface_name);
interface_name[(sizeof interface_name) - 1] = '\0';
interface = interface_name;
iface = interface_name;
break;
case 'c':
close_testing = 1;
@ -598,7 +598,7 @@ int main(int argc, char **argv)
}
#endif
info.interface = interface;
info.iface = iface;
info.protocols = protocols;
#ifndef LWS_NO_EXTENSIONS
info.extensions = libwebsocket_internal_extensions;