diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-07-08 15:41:13 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-08 18:06:39 +0000 |
commit | 819fe534ea62b07340b20f18841d1ed93cf5caff (patch) | |
tree | ab2dd90a2fb8df0d3de8f1ff4ebff5726728fce7 /toxcore/friend_connection.h | |
parent | b3889f0f052b450225eeb02826efcfea82ae9590 (diff) |
Use named function types for friend_connection callbacks.
Also:
* No inner structs.
* One declarator per member declaration.
* Function names are snake_case.
* Names ending in `_cb` are function types.
* `++i` is preferred over `i++`.
Diffstat (limited to 'toxcore/friend_connection.h')
-rw-r--r-- | toxcore/friend_connection.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/toxcore/friend_connection.h b/toxcore/friend_connection.h index f4d53c7a..a29cc7be 100644 --- a/toxcore/friend_connection.h +++ b/toxcore/friend_connection.h | |||
@@ -101,6 +101,10 @@ void set_dht_temp_pk(Friend_Connections *fr_c, int friendcon_id, const uint8_t * | |||
101 | */ | 101 | */ |
102 | int friend_add_tcp_relay(Friend_Connections *fr_c, int friendcon_id, IP_Port ip_port, const uint8_t *public_key); | 102 | int friend_add_tcp_relay(Friend_Connections *fr_c, int friendcon_id, IP_Port ip_port, const uint8_t *public_key); |
103 | 103 | ||
104 | typedef int fc_status_cb(void *object, int id, uint8_t status, void *userdata); | ||
105 | typedef int fc_data_cb(void *object, int id, const uint8_t *data, uint16_t length, void *userdata); | ||
106 | typedef int fc_lossy_data_cb(void *object, int id, const uint8_t *data, uint16_t length, void *userdata); | ||
107 | |||
104 | /* Set the callbacks for the friend connection. | 108 | /* Set the callbacks for the friend connection. |
105 | * index is the index (0 to (MAX_FRIEND_CONNECTION_CALLBACKS - 1)) we want the callback to set in the array. | 109 | * index is the index (0 to (MAX_FRIEND_CONNECTION_CALLBACKS - 1)) we want the callback to set in the array. |
106 | * | 110 | * |
@@ -108,9 +112,9 @@ int friend_add_tcp_relay(Friend_Connections *fr_c, int friendcon_id, IP_Port ip_ | |||
108 | * return -1 on failure | 112 | * return -1 on failure |
109 | */ | 113 | */ |
110 | int friend_connection_callbacks(Friend_Connections *fr_c, int friendcon_id, unsigned int index, | 114 | int friend_connection_callbacks(Friend_Connections *fr_c, int friendcon_id, unsigned int index, |
111 | int (*status_callback)(void *object, int id, uint8_t status, void *userdata), | 115 | fc_status_cb *status_callback, |
112 | int (*data_callback)(void *object, int id, const uint8_t *data, uint16_t len, void *userdata), | 116 | fc_data_cb *data_callback, |
113 | int (*lossy_data_callback)(void *object, int id, const uint8_t *data, uint16_t length, void *userdata), | 117 | fc_lossy_data_cb *lossy_data_callback, |
114 | void *object, int number); | 118 | void *object, int number); |
115 | 119 | ||
116 | /* return the crypt_connection_id for the connection. | 120 | /* return the crypt_connection_id for the connection. |
@@ -144,12 +148,14 @@ int kill_friend_connection(Friend_Connections *fr_c, int friendcon_id); | |||
144 | int send_friend_request_packet(Friend_Connections *fr_c, int friendcon_id, uint32_t nospam_num, const uint8_t *data, | 148 | int send_friend_request_packet(Friend_Connections *fr_c, int friendcon_id, uint32_t nospam_num, const uint8_t *data, |
145 | uint16_t length); | 149 | uint16_t length); |
146 | 150 | ||
151 | typedef int fr_request_cb(void *object, const uint8_t *source_pubkey, const uint8_t *data, uint16_t len, | ||
152 | void *userdata); | ||
153 | |||
147 | /* Set friend request callback. | 154 | /* Set friend request callback. |
148 | * | 155 | * |
149 | * This function will be called every time a friend request is received. | 156 | * This function will be called every time a friend request is received. |
150 | */ | 157 | */ |
151 | void set_friend_request_callback(Friend_Connections *fr_c, int (*fr_request_callback)(void *, const uint8_t *, | 158 | void set_friend_request_callback(Friend_Connections *fr_c, fr_request_cb *fr_request_callback, void *object); |
152 | const uint8_t *, uint16_t, void *), void *object); | ||
153 | 159 | ||
154 | /* Create new friend_connections instance. */ | 160 | /* Create new friend_connections instance. */ |
155 | Friend_Connections *new_friend_connections(Onion_Client *onion_c, bool local_discovery_enabled); | 161 | Friend_Connections *new_friend_connections(Onion_Client *onion_c, bool local_discovery_enabled); |