Merge commit '61accfe1846e1f857fcdf84d27fb3d6e78fb46a3'

This commit is contained in:
2024-01-15 23:32:23 +01:00
63 changed files with 632 additions and 344 deletions

View File

@ -730,17 +730,6 @@ cc_library(
],
)
cc_test(
name = "friend_connection_test",
size = "small",
srcs = ["friend_connection_test.cc"],
deps = [
":friend_connection",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "friend_requests",
srcs = ["friend_requests.c"],
@ -903,6 +892,19 @@ cc_test(
],
)
cc_library(
name = "tox_pack",
srcs = ["tox_pack.c"],
hdrs = ["tox_pack.h"],
visibility = ["//c-toxcore:__subpackages__"],
deps = [
":attributes",
":bin_pack",
":ccompat",
":tox",
],
)
cc_library(
name = "tox_unpack",
srcs = ["tox_unpack.c"],
@ -937,6 +939,7 @@ cc_library(
":ccompat",
":mem",
":tox",
":tox_pack",
":tox_unpack",
"//c-toxcore/third_party:cmp",
],

View File

@ -94,6 +94,8 @@ libtoxcore_la_SOURCES = ../third_party/cmp/cmp.c \
../toxcore/tox_event.c \
../toxcore/tox_events.h \
../toxcore/tox_events.c \
../toxcore/tox_pack.h \
../toxcore/tox_pack.c \
../toxcore/tox_unpack.h \
../toxcore/tox_unpack.c \
../toxcore/tox_private.c \

View File

@ -54,10 +54,7 @@ static void tox_event_conference_connected_destruct(Tox_Event_Conference_Connect
bool tox_event_conference_connected_pack(
const Tox_Event_Conference_Connected *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_CONNECTED)
&& bin_pack_u32(bp, event->conference_number);
return bin_pack_u32(bp, event->conference_number);
}
non_null()

View File

@ -14,6 +14,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -107,12 +108,9 @@ static void tox_event_conference_invite_destruct(Tox_Event_Conference_Invite *co
bool tox_event_conference_invite_pack(
const Tox_Event_Conference_Invite *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_INVITE)
&& bin_pack_array(bp, 3)
return bin_pack_array(bp, 3)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_u32(bp, event->type)
&& tox_conference_type_pack(event->type, bp)
&& bin_pack_bin(bp, event->cookie, event->cookie_length);
}
@ -126,7 +124,7 @@ static bool tox_event_conference_invite_unpack_into(
}
return bin_unpack_u32(bu, &event->friend_number)
&& tox_conference_type_unpack(bu, &event->type)
&& tox_conference_type_unpack(&event->type, bu)
&& bin_unpack_bin(bu, &event->cookie, &event->cookie_length);
}

View File

@ -14,6 +14,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -121,13 +122,10 @@ static void tox_event_conference_message_destruct(Tox_Event_Conference_Message *
bool tox_event_conference_message_pack(
const Tox_Event_Conference_Message *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_MESSAGE)
&& bin_pack_array(bp, 4)
return bin_pack_array(bp, 4)
&& bin_pack_u32(bp, event->conference_number)
&& bin_pack_u32(bp, event->peer_number)
&& bin_pack_u32(bp, event->type)
&& tox_message_type_pack(event->type, bp)
&& bin_pack_bin(bp, event->message, event->message_length);
}
@ -142,7 +140,7 @@ static bool tox_event_conference_message_unpack_into(
return bin_unpack_u32(bu, &event->conference_number)
&& bin_unpack_u32(bu, &event->peer_number)
&& tox_message_type_unpack(bu, &event->type)
&& tox_message_type_unpack(&event->type, bu)
&& bin_unpack_bin(bu, &event->message, &event->message_length);
}

View File

@ -54,10 +54,7 @@ static void tox_event_conference_peer_list_changed_destruct(Tox_Event_Conference
bool tox_event_conference_peer_list_changed_pack(
const Tox_Event_Conference_Peer_List_Changed *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED)
&& bin_pack_u32(bp, event->conference_number);
return bin_pack_u32(bp, event->conference_number);
}
non_null()

View File

@ -106,10 +106,7 @@ static void tox_event_conference_peer_name_destruct(Tox_Event_Conference_Peer_Na
bool tox_event_conference_peer_name_pack(
const Tox_Event_Conference_Peer_Name *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_PEER_NAME)
&& bin_pack_array(bp, 3)
return bin_pack_array(bp, 3)
&& bin_pack_u32(bp, event->conference_number)
&& bin_pack_u32(bp, event->peer_number)
&& bin_pack_bin(bp, event->name, event->name_length);

View File

@ -106,10 +106,7 @@ static void tox_event_conference_title_destruct(Tox_Event_Conference_Title *conf
bool tox_event_conference_title_pack(
const Tox_Event_Conference_Title *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_CONFERENCE_TITLE)
&& bin_pack_array(bp, 3)
return bin_pack_array(bp, 3)
&& bin_pack_u32(bp, event->conference_number)
&& bin_pack_u32(bp, event->peer_number)
&& bin_pack_bin(bp, event->title, event->title_length);

View File

@ -96,10 +96,7 @@ static void tox_event_file_chunk_request_destruct(Tox_Event_File_Chunk_Request *
bool tox_event_file_chunk_request_pack(
const Tox_Event_File_Chunk_Request *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FILE_CHUNK_REQUEST)
&& bin_pack_array(bp, 4)
return bin_pack_array(bp, 4)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_u32(bp, event->file_number)
&& bin_pack_u64(bp, event->position)

View File

@ -134,10 +134,7 @@ static void tox_event_file_recv_destruct(Tox_Event_File_Recv *file_recv, const M
bool tox_event_file_recv_pack(
const Tox_Event_File_Recv *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FILE_RECV)
&& bin_pack_array(bp, 5)
return bin_pack_array(bp, 5)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_u32(bp, event->file_number)
&& bin_pack_u32(bp, event->kind)

View File

@ -120,10 +120,7 @@ static void tox_event_file_recv_chunk_destruct(Tox_Event_File_Recv_Chunk *file_r
bool tox_event_file_recv_chunk_pack(
const Tox_Event_File_Recv_Chunk *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FILE_RECV_CHUNK)
&& bin_pack_array(bp, 4)
return bin_pack_array(bp, 4)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_u32(bp, event->file_number)
&& bin_pack_u64(bp, event->position)

View File

@ -12,6 +12,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -83,13 +84,10 @@ static void tox_event_file_recv_control_destruct(Tox_Event_File_Recv_Control *fi
bool tox_event_file_recv_control_pack(
const Tox_Event_File_Recv_Control *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FILE_RECV_CONTROL)
&& bin_pack_array(bp, 3)
return bin_pack_array(bp, 3)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_u32(bp, event->file_number)
&& bin_pack_u32(bp, event->control);
&& tox_file_control_pack(event->control, bp);
}
non_null()
@ -103,7 +101,7 @@ static bool tox_event_file_recv_control_unpack_into(
return bin_unpack_u32(bu, &event->friend_number)
&& bin_unpack_u32(bu, &event->file_number)
&& tox_file_control_unpack(bu, &event->control);
&& tox_file_control_unpack(&event->control, bu);
}

View File

@ -12,6 +12,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -69,12 +70,9 @@ static void tox_event_friend_connection_status_destruct(Tox_Event_Friend_Connect
bool tox_event_friend_connection_status_pack(
const Tox_Event_Friend_Connection_Status *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_CONNECTION_STATUS)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_u32(bp, event->connection_status);
&& tox_connection_pack(event->connection_status, bp);
}
non_null()
@ -87,7 +85,7 @@ static bool tox_event_friend_connection_status_unpack_into(
}
return bin_unpack_u32(bu, &event->friend_number)
&& tox_connection_unpack(bu, &event->connection_status);
&& tox_connection_unpack(&event->connection_status, bu);
}

View File

@ -92,10 +92,7 @@ static void tox_event_friend_lossless_packet_destruct(Tox_Event_Friend_Lossless_
bool tox_event_friend_lossless_packet_pack(
const Tox_Event_Friend_Lossless_Packet *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_LOSSLESS_PACKET)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_bin(bp, event->data, event->data_length);
}

View File

@ -92,10 +92,7 @@ static void tox_event_friend_lossy_packet_destruct(Tox_Event_Friend_Lossy_Packet
bool tox_event_friend_lossy_packet_pack(
const Tox_Event_Friend_Lossy_Packet *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_LOSSY_PACKET)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_bin(bp, event->data, event->data_length);
}

View File

@ -14,6 +14,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -107,12 +108,9 @@ static void tox_event_friend_message_destruct(Tox_Event_Friend_Message *friend_m
bool tox_event_friend_message_pack(
const Tox_Event_Friend_Message *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_MESSAGE)
&& bin_pack_array(bp, 3)
return bin_pack_array(bp, 3)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_u32(bp, event->type)
&& tox_message_type_pack(event->type, bp)
&& bin_pack_bin(bp, event->message, event->message_length);
}
@ -126,7 +124,7 @@ static bool tox_event_friend_message_unpack_into(
}
return bin_unpack_u32(bu, &event->friend_number)
&& tox_message_type_unpack(bu, &event->type)
&& tox_message_type_unpack(&event->type, bu)
&& bin_unpack_bin(bu, &event->message, &event->message_length);
}

View File

@ -92,10 +92,7 @@ static void tox_event_friend_name_destruct(Tox_Event_Friend_Name *friend_name, c
bool tox_event_friend_name_pack(
const Tox_Event_Friend_Name *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_NAME)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_bin(bp, event->name, event->name_length);
}

View File

@ -68,10 +68,7 @@ static void tox_event_friend_read_receipt_destruct(Tox_Event_Friend_Read_Receipt
bool tox_event_friend_read_receipt_pack(
const Tox_Event_Friend_Read_Receipt *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_READ_RECEIPT)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_u32(bp, event->message_id);
}

View File

@ -93,10 +93,7 @@ static void tox_event_friend_request_destruct(Tox_Event_Friend_Request *friend_r
bool tox_event_friend_request_pack(
const Tox_Event_Friend_Request *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_REQUEST)
&& bin_pack_array(bp, 2)
&& bin_pack_bin(bp, event->public_key, TOX_PUBLIC_KEY_SIZE)
&& bin_pack_bin(bp, event->message, event->message_length);
}

View File

@ -12,6 +12,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -69,12 +70,9 @@ static void tox_event_friend_status_destruct(Tox_Event_Friend_Status *friend_sta
bool tox_event_friend_status_pack(
const Tox_Event_Friend_Status *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_STATUS)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_u32(bp, event->status);
&& tox_user_status_pack(event->status, bp);
}
non_null()
@ -87,7 +85,7 @@ static bool tox_event_friend_status_unpack_into(
}
return bin_unpack_u32(bu, &event->friend_number)
&& tox_user_status_unpack(bu, &event->status);
&& tox_user_status_unpack(&event->status, bu);
}

View File

@ -92,10 +92,7 @@ static void tox_event_friend_status_message_destruct(Tox_Event_Friend_Status_Mes
bool tox_event_friend_status_message_pack(
const Tox_Event_Friend_Status_Message *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_STATUS_MESSAGE)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_bin(bp, event->message, event->message_length);
}

View File

@ -68,10 +68,7 @@ static void tox_event_friend_typing_destruct(Tox_Event_Friend_Typing *friend_typ
bool tox_event_friend_typing_pack(
const Tox_Event_Friend_Typing *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_FRIEND_TYPING)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_bool(bp, event->typing);
}

View File

@ -106,10 +106,7 @@ static void tox_event_group_custom_packet_destruct(Tox_Event_Group_Custom_Packet
bool tox_event_group_custom_packet_pack(
const Tox_Event_Group_Custom_Packet *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_CUSTOM_PACKET)
&& bin_pack_array(bp, 3)
return bin_pack_array(bp, 3)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id)
&& bin_pack_bin(bp, event->data, event->data_length);

View File

@ -106,10 +106,7 @@ static void tox_event_group_custom_private_packet_destruct(Tox_Event_Group_Custo
bool tox_event_group_custom_private_packet_pack(
const Tox_Event_Group_Custom_Private_Packet *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET)
&& bin_pack_array(bp, 3)
return bin_pack_array(bp, 3)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id)
&& bin_pack_bin(bp, event->data, event->data_length);

View File

@ -129,10 +129,7 @@ static void tox_event_group_invite_destruct(Tox_Event_Group_Invite *group_invite
bool tox_event_group_invite_pack(
const Tox_Event_Group_Invite *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_INVITE)
&& bin_pack_array(bp, 3)
return bin_pack_array(bp, 3)
&& bin_pack_u32(bp, event->friend_number)
&& bin_pack_bin(bp, event->invite_data, event->invite_data_length)
&& bin_pack_bin(bp, event->group_name, event->group_name_length);

View File

@ -12,6 +12,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -69,12 +70,9 @@ static void tox_event_group_join_fail_destruct(Tox_Event_Group_Join_Fail *group_
bool tox_event_group_join_fail_pack(
const Tox_Event_Group_Join_Fail *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_JOIN_FAIL)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->fail_type);
&& tox_group_join_fail_pack(event->fail_type, bp);
}
non_null()
@ -87,7 +85,7 @@ static bool tox_event_group_join_fail_unpack_into(
}
return bin_unpack_u32(bu, &event->group_number)
&& tox_group_join_fail_unpack(bu, &event->fail_type);
&& tox_group_join_fail_unpack(&event->fail_type, bu);
}

View File

@ -14,6 +14,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -135,13 +136,10 @@ static void tox_event_group_message_destruct(Tox_Event_Group_Message *group_mess
bool tox_event_group_message_pack(
const Tox_Event_Group_Message *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_MESSAGE)
&& bin_pack_array(bp, 5)
return bin_pack_array(bp, 5)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id)
&& bin_pack_u32(bp, event->type)
&& tox_message_type_pack(event->type, bp)
&& bin_pack_bin(bp, event->message, event->message_length)
&& bin_pack_u32(bp, event->message_id);
}
@ -157,7 +155,7 @@ static bool tox_event_group_message_unpack_into(
return bin_unpack_u32(bu, &event->group_number)
&& bin_unpack_u32(bu, &event->peer_id)
&& tox_message_type_unpack(bu, &event->type)
&& tox_message_type_unpack(&event->type, bu)
&& bin_unpack_bin(bu, &event->message, &event->message_length)
&& bin_unpack_u32(bu, &event->message_id);
}

View File

@ -12,6 +12,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -97,14 +98,11 @@ static void tox_event_group_moderation_destruct(Tox_Event_Group_Moderation *grou
bool tox_event_group_moderation_pack(
const Tox_Event_Group_Moderation *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_MODERATION)
&& bin_pack_array(bp, 4)
return bin_pack_array(bp, 4)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->source_peer_id)
&& bin_pack_u32(bp, event->target_peer_id)
&& bin_pack_u32(bp, event->mod_type);
&& tox_group_mod_event_pack(event->mod_type, bp);
}
non_null()
@ -119,7 +117,7 @@ static bool tox_event_group_moderation_unpack_into(
return bin_unpack_u32(bu, &event->group_number)
&& bin_unpack_u32(bu, &event->source_peer_id)
&& bin_unpack_u32(bu, &event->target_peer_id)
&& tox_group_mod_event_unpack(bu, &event->mod_type);
&& tox_group_mod_event_unpack(&event->mod_type, bu);
}

