diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-09-18 01:31:55 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-09-24 21:53:50 +0100 |
commit | 15cb4261665bab4ef02a5b1b9db48b9477c9b87a (patch) | |
tree | d0c40a45afa19fff26ce1eb5bb703e18a9acdd4a /toxcore/tox.c | |
parent | 0d347c2b2e69aa09b079f6daaa00007fef4fe52f (diff) |
Make toxcore code C++ compatible.
It is still C code, so still compatible with C compilers as well. This
change lets us see more clearly where implicit conversions occur by
making them explicit.
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r-- | toxcore/tox.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c index 93993c53..bf664b41 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -158,7 +158,7 @@ void tox_options_default(struct Tox_Options *options) | |||
158 | 158 | ||
159 | struct Tox_Options *tox_options_new(TOX_ERR_OPTIONS_NEW *error) | 159 | struct Tox_Options *tox_options_new(TOX_ERR_OPTIONS_NEW *error) |
160 | { | 160 | { |
161 | struct Tox_Options *options = calloc(sizeof(struct Tox_Options), 1); | 161 | struct Tox_Options *options = (struct Tox_Options *)calloc(sizeof(struct Tox_Options), 1); |
162 | 162 | ||
163 | if (options) { | 163 | if (options) { |
164 | tox_options_default(options); | 164 | tox_options_default(options); |
@@ -303,7 +303,7 @@ void tox_kill(Tox *tox) | |||
303 | 303 | ||
304 | Messenger *m = tox; | 304 | Messenger *m = tox; |
305 | Logger *log = m->log; | 305 | Logger *log = m->log; |
306 | kill_groupchats(m->group_chat_object); | 306 | kill_groupchats((Group_Chats *)m->group_chat_object); |
307 | kill_messenger(m); | 307 | kill_messenger(m); |
308 | logger_kill(log); | 308 | logger_kill(log); |
309 | } | 309 | } |
@@ -463,7 +463,7 @@ TOX_CONNECTION tox_self_get_connection_status(const Tox *tox) | |||
463 | void tox_callback_self_connection_status(Tox *tox, tox_self_connection_status_cb *callback) | 463 | void tox_callback_self_connection_status(Tox *tox, tox_self_connection_status_cb *callback) |
464 | { | 464 | { |
465 | Messenger *m = tox; | 465 | Messenger *m = tox; |
466 | m_callback_core_connection(m, callback); | 466 | m_callback_core_connection(m, (void (*)(Messenger *, unsigned int, void *))callback); |
467 | } | 467 | } |
468 | 468 | ||
469 | uint32_t tox_iteration_interval(const Tox *tox) | 469 | uint32_t tox_iteration_interval(const Tox *tox) |
@@ -476,7 +476,7 @@ void tox_iterate(Tox *tox, void *user_data) | |||
476 | { | 476 | { |
477 | Messenger *m = tox; | 477 | Messenger *m = tox; |
478 | do_messenger(m, user_data); | 478 | do_messenger(m, user_data); |
479 | do_groupchats(m->group_chat_object, user_data); | 479 | do_groupchats((Group_Chats *)m->group_chat_object, user_data); |
480 | } | 480 | } |
481 | 481 | ||
482 | void tox_self_get_address(const Tox *tox, uint8_t *address) | 482 | void tox_self_get_address(const Tox *tox, uint8_t *address) |
@@ -528,7 +528,7 @@ bool tox_self_set_name(Tox *tox, const uint8_t *name, size_t length, TOX_ERR_SET | |||
528 | 528 | ||
529 | if (setname(m, name, length) == 0) { | 529 | if (setname(m, name, length) == 0) { |
530 | // TODO(irungentoo): function to set different per group names? | 530 | // TODO(irungentoo): function to set different per group names? |
531 | send_name_all_groups(m->group_chat_object); | 531 | send_name_all_groups((Group_Chats *)m->group_chat_object); |
532 | SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_OK); | 532 | SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_OK); |
533 | return 1; | 533 | return 1; |
534 | } | 534 | } |
@@ -592,7 +592,7 @@ void tox_self_set_status(Tox *tox, TOX_USER_STATUS status) | |||
592 | TOX_USER_STATUS tox_self_get_status(const Tox *tox) | 592 | TOX_USER_STATUS tox_self_get_status(const Tox *tox) |
593 | { | 593 | { |
594 | const Messenger *m = tox; | 594 | const Messenger *m = tox; |
595 | return m_get_self_userstatus(m); | 595 | return (TOX_USER_STATUS)m_get_self_userstatus(m); |
596 | } | 596 | } |
597 | 597 | ||
598 | static void set_friend_error(int32_t ret, TOX_ERR_FRIEND_ADD *error) | 598 | static void set_friend_error(int32_t ret, TOX_ERR_FRIEND_ADD *error) |
@@ -842,17 +842,17 @@ TOX_USER_STATUS tox_friend_get_status(const Tox *tox, uint32_t friend_number, TO | |||
842 | 842 | ||
843 | if (ret == USERSTATUS_INVALID) { | 843 | if (ret == USERSTATUS_INVALID) { |
844 | SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_FRIEND_NOT_FOUND); | 844 | SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_FRIEND_NOT_FOUND); |
845 | return TOX_USER_STATUS_BUSY + 1; | 845 | return (TOX_USER_STATUS)(TOX_USER_STATUS_BUSY + 1); |
846 | } | 846 | } |
847 | 847 | ||
848 | SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_OK); | 848 | SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_OK); |
849 | return ret; | 849 | return (TOX_USER_STATUS)ret; |
850 | } | 850 | } |
851 | 851 | ||
852 | void tox_callback_friend_status(Tox *tox, tox_friend_status_cb *callback) | 852 | void tox_callback_friend_status(Tox *tox, tox_friend_status_cb *callback) |
853 | { | 853 | { |
854 | Messenger *m = tox; | 854 | Messenger *m = tox; |
855 | m_callback_userstatus(m, callback); | 855 | m_callback_userstatus(m, (void (*)(Messenger *, uint32_t, unsigned int, void *))callback); |
856 | } | 856 | } |
857 | 857 | ||
858 | TOX_CONNECTION tox_friend_get_connection_status(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) | 858 | TOX_CONNECTION tox_friend_get_connection_status(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) |
@@ -867,13 +867,13 @@ TOX_CONNECTION tox_friend_get_connection_status(const Tox *tox, uint32_t friend_ | |||
867 | } | 867 | } |
868 | 868 | ||
869 | SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_OK); | 869 | SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_OK); |
870 | return ret; | 870 | return (TOX_CONNECTION)ret; |
871 | } | 871 | } |
872 | 872 | ||
873 | void tox_callback_friend_connection_status(Tox *tox, tox_friend_connection_status_cb *callback) | 873 | void tox_callback_friend_connection_status(Tox *tox, tox_friend_connection_status_cb *callback) |
874 | { | 874 | { |
875 | Messenger *m = tox; | 875 | Messenger *m = tox; |
876 | m_callback_connectionstatus(m, callback); | 876 | m_callback_connectionstatus(m, (void (*)(Messenger *, uint32_t, unsigned int, void *))callback); |
877 | } | 877 | } |
878 | 878 | ||
879 | bool tox_friend_get_typing(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) | 879 | bool tox_friend_get_typing(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) |
@@ -972,7 +972,7 @@ void tox_callback_friend_request(Tox *tox, tox_friend_request_cb *callback) | |||
972 | void tox_callback_friend_message(Tox *tox, tox_friend_message_cb *callback) | 972 | void tox_callback_friend_message(Tox *tox, tox_friend_message_cb *callback) |
973 | { | 973 | { |
974 | Messenger *m = tox; | 974 | Messenger *m = tox; |
975 | m_callback_friendmessage(m, callback); | 975 | m_callback_friendmessage(m, (void (*)(Messenger *, uint32_t, unsigned int, const uint8_t *, size_t, void *))callback); |
976 | } | 976 | } |
977 | 977 | ||
978 | bool tox_hash(uint8_t *hash, const uint8_t *data, size_t length) | 978 | bool tox_hash(uint8_t *hash, const uint8_t *data, size_t length) |
@@ -1079,7 +1079,7 @@ bool tox_file_seek(Tox *tox, uint32_t friend_number, uint32_t file_number, uint6 | |||
1079 | void tox_callback_file_recv_control(Tox *tox, tox_file_recv_control_cb *callback) | 1079 | void tox_callback_file_recv_control(Tox *tox, tox_file_recv_control_cb *callback) |
1080 | { | 1080 | { |
1081 | Messenger *m = tox; | 1081 | Messenger *m = tox; |
1082 | callback_file_control(m, callback); | 1082 | callback_file_control(m, (void (*)(Messenger *, uint32_t, uint32_t, unsigned int, void *))callback); |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | bool tox_file_get_file_id(const Tox *tox, uint32_t friend_number, uint32_t file_number, uint8_t *file_id, | 1085 | bool tox_file_get_file_id(const Tox *tox, uint32_t friend_number, uint32_t file_number, uint8_t *file_id, |