Const correctness for toxcore/Messenger.c and related files

This commit is contained in:
Marc Schütz 2014-06-17 21:34:45 +02:00
parent 8f7638da5c
commit 8391417f61
12 changed files with 208 additions and 208 deletions

View File

@ -56,7 +56,7 @@
#endif
void print_message(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
void print_message(Messenger *m, int friendnumber, const uint8_t *string, uint16_t length, void *userdata)
{
printf("Message with length %u received from %u: %s \n", length, friendnumber, string);
m_sendmessage(m, friendnumber, (uint8_t *)"Test1", 6);

View File

@ -130,7 +130,7 @@ int not_sending()
static char path[1024];
void file_request_accept(Tox *m, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename,
void file_request_accept(Tox *m, int friendnumber, uint8_t filenumber, uint64_t filesize, const uint8_t *filename,
uint16_t filename_length, void *userdata)
{
char fullpath[1024];
@ -169,7 +169,7 @@ void file_request_accept(Tox *m, int friendnumber, uint8_t filenumber, uint64_t
}
void file_print_control(Tox *m, int friendnumber, uint8_t recieve_send, uint8_t filenumber, uint8_t control_type,
uint8_t *data,
const uint8_t *data,
uint16_t length, void *userdata)
{
if (recieve_send == 1 && (control_type == TOX_FILECONTROL_KILL || control_type == TOX_FILECONTROL_FINISHED)) {
@ -185,7 +185,7 @@ void file_print_control(Tox *m, int friendnumber, uint8_t recieve_send, uint8_t
}
}
void write_file(Tox *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
void write_file(Tox *m, int friendnumber, uint8_t filenumber, const uint8_t *data, uint16_t length, void *userdata)
{
if (file_recv[filenumber].file != 0)
if (fwrite(data, length, 1, file_recv[filenumber].file) != 1)

View File

@ -40,10 +40,10 @@
static void set_friend_status(Messenger *m, int32_t friendnumber, uint8_t status);
static int write_cryptpacket_id(Messenger *m, int32_t friendnumber, uint8_t packet_id, uint8_t *data, uint32_t length);
static int write_cryptpacket_id(const Messenger *m, int32_t friendnumber, uint8_t packet_id, const uint8_t *data, uint32_t length);
// friend_not_valid determines if the friendnumber passed is valid in the Messenger object
static uint8_t friend_not_valid(Messenger *m, int32_t friendnumber)
static uint8_t friend_not_valid(const Messenger *m, int32_t friendnumber)
{
return (unsigned int)friendnumber >= m->numfriends;
}
@ -109,7 +109,7 @@ int32_t getfriend_id(const Messenger *m, const uint8_t *client_id)
* return 0 if success.
* return -1 if failure.
*/
int getclient_id(Messenger *m, int32_t friendnumber, uint8_t *client_id)
int getclient_id(const Messenger *m, int32_t friendnumber, uint8_t *client_id)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -125,7 +125,7 @@ int getclient_id(Messenger *m, int32_t friendnumber, uint8_t *client_id)
*
* return a uint16_t that represents the checksum of address of length len.
*/
static uint16_t address_checksum(uint8_t *address, uint32_t len)
static uint16_t address_checksum(const uint8_t *address, uint32_t len)
{
uint8_t checksum[2] = {0};
uint16_t check;
@ -142,7 +142,7 @@ static uint16_t address_checksum(uint8_t *address, uint32_t len)
*
* return FRIEND_ADDRESS_SIZE byte address to give to others.
*/
void getaddress(Messenger *m, uint8_t *address)
void getaddress(const Messenger *m, uint8_t *address)
{
id_copy(address, m->net_crypto->self_public_key);
uint32_t nospam = get_nospam(&(m->fr));
@ -152,7 +152,7 @@ void getaddress(Messenger *m, uint8_t *address)
}
/* callback for recv TCP relay nodes. */
static int tcp_relay_node_callback(void *object, uint32_t number, IP_Port ip_port, uint8_t *public_key)
static int tcp_relay_node_callback(void *object, uint32_t number, IP_Port ip_port, const uint8_t *public_key)
{
Messenger *m = object;
@ -183,7 +183,7 @@ static int tcp_relay_node_callback(void *object, uint32_t number, IP_Port ip_por
* (the nospam for that friend was set to the new one).
* return FAERR_NOMEM if increasing the friend list size fails.
*/
int32_t m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length)
int32_t m_addfriend(Messenger *m, const uint8_t *address, const uint8_t *data, uint16_t length)
{
if (length > MAX_FRIEND_REQUEST_DATA_SIZE)
return FAERR_TOOLONG;
@ -346,7 +346,7 @@ int m_delfriend(Messenger *m, int32_t friendnumber)
return 0;
}
int m_get_friend_connectionstatus(Messenger *m, int32_t friendnumber)
int m_get_friend_connectionstatus(const Messenger *m, int32_t friendnumber)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -354,7 +354,7 @@ int m_get_friend_connectionstatus(Messenger *m, int32_t friendnumber)
return m->friendlist[friendnumber].status == FRIEND_ONLINE;
}
int m_friend_exists(Messenger *m, int32_t friendnumber)
int m_friend_exists(const Messenger *m, int32_t friendnumber)
{
if (friend_not_valid(m, friendnumber))
return 0;
@ -402,7 +402,7 @@ uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid
* return the message id if packet was successfully put into the send queue.
* return 0 if it was not.
*/
uint32_t m_sendaction(Messenger *m, int32_t friendnumber, uint8_t *action, uint32_t length)
uint32_t m_sendaction(Messenger *m, int32_t friendnumber, const uint8_t *action, uint32_t length)
{
if (friend_not_valid(m, friendnumber))
return 0;
@ -419,7 +419,7 @@ uint32_t m_sendaction(Messenger *m, int32_t friendnumber, uint8_t *action, uint3
return 0;
}
uint32_t m_sendaction_withid(Messenger *m, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length)
uint32_t m_sendaction_withid(const Messenger *m, int32_t friendnumber, uint32_t theid, const uint8_t *action, uint32_t length)
{
if (length >= (MAX_CRYPTO_DATA_SIZE - sizeof(theid)))
return 0;
@ -434,7 +434,7 @@ uint32_t m_sendaction_withid(Messenger *m, int32_t friendnumber, uint32_t theid,
/* Send a name packet to friendnumber.
* length is the length with the NULL terminator.
*/
static int m_sendname(Messenger *m, int32_t friendnumber, uint8_t *name, uint16_t length)
static int m_sendname(const Messenger *m, int32_t friendnumber, const uint8_t *name, uint16_t length)
{
if (length > MAX_NAME_LENGTH || length == 0)
return 0;
@ -447,7 +447,7 @@ static int m_sendname(Messenger *m, int32_t friendnumber, uint8_t *name, uint16_
* return 0 if success.
* return -1 if failure.
*/
int setfriendname(Messenger *m, int32_t friendnumber, uint8_t *name, uint16_t length)
int setfriendname(Messenger *m, int32_t friendnumber, const uint8_t *name, uint16_t length)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -492,7 +492,7 @@ int setname(Messenger *m, const uint8_t *name, uint16_t length)
*
* return the length of the name.
*/
uint16_t getself_name(Messenger *m, uint8_t *name)
uint16_t getself_name(const Messenger *m, uint8_t *name)
{
if (name == NULL) {
return 0;
@ -509,7 +509,7 @@ uint16_t getself_name(Messenger *m, uint8_t *name)
* return length of name if success.
* return -1 if failure.
*/
int getname(Messenger *m, int32_t friendnumber, uint8_t *name)
int getname(const Messenger *m, int32_t friendnumber, uint8_t *name)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -518,7 +518,7 @@ int getname(Messenger *m, int32_t friendnumber, uint8_t *name)
return m->friendlist[friendnumber].name_length;
}
int m_get_name_size(Messenger *m, int32_t friendnumber)
int m_get_name_size(const Messenger *m, int32_t friendnumber)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -526,7 +526,7 @@ int m_get_name_size(Messenger *m, int32_t friendnumber)
return m->friendlist[friendnumber].name_length;
}
int m_get_self_name_size(Messenger *m)
int m_get_self_name_size(const Messenger *m)
{
return m->name_length;
}
@ -565,7 +565,7 @@ int m_set_userstatus(Messenger *m, uint8_t status)
/* return the size of friendnumber's user status.
* Guaranteed to be at most MAX_STATUSMESSAGE_LENGTH.
*/
int m_get_statusmessage_size(Messenger *m, int32_t friendnumber)
int m_get_statusmessage_size(const Messenger *m, int32_t friendnumber)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -576,7 +576,7 @@ int m_get_statusmessage_size(Messenger *m, int32_t friendnumber)
/* Copy the user status of friendnumber into buf, truncating if needed to maxlen
* bytes, use m_get_statusmessage_size to find out how much you need to allocate.
*/
int m_copy_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *buf, uint32_t maxlen)
int m_copy_statusmessage(const Messenger *m, int32_t friendnumber, uint8_t *buf, uint32_t maxlen)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -591,12 +591,12 @@ int m_copy_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *buf, uint3
/* return the size of friendnumber's user status.
* Guaranteed to be at most MAX_STATUSMESSAGE_LENGTH.
*/
int m_get_self_statusmessage_size(Messenger *m)
int m_get_self_statusmessage_size(const Messenger *m)
{
return m->statusmessage_length;
}
int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen)
int m_copy_self_statusmessage(const Messenger *m, uint8_t *buf, uint32_t maxlen)
{
int msglen = MIN(maxlen, m->statusmessage_length);
memcpy(buf, m->statusmessage, msglen);
@ -604,7 +604,7 @@ int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen)
return msglen;
}
uint8_t m_get_userstatus(Messenger *m, int32_t friendnumber)
uint8_t m_get_userstatus(const Messenger *m, int32_t friendnumber)
{
if (friend_not_valid(m, friendnumber))
return USERSTATUS_INVALID;
@ -618,12 +618,12 @@ uint8_t m_get_userstatus(Messenger *m, int32_t friendnumber)
return status;
}
uint8_t m_get_self_userstatus(Messenger *m)
uint8_t m_get_self_userstatus(const Messenger *m)
{
return m->userstatus;
}
uint64_t m_get_last_online(Messenger *m, int32_t friendnumber)
uint64_t m_get_last_online(const Messenger *m, int32_t friendnumber)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -647,7 +647,7 @@ int m_set_usertyping(Messenger *m, int32_t friendnumber, uint8_t is_typing)
return 0;
}
uint8_t m_get_istyping(Messenger *m, int32_t friendnumber)
uint8_t m_get_istyping(const Messenger *m, int32_t friendnumber)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -655,23 +655,23 @@ uint8_t m_get_istyping(Messenger *m, int32_t friendnumber)
return m->friendlist[friendnumber].is_typing;
}
static int send_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *status, uint16_t length)
static int send_statusmessage(const Messenger *m, int32_t friendnumber, const uint8_t *status, uint16_t length)
{
return write_cryptpacket_id(m, friendnumber, PACKET_ID_STATUSMESSAGE, status, length);
}
static int send_userstatus(Messenger *m, int32_t friendnumber, uint8_t status)
static int send_userstatus(const Messenger *m, int32_t friendnumber, uint8_t status)
{
return write_cryptpacket_id(m, friendnumber, PACKET_ID_USERSTATUS, &status, sizeof(status));
}
static int send_user_istyping(Messenger *m, int32_t friendnumber, uint8_t is_typing)
static int send_user_istyping(const Messenger *m, int32_t friendnumber, uint8_t is_typing)
{
uint8_t typing = is_typing;
return write_cryptpacket_id(m, friendnumber, PACKET_ID_TYPING, &typing, sizeof(typing));
}
static int send_ping(Messenger *m, int32_t friendnumber)
static int send_ping(const Messenger *m, int32_t friendnumber)
{
int ret = write_cryptpacket_id(m, friendnumber, PACKET_ID_ALIVE, 0, 0);
@ -681,7 +681,7 @@ static int send_ping(Messenger *m, int32_t friendnumber)
return ret;
}
static int send_relays(Messenger *m, int32_t friendnumber)
static int send_relays(const Messenger *m, int32_t friendnumber)
{
Node_format nodes[MAX_SHARED_RELAYS];
uint8_t data[1024];
@ -700,7 +700,7 @@ static int send_relays(Messenger *m, int32_t friendnumber)
static int set_friend_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *status, uint16_t length)
static int set_friend_statusmessage(const Messenger *m, int32_t friendnumber, const uint8_t *status, uint16_t length)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -713,12 +713,12 @@ static int set_friend_statusmessage(Messenger *m, int32_t friendnumber, uint8_t
return 0;
}
static void set_friend_userstatus(Messenger *m, int32_t friendnumber, uint8_t status)
static void set_friend_userstatus(const Messenger *m, int32_t friendnumber, uint8_t status)
{
m->friendlist[friendnumber].userstatus = status;
}
static void set_friend_typing(Messenger *m, int32_t friendnumber, uint8_t is_typing)
static void set_friend_typing(const Messenger *m, int32_t friendnumber, uint8_t is_typing)
{
m->friendlist[friendnumber].is_typing = is_typing;
}
@ -745,28 +745,28 @@ void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const
}
/* Set the function that will be executed when a message from a friend is received. */
void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *),
void *userdata)
{
m->friend_message = function;
m->friend_message_userdata = userdata;
}
void m_callback_action(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
void m_callback_action(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *),
void *userdata)
{
m->friend_action = function;
m->friend_action_userdata = userdata;
}
void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *),
void *userdata)
{
m->friend_namechange = function;
m->friend_namechange_userdata = userdata;
}
void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *),
void *userdata)
{
m->friend_statusmessagechange = function;
@ -804,7 +804,7 @@ void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Mess
m->friend_connectionstatuschange_internal_userdata = userdata;
}
static void break_files(Messenger *m, int32_t friendnumber);
static void break_files(const Messenger *m, int32_t friendnumber);
static void check_friend_connectionstatus(Messenger *m, int32_t friendnumber, uint8_t status)
{
if (status == NOFRIEND)
@ -840,7 +840,7 @@ void set_friend_status(Messenger *m, int32_t friendnumber, uint8_t status)
m->friendlist[friendnumber].status = status;
}
int write_cryptpacket_id(Messenger *m, int32_t friendnumber, uint8_t packet_id, uint8_t *data, uint32_t length)
int write_cryptpacket_id(const Messenger *m, int32_t friendnumber, uint8_t packet_id, const uint8_t *data, uint32_t length)
{
if (friend_not_valid(m, friendnumber))
return 0;
@ -862,7 +862,7 @@ int write_cryptpacket_id(Messenger *m, int32_t friendnumber, uint8_t packet_id,
/* return 1 if the groupnumber is not valid.
* return 0 if the groupnumber is valid.
*/
static uint8_t groupnumber_not_valid(Messenger *m, int groupnumber)
static uint8_t groupnumber_not_valid(const Messenger *m, int groupnumber)
{
if ((unsigned int)groupnumber >= m->numchats)
return 1;
@ -880,7 +880,7 @@ static uint8_t groupnumber_not_valid(Messenger *m, int groupnumber)
/* returns valid ip port of connected friend on success
* returns zeroed out IP_Port on failure
*/
static IP_Port get_friend_ipport(Messenger *m, int32_t friendnumber)
static IP_Port get_friend_ipport(const Messenger *m, int32_t friendnumber)
{
IP_Port zero;
memset(&zero, 0, sizeof(zero));
@ -904,7 +904,7 @@ static IP_Port get_friend_ipport(Messenger *m, int32_t friendnumber)
/* returns the group number of the chat with public key group_public_key.
* returns -1 on failure.
*/
static int group_num(Messenger *m, uint8_t *group_public_key)
static int group_num(const Messenger *m, const uint8_t *group_public_key)
{
uint32_t i;
@ -921,7 +921,7 @@ static int group_num(Messenger *m, uint8_t *group_public_key)
*
* Function(Messenger *m, int32_t friendnumber, uint8_t *group_public_key, void *userdata)
*/
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, void *), void *userdata)
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, void *), void *userdata)
{
m->group_invite = function;
m->group_invite_userdata = userdata;
@ -931,7 +931,7 @@ void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_
*
* Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
*/
void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int, int, uint8_t *, uint16_t, void *),
void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int, int, const uint8_t *, uint16_t, void *),
void *userdata)
{
m->group_message = function;
@ -942,7 +942,7 @@ void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int,
*
* Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
*/
void m_callback_group_action(Messenger *m, void (*function)(Messenger *m, int, int, uint8_t *, uint16_t, void *),
void m_callback_group_action(Messenger *m, void (*function)(Messenger *m, int, int, const uint8_t *, uint16_t, void *),
void *userdata)
{
m->group_action = function;
@ -961,7 +961,7 @@ void m_callback_group_namelistchange(Messenger *m, void (*function)(Messenger *m
m->group_namelistchange_userdata = userdata;
}
static int get_chat_num(Messenger *m, Group_Chat *chat)
static int get_chat_num(const Messenger *m, const Group_Chat *chat)
{
uint32_t i;
@ -1141,7 +1141,7 @@ static void group_store_friendinvite(Messenger *m, int32_t friendnumber, int gro
/* return 1 if that friend was invited to the group
* return 0 if the friend was not or error.
*/
static uint8_t group_invited(Messenger *m, int32_t friendnumber, int groupnumber)
static uint8_t group_invited(const Messenger *m, int32_t friendnumber, int groupnumber)
{
uint32_t i;
@ -1189,7 +1189,7 @@ int invite_friend(Messenger *m, int32_t friendnumber, int groupnumber)
* returns group number on success
* returns -1 on failure.
*/
int join_groupchat(Messenger *m, int32_t friendnumber, uint8_t *friend_group_public_key)
int join_groupchat(Messenger *m, int32_t friendnumber, const uint8_t *friend_group_public_key)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -1222,7 +1222,7 @@ int join_groupchat(Messenger *m, int32_t friendnumber, uint8_t *friend_group_pub
* return 0 on success
* return -1 on failure
*/
int group_message_send(Messenger *m, int groupnumber, uint8_t *message, uint32_t length)
int group_message_send(const Messenger *m, int groupnumber, const uint8_t *message, uint32_t length)
{
if (groupnumber_not_valid(m, groupnumber))
return -1;
@ -1237,7 +1237,7 @@ int group_message_send(Messenger *m, int groupnumber, uint8_t *message, uint32_t
* return 0 on success
* return -1 on failure
*/
int group_action_send(Messenger *m, int groupnumber, uint8_t *action, uint32_t length)
int group_action_send(const Messenger *m, int groupnumber, const uint8_t *action, uint32_t length)
{
if (groupnumber_not_valid(m, groupnumber))
return -1;
@ -1251,7 +1251,7 @@ int group_action_send(Messenger *m, int groupnumber, uint8_t *action, uint32_t l
/* Return the number of peers in the group chat on success.
* return -1 on failure
*/
int group_number_peers(Messenger *m, int groupnumber)
int group_number_peers(const Messenger *m, int groupnumber)
{
if (groupnumber_not_valid(m, groupnumber))
return -1;
@ -1269,7 +1269,7 @@ int group_number_peers(Messenger *m, int groupnumber)
*
* return -1 on failure.
*/
int group_names(Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], uint16_t length)
int group_names(const Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], uint16_t length)
{
if (groupnumber_not_valid(m, groupnumber))
return -1;
@ -1315,7 +1315,7 @@ static void do_allgroupchats(Messenger *m)
*
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
*/
void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *,
void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, const uint8_t *,
uint16_t, void *), void *userdata)
{
m->file_sendrequest = function;
@ -1327,7 +1327,7 @@ void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int3
* Function(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
*
*/
void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *,
void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, const uint8_t *,
uint16_t, void *), void *userdata)
{
m->file_filecontrol = function;
@ -1339,7 +1339,7 @@ void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t,
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
*
*/
void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length,
void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, const uint8_t *, uint16_t length,
void *), void *userdata)
{
m->file_filedata = function;
@ -1353,7 +1353,7 @@ void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, ui
* return 1 on success
* return 0 on failure
*/
int file_sendrequest(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename,
int file_sendrequest(const Messenger *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, const uint8_t *filename,
uint16_t filename_length)
{
if (friend_not_valid(m, friendnumber))
@ -1376,7 +1376,7 @@ int file_sendrequest(Messenger *m, int32_t friendnumber, uint8_t filenumber, uin
* return file number on success
* return -1 on failure
*/
int new_filesender(Messenger *m, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length)
int new_filesender(const Messenger *m, int32_t friendnumber, uint64_t filesize, const uint8_t *filename, uint16_t filename_length)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -1406,8 +1406,8 @@ int new_filesender(Messenger *m, int32_t friendnumber, uint64_t filesize, uint8_
* return 0 on success
* return -1 on failure
*/
int file_control(Messenger *m, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
uint8_t *data, uint16_t length)
int file_control(const Messenger *m, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
const uint8_t *data, uint16_t length)
{
if (length > MAX_CRYPTO_DATA_SIZE - 3)
return -1;
@ -1494,7 +1494,7 @@ int file_control(Messenger *m, int32_t friendnumber, uint8_t send_receive, uint8
* return 0 on success
* return -1 on failure
*/
int file_data(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length)
int file_data(const Messenger *m, int32_t friendnumber, uint8_t filenumber, const uint8_t *data, uint16_t length)
{
if (length > MAX_CRYPTO_DATA_SIZE - 1)
return -1;
@ -1529,7 +1529,7 @@ int file_data(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t *d
* return number of bytes remaining to be sent/received on success
* return 0 on failure
*/
uint64_t file_dataremaining(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive)
uint64_t file_dataremaining(const Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive)
{
if (friend_not_valid(m, friendnumber))
return 0;
@ -1552,7 +1552,7 @@ uint64_t file_dataremaining(Messenger *m, int32_t friendnumber, uint8_t filenumb
/* Run this when the friend disconnects.
* Sets all current file transfers to broken.
*/
static void break_files(Messenger *m, int32_t friendnumber)
static void break_files(const Messenger *m, int32_t friendnumber)
{
uint32_t i;
@ -1565,7 +1565,7 @@ static void break_files(Messenger *m, int32_t friendnumber)
}
}
static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber,
static int handle_filecontrol(const Messenger *m, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber,
uint8_t message_id, uint8_t *data,
uint16_t length)
{
@ -1655,7 +1655,7 @@ static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receiv
*
* Function(Messenger *m, int friendnumber, uint8_t *data, uint16_t length, void *userdata)
*/
void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *),
void *userdata)
{
m->msi_packet = function;
@ -1667,12 +1667,12 @@ void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t,
* return 1 on success
* return 0 on failure
*/
int m_msi_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length)
int m_msi_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length)
{
return write_cryptpacket_id(m, friendnumber, PACKET_ID_MSI, data, length);
}
static int handle_custom_lossy_packet(void *object, int friend_num, uint8_t *packet, uint16_t length)
static int handle_custom_lossy_packet(void *object, int friend_num, const uint8_t *packet, uint16_t length)
{
Messenger *m = object;
@ -1687,7 +1687,7 @@ static int handle_custom_lossy_packet(void *object, int friend_num, uint8_t *pac
}
int custom_lossy_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
int (*packet_handler_callback)(void *object, uint8_t *data, uint32_t len), void *object)
int (*packet_handler_callback)(void *object, const uint8_t *data, uint32_t len), void *object)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -1703,7 +1703,7 @@ int custom_lossy_packet_registerhandler(Messenger *m, int32_t friendnumber, uint
return 0;
}
int send_custom_lossy_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length)
int send_custom_lossy_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -1717,7 +1717,7 @@ int send_custom_lossy_packet(Messenger *m, int32_t friendnumber, uint8_t *data,
return send_lossy_cryptpacket(m->net_crypto, m->friendlist[friendnumber].crypt_connection_id, data, length);
}
static int handle_custom_lossless_packet(void *object, int friend_num, uint8_t *packet, uint16_t length)
static int handle_custom_lossless_packet(void *object, int friend_num, const uint8_t *packet, uint16_t length)
{
Messenger *m = object;
@ -1738,7 +1738,7 @@ static int handle_custom_lossless_packet(void *object, int friend_num, uint8_t *
}
int custom_lossless_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
int (*packet_handler_callback)(void *object, uint8_t *data, uint32_t len), void *object)
int (*packet_handler_callback)(void *object, const uint8_t *data, uint32_t len), void *object)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -1755,7 +1755,7 @@ int custom_lossless_packet_registerhandler(Messenger *m, int32_t friendnumber, u
return 0;
}
int send_custom_lossless_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length)
int send_custom_lossless_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -1772,7 +1772,7 @@ int send_custom_lossless_packet(Messenger *m, int32_t friendnumber, uint8_t *dat
/* Function to filter out some friend requests*/
static int friend_already_added(const uint8_t *client_id, void *data)
{
Messenger *m = data;
const Messenger *m = data;
if (getfriend_id(m, client_id) == -1)
return 0;
@ -2029,13 +2029,13 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len)
}
case PACKET_ID_MESSAGE: {
uint8_t *message_id = data;
const uint8_t *message_id = data;
uint8_t message_id_length = 4;
if (data_length <= message_id_length)
break;
uint8_t *message = data + message_id_length;
const uint8_t *message = data + message_id_length;
uint16_t message_length = data_length - message_id_length;
/* Make sure the NULL terminator is present. */
@ -2054,13 +2054,13 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len)
}
case PACKET_ID_ACTION: {
uint8_t *message_id = data;
const uint8_t *message_id = data;
uint8_t message_id_length = 4;
if (data_length <= message_id_length)
break;
uint8_t *action = data + message_id_length;
const uint8_t *action = data + message_id_length;
uint16_t action_length = data_length - message_id_length;
/* Make sure the NULL terminator is present. */
@ -2128,8 +2128,8 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len)
uint8_t filenumber = data[0];
uint64_t filesize;
net_to_host(data + 1, sizeof(filesize));
memcpy(&filesize, data + 1, sizeof(filesize));
net_to_host((uint8_t *) &filesize, sizeof(filesize));
m->friendlist[i].file_receiving[filenumber].status = FILESTATUS_NOT_ACCEPTED;
m->friendlist[i].file_receiving[filenumber].size = filesize;
m->friendlist[i].file_receiving[filenumber].transferred = 0;
@ -2216,7 +2216,7 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len)
return 0;
}
static int friend_new_connection(Messenger *m, int32_t friendnumber, uint8_t *real_public_key)
static int friend_new_connection(Messenger *m, int32_t friendnumber, const uint8_t *real_public_key)
{
if (friend_not_valid(m, friendnumber))
return -1;
@ -2337,7 +2337,7 @@ void do_friends(Messenger *m)
#define DUMPING_CLIENTS_FRIENDS_EVERY_N_SECONDS 60UL
static time_t lastdump = 0;
static char IDString[CLIENT_ID_SIZE * 2 + 1];
static char *ID2String(uint8_t *client_id)
static char *ID2String(const uint8_t *client_id)
{
uint32_t i;
@ -2530,12 +2530,12 @@ struct SAVED_FRIEND {
uint64_t ping_lastrecv;
};
static uint32_t saved_friendslist_size(Messenger *m)
static uint32_t saved_friendslist_size(const Messenger *m)
{
return count_friendlist(m) * sizeof(struct SAVED_FRIEND);
}
static uint32_t friends_list_save(Messenger *m, uint8_t *data)
static uint32_t friends_list_save(const Messenger *m, uint8_t *data)
{
uint32_t i;
uint32_t num = 0;
@ -2614,7 +2614,7 @@ static int friends_list_load(Messenger *m, const uint8_t *data, uint32_t length)
}
/* return size of the messenger data (for saving) */
uint32_t messenger_size(Messenger *m)
uint32_t messenger_size(const Messenger *m)
{
uint32_t size32 = sizeof(uint32_t), sizesubhead = size32 * 2;
return size32 * 2 // global cookie
@ -2639,7 +2639,7 @@ static uint8_t *z_state_save_subheader(uint8_t *data, uint32_t len, uint16_t typ
/* Save the messenger in data of size Messenger_size(). */
void messenger_save(Messenger *m, uint8_t *data)
void messenger_save(const Messenger *m, uint8_t *data)
{
uint32_t len;
uint16_t type;
@ -2776,7 +2776,7 @@ static int messenger_load_state_callback(void *outer, const uint8_t *data, uint3
}
/* Load the messenger from data of size length. */
int messenger_load(Messenger *m, uint8_t *data, uint32_t length)
int messenger_load(Messenger *m, const uint8_t *data, uint32_t length)
{
uint32_t data32[2];
uint32_t cookie_len = sizeof(data32);
@ -2796,7 +2796,7 @@ int messenger_load(Messenger *m, uint8_t *data, uint32_t length)
/* Return the number of friends in the instance m.
* You should use this to determine how much memory to allocate
* for copy_friendlist. */
uint32_t count_friendlist(Messenger *m)
uint32_t count_friendlist(const Messenger *m)
{
uint32_t ret = 0;
uint32_t i;
@ -2811,7 +2811,7 @@ uint32_t count_friendlist(Messenger *m)
}
/* Return the number of online friends in the instance m. */
uint32_t get_num_online_friends(Messenger *m)
uint32_t get_num_online_friends(const Messenger *m)
{
return m->numonline_friends;
}
@ -2821,7 +2821,7 @@ uint32_t get_num_online_friends(Messenger *m)
* Otherwise, returns the number of elements copied.
* If the array was too small, the contents
* of out_list will be truncated to list_size. */
uint32_t copy_friendlist(Messenger *m, int32_t *out_list, uint32_t list_size)
uint32_t copy_friendlist(Messenger const *m, int32_t *out_list, uint32_t list_size)
{
if (!out_list)
return 0;
@ -2853,7 +2853,7 @@ uint32_t copy_friendlist(Messenger *m, int32_t *out_list, uint32_t list_size)
* retun 0 if success.
* return -1 if failure.
*/
int get_friendlist(Messenger *m, int32_t **out_list, uint32_t *out_list_length)
int get_friendlist(const Messenger *m, int32_t **out_list, uint32_t *out_list_length)
{
uint32_t i;
@ -2883,7 +2883,7 @@ int get_friendlist(Messenger *m, int32_t **out_list, uint32_t *out_list_length)
/* Return the number of chats in the instance m.
* You should use this to determine how much memory to allocate
* for copy_chatlist. */
uint32_t count_chatlist(Messenger *m)
uint32_t count_chatlist(const Messenger *m)
{
uint32_t ret = 0;
uint32_t i;
@ -2902,7 +2902,7 @@ uint32_t count_chatlist(Messenger *m)
* Otherwise, returns the number of elements copied.
* If the array was too small, the contents
* of out_list will be truncated to list_size. */
uint32_t copy_chatlist(Messenger *m, int *out_list, uint32_t list_size)
uint32_t copy_chatlist(const Messenger *m, int *out_list, uint32_t list_size)
{
if (!out_list)
return 0;

View File

@ -172,12 +172,12 @@ typedef struct {
uint16_t invited_groups_num;
struct {
int (*function)(void *object, uint8_t *data, uint32_t len);
int (*function)(void *object, const uint8_t *data, uint32_t len);
void *object;
} lossy_packethandlers[PACKET_ID_LOSSY_RANGE_SIZE];
struct {
int (*function)(void *object, uint8_t *data, uint32_t len);
int (*function)(void *object, const uint8_t *data, uint32_t len);
void *object;
} lossless_packethandlers[PACKET_ID_LOSSLESS_RANGE_SIZE];
} Friend;
@ -212,13 +212,13 @@ typedef struct Messenger {
uint64_t last_LANdiscovery;
void (*friend_message)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
void (*friend_message)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *);
void *friend_message_userdata;
void (*friend_action)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
void (*friend_action)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *);
void *friend_action_userdata;
void (*friend_namechange)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
void (*friend_namechange)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *);
void *friend_namechange_userdata;
void (*friend_statusmessagechange)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
void (*friend_statusmessagechange)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *);
void *friend_statusmessagechange_userdata;
void (*friend_userstatuschange)(struct Messenger *m, int32_t, uint8_t, void *);
void *friend_userstatuschange_userdata;
@ -233,23 +233,23 @@ typedef struct Messenger {
void (*friend_connectionstatuschange_internal)(struct Messenger *m, int32_t, uint8_t, void *);
void *friend_connectionstatuschange_internal_userdata;
void (*group_invite)(struct Messenger *m, int32_t, uint8_t *, void *);
void (*group_invite)(struct Messenger *m, int32_t, const uint8_t *, void *);
void *group_invite_userdata;
void (*group_message)(struct Messenger *m, int, int, uint8_t *, uint16_t, void *);
void (*group_message)(struct Messenger *m, int, int, const uint8_t *, uint16_t, void *);
void *group_message_userdata;
void (*group_action)(struct Messenger *m, int, int, uint8_t *, uint16_t, void *);
void (*group_action)(struct Messenger *m, int, int, const uint8_t *, uint16_t, void *);
void *group_action_userdata;
void (*group_namelistchange)(struct Messenger *m, int, int, uint8_t, void *);
void *group_namelistchange_userdata;
void (*file_sendrequest)(struct Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *, uint16_t, void *);
void (*file_sendrequest)(struct Messenger *m, int32_t, uint8_t, uint64_t, const uint8_t *, uint16_t, void *);
void *file_sendrequest_userdata;
void (*file_filecontrol)(struct Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *, uint16_t, void *);
void (*file_filecontrol)(struct Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, const uint8_t *, uint16_t, void *);
void *file_filecontrol_userdata;
void (*file_filedata)(struct Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length, void *);
void (*file_filedata)(struct Messenger *m, int32_t, uint8_t, const uint8_t *, uint16_t length, void *);
void *file_filedata_userdata;
void (*msi_packet)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
void (*msi_packet)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *);
void *msi_packet_userdata;
} Messenger;
@ -258,7 +258,7 @@ typedef struct Messenger {
*
* return FRIEND_ADDRESS_SIZE byte address to give to others.
*/
void getaddress(Messenger *m, uint8_t *address);
void getaddress(const Messenger *m, uint8_t *address);
/* Add a friend.
* Set the data that will be sent along with friend request.
@ -276,7 +276,7 @@ void getaddress(Messenger *m, uint8_t *address);
* (the nospam for that friend was set to the new one).
* return -8 if increasing the friend list size fails.
*/
int32_t m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length);
int32_t m_addfriend(Messenger *m, const uint8_t *address, const uint8_t *data, uint16_t length);
/* Add a friend without sending a friendrequest.
@ -296,7 +296,7 @@ int32_t getfriend_id(const Messenger *m, const uint8_t *client_id);
* return 0 if success
* return -1 if failure
*/
int getclient_id(Messenger *m, int32_t friendnumber, uint8_t *client_id);
int getclient_id(const Messenger *m, int32_t friendnumber, uint8_t *client_id);
/* Remove a friend.
*
@ -311,14 +311,14 @@ int m_delfriend(Messenger *m, int32_t friendnumber);
* return 0 if friend is not connected to us (Offline).
* return -1 on failure.
*/
int m_get_friend_connectionstatus(Messenger *m, int32_t friendnumber);
int m_get_friend_connectionstatus(const Messenger *m, int32_t friendnumber);
/* Checks if there exists a friend with given friendnumber.
*
* return 1 if friend exists.
* return 0 if friend doesn't exist.
*/
int m_friend_exists(Messenger *m, int32_t friendnumber);
int m_friend_exists(const Messenger *m, int32_t friendnumber);
/* Send a text chat message to an online friend.
*
@ -344,8 +344,8 @@ uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid
* m_sendaction_withid will send an action message with the id of your choosing,
* however we can generate an id for you by calling plain m_sendaction.
*/
uint32_t m_sendaction(Messenger *m, int32_t friendnumber, uint8_t *action, uint32_t length);
uint32_t m_sendaction_withid(Messenger *m, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length);
uint32_t m_sendaction(Messenger *m, int32_t friendnumber, const uint8_t *action, uint32_t length);
uint32_t m_sendaction_withid(const Messenger *m, int32_t friendnumber, uint32_t theid, const uint8_t *action, uint32_t length);
/* Set the name and name_length of a friend.
* name must be a string of maximum MAX_NAME_LENGTH length.
@ -355,7 +355,7 @@ uint32_t m_sendaction_withid(Messenger *m, int32_t friendnumber, uint32_t theid,
* return 0 if success.
* return -1 if failure.
*/
int setfriendname(Messenger *m, int32_t friendnumber, uint8_t *name, uint16_t length);
int setfriendname(Messenger *m, int32_t friendnumber, const uint8_t *name, uint16_t length);
/* Set our nickname.
* name must be a string of maximum MAX_NAME_LENGTH length.
@ -375,7 +375,7 @@ int setname(Messenger *m, const uint8_t *name, uint16_t length);
* return length of the name.
* return 0 on error.
*/
uint16_t getself_name(Messenger *m, uint8_t *name);
uint16_t getself_name(const Messenger *m, uint8_t *name);
/* Get name of friendnumber and put it in name.
* name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
@ -383,13 +383,13 @@ uint16_t getself_name(Messenger *m, uint8_t *name);
* return length of name if success.
* return -1 if failure.
*/
int getname(Messenger *m, int32_t friendnumber, uint8_t *name);
int getname(const Messenger *m, int32_t friendnumber, uint8_t *name);
/* return the length of name, including null on success.
* return -1 on failure.
*/
int m_get_name_size(Messenger *m, int32_t friendnumber);
int m_get_self_name_size(Messenger *m);
int m_get_name_size(const Messenger *m, int32_t friendnumber);
int m_get_self_name_size(const Messenger *m);
/* Set our user status.
* You are responsible for freeing status after.
@ -403,8 +403,8 @@ int m_set_userstatus(Messenger *m, uint8_t status);
/* return the length of friendnumber's status message, including null on success.
* return -1 on failure.
*/
int m_get_statusmessage_size(Messenger *m, int32_t friendnumber);
int m_get_self_statusmessage_size(Messenger *m);
int m_get_statusmessage_size(const Messenger *m, int32_t friendnumber);
int m_get_self_statusmessage_size(const Messenger *m);
/* Copy friendnumber's status message into buf, truncating if size is over maxlen.
* Get the size you need to allocate from m_get_statusmessage_size.
@ -413,21 +413,21 @@ int m_get_self_statusmessage_size(Messenger *m);
* returns the length of the copied data on success
* retruns -1 on failure.
*/
int m_copy_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *buf, uint32_t maxlen);
int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen);
int m_copy_statusmessage(const Messenger *m, int32_t friendnumber, uint8_t *buf, uint32_t maxlen);
int m_copy_self_statusmessage(const Messenger *m, uint8_t *buf, uint32_t maxlen);
/* return one of USERSTATUS values.
* Values unknown to your application should be represented as USERSTATUS_NONE.
* As above, the self variant will return our own USERSTATUS.
* If friendnumber is invalid, this shall return USERSTATUS_INVALID.
*/
uint8_t m_get_userstatus(Messenger *m, int32_t friendnumber);
uint8_t m_get_self_userstatus(Messenger *m);
uint8_t m_get_userstatus(const Messenger *m, int32_t friendnumber);
uint8_t m_get_self_userstatus(const Messenger *m);
/* returns timestamp of last time friendnumber was seen online, or 0 if never seen.
* returns -1 on error.
*/
uint64_t m_get_last_online(Messenger *m, int32_t friendnumber);
uint64_t m_get_last_online(const Messenger *m, int32_t friendnumber);
/* Set our typing status for a friend.
* You are responsible for turning it on or off.
@ -442,7 +442,7 @@ int m_set_usertyping(Messenger *m, int32_t friendnumber, uint8_t is_typing);
* returns 0 if friend is not typing.
* returns 1 if friend is typing.
*/
uint8_t m_get_istyping(Messenger *m, int32_t friendnumber);
uint8_t m_get_istyping(const Messenger *m, int32_t friendnumber);
/* Sets whether we send read receipts for friendnumber.
* This function is not lazy, and it will fail if yesno is not (0 or 1).
@ -458,20 +458,20 @@ void m_callback_friendrequest(Messenger *m, void (*function)(Messenger *m, const
/* Set the function that will be executed when a message from a friend is received.
* Function format is: function(int32_t friendnumber, uint8_t * message, uint32_t length)
*/
void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set the function that will be executed when an action from a friend is received.
* Function format is: function(int32_t friendnumber, uint8_t * action, uint32_t length)
*/
void m_callback_action(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
void m_callback_action(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set the callback for name changes.
* Function(int32_t friendnumber, uint8_t *newname, uint16_t length)
* You are not responsible for freeing newname.
*/
void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set the callback for status message changes.
@ -479,7 +479,7 @@ void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int32_t,
*
* You are not responsible for freeing newstatus
*/
void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set the callback for status type changes.
@ -526,20 +526,20 @@ void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Mess
*
* Function(Messenger *m, int32_t friendnumber, uint8_t *group_public_key, void *userdata)
*/
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, void *), void *userdata);
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, void *), void *userdata);
/* Set the callback for group messages.
*
* Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
*/
void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int, int, uint8_t *, uint16_t, void *),
void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int, int, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set the callback for group actions.
*
* Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
*/
void m_callback_group_action(Messenger *m, void (*function)(Messenger *m, int, int, uint8_t *, uint16_t, void *),
void m_callback_group_action(Messenger *m, void (*function)(Messenger *m, int, int, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set callback function for peer name list changes.
@ -583,24 +583,24 @@ int invite_friend(Messenger *m, int32_t friendnumber, int groupnumber);
* returns group number on success
* returns -1 on failure.
*/
int join_groupchat(Messenger *m, int32_t friendnumber, uint8_t *friend_group_public_key);
int join_groupchat(Messenger *m, int32_t friendnumber, const uint8_t *friend_group_public_key);
/* send a group message
* return 0 on success
* return -1 on failure
*/
int group_message_send(Messenger *m, int groupnumber, uint8_t *message, uint32_t length);
int group_message_send(const Messenger *m, int groupnumber, const uint8_t *message, uint32_t length);
/* send a group action
* return 0 on success
* return -1 on failure
*/
int group_action_send(Messenger *m, int groupnumber, uint8_t *action, uint32_t length);
int group_action_send(const Messenger *m, int groupnumber, const uint8_t *action, uint32_t length);
/* Return the number of peers in the group chat on success.
* return -1 on failure
*/
int group_number_peers(Messenger *m, int groupnumber);
int group_number_peers(const Messenger *m, int groupnumber);
/* List all the peers in the group chat.
*
@ -612,7 +612,7 @@ int group_number_peers(Messenger *m, int groupnumber);
*
* return -1 on failure.
*/
int group_names(Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], uint16_t length);
int group_names(const Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], uint16_t length);
/****************FILE SENDING*****************/
@ -621,7 +621,7 @@ int group_names(Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES],
*
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
*/
void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *,
void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, const uint8_t *,
uint16_t, void *), void *userdata);
/* Set the callback for file control requests.
@ -629,7 +629,7 @@ void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int3
* Function(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
*
*/
void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *,
void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, const uint8_t *,
uint16_t, void *), void *userdata);
/* Set the callback for file data.
@ -637,7 +637,7 @@ void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t,
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
*
*/
void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length,
void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, const uint8_t *, uint16_t length,
void *), void *userdata);
/* Send a file send request.
@ -645,7 +645,7 @@ void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, ui
* return 1 on success
* return 0 on failure
*/
int file_sendrequest(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename,
int file_sendrequest(const Messenger *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, const uint8_t *filename,
uint16_t filename_length);
/* Send a file send request.
@ -653,7 +653,7 @@ int file_sendrequest(Messenger *m, int32_t friendnumber, uint8_t filenumber, uin
* return file number on success
* return -1 on failure
*/
int new_filesender(Messenger *m, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length);
int new_filesender(const Messenger *m, int32_t friendnumber, uint64_t filesize, const uint8_t *filename, uint16_t filename_length);
/* Send a file control request.
* send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file.
@ -661,15 +661,15 @@ int new_filesender(Messenger *m, int32_t friendnumber, uint64_t filesize, uint8_
* return 1 on success
* return 0 on failure
*/
int file_control(Messenger *m, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
uint8_t *data, uint16_t length);
int file_control(const Messenger *m, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
const uint8_t *data, uint16_t length);
/* Send file data.
*
* return 1 on success
* return 0 on failure
*/
int file_data(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length);
int file_data(const Messenger *m, int32_t friendnumber, uint8_t filenumber, const uint8_t *data, uint16_t length);
/* Give the number of bytes left to be sent/received.
*
@ -678,7 +678,7 @@ int file_data(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t *d
* return number of bytes remaining to be sent/received on success
* return 0 on failure
*/
uint64_t file_dataremaining(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive);
uint64_t file_dataremaining(const Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive);
/*************** A/V related ******************/
@ -686,7 +686,7 @@ uint64_t file_dataremaining(Messenger *m, int32_t friendnumber, uint8_t filenumb
*
* Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length, void *userdata)
*/
void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *),
void *userdata);
/* Send an msi packet.
@ -694,7 +694,7 @@ void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t,
* return 1 on success
* return 0 on failure
*/
int m_msi_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length);
int m_msi_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length);
/**********************************************/
@ -704,14 +704,14 @@ int m_msi_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t len
* return 0 on success.
*/
int custom_lossy_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
int (*packet_handler_callback)(void *object, uint8_t *data, uint32_t len), void *object);
int (*packet_handler_callback)(void *object, const uint8_t *data, uint32_t len), void *object);
/* High level function to send custom lossy packets.
*
* return -1 on failure.
* return 0 on success.
*/
int send_custom_lossy_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length);
int send_custom_lossy_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length);
/* Set handlers for custom lossless packets.
@ -722,14 +722,14 @@ int send_custom_lossy_packet(Messenger *m, int32_t friendnumber, uint8_t *data,
* return 0 on success.
*/
int custom_lossless_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte,
int (*packet_handler_callback)(void *object, uint8_t *data, uint32_t len), void *object);
int (*packet_handler_callback)(void *object, const uint8_t *data, uint32_t len), void *object);
/* High level function to send custom lossless packets.
*
* return -1 on failure.
* return 0 on success.
*/
int send_custom_lossless_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length);
int send_custom_lossless_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length);
/**********************************************/
/* Run this at startup.
@ -756,28 +756,28 @@ uint32_t messenger_run_interval(Messenger *m);
/* SAVING AND LOADING FUNCTIONS: */
/* return size of the messenger data (for saving). */
uint32_t messenger_size(Messenger *m);
uint32_t messenger_size(const Messenger *m);
/* Save the messenger in data (must be allocated memory of size Messenger_size()) */
void messenger_save(Messenger *m, uint8_t *data);
void messenger_save(const Messenger *m, uint8_t *data);
/* Load the messenger from data of size length. */
int messenger_load(Messenger *m, uint8_t *data, uint32_t length);
int messenger_load(Messenger *m, const uint8_t *data, uint32_t length);
/* Return the number of friends in the instance m.
* You should use this to determine how much memory to allocate
* for copy_friendlist. */
uint32_t count_friendlist(Messenger *m);
uint32_t count_friendlist(const Messenger *m);
/* Return the number of online friends in the instance m. */
uint32_t get_num_online_friends(Messenger *m);
uint32_t get_num_online_friends(const Messenger *m);
/* Copy a list of valid friend IDs into the array out_list.
* If out_list is NULL, returns 0.
* Otherwise, returns the number of elements copied.
* If the array was too small, the contents
* of out_list will be truncated to list_size. */
uint32_t copy_friendlist(Messenger *m, int32_t *out_list, uint32_t list_size);
uint32_t copy_friendlist(const Messenger *m, int32_t *out_list, uint32_t list_size);
/* Allocate and return a list of valid friend id's. List must be freed by the
* caller.
@ -785,18 +785,18 @@ uint32_t copy_friendlist(Messenger *m, int32_t *out_list, uint32_t list_size);
* retun 0 if success.
* return -1 if failure.
*/
int get_friendlist(Messenger *m, int **out_list, uint32_t *out_list_length);
int get_friendlist(const Messenger *m, int **out_list, uint32_t *out_list_length);
/* Return the number of chats in the instance m.
* You should use this to determine how much memory to allocate
* for copy_chatlist. */
uint32_t count_chatlist(Messenger *m);
uint32_t count_chatlist(const Messenger *m);
/* Copy a list of valid chat IDs into the array out_list.
* If out_list is NULL, returns 0.
* Otherwise, returns the number of elements copied.
* If the array was too small, the contents
* of out_list will be truncated to list_size. */
uint32_t copy_chatlist(Messenger *m, int *out_list, uint32_t list_size);
uint32_t copy_chatlist(const Messenger *m, int *out_list, uint32_t list_size);
#endif

