summaryrefslogtreecommitdiff
path: root/toxcore/tox.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-12-06 22:51:17 -0500
committerirungentoo <irungentoo@gmail.com>2013-12-06 22:51:17 -0500
commit7cd43ecc76cd08c5c2c16b9f9169908ef4674762 (patch)
tree5b5ba5b61b5591222e2c4682d750c71469f1086c /toxcore/tox.c
parent1473126f9a459f31f4c33262a21987a3bb7dde65 (diff)
parent4207b73ca9432aeacfa72e5b7610cbb0ba9324c8 (diff)
Merge branch 'master' into harden
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r--toxcore/tox.c135
1 files changed, 95 insertions, 40 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c
index 6a0c6a62..487f2517 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -37,7 +37,7 @@ typedef struct Messenger Tox;
37 * Format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] 37 * Format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)]
38 * 38 *
39 */ 39 */
40void tox_getaddress(Tox *tox, uint8_t *address) 40void tox_get_address(Tox *tox, uint8_t *address)
41{ 41{
42 Messenger *m = tox; 42 Messenger *m = tox;
43 getaddress(m, address); 43 getaddress(m, address);
@@ -60,7 +60,7 @@ void tox_getaddress(Tox *tox, uint8_t *address)
60 * (the nospam for that friend was set to the new one). 60 * (the nospam for that friend was set to the new one).
61 * return FAERR_NOMEM if increasing the friend list size fails. 61 * return FAERR_NOMEM if increasing the friend list size fails.
62 */ 62 */
63int tox_addfriend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length) 63int tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length)
64{ 64{
65 Messenger *m = tox; 65 Messenger *m = tox;
66 return m_addfriend(m, address, data, length); 66 return m_addfriend(m, address, data, length);
@@ -71,7 +71,7 @@ int tox_addfriend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length)
71 * return the friend number if success. 71 * return the friend number if success.
72 * return -1 if failure. 72 * return -1 if failure.
73 */ 73 */
74int tox_addfriend_norequest(Tox *tox, uint8_t *client_id) 74int tox_add_friend_norequest(Tox *tox, uint8_t *client_id)
75{ 75{
76 Messenger *m = tox; 76 Messenger *m = tox;
77 return m_addfriend_norequest(m, client_id); 77 return m_addfriend_norequest(m, client_id);
@@ -80,7 +80,7 @@ int tox_addfriend_norequest(Tox *tox, uint8_t *client_id)
80/* return the friend id associated to that client id. 80/* return the friend id associated to that client id.
81 * return -1 if no such friend. 81 * return -1 if no such friend.
82 */ 82 */
83int tox_getfriend_id(Tox *tox, uint8_t *client_id) 83int tox_get_friend_id(Tox *tox, uint8_t *client_id)
84{ 84{
85 Messenger *m = tox; 85 Messenger *m = tox;
86 return getfriend_id(m, client_id); 86 return getfriend_id(m, client_id);
@@ -92,14 +92,14 @@ int tox_getfriend_id(Tox *tox, uint8_t *client_id)
92 * return 0 if success. 92 * return 0 if success.
93 * return -1 if failure. 93 * return -1 if failure.
94 */ 94 */
95int tox_getclient_id(Tox *tox, int friend_id, uint8_t *client_id) 95int tox_get_client_id(Tox *tox, int friend_id, uint8_t *client_id)
96{ 96{
97 Messenger *m = tox; 97 Messenger *m = tox;
98 return getclient_id(m, friend_id, client_id); 98 return getclient_id(m, friend_id, client_id);
99} 99}
100 100
101/* Remove a friend. */ 101/* Remove a friend. */
102int tox_delfriend(Tox *tox, int friendnumber) 102int tox_del_friend(Tox *tox, int friendnumber)
103{ 103{
104 Messenger *m = tox; 104 Messenger *m = tox;
105 return m_delfriend(m, friendnumber); 105 return m_delfriend(m, friendnumber);
@@ -111,7 +111,7 @@ int tox_delfriend(Tox *tox, int friendnumber)
111 * return 0 if friend is not connected to us (Offline). 111 * return 0 if friend is not connected to us (Offline).
112 * return -1 on failure. 112 * return -1 on failure.
113 */ 113 */
114int tox_get_friend_connectionstatus(Tox *tox, int friendnumber) 114int tox_get_friend_connection_status(Tox *tox, int friendnumber)
115{ 115{
116 Messenger *m = tox; 116 Messenger *m = tox;
117 return m_get_friend_connectionstatus(m, friendnumber); 117 return m_get_friend_connectionstatus(m, friendnumber);
@@ -137,13 +137,13 @@ int tox_friend_exists(Tox *tox, int friendnumber)
137 * m_sendmessage_withid will send a message with the id of your choosing, 137 * m_sendmessage_withid will send a message with the id of your choosing,
138 * however we can generate an id for you by calling plain m_sendmessage. 138 * however we can generate an id for you by calling plain m_sendmessage.
139 */ 139 */
140uint32_t tox_sendmessage(Tox *tox, int friendnumber, uint8_t *message, uint32_t length) 140uint32_t tox_send_message(Tox *tox, int friendnumber, uint8_t *message, uint32_t length)
141{ 141{
142 Messenger *m = tox; 142 Messenger *m = tox;
143 return m_sendmessage(m, friendnumber, message, length); 143 return m_sendmessage(m, friendnumber, message, length);
144} 144}
145 145
146uint32_t tox_sendmessage_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length) 146uint32_t tox_send_message_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length)
147{ 147{
148 Messenger *m = tox; 148 Messenger *m = tox;
149 return m_sendmessage_withid(m, friendnumber, theid, message, length); 149 return m_sendmessage_withid(m, friendnumber, theid, message, length);
@@ -159,13 +159,13 @@ uint32_t tox_sendmessage_withid(Tox *tox, int friendnumber, uint32_t theid, uint
159 * m_sendaction_withid will send an action message with the id of your choosing, 159 * m_sendaction_withid will send an action message with the id of your choosing,
160 * however we can generate an id for you by calling plain m_sendaction. 160 * however we can generate an id for you by calling plain m_sendaction.
161 */ 161 */
162uint32_t tox_sendaction(Tox *tox, int friendnumber, uint8_t *action, uint32_t length) 162uint32_t tox_send_action(Tox *tox, int friendnumber, uint8_t *action, uint32_t length)
163{ 163{
164 Messenger *m = tox; 164 Messenger *m = tox;
165 return m_sendaction(m, friendnumber, action, length); 165 return m_sendaction(m, friendnumber, action, length);
166} 166}
167 167
168uint32_t tox_sendaction_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length) 168uint32_t tox_send_action_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length)
169{ 169{
170 Messenger *m = tox; 170 Messenger *m = tox;
171 return m_sendaction_withid(m, friendnumber, theid, action, length); 171 return m_sendaction_withid(m, friendnumber, theid, action, length);
@@ -179,7 +179,7 @@ uint32_t tox_sendaction_withid(Tox *tox, int friendnumber, uint32_t theid, uint8
179 * return 0 if success. 179 * return 0 if success.
180 * return -1 if failure. 180 * return -1 if failure.
181 */ 181 */
182int tox_setname(Tox *tox, uint8_t *name, uint16_t length) 182int tox_set_name(Tox *tox, uint8_t *name, uint16_t length)
183{ 183{
184 Messenger *m = tox; 184 Messenger *m = tox;
185 return setname(m, name, length); 185 return setname(m, name, length);
@@ -193,7 +193,7 @@ int tox_setname(Tox *tox, uint8_t *name, uint16_t length)
193 * return length of the name. 193 * return length of the name.
194 * return 0 on error. 194 * return 0 on error.
195 */ 195 */
196uint16_t tox_getselfname(Tox *tox, uint8_t *name, uint16_t nlen) 196uint16_t tox_get_self_name(Tox *tox, uint8_t *name, uint16_t nlen)
197{ 197{
198 Messenger *m = tox; 198 Messenger *m = tox;
199 return getself_name(m, name, nlen); 199 return getself_name(m, name, nlen);
@@ -205,7 +205,7 @@ uint16_t tox_getselfname(Tox *tox, uint8_t *name, uint16_t nlen)
205 * return length of name (with the NULL terminator) if success. 205 * return length of name (with the NULL terminator) if success.
206 * return -1 if failure. 206 * return -1 if failure.
207 */ 207 */
208int tox_getname(Tox *tox, int friendnumber, uint8_t *name) 208int tox_get_name(Tox *tox, int friendnumber, uint8_t *name)
209{ 209{
210 Messenger *m = tox; 210 Messenger *m = tox;
211 return getname(m, friendnumber, name); 211 return getname(m, friendnumber, name);
@@ -216,13 +216,13 @@ int tox_getname(Tox *tox, int friendnumber, uint8_t *name)
216 * 216 *
217 * return 0 on success, -1 on failure. 217 * return 0 on success, -1 on failure.
218 */ 218 */
219int tox_set_statusmessage(Tox *tox, uint8_t *status, uint16_t length) 219int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length)
220{ 220{
221 Messenger *m = tox; 221 Messenger *m = tox;
222 return m_set_statusmessage(m, status, length); 222 return m_set_statusmessage(m, status, length);
223} 223}
224 224
225int tox_set_userstatus(Tox *tox, TOX_USERSTATUS status) 225int tox_set_user_status(Tox *tox, TOX_USERSTATUS status)
226{ 226{
227 Messenger *m = tox; 227 Messenger *m = tox;
228 return m_set_userstatus(m, (USERSTATUS)status); 228 return m_set_userstatus(m, (USERSTATUS)status);
@@ -231,7 +231,7 @@ int tox_set_userstatus(Tox *tox, TOX_USERSTATUS status)
231/* return the length of friendnumber's status message, including null. 231/* return the length of friendnumber's status message, including null.
232 * Pass it into malloc. 232 * Pass it into malloc.
233 */ 233 */
234int tox_get_statusmessage_size(Tox *tox, int friendnumber) 234int tox_get_status_message_size(Tox *tox, int friendnumber)
235{ 235{
236 Messenger *m = tox; 236 Messenger *m = tox;
237 return m_get_statusmessage_size(m, friendnumber); 237 return m_get_statusmessage_size(m, friendnumber);
@@ -241,13 +241,13 @@ int tox_get_statusmessage_size(Tox *tox, int friendnumber)
241 * Get the size you need to allocate from m_get_statusmessage_size. 241 * Get the size you need to allocate from m_get_statusmessage_size.
242 * The self variant will copy our own status message. 242 * The self variant will copy our own status message.
243 */ 243 */
244int tox_copy_statusmessage(Tox *tox, int friendnumber, uint8_t *buf, uint32_t maxlen) 244int tox_get_status_message(Tox *tox, int friendnumber, uint8_t *buf, uint32_t maxlen)
245{ 245{
246 Messenger *m = tox; 246 Messenger *m = tox;
247 return m_copy_statusmessage(m, friendnumber, buf, maxlen); 247 return m_copy_statusmessage(m, friendnumber, buf, maxlen);
248} 248}
249 249
250int tox_copy_self_statusmessage(Tox *tox, uint8_t *buf, uint32_t maxlen) 250int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen)
251{ 251{
252 Messenger *m = tox; 252 Messenger *m = tox;
253 return m_copy_self_statusmessage(m, buf, maxlen); 253 return m_copy_self_statusmessage(m, buf, maxlen);
@@ -258,13 +258,13 @@ int tox_copy_self_statusmessage(Tox *tox, uint8_t *buf, uint32_t maxlen)
258 * As above, the self variant will return our own USERSTATUS. 258 * As above, the self variant will return our own USERSTATUS.
259 * If friendnumber is invalid, this shall return USERSTATUS_INVALID. 259 * If friendnumber is invalid, this shall return USERSTATUS_INVALID.
260 */ 260 */
261TOX_USERSTATUS tox_get_userstatus(Tox *tox, int friendnumber) 261TOX_USERSTATUS tox_get_user_status(Tox *tox, int friendnumber)
262{ 262{
263 Messenger *m = tox; 263 Messenger *m = tox;
264 return (TOX_USERSTATUS)m_get_userstatus(m, friendnumber); 264 return (TOX_USERSTATUS)m_get_userstatus(m, friendnumber);
265} 265}
266 266
267TOX_USERSTATUS tox_get_selfuserstatus(Tox *tox) 267TOX_USERSTATUS tox_get_self_user_status(Tox *tox)
268{ 268{
269 Messenger *m = tox; 269 Messenger *m = tox;
270 return (TOX_USERSTATUS)m_get_self_userstatus(m); 270 return (TOX_USERSTATUS)m_get_self_userstatus(m);
@@ -294,7 +294,7 @@ uint32_t tox_count_friendlist(Tox *tox)
294 * Otherwise, returns the number of elements copied. 294 * Otherwise, returns the number of elements copied.
295 * If the array was too small, the contents 295 * If the array was too small, the contents
296 * of out_list will be truncated to list_size. */ 296 * of out_list will be truncated to list_size. */
297uint32_t tox_copy_friendlist(Tox *tox, int *out_list, uint32_t list_size) 297uint32_t tox_get_friendlist(Tox *tox, int *out_list, uint32_t list_size)
298{ 298{
299 Messenger *m = tox; 299 Messenger *m = tox;
300 return copy_friendlist(m, out_list, list_size); 300 return copy_friendlist(m, out_list, list_size);
@@ -303,7 +303,7 @@ uint32_t tox_copy_friendlist(Tox *tox, int *out_list, uint32_t list_size)
303/* Set the function that will be executed when a friend request is received. 303/* Set the function that will be executed when a friend request is received.
304 * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) 304 * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length)
305 */ 305 */
306void tox_callback_friendrequest(Tox *tox, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata) 306void tox_callback_friend_request(Tox *tox, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata)
307{ 307{
308 Messenger *m = tox; 308 Messenger *m = tox;
309 m_callback_friendrequest(m, function, userdata); 309 m_callback_friendrequest(m, function, userdata);
@@ -313,7 +313,7 @@ void tox_callback_friendrequest(Tox *tox, void (*function)(uint8_t *, uint8_t *,
313/* Set the function that will be executed when a message from a friend is received. 313/* Set the function that will be executed when a message from a friend is received.
314 * Function format is: function(int friendnumber, uint8_t * message, uint32_t length) 314 * Function format is: function(int friendnumber, uint8_t * message, uint32_t length)
315 */ 315 */
316void tox_callback_friendmessage(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *), 316void tox_callback_friend_message(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *),
317 void *userdata) 317 void *userdata)
318{ 318{
319 Messenger *m = tox; 319 Messenger *m = tox;
@@ -333,7 +333,7 @@ void tox_callback_action(Tox *tox, void (*function)(Messenger *tox, int, uint8_t
333 * function(int friendnumber, uint8_t *newname, uint16_t length) 333 * function(int friendnumber, uint8_t *newname, uint16_t length)
334 * You are not responsible for freeing newname. 334 * You are not responsible for freeing newname.
335 */ 335 */
336void tox_callback_namechange(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *), 336void tox_callback_name_change(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *),
337 void *userdata) 337 void *userdata)
338{ 338{
339 Messenger *m = tox; 339 Messenger *m = tox;
@@ -344,7 +344,7 @@ void tox_callback_namechange(Tox *tox, void (*function)(Messenger *tox, int, uin
344 * function(int friendnumber, uint8_t *newstatus, uint16_t length) 344 * function(int friendnumber, uint8_t *newstatus, uint16_t length)
345 * You are not responsible for freeing newstatus. 345 * You are not responsible for freeing newstatus.
346 */ 346 */
347void tox_callback_statusmessage(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *), 347void tox_callback_status_message(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *),
348 void *userdata) 348 void *userdata)
349{ 349{
350 Messenger *m = tox; 350 Messenger *m = tox;
@@ -354,7 +354,7 @@ void tox_callback_statusmessage(Tox *tox, void (*function)(Messenger *tox, int,
354/* Set the callback for status type changes. 354/* Set the callback for status type changes.
355 * function(int friendnumber, USERSTATUS kind) 355 * function(int friendnumber, USERSTATUS kind)
356 */ 356 */
357void tox_callback_userstatus(Tox *tox, void (*_function)(Tox *tox, int, TOX_USERSTATUS, void *), void *userdata) 357void tox_callback_user_status(Tox *tox, void (*_function)(Tox *tox, int, TOX_USERSTATUS, void *), void *userdata)
358{ 358{
359 Messenger *m = tox; 359 Messenger *m = tox;
360 typedef void (*function_type)(Messenger *, int, USERSTATUS, void *); 360 typedef void (*function_type)(Messenger *, int, USERSTATUS, void *);
@@ -388,7 +388,7 @@ void tox_callback_read_receipt(Tox *tox, void (*function)(Messenger *tox, int, u
388 * being previously online" part. It's assumed that when adding friends, 388 * being previously online" part. It's assumed that when adding friends,
389 * their connection status is offline. 389 * their connection status is offline.
390 */ 390 */
391void tox_callback_connectionstatus(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, void *), void *userdata) 391void tox_callback_connection_status(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, void *), void *userdata)
392{ 392{
393 Messenger *m = tox; 393 Messenger *m = tox;
394 m_callback_connectionstatus(m, function, userdata); 394 m_callback_connectionstatus(m, function, userdata);
@@ -415,6 +415,19 @@ void tox_callback_group_message(Tox *tox, void (*function)(Messenger *tox, int,
415 Messenger *m = tox; 415 Messenger *m = tox;
416 m_callback_group_message(m, function, userdata); 416 m_callback_group_message(m, function, userdata);
417} 417}
418
419/* Set callback function for peer name list changes.
420 *
421 * It gets called every time the name list changes(new peer/name, deleted peer)
422 * Function(Tox *tox, int groupnumber, void *userdata)
423 */
424
425void tox_callback_group_namelist_change(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t, void *), void *userdata)
426{
427 Messenger *m = tox;
428 m_callback_group_namelistchange(m, function, userdata);
429}
430
418/* Creates a new groupchat and puts it in the chats array. 431/* Creates a new groupchat and puts it in the chats array.
419 * 432 *
420 * return group number on success. 433 * return group number on success.
@@ -477,6 +490,48 @@ int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t
477 return group_message_send(m, groupnumber, message, length); 490 return group_message_send(m, groupnumber, message, length);
478} 491}
479 492
493/* Return the number of peers in the group chat on success.
494 * return -1 on failure
495 */
496int tox_group_number_peers(Tox *tox, int groupnumber)
497{
498 Messenger *m = tox;
499 return group_number_peers(m, groupnumber);
500}
501
502/* List all the peers in the group chat.
503 *
504 * Copies the names of the peers to the name[length][MAX_NICK_BYTES] array.
505 *
506 * returns the number of peers on success.
507 *
508 * return -1 on failure.
509 */
510int tox_group_get_names(Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t length)
511{
512 Messenger *m = tox;
513 return group_names(m, groupnumber, names, length);
514}
515
516/* Return the number of chats in the instance m.
517 * You should use this to determine how much memory to allocate
518 * for copy_chatlist. */
519uint32_t tox_count_chatlist(Tox *tox)
520{
521 Messenger *m = tox;
522 return count_chatlist(m);
523}
524
525/* Copy a list of valid chat IDs into the array out_list.
526 * If out_list is NULL, returns 0.
527 * Otherwise, returns the number of elements copied.
528 * If the array was too small, the contents
529 * of out_list will be truncated to list_size. */
530uint32_t tox_get_chatlist(Tox *tox, int *out_list, uint32_t list_size)
531{
532 Messenger *m = tox;
533 return copy_chatlist(m, out_list, list_size);
534}
480 535
481 536
482/****************FILE SENDING FUNCTIONS*****************/ 537/****************FILE SENDING FUNCTIONS*****************/
@@ -486,7 +541,7 @@ int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t
486 * 541 *
487 * Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) 542 * Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
488 */ 543 */
489void tox_callback_file_sendrequest(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, uint64_t, uint8_t *, 544void tox_callback_file_send_request(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, uint64_t, uint8_t *,
490 uint16_t, 545 uint16_t,
491 void *), void *userdata) 546 void *), void *userdata)
492{ 547{
@@ -522,7 +577,7 @@ void tox_callback_file_data(Tox *tox, void (*function)(Messenger *tox, int, uint
522 * return file number on success 577 * return file number on success
523 * return -1 on failure 578 * return -1 on failure
524 */ 579 */
525int tox_new_filesender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length) 580int tox_new_file_sender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length)
526{ 581{
527 Messenger *m = tox; 582 Messenger *m = tox;
528 return new_filesender(m, friendnumber, filesize, filename, filename_length); 583 return new_filesender(m, friendnumber, filesize, filename, filename_length);
@@ -530,10 +585,10 @@ int tox_new_filesender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *f
530/* Send a file control request. 585/* Send a file control request.
531 * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file. 586 * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file.
532 * 587 *
533 * return 1 on success 588 * return 0 on success
534 * return 0 on failure 589 * return -1 on failure
535 */ 590 */
536int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, 591int tox_file_send_control(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
537 uint8_t *data, uint16_t length) 592 uint8_t *data, uint16_t length)
538{ 593{
539 Messenger *m = tox; 594 Messenger *m = tox;
@@ -541,21 +596,21 @@ int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8
541} 596}
542/* Send file data. 597/* Send file data.
543 * 598 *
544 * return 1 on success 599 * return 0 on success
545 * return 0 on failure 600 * return -1 on failure
546 */ 601 */
547int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length) 602int tox_file_send_data(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length)
548{ 603{
549 Messenger *m = tox; 604 Messenger *m = tox;
550 return file_data(m, friendnumber, filenumber, data, length); 605 return file_data(m, friendnumber, filenumber, data, length);
551} 606}
552 607
553/* Returns the recommended/maximum size of the filedata you send with tox_file_senddata() 608/* Returns the recommended/maximum size of the filedata you send with tox_file_send_data()
554 * 609 *
555 * return size on success 610 * return size on success
556 * return 0 on failure (currently will never return 0) 611 * return -1 on failure (currently will never return -1)
557 */ 612 */
558int tox_filedata_size(Tox *tox, int friendnumber) 613int tox_file_data_size(Tox *tox, int friendnumber)
559{ 614{
560 return MAX_DATA_SIZE - crypto_box_MACBYTES - 3; 615 return MAX_DATA_SIZE - crypto_box_MACBYTES - 3;
561} 616}
@@ -567,7 +622,7 @@ int tox_filedata_size(Tox *tox, int friendnumber)
567 * return number of bytes remaining to be sent/received on success 622 * return number of bytes remaining to be sent/received on success
568 * return 0 on failure 623 * return 0 on failure
569 */ 624 */
570uint64_t tox_file_dataremaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive) 625uint64_t tox_file_data_remaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive)
571{ 626{
572 Messenger *m = tox; 627 Messenger *m = tox;
573 return file_dataremaining(m, friendnumber, filenumber, send_receive); 628 return file_dataremaining(m, friendnumber, filenumber, send_receive);