chore: Reformat sources with astyle.

Restyled astyle is fixed now.
pull/1660/head
iphydf 2024-02-02 00:09:27 +00:00
parent 4359e3a6bc
commit 4e2dba4d9f
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
149 changed files with 712 additions and 1244 deletions

View File

@ -5,6 +5,7 @@ exclude:
restylers:
- astyle:
image: restyled/restyler-astyle:d7967bcb8b622a98524b7df1da1b02652114cf9a
arguments: ["--options=other/astyle/astylerc"]
include:
- "**/*.c"
@ -12,7 +13,7 @@ restylers:
- autopep8
- black
- clang-format:
image: restyled/restyler-clang-format:13.0.1
image: restyled/restyler-clang-format:v16.0.6
include:
- "**/*.cc"
- "**/*.hh"

View File

@ -655,7 +655,7 @@ static void test_client_invalid(void)
ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);
ip_port_tcp_s.ip = get_loopback();
TCP_Client_Connection *conn = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s,
self_public_key, f_public_key, f_secret_key, nullptr);
self_public_key, f_public_key, f_secret_key, nullptr);
// Run the client's main loop but not the server.
mono_time_update(mono_time);
@ -709,7 +709,6 @@ static int tcp_data_callback(void *object, int id, const uint8_t *data, uint16_t
return 0;
}
static void test_tcp_connection(void)
{
const Random *rng = os_random();

View File

@ -120,7 +120,6 @@ static void basic_announce_tests(void)
test_store_data();
}
int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

View File

@ -444,7 +444,6 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin
}
}
void print_debug_logger(void *context, Logger_Level level, const char *file, int line, const char *func, const char *message, void *userdata)
{
print_debug_log(nullptr, (Tox_Log_Level) level, file, (uint32_t) line, func, message, userdata);

View File

@ -61,7 +61,7 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin
// Use this function when setting the log callback on a Logger object
void print_debug_logger(void *context, Logger_Level level, const char *file, int line,
const char *func, const char *message, void *userdata);
const char *func, const char *message, void *userdata);
Tox *tox_new_log(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data);
Tox *tox_new_log_lan(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data, bool lan_discovery);

View File

@ -426,7 +426,6 @@ static void test_groupav(AutoTox *autotoxes)
ck_assert_msg(tox_conference_invite(autotoxes[0].tox, 0, 0, nullptr) != 0, "failed to invite friend");
((State *)autotoxes[0].state)->invited_next = true;
printf("waiting for invitations to be made\n");
uint32_t invited_count = 0;

View File

@ -174,7 +174,6 @@ static bool names_propagated(uint32_t tox_count, AutoTox *autotoxes)
return true;
}
/**
* returns a random index at which a list of booleans is false
* (some such index is required to exist)
@ -357,7 +356,6 @@ static void test_many_group(AutoTox *autotoxes)
nullptr) != 0,
"failed to set group title");
printf("waiting for invitations to be made\n");
uint32_t invited_count = 0;

View File

@ -128,10 +128,9 @@ static void test_dht_getnodes(AutoTox *autotoxes)
tox_events_callback_dht_get_nodes_response(autotoxes[i].dispatch, getnodes_response_cb);
printf("Peer %zu dht closenode count total/announce-capable: %d/%d\n",
i,
tox_dht_get_num_closelist(autotoxes[i].tox),
tox_dht_get_num_closelist_announce_capable(autotoxes[i].tox)
);
i,
tox_dht_get_num_closelist(autotoxes[i].tox),
tox_dht_get_num_closelist_announce_capable(autotoxes[i].tox));
}
while (!all_nodes_crawled(autotoxes, NUM_TOXES, public_key_list)) {

View File

@ -184,7 +184,6 @@ static void test_keys(void)
free(in_plaintext2a);
free(out_plaintext2a);
uint8_t encrypted2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
ret = tox_pass_encrypt(string, 44, key_char, 12, encrypted2, &encerr);
ck_assert_msg(ret, "generic failure 3: %d", encerr);

View File

@ -126,7 +126,6 @@ static void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t fi
Tox_Err_File_Send_Chunk error;
tox_file_send_chunk(tox, friend_number, file_number, position, f_data, length, &error);
ck_assert_msg(error == TOX_ERR_FILE_SEND_CHUNK_OK,
"could not send chunk, error num=%d pos=%d len=%d", (int)error, (int)position, (int)length);
@ -134,7 +133,6 @@ static void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t fi
sending_pos += length;
}
static uint8_t num;
static bool file_recv;
static void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data,
@ -225,8 +223,8 @@ static void file_transfer_test(void)
tox_callback_file_recv(tox3, tox_file_receive);
const uint64_t totalf_size = UINT64_MAX;
Tox_File_Number fnum = tox_file_send(
tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail");
Tox_Err_File_Get gfierr;

View File

@ -150,7 +150,6 @@ static void tox_file_chunk_request(Tox *tox, const Tox_Event_File_Chunk_Request
sending_pos += length;
}
static uint8_t num;
static bool file_recv;
static void write_file(Tox *tox, const Tox_Event_File_Recv_Chunk *event, void *user_data)

View File

@ -317,7 +317,6 @@ static void test_forwarding(void)
}
}
for (uint32_t i = 0; i < NUM_FORWARDER; ++i) {
kill_forwarding_subtox(mem, subtoxes[i]);
}
@ -325,7 +324,6 @@ static void test_forwarding(void)
tox_kill(relay);
}
int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);

View File

@ -448,7 +448,6 @@ static void group_announce_test(AutoTox *autotoxes)
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
}
printf("All tests passed!\n");
}

View File

@ -425,8 +425,8 @@ static void group_message_test(AutoTox *autotoxes)
if (state1->peer_joined && !state1->message_sent) {
state1->pseudo_msg_id = tox_group_send_message(
tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)TEST_MESSAGE,
TEST_MESSAGE_LEN, &err_send);
tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)TEST_MESSAGE,
TEST_MESSAGE_LEN, &err_send);
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
state1->message_sent = true;
}

View File

@ -38,7 +38,6 @@ typedef struct State {
char mod_name1[TOX_MAX_NAME_LENGTH];
char mod_name2[TOX_MAX_NAME_LENGTH];
bool observer_check;
size_t observer_event_count;
char observer_name1[TOX_MAX_NAME_LENGTH];

View File

@ -181,7 +181,6 @@ static void group_save_test(AutoTox *autotoxes)
tox_group_self_get_public_key(tox0, group_number, founder_pk, &sq_err);
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
Tox_Err_Group_Invite_Friend err_invite;
tox_group_invite_friend(tox0, group_number, 0, &err_invite);

View File

@ -178,7 +178,6 @@ static void group_tcp_test(AutoTox *autotoxes)
printf("%d peers successfully joined. Waiting for code...\n", NUM_GROUP_TOXES);
printf("Tox 0 sending secret code to all peers\n");
for (size_t i = 0; i < NUM_GROUP_TOXES - 1; ++i) {
Tox_Err_Group_Send_Private_Message perr;

View File

@ -118,7 +118,6 @@ static int handle_test_3(void *object, const IP_Port *source, const uint8_t *pac
return 1;
}
if (memcmp(packet + 1, sb_data, ONION_ANNOUNCE_SENDBACK_DATA_LENGTH) != 0) {
return 1;
}
@ -154,7 +153,6 @@ static int handle_test_3_old(void *object, const IP_Port *source, const uint8_t
return 1;
}
if (memcmp(packet + 1, sb_data, ONION_ANNOUNCE_SENDBACK_DATA_LENGTH) != 0) {
return 1;
}

View File

@ -24,10 +24,10 @@ static bool try_bootstrap(Tox *tox1, Tox *tox2, Tox *tox3, Tox *tox4)
tox_self_get_connection_status(tox3) != TOX_CONNECTION_NONE &&
tox_self_get_connection_status(tox4) != TOX_CONNECTION_NONE) {
printf("%d %d %d %d\n",
tox_self_get_connection_status(tox1),
tox_self_get_connection_status(tox2),
tox_self_get_connection_status(tox3),
tox_self_get_connection_status(tox4));
tox_self_get_connection_status(tox1),
tox_self_get_connection_status(tox2),
tox_self_get_connection_status(tox3),
tox_self_get_connection_status(tox4));
return true;
}
@ -38,10 +38,10 @@ static bool try_bootstrap(Tox *tox1, Tox *tox2, Tox *tox3, Tox *tox4)
if (i % 10 == 0) {
printf("%d %d %d %d\n",
tox_self_get_connection_status(tox1),
tox_self_get_connection_status(tox2),
tox_self_get_connection_status(tox3),
tox_self_get_connection_status(tox4));
tox_self_get_connection_status(tox1),
tox_self_get_connection_status(tox2),
tox_self_get_connection_status(tox3),
tox_self_get_connection_status(tox4));
}
c_sleep(tox_iteration_interval(tox1));

View File

@ -75,7 +75,7 @@ int main(void)
ck_assert(tox2 != nullptr);
tox_events_init(tox1);
Tox_Dispatch* dispatch1 = tox_dispatch_new(nullptr);
Tox_Dispatch *dispatch1 = tox_dispatch_new(nullptr);
ck_assert(dispatch1 != nullptr);
printf("bootstrapping tox2 off tox1\n");

View File

@ -154,7 +154,7 @@ static void test_few_clients(void)
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
tox_options_free(opts1);
tox_events_init(tox1);
Tox_Dispatch* dispatch1 = tox_dispatch_new(nullptr);
Tox_Dispatch *dispatch1 = tox_dispatch_new(nullptr);
ck_assert(dispatch1 != nullptr);
struct Tox_Options *opts2 = tox_options_new(nullptr);
@ -164,7 +164,7 @@ static void test_few_clients(void)
Tox *tox2 = tox_new_log(opts2, &t_n_error, &index[1]);
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
tox_events_init(tox2);
Tox_Dispatch* dispatch2 = tox_dispatch_new(nullptr);
Tox_Dispatch *dispatch2 = tox_dispatch_new(nullptr);
ck_assert(dispatch2 != nullptr);
struct Tox_Options *opts3 = tox_options_new(nullptr);
@ -175,7 +175,6 @@ static void test_few_clients(void)
ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances");
Time_Data time_data;
ck_assert_msg(pthread_mutex_init(&time_data.lock, nullptr) == 0, "Failed to init time_data mutex");
time_data.clock = current_time_monotonic(tox1->mono_time);

View File

@ -18,7 +18,7 @@
static void nickchange_callback(Tox *tox, const Tox_Event_Friend_Name *event, void *user_data)
{
//const uint32_t friend_number = tox_event_friend_name_get_friend_number(event);
const uint8_t* name = tox_event_friend_name_get_name(event);
const uint8_t *name = tox_event_friend_name_get_name(event);
const uint32_t name_length = tox_event_friend_name_get_name_length(event);
ck_assert_msg(name_length == sizeof(NICKNAME), "Name length not correct: %d != %d", (uint16_t)name_length,

View File

@ -269,7 +269,6 @@ loop_top:
printf("test_many_clients_tcp_b succeeded, took %llu seconds\n", time(nullptr) - cur_time);
}
static void tox_suite(void)
{
/* Each tox connects to a single tox TCP */

View File

@ -24,7 +24,6 @@ static void accept_friend_request(Tox *m, const Tox_Event_Friend_Request *event,
}
}
#define TCP_TEST_NUM_TOXES 90
#define TCP_TEST_NUM_FRIENDS 50

View File

