cleanup: Ensure handler params are named after callback params.

This commit is contained in:
iphydf 2024-01-17 22:35:00 +00:00
parent c650d9d345
commit 89957be230
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
33 changed files with 260 additions and 262 deletions

View File

@ -1 +1 @@
c31bc1cd7249c62b4f1d2c9ea26c9e8528d9b897dc29afbdbe95894d30c92c8d /usr/local/bin/tox-bootstrapd
3b4f5c3224e919d4474c4af4b5058916b181a2689f59a3b04e72305b454b2ae3 /usr/local/bin/tox-bootstrapd

View File

@ -194,9 +194,9 @@ void ac_iterate(ACSession *ac)
free(temp_audio_buffer);
}
int ac_queue_message(Mono_Time *mono_time, void *acp, struct RTPMessage *msg)
int ac_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg)
{
ACSession *ac = (ACSession *)acp;
ACSession *ac = (ACSession *)cs;
if (ac == nullptr || msg == nullptr) {
free(msg);

View File

@ -67,7 +67,7 @@ ACSession *ac_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t f
toxav_audio_receive_frame_cb *cb, void *cb_data);
void ac_kill(ACSession *ac);
void ac_iterate(ACSession *ac);
int ac_queue_message(Mono_Time *mono_time, void *acp, struct RTPMessage *msg);
int ac_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
int ac_reconfigure_encoder(ACSession *ac, uint32_t bit_rate, uint32_t sampling_rate, uint8_t channels);
#endif // C_TOXCORE_TOXAV_AUDIO_H

View File

@ -56,7 +56,7 @@ struct BWCMessage {
uint32_t recv;
};
static int bwc_handle_data(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length, void *object);
static int bwc_handle_data(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object);
static int bwc_send_custom_lossy_packet(Tox *tox, int32_t friendnumber, const uint8_t *data, uint32_t length);
static void send_update(BWController *bwc);
@ -206,7 +206,7 @@ static int bwc_send_custom_lossy_packet(Tox *tox, int32_t friendnumber, const ui
return -1;
}
static int bwc_handle_data(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length, void *object)
static int bwc_handle_data(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object)
{
BWController *bwc = (BWController *)object;

View File

@ -10,7 +10,7 @@
typedef struct BWController BWController;
typedef void m_cb(BWController *bwc, uint32_t friend_number, float todo, void *user_data);
typedef void m_cb(BWController *bwc, uint32_t friend_number, float loss, void *user_data);
BWController *bwc_new(Messenger *m, Tox *tox, uint32_t friendnumber, m_cb *mcb, void *mcb_user_data,
Mono_Time *bwc_mono_time);

View File

@ -255,7 +255,7 @@ static Group_AV *new_group_av(const Logger *log, Tox *tox, Group_Chats *g_c, aud
return group_av;
}
static void group_av_peer_new(void *object, uint32_t groupnumber, uint32_t friendgroupnumber)
static void group_av_peer_new(void *object, uint32_t conference_number, uint32_t peer_number)
{
const Group_AV *group_av = (const Group_AV *)object;
Group_Peer_AV *peer_av = (Group_Peer_AV *)calloc(1, sizeof(Group_Peer_AV));
@ -267,12 +267,12 @@ static void group_av_peer_new(void *object, uint32_t groupnumber, uint32_t frien
peer_av->mono_time = g_mono_time(group_av->g_c);
peer_av->buffer = create_queue(GROUP_JBUF_SIZE);
if (group_peer_set_object(group_av->g_c, groupnumber, friendgroupnumber, peer_av) == -1) {
if (group_peer_set_object(group_av->g_c, conference_number, peer_number, peer_av) == -1) {
free(peer_av);
}
}
static void group_av_peer_delete(void *object, uint32_t groupnumber, void *peer_object)
static void group_av_peer_delete(void *object, uint32_t conference_number, void *peer_object)
{
Group_Peer_AV *peer_av = (Group_Peer_AV *)peer_object;
@ -288,7 +288,7 @@ static void group_av_peer_delete(void *object, uint32_t groupnumber, void *peer_
free(peer_object);
}
static void group_av_groupchat_delete(void *object, uint32_t groupnumber)
static void group_av_groupchat_delete(void *object, uint32_t conference_number)
{
Group_AV *group_av = (Group_AV *)object;
if (group_av != nullptr) {
@ -296,8 +296,8 @@ static void group_av_groupchat_delete(void *object, uint32_t groupnumber)
}
}
static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_av, uint32_t groupnumber,
uint32_t friendgroupnumber)
static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_av, uint32_t conference_number,
uint32_t peer_number)
{
if (group_av == nullptr || peer_av == nullptr) {
return -1;
@ -391,7 +391,7 @@ static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_av, uint3
if (out_audio != nullptr) {
if (group_av->audio_data != nullptr) {
group_av->audio_data(group_av->tox, groupnumber, friendgroupnumber, out_audio, out_audio_samples,
group_av->audio_data(group_av->tox, conference_number, peer_number, out_audio, out_audio_samples,
peer_av->decoder_channels, sample_rate, group_av->userdata);
}
@ -402,7 +402,7 @@ static int decode_audio_packet(Group_AV *group_av, Group_Peer_AV *peer_av, uint3
return -1;
}
static int handle_group_audio_packet(void *object, uint32_t groupnumber, uint32_t friendgroupnumber, void *peer_object,
static int handle_group_audio_packet(void *object, uint32_t conference_number, uint32_t peer_number, void *peer_object,
const uint8_t *packet, uint16_t length)
{
Group_AV *group_av = (Group_AV *)object;
@ -435,7 +435,7 @@ static int handle_group_audio_packet(void *object, uint32_t groupnumber, uint32_
return -1;
}
while (decode_audio_packet(group_av, peer_av, groupnumber, friendgroupnumber) == 0) {
while (decode_audio_packet(group_av, peer_av, conference_number, peer_number) == 0) {
/* Continue. */
}
@ -447,11 +447,11 @@ static int handle_group_audio_packet(void *object, uint32_t groupnumber, uint32_
* @retval 0 on success.
* @retval -1 on failure.
*/
int groupchat_enable_av(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t groupnumber,
int groupchat_enable_av(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t conference_number,
audio_data_cb *audio_callback, void *userdata)
{
if (group_get_type(g_c, groupnumber) != GROUPCHAT_TYPE_AV
|| group_get_object(g_c, groupnumber) != nullptr) {
if (group_get_type(g_c, conference_number) != GROUPCHAT_TYPE_AV
|| group_get_object(g_c, conference_number) != nullptr) {
return -1;
}
@ -461,15 +461,15 @@ int groupchat_enable_av(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t
return -1;
}
if (group_set_object(g_c, groupnumber, group_av) == -1
|| callback_groupchat_peer_new(g_c, groupnumber, group_av_peer_new) == -1
|| callback_groupchat_peer_delete(g_c, groupnumber, group_av_peer_delete) == -1
|| callback_groupchat_delete(g_c, groupnumber, group_av_groupchat_delete) == -1) {
if (group_set_object(g_c, conference_number, group_av) == -1
|| callback_groupchat_peer_new(g_c, conference_number, group_av_peer_new) == -1
|| callback_groupchat_peer_delete(g_c, conference_number, group_av_peer_delete) == -1
|| callback_groupchat_delete(g_c, conference_number, group_av_groupchat_delete) == -1) {
kill_group_av(group_av);
return -1;
}
const int numpeers = group_number_peers(g_c, groupnumber, false);
const int numpeers = group_number_peers(g_c, conference_number, false);
if (numpeers < 0) {
kill_group_av(group_av);
@ -477,7 +477,7 @@ int groupchat_enable_av(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t
}
for (uint32_t i = 0; i < numpeers; ++i) {
group_av_peer_new(group_av, groupnumber, i);
group_av_peer_new(group_av, conference_number, i);
}
group_lossy_packet_registerhandler(g_c, GROUP_AUDIO_PACKET_ID, &handle_group_audio_packet);
@ -489,19 +489,19 @@ int groupchat_enable_av(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t
* @retval 0 on success.
* @retval -1 on failure.
*/
int groupchat_disable_av(const Group_Chats *g_c, uint32_t groupnumber)
int groupchat_disable_av(const Group_Chats *g_c, uint32_t conference_number)
{
if (group_get_type(g_c, groupnumber) != GROUPCHAT_TYPE_AV) {
if (group_get_type(g_c, conference_number) != GROUPCHAT_TYPE_AV) {
return -1;
}
Group_AV *group_av = (Group_AV *)group_get_object(g_c, groupnumber);
Group_AV *group_av = (Group_AV *)group_get_object(g_c, conference_number);
if (group_av == nullptr) {
return -1;
}
const int numpeers = group_number_peers(g_c, groupnumber, false);
const int numpeers = group_number_peers(g_c, conference_number, false);
if (numpeers < 0) {
kill_group_av(group_av);
@ -509,16 +509,16 @@ int groupchat_disable_av(const Group_Chats *g_c, uint32_t groupnumber)
}
for (uint32_t i = 0; i < numpeers; ++i) {
group_av_peer_delete(group_av, groupnumber, group_peer_get_object(g_c, groupnumber, i));
group_peer_set_object(g_c, groupnumber, i, nullptr);
group_av_peer_delete(group_av, conference_number, group_peer_get_object(g_c, conference_number, i));
group_peer_set_object(g_c, conference_number, i, nullptr);
}
kill_group_av(group_av);
if (group_set_object(g_c, groupnumber, nullptr) == -1
|| callback_groupchat_peer_new(g_c, groupnumber, nullptr) == -1
|| callback_groupchat_peer_delete(g_c, groupnumber, nullptr) == -1
|| callback_groupchat_delete(g_c, groupnumber, nullptr) == -1) {
if (group_set_object(g_c, conference_number, nullptr) == -1
|| callback_groupchat_peer_new(g_c, conference_number, nullptr) == -1
|| callback_groupchat_peer_delete(g_c, conference_number, nullptr) == -1
|| callback_groupchat_delete(g_c, conference_number, nullptr) == -1) {
return -1;
}
@ -526,9 +526,9 @@ int groupchat_disable_av(const Group_Chats *g_c, uint32_t groupnumber)
}
/** Return whether A/V is enabled in the groupchat. */
bool groupchat_av_enabled(const Group_Chats *g_c, uint32_t groupnumber)
bool groupchat_av_enabled(const Group_Chats *g_c, uint32_t conference_number)
{
return group_get_object(g_c, groupnumber) != nullptr;
return group_get_object(g_c, conference_number) != nullptr;
}
/** @brief Create and connect to a new toxav group.
@ -538,18 +538,18 @@ bool groupchat_av_enabled(const Group_Chats *g_c, uint32_t groupnumber)
*/
int add_av_groupchat(const Logger *log, Tox *tox, Group_Chats *g_c, audio_data_cb *audio_callback, void *userdata)
{
const int groupnumber = add_groupchat(g_c, tox->sys.rng, GROUPCHAT_TYPE_AV);
const int conference_number = add_groupchat(g_c, tox->sys.rng, GROUPCHAT_TYPE_AV);
if (groupnumber == -1) {
if (conference_number == -1) {
return -1;
}
if (groupchat_enable_av(log, tox, g_c, groupnumber, audio_callback, userdata) == -1) {
del_groupchat(g_c, groupnumber, true);
if (groupchat_enable_av(log, tox, g_c, conference_number, audio_callback, userdata) == -1) {
del_groupchat(g_c, conference_number, true);
return -1;
}
return groupnumber;
return conference_number;
}
/** @brief Join a AV group (you need to have been invited first).
@ -560,18 +560,18 @@ int add_av_groupchat(const Logger *log, Tox *tox, Group_Chats *g_c, audio_data_c
int join_av_groupchat(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t friendnumber, const uint8_t *data,
uint16_t length, audio_data_cb *audio_callback, void *userdata)
{
const int groupnumber = join_groupchat(g_c, friendnumber, GROUPCHAT_TYPE_AV, data, length);
const int conference_number = join_groupchat(g_c, friendnumber, GROUPCHAT_TYPE_AV, data, length);
if (groupnumber == -1) {
if (conference_number == -1) {
return -1;
}
if (groupchat_enable_av(log, tox, g_c, groupnumber, audio_callback, userdata) == -1) {
del_groupchat(g_c, groupnumber, true);
if (groupchat_enable_av(log, tox, g_c, conference_number, audio_callback, userdata) == -1) {
del_groupchat(g_c, conference_number, true);
return -1;
}
return groupnumber;
return conference_number;
}
/** @brief Send an encoded audio packet to the group chat.
@ -579,7 +579,7 @@ int join_av_groupchat(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t fr
* @retval 0 on success.
* @retval -1 on failure.
*/
static int send_audio_packet(const Group_Chats *g_c, uint32_t groupnumber, const uint8_t *packet, uint16_t length)
static int send_audio_packet(const Group_Chats *g_c, uint32_t conference_number, const uint8_t *packet, uint16_t length)
{
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE - 1 - sizeof(uint16_t)) {
return -1;
@ -587,7 +587,7 @@ static int send_audio_packet(const Group_Chats *g_c, uint32_t groupnumber, const
const uint16_t plen = 1 + sizeof(uint16_t) + length;
Group_AV *const group_av = (Group_AV *)group_get_object(g_c, groupnumber);
Group_AV *const group_av = (Group_AV *)group_get_object(g_c, conference_number);
if (group_av == nullptr) {
return -1;
@ -601,7 +601,7 @@ static int send_audio_packet(const Group_Chats *g_c, uint32_t groupnumber, const
ptr += net_pack_u16(ptr, group_av->audio_sequnum);
memcpy(ptr, packet, length);
if (send_group_lossy_packet(g_c, groupnumber, data, plen) == -1) {
if (send_group_lossy_packet(g_c, conference_number, data, plen) == -1) {
return -1;
}
@ -614,10 +614,10 @@ static int send_audio_packet(const Group_Chats *g_c, uint32_t groupnumber, const
* @retval 0 on success.
* @retval -1 on failure.
*/
int group_send_audio(const Group_Chats *g_c, uint32_t groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels,
int group_send_audio(const Group_Chats *g_c, uint32_t conference_number, const int16_t *pcm, unsigned int samples, uint8_t channels,
uint32_t sample_rate)
{
Group_AV *group_av = (Group_AV *)group_get_object(g_c, groupnumber);
Group_AV *group_av = (Group_AV *)group_get_object(g_c, conference_number);
if (group_av == nullptr) {
return -1;
@ -655,5 +655,5 @@ int group_send_audio(const Group_Chats *g_c, uint32_t groupnumber, const int16_t
return -1;
}
return send_audio_packet(g_c, groupnumber, encoded, size);
return send_audio_packet(g_c, conference_number, encoded, size);
}

View File

@ -14,9 +14,9 @@
#define GROUP_AUDIO_PACKET_ID 192
// TODO(iphydf): Use this better typed one instead of the void-pointer one below.
// typedef void audio_data_cb(Tox *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t *pcm,
// typedef void audio_data_cb(Tox *tox, uint32_t conference_number, uint32_t peernumber, const int16_t *pcm,
// uint32_t samples, uint8_t channels, uint32_t sample_rate, void *userdata);
typedef void audio_data_cb(void *tox, uint32_t groupnumber, uint32_t peernumber, const int16_t *pcm,
typedef void audio_data_cb(void *tox, uint32_t conference_number, uint32_t peernumber, const int16_t *pcm,
uint32_t samples, uint8_t channels, uint32_t sample_rate, void *userdata);
/** @brief Create and connect to a new toxav group.
@ -40,7 +40,7 @@ int join_av_groupchat(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t fr
* @retval 0 on success.
* @retval -1 on failure.
*/
int group_send_audio(const Group_Chats *g_c, uint32_t groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels,
int group_send_audio(const Group_Chats *g_c, uint32_t conference_number, const int16_t *pcm, unsigned int samples, uint8_t channels,
uint32_t sample_rate);
/** @brief Enable A/V in a groupchat.
@ -48,7 +48,7 @@ int group_send_audio(const Group_Chats *g_c, uint32_t groupnumber, const int16_t
* @retval 0 on success.
* @retval -1 on failure.
*/
int groupchat_enable_av(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t groupnumber,
int groupchat_enable_av(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t conference_number,
audio_data_cb *audio_callback, void *userdata);
/** @brief Disable A/V in a groupchat.
@ -56,9 +56,9 @@ int groupchat_enable_av(const Logger *log, Tox *tox, Group_Chats *g_c, uint32_t
* @retval 0 on success.
* @retval -1 on failure.
*/
int groupchat_disable_av(const Group_Chats *g_c, uint32_t groupnumber);
int groupchat_disable_av(const Group_Chats *g_c, uint32_t conference_number);
/** Return whether A/V is enabled in the groupchat. */
bool groupchat_av_enabled(const Group_Chats *g_c, uint32_t groupnumber);
bool groupchat_av_enabled(const Group_Chats *g_c, uint32_t conference_number);
#endif // C_TOXCORE_TOXAV_GROUPAV_H

View File

@ -68,11 +68,11 @@ static bool invoke_callback(MSICall *call, MSICallbackID cb);
static MSICall *get_call(MSISession *session, uint32_t friend_number);
static MSICall *new_call(MSISession *session, uint32_t friend_number);
static void kill_call(MSICall *call);
static void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void *data);
static void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t connection_status, void *user_data);
static void handle_init(MSICall *call, const MSIMessage *msg);
static void handle_push(MSICall *call, const MSIMessage *msg);
static void handle_pop(MSICall *call, const MSIMessage *msg);
static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object);
static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *user_data);
/*
@ -655,11 +655,11 @@ CLEAR_CONTAINER:
free(call);
session->calls = nullptr;
}
static void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void *data)
static void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t connection_status, void *user_data)
{
MSISession *session = (MSISession *)data;
MSISession *session = (MSISession *)user_data;
if (status != 0) {
if (connection_status != 0) {
// Friend is online.
return;
}
@ -850,9 +850,9 @@ static void handle_pop(MSICall *call, const MSIMessage *msg)
kill_call(call);
}
static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object)
static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *user_data)
{
MSISession *session = (MSISession *)object;
MSISession *session = (MSISession *)user_data;
LOGGER_DEBUG(m->log, "Got msi message");

View File

@ -86,7 +86,7 @@ typedef struct MSICall {
* returned the call is considered errored and will be handled
* as such which means it will be terminated without any notice.
*/
typedef int msi_action_cb(void *av, MSICall *call);
typedef int msi_action_cb(void *object, MSICall *call);
/**
* Control session struct. Please do not modify outside msi.c

View File

@ -440,7 +440,7 @@ static int handle_video_packet(RTPSession *session, const struct RTPHeader *head
* @retval -1 on error.
* @retval 0 on success.
*/
static int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length, void *object)
static int handle_rtp_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object)
{
RTPSession *session = (RTPSession *)object;

View File

@ -118,11 +118,11 @@ struct ToxAV {
static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss, void *user_data);
static int callback_invite(void *toxav_inst, MSICall *call);
static int callback_start(void *toxav_inst, MSICall *call);
static int callback_end(void *toxav_inst, MSICall *call);
static int callback_error(void *toxav_inst, MSICall *call);
static int callback_capabilites(void *toxav_inst, MSICall *call);
static int callback_invite(void *object, MSICall *call);
static int callback_start(void *object, MSICall *call);
static int callback_end(void *object, MSICall *call);
static int callback_error(void *object, MSICall *call);
static int callback_capabilites(void *object, MSICall *call);
static bool audio_bit_rate_invalid(uint32_t bit_rate);
static bool video_bit_rate_invalid(uint32_t bit_rate);
@ -1095,9 +1095,9 @@ static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss,
pthread_mutex_unlock(call->av->mutex);
}
static int callback_invite(void *toxav_inst, MSICall *call)
static int callback_invite(void *object, MSICall *call)
{
ToxAV *toxav = (ToxAV *)toxav_inst;
ToxAV *toxav = (ToxAV *)object;
pthread_mutex_lock(toxav->mutex);
ToxAVCall *av_call = call_new(toxav, call->friend_number, nullptr);
@ -1123,9 +1123,9 @@ static int callback_invite(void *toxav_inst, MSICall *call)
pthread_mutex_unlock(toxav->mutex);
return 0;
}
static int callback_start(void *toxav_inst, MSICall *call)
static int callback_start(void *object, MSICall *call)
{
ToxAV *toxav = (ToxAV *)toxav_inst;
ToxAV *toxav = (ToxAV *)object;
pthread_mutex_lock(toxav->mutex);
ToxAVCall *av_call = call_get(toxav, call->friend_number);
@ -1137,13 +1137,13 @@ static int callback_start(void *toxav_inst, MSICall *call)
}
if (!call_prepare_transmission(av_call)) {
callback_error(toxav_inst, call);
callback_error(toxav, call);
pthread_mutex_unlock(toxav->mutex);
return -1;
}
if (!invoke_call_state_callback(toxav, call->friend_number, call->peer_capabilities)) {
callback_error(toxav_inst, call);
callback_error(toxav, call);
pthread_mutex_unlock(toxav->mutex);
return -1;
}
@ -1151,9 +1151,9 @@ static int callback_start(void *toxav_inst, MSICall *call)
pthread_mutex_unlock(toxav->mutex);
return 0;
}
static int callback_end(void *toxav_inst, MSICall *call)
static int callback_end(void *object, MSICall *call)
{
ToxAV *toxav = (ToxAV *)toxav_inst;
ToxAV *toxav = (ToxAV *)object;
pthread_mutex_lock(toxav->mutex);
invoke_call_state_callback(toxav, call->friend_number, TOXAV_FRIEND_CALL_STATE_FINISHED);
@ -1166,9 +1166,9 @@ static int callback_end(void *toxav_inst, MSICall *call)
pthread_mutex_unlock(toxav->mutex);
return 0;
}
static int callback_error(void *toxav_inst, MSICall *call)
static int callback_error(void *object, MSICall *call)
{
ToxAV *toxav = (ToxAV *)toxav_inst;
ToxAV *toxav = (ToxAV *)object;
pthread_mutex_lock(toxav->mutex);
invoke_call_state_callback(toxav, call->friend_number, TOXAV_FRIEND_CALL_STATE_ERROR);
@ -1181,9 +1181,9 @@ static int callback_error(void *toxav_inst, MSICall *call)
pthread_mutex_unlock(toxav->mutex);
return 0;
}
static int callback_capabilites(void *toxav_inst, MSICall *call)
static int callback_capabilites(void *object, MSICall *call)
{
ToxAV *toxav = (ToxAV *)toxav_inst;
ToxAV *toxav = (ToxAV *)object;
pthread_mutex_lock(toxav->mutex);
if ((call->peer_capabilities & MSI_CAP_S_AUDIO) != 0) {

View File

@ -343,9 +343,9 @@ void vc_iterate(VCSession *vc)
}
}
int vc_queue_message(Mono_Time *mono_time, void *vcp, struct RTPMessage *msg)
int vc_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg)
{
VCSession *vc = (VCSession *)vcp;
VCSession *vc = (VCSession *)cs;
/* This function is called with complete messages
* they have already been assembled.

View File

@ -48,7 +48,7 @@ VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t f
toxav_video_receive_frame_cb *cb, void *cb_data);
void vc_kill(VCSession *vc);
void vc_iterate(VCSession *vc);
int vc_queue_message(Mono_Time *mono_time, void *vcp, struct RTPMessage *msg);
int vc_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height, int16_t kf_max_dist);
#endif // C_TOXCORE_TOXAV_VIDEO_H

View File

@ -257,8 +257,8 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed
/*----------------------------------------------------------------------------------*/
typedef int cryptopacket_handler_cb(void *object, const IP_Port *ip_port, const uint8_t *source_pubkey,
const uint8_t *data, uint16_t len, void *userdata);
typedef int cryptopacket_handler_cb(void *object, const IP_Port *source, const uint8_t *source_pubkey,
const uint8_t *packet, uint16_t length, void *userdata);
typedef struct DHT DHT;

View File

@ -152,11 +152,11 @@ static bool send_offline_packet(Messenger *m, int friendcon_id)
}
non_null(1) nullable(4)
static int m_handle_status(void *object, int i, bool status, void *userdata);
static int m_handle_status(void *object, int friendcon_id, bool status, void *userdata);
non_null(1, 3) nullable(5)
static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t len, void *userdata);
static int m_handle_packet(void *object, int friendcon_id, const uint8_t *data, uint16_t length, void *userdata);
non_null(1, 3) nullable(5)
static int m_handle_lossy_packet(void *object, int friend_num, const uint8_t *packet, uint16_t length,
static int m_handle_lossy_packet(void *object, int friendcon_id, const uint8_t *data, uint16_t length,
void *userdata);
non_null()
@ -1125,9 +1125,9 @@ bool send_conference_invite_packet(const Messenger *m, int32_t friendnumber, con
*
* @retval true if success
*/
bool send_group_invite_packet(const Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length)
bool send_group_invite_packet(const Messenger *m, uint32_t friendnumber, const uint8_t *packet, uint16_t length)
{
return write_cryptpacket_id(m, friendnumber, PACKET_ID_INVITE_GROUPCHAT, data, length, false);
return write_cryptpacket_id(m, friendnumber, PACKET_ID_INVITE_GROUPCHAT, packet, length, false);
}
@ -1873,28 +1873,28 @@ bool m_msi_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data,
return write_cryptpacket_id(m, friendnumber, PACKET_ID_MSI, data, length, false);
}
static int m_handle_lossy_packet(void *object, int friend_num, const uint8_t *packet, uint16_t length,
static int m_handle_lossy_packet(void *object, int friendcon_id, const uint8_t *data, uint16_t length,
void *userdata)
{
Messenger *m = (Messenger *)object;
if (!m_friend_exists(m, friend_num)) {
if (!m_friend_exists(m, friendcon_id)) {
return 1;
}
if (packet[0] <= PACKET_ID_RANGE_LOSSY_AV_END) {
if (data[0] <= PACKET_ID_RANGE_LOSSY_AV_END) {
const RTP_Packet_Handler *const ph =
&m->friendlist[friend_num].lossy_rtp_packethandlers[packet[0] % PACKET_ID_RANGE_LOSSY_AV_SIZE];
&m->friendlist[friendcon_id].lossy_rtp_packethandlers[data[0] % PACKET_ID_RANGE_LOSSY_AV_SIZE];
if (ph->function != nullptr) {
return ph->function(m, friend_num, packet, length, ph->object);
return ph->function(m, friendcon_id, data, length, ph->object);
}
return 1;
}
if (m->lossy_packethandler != nullptr) {
m->lossy_packethandler(m, friend_num, packet[0], packet, length, userdata);
m->lossy_packethandler(m, friendcon_id, data[0], data, length, userdata);
}
return 1;
@ -2020,11 +2020,11 @@ int send_custom_lossless_packet(const Messenger *m, int32_t friendnumber, const
/** Function to filter out some friend requests*/
non_null()
static int friend_already_added(const uint8_t *real_pk, void *data)
static int friend_already_added(void *object, const uint8_t *public_key)
{
const Messenger *m = (const Messenger *)data;
const Messenger *m = (const Messenger *)object;
if (getfriend_id(m, real_pk) == -1) {
if (getfriend_id(m, public_key) == -1) {
return 0;
}
@ -2034,16 +2034,16 @@ static int friend_already_added(const uint8_t *real_pk, void *data)
/** @brief Check for and handle a timed-out friend request.
*
* If the request has timed-out then the friend status is set back to FRIEND_ADDED.
* @param i friendlist index of the timed-out friend
* @param friendcon_id friendlist index of the timed-out friend
* @param t time
*/
non_null(1) nullable(4)
static void check_friend_request_timed_out(Messenger *m, uint32_t i, uint64_t t, void *userdata)
static void check_friend_request_timed_out(Messenger *m, uint32_t friendcon_id, uint64_t t, void *userdata)
{
Friend *f = &m->friendlist[i];
Friend *f = &m->friendlist[friendcon_id];
if (f->friendrequest_lastsent + f->friendrequest_timeout < t) {
set_friend_status(m, i, FRIEND_ADDED, userdata);
set_friend_status(m, friendcon_id, FRIEND_ADDED, userdata);
/* Double the default timeout every time if friendrequest is assumed
* to have been sent unsuccessfully.
*/
@ -2052,15 +2052,15 @@ static void check_friend_request_timed_out(Messenger *m, uint32_t i, uint64_t t,
}
non_null(1) nullable(4)
static int m_handle_status(void *object, int i, bool status, void *userdata)
static int m_handle_status(void *object, int friendcon_id, bool status, void *userdata)
{
Messenger *m = (Messenger *)object;
if (status) { /* Went online. */
send_online_packet(m, m->friendlist[i].friendcon_id);
send_online_packet(m, m->friendlist[friendcon_id].friendcon_id);
} else { /* Went offline. */
if (m->friendlist[i].status == FRIEND_ONLINE) {
set_friend_status(m, i, FRIEND_CONFIRMED, userdata);
if (m->friendlist[friendcon_id].status == FRIEND_ONLINE) {
set_friend_status(m, friendcon_id, FRIEND_CONFIRMED, userdata);
}
}
@ -2068,17 +2068,17 @@ static int m_handle_status(void *object, int i, bool status, void *userdata)
}
non_null(1, 3) nullable(5)
static int m_handle_packet_offline(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
static int m_handle_packet_offline(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
if (data_length == 0) {
set_friend_status(m, i, FRIEND_CONFIRMED, userdata);
set_friend_status(m, friendcon_id, FRIEND_CONFIRMED, userdata);
}
return 0;
}
non_null(1, 3) nullable(5)
static int m_handle_packet_nickname(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
static int m_handle_packet_nickname(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
if (data_length > MAX_NAME_LENGTH) {
return 0;
@ -2091,17 +2091,17 @@ static int m_handle_packet_nickname(Messenger *m, const int i, const uint8_t *da
/* inform of namechange before we overwrite the old name */
if (m->friend_namechange != nullptr) {
m->friend_namechange(m, i, data_terminated, data_length, userdata);
m->friend_namechange(m, friendcon_id, data_terminated, data_length, userdata);
}
memcpy(m->friendlist[i].name, data_terminated, data_length);
m->friendlist[i].name_length = data_length;
memcpy(m->friendlist[friendcon_id].name, data_terminated, data_length);
m->friendlist[friendcon_id].name_length = data_length;
return 0;
}
non_null(1, 3) nullable(5)
static int m_handle_packet_statusmessage(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
static int m_handle_packet_statusmessage(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
if (data_length > MAX_STATUSMESSAGE_LENGTH) {
return 0;
@ -2113,16 +2113,16 @@ static int m_handle_packet_statusmessage(Messenger *m, const int i, const uint8_
data_terminated[data_length] = 0;
if (m->friend_statusmessagechange != nullptr) {
m->friend_statusmessagechange(m, i, data_terminated, data_length, userdata);
m->friend_statusmessagechange(m, friendcon_id, data_terminated, data_length, userdata);
}
set_friend_statusmessage(m, i, data_terminated, data_length);
set_friend_statusmessage(m, friendcon_id, data_terminated, data_length);
return 0;
}
non_null(1, 3) nullable(5)
static int m_handle_packet_userstatus(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
static int m_handle_packet_userstatus(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
if (data_length != 1) {
return 0;
@ -2134,16 +2134,16 @@ static int m_handle_packet_userstatus(Messenger *m, const int i, const uint8_t *
}
if (m->friend_userstatuschange != nullptr) {
m->friend_userstatuschange(m, i, status, userdata);
m->friend_userstatuschange(m, friendcon_id, status, userdata);
}
set_friend_userstatus(m, i, status);
set_friend_userstatus(m, friendcon_id, status);
return 0;
}
non_null(1, 3) nullable(5)
static int m_handle_packet_typing(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
static int m_handle_packet_typing(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
if (data_length != 1) {
return 0;
@ -2151,17 +2151,17 @@ static int m_handle_packet_typing(Messenger *m, const int i, const uint8_t *data
const bool typing = data[0] != 0;
set_friend_typing(m, i, typing);
set_friend_typing(m, friendcon_id, typing);
if (m->friend_typingchange != nullptr) {
m->friend_typingchange(m, i, typing, userdata);
m->friend_typingchange(m, friendcon_id, typing, userdata);
}
return 0;
}
non_null(1, 3) nullable(6)
static int m_handle_packet_message(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, const Message_Type message_type, void *userdata)
static int m_handle_packet_message(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, const Message_Type message_type, void *userdata)
{
if (data_length == 0) {
return 0;
@ -2176,28 +2176,28 @@ static int m_handle_packet_message(Messenger *m, const int i, const uint8_t *dat
message_terminated[message_length] = 0;
if (m->friend_message != nullptr) {
m->friend_message(m, i, message_type, message_terminated, message_length, userdata);
m->friend_message(m, friendcon_id, message_type, message_terminated, message_length, userdata);
}
return 0;
}
non_null(1, 3) nullable(5)
static int m_handle_packet_invite_conference(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
static int m_handle_packet_invite_conference(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
if (data_length == 0) {
return 0;
}
if (m->conference_invite != nullptr) {
m->conference_invite(m, i, data, data_length, userdata);
m->conference_invite(m, friendcon_id, data, data_length, userdata);
}
return 0;
}
non_null(1, 3) nullable(5)
static int m_handle_packet_file_sendrequest(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
static int m_handle_packet_file_sendrequest(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
const unsigned int head_length = 1 + sizeof(uint32_t) + sizeof(uint64_t) + FILE_ID_LENGTH;
@ -2227,7 +2227,7 @@ static int m_handle_packet_file_sendrequest(Messenger *m, const int i, const uin
file_type = net_ntohl(file_type);
net_unpack_u64(data + 1 + sizeof(uint32_t), &filesize);
struct File_Transfers *ft = &m->friendlist[i].file_receiving[filenumber];
struct File_Transfers *ft = &m->friendlist[friendcon_id].file_receiving[filenumber];
if (ft->status != FILESTATUS_NONE) {
return 0;
@ -2254,7 +2254,7 @@ static int m_handle_packet_file_sendrequest(Messenger *m, const int i, const uin
real_filenumber <<= 16;
if (m->file_sendrequest != nullptr) {
m->file_sendrequest(m, i, real_filenumber, file_type, filesize, filename, filename_length,
m->file_sendrequest(m, friendcon_id, real_filenumber, file_type, filesize, filename, filename_length,
userdata);
}
@ -2262,7 +2262,7 @@ static int m_handle_packet_file_sendrequest(Messenger *m, const int i, const uin
}
non_null(1, 3) nullable(5)
static int m_handle_packet_file_control(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
static int m_handle_packet_file_control(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
if (data_length < 3) {
return 0;
@ -2283,7 +2283,7 @@ static int m_handle_packet_file_control(Messenger *m, const int i, const uint8_t
#endif
if (handle_filecontrol(m, i, outbound, filenumber, control_type, data + 3, data_length - 3, userdata) == -1) {
if (handle_filecontrol(m, friendcon_id, outbound, filenumber, control_type, data + 3, data_length - 3, userdata) == -1) {
// TODO(iphydf): Do something different here? Right now, this
// check is pointless.
return 0;
@ -2293,7 +2293,7 @@ static int m_handle_packet_file_control(Messenger *m, const int i, const uint8_t
}
non_null(1, 3) nullable(5)
static int m_handle_packet_file_data(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
static int m_handle_packet_file_data(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
if (data_length < 1) {
return 0;
@ -2309,7 +2309,7 @@ static int m_handle_packet_file_data(Messenger *m, const int i, const uint8_t *d
#endif
struct File_Transfers *ft = &m->friendlist[i].file_receiving[filenumber];
struct File_Transfers *ft = &m->friendlist[friendcon_id].file_receiving[filenumber];
if (ft->status != FILESTATUS_TRANSFERRING) {
return 0;
@ -2334,7 +2334,7 @@ static int m_handle_packet_file_data(Messenger *m, const int i, const uint8_t *d
}
if (m->file_filedata != nullptr) {
m->file_filedata(m, i, real_filenumber, position, file_data, file_data_length, userdata);
m->file_filedata(m, friendcon_id, real_filenumber, position, file_data, file_data_length, userdata);
}
ft->transferred += file_data_length;
@ -2346,7 +2346,7 @@ static int m_handle_packet_file_data(Messenger *m, const int i, const uint8_t *d
/* Full file received. */
if (m->file_filedata != nullptr) {
m->file_filedata(m, i, real_filenumber, position, file_data, file_data_length, userdata);
m->file_filedata(m, friendcon_id, real_filenumber, position, file_data, file_data_length, userdata);
}
}
@ -2359,21 +2359,21 @@ static int m_handle_packet_file_data(Messenger *m, const int i, const uint8_t *d
}
non_null(1, 3) nullable(5)
static int m_handle_packet_msi(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
static int m_handle_packet_msi(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
if (data_length == 0) {
return 0;
}
if (m->msi_packet != nullptr) {
m->msi_packet(m, i, data, data_length, m->msi_packet_userdata);
m->msi_packet(m, friendcon_id, data, data_length, m->msi_packet_userdata);
}
return 0;
}
non_null(1, 3) nullable(5)
static int m_handle_packet_invite_groupchat(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
static int m_handle_packet_invite_groupchat(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
// first two bytes are messenger packet type and group invite type
if (data_length < 2 + GC_JOIN_DATA_LENGTH) {
@ -2386,35 +2386,35 @@ static int m_handle_packet_invite_groupchat(Messenger *m, const int i, const uin
if (m->group_invite != nullptr && data[1] == GROUP_INVITE && data_length != 2 + GC_JOIN_DATA_LENGTH) {
if (group_not_added(m->group_handler, join_data, join_data_len)) {
m->group_invite(m, i, join_data, GC_JOIN_DATA_LENGTH,
m->group_invite(m, friendcon_id, join_data, GC_JOIN_DATA_LENGTH,
join_data + GC_JOIN_DATA_LENGTH, join_data_len - GC_JOIN_DATA_LENGTH, userdata);
}
} else if (invite_type == GROUP_INVITE_ACCEPTED) {
handle_gc_invite_accepted_packet(m->group_handler, i, join_data, join_data_len);
handle_gc_invite_accepted_packet(m->group_handler, friendcon_id, join_data, join_data_len);
} else if (invite_type == GROUP_INVITE_CONFIRMATION) {
handle_gc_invite_confirmed_packet(m->group_handler, i, join_data, join_data_len);
handle_gc_invite_confirmed_packet(m->group_handler, friendcon_id, join_data, join_data_len);
}
return 0;
}
non_null(1, 3) nullable(5)
static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t len, void *userdata)
static int m_handle_packet(void *object, int friendcon_id, const uint8_t *data, uint16_t length, void *userdata)
{
Messenger *m = (Messenger *)object;
if (len == 0) {
if (length == 0) {
return -1;
}
const uint8_t packet_id = temp[0];
const uint8_t *data = temp + 1;
const uint16_t data_length = len - 1;
const uint8_t packet_id = data[0];
const uint8_t *payload = data + 1;
const uint16_t payload_length = length - 1;
if (m->friendlist[i].status != FRIEND_ONLINE) {
if (packet_id == PACKET_ID_ONLINE && len == 1) {
set_friend_status(m, i, FRIEND_ONLINE, userdata);
send_online_packet(m, m->friendlist[i].friendcon_id);
if (m->friendlist[friendcon_id].status != FRIEND_ONLINE) {
if (packet_id == PACKET_ID_ONLINE && length == 1) {
set_friend_status(m, friendcon_id, FRIEND_ONLINE, userdata);
send_online_packet(m, m->friendlist[friendcon_id].friendcon_id);
} else {
return -1;
}
@ -2423,34 +2423,34 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
switch (packet_id) {
// TODO(Green-Sky): now all return 0 on error AND success, make errors errors?
case PACKET_ID_OFFLINE:
return m_handle_packet_offline(m, i, data, data_length, userdata);
return m_handle_packet_offline(m, friendcon_id, payload, payload_length, userdata);
case PACKET_ID_NICKNAME:
return m_handle_packet_nickname(m, i, data, data_length, userdata);
return m_handle_packet_nickname(m, friendcon_id, payload, payload_length, userdata);
case PACKET_ID_STATUSMESSAGE:
return m_handle_packet_statusmessage(m, i, data, data_length, userdata);
return m_handle_packet_statusmessage(m, friendcon_id, payload, payload_length, userdata);
case PACKET_ID_USERSTATUS:
return m_handle_packet_userstatus(m, i, data, data_length, userdata);
return m_handle_packet_userstatus(m, friendcon_id, payload, payload_length, userdata);
case PACKET_ID_TYPING:
return m_handle_packet_typing(m, i, data, data_length, userdata);
return m_handle_packet_typing(m, friendcon_id, payload, payload_length, userdata);
case PACKET_ID_MESSAGE:
return m_handle_packet_message(m, i, data, data_length, MESSAGE_NORMAL, userdata);
return m_handle_packet_message(m, friendcon_id, payload, payload_length, MESSAGE_NORMAL, userdata);
case PACKET_ID_ACTION:
return m_handle_packet_message(m, i, data, data_length, MESSAGE_ACTION, userdata);
return m_handle_packet_message(m, friendcon_id, payload, payload_length, MESSAGE_ACTION, userdata);
case PACKET_ID_INVITE_CONFERENCE:
return m_handle_packet_invite_conference(m, i, data, data_length, userdata);
return m_handle_packet_invite_conference(m, friendcon_id, payload, payload_length, userdata);
case PACKET_ID_FILE_SENDREQUEST:
return m_handle_packet_file_sendrequest(m, i, data, data_length, userdata);
return m_handle_packet_file_sendrequest(m, friendcon_id, payload, payload_length, userdata);
case PACKET_ID_FILE_CONTROL:
return m_handle_packet_file_control(m, i, data, data_length, userdata);
return m_handle_packet_file_control(m, friendcon_id, payload, payload_length, userdata);
case PACKET_ID_FILE_DATA:
return m_handle_packet_file_data(m, i, data, data_length, userdata);
return m_handle_packet_file_data(m, friendcon_id, payload, payload_length, userdata);
case PACKET_ID_MSI:
return m_handle_packet_msi(m, i, data, data_length, userdata);
return m_handle_packet_msi(m, friendcon_id, payload, payload_length, userdata);
case PACKET_ID_INVITE_GROUPCHAT:
return m_handle_packet_invite_groupchat(m, i, data, data_length, userdata);
return m_handle_packet_invite_groupchat(m, friendcon_id, payload, payload_length, userdata);
}
return handle_custom_lossless_packet(object, i, temp, len, userdata);
return handle_custom_lossless_packet(object, friendcon_id, data, length, userdata);
}
non_null(1) nullable(2)
@ -3191,7 +3191,7 @@ static void pack_groupchats(const GC_Session *c, Bin_Pack *bp)
}
non_null()
static bool pack_groupchats_handler(const void *obj, const Logger *log, Bin_Pack *bp)
static bool pack_groupchats_handler(const void *obj, const Logger *logger, Bin_Pack *bp)
{
const GC_Session *session = (const GC_Session *)obj;
pack_groupchats(session, bp);

View File

@ -197,11 +197,11 @@ typedef void m_friend_connectionstatuschange_internal_cb(Messenger *m, uint32_t
uint8_t connection_status, void *user_data);
typedef void m_conference_invite_cb(Messenger *m, uint32_t friend_number, const uint8_t *cookie, uint16_t length,
void *user_data);
typedef void m_group_invite_cb(const Messenger *m, uint32_t friendnumber, const uint8_t *data, size_t length,
const uint8_t *group_name, size_t group_name_length, void *userdata);
typedef void m_group_invite_cb(const Messenger *m, 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);
typedef void m_msi_packet_cb(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length,
void *user_data);
typedef int m_lossy_rtp_packet_cb(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t len, void *object);
typedef int m_lossy_rtp_packet_cb(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object);
typedef struct RTP_Packet_Handler {
m_lossy_rtp_packet_cb *function;
@ -646,7 +646,7 @@ bool send_conference_invite_packet(const Messenger *m, int32_t friendnumber, con
* return true on success
*/
non_null()
bool send_group_invite_packet(const Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length);
bool send_group_invite_packet(const Messenger *m, uint32_t friendnumber, const uint8_t *packet, uint16_t length);
/*** FILE SENDING */

View File

@ -156,7 +156,7 @@ non_null()
int tcp_send_oob_packet(const TCP_Connections *tcp_c, unsigned int tcp_connections_number, const uint8_t *public_key,
const uint8_t *packet, uint16_t length);
typedef int tcp_data_cb(void *object, int id, const uint8_t *data, uint16_t length, void *userdata);
typedef int tcp_data_cb(void *object, int crypt_connection_id, const uint8_t *packet, uint16_t length, void *userdata);
non_null()
int tcp_send_oob_packet_using_relay(const TCP_Connections *tcp_c, const uint8_t *relay_pk, const uint8_t *public_key,
@ -180,7 +180,7 @@ void set_forwarding_packet_tcp_connection_callback(TCP_Connections *tcp_c,
typedef int tcp_oob_cb(void *object, const uint8_t *public_key, unsigned int tcp_connections_number,
const uint8_t *data, uint16_t length, void *userdata);
const uint8_t *packet, uint16_t length, void *userdata);
/** @brief Set the callback for TCP oob data packets. */
non_null()

View File

@ -629,16 +629,15 @@ static void forwarded_request_callback(void *object, const IP_Port *forwarder,
}
non_null(1, 2, 3) nullable(5)
static int handle_dht_announce_request(void *object, const IP_Port *source,
const uint8_t *data, uint16_t length, void *userdata)
static int handle_dht_announce_request(
void *object, const IP_Port *source, const uint8_t *packet, uint16_t length, void *userdata)
{
Announcements *announce = (Announcements *) object;
Announcements *announce = (Announcements *)object;
uint8_t reply[MAX_FORWARD_DATA_SIZE];
const int len = create_reply(announce, source,
nullptr, 0,
data, length, reply, sizeof(reply));
const int len
= create_reply(announce, source, nullptr, 0, packet, length, reply, sizeof(reply));
if (len == -1) {
return -1;

View File

@ -26,18 +26,18 @@ static bool null_reader(cmp_ctx_t *ctx, void *data, size_t limit)
}
non_null()
static bool null_skipper(cmp_ctx_t *ctx, size_t limit)
static bool null_skipper(cmp_ctx_t *ctx, size_t count)
{
assert(limit == 0);
assert(count == 0);
return false;
}
non_null()
static size_t buf_writer(cmp_ctx_t *ctx, const void *data, size_t data_size)
static size_t buf_writer(cmp_ctx_t *ctx, const void *data, size_t count)
{
Bin_Pack *bp = (Bin_Pack *)ctx->buf;
assert(bp != nullptr);
const uint32_t new_pos = bp->bytes_pos + data_size;
const uint32_t new_pos = bp->bytes_pos + count;
if (new_pos < bp->bytes_pos) {
// 32 bit overflow.
return 0;
@ -47,10 +47,10 @@ static size_t buf_writer(cmp_ctx_t *ctx, const void *data, size_t data_size)
// Buffer too small.
return 0;
}
memcpy(&bp->bytes[bp->bytes_pos], data, data_size);
memcpy(&bp->bytes[bp->bytes_pos], data, count);
}
bp->bytes_pos += data_size;
return data_size;
bp->bytes_pos += count;
return count;
}
non_null(1) nullable(2)

View File

@ -32,15 +32,15 @@ static bool buf_reader(cmp_ctx_t *ctx, void *data, size_t limit)
}
non_null()
static bool buf_skipper(cmp_ctx_t *ctx, size_t limit)
static bool buf_skipper(cmp_ctx_t *ctx, size_t count)
{
Bin_Unpack *reader = (Bin_Unpack *)ctx->buf;
assert(reader != nullptr && reader->bytes != nullptr);
if (limit > reader->bytes_size) {
if (count > reader->bytes_size) {
return false;
}
reader->bytes += limit;
reader->bytes_size -= limit;
reader->bytes += count;
reader->bytes_size -= count;
return true;
}

View File

@ -397,10 +397,10 @@ static void change_dht_pk(Friend_Connections *fr_c, int friendcon_id, const uint
}
non_null()
static int handle_status(void *object, int number, bool status, void *userdata)
static int handle_status(void *object, int id, bool status, void *userdata)
{
Friend_Connections *const fr_c = (Friend_Connections *)object;
Friend_Conn *const friend_con = get_conn(fr_c, number);
Friend_Conn *const friend_con = get_conn(fr_c, id);
if (friend_con == nullptr) {
return -1;
@ -428,7 +428,7 @@ static int handle_status(void *object, int number, bool status, void *userdata)
if (status_changed) {
if (fr_c->global_status_callback != nullptr) {
fr_c->global_status_callback(fr_c->global_status_callback_object, number, status, userdata);
fr_c->global_status_callback(fr_c->global_status_callback_object, id, status, userdata);
}
for (unsigned i = 0; i < MAX_FRIEND_CONNECTION_CALLBACKS; ++i) {
@ -472,7 +472,7 @@ static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_pub
}
non_null()
static int handle_packet(void *object, int number, const uint8_t *data, uint16_t length, void *userdata)
static int handle_packet(void *object, int id, const uint8_t *data, uint16_t length, void *userdata)
{
Friend_Connections *const fr_c = (Friend_Connections *)object;
@ -480,7 +480,7 @@ static int handle_packet(void *object, int number, const uint8_t *data, uint16_t
return -1;
}
Friend_Conn *friend_con = get_conn(fr_c, number);
Friend_Conn *friend_con = get_conn(fr_c, id);
if (friend_con == nullptr) {
return -1;
@ -508,7 +508,7 @@ static int handle_packet(void *object, int number, const uint8_t *data, uint16_t
}
for (int j = 0; j < n; ++j) {
friend_add_tcp_relay(fr_c, number, &nodes[j].ip_port, nodes[j].public_key);
friend_add_tcp_relay(fr_c, id, &nodes[j].ip_port, nodes[j].public_key);
}
return 0;
@ -521,7 +521,7 @@ static int handle_packet(void *object, int number, const uint8_t *data, uint16_t
friend_con->callbacks[i].callback_id, data, length, userdata);
}
friend_con = get_conn(fr_c, number);
friend_con = get_conn(fr_c, id);
if (friend_con == nullptr) {
return -1;
@ -532,7 +532,7 @@ static int handle_packet(void *object, int number, const uint8_t *data, uint16_t
}
non_null()
static int handle_lossy_packet(void *object, int number, const uint8_t *data, uint16_t length, void *userdata)
static int handle_lossy_packet(void *object, int id, const uint8_t *data, uint16_t length, void *userdata)
{
const Friend_Connections *const fr_c = (const Friend_Connections *)object;
@ -540,7 +540,7 @@ static int handle_lossy_packet(void *object, int number, const uint8_t *data, ui
return -1;
}
const Friend_Conn *friend_con = get_conn(fr_c, number);
const Friend_Conn *friend_con = get_conn(fr_c, id);
if (friend_con == nullptr) {
return -1;
@ -553,7 +553,7 @@ static int handle_lossy_packet(void *object, int number, const uint8_t *data, ui
friend_con->callbacks[i].callback_id, data, length, userdata);
}
friend_con = get_conn(fr_c, number);
friend_con = get_conn(fr_c, id);
if (friend_con == nullptr) {
return -1;

View File

@ -84,11 +84,11 @@ int get_friendcon_public_keys(uint8_t *real_pk, uint8_t *dht_temp_pk, const Frie
non_null()
void set_dht_temp_pk(Friend_Connections *fr_c, int friendcon_id, const uint8_t *dht_temp_pk, void *userdata);
typedef int global_status_cb(void *object, int id, bool status, void *userdata);
typedef int global_status_cb(void *object, int friendcon_id, bool status, void *userdata);
typedef int fc_status_cb(void *object, int id, bool status, void *userdata);
typedef int fc_data_cb(void *object, int id, const uint8_t *data, uint16_t length, void *userdata);
typedef int fc_lossy_data_cb(void *object, int id, const uint8_t *data, uint16_t length, void *userdata);
typedef int fc_status_cb(void *object, int friendcon_id, bool status, void *userdata);
typedef int fc_data_cb(void *object, int friendcon_id, const uint8_t *data, uint16_t length, void *userdata);
typedef int fc_lossy_data_cb(void *object, int friendcon_id, const uint8_t *data, uint16_t length, void *userdata);
/** Set global status callback for friend connections. */
non_null(1) nullable(2, 3)
@ -144,7 +144,7 @@ int send_friend_request_packet(
Friend_Connections *fr_c, int friendcon_id, uint32_t nospam_num, const uint8_t *data, uint16_t length);
typedef int fr_request_cb(
void *object, const uint8_t *source_pubkey, const uint8_t *data, uint16_t len, void *userdata);
void *object, const uint8_t *source_pubkey, const uint8_t *data, uint16_t length, void *userdata);
/** @brief Set friend request callback.
*

View File

@ -116,7 +116,7 @@ int remove_request_received(Friend_Requests *fr, const uint8_t *real_pk)
non_null()
static int friendreq_handlepacket(void *object, const uint8_t *source_pubkey, const uint8_t *packet, uint16_t length,
static int friendreq_handlepacket(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint16_t length,
void *userdata)
{
Friend_Requests *const fr = (Friend_Requests *)object;
@ -125,7 +125,7 @@ static int friendreq_handlepacket(void *object, const uint8_t *source_pubkey, co
return 1;
}
++packet;
++data;
--length;
if (fr->handle_friendrequest_isset == 0) {
@ -136,12 +136,12 @@ static int friendreq_handlepacket(void *object, const uint8_t *source_pubkey, co
return 1;
}
if (memcmp(packet, &fr->nospam, sizeof(fr->nospam)) != 0) {
if (memcmp(data, &fr->nospam, sizeof(fr->nospam)) != 0) {
return 1;
}
if (fr->filter_function != nullptr) {
if (fr->filter_function(source_pubkey, fr->filter_function_userdata) != 0) {
if (fr->filter_function(fr->filter_function_userdata, source_pubkey) != 0) {
return 1;
}
}
@ -150,7 +150,7 @@ static int friendreq_handlepacket(void *object, const uint8_t *source_pubkey, co
const uint32_t message_len = length - sizeof(fr->nospam);
VLA(uint8_t, message, message_len + 1);
memcpy(message, packet + sizeof(fr->nospam), message_len);
memcpy(message, data + sizeof(fr->nospam), message_len);
message[SIZEOF_VLA(message) - 1] = 0; /* Be sure the message is null terminated. */
fr->handle_friendrequest(fr->handle_friendrequest_object, source_pubkey, message, message_len, userdata);

View File

@ -34,7 +34,7 @@ typedef void fr_friend_request_cb(void *object, const uint8_t *public_key, const
non_null()
void callback_friendrequest(Friend_Requests *fr, fr_friend_request_cb *function, void *object);
typedef int filter_function_cb(const uint8_t *public_key, void *user_data);
typedef int filter_function_cb(void *object, const uint8_t *public_key);
/** @brief Set the function used to check if a friend request should be displayed to the user or not.
* It must return 0 if the request is ok (anything else if it is bad).

View File

@ -2115,8 +2115,8 @@ static bool get_peer_number(const Group_c *g, const uint8_t *real_pk, uint16_t *
}
non_null(1, 3) nullable(5)
static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length,
void *userdata)
static void handle_friend_invite_packet(Messenger *m, uint32_t friend_number, const uint8_t *cookie, uint16_t length,
void *user_data)
{
Group_Chats *g_c = m->conferences_object;
@ -2124,20 +2124,20 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
return;
}
switch (data[0]) {
switch (cookie[0]) {
case INVITE_ID: {
if (length != INVITE_PACKET_SIZE) {
return;
}
const int groupnumber = get_group_num(g_c, data[1 + sizeof(uint16_t)], data + 1 + sizeof(uint16_t) + 1);
const int groupnumber = get_group_num(g_c, cookie[1 + sizeof(uint16_t)], cookie + 1 + sizeof(uint16_t) + 1);
const uint8_t *invite_data = data + 1;
const uint8_t *invite_data = cookie + 1;
const uint16_t invite_length = length - 1;
if (groupnumber == -1) {
if (g_c->invite_callback != nullptr) {
g_c->invite_callback(m, friendnumber, invite_data[sizeof(uint16_t)], invite_data, invite_length, userdata);
g_c->invite_callback(m, friend_number, invite_data[sizeof(uint16_t)], invite_data, invite_length, user_data);
}
return;
@ -2145,7 +2145,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
const Group_c *g = get_group_c(g_c, groupnumber);
if (g != nullptr && g->status == GROUPCHAT_STATUS_CONNECTED) {
send_invite_response(g_c, groupnumber, friendnumber, invite_data, invite_length);
send_invite_response(g_c, groupnumber, friend_number, invite_data, invite_length);
}
}
@ -2154,7 +2154,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
case INVITE_ACCEPT_ID:
case INVITE_MEMBER_ID: {
const bool member = data[0] == INVITE_MEMBER_ID;
const bool member = cookie[0] == INVITE_MEMBER_ID;
if (length != (member ? INVITE_MEMBER_PACKET_SIZE : INVITE_ACCEPT_PACKET_SIZE)) {
return;
@ -2162,8 +2162,8 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
uint16_t other_groupnum;
uint16_t groupnum;
net_unpack_u16(data + 1, &other_groupnum);
net_unpack_u16(data + 1 + sizeof(uint16_t), &groupnum);
net_unpack_u16(cookie + 1, &other_groupnum);
net_unpack_u16(cookie + 1 + sizeof(uint16_t), &groupnum);
Group_c *g = get_group_c(g_c, groupnum);
@ -2171,18 +2171,18 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
return;
}
if (data[1 + sizeof(uint16_t) * 2] != g->type) {
if (cookie[1 + sizeof(uint16_t) * 2] != g->type) {
return;
}
if (!group_id_eq(data + 1 + sizeof(uint16_t) * 2 + 1, g->id)) {
if (!group_id_eq(cookie + 1 + sizeof(uint16_t) * 2 + 1, g->id)) {
return;
}
uint16_t peer_number;
if (member) {
net_unpack_u16(data + 1 + sizeof(uint16_t) * 2 + 1 + GROUP_ID_LENGTH, &peer_number);
net_unpack_u16(cookie + 1 + sizeof(uint16_t) * 2 + 1 + GROUP_ID_LENGTH, &peer_number);
} else {
/* TODO(irungentoo): what if two people enter the group at the
* same time and are given the same peer_number by different
@ -2201,7 +2201,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
}
}
const int friendcon_id = getfriendcon_id(m, friendnumber);
const int friendcon_id = getfriendcon_id(m, friend_number);
if (friendcon_id == -1) {
// TODO(iphydf): Log something?
@ -2212,7 +2212,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con
uint8_t temp_pk[CRYPTO_PUBLIC_KEY_SIZE];
get_friendcon_public_keys(real_pk, temp_pk, g_c->fr_c, friendcon_id);
addpeer(g_c, groupnum, real_pk, temp_pk, peer_number, userdata, true, true);
addpeer(g_c, groupnum, real_pk, temp_pk, peer_number, user_data, true, true);
const int connection_index = add_conn_to_groupchat(g_c, friendcon_id, g,
GROUPCHAT_CONNECTION_REASON_INTRODUCING, true);

View File

@ -6357,7 +6357,7 @@ static bool group_can_handle_packets(const GC_Chat *chat)
*/
#define MIN_TCP_PACKET_SIZE (1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE)
non_null(1, 3) nullable(5)
static int handle_gc_tcp_packet(void *object, int id, const uint8_t *packet, uint16_t length, void *userdata)
static int handle_gc_tcp_packet(void *object, int crypt_connection_id, const uint8_t *packet, uint16_t length, void *userdata)
{
const Messenger *m = (Messenger *)object;
@ -6493,7 +6493,7 @@ static int handle_gc_tcp_oob_packet(void *object, const uint8_t *public_key, uns
#define MIN_UDP_PACKET_SIZE (1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE)
non_null(1, 2, 3) nullable(5)
static int handle_gc_udp_packet(void *object, const IP_Port *ipp, const uint8_t *packet, uint16_t length,
static int handle_gc_udp_packet(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length,
void *userdata)
{
const Messenger *m = (Messenger *)object;
@ -6558,7 +6558,7 @@ static int handle_gc_udp_packet(void *object, const IP_Port *ipp, const uint8_t
payload_len = payload_len - ENC_PUBLIC_KEY_SIZE;
payload = payload + ENC_PUBLIC_KEY_SIZE;
ret = handle_gc_handshake_packet(chat, sender_pk, ipp, payload, payload_len, true, userdata) != -1;
ret = handle_gc_handshake_packet(chat, sender_pk, source, payload, payload_len, true, userdata) != -1;
break;
}

View File

@ -329,33 +329,33 @@ typedef struct Messenger Messenger;
#endif /* MESSENGER_DEFINED */
typedef void gc_message_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id, unsigned int type,
const uint8_t *data, size_t length, uint32_t message_id, void *user_data);
const uint8_t *message, size_t length, uint32_t message_id, void *user_data);
typedef void gc_private_message_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id, unsigned int type,
const uint8_t *data, size_t length, void *user_data);
const uint8_t *message, size_t length, void *user_data);
typedef void gc_custom_packet_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id, const uint8_t *data,
size_t length, void *user_data);
typedef void gc_custom_private_packet_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id,
const uint8_t *data,
size_t length, void *user_data);
typedef void gc_moderation_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id, uint32_t target_peer,
unsigned int mod_event, void *user_data);
typedef void gc_nick_change_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id, const uint8_t *data,
const uint8_t *data, size_t length, void *user_data);
typedef void gc_moderation_cb(const Messenger *m, uint32_t group_number, uint32_t source_peer_number,
uint32_t target_peer_number, unsigned int mod_type, void *user_data);
typedef void gc_nick_change_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id, const uint8_t *name,
size_t length, void *user_data);
typedef void gc_status_change_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id, unsigned int status,
void *user_data);
typedef void gc_topic_change_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id, const uint8_t *data,
typedef void gc_topic_change_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id, const uint8_t *topic,
size_t length, void *user_data);
typedef void gc_topic_lock_cb(const Messenger *m, uint32_t group_number, unsigned int topic_lock, void *user_data);
typedef void gc_voice_state_cb(const Messenger *m, uint32_t group_number, unsigned int voice_state, void *user_data);
typedef void gc_peer_limit_cb(const Messenger *m, uint32_t group_number, uint32_t max_peers, void *user_data);
typedef void gc_privacy_state_cb(const Messenger *m, uint32_t group_number, unsigned int state, void *user_data);
typedef void gc_password_cb(const Messenger *m, uint32_t group_number, const uint8_t *data, size_t length,
typedef void gc_peer_limit_cb(const Messenger *m, uint32_t group_number, uint32_t peer_limit, void *user_data);
typedef void gc_privacy_state_cb(const Messenger *m, uint32_t group_number, unsigned int privacy_state, void *user_data);
typedef void gc_password_cb(const Messenger *m, uint32_t group_number, const uint8_t *password, size_t length,
void *user_data);
typedef void gc_peer_join_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id, void *user_data);
typedef void gc_peer_exit_cb(const Messenger *m, uint32_t group_number, uint32_t peer_id, unsigned int exit_type,
const uint8_t *nick, size_t nick_len, const uint8_t *data, size_t length, void *user_data);
const uint8_t *name, size_t name_length, const uint8_t *part_message, size_t length,
void *user_data);
typedef void gc_self_join_cb(const Messenger *m, uint32_t group_number, void *user_data);
typedef void gc_rejected_cb(const Messenger *m, uint32_t group_number, unsigned int type, void *user_data);
typedef void gc_rejected_cb(const Messenger *m, uint32_t group_number, unsigned int fail_type, void *user_data);
typedef struct GC_Session {
Messenger *messenger;

View File

@ -2229,7 +2229,7 @@ int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, const IP_Port *ip
non_null(1, 3) nullable(5)
static int tcp_data_callback(void *object, int crypt_connection_id, const uint8_t *data, uint16_t length,
static int tcp_data_callback(void *object, int crypt_connection_id, const uint8_t *packet, uint16_t length,
void *userdata)
{
Net_Crypto *c = (Net_Crypto *)object;
@ -2244,14 +2244,14 @@ static int tcp_data_callback(void *object, int crypt_connection_id, const uint8_
return -1;
}
if (data[0] == NET_PACKET_COOKIE_REQUEST) {
return tcp_handle_cookie_request(c, conn->connection_number_tcp, data, length);
if (packet[0] == NET_PACKET_COOKIE_REQUEST) {
return tcp_handle_cookie_request(c, conn->connection_number_tcp, packet, length);
}
// This unlocks the mutex that at this point is locked by do_tcp before
// calling do_tcp_connections.
pthread_mutex_unlock(&c->tcp_mutex);
const int ret = handle_packet_connection(c, crypt_connection_id, data, length, false, userdata);
const int ret = handle_packet_connection(c, crypt_connection_id, packet, length, false, userdata);
pthread_mutex_lock(&c->tcp_mutex);
if (ret != 0) {
@ -2264,7 +2264,7 @@ static int tcp_data_callback(void *object, int crypt_connection_id, const uint8_
non_null(1, 2, 4) nullable(6)
static int tcp_oob_callback(void *object, const uint8_t *public_key, unsigned int tcp_connections_number,
const uint8_t *data, uint16_t length, void *userdata)
const uint8_t *packet, uint16_t length, void *userdata)
{
Net_Crypto *c = (Net_Crypto *)object;
@ -2272,14 +2272,14 @@ static int tcp_oob_callback(void *object, const uint8_t *public_key, unsigned in
return -1;
}
if (data[0] == NET_PACKET_COOKIE_REQUEST) {
return tcp_oob_handle_cookie_request(c, tcp_connections_number, public_key, data, length);
if (packet[0] == NET_PACKET_COOKIE_REQUEST) {
return tcp_oob_handle_cookie_request(c, tcp_connections_number, public_key, packet, length);
}
if (data[0] == NET_PACKET_CRYPTO_HS) {
IP_Port source = tcp_connections_number_to_ip_port(tcp_connections_number);
if (packet[0] == NET_PACKET_CRYPTO_HS) {
const IP_Port source = tcp_connections_number_to_ip_port(tcp_connections_number);
if (handle_new_connection_handshake(c, &source, data, length, userdata) != 0) {
if (handle_new_connection_handshake(c, &source, packet, length, userdata) != 0) {
return -1;
}

View File

@ -135,7 +135,7 @@ typedef struct New_Connection {
typedef int connection_status_cb(void *object, int id, bool status, void *userdata);
typedef int connection_data_cb(void *object, int id, const uint8_t *data, uint16_t length, void *userdata);
typedef int connection_lossy_data_cb(void *object, int id, const uint8_t *data, uint16_t length, void *userdata);
typedef void dht_pk_cb(void *data, int32_t number, const uint8_t *dht_public_key, void *userdata);
typedef void dht_pk_cb(void *object, int32_t number, const uint8_t *dht_public_key, void *userdata);
typedef int new_connection_cb(void *object, const New_Connection *n_c);
/** @brief Set function to be called when someone requests a new connection to us.

View File

@ -399,7 +399,7 @@ bool addr_resolve_or_parse_ip(const Network *ns, const char *address, IP *to, IP
* Packet data is put into data.
* Packet length is put into length.
*/
typedef int packet_handler_cb(void *object, const IP_Port *ip_port, const uint8_t *data, uint16_t len, void *userdata);
typedef int packet_handler_cb(void *object, const IP_Port *source, const uint8_t *packet, uint16_t length, void *userdata);
typedef struct Networking_Core Networking_Core;

View File

@ -145,7 +145,7 @@ non_null()
int recv_tcp_relay_handler(Onion_Client *onion_c, int friend_num,
recv_tcp_relay_cb *callback, void *object, uint32_t number);
typedef void onion_dht_pk_cb(void *data, int32_t number, const uint8_t *dht_public_key, void *userdata);
typedef void onion_dht_pk_cb(void *object, int32_t number, const uint8_t *dht_public_key, void *userdata);
/** @brief Set the function for this friend that will be callbacked with object and number
* when that friend gives us their DHT temporary public key.
@ -191,7 +191,7 @@ non_null()
int send_onion_data(Onion_Client *onion_c, int friend_num, const uint8_t *data, uint16_t length);
typedef int oniondata_handler_cb(void *object, const uint8_t *source_pubkey, const uint8_t *data,
uint16_t len, void *userdata);
uint16_t length, void *userdata);
/** Function to call when onion data packet with contents beginning with byte is received. */
non_null(1) nullable(3, 4)

View File

@ -51,7 +51,7 @@ typedef enum State_Load_Status {
STATE_LOAD_STATUS_END,
} State_Load_Status;
typedef State_Load_Status state_load_cb(void *outer, const uint8_t *data, uint32_t len, uint16_t type);
typedef State_Load_Status state_load_cb(void *outer, const uint8_t *data, uint32_t length, uint16_t type);
/** state load/save */
non_null()

View File

@ -539,8 +539,7 @@ static void tox_group_peer_exit_handler(const Messenger *m, uint32_t group_numbe
if (tox_data->tox->group_peer_exit_callback != nullptr) {
tox_data->tox->group_peer_exit_callback(tox_data->tox, group_number, peer_id, (Tox_Group_Exit_Type) exit_type, name,
name_length,
part_message, length, tox_data->user_data);
name_length, part_message, length, tox_data->user_data);
}
}