FS-10167: Fixed small ISO C compliancy issue for windows build vs linux build of testwebsock

This commit is contained in:
Shane Bryldt 2017-03-28 16:07:01 -05:00
parent 61cdc9af3a
commit 5713f513b6

View File

@ -1,6 +1,10 @@
#include <ks.h> #include <ks.h>
#include <tap.h> #include <tap.h>
#ifdef _WINDOWS_
#undef unlink
#define unlink _unlink
#endif
static char v4[48] = ""; static char v4[48] = "";
static char v6[48] = ""; static char v6[48] = "";
@ -19,7 +23,7 @@ typedef struct ssl_profile_s {
char chain[512]; char chain[512];
} ssl_profile_t; } ssl_profile_t;
static int init_ssl(ssl_profile_t *profile) static int init_ssl(ssl_profile_t *profile)
{ {
const char *err = ""; const char *err = "";
@ -101,12 +105,12 @@ void server_callback(ks_socket_t server_sock, ks_socket_t client_sock, ks_sockad
} }
printf("WS %s SERVER SOCK %d connection from %s:%u\n", tcp_data->ssl ? "SSL" : "PLAIN", (int)server_sock, addr->host, addr->port); printf("WS %s SERVER SOCK %d connection from %s:%u\n", tcp_data->ssl ? "SSL" : "PLAIN", (int)server_sock, addr->host, addr->port);
if (kws_init(&kws, client_sock, tcp_data->server_profile.ssl_ctx, NULL, KWS_BLOCK, tcp_data->pool) != KS_STATUS_SUCCESS) { if (kws_init(&kws, client_sock, tcp_data->server_profile.ssl_ctx, NULL, KWS_BLOCK, tcp_data->pool) != KS_STATUS_SUCCESS) {
printf("WS SERVER CREATE FAIL\n"); printf("WS SERVER CREATE FAIL\n");
goto end; goto end;
} }
do { do {
bytes = kws_read_frame(kws, &oc, &data); bytes = kws_read_frame(kws, &oc, &data);
@ -119,7 +123,7 @@ void server_callback(ks_socket_t server_sock, ks_socket_t client_sock, ks_sockad
} while(zstr_buf((char *)data) || strcmp((char *)data, __MSG)); } while(zstr_buf((char *)data) || strcmp((char *)data, __MSG));
bytes = kws_write_frame(kws, WSOC_TEXT, (char *)data, strlen((char *)data)); bytes = kws_write_frame(kws, WSOC_TEXT, (char *)data, strlen((char *)data));
printf("WS SERVER WRITE %ld bytes\n", (long)bytes); printf("WS SERVER WRITE %ld bytes\n", (long)bytes);
end: end:
@ -183,7 +187,7 @@ static int test_ws(char *ip, int ssl)
printf("WS CLIENT Can't set ADDR\n"); printf("WS CLIENT Can't set ADDR\n");
goto end; goto end;
} }
if ((tcp_data.sock = socket(family, SOCK_STREAM, IPPROTO_TCP)) == KS_SOCK_INVALID) { if ((tcp_data.sock = socket(family, SOCK_STREAM, IPPROTO_TCP)) == KS_SOCK_INVALID) {
r = 0; r = 0;
printf("WS CLIENT Can't create sock family %d\n", family); printf("WS CLIENT Can't create sock family %d\n", family);
@ -203,7 +207,7 @@ static int test_ws(char *ip, int ssl)
ks_addr_set(&addr, ip, tcp_port, family); ks_addr_set(&addr, ip, tcp_port, family);
cl_sock = ks_socket_connect(SOCK_STREAM, IPPROTO_TCP, &addr); cl_sock = ks_socket_connect(SOCK_STREAM, IPPROTO_TCP, &addr);
printf("WS %s CLIENT SOCKET %d %s %d\n", ssl ? "SSL" : "PLAIN", (int)cl_sock, addr.host, addr.port); printf("WS %s CLIENT SOCKET %d %s %d\n", ssl ? "SSL" : "PLAIN", (int)cl_sock, addr.host, addr.port);
if (kws_init(&kws, cl_sock, tcp_data.client_profile.ssl_ctx, "/verto:tatooine.freeswitch.org:verto", KWS_BLOCK, pool) != KS_STATUS_SUCCESS) { if (kws_init(&kws, cl_sock, tcp_data.client_profile.ssl_ctx, "/verto:tatooine.freeswitch.org:verto", KWS_BLOCK, pool) != KS_STATUS_SUCCESS) {
@ -219,7 +223,7 @@ static int test_ws(char *ip, int ssl)
bytes = kws_read_frame(kws, &oc, &data); bytes = kws_read_frame(kws, &oc, &data);
printf("WS CLIENT READ %ld bytes [%s]\n", (long)bytes, (char *)data); printf("WS CLIENT READ %ld bytes [%s]\n", (long)bytes, (char *)data);
end: end:
kws_destroy(&kws); kws_destroy(&kws);
@ -276,7 +280,7 @@ int main(void)
ok(test_ws(v6, 1)); ok(test_ws(v6, 1));
} }
_unlink("./testwebsock.pem"); unlink("./testwebsock.pem");
ks_shutdown(); ks_shutdown();
done_testing(); done_testing();