@ -2,7 +2,8 @@
#include "../toxcore/ccompat.h"
int main(void) {
int main(void)
{
tox_kill(tox_new(nullptr, nullptr));
return 0;
}

View File

@ -23,7 +23,6 @@
#define TEST_STOP_RESUME_PAYLOAD 1
#define TEST_PAUSE_RESUME_SEND 1
#define ck_assert_call_control(a, b, c) do { \
Toxav_Err_Call_Control cc_err; \
bool ok = toxav_call_control(a, b, c, &cc_err); \
@ -34,7 +33,6 @@
ck_assert(cc_err == TOXAV_ERR_CALL_CONTROL_OK); \
} while (0)
typedef struct {
bool incoming;
uint32_t state;
@ -46,7 +44,6 @@ static void clear_call_control(CallControl *cc)
*cc = empty;
}
/**
* Callbacks
*/
@ -89,7 +86,6 @@ static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const
}
}
/**
* Iterate helper
*/
@ -207,7 +203,6 @@ static void test_av_flows(void)
c_sleep(20);
}
{
Toxav_Err_New error;
alice_av = toxav_new(alice, &error);

View File

@ -74,7 +74,6 @@ static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const
}
}
/**
* Iterate helper
*/
@ -299,7 +298,6 @@ static void test_av_three_calls(void)
}
}
do {
tox_iterate(bootstrap, nullptr);
tox_iterate(alice, nullptr);

View File

@ -50,7 +50,6 @@ static const char *motd_str = ""; //Change this to anything within 256 bytes(but
#define PORT 33445
static bool manage_keys(DHT *dht)
{
enum { KEYS_SIZE = CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE };
@ -165,7 +164,7 @@ int main(int argc, char *argv[])
Onion_Announce *onion_a = new_onion_announce(logger, mem, rng, mono_time, dht);
#ifdef DHT_NODE_EXTRA_PACKETS
bootstrap_set_callbacks(dht_get_net(dht), (uint32_t)DAEMON_VERSION_NUMBER, (const uint8_t *) motd_str, strlen(motd_str)+1);
bootstrap_set_callbacks(dht_get_net(dht), (uint32_t)DAEMON_VERSION_NUMBER, (const uint8_t *) motd_str, strlen(motd_str) + 1);
#endif
if (!(onion && forwarding && onion_a)) {

View File

@ -1,5 +1,6 @@
# Bracket Style Options
--style=kr
--attach-namespaces
# Tab Options
--indent=spaces=4
@ -9,15 +10,19 @@
# Padding Options
--pad-header
--break-blocks
--pad-oper
#--unpad-brackets
--unpad-paren
--align-pointer=name
--align-reference=name
#--squeeze-lines=1
#--squeeze-ws
# Formatting Options
--add-braces
--convert-tabs
--max-code-length=120
--max-code-length=200
--attach-return-type
# Other Options
--preserve-date

View File

@ -2,36 +2,6 @@
set -ex
SOURCE_DIR="$1"
ASTYLE="$2"
# Go to the source root.
if [ -z "$SOURCE_DIR" ]; then
SOURCE_DIR=.
fi
cd "$SOURCE_DIR"
if [ -z "$ASTYLE" ] || ! which "$ASTYLE"; then
ASTYLE=astyle
fi
if ! which "$ASTYLE"; then
# If we couldn't find or install an astyle binary, don't do anything.
echo "Could not find an astyle binary; please install astyle."
exit 1
fi
readarray -t CC_SOURCES <<<"$(find . '(' -name '*.cc' ')')"
CC_SOURCES+=(toxcore/crypto_core.c)
CC_SOURCES+=(toxcore/ping_array.c)
for bin in clang-format-11 clang-format-7 clang-format-6.0 clang-format-5.0 clang-format; do
if which "$bin"; then
"$bin" -i -style='{BasedOnStyle: Google, ColumnLimit: 100}' "${CC_SOURCES[@]}"
break
fi
done
FIND="find ."
FIND="$FIND '(' -name '*.[ch]' ')'"
FIND="$FIND -and -not -name '*.api.h'"
@ -40,7 +10,15 @@ FIND="$FIND -and -not -wholename './third_party/*'"
FIND="$FIND -and -not -wholename './toxencryptsave/crypto_pwhash*'"
readarray -t C_SOURCES <<<"$(eval "$FIND")"
readarray -t CC_SOURCES <<<"$(find . '(' -name '*.cc' -or -name '*.hh' ')')"
#CC_SOURCES+=(toxcore/crypto_core.c)
#CC_SOURCES+=(toxcore/ping_array.c)
"$ASTYLE" -n --options=other/astyle/astylerc "${C_SOURCES[@]}"
# Format C++ sources with clang-format.
clang-format -i "${CC_SOURCES[@]}"
# Format C sources with astyle. We can't use clang-format, because it strongly
# messes up formatting of non_null annotations.
astyle -n --options=other/astyle/astylerc "${C_SOURCES[@]}"
git diff --color=always --exit-code

View File

@ -18,7 +18,6 @@
#include <string.h>
/**
* Prints --help message
*/
@ -48,8 +47,8 @@ static void print_help(void)
}
Cli_Status handle_command_line_arguments(
int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend,
bool *run_in_foreground)
int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend,
bool *run_in_foreground)
{
if (argc < 2) {
log_write(LOG_LEVEL_ERROR, "Error: No arguments provided.\n\n");

View File

@ -32,7 +32,7 @@ typedef enum Cli_Status {
* @param run_in_foreground Sets to the provided by the user foreground option.
*/
Cli_Status handle_command_line_arguments(
int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend,
bool *run_in_foreground);
int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend,
bool *run_in_foreground);
#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_COMMAND_LINE_ARGUMENTS_H

View File

@ -50,7 +50,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
// NOLINTNEXTLINE, clang-tidy: error: suspicious comparison of 'sizeof(expr)' to a constant [bugprone-sizeof-expression,-warnings-as-errors]
static_assert(sizeof(default_ports) > 0, "At least one default TCP relay port should be provided");
const size_t default_ports_count = sizeof(default_ports)/sizeof(*default_ports);
const size_t default_ports_count = sizeof(default_ports) / sizeof(*default_ports);
for (size_t i = 0; i < default_ports_count; ++i) {
log_write(LOG_LEVEL_INFO, "Port #%zu: %u\n", i, default_ports[i]);

View File

@ -58,7 +58,6 @@ bool log_close(void)
return true;
}
bool log_write(LOG_LEVEL level, const char *format, ...)
{
if (current_backend == INVALID_BACKEND) {

View File

@ -47,5 +47,4 @@ bool log_close(void);
*/
bool log_write(LOG_LEVEL level, const char *format, ...) GNU_PRINTF(2, 3);
#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_H

View File

@ -50,7 +50,6 @@
#include "global.h"
#include "log.h"
static void sleep_milliseconds(uint32_t ms)
{
struct timespec req;
@ -164,7 +163,6 @@ static Cli_Status daemonize(LOG_BACKEND log_backend, char *pid_file_path)
return CLI_STATUS_ERROR;
}
// Change the current working directory
if ((chdir("/")) < 0) {
log_write(LOG_LEVEL_ERROR, "Couldn't change working directory to '/'. Exiting.\n");

View File

@ -9,26 +9,26 @@ int crypto_sign_keypair(unsigned char *pk, unsigned char *sk)
return 0;
}
int crypto_sign_ed25519_pk_to_curve25519(unsigned char *curve25519_pk,
const unsigned char *ed25519_pk)
const unsigned char *ed25519_pk)
{
memset(curve25519_pk, 0, 32);
return 0;
}
int crypto_sign_ed25519_sk_to_curve25519(unsigned char *curve25519_sk,
const unsigned char *ed25519_sk)
const unsigned char *ed25519_sk)
{
memset(curve25519_sk, 0, 32);
return 0;
}
void sodium_memzero(void * const pnt, const size_t len)
void sodium_memzero(void *const pnt, const size_t len)
{
memset(pnt, 0, len);
}
int sodium_mlock(void * const addr, const size_t len)
int sodium_mlock(void *const addr, const size_t len)
{
return 0;
}
int sodium_munlock(void * const addr, const size_t len)
int sodium_munlock(void *const addr, const size_t len)
{
return 0;
}
@ -98,7 +98,7 @@ int crypto_hash_sha512(unsigned char *out, const unsigned char *in,
{
return 0;
}
void randombytes(unsigned char * const buf, const unsigned long long buf_len)
void randombytes(unsigned char *const buf, const unsigned long long buf_len)
{
memset(buf, 0, buf_len);
}

View File

@ -186,14 +186,12 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
}
f << R"(
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
)";
// gen struct
@ -409,7 +407,7 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
);
first = false;
}
f << ";\n}\n\n";
f << ";\n}\n";
f << R"(
/*****************************************************
@ -467,7 +465,7 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
f << " Tox_Event_" << event_name << " *" << event_name_l << " = tox_events_add_" << event_name_l << "(state->events, state->mem);\n\n";
f << " if (" << event_name_l << " == nullptr) {\n";
f << " state->error = TOX_ERR_EVENTS_ITERATE_MALLOC;\n return nullptr;\n }\n\n";
f << " return " << event_name_l << ";\n}\n\n";
f << " return " << event_name_l << ";\n}\n";
f << R"(
@ -477,9 +475,9 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
*
*****************************************************/
)";
f << "void tox_events_handle_" << event_name_l << "(Tox *tox";
f << "void tox_events_handle_" << event_name_l << "(\n";
f << " Tox *tox";
for (const auto& t : event_types) {
std::visit(
@ -495,7 +493,7 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
);
}
f << ",\n void *user_data)\n{\n";
f << ",\n void *user_data)\n{\n";
f << " Tox_Event_" << event_name << " *" << event_name_l << " = tox_event_" << event_name_l << "_alloc(user_data);\n\n";
f << " if (" << event_name_l << " == nullptr) {\n return;\n }\n\n";

View File