View File

@ -92,10 +92,7 @@ static void tox_event_group_password_destruct(Tox_Event_Group_Password *group_pa
bool tox_event_group_password_pack(
const Tox_Event_Group_Password *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PASSWORD)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_bin(bp, event->password, event->password_length);
}

View File

@ -14,6 +14,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -158,13 +159,10 @@ static void tox_event_group_peer_exit_destruct(Tox_Event_Group_Peer_Exit *group_
bool tox_event_group_peer_exit_pack(
const Tox_Event_Group_Peer_Exit *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PEER_EXIT)
&& bin_pack_array(bp, 5)
return bin_pack_array(bp, 5)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id)
&& bin_pack_u32(bp, event->exit_type)
&& tox_group_exit_type_pack(event->exit_type, bp)
&& bin_pack_bin(bp, event->name, event->name_length)
&& bin_pack_bin(bp, event->part_message, event->part_message_length);
}
@ -180,7 +178,7 @@ static bool tox_event_group_peer_exit_unpack_into(
return bin_unpack_u32(bu, &event->group_number)
&& bin_unpack_u32(bu, &event->peer_id)
&& tox_group_exit_type_unpack(bu, &event->exit_type)
&& tox_group_exit_type_unpack(&event->exit_type, bu)
&& bin_unpack_bin(bu, &event->name, &event->name_length)
&& bin_unpack_bin(bu, &event->part_message, &event->part_message_length);
}

