mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Revert "Revert "Portability fixes""
This reverts commit 59e2a844f0
, and
defines _DARWIN_C_SOURCE in toxcore/network.c
This commit is contained in:
parent
08cd61387e
commit
8ef1f35ca7
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -21,6 +21,9 @@ install_manifest.txt
|
|||
tags
|
||||
Makefile.in
|
||||
CMakeLists.txt.user
|
||||
DartConfiguration.tcl
|
||||
CTestTestfile.cmake
|
||||
*.pc
|
||||
|
||||
# Testing
|
||||
testing/data
|
||||
|
@ -40,6 +43,9 @@ testing/data
|
|||
*.app
|
||||
*.la
|
||||
|
||||
# Libraries
|
||||
*.so
|
||||
|
||||
# Misc (?)
|
||||
m4/*
|
||||
configure
|
||||
|
@ -51,8 +57,6 @@ config.log
|
|||
config.status
|
||||
stamp-h1
|
||||
autom4te.cache
|
||||
libtoxcore.pc
|
||||
libtoxav.pc
|
||||
libtool
|
||||
.deps
|
||||
.libs
|
||||
|
|
|
@ -57,21 +57,20 @@ macro(add_flag flag)
|
|||
add_cxxflag(${flag})
|
||||
endmacro()
|
||||
|
||||
# Set standard version for compiler.
|
||||
add_cflag("-std=c99")
|
||||
add_cxxflag("-std=c++11")
|
||||
|
||||
# Error on non-ISO C.
|
||||
add_cflag("-pedantic-errors")
|
||||
|
||||
option(WARNINGS "Enable additional compiler warnings" ON)
|
||||
if(WARNINGS)
|
||||
# Set standard version for compiler.
|
||||
add_cflag("-std=gnu99")
|
||||
add_cxxflag("-std=c++98")
|
||||
|
||||
# Add all warning flags we can.
|
||||
add_flag("-Wall")
|
||||
add_flag("-Wextra")
|
||||
add_flag("-Weverything")
|
||||
|
||||
# -pedantic only for C, because in C++ we want to allow the GNU/C99 extension
|
||||
# of having a comma at the end of an enumerator list.
|
||||
add_cflag("-pedantic")
|
||||
|
||||
# Disable specific warning flags for both C and C++.
|
||||
add_flag("-Wno-cast-align")
|
||||
add_flag("-Wno-conversion")
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/* Auto Tests: Conferences.
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
@ -175,7 +177,7 @@ group_test_restart:
|
|||
* Either way in this case it's fine */
|
||||
if (peer_count != NUM_GROUP_TOX) {
|
||||
++test_run;
|
||||
printf("\tError starting up the first group (peer_count %"PRIu32" != %d, test_run = %d)\n", peer_count, NUM_GROUP_TOX,
|
||||
printf("\tError starting up the first group (peer_count %" PRIu32 " != %d, test_run = %d)\n", peer_count, NUM_GROUP_TOX,
|
||||
test_run);
|
||||
|
||||
for (j = 0; j < NUM_GROUP_TOX; ++j) {
|
||||
|
@ -194,7 +196,7 @@ group_test_restart:
|
|||
* important again.
|
||||
*/
|
||||
ck_assert_msg(peer_count == NUM_GROUP_TOX, "\n\tBad number of group peers (pre check)."
|
||||
"\n\t\t\tExpected: %u but tox_instance(%u) only has: %"PRIu32"\n\n",
|
||||
"\n\t\t\tExpected: %u but tox_instance(%u) only has: %" PRIu32 "\n\n",
|
||||
NUM_GROUP_TOX, i, peer_count);
|
||||
|
||||
uint8_t title[2048];
|
||||
|
@ -241,7 +243,7 @@ group_test_restart:
|
|||
for (i = 0; i < (k - 1); ++i) {
|
||||
uint32_t peer_count = tox_conference_peer_count(toxes[i], 0, NULL);
|
||||
ck_assert_msg(peer_count == (k - 1), "\n\tBad number of group peers (post check)."
|
||||
"\n\t\t\tExpected: %u but tox_instance(%u) only has: %"PRIu32"\n\n",
|
||||
"\n\t\t\tExpected: %u but tox_instance(%u) only has: %" PRIu32 "\n\n",
|
||||
(k - 1), i, peer_count);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -114,8 +114,8 @@ START_TEST(test_ip_equal)
|
|||
ip2.ip6.uint32[2] = htonl(0xFFFF);
|
||||
ip2.ip6.uint32[3] = htonl(0x7F000001);
|
||||
|
||||
ck_assert_msg(IN6_IS_ADDR_V4MAPPED(&ip2.ip6.in6_addr) != 0,
|
||||
"IN6_IS_ADDR_V4MAPPED(::ffff:127.0.0.1): expected != 0, got 0.");
|
||||
ck_assert_msg(IPV6_IPV4_IN_V6(ip2.ip6) != 0,
|
||||
"IPV6_IPV4_IN_V6(::ffff:127.0.0.1): expected != 0, got 0.");
|
||||
|
||||
res = ip_equal(&ip1, &ip2);
|
||||
ck_assert_msg(res != 0, "ip_equal( {AF_INET, 127.0.0.1}, {AF_INET6, ::ffff:127.0.0.1} ): expected result != 0, got 0.");
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
/* Auto Tests: Save and load friends.
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#include "helpers.h"
|
||||
#include "../toxcore/tox.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/* Auto Tests: Many TCP.
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/* Auto Tests: Many clients.
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
#include "global.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -82,7 +82,22 @@ static int level_syslog(LOG_LEVEL level)
|
|||
|
||||
static void log_syslog(LOG_LEVEL level, const char *format, va_list args)
|
||||
{
|
||||
vsyslog(level_syslog(level), format, args);
|
||||
va_list args2;
|
||||
|
||||
va_copy(args2, args);
|
||||
int size = vsnprintf(NULL, 0, format, args2);
|
||||
va_end(args2);
|
||||
|
||||
assert(size >= 0);
|
||||
|
||||
if (size < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[size + 1];
|
||||
vsnprintf(buf, size + 1, format, args);
|
||||
|
||||
syslog(level_syslog(level), "%s", buf);
|
||||
}
|
||||
|
||||
static FILE *level_stdout(LOG_LEVEL level)
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
// system provided
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
@ -34,8 +35,8 @@ static uint16_t port = 6667;
|
|||
|
||||
static int sock;
|
||||
|
||||
#define SERVER_CONNECT "NICK "IRC_NAME"\nUSER "IRC_NAME" 8 * :"IRC_NAME"\n"
|
||||
#define CHANNEL_JOIN "JOIN "IRC_CHANNEL"\n"
|
||||
#define SERVER_CONNECT "NICK " IRC_NAME "\nUSER " IRC_NAME " 8 * :" IRC_NAME "\n"
|
||||
#define CHANNEL_JOIN "JOIN " IRC_CHANNEL "\n"
|
||||
|
||||
/* In toxcore/network.c */
|
||||
uint64_t current_time_monotonic(void);
|
||||
|
@ -131,8 +132,8 @@ static void copy_groupmessage(Tox *tox, uint32_t groupnumber, uint32_t friendgro
|
|||
uint8_t sendbuf[2048];
|
||||
uint16_t send_len = 0;
|
||||
|
||||
memcpy(sendbuf, "PRIVMSG "IRC_CHANNEL" :", sizeof("PRIVMSG "IRC_CHANNEL" :"));
|
||||
send_len += sizeof("PRIVMSG "IRC_CHANNEL" :") - 1;
|
||||
memcpy(sendbuf, "PRIVMSG " IRC_CHANNEL " :", sizeof("PRIVMSG " IRC_CHANNEL " :"));
|
||||
send_len += sizeof("PRIVMSG " IRC_CHANNEL " :") - 1;
|
||||
memcpy(sendbuf + send_len, name, namelen);
|
||||
send_len += namelen;
|
||||
sendbuf[send_len] = ':';
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
#ifdef TOX_DEBUG
|
||||
#include <assert.h>
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
@ -42,6 +44,7 @@
|
|||
#include <dirent.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define NUM_FILE_SENDERS 256
|
||||
typedef struct {
|
||||
|
@ -297,6 +300,7 @@ int main(int argc, char *argv[])
|
|||
memcpy(path, argv[argvoffset + 4], strlen(argv[argvoffset + 4]));
|
||||
DIR *d;
|
||||
struct dirent *dir;
|
||||
struct stat statbuf;
|
||||
uint8_t notconnected = 1;
|
||||
|
||||
while (1) {
|
||||
|
@ -310,7 +314,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (d) {
|
||||
while ((dir = readdir(d)) != NULL) {
|
||||
if (dir->d_type == DT_REG) {
|
||||
char filepath[strlen(path) + strlen(dir->d_name) + 1];
|
||||
memcpy(filepath, path, strlen(path));
|
||||
memcpy(filepath + strlen(path), dir->d_name, strlen(dir->d_name) + 1);
|
||||
stat(filepath, &statbuf);
|
||||
|
||||
if (S_ISREG(statbuf.st_mode)) {
|
||||
char fullpath[1024];
|
||||
|
||||
if (path[strlen(path) - 1] == '/') {
|
||||
|
|
|
@ -619,7 +619,7 @@ static int send_routing_response(TCP_Secure_Connection *con, uint8_t rpid, const
|
|||
*/
|
||||
static int send_connect_notification(TCP_Secure_Connection *con, uint8_t id)
|
||||
{
|
||||
uint8_t data[2] = {TCP_PACKET_CONNECTION_NOTIFICATION, id + NUM_RESERVED_PORTS};
|
||||
uint8_t data[2] = {TCP_PACKET_CONNECTION_NOTIFICATION, (uint8_t)(id + NUM_RESERVED_PORTS)};
|
||||
return write_packet_TCP_secure_connection(con, data, sizeof(data), 1);
|
||||
}
|
||||
|
||||
|
@ -629,7 +629,7 @@ static int send_connect_notification(TCP_Secure_Connection *con, uint8_t id)
|
|||
*/
|
||||
static int send_disconnect_notification(TCP_Secure_Connection *con, uint8_t id)
|
||||
{
|
||||
uint8_t data[2] = {TCP_PACKET_DISCONNECT_NOTIFICATION, id + NUM_RESERVED_PORTS};
|
||||
uint8_t data[2] = {TCP_PACKET_DISCONNECT_NOTIFICATION, (uint8_t)(id + NUM_RESERVED_PORTS)};
|
||||
return write_packet_TCP_secure_connection(con, data, sizeof(data), 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _DARWIN_C_SOURCE
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#if defined(_WIN32) && _WIN32_WINNT >= _WIN32_WINNT_WINXP
|
||||
#define _WIN32_WINNT 0x501
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* along with Tox. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 600
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user