summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-11-02 14:34:33 +0000
committeriphydf <iphydf@users.noreply.github.com>2016-11-02 18:50:41 +0000
commit96c672aef59ac785f3d351698311bb358820cc3c (patch)
treef862797a5a7f161a5ec727ca1d7df322a6d58c05 /toxcore
parente2d63e04979b59698b7e541f2aebb3c74495a2d3 (diff)
Compile as C++ for windows builds.
Compiling as C++ changes nothing semantically, but ensures that we don't break C++ compatibility while also retaining C compatibility. C++ compatibility is useful for tooling and additional diagnostics and analyses.
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/LAN_discovery.c4
-rw-r--r--toxcore/TCP_client.c8
-rw-r--r--toxcore/TCP_server.c14
-rw-r--r--toxcore/network.c16
4 files changed, 21 insertions, 21 deletions
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c
index d2bfb4e1..48e0e7bb 100644
--- a/toxcore/LAN_discovery.c
+++ b/toxcore/LAN_discovery.c
@@ -50,7 +50,7 @@ static void fetch_broadcast_info(uint16_t port)
50{ 50{
51 broadcast_count = 0; 51 broadcast_count = 0;
52 52
53 IP_ADAPTER_INFO *pAdapterInfo = malloc(sizeof(IP_ADAPTER_INFO)); 53 IP_ADAPTER_INFO *pAdapterInfo = (IP_ADAPTER_INFO *)malloc(sizeof(IP_ADAPTER_INFO));
54 unsigned long ulOutBufLen = sizeof(IP_ADAPTER_INFO); 54 unsigned long ulOutBufLen = sizeof(IP_ADAPTER_INFO);
55 55
56 if (pAdapterInfo == NULL) { 56 if (pAdapterInfo == NULL) {
@@ -59,7 +59,7 @@ static void fetch_broadcast_info(uint16_t port)
59 59
60 if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) { 60 if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
61 free(pAdapterInfo); 61 free(pAdapterInfo);
62 pAdapterInfo = malloc(ulOutBufLen); 62 pAdapterInfo = (IP_ADAPTER_INFO *)malloc(ulOutBufLen);
63 63
64 if (pAdapterInfo == NULL) { 64 if (pAdapterInfo == NULL) {
65 return; 65 return;
diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c
index ba8aeabe..caa1b73d 100644
--- a/toxcore/TCP_client.c
+++ b/toxcore/TCP_client.c
@@ -272,7 +272,7 @@ static int send_pending_data_nonpriority(TCP_Client_Connection *con)
272 } 272 }
273 273
274 uint16_t left = con->last_packet_length - con->last_packet_sent; 274 uint16_t left = con->last_packet_length - con->last_packet_sent;
275 int len = send(con->sock, con->last_packet + con->last_packet_sent, left, MSG_NOSIGNAL); 275 int len = send(con->sock, (const char *)(con->last_packet + con->last_packet_sent), left, MSG_NOSIGNAL);
276 276
277 if (len <= 0) { 277 if (len <= 0) {
278 return -1; 278 return -1;
@@ -302,7 +302,7 @@ static int send_pending_data(TCP_Client_Connection *con)
302 302
303 while (p) { 303 while (p) {
304 uint16_t left = p->size - p->sent; 304 uint16_t left = p->size - p->sent;
305 int len = send(con->sock, p->data + p->sent, left, MSG_NOSIGNAL); 305 int len = send(con->sock, (const char *)(p->data + p->sent), left, MSG_NOSIGNAL);
306 306
307 if (len != left) { 307 if (len != left) {
308 if (len > 0) { 308 if (len > 0) {
@@ -397,7 +397,7 @@ static int write_packet_TCP_secure_connection(TCP_Client_Connection *con, const
397 } 397 }
398 398
399 if (priority) { 399 if (priority) {
400 len = sendpriority ? send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL) : 0; 400 len = sendpriority ? send(con->sock, (const char *)packet, sizeof(packet), MSG_NOSIGNAL) : 0;
401 401
402 if (len <= 0) { 402 if (len <= 0) {
403 len = 0; 403 len = 0;
@@ -412,7 +412,7 @@ static int write_packet_TCP_secure_connection(TCP_Client_Connection *con, const
412 return add_priority(con, packet, sizeof(packet), len); 412 return add_priority(con, packet, sizeof(packet), len);
413 } 413 }
414 414
415 len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); 415 len = send(con->sock, (const char *)packet, sizeof(packet), MSG_NOSIGNAL);
416 416
417 if (len <= 0) { 417 if (len <= 0) {
418 return 0; 418 return 0;
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c
index 5a5a55be..4b355a62 100644
--- a/toxcore/TCP_server.c
+++ b/toxcore/TCP_server.c
@@ -251,7 +251,7 @@ uint16_t read_TCP_length(sock_t sock)
251 251
252 if (count >= sizeof(uint16_t)) { 252 if (count >= sizeof(uint16_t)) {
253 uint16_t length; 253 uint16_t length;
254 int len = recv(sock, (uint8_t *)&length, sizeof(uint16_t), MSG_NOSIGNAL); 254 int len = recv(sock, (char *)&length, sizeof(uint16_t), MSG_NOSIGNAL);
255 255
256 if (len != sizeof(uint16_t)) { 256 if (len != sizeof(uint16_t)) {
257 fprintf(stderr, "FAIL recv packet\n"); 257 fprintf(stderr, "FAIL recv packet\n");
@@ -280,7 +280,7 @@ int read_TCP_packet(sock_t sock, uint8_t *data, uint16_t length)
280 unsigned int count = TCP_socket_data_recv_buffer(sock); 280 unsigned int count = TCP_socket_data_recv_buffer(sock);
281 281
282 if (count >= length) { 282 if (count >= length) {
283 int len = recv(sock, data, length, MSG_NOSIGNAL); 283 int len = recv(sock, (char *)data, length, MSG_NOSIGNAL);
284 284
285 if (len != length) { 285 if (len != length) {
286 fprintf(stderr, "FAIL recv packet\n"); 286 fprintf(stderr, "FAIL recv packet\n");
@@ -348,7 +348,7 @@ static int send_pending_data_nonpriority(TCP_Secure_Connection *con)
348 } 348 }
349 349
350 uint16_t left = con->last_packet_length - con->last_packet_sent; 350 uint16_t left = con->last_packet_length - con->last_packet_sent;
351 int len = send(con->sock, con->last_packet + con->last_packet_sent, left, MSG_NOSIGNAL); 351 int len = send(con->sock, (const char *)(con->last_packet + con->last_packet_sent), left, MSG_NOSIGNAL);
352 352
353 if (len <= 0) { 353 if (len <= 0) {
354 return -1; 354 return -1;
@@ -378,7 +378,7 @@ static int send_pending_data(TCP_Secure_Connection *con)
378 378
379 while (p) { 379 while (p) {
380 uint16_t left = p->size - p->sent; 380 uint16_t left = p->size - p->sent;
381 int len = send(con->sock, p->data + p->sent, left, MSG_NOSIGNAL); 381 int len = send(con->sock, (const char *)(p->data + p->sent), left, MSG_NOSIGNAL);
382 382
383 if (len != left) { 383 if (len != left) {
384 if (len > 0) { 384 if (len > 0) {
@@ -462,7 +462,7 @@ static int write_packet_TCP_secure_connection(TCP_Secure_Connection *con, const
462 } 462 }
463 463
464 if (priority) { 464 if (priority) {
465 len = sendpriority ? send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL) : 0; 465 len = sendpriority ? send(con->sock, (const char *)packet, sizeof(packet), MSG_NOSIGNAL) : 0;
466 466
467 if (len <= 0) { 467 if (len <= 0) {
468 len = 0; 468 len = 0;
@@ -477,7 +477,7 @@ static int write_packet_TCP_secure_connection(TCP_Secure_Connection *con, const
477 return add_priority(con, packet, sizeof(packet), len); 477 return add_priority(con, packet, sizeof(packet), len);
478 } 478 }
479 479
480 len = send(con->sock, packet, sizeof(packet), MSG_NOSIGNAL); 480 len = send(con->sock, (const char *)packet, sizeof(packet), MSG_NOSIGNAL);
481 481
482 if (len <= 0) { 482 if (len <= 0) {
483 return 0; 483 return 0;
@@ -574,7 +574,7 @@ static int handle_TCP_handshake(TCP_Secure_Connection *con, const uint8_t *data,
574 return -1; 574 return -1;
575 } 575 }
576 576
577 if (TCP_SERVER_HANDSHAKE_SIZE != send(con->sock, response, TCP_SERVER_HANDSHAKE_SIZE, MSG_NOSIGNAL)) { 577 if (TCP_SERVER_HANDSHAKE_SIZE != send(con->sock, (const char *)response, TCP_SERVER_HANDSHAKE_SIZE, MSG_NOSIGNAL)) {
578 return -1; 578 return -1;
579 } 579 }
580 580
diff --git a/toxcore/network.c b/toxcore/network.c
index 386f8c16..31e8fd8b 100644
--- a/toxcore/network.c
+++ b/toxcore/network.c
@@ -170,7 +170,7 @@ int set_socket_nosigpipe(sock_t sock)
170{ 170{
171#if defined(__MACH__) 171#if defined(__MACH__)
172 int set = 1; 172 int set = 1;
173 return (setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int)) == 0); 173 return (setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (const char *)&set, sizeof(int)) == 0);
174#else 174#else
175 return 1; 175 return 1;
176#endif 176#endif
@@ -184,7 +184,7 @@ int set_socket_nosigpipe(sock_t sock)
184int set_socket_reuseaddr(sock_t sock) 184int set_socket_reuseaddr(sock_t sock)
185{ 185{
186 int set = 1; 186 int set = 1;
187 return (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&set, sizeof(set)) == 0); 187 return (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&set, sizeof(set)) == 0);
188} 188}
189 189
190/* Set socket to dual (IPv4 + IPv6 socket) 190/* Set socket to dual (IPv4 + IPv6 socket)
@@ -196,14 +196,14 @@ int set_socket_dualstack(sock_t sock)
196{ 196{
197 int ipv6only = 0; 197 int ipv6only = 0;
198 socklen_t optsize = sizeof(ipv6only); 198 socklen_t optsize = sizeof(ipv6only);
199 int res = getsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&ipv6only, &optsize); 199 int res = getsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&ipv6only, &optsize);
200 200
201 if ((res == 0) && (ipv6only == 0)) { 201 if ((res == 0) && (ipv6only == 0)) {
202 return 1; 202 return 1;
203 } 203 }
204 204
205 ipv6only = 0; 205 ipv6only = 0;
206 return (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&ipv6only, sizeof(ipv6only)) == 0); 206 return (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&ipv6only, sizeof(ipv6only)) == 0);
207} 207}
208 208
209 209
@@ -588,12 +588,12 @@ Networking_Core *new_networking_ex(Logger *log, IP ip, uint16_t port_from, uint1
588 /* Functions to increase the size of the send and receive UDP buffers. 588 /* Functions to increase the size of the send and receive UDP buffers.
589 */ 589 */
590 int n = 1024 * 1024 * 2; 590 int n = 1024 * 1024 * 2;
591 setsockopt(temp->sock, SOL_SOCKET, SO_RCVBUF, (char *)&n, sizeof(n)); 591 setsockopt(temp->sock, SOL_SOCKET, SO_RCVBUF, (const char *)&n, sizeof(n));
592 setsockopt(temp->sock, SOL_SOCKET, SO_SNDBUF, (char *)&n, sizeof(n)); 592 setsockopt(temp->sock, SOL_SOCKET, SO_SNDBUF, (const char *)&n, sizeof(n));
593 593
594 /* Enable broadcast on socket */ 594 /* Enable broadcast on socket */
595 int broadcast = 1; 595 int broadcast = 1;
596 setsockopt(temp->sock, SOL_SOCKET, SO_BROADCAST, (char *)&broadcast, sizeof(broadcast)); 596 setsockopt(temp->sock, SOL_SOCKET, SO_BROADCAST, (const char *)&broadcast, sizeof(broadcast));
597 597
598 /* iOS UDP sockets are weird and apparently can SIGPIPE */ 598 /* iOS UDP sockets are weird and apparently can SIGPIPE */
599 if (!set_socket_nosigpipe(temp->sock)) { 599 if (!set_socket_nosigpipe(temp->sock)) {
@@ -659,7 +659,7 @@ Networking_Core *new_networking_ex(Logger *log, IP ip, uint16_t port_from, uint1
659 mreq.ipv6mr_multiaddr.s6_addr[ 1] = 0x02; 659 mreq.ipv6mr_multiaddr.s6_addr[ 1] = 0x02;
660 mreq.ipv6mr_multiaddr.s6_addr[15] = 0x01; 660 mreq.ipv6mr_multiaddr.s6_addr[15] = 0x01;
661 mreq.ipv6mr_interface = 0; 661 mreq.ipv6mr_interface = 0;
662 int res = setsockopt(temp->sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq)); 662 int res = setsockopt(temp->sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (const char *)&mreq, sizeof(mreq));
663 663
664 LOGGER_DEBUG(log, res < 0 ? "Failed to activate local multicast membership. (%u, %s)" : 664 LOGGER_DEBUG(log, res < 0 ? "Failed to activate local multicast membership. (%u, %s)" :
665 "Local multicast group FF02::1 joined successfully", errno, strerror(errno)); 665 "Local multicast group FF02::1 joined successfully", errno, strerror(errno));