View File

@ -68,10 +68,7 @@ static void tox_event_group_peer_join_destruct(Tox_Event_Group_Peer_Join *group_
bool tox_event_group_peer_join_pack(
const Tox_Event_Group_Peer_Join *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PEER_JOIN)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id);
}

View File

@ -68,10 +68,7 @@ static void tox_event_group_peer_limit_destruct(Tox_Event_Group_Peer_Limit *grou
bool tox_event_group_peer_limit_pack(
const Tox_Event_Group_Peer_Limit *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PEER_LIMIT)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_limit);
}

View File

@ -106,10 +106,7 @@ static void tox_event_group_peer_name_destruct(Tox_Event_Group_Peer_Name *group_
bool tox_event_group_peer_name_pack(
const Tox_Event_Group_Peer_Name *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PEER_NAME)
&& bin_pack_array(bp, 3)
return bin_pack_array(bp, 3)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id)
&& bin_pack_bin(bp, event->name, event->name_length);

View File

@ -12,6 +12,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -83,13 +84,10 @@ static void tox_event_group_peer_status_destruct(Tox_Event_Group_Peer_Status *gr
bool tox_event_group_peer_status_pack(
const Tox_Event_Group_Peer_Status *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PEER_STATUS)
&& bin_pack_array(bp, 3)
return bin_pack_array(bp, 3)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id)
&& bin_pack_u32(bp, event->status);
&& tox_user_status_pack(event->status, bp);
}
non_null()
@ -103,7 +101,7 @@ static bool tox_event_group_peer_status_unpack_into(
return bin_unpack_u32(bu, &event->group_number)
&& bin_unpack_u32(bu, &event->peer_id)
&& tox_user_status_unpack(bu, &event->status);
&& tox_user_status_unpack(&event->status, bu);
}