@ -198,7 +198,6 @@ int main(int argc, char *argv[])
randombytes(priv_key, KEY_LEN);
uint32_t longest_match = 0;
// Finishes a batch every ~10s on my PC
const uint64_t batch_size = (UINT64_C(1) << 18) * NUM_THREADS();
@ -220,7 +219,6 @@ int main(int argc, char *argv[])
return 0;
}
for (uint64_t tries = 0; tries < rem_start; tries += batch_size) {
cracker_core(tries, tries + batch_size, 0, priv_key_shadow, &longest_match, hex_prefix, prefix_chars_len);

View File

@ -30,7 +30,6 @@ static void print_key(const uint8_t *client_id)
}
}
int main(int argc, char *argv[])
{
if (argc < 2) {

View File

@ -138,7 +138,6 @@ int cmdline_parsefor_ipv46(int argc, char **argv, bool *ipv6enabled)
return argvoffset;
}
static const char *test_rng_name(void)
{
return "test_rng";

View File

@ -25,8 +25,6 @@ static bool reconfigure_audio_encoder(const Logger *log, OpusEncoder **e, uint32
uint8_t new_ch, uint32_t *old_br, uint32_t *old_sr, uint8_t *old_ch);
static bool reconfigure_audio_decoder(ACSession *ac, uint32_t sampling_rate, uint8_t channels);
ACSession *ac_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number,
toxav_audio_receive_frame_cb *cb, void *cb_data)
{
@ -242,8 +240,6 @@ int ac_reconfigure_encoder(ACSession *ac, uint32_t bit_rate, uint32_t sampling_r
return 0;
}
struct JitterBuffer {
struct RTPMessage **queue;
uint32_t size;
@ -365,7 +361,6 @@ static OpusEncoder *create_audio_encoder(const Logger *log, uint32_t bit_rate, u
return nullptr;
}
/*
* Rates from 500 to 512000 bits per second are meaningful as well as the special
* values OPUS_BITRATE_AUTO and OPUS_BITRATE_MAX. The value OPUS_BITRATE_MAX can
@ -382,7 +377,6 @@ static OpusEncoder *create_audio_encoder(const Logger *log, uint32_t bit_rate, u
goto FAILURE;
}
/*
* Configures the encoder's use of inband forward error correction.
* Note:
@ -398,7 +392,6 @@ static OpusEncoder *create_audio_encoder(const Logger *log, uint32_t bit_rate, u
goto FAILURE;
}
/*
* Configures the encoder's expected packet loss percentage.
* Higher values with trigger progressively more loss resistant behavior in
@ -418,7 +411,6 @@ static OpusEncoder *create_audio_encoder(const Logger *log, uint32_t bit_rate, u
goto FAILURE;
}
/*
* Configures the encoder's computational complexity.
*

View File

@ -34,7 +34,6 @@ int add_av_groupchat(const Logger *log, Tox *tox, Group_Chats *g_c, audio_data_c
int join_av_groupchat(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t peer_number, const uint8_t *data,
uint16_t length, audio_data_cb *audio_callback, void *userdata);
/** @brief Send audio to the conference.
*
* @retval 0 on success.

View File

@ -27,14 +27,12 @@ typedef enum MSIHeaderID {
ID_CAPABILITIES,
} MSIHeaderID;
typedef enum MSIRequest {
REQU_INIT,
REQU_PUSH,
REQU_POP,
} MSIRequest;
typedef struct MSIHeaderRequest {
MSIRequest value;
bool exists;
@ -50,14 +48,12 @@ typedef struct MSIHeaderCapabilities {
bool exists;
} MSIHeaderCapabilities;
typedef struct MSIMessage {
MSIHeaderRequest request;
MSIHeaderError error;
MSIHeaderCapabilities capabilities;
} MSIMessage;
static void msg_init(MSIMessage *dest, MSIRequest request);
static int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data, uint16_t length);
static uint8_t *msg_parse_header_out(MSIHeaderID id, uint8_t *dest, const uint8_t *value, uint8_t value_len,
@ -74,7 +70,6 @@ static void handle_push(MSICall *call, const MSIMessage *msg);
static void handle_pop(MSICall *call, const MSIMessage *msg);
static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *user_data);
/*
* Public functions
*/
@ -318,7 +313,6 @@ int msi_change_capabilities(MSICall *call, uint8_t capabilities)
return 0;
}
/**
* Private functions
*/
@ -357,7 +351,6 @@ static bool check_enum_high(const Logger *log, const uint8_t *bytes, uint8_t enu
return true;
}
static int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data, uint16_t length)
{
/* Parse raw data received from socket into MSIMessage struct */
@ -449,7 +442,7 @@ static int send_message(const Messenger *m, uint32_t friend_number, const MSIMes
/* Parse and send message */
assert(m != nullptr);
uint8_t parsed [MSI_MAXMSG_SIZE];
uint8_t parsed[MSI_MAXMSG_SIZE];
uint8_t *it = parsed;
uint16_t size = 0;
@ -587,7 +580,7 @@ static MSICall *new_call(MSISession *session, uint32_t friend_number)
session->calls_tail = friend_number;
session->calls_head = friend_number;
} else if (session->calls_tail < friend_number) { /* Appending */
MSICall **tmp = (MSICall **)realloc(session->calls, (friend_number + 1) * sizeof(MSICall *));
MSICall **tmp = (MSICall **)realloc(session->calls, (friend_number + 1) * sizeof(MSICall *));
if (tmp == nullptr) {
free(rc);

View File

@ -38,7 +38,6 @@ typedef enum MSICapabilities {
MSI_CAP_R_VIDEO = 32, /* receiving video */
} MSICapabilities;
/**
* Call state identifiers.
*/
@ -80,7 +79,6 @@ typedef struct MSICall {
struct MSICall *prev;
} MSICall;
/**
* Expected return on success is 0, if any other number is
* returned the call is considered errored and will be handled

View File

@ -23,7 +23,6 @@
*/
#define VIDEO_KEEP_KEYFRAME_IN_BUFFER_FOR_MS 15
/**
* return -1 on failure, 0 on success
*

View File

@ -52,7 +52,6 @@ typedef enum RTPFlags {
RTP_KEY_FRAME = 1 << 1,
} RTPFlags;
struct RTPHeader {
/* Standard RTP header */
unsigned ve: 2; /* Version has only 2 bits! */
@ -100,7 +99,6 @@ struct RTPHeader {
uint16_t data_length_lower;
};
struct RTPMessage {
/**
* This is used in the old code that doesn't deal with large frames, i.e.
@ -167,7 +165,6 @@ typedef struct RTPSession {
rtp_m_cb *mcb;
} RTPSession;
/**
* Serialise an RTPHeader to bytes to be sent over the network.
*

View File

@ -65,7 +65,6 @@ typedef struct ToxAVCall {
struct ToxAVCall *next;
} ToxAVCall;
/** Decode time statistics */
typedef struct DecodeTimeStats {
/** Measure count */
@ -857,7 +856,7 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc
sampling_rate = net_htonl(sampling_rate);
memcpy(dest, &sampling_rate, sizeof(sampling_rate));
const int vrc = opus_encode(call->audio->encoder, pcm, sample_count,
dest + sizeof(sampling_rate), dest_size - sizeof(sampling_rate));
dest + sizeof(sampling_rate), dest_size - sizeof(sampling_rate));
if (vrc < 0) {
LOGGER_WARNING(av->m->log, "Failed to encode frame %s", opus_strerror(vrc));
@ -1004,7 +1003,7 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u
memcpy(img.planes[VPX_PLANE_V], v, (width / 2) * (height / 2));
const vpx_codec_err_t vrc = vpx_codec_encode(call->video->encoder, &img,
call->video->frame_counter, 1, vpx_encode_flags, MAX_ENCODE_TIME_US);
call->video->frame_counter, 1, vpx_encode_flags, MAX_ENCODE_TIME_US);
vpx_img_free(&img);

View File

@ -83,7 +83,6 @@ typedef struct Tox Tox;
*/
typedef struct ToxAV ToxAV;
/** @{
* @brief Creation and destruction
*/
@ -113,7 +112,6 @@ typedef enum Toxav_Err_New {
} Toxav_Err_New;
/**
* Start new A/V session. There can only be only one session per Tox instance.
*/
@ -135,7 +133,6 @@ Tox *toxav_get_tox(const ToxAV *av);
/** @} */
/** @{
* @brief A/V event loop, single thread
*/
@ -156,7 +153,6 @@ void toxav_iterate(ToxAV *av);
/** @} */
/** @{
* @brief A/V event loop, multiple threads
*/
@ -195,7 +191,6 @@ void toxav_video_iterate(ToxAV *av);
/** @} */
/** @{
* @brief Call setup
*/
@ -241,7 +236,6 @@ typedef enum Toxav_Err_Call {
} Toxav_Err_Call;
/**
* Call a friend. This will start ringing the friend.
*
@ -268,7 +262,6 @@ bool toxav_call(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, uint
*/
typedef void toxav_call_cb(ToxAV *av, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *user_data);
/**
* Set the callback for the `call` event. Pass NULL to unset.
*
@ -312,7 +305,6 @@ typedef enum Toxav_Err_Answer {
} Toxav_Err_Answer;
/**
* Accept an incoming call.
*
@ -331,7 +323,6 @@ bool toxav_answer(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, ui
/** @} */
/** @{
* @brief Call state graph
*/
@ -380,7 +371,6 @@ enum Toxav_Friend_Call_State {
};
/**
* The function type for the call_state callback.
*
@ -392,7 +382,6 @@ enum Toxav_Friend_Call_State {
*/
typedef void toxav_call_state_cb(ToxAV *av, uint32_t friend_number, uint32_t state, void *user_data);
/**
* Set the callback for the `call_state` event. Pass NULL to unset.
*
@ -401,7 +390,6 @@ void toxav_callback_call_state(ToxAV *av, toxav_call_state_cb *callback, void *u
/** @} */
/** @{
* @brief Call control
*/
@ -451,7 +439,6 @@ typedef enum Toxav_Call_Control {
} Toxav_Call_Control;
typedef enum Toxav_Err_Call_Control {
/**
@ -483,7 +470,6 @@ typedef enum Toxav_Err_Call_Control {
} Toxav_Err_Call_Control;
/**
* Sends a call control command to a friend.
*
@ -497,7 +483,6 @@ bool toxav_call_control(ToxAV *av, uint32_t friend_number, Toxav_Call_Control co
/** @} */
/** @{
* @brief Controlling bit rates
*/
@ -533,8 +518,6 @@ typedef enum Toxav_Err_Bit_Rate_Set {
/** @} */
/** @{
* @brief A/V sending
*/
@ -586,7 +569,6 @@ typedef enum Toxav_Err_Send_Frame {
} Toxav_Err_Send_Frame;
/**
* Send an audio frame to a friend.
*
@ -632,7 +614,6 @@ bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t bit_ra
*/
typedef void toxav_audio_bit_rate_cb(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, void *user_data);
/**
* Set the callback for the `audio_bit_rate` event. Pass NULL to unset.
*
@ -655,11 +636,11 @@ void toxav_callback_audio_bit_rate(ToxAV *av, toxav_audio_bit_rate_cb *callback,
* @param v V (Chroma) plane data.
*/
bool toxav_video_send_frame(
ToxAV *av, uint32_t friend_number, uint16_t width, uint16_t height,
const uint8_t y[/*! height * width */],
const uint8_t u[/*! height/2 * width/2 */],
const uint8_t v[/*! height/2 * width/2 */],
Toxav_Err_Send_Frame *error);
ToxAV *av, uint32_t friend_number, uint16_t width, uint16_t height,
const uint8_t y[/*! height * width */],
const uint8_t u[/*! height/2 * width/2 */],
const uint8_t v[/*! height/2 * width/2 */],
Toxav_Err_Send_Frame *error);
/**
* Set the bit rate to be used in subsequent video frames.
@ -683,7 +664,6 @@ bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t bit_ra
*/
typedef void toxav_video_bit_rate_cb(ToxAV *av, uint32_t friend_number, uint32_t video_bit_rate, void *user_data);
/**
* Set the callback for the `video_bit_rate` event. Pass NULL to unset.
*
@ -692,7 +672,6 @@ void toxav_callback_video_bit_rate(ToxAV *av, toxav_video_bit_rate_cb *callback,
/** @} */
/** @{
* @brief A/V receiving
*/
@ -712,7 +691,6 @@ void toxav_callback_video_bit_rate(ToxAV *av, toxav_video_bit_rate_cb *callback,
typedef void toxav_audio_receive_frame_cb(ToxAV *av, uint32_t friend_number, const int16_t pcm[], size_t sample_count,
uint8_t channels, uint32_t sampling_rate, void *user_data);
/**
* Set the callback for the `audio_receive_frame` event. Pass NULL to unset.
*
@ -742,14 +720,13 @@ void toxav_callback_audio_receive_frame(ToxAV *av, toxav_audio_receive_frame_cb
* @param vstride V chroma plane stride.
*/
typedef void toxav_video_receive_frame_cb(
ToxAV *av, uint32_t friend_number,
uint16_t width, uint16_t height,
const uint8_t y[/*! max(width, abs(ystride)) * height */],
const uint8_t u[/*! max(width/2, abs(ustride)) * (height/2) */],
const uint8_t v[/*! max(width/2, abs(vstride)) * (height/2) */],
int32_t ystride, int32_t ustride, int32_t vstride,
void *user_data);
ToxAV *av, uint32_t friend_number,
uint16_t width, uint16_t height,
const uint8_t y[/*! max(width, abs(ystride)) * height */],
const uint8_t u[/*! max(width/2, abs(ustride)) * (height/2) */],
const uint8_t v[/*! max(width/2, abs(vstride)) * (height/2) */],
int32_t ystride, int32_t ustride, int32_t vstride,
void *user_data);
/**
* Set the callback for the `video_receive_frame` event. Pass NULL to unset.
@ -791,8 +768,8 @@ int32_t toxav_add_av_groupchat(Tox *tox, toxav_audio_data_cb *audio_callback, vo
* Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`.
*/
int32_t toxav_join_av_groupchat(
Tox *tox, uint32_t friendnumber, const uint8_t data[], uint16_t length,
toxav_audio_data_cb *audio_callback, void *userdata);
Tox *tox, uint32_t friendnumber, const uint8_t data[], uint16_t length,
toxav_audio_data_cb *audio_callback, void *userdata);
/** @brief Send audio to the group chat.
*
@ -809,8 +786,8 @@ int32_t toxav_join_av_groupchat(
* Recommended values are: samples = 960, channels = 1, sample_rate = 48000
*/
int32_t toxav_group_send_audio(
Tox *tox, uint32_t groupnumber, const int16_t pcm[], uint32_t samples, uint8_t channels,
uint32_t sample_rate);
Tox *tox, uint32_t groupnumber, const int16_t pcm[], uint32_t samples, uint8_t channels,
uint32_t sample_rate);
/** @brief Enable A/V in a groupchat.
*
@ -828,8 +805,8 @@ int32_t toxav_group_send_audio(
* Note that total size of pcm in bytes is equal to `samples * channels * sizeof(int16_t)`.
*/
int32_t toxav_groupchat_enable_av(
Tox *tox, uint32_t groupnumber,
toxav_audio_data_cb *audio_callback, void *userdata);
Tox *tox, uint32_t groupnumber,
toxav_audio_data_cb *audio_callback, void *userdata);
/** @brief Disable A/V in a groupchat.
*

View File

@ -84,7 +84,7 @@ struct DHT_Friend {
static const DHT_Friend empty_dht_friend = {{0}};
const Node_format empty_node_format = {{0}};
static_assert(sizeof (empty_dht_friend.lock_flags) * 8 == DHT_FRIEND_MAX_LOCKS, "Bitfield size and number of locks don't match");
static_assert(sizeof(empty_dht_friend.lock_flags) * 8 == DHT_FRIEND_MAX_LOCKS, "Bitfield size and number of locks don't match");
typedef struct Cryptopacket_Handler {
cryptopacket_handler_cb *function;
@ -363,7 +363,6 @@ int packed_node_size(Family ip_family)
return -1;
}
int dht_create_packet(const Memory *mem, const Random *rng,
const uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE],
const uint8_t *shared_key, const uint8_t type,
@ -613,8 +612,8 @@ static bool client_or_ip_port_in_list(const Logger *log, const Mono_Time *mono_t
}
bool add_to_list(
Node_format *nodes_list, uint32_t length, const uint8_t pk[CRYPTO_PUBLIC_KEY_SIZE],
const IP_Port *ip_port, const uint8_t cmp_pk[CRYPTO_PUBLIC_KEY_SIZE])
Node_format *nodes_list, uint32_t length, const uint8_t pk[CRYPTO_PUBLIC_KEY_SIZE],
const IP_Port *ip_port, const uint8_t cmp_pk[CRYPTO_PUBLIC_KEY_SIZE])
{
for (uint32_t i = 0; i < length; ++i) {
Node_format *node = &nodes_list[i];
@ -644,10 +643,10 @@ bool add_to_list(
*/
non_null()
static void get_close_nodes_inner(
uint64_t cur_time, const uint8_t *public_key,
Node_format *nodes_list, uint32_t *num_nodes_ptr,
Family sa_family, const Client_data *client_list, uint32_t client_list_length,
bool is_lan, bool want_announce)
uint64_t cur_time, const uint8_t *public_key,
Node_format *nodes_list, uint32_t *num_nodes_ptr,
Family sa_family, const Client_data *client_list, uint32_t client_list_length,
bool is_lan, bool want_announce)
{
if (!net_family_is_ipv4(sa_family) && !net_family_is_ipv6(sa_family) && !net_family_is_unspec(sa_family)) {
return;
@ -715,10 +714,10 @@ static void get_close_nodes_inner(
*/
non_null()
static int get_somewhat_close_nodes(
uint64_t cur_time, const uint8_t *public_key, Node_format nodes_list[MAX_SENT_NODES],
Family sa_family, const Client_data *close_clientlist,
const DHT_Friend *friends_list, uint16_t friends_list_size,
bool is_lan, bool want_announce)
uint64_t cur_time, const uint8_t *public_key, Node_format nodes_list[MAX_SENT_NODES],
Family sa_family, const Client_data *close_clientlist,
const DHT_Friend *friends_list, uint16_t friends_list_size,
bool is_lan, bool want_announce)
{
for (uint16_t i = 0; i < MAX_SENT_NODES; ++i) {
nodes_list[i] = empty_node_format;
@ -726,34 +725,34 @@ static int get_somewhat_close_nodes(
uint32_t num_nodes = 0;
get_close_nodes_inner(
cur_time, public_key,
nodes_list, &num_nodes,
sa_family, close_clientlist, LCLIENT_LIST,
is_lan, want_announce);
cur_time, public_key,
nodes_list, &num_nodes,
sa_family, close_clientlist, LCLIENT_LIST,
is_lan, want_announce);
for (uint16_t i = 0; i < friends_list_size; ++i) {
const DHT_Friend *dht_friend = &friends_list[i];
get_close_nodes_inner(
cur_time, public_key,
nodes_list, &num_nodes,
sa_family, dht_friend->client_list, MAX_FRIEND_CLIENTS,
is_lan, want_announce);
cur_time, public_key,
nodes_list, &num_nodes,
sa_family, dht_friend->client_list, MAX_FRIEND_CLIENTS,
is_lan, want_announce);
}
return num_nodes;
}
int get_close_nodes(
const DHT *dht, const uint8_t *public_key,
Node_format nodes_list[MAX_SENT_NODES], Family sa_family,
bool is_lan, bool want_announce)
const DHT *dht, const uint8_t *public_key,
Node_format nodes_list[MAX_SENT_NODES], Family sa_family,
bool is_lan, bool want_announce)
{
return get_somewhat_close_nodes(
dht->cur_time, public_key, nodes_list,
sa_family, dht->close_clientlist,
dht->friends_list, dht->num_friends,
is_lan, want_announce);
dht->cur_time, public_key, nodes_list,
sa_family, dht->close_clientlist,
dht->friends_list, dht->num_friends,
is_lan, want_announce);
}
typedef struct DHT_Cmp_Data {
@ -1522,7 +1521,7 @@ static int handle_sendnodes_ipv6(void *object, const IP_Port *source, const uint
non_null(1) nullable(2, 3)
static uint32_t dht_friend_lock(DHT_Friend *const dht_friend, dht_ip_cb *ip_callback,
void *data, int32_t number)
void *data, int32_t number)
{
// find first free slot
uint8_t lock_num;
@ -1970,7 +1969,6 @@ static int friend_iplist(const DHT *dht, IP_Port *ip_portlist, uint16_t friend_n
#endif /* !FRIEND_IPLIST_PAD */
}
/**
* Callback invoked for each IP/port of each client of a friend.
*
@ -2057,7 +2055,6 @@ uint32_t route_to_friend(const DHT *dht, const uint8_t *friend_id, const Packet
return 0;
}
IP_Port ip_list[MAX_FRIEND_CLIENTS];
const int ip_num = friend_iplist(dht, ip_list, num);
@ -2571,7 +2568,6 @@ DHT *new_dht(const Logger *log, const Memory *mem, const Random *rng, const Netw
return nullptr;
}
dht->dht_ping_array = ping_array_new(mem, DHT_PING_ARRAY_SIZE, PING_TIMEOUT);
if (dht->dht_ping_array == nullptr) {
@ -2744,8 +2740,8 @@ void dht_save(const DHT *dht, uint8_t *data)
}
state_write_section_header(
old_data, DHT_STATE_COOKIE_TYPE, pack_nodes(dht->log, data, sizeof(Node_format) * num, clients, num),
DHT_STATE_TYPE_NODES);
old_data, DHT_STATE_COOKIE_TYPE, pack_nodes(dht->log, data, sizeof(Node_format) * num, clients, num),
DHT_STATE_TYPE_NODES);
mem_delete(dht->mem, clients);
}
@ -2884,7 +2880,8 @@ bool dht_non_lan_connected(const DHT *dht)
return false;
}
uint16_t dht_get_num_closelist(const DHT *dht) {
uint16_t dht_get_num_closelist(const DHT *dht)
{
uint16_t num_valid_close_clients = 0;
for (uint32_t i = 0; i < LCLIENT_LIST; ++i) {
const Client_data *const client = dht_get_close_client(dht, i);
@ -2898,7 +2895,8 @@ uint16_t dht_get_num_closelist(const DHT *dht) {
return num_valid_close_clients;
}
uint16_t dht_get_num_closelist_announce_capable(const DHT *dht) {
uint16_t dht_get_num_closelist_announce_capable(const DHT *dht)
{
uint16_t num_valid_close_clients_with_cap = 0;
for (uint32_t i = 0; i < LCLIENT_LIST; ++i) {
const Client_data *const client = dht_get_close_client(dht, i);

View File

@ -36,7 +36,6 @@ extern "C" {
#define EXT_SECRET_KEY_SIZE (ENC_SECRET_KEY_SIZE + SIG_SECRET_KEY_SIZE)
#define EXT_PUBLIC_KEY_SIZE (ENC_PUBLIC_KEY_SIZE + SIG_PUBLIC_KEY_SIZE)
/* Maximum size of a signature (may be smaller) */
#define SIGNATURE_SIZE CRYPTO_SIGNATURE_SIZE
/** Maximum number of clients stored per friend. */
@ -350,8 +349,8 @@ unsigned int bit_by_bit_cmp(const uint8_t *pk1, const uint8_t *pk2);
*/
non_null()
bool add_to_list(
Node_format *nodes_list, uint32_t length, const uint8_t pk[CRYPTO_PUBLIC_KEY_SIZE],
const IP_Port *ip_port, const uint8_t cmp_pk[CRYPTO_PUBLIC_KEY_SIZE]);
Node_format *nodes_list, uint32_t length, const uint8_t pk[CRYPTO_PUBLIC_KEY_SIZE],
const IP_Port *ip_port, const uint8_t cmp_pk[CRYPTO_PUBLIC_KEY_SIZE]);
/** Return 1 if node can be added to close list, 0 if it can't. */
non_null()
@ -375,10 +374,9 @@ void set_announce_node(DHT *dht, const uint8_t *public_key);
*/
non_null()
int get_close_nodes(
const DHT *dht, const uint8_t *public_key,
Node_format nodes_list[MAX_SENT_NODES], Family sa_family,
bool is_lan, bool want_announce);
const DHT *dht, const uint8_t *public_key,
Node_format nodes_list[MAX_SENT_NODES], Family sa_family,
bool is_lan, bool want_announce);
/** @brief Put up to max_num nodes in nodes from the random friends.
*

View File

@ -45,7 +45,6 @@
#define MAX_INTERFACES 16
struct Broadcast_Info {
uint32_t count;
IP ips[MAX_INTERFACES];
@ -240,8 +239,8 @@ static IP broadcast_ip(Family family_socket, Family family_broadcast)
/* `FF02::1` is - according to RFC 4291 - multicast all-nodes link-local */
/* `FE80::*:` MUST be exact, for that we would need to look over all
* interfaces and check in which status they are */
ip.ip.v6.uint8[ 0] = 0xFF;
ip.ip.v6.uint8[ 1] = 0x02;
ip.ip.v6.uint8[0] = 0xFF;
ip.ip.v6.uint8[1] = 0x02;
ip.ip.v6.uint8[15] = 0x01;
} else if (net_family_is_ipv4(family_broadcast)) {
ip.family = net_family_ipv6();
@ -340,7 +339,6 @@ bool ip_is_lan(const IP *ip)
return false;
}
bool lan_discovery_send(const Networking_Core *net, const Broadcast_Info *broadcast, const uint8_t *dht_pk,
uint16_t port)
{
@ -377,7 +375,6 @@ bool lan_discovery_send(const Networking_Core *net, const Broadcast_Info *broadc
return res;
}
Broadcast_Info *lan_discovery_init(const Network *ns)
{
return fetch_broadcast_info(ns);

View File

@ -592,7 +592,7 @@ int m_send_message_generic(Messenger *m, int32_t friendnumber, uint8_t type, con
memcpy(packet + 1, message, length);
const int64_t packet_num = write_cryptpacket(m->net_crypto, friend_connection_crypt_connection_id(m->fr_c,
m->friendlist[friendnumber].friendcon_id), packet, length + 1, false);
m->friendlist[friendnumber].friendcon_id), packet, length + 1, false);
if (packet_num == -1) {
return -4;
@ -1098,7 +1098,6 @@ static void set_friend_status(Messenger *m, int32_t friendnumber, uint8_t status
/*** CONFERENCES */
/** @brief Set the callback for conference invites. */
void m_callback_conference_invite(Messenger *m, m_conference_invite_cb *function)
{
@ -1121,7 +1120,6 @@ bool send_conference_invite_packet(const Messenger *m, int32_t friendnumber, con
return write_cryptpacket_id(m, friendnumber, PACKET_ID_INVITE_CONFERENCE, data, length, false);
}
/** @brief Send a group invite packet.
*
* @retval true if success
@ -1131,10 +1129,8 @@ bool send_group_invite_packet(const Messenger *m, uint32_t friendnumber, const u
return write_cryptpacket_id(m, friendnumber, PACKET_ID_INVITE_GROUPCHAT, packet, length, false);
}
/*** FILE SENDING */
/** @brief Set the callback for file send requests. */
void callback_file_sendrequest(Messenger *m, m_file_recv_cb *function)
{
@ -1196,8 +1192,8 @@ int file_get_id(const Messenger *m, int32_t friendnumber, uint32_t filenumber, u
file_number = temp_filenum;
const struct File_Transfers *const ft = inbound
? &m->friendlist[friendnumber].file_receiving[file_number]
: &m->friendlist[friendnumber].file_sending[file_number];
? &m->friendlist[friendnumber].file_receiving[file_number]
: &m->friendlist[friendnumber].file_sending[file_number];
if (ft->status == FILESTATUS_NONE) {
return -2;
@ -1716,7 +1712,6 @@ static void do_reqchunk_filecb(Messenger *m, int32_t friendnumber, void *userdat
}
}
/** @brief Run this when the friend disconnects.
* Kill all current file transfers.
*/
@ -1925,7 +1920,6 @@ int m_callback_rtp_packet(Messenger *m, int32_t friendnumber, uint8_t byte, m_lo
return 0;
}
/** @brief High level function to send custom lossy packets.
*
* TODO(oxij): this name is confusing, because this function sends both av and custom lossy packets.
@ -2465,8 +2459,8 @@ static void do_friends(Messenger *m, void *userdata)
for (uint32_t i = 0; i < m->numfriends; ++i) {
if (m->friendlist[i].status == FRIEND_ADDED) {
const int fr = send_friend_request_packet(m->fr_c, m->friendlist[i].friendcon_id, m->friendlist[i].friendrequest_nospam,
m->friendlist[i].info,
m->friendlist[i].info_size);
m->friendlist[i].info,
m->friendlist[i].info_size);
if (fr >= 0) {
set_friend_status(m, i, FRIEND_REQUESTED, userdata);
@ -2532,7 +2526,6 @@ static void m_connection_status_callback(Messenger *m, void *userdata)
}
}
#define DUMPING_CLIENTS_FRIENDS_EVERY_N_SECONDS 60UL
#define IDSTRING_LEN (CRYPTO_PUBLIC_KEY_SIZE * 2 + 1)
@ -2725,7 +2718,6 @@ void do_messenger(Messenger *m, void *userdata)
}
}
/* dht contains additional "friends" (requests) */
const uint32_t num_dhtfriends = dht_get_num_friends(m->dht);
VLA(int32_t, m2dht, num_dhtfriends);
@ -2893,7 +2885,6 @@ static uint8_t *friend_save(const struct Saved_Friend *temp, uint8_t *data)
return data;
}
non_null()
static const uint8_t *friend_load(struct Saved_Friend *temp, const uint8_t *data)
{
@ -2931,7 +2922,6 @@ static const uint8_t *friend_load(struct Saved_Friend *temp, const uint8_t *data
return data;
}
non_null()
static uint32_t m_state_plugins_size(const Messenger *m)
{
@ -2960,7 +2950,7 @@ bool m_register_state_plugin(Messenger *m, State_Type type, m_state_size_cb *siz
{
const uint32_t new_length = m->options.state_plugins_length + 1;
Messenger_State_Plugin *temp = (Messenger_State_Plugin *)mem_vrealloc(
m->mem, m->options.state_plugins, new_length, sizeof(Messenger_State_Plugin));
m->mem, m->options.state_plugins, new_length, sizeof(Messenger_State_Plugin));
if (temp == nullptr) {
return false;

View File

@ -39,7 +39,6 @@
/* This cannot be bigger than 256 */
#define MAX_CONCURRENT_FILE_PIPES 256
#define FRIEND_ADDRESS_SIZE (CRYPTO_PUBLIC_KEY_SIZE + sizeof(uint32_t) + sizeof(uint16_t))
typedef enum Message_Type {
@ -88,7 +87,6 @@ typedef struct Messenger_Options {
uint8_t state_plugins_length;
} Messenger_Options;
struct Receipts {
uint32_t packet_num;
uint32_t msg_id;
@ -118,7 +116,6 @@ typedef enum Friend_Add_Error {
FAERR_NOMEM = -8,
} Friend_Add_Error;
/** Default start timeout in seconds between friend requests. */
#define FRIENDREQUEST_TIMEOUT 5
@ -176,7 +173,6 @@ typedef enum Filekind {
FILEKIND_AVATAR,
} Filekind;
typedef void m_self_connection_status_cb(Messenger *m, Onion_Connection_Status connection_status, void *user_data);
typedef void m_friend_status_cb(Messenger *m, uint32_t friend_number, unsigned int status, void *user_data);
typedef void m_friend_connection_status_cb(Messenger *m, uint32_t friend_number, unsigned int connection_status,
@ -369,7 +365,6 @@ void getaddress(const Messenger *m, uint8_t *address);
non_null()
int32_t m_addfriend(Messenger *m, const uint8_t *address, const uint8_t *data, uint16_t length);
/** @brief Add a friend without sending a friendrequest.
* @return the friend number if success.
* @retval -3 if user's own key.
@ -459,7 +454,6 @@ non_null(1, 4) nullable(6)
int m_send_message_generic(Messenger *m, int32_t friendnumber, uint8_t type, const uint8_t *message, uint32_t length,
uint32_t *message_id);
/** @brief Set the name and name_length of a friend.
*
* name must be a string of maximum MAX_NAME_LENGTH length.
@ -550,7 +544,6 @@ non_null() int m_copy_self_statusmessage(const Messenger *m, uint8_t *buf);
non_null() uint8_t m_get_userstatus(const Messenger *m, int32_t friendnumber);
non_null() uint8_t m_get_self_userstatus(const Messenger *m);
/** @brief returns timestamp of last time friendnumber was seen online or 0 if never seen.
* if friendnumber is invalid this function will return UINT64_MAX.
*/
@ -624,7 +617,6 @@ non_null() void m_callback_connectionstatus(Messenger *m, m_friend_connection_st
non_null() void m_callback_connectionstatus_internal_av(
Messenger *m, m_friend_connectionstatuschange_internal_cb *function, void *userdata);
/** @brief Set the callback for typing changes. */
non_null() void m_callback_core_connection(Messenger *m, m_self_connection_status_cb *function);
@ -639,7 +631,6 @@ void m_callback_conference_invite(Messenger *m, m_conference_invite_cb *function
non_null(1) nullable(2)
void m_callback_group_invite(Messenger *m, m_group_invite_cb *function);
/** @brief Send a conference invite packet.
*
* return true on success
@ -658,14 +649,11 @@ bool send_conference_invite_packet(const Messenger *m, int32_t friendnumber, con
non_null()
bool send_group_invite_packet(const Messenger *m, uint32_t friendnumber, const uint8_t *packet, uint16_t length);
/*** FILE SENDING */
/** @brief Set the callback for file send requests. */
non_null() void callback_file_sendrequest(Messenger *m, m_file_recv_cb *function);
/** @brief Set the callback for file control requests. */
non_null() void callback_file_control(Messenger *m, m_file_recv_control_cb *function);
@ -675,7 +663,6 @@ non_null() void callback_file_data(Messenger *m, m_file_recv_chunk_cb *function)
/** @brief Set the callback for file request chunk. */
non_null() void callback_file_reqchunk(Messenger *m, m_file_chunk_request_cb *function);
/** @brief Copy the file transfer file id to file_id
*
* @retval 0 on success.
@ -790,7 +777,6 @@ non_null() void custom_lossy_packet_registerhandler(Messenger *m, m_friend_lossy
non_null()
int m_send_custom_lossy_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length);
/** @brief Set handlers for custom lossless packets. */
non_null()
void custom_lossless_packet_registerhandler(Messenger *m, m_friend_lossless_packet_cb *lossless_packethandler);

View File

@ -313,7 +313,7 @@ static int generate_handshake(TCP_Client_Connection *tcp_conn)
memcpy(tcp_conn->con.last_packet, tcp_conn->self_public_key, CRYPTO_PUBLIC_KEY_SIZE);
random_nonce(tcp_conn->con.rng, tcp_conn->con.last_packet + CRYPTO_PUBLIC_KEY_SIZE);
const int len = encrypt_data_symmetric(tcp_conn->con.shared_key, tcp_conn->con.last_packet + CRYPTO_PUBLIC_KEY_SIZE, plain,
sizeof(plain), tcp_conn->con.last_packet + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE);
sizeof(plain), tcp_conn->con.last_packet + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE);
if (len != sizeof(plain) + CRYPTO_MAC_SIZE) {
return -1;
@ -335,7 +335,7 @@ static int handle_handshake(TCP_Client_Connection *tcp_conn, const uint8_t *data
{
uint8_t plain[CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE];
const int len = decrypt_data_symmetric(tcp_conn->con.shared_key, data, data + CRYPTO_NONCE_SIZE,
TCP_SERVER_HANDSHAKE_SIZE - CRYPTO_NONCE_SIZE, plain);
TCP_SERVER_HANDSHAKE_SIZE - CRYPTO_NONCE_SIZE, plain);
if (len != sizeof(plain)) {
return -1;
@ -421,7 +421,6 @@ int send_oob_packet(const Logger *logger, TCP_Client_Connection *con, const uint
return write_packet_tcp_secure_connection(logger, &con->con, packet, packet_size, false);
}
/** @brief Set the number that will be used as an argument in the callbacks related to con_id.
*
* When not set by this function, the number is -1.
@ -581,9 +580,9 @@ void forwarding_handler(TCP_Client_Connection *con, forwarded_response_cb *forwa
/** Create new TCP connection to ip_port/public_key */
TCP_Client_Connection *new_tcp_connection(
const Logger *logger, const Memory *mem, const Mono_Time *mono_time, const Random *rng, const Network *ns,
const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *self_public_key, const uint8_t *self_secret_key,
const TCP_Proxy_Info *proxy_info)
const Logger *logger, const Memory *mem, const Mono_Time *mono_time, const Random *rng, const Network *ns,
const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *self_public_key, const uint8_t *self_secret_key,
const TCP_Proxy_Info *proxy_info)
{
assert(logger != nullptr);
assert(mem != nullptr);
@ -874,7 +873,8 @@ non_null(1, 2) nullable(3)
static bool tcp_process_packet(const Logger *logger, TCP_Client_Connection *conn, void *userdata)
{
uint8_t packet[MAX_PACKET_SIZE];
const int len = read_packet_tcp_secure_connection(logger, conn->con.mem, conn->con.ns, conn->con.sock, &conn->next_packet_length, conn->con.shared_key, conn->recv_nonce, packet, sizeof(packet), &conn->ip_port);
const int len = read_packet_tcp_secure_connection(logger, conn->con.mem, conn->con.ns, conn->con.sock, &conn->next_packet_length, conn->con.shared_key, conn->recv_nonce, packet, sizeof(packet),
&conn->ip_port);
if (len == 0) {
return false;

View File

@ -62,9 +62,9 @@ void tcp_con_set_custom_uint(TCP_Client_Connection *con, uint32_t value);
/** Create new TCP connection to ip_port/public_key */
non_null(1, 2, 3, 4, 5, 6, 7, 8, 9) nullable(10)
TCP_Client_Connection *new_tcp_connection(
const Logger *logger, const Memory *mem, const Mono_Time *mono_time, const Random *rng, const Network *ns,
const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *self_public_key, const uint8_t *self_secret_key,
const TCP_Proxy_Info *proxy_info);
const Logger *logger, const Memory *mem, const Mono_Time *mono_time, const Random *rng, const Network *ns,
const IP_Port *ip_port, const uint8_t *public_key, const uint8_t *self_public_key, const uint8_t *self_secret_key,
const TCP_Proxy_Info *proxy_info);
/** Run the TCP connection */
non_null(1, 2, 3) nullable(4)
@ -153,5 +153,4 @@ int send_oob_packet(const Logger *logger, TCP_Client_Connection *con, const uint
non_null()
void oob_data_handler(TCP_Client_Connection *con, tcp_oob_data_cb *oob_data_callback, void *object);
#endif /* C_TOXCORE_TOXCORE_TCP_CLIENT_H */

View File

@ -203,7 +203,7 @@ int write_packet_tcp_secure_connection(const Logger *logger, TCP_Connection *con
* return -1 on failure/no data in buffer.
*/
int read_tcp_packet(
const Logger *logger, const Memory *mem, const Network *ns, Socket sock, uint8_t *data, uint16_t length, const IP_Port *ip_port)
const Logger *logger, const Memory *mem, const Network *ns, Socket sock, uint8_t *data, uint16_t length, const IP_Port *ip_port)
{
const uint16_t count = net_socket_data_recv_buffer(ns, sock);
@ -267,10 +267,10 @@ static uint16_t read_tcp_length(const Logger *logger, const Memory *mem, const N
* @retval -1 on failure (connection must be killed).
*/
int read_packet_tcp_secure_connection(
const Logger *logger, const Memory *mem, const Network *ns,
Socket sock, uint16_t *next_packet_length,
const uint8_t *shared_key, uint8_t *recv_nonce, uint8_t *data,
uint16_t max_len, const IP_Port *ip_port)
const Logger *logger, const Memory *mem, const Network *ns,
Socket sock, uint16_t *next_packet_length,
const uint8_t *shared_key, uint8_t *recv_nonce, uint8_t *data,
uint16_t max_len, const IP_Port *ip_port)
{
if (*next_packet_length == 0) {
const uint16_t len = read_tcp_length(logger, mem, ns, sock, ip_port);

View File

@ -89,8 +89,8 @@ int send_pending_data(const Logger *logger, TCP_Connection *con);
*/
non_null()
int write_packet_tcp_secure_connection(
const Logger *logger, TCP_Connection *con, const uint8_t *data, uint16_t length,
bool priority);
const Logger *logger, TCP_Connection *con, const uint8_t *data, uint16_t length,
bool priority);
/** @brief Read length bytes from socket.
*
@ -99,7 +99,7 @@ int write_packet_tcp_secure_connection(
*/
non_null()
int read_tcp_packet(
const Logger *logger, const Memory *mem, const Network *ns, Socket sock, uint8_t *data, uint16_t length, const IP_Port *ip_port);
const Logger *logger, const Memory *mem, const Network *ns, Socket sock, uint8_t *data, uint16_t length, const IP_Port *ip_port);
/**
* @return length of received packet on success.
@ -108,9 +108,9 @@ int read_tcp_packet(
*/
non_null()
int read_packet_tcp_secure_connection(
const Logger *logger, const Memory *mem, const Network *ns,
Socket sock, uint16_t *next_packet_length,
const uint8_t *shared_key, uint8_t *recv_nonce, uint8_t *data,
uint16_t max_len, const IP_Port *ip_port);
const Logger *logger, const Memory *mem, const Network *ns,
Socket sock, uint16_t *next_packet_length,
const uint8_t *shared_key, uint8_t *recv_nonce, uint8_t *data,
uint16_t max_len, const IP_Port *ip_port);
#endif /* C_TOXCORE_TOXCORE_TCP_COMMON_H */

View File

@ -58,17 +58,14 @@ struct TCP_Connections {
uint16_t onion_num_conns;
};
static const TCP_Connection_to empty_tcp_connection_to = {0};
static const TCP_con empty_tcp_con = {0};
const uint8_t *tcp_connections_public_key(const TCP_Connections *tcp_c)
{
return tcp_c->self_public_key;
}
uint32_t tcp_connections_count(const TCP_Connections *tcp_c)
{
return tcp_c->tcp_connections_length;
@ -120,7 +117,6 @@ static int realloc_tcp_con(const Memory *mem, TCP_con **array, size_t num)
return 0;
}
/**
* Return true if the connections_number is valid.
*/
@ -1020,8 +1016,8 @@ static int unsleep_tcp_relay_connection(TCP_Connections *tcp_c, int tcp_connecti
}
tcp_con->connection = new_tcp_connection(
tcp_c->logger, tcp_c->mem, tcp_c->mono_time, tcp_c->rng, tcp_c->ns, &tcp_con->ip_port,
tcp_con->relay_pk, tcp_c->self_public_key, tcp_c->self_secret_key, &tcp_c->proxy_info);
tcp_c->logger, tcp_c->mem, tcp_c->mono_time, tcp_c->rng, tcp_c->ns, &tcp_con->ip_port,
tcp_con->relay_pk, tcp_c->self_public_key, tcp_c->self_secret_key, &tcp_c->proxy_info);
if (tcp_con->connection == nullptr) {
kill_tcp_relay_connection(tcp_c, tcp_connections_number);
@ -1318,8 +1314,8 @@ static int add_tcp_relay_instance(TCP_Connections *tcp_c, const IP_Port *ip_port
TCP_con *tcp_con = &tcp_c->tcp_connections[tcp_connections_number];
tcp_con->connection = new_tcp_connection(
tcp_c->logger, tcp_c->mem, tcp_c->mono_time, tcp_c->rng, tcp_c->ns, &ipp_copy,
relay_pk, tcp_c->self_public_key, tcp_c->self_secret_key, &tcp_c->proxy_info);
tcp_c->logger, tcp_c->mem, tcp_c->mono_time, tcp_c->rng, tcp_c->ns, &ipp_copy,
relay_pk, tcp_c->self_public_key, tcp_c->self_secret_key, &tcp_c->proxy_info);
if (tcp_con->connection == nullptr) {
return -1;

View File

@ -186,7 +186,6 @@ void set_forwarding_packet_tcp_connection_callback(TCP_Connections *tcp_c,
forwarded_response_cb *tcp_forwarded_response_callback,
void *object);
typedef int tcp_oob_cb(void *object, const uint8_t *public_key, unsigned int tcp_connections_number,
const uint8_t *packet, uint16_t length, void *userdata);

View File

@ -62,7 +62,6 @@ typedef struct TCP_Secure_Connection {
static const TCP_Secure_Connection empty_tcp_secure_connection = {{nullptr}};
struct TCP_Server {
const Logger *logger;
const Memory *mem;
@ -188,7 +187,6 @@ static int get_tcp_connection_index(const TCP_Server *tcp_server, const uint8_t
return bs_list_find(&tcp_server->accepted_key_list, public_key);
}
non_null()
static int kill_accepted(TCP_Server *tcp_server, int index);
@ -850,7 +848,6 @@ static int handle_tcp_packet(TCP_Server *tcp_server, uint32_t con_id, const uint
return 0;
}
non_null()
static int confirm_tcp_connection(TCP_Server *tcp_server, const Mono_Time *mono_time, TCP_Secure_Connection *con,
const uint8_t *data, uint16_t length)
@ -1115,7 +1112,8 @@ static int do_unconfirmed(TCP_Server *tcp_server, const Mono_Time *mono_time, ui
LOGGER_TRACE(tcp_server->logger, "handling unconfirmed TCP connection %d", i);
uint8_t packet[MAX_PACKET_SIZE];
const int len = read_packet_tcp_secure_connection(tcp_server->logger, conn->con.mem, conn->con.ns, conn->con.sock, &conn->next_packet_length, conn->con.shared_key, conn->recv_nonce, packet, sizeof(packet), &conn->con.ip_port);
const int len = read_packet_tcp_secure_connection(tcp_server->logger, conn->con.mem, conn->con.ns, conn->con.sock, &conn->next_packet_length, conn->con.shared_key, conn->recv_nonce, packet,
sizeof(packet), &conn->con.ip_port);
if (len == 0) {
return -1;
@ -1135,7 +1133,8 @@ static bool tcp_process_secure_packet(TCP_Server *tcp_server, uint32_t i)
TCP_Secure_Connection *const conn = &tcp_server->accepted_connection_array[i];
uint8_t packet[MAX_PACKET_SIZE];
const int len = read_packet_tcp_secure_connection(tcp_server->logger, conn->con.mem, conn->con.ns, conn->con.sock, &conn->next_packet_length, conn->con.shared_key, conn->recv_nonce, packet, sizeof(packet), &conn->con.ip_port);
const int len = read_packet_tcp_secure_connection(tcp_server->logger, conn->con.mem, conn->con.ns, conn->con.sock, &conn->next_packet_length, conn->con.shared_key, conn->recv_nonce, packet,
sizeof(packet), &conn->con.ip_port);
LOGGER_TRACE(tcp_server->logger, "processing packet for %d: %d", i, len);
if (len == 0) {
@ -1283,7 +1282,6 @@ static bool tcp_epoll_process(TCP_Server *tcp_server, const Mono_Time *mono_time
continue;
}
if ((events[n].events & EPOLLIN) == 0) {
continue;
}

View File

@ -52,5 +52,4 @@ void do_tcp_server(TCP_Server *tcp_server, const Mono_Time *mono_time);
nullable(1)
void kill_tcp_server(TCP_Server *tcp_server);
#endif /* C_TOXCORE_TOXCORE_TCP_SERVER_H */

View File

@ -165,7 +165,6 @@ static const Announce_Entry *get_stored_const(const Announcements *announce, con
return nullptr;
}
bool announce_on_stored(const Announcements *announce, const uint8_t *data_public_key,
announce_on_retrieve_cb *on_retrieve_callback, void *object)
{
@ -388,11 +387,11 @@ static int create_reply_plain_data_search_request(Announcements *announce,
non_null()
static int create_reply_plain_data_retrieve_request(
const Announcements *announce,
const IP_Port *source,
const uint8_t *data, uint16_t length,
uint8_t *reply, uint16_t reply_max_length,
const uint8_t *to_auth, uint16_t to_auth_length)
const Announcements *announce,
const IP_Port *source,
const uint8_t *data, uint16_t length,
uint8_t *reply, uint16_t reply_max_length,
const uint8_t *to_auth, uint16_t to_auth_length)
{
if (length != CRYPTO_PUBLIC_KEY_SIZE + 1 + TIMED_AUTH_SIZE) {
return -1;
@ -447,7 +446,7 @@ static int create_reply_plain_store_announce_request(Announcements *announce,
VLA(uint8_t, plain, plain_len);
const uint8_t* shared_key = shared_key_cache_lookup(announce->shared_keys, data_public_key);
const uint8_t *shared_key = shared_key_cache_lookup(announce->shared_keys, data_public_key);
if (shared_key == nullptr) {
/* Error looking up/deriving the shared key */

View File

@ -41,7 +41,6 @@ void announce_set_synch_offset(Announcements *announce, int32_t synch_offset);
nullable(1)
void kill_announcements(Announcements *announce);
/* The declarations below are not public, they are exposed only for tests. */
/** @private

View File

@ -168,7 +168,7 @@ bool bin_unpack_u16_b(Bin_Unpack *bu, uint16_t *val)
uint8_t hi = 0;
uint8_t lo = 0;
if (!(bin_unpack_u08_b(bu, &hi)
&& bin_unpack_u08_b(bu, &lo))) {
&& bin_unpack_u08_b(bu, &lo))) {
return false;
}
*val = ((uint16_t)hi << 8) | lo;
@ -180,7 +180,7 @@ bool bin_unpack_u32_b(Bin_Unpack *bu, uint32_t *val)
uint16_t hi = 0;
uint16_t lo = 0;
if (!(bin_unpack_u16_b(bu, &hi)
&& bin_unpack_u16_b(bu, &lo))) {
&& bin_unpack_u16_b(bu, &lo))) {
return false;
}
*val = ((uint32_t)hi << 16) | lo;
@ -192,7 +192,7 @@ bool bin_unpack_u64_b(Bin_Unpack *bu, uint64_t *val)
uint32_t hi = 0;
uint32_t lo = 0;
if (!(bin_unpack_u32_b(bu, &hi)
&& bin_unpack_u32_b(bu, &lo))) {
&& bin_unpack_u32_b(bu, &lo))) {
return false;
}
*val = ((uint64_t)hi << 32) | lo;

View File

@ -14,14 +14,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Conference_Connected {
uint32_t conference_number;
};
@ -66,7 +64,6 @@ static bool tox_event_conference_connected_unpack_into(
return bin_unpack_u32(bu, &event->conference_number);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -150,16 +147,15 @@ static Tox_Event_Conference_Connected *tox_event_conference_connected_alloc(void
return conference_connected;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_conference_connected(Tox *tox, uint32_t conference_number,
void *user_data)
void tox_events_handle_conference_connected(
Tox *tox, uint32_t conference_number,
void *user_data)
{
Tox_Event_Conference_Connected *conference_connected = tox_event_conference_connected_alloc(user_data);

View File

@ -18,14 +18,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Conference_Invite {
uint32_t friend_number;
Tox_Conference_Type type;
@ -134,7 +132,6 @@ static bool tox_event_conference_invite_unpack_into(
&& bin_unpack_bin(bu, &event->cookie, &event->cookie_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -218,16 +215,15 @@ static Tox_Event_Conference_Invite *tox_event_conference_invite_alloc(void *user
return conference_invite;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_conference_invite(Tox *tox, uint32_t friend_number, Tox_Conference_Type type, const uint8_t *cookie, size_t length,
void *user_data)
void tox_events_handle_conference_invite(
Tox *tox, uint32_t friend_number, Tox_Conference_Type type, const uint8_t *cookie, size_t length,
void *user_data)
{
Tox_Event_Conference_Invite *conference_invite = tox_event_conference_invite_alloc(user_data);

View File

@ -18,14 +18,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Conference_Message {
uint32_t conference_number;
uint32_t peer_number;
@ -150,7 +148,6 @@ static bool tox_event_conference_message_unpack_into(
&& bin_unpack_bin(bu, &event->message, &event->message_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -234,16 +231,15 @@ static Tox_Event_Conference_Message *tox_event_conference_message_alloc(void *us
return conference_message;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_conference_message(Tox *tox, uint32_t conference_number, uint32_t peer_number, Tox_Message_Type type, const uint8_t *message, size_t length,
void *user_data)
void tox_events_handle_conference_message(
Tox *tox, uint32_t conference_number, uint32_t peer_number, Tox_Message_Type type, const uint8_t *message, size_t length,
void *user_data)
{
Tox_Event_Conference_Message *conference_message = tox_event_conference_message_alloc(user_data);

View File

@ -14,14 +14,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Conference_Peer_List_Changed {
uint32_t conference_number;
};
@ -66,7 +64,6 @@ static bool tox_event_conference_peer_list_changed_unpack_into(
return bin_unpack_u32(bu, &event->conference_number);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -150,16 +147,15 @@ static Tox_Event_Conference_Peer_List_Changed *tox_event_conference_peer_list_ch
return conference_peer_list_changed;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_conference_peer_list_changed(Tox *tox, uint32_t conference_number,
void *user_data)
void tox_events_handle_conference_peer_list_changed(
Tox *tox, uint32_t conference_number,
void *user_data)
{
Tox_Event_Conference_Peer_List_Changed *conference_peer_list_changed = tox_event_conference_peer_list_changed_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Conference_Peer_Name {
uint32_t conference_number;
uint32_t peer_number;
@ -132,7 +130,6 @@ static bool tox_event_conference_peer_name_unpack_into(
&& bin_unpack_bin(bu, &event->name, &event->name_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -216,16 +213,15 @@ static Tox_Event_Conference_Peer_Name *tox_event_conference_peer_name_alloc(void
return conference_peer_name;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_conference_peer_name(Tox *tox, uint32_t conference_number, uint32_t peer_number, const uint8_t *name, size_t length,
void *user_data)
void tox_events_handle_conference_peer_name(
Tox *tox, uint32_t conference_number, uint32_t peer_number, const uint8_t *name, size_t length,
void *user_data)
{
Tox_Event_Conference_Peer_Name *conference_peer_name = tox_event_conference_peer_name_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Conference_Title {
uint32_t conference_number;
uint32_t peer_number;
@ -132,7 +130,6 @@ static bool tox_event_conference_title_unpack_into(
&& bin_unpack_bin(bu, &event->title, &event->title_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -216,16 +213,15 @@ static Tox_Event_Conference_Title *tox_event_conference_title_alloc(void *user_d
return conference_title;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_conference_title(Tox *tox, uint32_t conference_number, uint32_t peer_number, const uint8_t *title, size_t length,
void *user_data)
void tox_events_handle_conference_title(
Tox *tox, uint32_t conference_number, uint32_t peer_number, const uint8_t *title, size_t length,
void *user_data)
{
Tox_Event_Conference_Title *conference_title = tox_event_conference_title_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox_events.h"
#include "../tox_private.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Dht_Get_Nodes_Response {
uint8_t public_key[TOX_PUBLIC_KEY_SIZE];
uint8_t *ip;
@ -87,7 +85,9 @@ non_null()
static void tox_event_dht_get_nodes_response_construct(Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response)
{
*dht_get_nodes_response = (Tox_Event_Dht_Get_Nodes_Response) {
{0}
{
0
}
};
}
non_null()
@ -194,17 +194,15 @@ static Tox_Event_Dht_Get_Nodes_Response *tox_event_dht_get_nodes_response_alloc(
return dht_get_nodes_response;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_dht_get_nodes_response(
Tox *tox, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE],
const char *ip, uint16_t port, void *user_data)
Tox *tox, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE],
const char *ip, uint16_t port, void *user_data)
{
Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response = tox_event_dht_get_nodes_response_alloc(user_data);

View File

@ -63,7 +63,7 @@ bool tox_events_add(Tox_Events *events, const Tox_Event *event)
if (events->events_size == events->events_capacity) {
const uint32_t new_events_capacity = events->events_capacity * 2 + 1;
Tox_Event *new_events = (Tox_Event *)mem_vrealloc(
events->mem, events->events, new_events_capacity, sizeof(Tox_Event));
events->mem, events->events, new_events_capacity, sizeof(Tox_Event));
if (new_events == nullptr) {
return false;

View File

@ -14,14 +14,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_File_Chunk_Request {
uint32_t friend_number;
uint32_t file_number;
@ -119,7 +117,6 @@ static bool tox_event_file_chunk_request_unpack_into(
&& bin_unpack_u16(bu, &event->length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -203,16 +200,15 @@ static Tox_Event_File_Chunk_Request *tox_event_file_chunk_request_alloc(void *us
return file_chunk_request;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position, size_t length,
void *user_data)
void tox_events_handle_file_chunk_request(
Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position, size_t length,
void *user_data)
{
Tox_Event_File_Chunk_Request *file_chunk_request = tox_event_file_chunk_request_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_File_Recv {
uint32_t friend_number;
uint32_t file_number;
@ -164,7 +162,6 @@ static bool tox_event_file_recv_unpack_into(
&& bin_unpack_bin(bu, &event->filename, &event->filename_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -248,16 +245,15 @@ static Tox_Event_File_Recv *tox_event_file_recv_alloc(void *user_data)
return file_recv;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_file_recv(Tox *tox, uint32_t friend_number, uint32_t file_number, uint32_t kind, uint64_t file_size, const uint8_t *filename, size_t filename_length,
void *user_data)
void tox_events_handle_file_recv(
Tox *tox, uint32_t friend_number, uint32_t file_number, uint32_t kind, uint64_t file_size, const uint8_t *filename, size_t filename_length,
void *user_data)
{
Tox_Event_File_Recv *file_recv = tox_event_file_recv_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_File_Recv_Chunk {
uint32_t friend_number;
uint32_t file_number;
@ -148,7 +146,6 @@ static bool tox_event_file_recv_chunk_unpack_into(
&& bin_unpack_bin(bu, &event->data, &event->data_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -232,16 +229,15 @@ static Tox_Event_File_Recv_Chunk *tox_event_file_recv_chunk_alloc(void *user_dat
return file_recv_chunk;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_file_recv_chunk(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position, const uint8_t *data, size_t length,
void *user_data)
void tox_events_handle_file_recv_chunk(
Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position, const uint8_t *data, size_t length,
void *user_data)
{
Tox_Event_File_Recv_Chunk *file_recv_chunk = tox_event_file_recv_chunk_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_File_Recv_Control {
uint32_t friend_number;
uint32_t file_number;
@ -105,7 +103,6 @@ static bool tox_event_file_recv_control_unpack_into(
&& tox_file_control_unpack(&event->control, bu);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -189,16 +186,15 @@ static Tox_Event_File_Recv_Control *tox_event_file_recv_control_alloc(void *user
return file_recv_control;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_file_recv_control(Tox *tox, uint32_t friend_number, uint32_t file_number, Tox_File_Control control,
void *user_data)
void tox_events_handle_file_recv_control(
Tox *tox, uint32_t friend_number, uint32_t file_number, Tox_File_Control control,
void *user_data)
{
Tox_Event_File_Recv_Control *file_recv_control = tox_event_file_recv_control_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Friend_Connection_Status {
uint32_t friend_number;
Tox_Connection connection_status;
@ -89,7 +87,6 @@ static bool tox_event_friend_connection_status_unpack_into(
&& tox_connection_unpack(&event->connection_status, bu);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -173,16 +170,15 @@ static Tox_Event_Friend_Connection_Status *tox_event_friend_connection_status_al
return friend_connection_status;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_friend_connection_status(Tox *tox, uint32_t friend_number, Tox_Connection connection_status,
void *user_data)
void tox_events_handle_friend_connection_status(
Tox *tox, uint32_t friend_number, Tox_Connection connection_status,
void *user_data)
{
Tox_Event_Friend_Connection_Status *friend_connection_status = tox_event_friend_connection_status_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Friend_Lossless_Packet {
uint32_t friend_number;
uint8_t *data;
@ -116,7 +114,6 @@ static bool tox_event_friend_lossless_packet_unpack_into(
&& bin_unpack_bin(bu, &event->data, &event->data_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -200,16 +197,15 @@ static Tox_Event_Friend_Lossless_Packet *tox_event_friend_lossless_packet_alloc(
return friend_lossless_packet;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_friend_lossless_packet(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length,
void *user_data)
void tox_events_handle_friend_lossless_packet(
Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length,
void *user_data)
{
Tox_Event_Friend_Lossless_Packet *friend_lossless_packet = tox_event_friend_lossless_packet_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Friend_Lossy_Packet {
uint32_t friend_number;
uint8_t *data;
@ -116,7 +114,6 @@ static bool tox_event_friend_lossy_packet_unpack_into(
&& bin_unpack_bin(bu, &event->data, &event->data_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -200,16 +197,15 @@ static Tox_Event_Friend_Lossy_Packet *tox_event_friend_lossy_packet_alloc(void *
return friend_lossy_packet;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_friend_lossy_packet(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length,
void *user_data)
void tox_events_handle_friend_lossy_packet(
Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length,
void *user_data)
{
Tox_Event_Friend_Lossy_Packet *friend_lossy_packet = tox_event_friend_lossy_packet_alloc(user_data);

View File

@ -18,14 +18,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Friend_Message {
uint32_t friend_number;
Tox_Message_Type type;
@ -134,7 +132,6 @@ static bool tox_event_friend_message_unpack_into(
&& bin_unpack_bin(bu, &event->message, &event->message_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -218,16 +215,15 @@ static Tox_Event_Friend_Message *tox_event_friend_message_alloc(void *user_data)
return friend_message;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_friend_message(Tox *tox, uint32_t friend_number, Tox_Message_Type type, const uint8_t *message, size_t length,
void *user_data)
void tox_events_handle_friend_message(
Tox *tox, uint32_t friend_number, Tox_Message_Type type, const uint8_t *message, size_t length,
void *user_data)
{
Tox_Event_Friend_Message *friend_message = tox_event_friend_message_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Friend_Name {
uint32_t friend_number;
uint8_t *name;
@ -116,7 +114,6 @@ static bool tox_event_friend_name_unpack_into(
&& bin_unpack_bin(bu, &event->name, &event->name_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -200,16 +197,15 @@ static Tox_Event_Friend_Name *tox_event_friend_name_alloc(void *user_data)
return friend_name;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_friend_name(Tox *tox, uint32_t friend_number, const uint8_t *name, size_t length,
void *user_data)
void tox_events_handle_friend_name(
Tox *tox, uint32_t friend_number, const uint8_t *name, size_t length,
void *user_data)
{
Tox_Event_Friend_Name *friend_name = tox_event_friend_name_alloc(user_data);

View File

@ -14,14 +14,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Friend_Read_Receipt {
uint32_t friend_number;
uint32_t message_id;
@ -87,7 +85,6 @@ static bool tox_event_friend_read_receipt_unpack_into(
&& bin_unpack_u32(bu, &event->message_id);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -171,16 +168,15 @@ static Tox_Event_Friend_Read_Receipt *tox_event_friend_read_receipt_alloc(void *
return friend_read_receipt;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_friend_read_receipt(Tox *tox, uint32_t friend_number, uint32_t message_id,
void *user_data)
void tox_events_handle_friend_read_receipt(
Tox *tox, uint32_t friend_number, uint32_t message_id,
void *user_data)
{
Tox_Event_Friend_Read_Receipt *friend_read_receipt = tox_event_friend_read_receipt_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox_events.h"
#include "../tox_private.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Friend_Request {
uint8_t public_key[TOX_PUBLIC_KEY_SIZE];
uint8_t *message;
@ -82,7 +80,9 @@ non_null()
static void tox_event_friend_request_construct(Tox_Event_Friend_Request *friend_request)
{
*friend_request = (Tox_Event_Friend_Request) {
{0}
{
0
}
};
}
non_null()
@ -190,14 +190,12 @@ static Tox_Event_Friend_Request *tox_event_friend_request_alloc(void *user_data)
return friend_request;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_friend_request(Tox *tox, const uint8_t *public_key, const uint8_t *message, size_t length,
void *user_data)
{

View File

@ -16,14 +16,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Friend_Status {
uint32_t friend_number;
Tox_User_Status status;
@ -89,7 +87,6 @@ static bool tox_event_friend_status_unpack_into(
&& tox_user_status_unpack(&event->status, bu);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -173,16 +170,15 @@ static Tox_Event_Friend_Status *tox_event_friend_status_alloc(void *user_data)
return friend_status;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_friend_status(Tox *tox, uint32_t friend_number, Tox_User_Status status,
void *user_data)
void tox_events_handle_friend_status(
Tox *tox, uint32_t friend_number, Tox_User_Status status,
void *user_data)
{
Tox_Event_Friend_Status *friend_status = tox_event_friend_status_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Friend_Status_Message {
uint32_t friend_number;
uint8_t *message;
@ -116,7 +114,6 @@ static bool tox_event_friend_status_message_unpack_into(
&& bin_unpack_bin(bu, &event->message, &event->message_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -200,16 +197,15 @@ static Tox_Event_Friend_Status_Message *tox_event_friend_status_message_alloc(vo
return friend_status_message;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_friend_status_message(Tox *tox, uint32_t friend_number, const uint8_t *message, size_t length,
void *user_data)
void tox_events_handle_friend_status_message(
Tox *tox, uint32_t friend_number, const uint8_t *message, size_t length,
void *user_data)
{
Tox_Event_Friend_Status_Message *friend_status_message = tox_event_friend_status_message_alloc(user_data);

View File

@ -14,14 +14,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Friend_Typing {
uint32_t friend_number;
bool typing;
@ -87,7 +85,6 @@ static bool tox_event_friend_typing_unpack_into(
&& bin_unpack_bool(bu, &event->typing);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -171,16 +168,15 @@ static Tox_Event_Friend_Typing *tox_event_friend_typing_alloc(void *user_data)
return friend_typing;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_friend_typing(Tox *tox, uint32_t friend_number, bool typing,
void *user_data)
void tox_events_handle_friend_typing(
Tox *tox, uint32_t friend_number, bool typing,
void *user_data)
{
Tox_Event_Friend_Typing *friend_typing = tox_event_friend_typing_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Custom_Packet {
uint32_t group_number;
uint32_t peer_id;
@ -132,7 +130,6 @@ static bool tox_event_group_custom_packet_unpack_into(
&& bin_unpack_bin(bu, &event->data, &event->data_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -216,16 +213,15 @@ static Tox_Event_Group_Custom_Packet *tox_event_group_custom_packet_alloc(void *
return group_custom_packet;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_custom_packet(Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t length,
void *user_data)
void tox_events_handle_group_custom_packet(
Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t length,
void *user_data)
{
Tox_Event_Group_Custom_Packet *group_custom_packet = tox_event_group_custom_packet_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Custom_Private_Packet {
uint32_t group_number;
uint32_t peer_id;
@ -132,7 +130,6 @@ static bool tox_event_group_custom_private_packet_unpack_into(
&& bin_unpack_bin(bu, &event->data, &event->data_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -216,16 +213,15 @@ static Tox_Event_Group_Custom_Private_Packet *tox_event_group_custom_private_pac
return group_custom_private_packet;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_custom_private_packet(Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t length,
void *user_data)
void tox_events_handle_group_custom_private_packet(
Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t length,
void *user_data)
{
Tox_Event_Group_Custom_Private_Packet *group_custom_private_packet = tox_event_group_custom_private_packet_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Invite {
uint32_t friend_number;
uint8_t *invite_data;
@ -160,7 +158,6 @@ static bool tox_event_group_invite_unpack_into(
&& bin_unpack_bin(bu, &event->group_name, &event->group_name_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -244,16 +241,15 @@ static Tox_Event_Group_Invite *tox_event_group_invite_alloc(void *user_data)
return group_invite;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_invite(Tox *tox, uint32_t friend_number, const uint8_t *invite_data, size_t length, const uint8_t *group_name, size_t group_name_length,
void *user_data)
void tox_events_handle_group_invite(
Tox *tox, uint32_t friend_number, const uint8_t *invite_data, size_t length, const uint8_t *group_name, size_t group_name_length,
void *user_data)
{
Tox_Event_Group_Invite *group_invite = tox_event_group_invite_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Join_Fail {
uint32_t group_number;
Tox_Group_Join_Fail fail_type;
@ -89,7 +87,6 @@ static bool tox_event_group_join_fail_unpack_into(
&& tox_group_join_fail_unpack(&event->fail_type, bu);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -173,16 +170,15 @@ static Tox_Event_Group_Join_Fail *tox_event_group_join_fail_alloc(void *user_dat
return group_join_fail;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_join_fail(Tox *tox, uint32_t group_number, Tox_Group_Join_Fail fail_type,
void *user_data)
void tox_events_handle_group_join_fail(
Tox *tox, uint32_t group_number, Tox_Group_Join_Fail fail_type,
void *user_data)
{
Tox_Event_Group_Join_Fail *group_join_fail = tox_event_group_join_fail_alloc(user_data);

View File

@ -18,14 +18,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Message {
uint32_t group_number;
uint32_t peer_id;
@ -166,7 +164,6 @@ static bool tox_event_group_message_unpack_into(
&& bin_unpack_u32(bu, &event->message_id);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -250,16 +247,15 @@ static Tox_Event_Group_Message *tox_event_group_message_alloc(void *user_data)
return group_message;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_message(Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id,
void *user_data)
void tox_events_handle_group_message(
Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id,
void *user_data)
{
Tox_Event_Group_Message *group_message = tox_event_group_message_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Moderation {
uint32_t group_number;
uint32_t source_peer_id;
@ -121,7 +119,6 @@ static bool tox_event_group_moderation_unpack_into(
&& tox_group_mod_event_unpack(&event->mod_type, bu);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -205,16 +202,15 @@ static Tox_Event_Group_Moderation *tox_event_group_moderation_alloc(void *user_d
return group_moderation;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_moderation(Tox *tox, uint32_t group_number, uint32_t source_peer_id, uint32_t target_peer_id, Tox_Group_Mod_Event mod_type,
void *user_data)
void tox_events_handle_group_moderation(
Tox *tox, uint32_t group_number, uint32_t source_peer_id, uint32_t target_peer_id, Tox_Group_Mod_Event mod_type,
void *user_data)
{
Tox_Event_Group_Moderation *group_moderation = tox_event_group_moderation_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Password {
uint32_t group_number;
uint8_t *password;
@ -116,7 +114,6 @@ static bool tox_event_group_password_unpack_into(
&& bin_unpack_bin(bu, &event->password, &event->password_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -200,16 +197,15 @@ static Tox_Event_Group_Password *tox_event_group_password_alloc(void *user_data)
return group_password;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_password(Tox *tox, uint32_t group_number, const uint8_t *password, size_t length,
void *user_data)
void tox_events_handle_group_password(
Tox *tox, uint32_t group_number, const uint8_t *password, size_t length,
void *user_data)
{
Tox_Event_Group_Password *group_password = tox_event_group_password_alloc(user_data);

View File

@ -18,14 +18,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Peer_Exit {
uint32_t group_number;
uint32_t peer_id;
@ -194,7 +192,6 @@ static bool tox_event_group_peer_exit_unpack_into(
&& bin_unpack_bin(bu, &event->part_message, &event->part_message_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -278,16 +275,15 @@ static Tox_Event_Group_Peer_Exit *tox_event_group_peer_exit_alloc(void *user_dat
return group_peer_exit;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_peer_exit(Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Group_Exit_Type exit_type, const uint8_t *name, size_t name_length, const uint8_t *part_message, size_t part_message_length,
void *user_data)
void tox_events_handle_group_peer_exit(
Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Group_Exit_Type exit_type, const uint8_t *name, size_t name_length, const uint8_t *part_message, size_t part_message_length,
void *user_data)
{
Tox_Event_Group_Peer_Exit *group_peer_exit = tox_event_group_peer_exit_alloc(user_data);

View File

@ -14,14 +14,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Peer_Join {
uint32_t group_number;
uint32_t peer_id;
@ -87,7 +85,6 @@ static bool tox_event_group_peer_join_unpack_into(
&& bin_unpack_u32(bu, &event->peer_id);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -171,16 +168,15 @@ static Tox_Event_Group_Peer_Join *tox_event_group_peer_join_alloc(void *user_dat
return group_peer_join;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_peer_join(Tox *tox, uint32_t group_number, uint32_t peer_id,
void *user_data)
void tox_events_handle_group_peer_join(
Tox *tox, uint32_t group_number, uint32_t peer_id,
void *user_data)
{
Tox_Event_Group_Peer_Join *group_peer_join = tox_event_group_peer_join_alloc(user_data);

View File

@ -14,14 +14,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Peer_Limit {
uint32_t group_number;
uint32_t peer_limit;
@ -87,7 +85,6 @@ static bool tox_event_group_peer_limit_unpack_into(
&& bin_unpack_u32(bu, &event->peer_limit);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -171,16 +168,15 @@ static Tox_Event_Group_Peer_Limit *tox_event_group_peer_limit_alloc(void *user_d
return group_peer_limit;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_peer_limit(Tox *tox, uint32_t group_number, uint32_t peer_limit,
void *user_data)
void tox_events_handle_group_peer_limit(
Tox *tox, uint32_t group_number, uint32_t peer_limit,
void *user_data)
{
Tox_Event_Group_Peer_Limit *group_peer_limit = tox_event_group_peer_limit_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Peer_Name {
uint32_t group_number;
uint32_t peer_id;
@ -132,7 +130,6 @@ static bool tox_event_group_peer_name_unpack_into(
&& bin_unpack_bin(bu, &event->name, &event->name_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -216,16 +213,15 @@ static Tox_Event_Group_Peer_Name *tox_event_group_peer_name_alloc(void *user_dat
return group_peer_name;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_peer_name(Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *name, size_t length,
void *user_data)
void tox_events_handle_group_peer_name(
Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *name, size_t length,
void *user_data)
{
Tox_Event_Group_Peer_Name *group_peer_name = tox_event_group_peer_name_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Peer_Status {
uint32_t group_number;
uint32_t peer_id;
@ -105,7 +103,6 @@ static bool tox_event_group_peer_status_unpack_into(
&& tox_user_status_unpack(&event->status, bu);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -189,16 +186,15 @@ static Tox_Event_Group_Peer_Status *tox_event_group_peer_status_alloc(void *user
return group_peer_status;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_peer_status(Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_User_Status status,
void *user_data)
void tox_events_handle_group_peer_status(
Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_User_Status status,
void *user_data)
{
Tox_Event_Group_Peer_Status *group_peer_status = tox_event_group_peer_status_alloc(user_data);

View File

@ -16,14 +16,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Privacy_State {
uint32_t group_number;
Tox_Group_Privacy_State privacy_state;
@ -89,7 +87,6 @@ static bool tox_event_group_privacy_state_unpack_into(
&& tox_group_privacy_state_unpack(&event->privacy_state, bu);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -173,16 +170,15 @@ static Tox_Event_Group_Privacy_State *tox_event_group_privacy_state_alloc(void *
return group_privacy_state;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_privacy_state(Tox *tox, uint32_t group_number, Tox_Group_Privacy_State privacy_state,
void *user_data)
void tox_events_handle_group_privacy_state(
Tox *tox, uint32_t group_number, Tox_Group_Privacy_State privacy_state,
void *user_data)
{
Tox_Event_Group_Privacy_State *group_privacy_state = tox_event_group_privacy_state_alloc(user_data);

Some files were not shown because too many files have changed in this diff Show More