summaryrefslogtreecommitdiff
path: root/toxcore/tox.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r--toxcore/tox.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h
index eabbb1af..e497e6f5 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -140,7 +140,10 @@ typedef enum {
140} 140}
141TOX_USERSTATUS; 141TOX_USERSTATUS;
142 142
143typedef void Tox; 143#ifndef __TOX_DEFINED__
144#define __TOX_DEFINED__
145typedef struct Tox Tox;
146#endif
144 147
145/* return FRIEND_ADDRESS_SIZE byte address to give to others. 148/* return FRIEND_ADDRESS_SIZE byte address to give to others.
146 * format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] 149 * format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)]
@@ -229,7 +232,7 @@ int tox_sendaction(Tox *tox, int friendnumber, uint8_t *action, uint32_t length)
229 * return 0 if success. 232 * return 0 if success.
230 * return -1 if failure. 233 * return -1 if failure.
231 */ 234 */
232int tox_setfriendname(void *tox, int friendnumber, uint8_t *name, uint16_t length); 235int tox_setfriendname(Tox *tox, int friendnumber, uint8_t *name, uint16_t length);
233 236
234/* Set our nickname. 237/* Set our nickname.
235 * name must be a string of maximum MAX_NAME_LENGTH length. 238 * name must be a string of maximum MAX_NAME_LENGTH length.
@@ -300,14 +303,14 @@ void tox_set_sends_receipts(Tox *tox, int friendnumber, int yesno);
300/* Return the number of friends in the instance m. 303/* Return the number of friends in the instance m.
301 * You should use this to determine how much memory to allocate 304 * You should use this to determine how much memory to allocate
302 * for copy_friendlist. */ 305 * for copy_friendlist. */
303uint32_t tox_count_friendlist(void *tox); 306uint32_t tox_count_friendlist(Tox *tox);
304 307
305/* Copy a list of valid friend IDs into the array out_list. 308/* Copy a list of valid friend IDs into the array out_list.
306 * If out_list is NULL, returns 0. 309 * If out_list is NULL, returns 0.
307 * Otherwise, returns the number of elements copied. 310 * Otherwise, returns the number of elements copied.
308 * If the array was too small, the contents 311 * If the array was too small, the contents
309 * of out_list will be truncated to list_size. */ 312 * of out_list will be truncated to list_size. */
310uint32_t tox_copy_friendlist(void *tox, int *out_list, uint32_t list_size); 313uint32_t tox_copy_friendlist(Tox *tox, int *out_list, uint32_t list_size);
311 314
312/* Set the function that will be executed when a friend request is received. 315/* Set the function that will be executed when a friend request is received.
313 * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) 316 * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length)
@@ -436,6 +439,7 @@ int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t
436 * to setup connections 439 * to setup connections
437 */ 440 */
438void tox_bootstrap_from_ip(Tox *tox, tox_IP_Port ip_port, uint8_t *public_key); 441void tox_bootstrap_from_ip(Tox *tox, tox_IP_Port ip_port, uint8_t *public_key);
442
439/* Resolves address into an IP address. If successful, sends a "get nodes" 443/* Resolves address into an IP address. If successful, sends a "get nodes"
440 * request to the given node with ip, port and public_key to setup connections 444 * request to the given node with ip, port and public_key to setup connections
441 * 445 *
@@ -477,6 +481,18 @@ void tox_kill(Tox *tox);
477/* The main loop that needs to be run at least 20 times per second. */ 481/* The main loop that needs to be run at least 20 times per second. */
478void tox_do(Tox *tox); 482void tox_do(Tox *tox);
479 483
484/*
485 * Waits for something to happen on the socket for up to milliseconds milliseconds.
486 * *** Function MUSTN'T poll. ***
487 * The function mustn't modify anything at all, so it can be called completely
488 * asynchronously without any worry.
489 *
490 * returns 0 if the timeout was reached
491 * returns 1 if there is socket activity (i.e. tox_do() should be called)
492 *
493 */
494int tox_wait(Tox *tox, uint16_t milliseconds);
495
480/* SAVING AND LOADING FUNCTIONS: */ 496/* SAVING AND LOADING FUNCTIONS: */
481 497
482/* return size of messenger data (for saving). */ 498/* return size of messenger data (for saving). */
@@ -494,3 +510,4 @@ int tox_load(Tox *tox, uint8_t *data, uint32_t length);
494#endif 510#endif
495 511
496#endif 512#endif
513