View File

@ -12,6 +12,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -69,12 +70,9 @@ static void tox_event_group_privacy_state_destruct(Tox_Event_Group_Privacy_State
bool tox_event_group_privacy_state_pack(
const Tox_Event_Group_Privacy_State *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PRIVACY_STATE)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->privacy_state);
&& tox_group_privacy_state_pack(event->privacy_state, bp);
}
non_null()
@ -87,7 +85,7 @@ static bool tox_event_group_privacy_state_unpack_into(
}
return bin_unpack_u32(bu, &event->group_number)
&& tox_group_privacy_state_unpack(bu, &event->privacy_state);
&& tox_group_privacy_state_unpack(&event->privacy_state, bu);
}

View File

@ -14,6 +14,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -121,13 +122,10 @@ static void tox_event_group_private_message_destruct(Tox_Event_Group_Private_Mes
bool tox_event_group_private_message_pack(
const Tox_Event_Group_Private_Message *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_PRIVATE_MESSAGE)
&& bin_pack_array(bp, 4)
return bin_pack_array(bp, 4)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id)
&& bin_pack_u32(bp, event->type)
&& tox_message_type_pack(event->type, bp)
&& bin_pack_bin(bp, event->message, event->message_length);
}
@ -142,7 +140,7 @@ static bool tox_event_group_private_message_unpack_into(
return bin_unpack_u32(bu, &event->group_number)
&& bin_unpack_u32(bu, &event->peer_id)
&& tox_message_type_unpack(bu, &event->type)
&& tox_message_type_unpack(&event->type, bu)
&& bin_unpack_bin(bu, &event->message, &event->message_length);
}

View File

@ -54,10 +54,7 @@ static void tox_event_group_self_join_destruct(Tox_Event_Group_Self_Join *group_
bool tox_event_group_self_join_pack(
const Tox_Event_Group_Self_Join *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_SELF_JOIN)
&& bin_pack_u32(bp, event->group_number);
return bin_pack_u32(bp, event->group_number);
}
non_null()

View File

@ -106,10 +106,7 @@ static void tox_event_group_topic_destruct(Tox_Event_Group_Topic *group_topic, c
bool tox_event_group_topic_pack(
const Tox_Event_Group_Topic *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_TOPIC)
&& bin_pack_array(bp, 3)
return bin_pack_array(bp, 3)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id)
&& bin_pack_bin(bp, event->topic, event->topic_length);

View File

@ -12,6 +12,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -69,12 +70,9 @@ static void tox_event_group_topic_lock_destruct(Tox_Event_Group_Topic_Lock *grou
bool tox_event_group_topic_lock_pack(
const Tox_Event_Group_Topic_Lock *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_TOPIC_LOCK)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->topic_lock);
&& tox_group_topic_lock_pack(event->topic_lock, bp);
}
non_null()
@ -87,7 +85,7 @@ static bool tox_event_group_topic_lock_unpack_into(
}
return bin_unpack_u32(bu, &event->group_number)
&& tox_group_topic_lock_unpack(bu, &event->topic_lock);
&& tox_group_topic_lock_unpack(&event->topic_lock, bu);
}

View File

@ -12,6 +12,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -69,12 +70,9 @@ static void tox_event_group_voice_state_destruct(Tox_Event_Group_Voice_State *gr
bool tox_event_group_voice_state_pack(
const Tox_Event_Group_Voice_State *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_GROUP_VOICE_STATE)
&& bin_pack_array(bp, 2)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->voice_state);
&& tox_group_voice_state_pack(event->voice_state, bp);
}
non_null()
@ -87,7 +85,7 @@ static bool tox_event_group_voice_state_unpack_into(
}
return bin_unpack_u32(bu, &event->group_number)
&& tox_group_voice_state_unpack(bu, &event->voice_state);
&& tox_group_voice_state_unpack(&event->voice_state, bu);
}

View File

