Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272

b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
This commit is contained in:
2024-03-07 23:12:55 +01:00
parent 61accfe184
commit aae086cc65
358 changed files with 8093 additions and 5229 deletions

View File

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -13,14 +14,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Conference_Connected {
uint32_t conference_number;
};
@ -65,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
@ -119,6 +117,7 @@ bool tox_event_conference_connected_unpack(
Tox_Event_Conference_Connected **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_conference_connected_new(mem);
if (*event == nullptr) {
@ -148,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -17,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;
@ -58,7 +57,7 @@ Tox_Conference_Type tox_event_conference_invite_get_type(const Tox_Event_Confere
return conference_invite->type;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_conference_invite_set_cookie(Tox_Event_Conference_Invite *conference_invite,
const uint8_t *cookie, uint32_t cookie_length)
{
@ -70,6 +69,11 @@ static bool tox_event_conference_invite_set_cookie(Tox_Event_Conference_Invite *
conference_invite->cookie_length = 0;
}
if (cookie == nullptr) {
assert(cookie_length == 0);
return true;
}
uint8_t *cookie_copy = (uint8_t *)malloc(cookie_length);
if (cookie_copy == nullptr) {
@ -128,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
@ -182,6 +185,7 @@ bool tox_event_conference_invite_unpack(
Tox_Event_Conference_Invite **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_conference_invite_new(mem);
if (*event == nullptr) {
@ -211,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -17,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;
@ -72,7 +71,7 @@ Tox_Message_Type tox_event_conference_message_get_type(const Tox_Event_Conferenc
return conference_message->type;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_conference_message_set_message(Tox_Event_Conference_Message *conference_message,
const uint8_t *message, uint32_t message_length)
{
@ -84,6 +83,11 @@ static bool tox_event_conference_message_set_message(Tox_Event_Conference_Messag
conference_message->message_length = 0;
}
if (message == nullptr) {
assert(message_length == 0);
return true;
}
uint8_t *message_copy = (uint8_t *)malloc(message_length);
if (message_copy == nullptr) {
@ -144,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
@ -198,6 +201,7 @@ bool tox_event_conference_message_unpack(
Tox_Event_Conference_Message **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_conference_message_new(mem);
if (*event == nullptr) {
@ -227,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -13,14 +14,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Conference_Peer_List_Changed {
uint32_t conference_number;
};
@ -65,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
@ -119,6 +117,7 @@ bool tox_event_conference_peer_list_changed_unpack(
Tox_Event_Conference_Peer_List_Changed **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_conference_peer_list_changed_new(mem);
if (*event == nullptr) {
@ -148,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -56,7 +55,7 @@ uint32_t tox_event_conference_peer_name_get_peer_number(const Tox_Event_Conferen
return conference_peer_name->peer_number;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_conference_peer_name_set_name(Tox_Event_Conference_Peer_Name *conference_peer_name,
const uint8_t *name, uint32_t name_length)
{
@ -68,6 +67,11 @@ static bool tox_event_conference_peer_name_set_name(Tox_Event_Conference_Peer_Na
conference_peer_name->name_length = 0;
}
if (name == nullptr) {
assert(name_length == 0);
return true;
}
uint8_t *name_copy = (uint8_t *)malloc(name_length);
if (name_copy == nullptr) {
@ -126,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
@ -180,6 +183,7 @@ bool tox_event_conference_peer_name_unpack(
Tox_Event_Conference_Peer_Name **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_conference_peer_name_new(mem);
if (*event == nullptr) {
@ -209,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -56,7 +55,7 @@ uint32_t tox_event_conference_title_get_peer_number(const Tox_Event_Conference_T
return conference_title->peer_number;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_conference_title_set_title(Tox_Event_Conference_Title *conference_title,
const uint8_t *title, uint32_t title_length)
{
@ -68,6 +67,11 @@ static bool tox_event_conference_title_set_title(Tox_Event_Conference_Title *con
conference_title->title_length = 0;
}
if (title == nullptr) {
assert(title_length == 0);
return true;
}
uint8_t *title_copy = (uint8_t *)malloc(title_length);
if (title_copy == nullptr) {
@ -126,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
@ -180,6 +183,7 @@ bool tox_event_conference_title_unpack(
Tox_Event_Conference_Title **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_conference_title_new(mem);
if (*event == nullptr) {
@ -209,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

@ -0,0 +1,223 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2022 The TokTok team.
*/
#include "events_alloc.h"
#include <assert.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
#include "../mem.h"
#include "../tox.h"
#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;
uint32_t ip_length;
uint16_t port;
};
non_null()
static bool tox_event_dht_get_nodes_response_set_public_key(Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE])
{
memcpy(dht_get_nodes_response->public_key, public_key, TOX_PUBLIC_KEY_SIZE);
return true;
}
const uint8_t *tox_event_dht_get_nodes_response_get_public_key(const Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response)
{
return dht_get_nodes_response->public_key;
}
non_null()
static bool tox_event_dht_get_nodes_response_set_ip(Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response,
const char *ip, uint32_t ip_length, const Memory *mem)
{
if (dht_get_nodes_response->ip != nullptr) {
mem_delete(mem, dht_get_nodes_response->ip);
dht_get_nodes_response->ip = nullptr;
dht_get_nodes_response->ip_length = 0;
}
uint8_t *ip_tmp = (uint8_t *)mem_balloc(mem, ip_length);
if (ip_tmp == nullptr) {
return false;
}
memcpy(ip_tmp, ip, ip_length);
dht_get_nodes_response->ip = ip_tmp;
dht_get_nodes_response->ip_length = ip_length;
return true;
}
uint32_t tox_event_dht_get_nodes_response_get_ip_length(const Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response)
{
return dht_get_nodes_response->ip_length;
}
const uint8_t *tox_event_dht_get_nodes_response_get_ip(const Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response)
{
return dht_get_nodes_response->ip;
}
non_null()
static bool tox_event_dht_get_nodes_response_set_port(Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response, uint16_t port)
{
dht_get_nodes_response->port = port;
return true;
}
uint16_t tox_event_dht_get_nodes_response_get_port(const Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response)
{
return dht_get_nodes_response->port;
}
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
}
};
}
non_null()
static void tox_event_dht_get_nodes_response_destruct(Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response, const Memory *mem)
{
mem_delete(mem, dht_get_nodes_response->ip);
}
bool tox_event_dht_get_nodes_response_pack(
const Tox_Event_Dht_Get_Nodes_Response *event, Bin_Pack *bp)
{
return bin_pack_array(bp, 3)
&& bin_pack_bin(bp, event->public_key, TOX_PUBLIC_KEY_SIZE)
&& bin_pack_bin(bp, event->ip, event->ip_length)
&& bin_pack_u16(bp, event->port);
}
non_null()
static bool tox_event_dht_get_nodes_response_unpack_into(
Tox_Event_Dht_Get_Nodes_Response *event, Bin_Unpack *bu)
{
if (!bin_unpack_array_fixed(bu, 3, nullptr)) {
return false;
}
return bin_unpack_bin_fixed(bu, event->public_key, TOX_PUBLIC_KEY_SIZE)
&& bin_unpack_bin(bu, &event->ip, &event->ip_length)
&& bin_unpack_u16(bu, &event->port);
}
const Tox_Event_Dht_Get_Nodes_Response *tox_event_get_dht_get_nodes_response(
const Tox_Event *event)
{
return event->type == TOX_EVENT_DHT_GET_NODES_RESPONSE ? event->data.dht_get_nodes_response : nullptr;
}
Tox_Event_Dht_Get_Nodes_Response *tox_event_dht_get_nodes_response_new(const Memory *mem)
{
Tox_Event_Dht_Get_Nodes_Response *const dht_get_nodes_response =
(Tox_Event_Dht_Get_Nodes_Response *)mem_alloc(mem, sizeof(Tox_Event_Dht_Get_Nodes_Response));
if (dht_get_nodes_response == nullptr) {
return nullptr;
}
tox_event_dht_get_nodes_response_construct(dht_get_nodes_response);
return dht_get_nodes_response;
}
void tox_event_dht_get_nodes_response_free(Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response, const Memory *mem)
{
if (dht_get_nodes_response != nullptr) {
tox_event_dht_get_nodes_response_destruct(dht_get_nodes_response, mem);
}
mem_delete(mem, dht_get_nodes_response);
}
non_null()
static Tox_Event_Dht_Get_Nodes_Response *tox_events_add_dht_get_nodes_response(Tox_Events *events, const Memory *mem)
{
Tox_Event_Dht_Get_Nodes_Response *const dht_get_nodes_response = tox_event_dht_get_nodes_response_new(mem);
if (dht_get_nodes_response == nullptr) {
return nullptr;
}
Tox_Event event;
event.type = TOX_EVENT_DHT_GET_NODES_RESPONSE;
event.data.dht_get_nodes_response = dht_get_nodes_response;
tox_events_add(events, &event);
return dht_get_nodes_response;
}
bool tox_event_dht_get_nodes_response_unpack(
Tox_Event_Dht_Get_Nodes_Response **event, Bin_Unpack *bu, const Memory *mem)
{
*event = tox_event_dht_get_nodes_response_new(mem);
if (*event == nullptr) {
return false;
}
return tox_event_dht_get_nodes_response_unpack_into(*event, bu);
}
non_null()
static Tox_Event_Dht_Get_Nodes_Response *tox_event_dht_get_nodes_response_alloc(void *user_data)
{
Tox_Events_State *state = tox_events_alloc(user_data);
assert(state != nullptr);
if (state->events == nullptr) {
return nullptr;
}
Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response = tox_events_add_dht_get_nodes_response(state->events, state->mem);
if (dht_get_nodes_response == nullptr) {
state->error = TOX_ERR_EVENTS_ITERATE_MALLOC;
return nullptr;
}
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_Event_Dht_Get_Nodes_Response *dht_get_nodes_response = tox_event_dht_get_nodes_response_alloc(user_data);
if (dht_get_nodes_response == nullptr) {
return;
}
const size_t ip_length = strlen(ip);
if (ip_length >= UINT32_MAX) {
return;
}
const Tox_System *sys = tox_get_system(tox);
tox_event_dht_get_nodes_response_set_public_key(dht_get_nodes_response, public_key);
tox_event_dht_get_nodes_response_set_ip(dht_get_nodes_response, ip, ip_length + 1, sys->mem);
tox_event_dht_get_nodes_response_set_port(dht_get_nodes_response, port);
}

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

@ -8,7 +8,11 @@
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../mem.h"
#include "../tox.h"
#include "../tox_event.h"
#include "../tox_events.h"
#include "../tox_private.h"
#ifdef __cplusplus
extern "C" {
@ -34,6 +38,7 @@ tox_conference_message_cb tox_events_handle_conference_message;
tox_conference_peer_list_changed_cb tox_events_handle_conference_peer_list_changed;
tox_conference_peer_name_cb tox_events_handle_conference_peer_name;
tox_conference_title_cb tox_events_handle_conference_title;
tox_dht_get_nodes_response_cb tox_events_handle_dht_get_nodes_response;
tox_file_chunk_request_cb tox_events_handle_file_chunk_request;
tox_file_recv_cb tox_events_handle_file_recv;
tox_file_recv_chunk_cb tox_events_handle_file_recv_chunk;
@ -68,12 +73,6 @@ tox_group_self_join_cb tox_events_handle_group_self_join;
tox_group_join_fail_cb tox_events_handle_group_join_fail;
tox_group_moderation_cb tox_events_handle_group_moderation;
non_null(2) nullable(1)
bool tox_events_pack(const Tox_Events *events, Bin_Pack *bp);
non_null()
bool tox_events_unpack(Tox_Events *events, Bin_Unpack *bu, const Memory *mem);
non_null()
Tox_Events_State *tox_events_alloc(void *user_data);
@ -81,7 +80,7 @@ non_null()
bool tox_events_add(Tox_Events *events, const Tox_Event *event);
#ifdef __cplusplus
}
} /* extern "C" */
#endif
#endif // C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H
#endif /* C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H */

View File

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -13,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;
@ -118,7 +117,6 @@ static bool tox_event_file_chunk_request_unpack_into(
&& bin_unpack_u16(bu, &event->length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -172,6 +170,7 @@ bool tox_event_file_chunk_request_unpack(
Tox_Event_File_Chunk_Request **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_file_chunk_request_new(mem);
if (*event == nullptr) {
@ -201,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -84,7 +83,7 @@ uint64_t tox_event_file_recv_get_file_size(const Tox_Event_File_Recv *file_recv)
return file_recv->file_size;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_file_recv_set_filename(Tox_Event_File_Recv *file_recv,
const uint8_t *filename, uint32_t filename_length)
{
@ -96,6 +95,11 @@ static bool tox_event_file_recv_set_filename(Tox_Event_File_Recv *file_recv,
file_recv->filename_length = 0;
}
if (filename == nullptr) {
assert(filename_length == 0);
return true;
}
uint8_t *filename_copy = (uint8_t *)malloc(filename_length);
if (filename_copy == nullptr) {
@ -158,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
@ -212,6 +215,7 @@ bool tox_event_file_recv_unpack(
Tox_Event_File_Recv **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_file_recv_new(mem);
if (*event == nullptr) {
@ -241,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -70,7 +69,7 @@ uint64_t tox_event_file_recv_chunk_get_position(const Tox_Event_File_Recv_Chunk
return file_recv_chunk->position;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_file_recv_chunk_set_data(Tox_Event_File_Recv_Chunk *file_recv_chunk,
const uint8_t *data, uint32_t data_length)
{
@ -82,6 +81,11 @@ static bool tox_event_file_recv_chunk_set_data(Tox_Event_File_Recv_Chunk *file_r
file_recv_chunk->data_length = 0;
}
if (data == nullptr) {
assert(data_length == 0);
return true;
}
uint8_t *data_copy = (uint8_t *)malloc(data_length);
if (data_copy == nullptr) {
@ -142,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
@ -196,6 +199,7 @@ bool tox_event_file_recv_chunk_unpack(
Tox_Event_File_Recv_Chunk **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_file_recv_chunk_new(mem);
if (*event == nullptr) {
@ -225,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -104,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
@ -158,6 +156,7 @@ bool tox_event_file_recv_control_unpack(
Tox_Event_File_Recv_Control **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_file_recv_control_new(mem);
if (*event == nullptr) {
@ -187,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -88,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
@ -142,6 +140,7 @@ bool tox_event_friend_connection_status_unpack(
Tox_Event_Friend_Connection_Status **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_friend_connection_status_new(mem);
if (*event == nullptr) {
@ -171,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -42,7 +41,7 @@ uint32_t tox_event_friend_lossless_packet_get_friend_number(const Tox_Event_Frie
return friend_lossless_packet->friend_number;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_friend_lossless_packet_set_data(Tox_Event_Friend_Lossless_Packet *friend_lossless_packet,
const uint8_t *data, uint32_t data_length)
{
@ -54,6 +53,11 @@ static bool tox_event_friend_lossless_packet_set_data(Tox_Event_Friend_Lossless_
friend_lossless_packet->data_length = 0;
}
if (data == nullptr) {
assert(data_length == 0);
return true;
}
uint8_t *data_copy = (uint8_t *)malloc(data_length);
if (data_copy == nullptr) {
@ -110,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
@ -164,6 +167,7 @@ bool tox_event_friend_lossless_packet_unpack(
Tox_Event_Friend_Lossless_Packet **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_friend_lossless_packet_new(mem);
if (*event == nullptr) {
@ -193,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -42,7 +41,7 @@ uint32_t tox_event_friend_lossy_packet_get_friend_number(const Tox_Event_Friend_
return friend_lossy_packet->friend_number;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_friend_lossy_packet_set_data(Tox_Event_Friend_Lossy_Packet *friend_lossy_packet,
const uint8_t *data, uint32_t data_length)
{
@ -54,6 +53,11 @@ static bool tox_event_friend_lossy_packet_set_data(Tox_Event_Friend_Lossy_Packet
friend_lossy_packet->data_length = 0;
}
if (data == nullptr) {
assert(data_length == 0);
return true;
}
uint8_t *data_copy = (uint8_t *)malloc(data_length);
if (data_copy == nullptr) {
@ -110,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
@ -164,6 +167,7 @@ bool tox_event_friend_lossy_packet_unpack(
Tox_Event_Friend_Lossy_Packet **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_friend_lossy_packet_new(mem);
if (*event == nullptr) {
@ -193,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -17,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;
@ -58,7 +57,7 @@ Tox_Message_Type tox_event_friend_message_get_type(const Tox_Event_Friend_Messag
return friend_message->type;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_friend_message_set_message(Tox_Event_Friend_Message *friend_message,
const uint8_t *message, uint32_t message_length)
{
@ -70,6 +69,11 @@ static bool tox_event_friend_message_set_message(Tox_Event_Friend_Message *frien
friend_message->message_length = 0;
}
if (message == nullptr) {
assert(message_length == 0);
return true;
}
uint8_t *message_copy = (uint8_t *)malloc(message_length);
if (message_copy == nullptr) {
@ -128,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
@ -182,6 +185,7 @@ bool tox_event_friend_message_unpack(
Tox_Event_Friend_Message **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_friend_message_new(mem);
if (*event == nullptr) {
@ -211,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -42,7 +41,7 @@ uint32_t tox_event_friend_name_get_friend_number(const Tox_Event_Friend_Name *fr
return friend_name->friend_number;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_friend_name_set_name(Tox_Event_Friend_Name *friend_name,
const uint8_t *name, uint32_t name_length)
{
@ -54,6 +53,11 @@ static bool tox_event_friend_name_set_name(Tox_Event_Friend_Name *friend_name,
friend_name->name_length = 0;
}
if (name == nullptr) {
assert(name_length == 0);
return true;
}
uint8_t *name_copy = (uint8_t *)malloc(name_length);
if (name_copy == nullptr) {
@ -110,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
@ -164,6 +167,7 @@ bool tox_event_friend_name_unpack(
Tox_Event_Friend_Name **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_friend_name_new(mem);
if (*event == nullptr) {
@ -193,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -13,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;
@ -86,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
@ -140,6 +138,7 @@ bool tox_event_friend_read_receipt_unpack(
Tox_Event_Friend_Read_Receipt **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_friend_read_receipt_new(mem);
if (*event == nullptr) {
@ -169,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

@ -7,6 +7,7 @@
#include <assert.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -81,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()
@ -159,6 +160,7 @@ bool tox_event_friend_request_unpack(
Tox_Event_Friend_Request **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_friend_request_new(mem);
if (*event == nullptr) {
@ -188,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -88,7 +87,6 @@ static bool tox_event_friend_status_unpack_into(
&& tox_user_status_unpack(&event->status, bu);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -142,6 +140,7 @@ bool tox_event_friend_status_unpack(
Tox_Event_Friend_Status **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_friend_status_new(mem);
if (*event == nullptr) {
@ -171,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -42,7 +41,7 @@ uint32_t tox_event_friend_status_message_get_friend_number(const Tox_Event_Frien
return friend_status_message->friend_number;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_friend_status_message_set_message(Tox_Event_Friend_Status_Message *friend_status_message,
const uint8_t *message, uint32_t message_length)
{
@ -54,6 +53,11 @@ static bool tox_event_friend_status_message_set_message(Tox_Event_Friend_Status_
friend_status_message->message_length = 0;
}
if (message == nullptr) {
assert(message_length == 0);
return true;
}
uint8_t *message_copy = (uint8_t *)malloc(message_length);
if (message_copy == nullptr) {
@ -110,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
@ -164,6 +167,7 @@ bool tox_event_friend_status_message_unpack(
Tox_Event_Friend_Status_Message **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_friend_status_message_new(mem);
if (*event == nullptr) {
@ -193,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -13,14 +14,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Friend_Typing {
uint32_t friend_number;
bool typing;
@ -86,7 +85,6 @@ static bool tox_event_friend_typing_unpack_into(
&& bin_unpack_bool(bu, &event->typing);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -140,6 +138,7 @@ bool tox_event_friend_typing_unpack(
Tox_Event_Friend_Typing **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_friend_typing_new(mem);
if (*event == nullptr) {
@ -169,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -56,7 +55,7 @@ uint32_t tox_event_group_custom_packet_get_peer_id(const Tox_Event_Group_Custom_
return group_custom_packet->peer_id;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_group_custom_packet_set_data(Tox_Event_Group_Custom_Packet *group_custom_packet,
const uint8_t *data, uint32_t data_length)
{
@ -68,6 +67,11 @@ static bool tox_event_group_custom_packet_set_data(Tox_Event_Group_Custom_Packet
group_custom_packet->data_length = 0;
}
if (data == nullptr) {
assert(data_length == 0);
return true;
}
uint8_t *data_copy = (uint8_t *)malloc(data_length);
if (data_copy == nullptr) {
@ -126,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
@ -180,6 +183,7 @@ bool tox_event_group_custom_packet_unpack(
Tox_Event_Group_Custom_Packet **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_custom_packet_new(mem);
if (*event == nullptr) {
@ -209,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -56,7 +55,7 @@ uint32_t tox_event_group_custom_private_packet_get_peer_id(const Tox_Event_Group
return group_custom_private_packet->peer_id;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_group_custom_private_packet_set_data(Tox_Event_Group_Custom_Private_Packet *group_custom_private_packet,
const uint8_t *data, uint32_t data_length)
{
@ -68,6 +67,11 @@ static bool tox_event_group_custom_private_packet_set_data(Tox_Event_Group_Custo
group_custom_private_packet->data_length = 0;
}
if (data == nullptr) {
assert(data_length == 0);
return true;
}
uint8_t *data_copy = (uint8_t *)malloc(data_length);
if (data_copy == nullptr) {
@ -126,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
@ -180,6 +183,7 @@ bool tox_event_group_custom_private_packet_unpack(
Tox_Event_Group_Custom_Private_Packet **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_custom_private_packet_new(mem);
if (*event == nullptr) {
@ -209,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -44,7 +43,7 @@ uint32_t tox_event_group_invite_get_friend_number(const Tox_Event_Group_Invite *
return group_invite->friend_number;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_group_invite_set_invite_data(Tox_Event_Group_Invite *group_invite,
const uint8_t *invite_data, uint32_t invite_data_length)
{
@ -56,6 +55,11 @@ static bool tox_event_group_invite_set_invite_data(Tox_Event_Group_Invite *group
group_invite->invite_data_length = 0;
}
if (invite_data == nullptr) {
assert(invite_data_length == 0);
return true;
}
uint8_t *invite_data_copy = (uint8_t *)malloc(invite_data_length);
if (invite_data_copy == nullptr) {
@ -78,7 +82,7 @@ const uint8_t *tox_event_group_invite_get_invite_data(const Tox_Event_Group_Invi
return group_invite->invite_data;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_group_invite_set_group_name(Tox_Event_Group_Invite *group_invite,
const uint8_t *group_name, uint32_t group_name_length)
{
@ -90,6 +94,11 @@ static bool tox_event_group_invite_set_group_name(Tox_Event_Group_Invite *group_
group_invite->group_name_length = 0;
}
if (group_name == nullptr) {
assert(group_name_length == 0);
return true;
}
uint8_t *group_name_copy = (uint8_t *)malloc(group_name_length);
if (group_name_copy == nullptr) {
@ -149,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
@ -203,6 +211,7 @@ bool tox_event_group_invite_unpack(
Tox_Event_Group_Invite **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_invite_new(mem);
if (*event == nullptr) {
@ -232,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -88,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
@ -142,6 +140,7 @@ bool tox_event_group_join_fail_unpack(
Tox_Event_Group_Join_Fail **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_join_fail_new(mem);
if (*event == nullptr) {
@ -171,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -17,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;
@ -73,7 +72,7 @@ Tox_Message_Type tox_event_group_message_get_type(const Tox_Event_Group_Message
return group_message->type;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_group_message_set_message(Tox_Event_Group_Message *group_message,
const uint8_t *message, uint32_t message_length)
{
@ -85,6 +84,11 @@ static bool tox_event_group_message_set_message(Tox_Event_Group_Message *group_m
group_message->message_length = 0;
}
if (message == nullptr) {
assert(message_length == 0);
return true;
}
uint8_t *message_copy = (uint8_t *)malloc(message_length);
if (message_copy == nullptr) {
@ -160,7 +164,6 @@ static bool tox_event_group_message_unpack_into(
&& bin_unpack_u32(bu, &event->message_id);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -214,6 +217,7 @@ bool tox_event_group_message_unpack(
Tox_Event_Group_Message **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_message_new(mem);
if (*event == nullptr) {
@ -243,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -120,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
@ -174,6 +172,7 @@ bool tox_event_group_moderation_unpack(
Tox_Event_Group_Moderation **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_moderation_new(mem);
if (*event == nullptr) {
@ -203,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -42,7 +41,7 @@ uint32_t tox_event_group_password_get_group_number(const Tox_Event_Group_Passwor
return group_password->group_number;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_group_password_set_password(Tox_Event_Group_Password *group_password,
const uint8_t *password, uint32_t password_length)
{
@ -54,6 +53,11 @@ static bool tox_event_group_password_set_password(Tox_Event_Group_Password *grou
group_password->password_length = 0;
}
if (password == nullptr) {
assert(password_length == 0);
return true;
}
uint8_t *password_copy = (uint8_t *)malloc(password_length);
if (password_copy == nullptr) {
@ -110,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
@ -164,6 +167,7 @@ bool tox_event_group_password_unpack(
Tox_Event_Group_Password **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_password_new(mem);
if (*event == nullptr) {
@ -193,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -17,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;
@ -74,7 +73,7 @@ Tox_Group_Exit_Type tox_event_group_peer_exit_get_exit_type(const Tox_Event_Grou
return group_peer_exit->exit_type;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_group_peer_exit_set_name(Tox_Event_Group_Peer_Exit *group_peer_exit,
const uint8_t *name, uint32_t name_length)
{
@ -86,6 +85,11 @@ static bool tox_event_group_peer_exit_set_name(Tox_Event_Group_Peer_Exit *group_
group_peer_exit->name_length = 0;
}
if (name == nullptr) {
assert(name_length == 0);
return true;
}
uint8_t *name_copy = (uint8_t *)malloc(name_length);
if (name_copy == nullptr) {
@ -108,7 +112,7 @@ const uint8_t *tox_event_group_peer_exit_get_name(const Tox_Event_Group_Peer_Exi
return group_peer_exit->name;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_group_peer_exit_set_part_message(Tox_Event_Group_Peer_Exit *group_peer_exit,
const uint8_t *part_message, uint32_t part_message_length)
{
@ -120,6 +124,11 @@ static bool tox_event_group_peer_exit_set_part_message(Tox_Event_Group_Peer_Exit
group_peer_exit->part_message_length = 0;
}
if (part_message == nullptr) {
assert(part_message_length == 0);
return true;
}
uint8_t *part_message_copy = (uint8_t *)malloc(part_message_length);
if (part_message_copy == nullptr) {
@ -183,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
@ -237,6 +245,7 @@ bool tox_event_group_peer_exit_unpack(
Tox_Event_Group_Peer_Exit **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_peer_exit_new(mem);
if (*event == nullptr) {
@ -266,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -13,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;
@ -86,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
@ -140,6 +138,7 @@ bool tox_event_group_peer_join_unpack(
Tox_Event_Group_Peer_Join **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_peer_join_new(mem);
if (*event == nullptr) {
@ -169,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -13,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;
@ -86,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
@ -140,6 +138,7 @@ bool tox_event_group_peer_limit_unpack(
Tox_Event_Group_Peer_Limit **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_peer_limit_new(mem);
if (*event == nullptr) {
@ -169,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

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -56,7 +55,7 @@ uint32_t tox_event_group_peer_name_get_peer_id(const Tox_Event_Group_Peer_Name *
return group_peer_name->peer_id;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_group_peer_name_set_name(Tox_Event_Group_Peer_Name *group_peer_name,
const uint8_t *name, uint32_t name_length)
{
@ -68,6 +67,11 @@ static bool tox_event_group_peer_name_set_name(Tox_Event_Group_Peer_Name *group_
group_peer_name->name_length = 0;
}
if (name == nullptr) {
assert(name_length == 0);
return true;
}
uint8_t *name_copy = (uint8_t *)malloc(name_length);
if (name_copy == nullptr) {
@ -126,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
@ -180,6 +183,7 @@ bool tox_event_group_peer_name_unpack(
Tox_Event_Group_Peer_Name **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_peer_name_new(mem);
if (*event == nullptr) {
@ -209,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -104,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
@ -158,6 +156,7 @@ bool tox_event_group_peer_status_unpack(
Tox_Event_Group_Peer_Status **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_peer_status_new(mem);
if (*event == nullptr) {
@ -187,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

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,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;
@ -88,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
@ -142,6 +140,7 @@ bool tox_event_group_privacy_state_unpack(
Tox_Event_Group_Privacy_State **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_privacy_state_new(mem);
if (*event == nullptr) {
@ -171,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);

View File

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -17,20 +18,19 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Private_Message {
uint32_t group_number;
uint32_t peer_id;
Tox_Message_Type type;
uint8_t *message;
uint32_t message_length;
uint32_t message_id;
};
non_null()
@ -72,7 +72,7 @@ Tox_Message_Type tox_event_group_private_message_get_type(const Tox_Event_Group_
return group_private_message->type;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_group_private_message_set_message(Tox_Event_Group_Private_Message *group_private_message,
const uint8_t *message, uint32_t message_length)
{
@ -84,6 +84,11 @@ static bool tox_event_group_private_message_set_message(Tox_Event_Group_Private_
group_private_message->message_length = 0;
}
if (message == nullptr) {
assert(message_length == 0);
return true;
}
uint8_t *message_copy = (uint8_t *)malloc(message_length);
if (message_copy == nullptr) {
@ -106,6 +111,19 @@ const uint8_t *tox_event_group_private_message_get_message(const Tox_Event_Group
return group_private_message->message;
}
non_null()
static void tox_event_group_private_message_set_message_id(Tox_Event_Group_Private_Message *group_private_message,
uint32_t message_id)
{
assert(group_private_message != nullptr);
group_private_message->message_id = message_id;
}
uint32_t tox_event_group_private_message_get_message_id(const Tox_Event_Group_Private_Message *group_private_message)
{
assert(group_private_message != nullptr);
return group_private_message->message_id;
}
non_null()
static void tox_event_group_private_message_construct(Tox_Event_Group_Private_Message *group_private_message)
{
@ -122,11 +140,12 @@ 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)
{
return bin_pack_array(bp, 4)
return bin_pack_array(bp, 5)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id)
&& tox_message_type_pack(event->type, bp)
&& bin_pack_bin(bp, event->message, event->message_length);
&& bin_pack_bin(bp, event->message, event->message_length)
&& bin_pack_u32(bp, event->message_id);
}
non_null()
@ -134,17 +153,17 @@ static bool tox_event_group_private_message_unpack_into(
Tox_Event_Group_Private_Message *event, Bin_Unpack *bu)
{
assert(event != nullptr);
if (!bin_unpack_array_fixed(bu, 4, nullptr)) {
if (!bin_unpack_array_fixed(bu, 5, nullptr)) {
return false;
}
return bin_unpack_u32(bu, &event->group_number)
&& bin_unpack_u32(bu, &event->peer_id)
&& tox_message_type_unpack(&event->type, bu)
&& bin_unpack_bin(bu, &event->message, &event->message_length);
&& bin_unpack_bin(bu, &event->message, &event->message_length)
&& bin_unpack_u32(bu, &event->message_id);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -198,6 +217,7 @@ bool tox_event_group_private_message_unpack(
Tox_Event_Group_Private_Message **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_private_message_new(mem);
if (*event == nullptr) {
@ -227,16 +247,15 @@ static Tox_Event_Group_Private_Message *tox_event_group_private_message_alloc(vo
return group_private_message;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_private_message(Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, const uint8_t *message, size_t length,
void *user_data)
void tox_events_handle_group_private_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_Private_Message *group_private_message = tox_event_group_private_message_alloc(user_data);
@ -248,4 +267,5 @@ void tox_events_handle_group_private_message(Tox *tox, uint32_t group_number, ui
tox_event_group_private_message_set_peer_id(group_private_message, peer_id);
tox_event_group_private_message_set_type(group_private_message, type);
tox_event_group_private_message_set_message(group_private_message, message, length);
tox_event_group_private_message_set_message_id(group_private_message, message_id);
}

View File

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -13,14 +14,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Self_Join {
uint32_t group_number;
};
@ -65,7 +64,6 @@ static bool tox_event_group_self_join_unpack_into(
return bin_unpack_u32(bu, &event->group_number);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -119,6 +117,7 @@ bool tox_event_group_self_join_unpack(
Tox_Event_Group_Self_Join **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_self_join_new(mem);
if (*event == nullptr) {
@ -148,16 +147,15 @@ static Tox_Event_Group_Self_Join *tox_event_group_self_join_alloc(void *user_dat
return group_self_join;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_self_join(Tox *tox, uint32_t group_number,
void *user_data)
void tox_events_handle_group_self_join(
Tox *tox, uint32_t group_number,
void *user_data)
{
Tox_Event_Group_Self_Join *group_self_join = tox_event_group_self_join_alloc(user_data);

View File

@ -8,6 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,14 +16,12 @@
#include "../tox.h"
#include "../tox_events.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Topic {
uint32_t group_number;
uint32_t peer_id;
@ -56,7 +55,7 @@ uint32_t tox_event_group_topic_get_peer_id(const Tox_Event_Group_Topic *group_to
return group_topic->peer_id;
}
non_null()
non_null(1) nullable(2)
static bool tox_event_group_topic_set_topic(Tox_Event_Group_Topic *group_topic,
const uint8_t *topic, uint32_t topic_length)
{
@ -68,6 +67,11 @@ static bool tox_event_group_topic_set_topic(Tox_Event_Group_Topic *group_topic,
group_topic->topic_length = 0;
}
if (topic == nullptr) {
assert(topic_length == 0);
return true;
}
uint8_t *topic_copy = (uint8_t *)malloc(topic_length);
if (topic_copy == nullptr) {
@ -126,7 +130,6 @@ static bool tox_event_group_topic_unpack_into(
&& bin_unpack_bin(bu, &event->topic, &event->topic_length);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -180,6 +183,7 @@ bool tox_event_group_topic_unpack(
Tox_Event_Group_Topic **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_topic_new(mem);
if (*event == nullptr) {
@ -209,16 +213,15 @@ static Tox_Event_Group_Topic *tox_event_group_topic_alloc(void *user_data)
return group_topic;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_topic(Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *topic, size_t length,
void *user_data)
void tox_events_handle_group_topic(
Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *topic, size_t length,
void *user_data)
{
Tox_Event_Group_Topic *group_topic = tox_event_group_topic_alloc(user_data);

View File

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,14 +16,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Topic_Lock {
uint32_t group_number;
Tox_Group_Topic_Lock topic_lock;
@ -88,7 +87,6 @@ static bool tox_event_group_topic_lock_unpack_into(
&& tox_group_topic_lock_unpack(&event->topic_lock, bu);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -142,6 +140,7 @@ bool tox_event_group_topic_lock_unpack(
Tox_Event_Group_Topic_Lock **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_topic_lock_new(mem);
if (*event == nullptr) {
@ -171,16 +170,15 @@ static Tox_Event_Group_Topic_Lock *tox_event_group_topic_lock_alloc(void *user_d
return group_topic_lock;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_topic_lock(Tox *tox, uint32_t group_number, Tox_Group_Topic_Lock topic_lock,
void *user_data)
void tox_events_handle_group_topic_lock(
Tox *tox, uint32_t group_number, Tox_Group_Topic_Lock topic_lock,
void *user_data)
{
Tox_Event_Group_Topic_Lock *group_topic_lock = tox_event_group_topic_lock_alloc(user_data);

View File

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,14 +16,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Group_Voice_State {
uint32_t group_number;
Tox_Group_Voice_State voice_state;
@ -88,7 +87,6 @@ static bool tox_event_group_voice_state_unpack_into(
&& tox_group_voice_state_unpack(&event->voice_state, bu);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -142,6 +140,7 @@ bool tox_event_group_voice_state_unpack(
Tox_Event_Group_Voice_State **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_group_voice_state_new(mem);
if (*event == nullptr) {
@ -171,16 +170,15 @@ static Tox_Event_Group_Voice_State *tox_event_group_voice_state_alloc(void *user
return group_voice_state;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_group_voice_state(Tox *tox, uint32_t group_number, Tox_Group_Voice_State voice_state,
void *user_data)
void tox_events_handle_group_voice_state(
Tox *tox, uint32_t group_number, Tox_Group_Voice_State voice_state,
void *user_data)
{
Tox_Event_Group_Voice_State *group_voice_state = tox_event_group_voice_state_alloc(user_data);

View File

@ -6,6 +6,7 @@
#include <assert.h>
#include "../attributes.h"
#include "../bin_pack.h"
#include "../bin_unpack.h"
#include "../ccompat.h"
@ -15,14 +16,12 @@
#include "../tox_pack.h"
#include "../tox_unpack.h"
/*****************************************************
*
* :: struct and accessors
*
*****************************************************/
struct Tox_Event_Self_Connection_Status {
Tox_Connection connection_status;
};
@ -67,7 +66,6 @@ static bool tox_event_self_connection_status_unpack_into(
return tox_connection_unpack(&event->connection_status, bu);
}
/*****************************************************
*
* :: new/free/add/get/size/unpack
@ -121,6 +119,7 @@ bool tox_event_self_connection_status_unpack(
Tox_Event_Self_Connection_Status **event, Bin_Unpack *bu, const Memory *mem)
{
assert(event != nullptr);
assert(*event == nullptr);
*event = tox_event_self_connection_status_new(mem);
if (*event == nullptr) {
@ -150,16 +149,15 @@ static Tox_Event_Self_Connection_Status *tox_event_self_connection_status_alloc(
return self_connection_status;
}
/*****************************************************
*
* :: event handler
*
*****************************************************/
void tox_events_handle_self_connection_status(Tox *tox, Tox_Connection connection_status,
void *user_data)
void tox_events_handle_self_connection_status(
Tox *tox, Tox_Connection connection_status,
void *user_data)
{
Tox_Event_Self_Connection_Status *self_connection_status = tox_event_self_connection_status_alloc(user_data);