View File

@ -65,7 +65,7 @@ static int connect_sock_to(sock_t sock, IP_Port ip_port)
/* return 0 on success.
* return -1 on failure.
*/
static int generate_handshake(TCP_Client_Connection *TCP_conn, uint8_t *self_public_key, uint8_t *self_secret_key)
static int generate_handshake(TCP_Client_Connection *TCP_conn, const uint8_t *self_public_key, const uint8_t *self_secret_key)
{
uint8_t plain[crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES];
crypto_box_keypair(plain, TCP_conn->temp_secret_key);
@ -335,8 +335,8 @@ void onion_response_handler(TCP_Client_Connection *con, int (*onion_callback)(vo
/* Create new TCP connection to ip_port/public_key
*/
TCP_Client_Connection *new_TCP_connection(IP_Port ip_port, uint8_t *public_key, uint8_t *self_public_key,
uint8_t *self_secret_key)
TCP_Client_Connection *new_TCP_connection(IP_Port ip_port, const uint8_t *public_key, const uint8_t *self_public_key,
const uint8_t *self_secret_key)
{
if (networking_at_startup() != 0) {
return NULL;

View File

@ -79,8 +79,8 @@ typedef struct {
/* Create new TCP connection to ip_port/public_key
*/
TCP_Client_Connection *new_TCP_connection(IP_Port ip_port, uint8_t *public_key, uint8_t *self_public_key,
uint8_t *self_secret_key);
TCP_Client_Connection *new_TCP_connection(IP_Port ip_port, const uint8_t *public_key, const uint8_t *self_public_key,
const uint8_t *self_secret_key);
/* Run the TCP connection
*/

View File

@ -751,7 +751,7 @@ static int send_data_packet(Net_Crypto *c, int crypt_connection_id, uint8_t *dat
* return 0 on success.
*/
static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint32_t buffer_start, uint32_t num,
uint8_t *data, uint32_t length)
const uint8_t *data, uint32_t length)
{
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE)
return -1;
@ -771,7 +771,7 @@ static int send_data_packet_helper(Net_Crypto *c, int crypt_connection_id, uint3
/* return -1 if data could not be put in packet queue.
* return positive packet number if data was put into the queue.
*/
static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint32_t length)
static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length)
{
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE)
return -1;
@ -1317,7 +1317,7 @@ static int wipe_crypto_connection(Net_Crypto *c, int crypt_connection_id)
* return -1 if there are no connections like we are looking for.
* return id if it found it.
*/
static int getcryptconnection_id(Net_Crypto *c, uint8_t *public_key)
static int getcryptconnection_id(Net_Crypto *c, const uint8_t *public_key)
{
uint32_t i;
@ -1493,7 +1493,7 @@ int accept_crypto_connection(Net_Crypto *c, New_Connection *n_c)
* return -1 on failure.
* return connection id on success.
*/
int new_crypto_connection(Net_Crypto *c, uint8_t *real_public_key)
int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key)
{
int crypt_connection_id = getcryptconnection_id(c, real_public_key);
@ -1790,7 +1790,7 @@ static int tcp_oob_callback(void *object, uint8_t *public_key, uint8_t *data, ui
* return -1 if it can't.
* return 0 if it can.
*/
static int tcp_connection_check(Net_Crypto *c, uint8_t *public_key)
static int tcp_connection_check(Net_Crypto *c, const uint8_t *public_key)
{
uint32_t i;
@ -1825,7 +1825,7 @@ static int tcp_connection_check(Net_Crypto *c, uint8_t *public_key)
* return 0 if it was added.
* return -1 if it wasn't.
*/
int add_tcp_relay_peer(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port, uint8_t *public_key)
int add_tcp_relay_peer(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port, const uint8_t *public_key)
{
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
@ -1878,7 +1878,7 @@ int add_tcp_relay_peer(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port,
* return 0 if it was added.
* return -1 if it wasn't.
*/
int add_tcp_relay(Net_Crypto *c, IP_Port ip_port, uint8_t *public_key)
int add_tcp_relay(Net_Crypto *c, IP_Port ip_port, const uint8_t *public_key)
{
if (ip_port.ip.family == TCP_INET) {
ip_port.ip.family = AF_INET;
@ -2119,7 +2119,7 @@ int connection_data_handler(Net_Crypto *c, int crypt_connection_id, int (*connec
* return 0 on success.
*/
int connection_lossy_data_handler(Net_Crypto *c, int crypt_connection_id,
int (*connection_lossy_data_callback)(void *object, int id, uint8_t *data, uint16_t length), void *object, int id)
int (*connection_lossy_data_callback)(void *object, int id, const uint8_t *data, uint16_t length), void *object, int id)
{
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
@ -2390,7 +2390,7 @@ uint32_t crypto_num_free_sendqueue_slots(Net_Crypto *c, int crypt_connection_id)
*
* The first byte of data must be in the CRYPTO_RESERVED_PACKETS to PACKET_ID_LOSSY_RANGE_START range.
*/
int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint32_t length)
int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length)
{
if (length == 0)
return -1;
@ -2427,7 +2427,7 @@ int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data,
*
* Sends a lossy cryptopacket. (first byte must in the PACKET_ID_LOSSY_RANGE_*)
*/
int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint32_t length)
int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length)
{
if (length == 0 || length > MAX_CRYPTO_DATA_SIZE)
return -1;

View File

@ -129,7 +129,7 @@ typedef struct {
void *connection_data_callback_object;
int connection_data_callback_id;
int (*connection_lossy_data_callback)(void *object, int id, uint8_t *data, uint16_t length);
int (*connection_lossy_data_callback)(void *object, int id, const uint8_t *data, uint16_t length);
void *connection_lossy_data_callback_object;
int connection_lossy_data_callback_id;
@ -220,7 +220,7 @@ int accept_crypto_connection(Net_Crypto *c, New_Connection *n_c);
* return -1 on failure.
* return connection id on success.
*/
int new_crypto_connection(Net_Crypto *c, uint8_t *real_public_key);
int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key);
/* Copy friends DHT public key into dht_key.
*
@ -279,7 +279,7 @@ int connection_data_handler(Net_Crypto *c, int crypt_connection_id, int (*connec
* return 0 on success.
*/
int connection_lossy_data_handler(Net_Crypto *c, int crypt_connection_id,
int (*connection_lossy_data_callback)(void *object, int id, uint8_t *data, uint16_t length), void *object, int id);
int (*connection_lossy_data_callback)(void *object, int id, const uint8_t *data, uint16_t length), void *object, int id);
/* returns the number of packet slots left in the sendbuffer.
* return 0 if failure.
@ -293,28 +293,28 @@ uint32_t crypto_num_free_sendqueue_slots(Net_Crypto *c, int crypt_connection_id)
*
* The first byte of data must be in the CRYPTO_RESERVED_PACKETS to PACKET_ID_LOSSY_RANGE_START range.
*/
int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint32_t length);
int64_t write_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length);
/* return -1 on failure.
* return 0 on success.
*
* Sends a lossy cryptopacket. (first byte must in the PACKET_ID_LOSSY_RANGE_*)
*/
int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uint32_t length);
int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t *data, uint32_t length);
/* Add a tcp relay, associating it to a crypt_connection_id.
*
* return 0 if it was added.
* return -1 if it wasn't.
*/
int add_tcp_relay_peer(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port, uint8_t *public_key);
int add_tcp_relay_peer(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port, const uint8_t *public_key);
/* Add a tcp relay to the array.
*
* return 0 if it was added.
* return -1 if it wasn't.
*/
int add_tcp_relay(Net_Crypto *c, IP_Port ip_port, uint8_t *public_key);
int add_tcp_relay(Net_Crypto *c, IP_Port ip_port, const uint8_t *public_key);
/* Copy a maximum of num TCP relays we are connected to to tcp_relays.
* NOTE that the family of the copied ip ports will be set to TCP_INET or TCP_INET6.

View File

@ -851,7 +851,7 @@ int onion_delfriend(Onion_Client *onion_c, int friend_num)
* return 0 on success.
*/
int recv_tcp_relay_handler(Onion_Client *onion_c, int friend_num, int (*tcp_relay_node_callback)(void *object,
uint32_t number, IP_Port ip_port, uint8_t *public_key), void *object, uint32_t number)
uint32_t number, IP_Port ip_port, const uint8_t *public_key), void *object, uint32_t number)
{
if ((uint32_t)friend_num >= onion_c->num_friends)
return -1;

View File

@ -97,7 +97,7 @@ typedef struct {
Last_Pinged last_pinged[MAX_STORED_PINGED_NODES];
uint8_t last_pinged_index;
int (*tcp_relay_node_callback)(void *object, uint32_t number, IP_Port ip_port, uint8_t *public_key);
int (*tcp_relay_node_callback)(void *object, uint32_t number, IP_Port ip_port, const uint8_t *public_key);
void *tcp_relay_node_callback_object;
uint32_t tcp_relay_node_callback_number;
} Onion_Friend;
@ -182,7 +182,7 @@ int onion_getfriendip(Onion_Client *onion_c, int friend_num, IP_Port *ip_port);
* return 0 on success.
*/
int recv_tcp_relay_handler(Onion_Client *onion_c, int friend_num, int (*tcp_relay_node_callback)(void *object,
uint32_t number, IP_Port ip_port, uint8_t *public_key), void *object, uint32_t number);
uint32_t number, IP_Port ip_port, const uint8_t *public_key), void *object, uint32_t number);
/* Set a friends DHT public key.
* timestamp is the time (current_time_monotonic()) at which the key was last confirmed belonging to

View File

@ -373,7 +373,7 @@ void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint
/* Set the function that will be executed when a message from a friend is received.
* Function format is: function(int32_t friendnumber, uint8_t * message, uint32_t length)
*/
void tox_callback_friend_message(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t *, uint16_t, void *),
void tox_callback_friend_message(Tox *tox, void (*function)(Messenger *tox, int32_t, const uint8_t *, uint16_t, void *),
void *userdata)
{
Messenger *m = tox;
@ -383,7 +383,7 @@ void tox_callback_friend_message(Tox *tox, void (*function)(Messenger *tox, int3
/* Set the function that will be executed when an action from a friend is received.
* function format is: function(int32_t friendnumber, uint8_t * action, uint32_t length)
*/
void tox_callback_friend_action(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t *, uint16_t, void *),
void tox_callback_friend_action(Tox *tox, void (*function)(Messenger *tox, int32_t, const uint8_t *, uint16_t, void *),
void *userdata)
{
Messenger *m = tox;
@ -394,7 +394,7 @@ void tox_callback_friend_action(Tox *tox, void (*function)(Messenger *tox, int32
* function(int32_t friendnumber, uint8_t *newname, uint16_t length)
* You are not responsible for freeing newname.
*/
void tox_callback_name_change(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t *, uint16_t, void *),
void tox_callback_name_change(Tox *tox, void (*function)(Messenger *tox, int32_t, const uint8_t *, uint16_t, void *),
void *userdata)
{
Messenger *m = tox;
@ -405,7 +405,7 @@ void tox_callback_name_change(Tox *tox, void (*function)(Messenger *tox, int32_t
* function(int32_t friendnumber, uint8_t *newstatus, uint16_t length)
* You are not responsible for freeing newstatus.
*/
void tox_callback_status_message(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t *, uint16_t, void *),
void tox_callback_status_message(Tox *tox, void (*function)(Messenger *tox, int32_t, const uint8_t *, uint16_t, void *),
void *userdata)
{
Messenger *m = tox;
@ -486,7 +486,7 @@ void tox_set_nospam(Tox *tox, uint32_t nospam)
*
* Function(Tox *tox, int32_t friendnumber, uint8_t *group_public_key, void *userdata)
*/
void tox_callback_group_invite(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t *, void *), void *userdata)
void tox_callback_group_invite(Tox *tox, void (*function)(Messenger *tox, int32_t, const uint8_t *, void *), void *userdata)
{
Messenger *m = tox;
m_callback_group_invite(m, function, userdata);
@ -496,7 +496,7 @@ void tox_callback_group_invite(Tox *tox, void (*function)(Messenger *tox, int32_
*
* Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
*/
void tox_callback_group_message(Tox *tox, void (*function)(Messenger *tox, int, int, uint8_t *, uint16_t, void *),
void tox_callback_group_message(Tox *tox, void (*function)(Messenger *tox, int, int, const uint8_t *, uint16_t, void *),
void *userdata)
{
Messenger *m = tox;
@ -507,7 +507,7 @@ void tox_callback_group_message(Tox *tox, void (*function)(Messenger *tox, int,
*
* Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * action, uint16_t length, void *userdata)
*/
void tox_callback_group_action(Tox *tox, void (*function)(Messenger *tox, int, int, uint8_t *, uint16_t, void *),
void tox_callback_group_action(Tox *tox, void (*function)(Messenger *tox, int, int, const uint8_t *, uint16_t, void *),
void *userdata)
{
Messenger *m = tox;
@ -651,7 +651,7 @@ uint32_t tox_get_chatlist(Tox *tox, int *out_list, uint32_t list_size)
*
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
*/
void tox_callback_file_send_request(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, uint64_t, uint8_t *,
void tox_callback_file_send_request(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, uint64_t, const uint8_t *,
uint16_t,
void *), void *userdata)
{
@ -663,7 +663,7 @@ void tox_callback_file_send_request(Tox *tox, void (*function)(Messenger *tox, i
* Function(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
*
*/
void tox_callback_file_control(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *,
void tox_callback_file_control(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, uint8_t, uint8_t, const uint8_t *,
uint16_t, void *), void *userdata)
{
Messenger *m = tox;
@ -674,7 +674,7 @@ void tox_callback_file_control(Tox *tox, void (*function)(Messenger *tox, int32_
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
*
*/
void tox_callback_file_data(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, uint8_t *, uint16_t length,
void tox_callback_file_data(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, const uint8_t *, uint16_t length,
void *),
void *userdata)

View File

@ -295,27 +295,27 @@ void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint
/* Set the function that will be executed when a message from a friend is received.
* Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * message, uint32_t length, void *userdata)
*/
void tox_callback_friend_message(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, uint16_t, void *),
void tox_callback_friend_message(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set the function that will be executed when an action from a friend is received.
* Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * action, uint32_t length, void *userdata)
*/
void tox_callback_friend_action(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, uint16_t, void *),
void tox_callback_friend_action(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set the callback for name changes.
* function(Tox *tox, int32_t friendnumber, uint8_t *newname, uint16_t length, void *userdata)
* You are not responsible for freeing newname
*/
void tox_callback_name_change(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, uint16_t, void *),
void tox_callback_name_change(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set the callback for status message changes.
* function(Tox *tox, int32_t friendnumber, uint8_t *newstatus, uint16_t length, void *userdata)
* You are not responsible for freeing newstatus.
*/
void tox_callback_status_message(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, uint16_t, void *),
void tox_callback_status_message(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set the callback for status type changes.
@ -367,20 +367,20 @@ void tox_set_nospam(Tox *tox, uint32_t nospam);
*
* Function(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata)
*/
void tox_callback_group_invite(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, void *), void *userdata);
void tox_callback_group_invite(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, void *), void *userdata);
/* Set the callback for group messages.
*
* Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
*/
void tox_callback_group_message(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t *, uint16_t, void *),
void tox_callback_group_message(Tox *tox, void (*function)(Tox *tox, int, int, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set the callback for group actions.
*
* Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * action, uint16_t length, void *userdata)
*/
void tox_callback_group_action(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t *, uint16_t, void *),
void tox_callback_group_action(Tox *tox, void (*function)(Tox *tox, int, int, const uint8_t *, uint16_t, void *),
void *userdata);
/* Set callback function for peer name list changes.
@ -523,7 +523,7 @@ enum {
*
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
*/
void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint64_t, uint8_t *, uint16_t,
void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint64_t, const uint8_t *, uint16_t,
void *), void *userdata);
/* Set the callback for file control requests.
@ -534,7 +534,7 @@ void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int32_t,
* Function(Tox *tox, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
*
*/
void tox_callback_file_control(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *,
void tox_callback_file_control(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint8_t, uint8_t, const uint8_t *,
uint16_t, void *), void *userdata);
/* Set the callback for file data.
@ -542,7 +542,7 @@ void tox_callback_file_control(Tox *tox, void (*function)(Tox *m, int32_t, uint8
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
*
*/
void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint8_t *, uint16_t length, void *),
void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, const uint8_t *, uint16_t length, void *),
void *userdata);