@ -12,6 +12,7 @@
#include "../mem.h"
#include "../tox.h"
#include "../tox_events.h"
#include "../tox_pack.h"
#include "../tox_unpack.h"
@ -55,10 +56,7 @@ static void tox_event_self_connection_status_destruct(Tox_Event_Self_Connection_
bool tox_event_self_connection_status_pack(
const Tox_Event_Self_Connection_Status *event, Bin_Pack *bp)
{
assert(event != nullptr);
return bin_pack_array(bp, 2)
&& bin_pack_u32(bp, TOX_EVENT_SELF_CONNECTION_STATUS)
&& bin_pack_u32(bp, event->connection_status);
return tox_connection_pack(event->connection_status, bp);
}
non_null()
@ -66,7 +64,7 @@ static bool tox_event_self_connection_status_unpack_into(
Tox_Event_Self_Connection_Status *event, Bin_Unpack *bu)
{
assert(event != nullptr);
return tox_connection_unpack(bu, &event->connection_status);
return tox_connection_unpack(&event->connection_status, bu);
}

View File

@ -1,14 +0,0 @@
#include "friend_connection.h"
#include <gtest/gtest.h>
namespace {
// TODO(Jfreegman) make this useful or remove it after NGC is merged
TEST(friend_connection, NullTest)
{
(void)friend_conn_get_onion_friendnum;
(void)friend_conn_get_dht_ip_port;
}
} // namespace

View File

@ -946,8 +946,9 @@ int send_packet(const Networking_Core *net, const IP_Port *ip_port, Packet packe
if (net_family_is_ipv4(net->family) && !net_family_is_ipv4(ipp_copy.ip.family)) {
// TODO(iphydf): Make this an error. Occasionally we try to send to an
// all-zero ip_port.
LOGGER_WARNING(net->log, "attempted to send message with network family %d (probably IPv6) on IPv4 socket",
ipp_copy.ip.family.value);
Ip_Ntoa ip_str;
LOGGER_WARNING(net->log, "attempted to send message with network family %d (probably IPv6) on IPv4 socket (%s)",
ipp_copy.ip.family.value, net_ip_ntoa(&ipp_copy.ip, &ip_str));
return -1;
}

View File

@ -48,7 +48,7 @@ static void change_symmetric_key(Onion *onion)
/** packing and unpacking functions */
non_null()
static void ip_pack(uint8_t *data, const IP *source)
static void ip_pack_to_bytes(uint8_t *data, const IP *source)
{
data[0] = source->family.value;
@ -62,7 +62,7 @@ static void ip_pack(uint8_t *data, const IP *source)
/** return 0 on success, -1 on failure. */
non_null()
static int ip_unpack(IP *target, const uint8_t *data, unsigned int data_size, bool disable_family_check)
static int ip_unpack_from_bytes(IP *target, const uint8_t *data, unsigned int data_size, bool disable_family_check)
{
if (data_size < (1 + SIZE_IP6)) {
return -1;
@ -87,7 +87,7 @@ static int ip_unpack(IP *target, const uint8_t *data, unsigned int data_size, bo
non_null()
static void ipport_pack(uint8_t *data, const IP_Port *source)
{
ip_pack(data, &source->ip);
ip_pack_to_bytes(data, &source->ip);
memcpy(data + SIZE_IP, &source->port, SIZE_PORT);
}
@ -99,7 +99,7 @@ static int ipport_unpack(IP_Port *target, const uint8_t *data, unsigned int data
return -1;
}
if (ip_unpack(&target->ip, data, data_size, disable_family_check) == -1) {
if (ip_unpack_from_bytes(&target->ip, data, data_size, disable_family_check) == -1) {
return -1;
}

View File

@ -1058,6 +1058,11 @@ bool tox_bootstrap(Tox *tox, const char *host, uint16_t port, const uint8_t publ
bool udp_success = tox->m->options.udp_disabled;
for (int32_t i = 0; i < count; ++i) {
if (!tox->m->options.ipv6enabled && net_family_is_ipv6(root[i].ip.family)) {
// We can't use ipv6 when it's disabled.
continue;
}
root[i].port = net_htons(port);
if (onion_add_bs_path_node(tox->m->onion_c, &root[i], public_key)) {

View File

@ -564,127 +564,132 @@ void tox_event_destruct(Tox_Event *event, const Memory *mem)
event->data.value = nullptr;
}
bool tox_event_pack(const Tox_Event *event, Bin_Pack *bp)
non_null()
static bool tox_event_type_pack(Tox_Event_Type type, Bin_Pack *bp)
{
assert(event->type != TOX_EVENT_INVALID);
return bin_pack_u32(bp, (uint32_t)type);
}
switch (event->type) {
non_null()
static bool tox_event_data_pack(Tox_Event_Type type, const Tox_Event_Data *data, Bin_Pack *bp)
{
switch (type) {
case TOX_EVENT_CONFERENCE_CONNECTED:
return tox_event_conference_connected_pack(event->data.conference_connected, bp);
return tox_event_conference_connected_pack(data->conference_connected, bp);
case TOX_EVENT_CONFERENCE_INVITE:
return tox_event_conference_invite_pack(event->data.conference_invite, bp);
return tox_event_conference_invite_pack(data->conference_invite, bp);
case TOX_EVENT_CONFERENCE_MESSAGE:
return tox_event_conference_message_pack(event->data.conference_message, bp);
return tox_event_conference_message_pack(data->conference_message, bp);
case TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED:
return tox_event_conference_peer_list_changed_pack(event->data.conference_peer_list_changed, bp);
return tox_event_conference_peer_list_changed_pack(data->conference_peer_list_changed, bp);
case TOX_EVENT_CONFERENCE_PEER_NAME:
return tox_event_conference_peer_name_pack(event->data.conference_peer_name, bp);
return tox_event_conference_peer_name_pack(data->conference_peer_name, bp);
case TOX_EVENT_CONFERENCE_TITLE:
return tox_event_conference_title_pack(event->data.conference_title, bp);
return tox_event_conference_title_pack(data->conference_title, bp);
case TOX_EVENT_FILE_CHUNK_REQUEST:
return tox_event_file_chunk_request_pack(event->data.file_chunk_request, bp);
return tox_event_file_chunk_request_pack(data->file_chunk_request, bp);
case TOX_EVENT_FILE_RECV_CHUNK:
return tox_event_file_recv_chunk_pack(event->data.file_recv_chunk, bp);
return tox_event_file_recv_chunk_pack(data->file_recv_chunk, bp);
case TOX_EVENT_FILE_RECV_CONTROL:
return tox_event_file_recv_control_pack(event->data.file_recv_control, bp);
return tox_event_file_recv_control_pack(data->file_recv_control, bp);
case TOX_EVENT_FILE_RECV:
return tox_event_file_recv_pack(event->data.file_recv, bp);
return tox_event_file_recv_pack(data->file_recv, bp);
case TOX_EVENT_FRIEND_CONNECTION_STATUS:
return tox_event_friend_connection_status_pack(event->data.friend_connection_status, bp);
return tox_event_friend_connection_status_pack(data->friend_connection_status, bp);
case TOX_EVENT_FRIEND_LOSSLESS_PACKET:
return tox_event_friend_lossless_packet_pack(event->data.friend_lossless_packet, bp);
return tox_event_friend_lossless_packet_pack(data->friend_lossless_packet, bp);
case TOX_EVENT_FRIEND_LOSSY_PACKET:
return tox_event_friend_lossy_packet_pack(event->data.friend_lossy_packet, bp);
return tox_event_friend_lossy_packet_pack(data->friend_lossy_packet, bp);
case TOX_EVENT_FRIEND_MESSAGE:
return tox_event_friend_message_pack(event->data.friend_message, bp);
return tox_event_friend_message_pack(data->friend_message, bp);
case TOX_EVENT_FRIEND_NAME:
return tox_event_friend_name_pack(event->data.friend_name, bp);
return tox_event_friend_name_pack(data->friend_name, bp);
case TOX_EVENT_FRIEND_READ_RECEIPT:
return tox_event_friend_read_receipt_pack(event->data.friend_read_receipt, bp);
return tox_event_friend_read_receipt_pack(data->friend_read_receipt, bp);
case TOX_EVENT_FRIEND_REQUEST:
return tox_event_friend_request_pack(event->data.friend_request, bp);
return tox_event_friend_request_pack(data->friend_request, bp);
case TOX_EVENT_FRIEND_STATUS:
return tox_event_friend_status_pack(event->data.friend_status, bp);
return tox_event_friend_status_pack(data->friend_status, bp);
case TOX_EVENT_FRIEND_STATUS_MESSAGE:
return tox_event_friend_status_message_pack(event->data.friend_status_message, bp);
return tox_event_friend_status_message_pack(data->friend_status_message, bp);
case TOX_EVENT_FRIEND_TYPING:
return tox_event_friend_typing_pack(event->data.friend_typing, bp);
return tox_event_friend_typing_pack(data->friend_typing, bp);
case TOX_EVENT_SELF_CONNECTION_STATUS:
return tox_event_self_connection_status_pack(event->data.self_connection_status, bp);
return tox_event_self_connection_status_pack(data->self_connection_status, bp);
case TOX_EVENT_GROUP_PEER_NAME:
return tox_event_group_peer_name_pack(event->data.group_peer_name, bp);
return tox_event_group_peer_name_pack(data->group_peer_name, bp);
case TOX_EVENT_GROUP_PEER_STATUS:
return tox_event_group_peer_status_pack(event->data.group_peer_status, bp);
return tox_event_group_peer_status_pack(data->group_peer_status, bp);
case TOX_EVENT_GROUP_TOPIC:
return tox_event_group_topic_pack(event->data.group_topic, bp);
return tox_event_group_topic_pack(data->group_topic, bp);
case TOX_EVENT_GROUP_PRIVACY_STATE:
return tox_event_group_privacy_state_pack(event->data.group_privacy_state, bp);
return tox_event_group_privacy_state_pack(data->group_privacy_state, bp);
case TOX_EVENT_GROUP_VOICE_STATE:
return tox_event_group_voice_state_pack(event->data.group_voice_state, bp);
return tox_event_group_voice_state_pack(data->group_voice_state, bp);
case TOX_EVENT_GROUP_TOPIC_LOCK:
return tox_event_group_topic_lock_pack(event->data.group_topic_lock, bp);
return tox_event_group_topic_lock_pack(data->group_topic_lock, bp);
case TOX_EVENT_GROUP_PEER_LIMIT:
return tox_event_group_peer_limit_pack(event->data.group_peer_limit, bp);
return tox_event_group_peer_limit_pack(data->group_peer_limit, bp);
case TOX_EVENT_GROUP_PASSWORD:
return tox_event_group_password_pack(event->data.group_password, bp);
return tox_event_group_password_pack(data->group_password, bp);
case TOX_EVENT_GROUP_MESSAGE:
return tox_event_group_message_pack(event->data.group_message, bp);
return tox_event_group_message_pack(data->group_message, bp);
case TOX_EVENT_GROUP_PRIVATE_MESSAGE:
return tox_event_group_private_message_pack(event->data.group_private_message, bp);
return tox_event_group_private_message_pack(data->group_private_message, bp);
case TOX_EVENT_GROUP_CUSTOM_PACKET:
return tox_event_group_custom_packet_pack(event->data.group_custom_packet, bp);
return tox_event_group_custom_packet_pack(data->group_custom_packet, bp);
case TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET:
return tox_event_group_custom_private_packet_pack(event->data.group_custom_private_packet, bp);
return tox_event_group_custom_private_packet_pack(data->group_custom_private_packet, bp);
case TOX_EVENT_GROUP_INVITE:
return tox_event_group_invite_pack(event->data.group_invite, bp);
return tox_event_group_invite_pack(data->group_invite, bp);
case TOX_EVENT_GROUP_PEER_JOIN:
return tox_event_group_peer_join_pack(event->data.group_peer_join, bp);
return tox_event_group_peer_join_pack(data->group_peer_join, bp);
case TOX_EVENT_GROUP_PEER_EXIT:
return tox_event_group_peer_exit_pack(event->data.group_peer_exit, bp);
return tox_event_group_peer_exit_pack(data->group_peer_exit, bp);
case TOX_EVENT_GROUP_SELF_JOIN:
return tox_event_group_self_join_pack(event->data.group_self_join, bp);
return tox_event_group_self_join_pack(data->group_self_join, bp);
case TOX_EVENT_GROUP_JOIN_FAIL:
return tox_event_group_join_fail_pack(event->data.group_join_fail, bp);
return tox_event_group_join_fail_pack(data->group_join_fail, bp);
case TOX_EVENT_GROUP_MODERATION:
return tox_event_group_moderation_pack(event->data.group_moderation, bp);
return tox_event_group_moderation_pack(data->group_moderation, bp);
case TOX_EVENT_INVALID:
return false;
@ -693,6 +698,15 @@ bool tox_event_pack(const Tox_Event *event, Bin_Pack *bp)
return false;
}
bool tox_event_pack(const Tox_Event *event, Bin_Pack *bp)
{
assert(event->type != TOX_EVENT_INVALID);
return bin_pack_array(bp, 2)
&& tox_event_type_pack(event->type, bp)
&& tox_event_data_pack(event->type, &event->data, bp);
}
non_null()
static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out)
{

View File

@ -0,0 +1,55 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2022 The TokTok team.
*/
#include "tox_pack.h"
#include <stdint.h>
#include "bin_pack.h"
#include "tox.h"
bool tox_conference_type_pack(Tox_Conference_Type val, Bin_Pack *bp)
{
return bin_pack_u32(bp, (uint32_t)val);
}
bool tox_connection_pack(Tox_Connection val, Bin_Pack *bp)
{
return bin_pack_u32(bp, (uint32_t)val);
}
bool tox_file_control_pack(Tox_File_Control val, Bin_Pack *bp)
{
return bin_pack_u32(bp, (uint32_t)val);
}
bool tox_message_type_pack(Tox_Message_Type val, Bin_Pack *bp)
{
return bin_pack_u32(bp, (uint32_t)val);
}
bool tox_user_status_pack(Tox_User_Status val, Bin_Pack *bp)
{
return bin_pack_u32(bp, (uint32_t)val);
}
bool tox_group_privacy_state_pack(Tox_Group_Privacy_State val, Bin_Pack *bp)
{
return bin_pack_u32(bp, (uint32_t)val);
}
bool tox_group_voice_state_pack(Tox_Group_Voice_State val, Bin_Pack *bp)
{
return bin_pack_u32(bp, (uint32_t)val);
}
bool tox_group_topic_lock_pack(Tox_Group_Topic_Lock val, Bin_Pack *bp)
{
return bin_pack_u32(bp, (uint32_t)val);
}
bool tox_group_join_fail_pack(Tox_Group_Join_Fail val, Bin_Pack *bp)
{
return bin_pack_u32(bp, (uint32_t)val);
}
bool tox_group_mod_event_pack(Tox_Group_Mod_Event val, Bin_Pack *bp)
{
return bin_pack_u32(bp, (uint32_t)val);
}
bool tox_group_exit_type_pack(Tox_Group_Exit_Type val, Bin_Pack *bp)
{
return bin_pack_u32(bp, (uint32_t)val);
}

View File

@ -0,0 +1,24 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2022 The TokTok team.
*/
#ifndef C_TOXCORE_TOXCORE_TOX_PACK_H
#define C_TOXCORE_TOXCORE_TOX_PACK_H
#include "attributes.h"
#include "bin_pack.h"
#include "tox.h"
non_null() bool tox_conference_type_pack(Tox_Conference_Type val, Bin_Pack *bp);
non_null() bool tox_connection_pack(Tox_Connection val, Bin_Pack *bp);
non_null() bool tox_file_control_pack(Tox_File_Control val, Bin_Pack *bp);
non_null() bool tox_message_type_pack(Tox_Message_Type val, Bin_Pack *bp);
non_null() bool tox_user_status_pack(Tox_User_Status val, Bin_Pack *bp);
non_null() bool tox_group_privacy_state_pack(Tox_Group_Privacy_State val, Bin_Pack *bp);
non_null() bool tox_group_voice_state_pack(Tox_Group_Voice_State val, Bin_Pack *bp);
non_null() bool tox_group_topic_lock_pack(Tox_Group_Topic_Lock val, Bin_Pack *bp);
non_null() bool tox_group_join_fail_pack(Tox_Group_Join_Fail val, Bin_Pack *bp);
non_null() bool tox_group_mod_event_pack(Tox_Group_Mod_Event val, Bin_Pack *bp);
non_null() bool tox_group_exit_type_pack(Tox_Group_Exit_Type val, Bin_Pack *bp);
#endif // C_TOXCORE_TOXCORE_TOX_PACK_H

View File

@ -29,7 +29,7 @@ static bool tox_conference_type_from_int(uint32_t value, Tox_Conference_Type *ou
}
}
}
bool tox_conference_type_unpack(Bin_Unpack *bu, Tox_Conference_Type *val)
bool tox_conference_type_unpack(Tox_Conference_Type *val, Bin_Unpack *bu)
{
uint32_t u32;
return bin_unpack_u32(bu, &u32)
@ -62,7 +62,7 @@ static bool tox_connection_from_int(uint32_t value, Tox_Connection *out)
}
}
bool tox_connection_unpack(Bin_Unpack *bu, Tox_Connection *val)
bool tox_connection_unpack(Tox_Connection *val, Bin_Unpack *bu)
{
uint32_t u32;
return bin_unpack_u32(bu, &u32)
@ -95,7 +95,7 @@ static bool tox_file_control_from_int(uint32_t value, Tox_File_Control *out)
}
}
bool tox_file_control_unpack(Bin_Unpack *bu, Tox_File_Control *val)
bool tox_file_control_unpack(Tox_File_Control *val, Bin_Unpack *bu)
{
uint32_t u32;
return bin_unpack_u32(bu, &u32)
@ -123,7 +123,7 @@ static bool tox_message_type_from_int(uint32_t value, Tox_Message_Type *out)
}
}
bool tox_message_type_unpack(Bin_Unpack *bu, Tox_Message_Type *val)
bool tox_message_type_unpack(Tox_Message_Type *val, Bin_Unpack *bu)
{
uint32_t u32;
return bin_unpack_u32(bu, &u32)
@ -156,7 +156,7 @@ static bool tox_user_status_from_int(uint32_t value, Tox_User_Status *out)
}
}
bool tox_user_status_unpack(Bin_Unpack *bu, Tox_User_Status *val)
bool tox_user_status_unpack(Tox_User_Status *val, Bin_Unpack *bu)
{
uint32_t u32;
return bin_unpack_u32(bu, &u32)
@ -181,7 +181,7 @@ static bool tox_group_privacy_state_from_int(uint32_t value, Tox_Group_Privacy_S
}
}
}
bool tox_group_privacy_state_unpack(Bin_Unpack *bu, Tox_Group_Privacy_State *val)
bool tox_group_privacy_state_unpack(Tox_Group_Privacy_State *val, Bin_Unpack *bu)
{
uint32_t u32;
return bin_unpack_u32(bu, &u32)
@ -209,7 +209,7 @@ static bool tox_group_voice_state_from_int(uint32_t value, Tox_Group_Voice_State
}
}
}
bool tox_group_voice_state_unpack(Bin_Unpack *bu, Tox_Group_Voice_State *val)
bool tox_group_voice_state_unpack(Tox_Group_Voice_State *val, Bin_Unpack *bu)
{
uint32_t u32;
return bin_unpack_u32(bu, &u32)
@ -234,7 +234,7 @@ static bool tox_group_topic_lock_from_int(uint32_t value, Tox_Group_Topic_Lock *
}
}
}
bool tox_group_topic_lock_unpack(Bin_Unpack *bu, Tox_Group_Topic_Lock *val)
bool tox_group_topic_lock_unpack(Tox_Group_Topic_Lock *val, Bin_Unpack *bu)
{
uint32_t u32;
return bin_unpack_u32(bu, &u32)
@ -263,7 +263,7 @@ static bool tox_group_join_fail_from_int(uint32_t value, Tox_Group_Join_Fail *ou
}
}
}
bool tox_group_join_fail_unpack(Bin_Unpack *bu, Tox_Group_Join_Fail *val)
bool tox_group_join_fail_unpack(Tox_Group_Join_Fail *val, Bin_Unpack *bu)
{
uint32_t u32;
return bin_unpack_u32(bu, &u32)
@ -296,7 +296,7 @@ static bool tox_group_mod_event_from_int(uint32_t value, Tox_Group_Mod_Event *ou
}
}
}
bool tox_group_mod_event_unpack(Bin_Unpack *bu, Tox_Group_Mod_Event *val)
bool tox_group_mod_event_unpack(Tox_Group_Mod_Event *val, Bin_Unpack *bu)
{
uint32_t u32;
return bin_unpack_u32(bu, &u32)
@ -337,7 +337,7 @@ static bool tox_group_exit_type_from_int(uint32_t value, Tox_Group_Exit_Type *ou
}
}
}
bool tox_group_exit_type_unpack(Bin_Unpack *bu, Tox_Group_Exit_Type *val)
bool tox_group_exit_type_unpack(Tox_Group_Exit_Type *val, Bin_Unpack *bu)
{
uint32_t u32;
return bin_unpack_u32(bu, &u32)

View File

@ -9,16 +9,16 @@
#include "bin_unpack.h"
#include "tox.h"
non_null() bool tox_conference_type_unpack(Bin_Unpack *bu, Tox_Conference_Type *val);
non_null() bool tox_connection_unpack(Bin_Unpack *bu, Tox_Connection *val);
non_null() bool tox_file_control_unpack(Bin_Unpack *bu, Tox_File_Control *val);
non_null() bool tox_message_type_unpack(Bin_Unpack *bu, Tox_Message_Type *val);
non_null() bool tox_user_status_unpack(Bin_Unpack *bu, Tox_User_Status *val);
non_null() bool tox_group_privacy_state_unpack(Bin_Unpack *bu, Tox_Group_Privacy_State *val);
non_null() bool tox_group_voice_state_unpack(Bin_Unpack *bu, Tox_Group_Voice_State *val);
non_null() bool tox_group_topic_lock_unpack(Bin_Unpack *bu, Tox_Group_Topic_Lock *val);
non_null() bool tox_group_join_fail_unpack(Bin_Unpack *bu, Tox_Group_Join_Fail *val);
non_null() bool tox_group_mod_event_unpack(Bin_Unpack *bu, Tox_Group_Mod_Event *val);
non_null() bool tox_group_exit_type_unpack(Bin_Unpack *bu, Tox_Group_Exit_Type *val);
non_null() bool tox_conference_type_unpack(Tox_Conference_Type *val, Bin_Unpack *bu);
non_null() bool tox_connection_unpack(Tox_Connection *val, Bin_Unpack *bu);
non_null() bool tox_file_control_unpack(Tox_File_Control *val, Bin_Unpack *bu);
non_null() bool tox_message_type_unpack(Tox_Message_Type *val, Bin_Unpack *bu);
non_null() bool tox_user_status_unpack(Tox_User_Status *val, Bin_Unpack *bu);
non_null() bool tox_group_privacy_state_unpack(Tox_Group_Privacy_State *val, Bin_Unpack *bu);
non_null() bool tox_group_voice_state_unpack(Tox_Group_Voice_State *val, Bin_Unpack *bu);
non_null() bool tox_group_topic_lock_unpack(Tox_Group_Topic_Lock *val, Bin_Unpack *bu);
non_null() bool tox_group_join_fail_unpack(Tox_Group_Join_Fail *val, Bin_Unpack *bu);
non_null() bool tox_group_mod_event_unpack(Tox_Group_Mod_Event *val, Bin_Unpack *bu);
non_null() bool tox_group_exit_type_unpack(Tox_Group_Exit_Type *val, Bin_Unpack *bu);
#endif // C_TOXCORE_TOXCORE_TOX_UNPACK_H