diff options
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 174 |
1 files changed, 87 insertions, 87 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 69bc845a..9f75f89f 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -34,16 +34,16 @@ | |||
34 | #define MIN(a,b) (((a)<(b))?(a):(b)) | 34 | #define MIN(a,b) (((a)<(b))?(a):(b)) |
35 | 35 | ||
36 | 36 | ||
37 | static void set_friend_status(Messenger *m, int friendnumber, uint8_t status); | 37 | static void set_friend_status(Messenger *m, int32_t friendnumber, uint8_t status); |
38 | static int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_id, uint8_t *data, uint32_t length); | 38 | static int write_cryptpacket_id(Messenger *m, int32_t friendnumber, uint8_t packet_id, uint8_t *data, uint32_t length); |
39 | 39 | ||
40 | // friend_not_valid determines if the friendnumber passed is valid in the Messenger object | 40 | // friend_not_valid determines if the friendnumber passed is valid in the Messenger object |
41 | static uint8_t friend_not_valid(Messenger *m, int friendnumber) | 41 | static uint8_t friend_not_valid(Messenger *m, int32_t friendnumber) |
42 | { | 42 | { |
43 | return (unsigned int)friendnumber >= m->numfriends; | 43 | return (unsigned int)friendnumber >= m->numfriends; |
44 | } | 44 | } |
45 | 45 | ||
46 | static int add_online_friend(Messenger *m, int friendnumber) | 46 | static int add_online_friend(Messenger *m, int32_t friendnumber) |
47 | { | 47 | { |
48 | if (friend_not_valid(m, friendnumber)) | 48 | if (friend_not_valid(m, friendnumber)) |
49 | return -1; | 49 | return -1; |
@@ -74,7 +74,7 @@ static int add_online_friend(Messenger *m, int friendnumber) | |||
74 | } | 74 | } |
75 | 75 | ||
76 | 76 | ||
77 | static int remove_online_friend(Messenger *m, int friendnumber) | 77 | static int remove_online_friend(Messenger *m, int32_t friendnumber) |
78 | { | 78 | { |
79 | uint32_t i; | 79 | uint32_t i; |
80 | Online_Friend *temp; | 80 | Online_Friend *temp; |
@@ -132,7 +132,7 @@ int realloc_friendlist(Messenger *m, uint32_t num) | |||
132 | /* return the friend id associated to that public key. | 132 | /* return the friend id associated to that public key. |
133 | * return -1 if no such friend. | 133 | * return -1 if no such friend. |
134 | */ | 134 | */ |
135 | int getfriend_id(Messenger *m, uint8_t *client_id) | 135 | int32_t getfriend_id(Messenger *m, uint8_t *client_id) |
136 | { | 136 | { |
137 | uint32_t i; | 137 | uint32_t i; |
138 | 138 | ||
@@ -151,13 +151,13 @@ int getfriend_id(Messenger *m, uint8_t *client_id) | |||
151 | * return 0 if success. | 151 | * return 0 if success. |
152 | * return -1 if failure. | 152 | * return -1 if failure. |
153 | */ | 153 | */ |
154 | int getclient_id(Messenger *m, int friend_id, uint8_t *client_id) | 154 | int getclient_id(Messenger *m, int32_t friendnumber, uint8_t *client_id) |
155 | { | 155 | { |
156 | if (friend_not_valid(m, friend_id)) | 156 | if (friend_not_valid(m, friendnumber)) |
157 | return -1; | 157 | return -1; |
158 | 158 | ||
159 | if (m->friendlist[friend_id].status > 0) { | 159 | if (m->friendlist[friendnumber].status > 0) { |
160 | memcpy(client_id, m->friendlist[friend_id].client_id, CLIENT_ID_SIZE); | 160 | memcpy(client_id, m->friendlist[friendnumber].client_id, CLIENT_ID_SIZE); |
161 | return 0; | 161 | return 0; |
162 | } | 162 | } |
163 | 163 | ||
@@ -210,7 +210,7 @@ void getaddress(Messenger *m, uint8_t *address) | |||
210 | * (the nospam for that friend was set to the new one). | 210 | * (the nospam for that friend was set to the new one). |
211 | * return FAERR_NOMEM if increasing the friend list size fails. | 211 | * return FAERR_NOMEM if increasing the friend list size fails. |
212 | */ | 212 | */ |
213 | int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length) | 213 | int32_t m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length) |
214 | { | 214 | { |
215 | if (length >= (MAX_DATA_SIZE - crypto_box_PUBLICKEYBYTES | 215 | if (length >= (MAX_DATA_SIZE - crypto_box_PUBLICKEYBYTES |
216 | - crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES | 216 | - crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES |
@@ -231,7 +231,7 @@ int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length) | |||
231 | if (id_equal(client_id, m->net_crypto->self_public_key)) | 231 | if (id_equal(client_id, m->net_crypto->self_public_key)) |
232 | return FAERR_OWNKEY; | 232 | return FAERR_OWNKEY; |
233 | 233 | ||
234 | int friend_id = getfriend_id(m, client_id); | 234 | int32_t friend_id = getfriend_id(m, client_id); |
235 | 235 | ||
236 | if (friend_id != -1) { | 236 | if (friend_id != -1) { |
237 | uint32_t nospam; | 237 | uint32_t nospam; |
@@ -250,7 +250,7 @@ int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length) | |||
250 | 250 | ||
251 | memset(&(m->friendlist[m->numfriends]), 0, sizeof(Friend)); | 251 | memset(&(m->friendlist[m->numfriends]), 0, sizeof(Friend)); |
252 | 252 | ||
253 | int onion_friendnum = onion_addfriend(m->onion_c, client_id); | 253 | int32_t onion_friendnum = onion_addfriend(m->onion_c, client_id); |
254 | 254 | ||
255 | if (onion_friendnum == -1) | 255 | if (onion_friendnum == -1) |
256 | return FAERR_UNKNOWN; | 256 | return FAERR_UNKNOWN; |
@@ -285,7 +285,7 @@ int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length) | |||
285 | return FAERR_UNKNOWN; | 285 | return FAERR_UNKNOWN; |
286 | } | 286 | } |
287 | 287 | ||
288 | int m_addfriend_norequest(Messenger *m, uint8_t *client_id) | 288 | int32_t m_addfriend_norequest(Messenger *m, uint8_t *client_id) |
289 | { | 289 | { |
290 | if (getfriend_id(m, client_id) != -1) | 290 | if (getfriend_id(m, client_id) != -1) |
291 | return -1; | 291 | return -1; |
@@ -299,7 +299,7 @@ int m_addfriend_norequest(Messenger *m, uint8_t *client_id) | |||
299 | 299 | ||
300 | memset(&(m->friendlist[m->numfriends]), 0, sizeof(Friend)); | 300 | memset(&(m->friendlist[m->numfriends]), 0, sizeof(Friend)); |
301 | 301 | ||
302 | int onion_friendnum = onion_addfriend(m->onion_c, client_id); | 302 | int32_t onion_friendnum = onion_addfriend(m->onion_c, client_id); |
303 | 303 | ||
304 | if (onion_friendnum == -1) | 304 | if (onion_friendnum == -1) |
305 | return FAERR_UNKNOWN; | 305 | return FAERR_UNKNOWN; |
@@ -335,7 +335,7 @@ int m_addfriend_norequest(Messenger *m, uint8_t *client_id) | |||
335 | * return 0 if success. | 335 | * return 0 if success. |
336 | * return -1 if failure. | 336 | * return -1 if failure. |
337 | */ | 337 | */ |
338 | int m_delfriend(Messenger *m, int friendnumber) | 338 | int m_delfriend(Messenger *m, int32_t friendnumber) |
339 | { | 339 | { |
340 | if (friend_not_valid(m, friendnumber)) | 340 | if (friend_not_valid(m, friendnumber)) |
341 | return -1; | 341 | return -1; |
@@ -362,7 +362,7 @@ int m_delfriend(Messenger *m, int friendnumber) | |||
362 | return 0; | 362 | return 0; |
363 | } | 363 | } |
364 | 364 | ||
365 | int m_get_friend_connectionstatus(Messenger *m, int friendnumber) | 365 | int m_get_friend_connectionstatus(Messenger *m, int32_t friendnumber) |
366 | { | 366 | { |
367 | if (friend_not_valid(m, friendnumber)) | 367 | if (friend_not_valid(m, friendnumber)) |
368 | return -1; | 368 | return -1; |
@@ -370,7 +370,7 @@ int m_get_friend_connectionstatus(Messenger *m, int friendnumber) | |||
370 | return m->friendlist[friendnumber].status == FRIEND_ONLINE; | 370 | return m->friendlist[friendnumber].status == FRIEND_ONLINE; |
371 | } | 371 | } |
372 | 372 | ||
373 | int m_friend_exists(Messenger *m, int friendnumber) | 373 | int m_friend_exists(Messenger *m, int32_t friendnumber) |
374 | { | 374 | { |
375 | if (friend_not_valid(m, friendnumber)) | 375 | if (friend_not_valid(m, friendnumber)) |
376 | return 0; | 376 | return 0; |
@@ -383,7 +383,7 @@ int m_friend_exists(Messenger *m, int friendnumber) | |||
383 | * return the message id if packet was successfully put into the send queue. | 383 | * return the message id if packet was successfully put into the send queue. |
384 | * return 0 if it was not. | 384 | * return 0 if it was not. |
385 | */ | 385 | */ |
386 | uint32_t m_sendmessage(Messenger *m, int friendnumber, uint8_t *message, uint32_t length) | 386 | uint32_t m_sendmessage(Messenger *m, int32_t friendnumber, uint8_t *message, uint32_t length) |
387 | { | 387 | { |
388 | if (friend_not_valid(m, friendnumber)) | 388 | if (friend_not_valid(m, friendnumber)) |
389 | return 0; | 389 | return 0; |
@@ -400,7 +400,7 @@ uint32_t m_sendmessage(Messenger *m, int friendnumber, uint8_t *message, uint32_ | |||
400 | return 0; | 400 | return 0; |
401 | } | 401 | } |
402 | 402 | ||
403 | uint32_t m_sendmessage_withid(Messenger *m, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length) | 403 | uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, uint8_t *message, uint32_t length) |
404 | { | 404 | { |
405 | if (length >= (MAX_DATA_SIZE - sizeof(theid))) | 405 | if (length >= (MAX_DATA_SIZE - sizeof(theid))) |
406 | return 0; | 406 | return 0; |
@@ -417,7 +417,7 @@ uint32_t m_sendmessage_withid(Messenger *m, int friendnumber, uint32_t theid, ui | |||
417 | * return the message id if packet was successfully put into the send queue. | 417 | * return the message id if packet was successfully put into the send queue. |
418 | * return 0 if it was not. | 418 | * return 0 if it was not. |
419 | */ | 419 | */ |
420 | uint32_t m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t length) | 420 | uint32_t m_sendaction(Messenger *m, int32_t friendnumber, uint8_t *action, uint32_t length) |
421 | { | 421 | { |
422 | if (friend_not_valid(m, friendnumber)) | 422 | if (friend_not_valid(m, friendnumber)) |
423 | return 0; | 423 | return 0; |
@@ -434,7 +434,7 @@ uint32_t m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t | |||
434 | return 0; | 434 | return 0; |
435 | } | 435 | } |
436 | 436 | ||
437 | uint32_t m_sendaction_withid(Messenger *m, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length) | 437 | uint32_t m_sendaction_withid(Messenger *m, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length) |
438 | { | 438 | { |
439 | if (length >= (MAX_DATA_SIZE - sizeof(theid))) | 439 | if (length >= (MAX_DATA_SIZE - sizeof(theid))) |
440 | return 0; | 440 | return 0; |
@@ -449,7 +449,7 @@ uint32_t m_sendaction_withid(Messenger *m, int friendnumber, uint32_t theid, uin | |||
449 | /* Send a name packet to friendnumber. | 449 | /* Send a name packet to friendnumber. |
450 | * length is the length with the NULL terminator. | 450 | * length is the length with the NULL terminator. |
451 | */ | 451 | */ |
452 | static int m_sendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t length) | 452 | static int m_sendname(Messenger *m, int32_t friendnumber, uint8_t *name, uint16_t length) |
453 | { | 453 | { |
454 | if (length > MAX_NAME_LENGTH || length == 0) | 454 | if (length > MAX_NAME_LENGTH || length == 0) |
455 | return 0; | 455 | return 0; |
@@ -462,7 +462,7 @@ static int m_sendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t le | |||
462 | * return 0 if success. | 462 | * return 0 if success. |
463 | * return -1 if failure. | 463 | * return -1 if failure. |
464 | */ | 464 | */ |
465 | int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t length) | 465 | int setfriendname(Messenger *m, int32_t friendnumber, uint8_t *name, uint16_t length) |
466 | { | 466 | { |
467 | if (friend_not_valid(m, friendnumber)) | 467 | if (friend_not_valid(m, friendnumber)) |
468 | return -1; | 468 | return -1; |
@@ -507,18 +507,15 @@ int setname(Messenger *m, uint8_t *name, uint16_t length) | |||
507 | * | 507 | * |
508 | * return the length of the name. | 508 | * return the length of the name. |
509 | */ | 509 | */ |
510 | uint16_t getself_name(Messenger *m, uint8_t *name, uint16_t nlen) | 510 | uint16_t getself_name(Messenger *m, uint8_t *name) |
511 | { | 511 | { |
512 | uint16_t len; | 512 | if (name == NULL) { |
513 | |||
514 | if (name == NULL || nlen == 0) { | ||
515 | return 0; | 513 | return 0; |
516 | } | 514 | } |
517 | 515 | ||
518 | len = MIN(nlen, m->name_length); | 516 | memcpy(name, m->name, m->name_length); |
519 | memcpy(name, m->name, len); | ||
520 | 517 | ||
521 | return len; | 518 | return m->name_length; |
522 | } | 519 | } |
523 | 520 | ||
524 | /* Get name of friendnumber and put it in name. | 521 | /* Get name of friendnumber and put it in name. |
@@ -527,7 +524,7 @@ uint16_t getself_name(Messenger *m, uint8_t *name, uint16_t nlen) | |||
527 | * return length of name if success. | 524 | * return length of name if success. |
528 | * return -1 if failure. | 525 | * return -1 if failure. |
529 | */ | 526 | */ |
530 | int getname(Messenger *m, int friendnumber, uint8_t *name) | 527 | int getname(Messenger *m, int32_t friendnumber, uint8_t *name) |
531 | { | 528 | { |
532 | if (friend_not_valid(m, friendnumber)) | 529 | if (friend_not_valid(m, friendnumber)) |
533 | return -1; | 530 | return -1; |
@@ -570,7 +567,7 @@ int m_set_userstatus(Messenger *m, USERSTATUS status) | |||
570 | /* return the size of friendnumber's user status. | 567 | /* return the size of friendnumber's user status. |
571 | * Guaranteed to be at most MAX_STATUSMESSAGE_LENGTH. | 568 | * Guaranteed to be at most MAX_STATUSMESSAGE_LENGTH. |
572 | */ | 569 | */ |
573 | int m_get_statusmessage_size(Messenger *m, int friendnumber) | 570 | int m_get_statusmessage_size(Messenger *m, int32_t friendnumber) |
574 | { | 571 | { |
575 | if (friend_not_valid(m, friendnumber)) | 572 | if (friend_not_valid(m, friendnumber)) |
576 | return -1; | 573 | return -1; |
@@ -581,7 +578,7 @@ int m_get_statusmessage_size(Messenger *m, int friendnumber) | |||
581 | /* Copy the user status of friendnumber into buf, truncating if needed to maxlen | 578 | /* Copy the user status of friendnumber into buf, truncating if needed to maxlen |
582 | * bytes, use m_get_statusmessage_size to find out how much you need to allocate. | 579 | * bytes, use m_get_statusmessage_size to find out how much you need to allocate. |
583 | */ | 580 | */ |
584 | int m_copy_statusmessage(Messenger *m, int friendnumber, uint8_t *buf, uint32_t maxlen) | 581 | int m_copy_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *buf, uint32_t maxlen) |
585 | { | 582 | { |
586 | if (friend_not_valid(m, friendnumber)) | 583 | if (friend_not_valid(m, friendnumber)) |
587 | return -1; | 584 | return -1; |
@@ -598,7 +595,7 @@ int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen) | |||
598 | return MIN(maxlen, m->statusmessage_length); | 595 | return MIN(maxlen, m->statusmessage_length); |
599 | } | 596 | } |
600 | 597 | ||
601 | USERSTATUS m_get_userstatus(Messenger *m, int friendnumber) | 598 | USERSTATUS m_get_userstatus(Messenger *m, int32_t friendnumber) |
602 | { | 599 | { |
603 | if (friend_not_valid(m, friendnumber)) | 600 | if (friend_not_valid(m, friendnumber)) |
604 | return USERSTATUS_INVALID; | 601 | return USERSTATUS_INVALID; |
@@ -617,7 +614,7 @@ USERSTATUS m_get_self_userstatus(Messenger *m) | |||
617 | return m->userstatus; | 614 | return m->userstatus; |
618 | } | 615 | } |
619 | 616 | ||
620 | int m_set_usertyping(Messenger *m, int friendnumber, uint8_t is_typing) | 617 | int m_set_usertyping(Messenger *m, int32_t friendnumber, uint8_t is_typing) |
621 | { | 618 | { |
622 | if (is_typing != 0 && is_typing != 1) { | 619 | if (is_typing != 0 && is_typing != 1) { |
623 | return -1; | 620 | return -1; |
@@ -632,7 +629,7 @@ int m_set_usertyping(Messenger *m, int friendnumber, uint8_t is_typing) | |||
632 | return 0; | 629 | return 0; |
633 | } | 630 | } |
634 | 631 | ||
635 | int m_get_istyping(Messenger *m, int friendnumber) | 632 | int m_get_istyping(Messenger *m, int32_t friendnumber) |
636 | { | 633 | { |
637 | if (friend_not_valid(m, friendnumber)) | 634 | if (friend_not_valid(m, friendnumber)) |
638 | return -1; | 635 | return -1; |
@@ -640,24 +637,24 @@ int m_get_istyping(Messenger *m, int friendnumber) | |||
640 | return m->friendlist[friendnumber].is_typing; | 637 | return m->friendlist[friendnumber].is_typing; |
641 | } | 638 | } |
642 | 639 | ||
643 | static int send_statusmessage(Messenger *m, int friendnumber, uint8_t *status, uint16_t length) | 640 | static int send_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *status, uint16_t length) |
644 | { | 641 | { |
645 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_STATUSMESSAGE, status, length); | 642 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_STATUSMESSAGE, status, length); |
646 | } | 643 | } |
647 | 644 | ||
648 | static int send_userstatus(Messenger *m, int friendnumber, USERSTATUS status) | 645 | static int send_userstatus(Messenger *m, int32_t friendnumber, USERSTATUS status) |
649 | { | 646 | { |
650 | uint8_t stat = status; | 647 | uint8_t stat = status; |
651 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_USERSTATUS, &stat, sizeof(stat)); | 648 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_USERSTATUS, &stat, sizeof(stat)); |
652 | } | 649 | } |
653 | 650 | ||
654 | static int send_user_istyping(Messenger *m, int friendnumber, uint8_t is_typing) | 651 | static int send_user_istyping(Messenger *m, int32_t friendnumber, uint8_t is_typing) |
655 | { | 652 | { |
656 | uint8_t typing = is_typing; | 653 | uint8_t typing = is_typing; |
657 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_TYPING, &typing, sizeof(typing)); | 654 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_TYPING, &typing, sizeof(typing)); |
658 | } | 655 | } |
659 | 656 | ||
660 | static int send_ping(Messenger *m, int friendnumber) | 657 | static int send_ping(Messenger *m, int32_t friendnumber) |
661 | { | 658 | { |
662 | int ret = write_cryptpacket_id(m, friendnumber, PACKET_ID_PING, 0, 0); | 659 | int ret = write_cryptpacket_id(m, friendnumber, PACKET_ID_PING, 0, 0); |
663 | 660 | ||
@@ -667,7 +664,7 @@ static int send_ping(Messenger *m, int friendnumber) | |||
667 | return ret; | 664 | return ret; |
668 | } | 665 | } |
669 | 666 | ||
670 | static int set_friend_statusmessage(Messenger *m, int friendnumber, uint8_t *status, uint16_t length) | 667 | static int set_friend_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *status, uint16_t length) |
671 | { | 668 | { |
672 | if (friend_not_valid(m, friendnumber)) | 669 | if (friend_not_valid(m, friendnumber)) |
673 | return -1; | 670 | return -1; |
@@ -680,18 +677,18 @@ static int set_friend_statusmessage(Messenger *m, int friendnumber, uint8_t *sta | |||
680 | return 0; | 677 | return 0; |
681 | } | 678 | } |
682 | 679 | ||
683 | static void set_friend_userstatus(Messenger *m, int friendnumber, USERSTATUS status) | 680 | static void set_friend_userstatus(Messenger *m, int32_t friendnumber, USERSTATUS status) |
684 | { | 681 | { |
685 | m->friendlist[friendnumber].userstatus = status; | 682 | m->friendlist[friendnumber].userstatus = status; |
686 | } | 683 | } |
687 | 684 | ||
688 | static void set_friend_typing(Messenger *m, int friendnumber, uint8_t is_typing) | 685 | static void set_friend_typing(Messenger *m, int32_t friendnumber, uint8_t is_typing) |
689 | { | 686 | { |
690 | m->friendlist[friendnumber].is_typing = is_typing; | 687 | m->friendlist[friendnumber].is_typing = is_typing; |
691 | } | 688 | } |
692 | 689 | ||
693 | /* Sets whether we send read receipts for friendnumber. */ | 690 | /* Sets whether we send read receipts for friendnumber. */ |
694 | void m_set_sends_receipts(Messenger *m, int friendnumber, int yesno) | 691 | void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno) |
695 | { | 692 | { |
696 | if (yesno != 0 && yesno != 1) | 693 | if (yesno != 0 && yesno != 1) |
697 | return; | 694 | return; |
@@ -710,66 +707,67 @@ void m_callback_friendrequest(Messenger *m, void (*function)(uint8_t *, uint8_t | |||
710 | } | 707 | } |
711 | 708 | ||
712 | /* Set the function that will be executed when a message from a friend is received. */ | 709 | /* Set the function that will be executed when a message from a friend is received. */ |
713 | void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), | 710 | void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *), |
714 | void *userdata) | 711 | void *userdata) |
715 | { | 712 | { |
716 | m->friend_message = function; | 713 | m->friend_message = function; |
717 | m->friend_message_userdata = userdata; | 714 | m->friend_message_userdata = userdata; |
718 | } | 715 | } |
719 | 716 | ||
720 | void m_callback_action(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), void *userdata) | 717 | void m_callback_action(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *), |
718 | void *userdata) | ||
721 | { | 719 | { |
722 | m->friend_action = function; | 720 | m->friend_action = function; |
723 | m->friend_action_userdata = userdata; | 721 | m->friend_action_userdata = userdata; |
724 | } | 722 | } |
725 | 723 | ||
726 | void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), | 724 | void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *), |
727 | void *userdata) | 725 | void *userdata) |
728 | { | 726 | { |
729 | m->friend_namechange = function; | 727 | m->friend_namechange = function; |
730 | m->friend_namechange_userdata = userdata; | 728 | m->friend_namechange_userdata = userdata; |
731 | } | 729 | } |
732 | 730 | ||
733 | void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), | 731 | void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *), |
734 | void *userdata) | 732 | void *userdata) |
735 | { | 733 | { |
736 | m->friend_statusmessagechange = function; | 734 | m->friend_statusmessagechange = function; |
737 | m->friend_statuschange_userdata = userdata; | 735 | m->friend_statuschange_userdata = userdata; |
738 | } | 736 | } |
739 | 737 | ||
740 | void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int, USERSTATUS, void *), void *userdata) | 738 | void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int32_t, USERSTATUS, void *), void *userdata) |
741 | { | 739 | { |
742 | m->friend_userstatuschange = function; | 740 | m->friend_userstatuschange = function; |
743 | m->friend_userstatuschange_userdata = userdata; | 741 | m->friend_userstatuschange_userdata = userdata; |
744 | } | 742 | } |
745 | 743 | ||
746 | void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int, int, void *), void *userdata) | 744 | void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int32_t, int, void *), void *userdata) |
747 | { | 745 | { |
748 | m->friend_typingchange = function; | 746 | m->friend_typingchange = function; |
749 | m->friend_typingchange_userdata = userdata; | 747 | m->friend_typingchange_userdata = userdata; |
750 | } | 748 | } |
751 | 749 | ||
752 | void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int, uint32_t, void *), void *userdata) | 750 | void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int32_t, uint32_t, void *), void *userdata) |
753 | { | 751 | { |
754 | m->read_receipt = function; | 752 | m->read_receipt = function; |
755 | m->read_receipt_userdata = userdata; | 753 | m->read_receipt_userdata = userdata; |
756 | } | 754 | } |
757 | 755 | ||
758 | void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int, uint8_t, void *), void *userdata) | 756 | void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *), void *userdata) |
759 | { | 757 | { |
760 | m->friend_connectionstatuschange = function; | 758 | m->friend_connectionstatuschange = function; |
761 | m->friend_connectionstatuschange_userdata = userdata; | 759 | m->friend_connectionstatuschange_userdata = userdata; |
762 | } | 760 | } |
763 | 761 | ||
764 | void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, int, uint8_t, void *), | 762 | void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *), |
765 | void *userdata) | 763 | void *userdata) |
766 | { | 764 | { |
767 | m->friend_connectionstatuschange_internal = function; | 765 | m->friend_connectionstatuschange_internal = function; |
768 | m->friend_connectionstatuschange_internal_userdata = userdata; | 766 | m->friend_connectionstatuschange_internal_userdata = userdata; |
769 | } | 767 | } |
770 | 768 | ||
771 | static void break_files(Messenger *m, int friendnumber); | 769 | static void break_files(Messenger *m, int32_t friendnumber); |
772 | static void check_friend_connectionstatus(Messenger *m, int friendnumber, uint8_t status) | 770 | static void check_friend_connectionstatus(Messenger *m, int32_t friendnumber, uint8_t status) |
773 | { | 771 | { |
774 | if (status == NOFRIEND) | 772 | if (status == NOFRIEND) |
775 | return; | 773 | return; |
@@ -796,13 +794,13 @@ static void check_friend_connectionstatus(Messenger *m, int friendnumber, uint8_ | |||
796 | } | 794 | } |
797 | } | 795 | } |
798 | 796 | ||
799 | void set_friend_status(Messenger *m, int friendnumber, uint8_t status) | 797 | void set_friend_status(Messenger *m, int32_t friendnumber, uint8_t status) |
800 | { | 798 | { |
801 | check_friend_connectionstatus(m, friendnumber, status); | 799 | check_friend_connectionstatus(m, friendnumber, status); |
802 | m->friendlist[friendnumber].status = status; | 800 | m->friendlist[friendnumber].status = status; |
803 | } | 801 | } |
804 | 802 | ||
805 | int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_id, uint8_t *data, uint32_t length) | 803 | int write_cryptpacket_id(Messenger *m, int32_t friendnumber, uint8_t packet_id, uint8_t *data, uint32_t length) |
806 | { | 804 | { |
807 | if (friend_not_valid(m, friendnumber)) | 805 | if (friend_not_valid(m, friendnumber)) |
808 | return 0; | 806 | return 0; |
@@ -842,7 +840,7 @@ static uint8_t groupnumber_not_valid(Messenger *m, int groupnumber) | |||
842 | /* returns valid ip port of connected friend on success | 840 | /* returns valid ip port of connected friend on success |
843 | * returns zeroed out IP_Port on failure | 841 | * returns zeroed out IP_Port on failure |
844 | */ | 842 | */ |
845 | IP_Port get_friend_ipport(Messenger *m, int friendnumber) | 843 | IP_Port get_friend_ipport(Messenger *m, int32_t friendnumber) |
846 | { | 844 | { |
847 | IP_Port zero; | 845 | IP_Port zero; |
848 | memset(&zero, 0, sizeof(zero)); | 846 | memset(&zero, 0, sizeof(zero)); |
@@ -876,9 +874,9 @@ static int group_num(Messenger *m, uint8_t *group_public_key) | |||
876 | 874 | ||
877 | /* Set the callback for group invites. | 875 | /* Set the callback for group invites. |
878 | * | 876 | * |
879 | * Function(Messenger *m, int friendnumber, uint8_t *group_public_key, void *userdata) | 877 | * Function(Messenger *m, int32_t friendnumber, uint8_t *group_public_key, void *userdata) |
880 | */ | 878 | */ |
881 | void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, void *), void *userdata) | 879 | void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, void *), void *userdata) |
882 | { | 880 | { |
883 | m->group_invite = function; | 881 | m->group_invite = function; |
884 | m->group_invite_userdata = userdata; | 882 | m->group_invite_userdata = userdata; |
@@ -1081,7 +1079,7 @@ int m_group_peername(Messenger *m, int groupnumber, int peernumber, uint8_t *nam | |||
1081 | 1079 | ||
1082 | /* Store the fact that we invited a specific friend. | 1080 | /* Store the fact that we invited a specific friend. |
1083 | */ | 1081 | */ |
1084 | static void group_store_friendinvite(Messenger *m, int friendnumber, int groupnumber) | 1082 | static void group_store_friendinvite(Messenger *m, int32_t friendnumber, int groupnumber) |
1085 | { | 1083 | { |
1086 | /* Add 1 to the groupchat number because 0 (default value in invited_groups) is a valid groupchat number */ | 1084 | /* Add 1 to the groupchat number because 0 (default value in invited_groups) is a valid groupchat number */ |
1087 | m->friendlist[friendnumber].invited_groups[m->friendlist[friendnumber].invited_groups_num % MAX_INVITED_GROUPS] = | 1085 | m->friendlist[friendnumber].invited_groups[m->friendlist[friendnumber].invited_groups_num % MAX_INVITED_GROUPS] = |
@@ -1092,7 +1090,7 @@ static void group_store_friendinvite(Messenger *m, int friendnumber, int groupnu | |||
1092 | /* return 1 if that friend was invited to the group | 1090 | /* return 1 if that friend was invited to the group |
1093 | * return 0 if the friend was not or error. | 1091 | * return 0 if the friend was not or error. |
1094 | */ | 1092 | */ |
1095 | static uint8_t group_invited(Messenger *m, int friendnumber, int groupnumber) | 1093 | static uint8_t group_invited(Messenger *m, int32_t friendnumber, int groupnumber) |
1096 | { | 1094 | { |
1097 | 1095 | ||
1098 | uint32_t i; | 1096 | uint32_t i; |
@@ -1114,7 +1112,7 @@ static uint8_t group_invited(Messenger *m, int friendnumber, int groupnumber) | |||
1114 | * return 0 on success | 1112 | * return 0 on success |
1115 | * return -1 on failure | 1113 | * return -1 on failure |
1116 | */ | 1114 | */ |
1117 | int invite_friend(Messenger *m, int friendnumber, int groupnumber) | 1115 | int invite_friend(Messenger *m, int32_t friendnumber, int groupnumber) |
1118 | { | 1116 | { |
1119 | if (friend_not_valid(m, friendnumber) || (unsigned int)groupnumber >= m->numchats) | 1117 | if (friend_not_valid(m, friendnumber) || (unsigned int)groupnumber >= m->numchats) |
1120 | return -1; | 1118 | return -1; |
@@ -1140,7 +1138,7 @@ int invite_friend(Messenger *m, int friendnumber, int groupnumber) | |||
1140 | * returns group number on success | 1138 | * returns group number on success |
1141 | * returns -1 on failure. | 1139 | * returns -1 on failure. |
1142 | */ | 1140 | */ |
1143 | int join_groupchat(Messenger *m, int friendnumber, uint8_t *friend_group_public_key) | 1141 | int join_groupchat(Messenger *m, int32_t friendnumber, uint8_t *friend_group_public_key) |
1144 | { | 1142 | { |
1145 | if (friend_not_valid(m, friendnumber)) | 1143 | if (friend_not_valid(m, friendnumber)) |
1146 | return -1; | 1144 | return -1; |
@@ -1257,9 +1255,10 @@ static void do_allgroupchats(Messenger *m) | |||
1257 | 1255 | ||
1258 | /* Set the callback for file send requests. | 1256 | /* Set the callback for file send requests. |
1259 | * | 1257 | * |
1260 | * Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) | 1258 | * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) |
1261 | */ | 1259 | */ |
1262 | void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint64_t, uint8_t *, uint16_t, | 1260 | void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *, |
1261 | uint16_t, | ||
1263 | void *), void *userdata) | 1262 | void *), void *userdata) |
1264 | { | 1263 | { |
1265 | m->file_sendrequest = function; | 1264 | m->file_sendrequest = function; |
@@ -1268,10 +1267,10 @@ void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int, | |||
1268 | 1267 | ||
1269 | /* Set the callback for file control requests. | 1268 | /* Set the callback for file control requests. |
1270 | * | 1269 | * |
1271 | * Function(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata) | 1270 | * 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) |
1272 | * | 1271 | * |
1273 | */ | 1272 | */ |
1274 | void callback_file_control(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint8_t, uint8_t, uint8_t *, | 1273 | void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *, |
1275 | uint16_t, | 1274 | uint16_t, |
1276 | void *), void *userdata) | 1275 | void *), void *userdata) |
1277 | { | 1276 | { |
@@ -1281,10 +1280,11 @@ void callback_file_control(Messenger *m, void (*function)(Messenger *m, int, uin | |||
1281 | 1280 | ||
1282 | /* Set the callback for file data. | 1281 | /* Set the callback for file data. |
1283 | * | 1282 | * |
1284 | * Function(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata) | 1283 | * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata) |
1285 | * | 1284 | * |
1286 | */ | 1285 | */ |
1287 | void callback_file_data(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint8_t *, uint16_t length, void *), | 1286 | void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length, |
1287 | void *), | ||
1288 | void *userdata) | 1288 | void *userdata) |
1289 | { | 1289 | { |
1290 | m->file_filedata = function; | 1290 | m->file_filedata = function; |
@@ -1298,7 +1298,7 @@ void callback_file_data(Messenger *m, void (*function)(Messenger *m, int, uint8_ | |||
1298 | * return 1 on success | 1298 | * return 1 on success |
1299 | * return 0 on failure | 1299 | * return 0 on failure |
1300 | */ | 1300 | */ |
1301 | int file_sendrequest(Messenger *m, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, | 1301 | int file_sendrequest(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, |
1302 | uint16_t filename_length) | 1302 | uint16_t filename_length) |
1303 | { | 1303 | { |
1304 | if (friend_not_valid(m, friendnumber)) | 1304 | if (friend_not_valid(m, friendnumber)) |
@@ -1321,7 +1321,7 @@ int file_sendrequest(Messenger *m, int friendnumber, uint8_t filenumber, uint64_ | |||
1321 | * return file number on success | 1321 | * return file number on success |
1322 | * return -1 on failure | 1322 | * return -1 on failure |
1323 | */ | 1323 | */ |
1324 | int new_filesender(Messenger *m, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length) | 1324 | int new_filesender(Messenger *m, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length) |
1325 | { | 1325 | { |
1326 | if (friend_not_valid(m, friendnumber)) | 1326 | if (friend_not_valid(m, friendnumber)) |
1327 | return -1; | 1327 | return -1; |
@@ -1351,7 +1351,7 @@ int new_filesender(Messenger *m, int friendnumber, uint64_t filesize, uint8_t *f | |||
1351 | * return 0 on success | 1351 | * return 0 on success |
1352 | * return -1 on failure | 1352 | * return -1 on failure |
1353 | */ | 1353 | */ |
1354 | int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, | 1354 | int file_control(Messenger *m, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, |
1355 | uint8_t *data, uint16_t length) | 1355 | uint8_t *data, uint16_t length) |
1356 | { | 1356 | { |
1357 | if (length > MAX_DATA_SIZE - 3) | 1357 | if (length > MAX_DATA_SIZE - 3) |
@@ -1439,7 +1439,7 @@ int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t f | |||
1439 | * return 0 on success | 1439 | * return 0 on success |
1440 | * return -1 on failure | 1440 | * return -1 on failure |
1441 | */ | 1441 | */ |
1442 | int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length) | 1442 | int file_data(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length) |
1443 | { | 1443 | { |
1444 | if (length > MAX_DATA_SIZE - 1) | 1444 | if (length > MAX_DATA_SIZE - 1) |
1445 | return -1; | 1445 | return -1; |
@@ -1474,7 +1474,7 @@ int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data, | |||
1474 | * return number of bytes remaining to be sent/received on success | 1474 | * return number of bytes remaining to be sent/received on success |
1475 | * return 0 on failure | 1475 | * return 0 on failure |
1476 | */ | 1476 | */ |
1477 | uint64_t file_dataremaining(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t send_receive) | 1477 | uint64_t file_dataremaining(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive) |
1478 | { | 1478 | { |
1479 | if (friend_not_valid(m, friendnumber)) | 1479 | if (friend_not_valid(m, friendnumber)) |
1480 | return 0; | 1480 | return 0; |
@@ -1497,7 +1497,7 @@ uint64_t file_dataremaining(Messenger *m, int friendnumber, uint8_t filenumber, | |||
1497 | /* Run this when the friend disconnects. | 1497 | /* Run this when the friend disconnects. |
1498 | * Sets all current file transfers to broken. | 1498 | * Sets all current file transfers to broken. |
1499 | */ | 1499 | */ |
1500 | static void break_files(Messenger *m, int friendnumber) | 1500 | static void break_files(Messenger *m, int32_t friendnumber) |
1501 | { | 1501 | { |
1502 | uint32_t i; | 1502 | uint32_t i; |
1503 | 1503 | ||
@@ -1510,7 +1510,7 @@ static void break_files(Messenger *m, int friendnumber) | |||
1510 | } | 1510 | } |
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | static int handle_filecontrol(Messenger *m, int friendnumber, uint8_t receive_send, uint8_t filenumber, | 1513 | static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber, |
1514 | uint8_t message_id, uint8_t *data, | 1514 | uint8_t message_id, uint8_t *data, |
1515 | uint16_t length) | 1515 | uint16_t length) |
1516 | { | 1516 | { |
@@ -1600,7 +1600,7 @@ static int handle_filecontrol(Messenger *m, int friendnumber, uint8_t receive_se | |||
1600 | * | 1600 | * |
1601 | * Function(Messenger *m, int friendnumber, uint8_t *data, uint16_t length, void *userdata) | 1601 | * Function(Messenger *m, int friendnumber, uint8_t *data, uint16_t length, void *userdata) |
1602 | */ | 1602 | */ |
1603 | void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), | 1603 | void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *), |
1604 | void *userdata) | 1604 | void *userdata) |
1605 | { | 1605 | { |
1606 | m->msi_packet = function; | 1606 | m->msi_packet = function; |
@@ -1612,12 +1612,12 @@ void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int, uin | |||
1612 | * return 1 on success | 1612 | * return 1 on success |
1613 | * return 0 on failure | 1613 | * return 0 on failure |
1614 | */ | 1614 | */ |
1615 | int m_msi_packet(Messenger *m, int friendnumber, uint8_t *data, uint16_t length) | 1615 | int m_msi_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length) |
1616 | { | 1616 | { |
1617 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_MSI, data, length); | 1617 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_MSI, data, length); |
1618 | } | 1618 | } |
1619 | 1619 | ||
1620 | static int friendnum_from_ip_port(Messenger *m, IP_Port ip_port) | 1620 | static int32_t friendnum_from_ip_port(Messenger *m, IP_Port ip_port) |
1621 | { | 1621 | { |
1622 | uint32_t i; | 1622 | uint32_t i; |
1623 | 1623 | ||
@@ -1632,7 +1632,7 @@ static int friendnum_from_ip_port(Messenger *m, IP_Port ip_port) | |||
1632 | static int handle_custom_user_packet(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 1632 | static int handle_custom_user_packet(void *object, IP_Port source, uint8_t *packet, uint32_t length) |
1633 | { | 1633 | { |
1634 | Messenger *m = object; | 1634 | Messenger *m = object; |
1635 | int friend_num = friendnum_from_ip_port(m, source); | 1635 | int32_t friend_num = friendnum_from_ip_port(m, source); |
1636 | 1636 | ||
1637 | if (friend_num == -1) | 1637 | if (friend_num == -1) |
1638 | return 1; | 1638 | return 1; |
@@ -1645,7 +1645,7 @@ static int handle_custom_user_packet(void *object, IP_Port source, uint8_t *pack | |||
1645 | } | 1645 | } |
1646 | 1646 | ||
1647 | 1647 | ||
1648 | int custom_user_packet_registerhandler(Messenger *m, int friendnumber, uint8_t byte, packet_handler_callback cb, | 1648 | int custom_user_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte, packet_handler_callback cb, |
1649 | void *object) | 1649 | void *object) |
1650 | { | 1650 | { |
1651 | if (friend_not_valid(m, friendnumber)) | 1651 | if (friend_not_valid(m, friendnumber)) |
@@ -1660,7 +1660,7 @@ int custom_user_packet_registerhandler(Messenger *m, int friendnumber, uint8_t b | |||
1660 | return 0; | 1660 | return 0; |
1661 | } | 1661 | } |
1662 | 1662 | ||
1663 | int send_custom_user_packet(Messenger *m, int friendnumber, uint8_t *data, uint32_t length) | 1663 | int send_custom_user_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length) |
1664 | { | 1664 | { |
1665 | IP_Port ip_port = get_friend_ipport(m, friendnumber); | 1665 | IP_Port ip_port = get_friend_ipport(m, friendnumber); |
1666 | 1666 | ||
@@ -2573,7 +2573,7 @@ uint32_t get_num_online_friends(Messenger *m) | |||
2573 | * Otherwise, returns the number of elements copied. | 2573 | * Otherwise, returns the number of elements copied. |
2574 | * If the array was too small, the contents | 2574 | * If the array was too small, the contents |
2575 | * of out_list will be truncated to list_size. */ | 2575 | * of out_list will be truncated to list_size. */ |
2576 | uint32_t copy_friendlist(Messenger *m, int *out_list, uint32_t list_size) | 2576 | uint32_t copy_friendlist(Messenger *m, int32_t *out_list, uint32_t list_size) |
2577 | { | 2577 | { |
2578 | if (!out_list) | 2578 | if (!out_list) |
2579 | return 0; | 2579 | return 0; |
@@ -2605,7 +2605,7 @@ uint32_t copy_friendlist(Messenger *m, int *out_list, uint32_t list_size) | |||
2605 | * retun 0 if success. | 2605 | * retun 0 if success. |
2606 | * return -1 if failure. | 2606 | * return -1 if failure. |
2607 | */ | 2607 | */ |
2608 | int get_friendlist(Messenger *m, int **out_list, uint32_t *out_list_length) | 2608 | int get_friendlist(Messenger *m, int32_t **out_list, uint32_t *out_list_length) |
2609 | { | 2609 | { |
2610 | uint32_t i; | 2610 | uint32_t i; |
2611 | 2611 | ||
@@ -2616,7 +2616,7 @@ int get_friendlist(Messenger *m, int **out_list, uint32_t *out_list_length) | |||
2616 | return 0; | 2616 | return 0; |
2617 | } | 2617 | } |
2618 | 2618 | ||
2619 | *out_list = malloc(m->numfriends * sizeof(int)); | 2619 | *out_list = malloc(m->numfriends * sizeof(int32_t)); |
2620 | 2620 | ||
2621 | if (*out_list == NULL) { | 2621 | if (*out_list == NULL) { |
2622 | return -1; | 2622 | return -1; |