mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Astyled some files.
This commit is contained in:
parent
bba10544e7
commit
2fdc412e36
|
@ -455,8 +455,9 @@ uint32_t sendqueue_total(Lossless_UDP *ludp)
|
|||
{
|
||||
uint32_t i, total = 0;
|
||||
|
||||
for(i = 0; i < ludp->connections.len; i++) {
|
||||
for (i = 0; i < ludp->connections.len; i++) {
|
||||
Connection *connection = &tox_array_get(&ludp->connections, i, Connection);
|
||||
|
||||
if (connection->status != 0)
|
||||
total += connection->sendbuff_packetnum - connection->successful_sent;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ int main()
|
|||
{
|
||||
tox_list_t head;
|
||||
tox_list_new(&head); //initialize head
|
||||
|
||||
|
||||
//input a new character, until user enters q or e
|
||||
char c = '\0';
|
||||
while (c != 'q' && c != 'e') {
|
||||
|
@ -98,16 +98,16 @@ int main()
|
|||
tmp->c = c;
|
||||
tox_list_add(&head, &tmp->tox_lst); //add it to the list
|
||||
}
|
||||
|
||||
|
||||
TOX_LIST_FOR_EACH() takes a struct tox_list and a name for a temporary pointer to use in the loop.
|
||||
|
||||
|
||||
TOX_LIST_GET_VALUE() uses magic to return an instance of a structure that contains tox_list_t.
|
||||
You have to give it a temporary tox_string_t, name of tox_list_t member inside our structure (tox_lst),
|
||||
and the type of structure to return.
|
||||
|
||||
|
||||
TOX_LIST_FOR_EACH(head, tmp)
|
||||
printf("%c", TOX_LIST_GET_VALUE(*tmp, tox_lst, tox_string_t).c);
|
||||
|
||||
|
||||
TOX_LIST_FOR_EACH(head, tmp) {
|
||||
if (TOX_LIST_GET_VALUE(*tmp, tox_lst, tox_string_t).c == 'z') {
|
||||
//If you delete tmp, you have to quit the loop, or it will go on infinitly.
|
||||
|
@ -116,12 +116,12 @@ and the type of structure to return.
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("\n");
|
||||
TOX_LIST_FOR_EACH(head, tmp)
|
||||
printf("%c", TOX_LIST_GET_VALUE(*tmp, tox_lst, tox_string_t).c);
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
* along with Tox. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
|
||||
#define _WIN32_WINNT 0x501
|
||||
#endif
|
||||
#define _WIN32_WINNT 0x501
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
@ -371,13 +371,15 @@ int networking_wait_execute(uint8_t *data, uint16_t len, uint16_t milliseconds)
|
|||
/* returns -1 on error, 0 on timeout, the socket on activity */
|
||||
int res = select(nfds, &readfds, &writefds, &exceptfds, &timeout);
|
||||
#ifdef LOGGING
|
||||
|
||||
/* only dump if not timeout */
|
||||
if (res) {
|
||||
sprintf(logbuffer, "select(%d): %d (%d, %s) - %d %d %d\n", milliseconds, res, errno,
|
||||
strerror(errno), FD_ISSET(s->sock, &readfds), FD_ISSET(s->sock, &writefds),
|
||||
FD_ISSET(s->sock, &exceptfds));
|
||||
strerror(errno), FD_ISSET(s->sock, &readfds), FD_ISSET(s->sock, &writefds),
|
||||
FD_ISSET(s->sock, &exceptfds));
|
||||
loglog(logbuffer);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (FD_ISSET(s->sock, &writefds))
|
||||
|
@ -525,14 +527,14 @@ Networking_Core *new_networking(IP ip, uint16_t port)
|
|||
} else
|
||||
return NULL;
|
||||
|
||||
if (ip.family == AF_INET6)
|
||||
{
|
||||
if (ip.family == AF_INET6) {
|
||||
char ipv6only = 0;
|
||||
socklen_t optsize = sizeof(ipv6only);
|
||||
#ifdef LOGGING
|
||||
errno = 0;
|
||||
#endif
|
||||
int res = getsockopt(temp->sock, IPPROTO_IPV6, IPV6_V6ONLY, &ipv6only, &optsize);
|
||||
|
||||
if ((res == 0) && (ipv6only == 0)) {
|
||||
#ifdef LOGGING
|
||||
loglog("Dual-stack socket: enabled per default.\n");
|
||||
|
@ -540,6 +542,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
|
|||
} else {
|
||||
ipv6only = 0;
|
||||
#ifdef LOGGING
|
||||
|
||||
if (res < 0) {
|
||||
sprintf(logbuffer, "Dual-stack socket: Failed to query default. (%d, %s)\n",
|
||||
errno, strerror(errno));
|
||||
|
@ -549,8 +552,9 @@ Networking_Core *new_networking(IP ip, uint16_t port)
|
|||
errno = 0;
|
||||
res =
|
||||
#endif
|
||||
setsockopt(temp->sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&ipv6only, sizeof(ipv6only));
|
||||
setsockopt(temp->sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&ipv6only, sizeof(ipv6only));
|
||||
#ifdef LOGGING
|
||||
|
||||
if (res < 0) {
|
||||
sprintf(logbuffer,
|
||||
"Dual-stack socket: Failed to enable, won't be able to receive from/send to IPv4 addresses. (%u, %s)\n",
|
||||
|
@ -558,6 +562,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
|
|||
loglog(logbuffer);
|
||||
} else
|
||||
loglog("Dual-stack socket: Enabled successfully.\n");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -605,8 +610,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
|
|||
*portptr = htons(port_to_try);
|
||||
int tries, res;
|
||||
|
||||
for (tries = TOX_PORTRANGE_FROM; tries <= TOX_PORTRANGE_TO; tries++)
|
||||
{
|
||||
for (tries = TOX_PORTRANGE_FROM; tries <= TOX_PORTRANGE_TO; tries++) {
|
||||
res = bind(temp->sock, (struct sockaddr *)&addr, addrsize);
|
||||
|
||||
if (!res) {
|
||||
|
@ -674,6 +678,7 @@ int ip_equal(IP *a, IP *b)
|
|||
else if (a->family == AF_INET6)
|
||||
#ifdef WIN32
|
||||
return IN6_ADDR_EQUAL(&a->ip6.in6_addr, &b->ip6.in6_addr);
|
||||
|
||||
#else
|
||||
return IN6_ARE_ADDR_EQUAL(&a->ip6.in6_addr, &b->ip6.in6_addr);
|
||||
#endif
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* This file is donated to the Tox Project.
|
||||
* Copyright 2013 plutooo
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2013 Tox project All Rights Reserved.
|
||||
*
|
||||
* This file is part of Tox.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* This file is donated to the Tox Project.
|
||||
* Copyright 2013 plutooo
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2013 Tox project All Rights Reserved.
|
||||
*
|
||||
* This file is part of Tox.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* This file is donated to the Tox Project.
|
||||
* Copyright 2013 plutooo
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2013 Tox project All Rights Reserved.
|
||||
*
|
||||
* This file is part of Tox.
|
||||
|
|
Loading…
Reference in New Issue
Block a user