diff options
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r-- | toxcore/tox.h | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h index 5b619cd0..1c84c1cb 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -662,37 +662,43 @@ void tox_kill(Tox *tox); | |||
662 | void tox_do(Tox *tox); | 662 | void tox_do(Tox *tox); |
663 | 663 | ||
664 | /* | 664 | /* |
665 | * tox_wait_prepare(): function should be called under lock | 665 | * tox_wait_data_size(): |
666 | * | ||
667 | * returns a size of data buffer to allocate. the size is constant. | ||
668 | * | ||
669 | * tox_wait_prepare(): function should be called under lock every time we want to call tox_wait_execute() | ||
666 | * Prepares the data required to call tox_wait_execute() asynchronously | 670 | * Prepares the data required to call tox_wait_execute() asynchronously |
667 | * | 671 | * |
668 | * data[] is reserved and kept by the caller | 672 | * data[] should be of at least tox_wait_data_size() size and it's reserved and kept by the caller |
669 | * *lenptr is in/out: in = reserved data[], out = required data[] | 673 | * Use that data[] to call tox_wait_execute() |
670 | * | 674 | * |
671 | * returns 1 on success | 675 | * returns 1 on success |
672 | * returns 0 if *lenptr is insufficient | 676 | * returns 0 if data was NULL |
673 | * returns -1 if lenptr is NULL | ||
674 | * | 677 | * |
675 | * | 678 | * |
676 | * tox_wait_execute(): function can be called asynchronously | 679 | * tox_wait_execute(): function can be called asynchronously |
677 | * Waits for something to happen on the socket for up to milliseconds milliseconds. | 680 | * Waits for something to happen on the socket for up to seconds seconds and mircoseconds microseconds. |
678 | * *** Function MUSTN'T poll. *** | 681 | * mircoseconds should be between 0 and 999999. |
679 | * The function mustn't modify anything at all, so it can be called completely | 682 | * If you set either or both seconds and microseconds to negatives, it will block indefinetly until there |
680 | * asynchronously without any worry. | 683 | * is an activity. |
681 | * | 684 | * |
682 | * returns 1 if there is socket activity (i.e. tox_do() should be called) | 685 | * returns 2 if there is socket activity (i.e. tox_do() should be called) |
683 | * returns 0 if the timeout was reached | 686 | * returns 1 if the timeout was reached (tox_do() should be called anyway. it's advised to call it at least |
684 | * returns -1 if data was NULL or len too short | 687 | * once per second) |
688 | * returns 0 if data was NULL | ||
685 | * | 689 | * |
686 | * | 690 | * |
687 | * tox_wait_cleanup(): function should be called under lock | 691 | * tox_wait_cleanup(): function should be called under lock, every time tox_wait_execute() finishes |
688 | * Stores results from tox_wait_execute(). | 692 | * Stores results from tox_wait_execute(). |
689 | * | 693 | * |
690 | * data[]/len shall be the exact same as given to tox_wait_execute() | 694 | * returns 1 on success |
695 | * returns 0 if data was NULL | ||
691 | * | 696 | * |
692 | */ | 697 | */ |
693 | int tox_wait_prepare(Tox *tox, uint8_t *data, uint16_t *lenptr); | 698 | size_t tox_wait_data_size(); |
694 | int tox_wait_execute(Tox *tox, uint8_t *data, uint16_t len, uint16_t milliseconds); | 699 | int tox_wait_prepare(Tox *tox, uint8_t *data); |
695 | void tox_wait_cleanup(Tox *tox, uint8_t *data, uint16_t len); | 700 | int tox_wait_execute(uint8_t *data, long seconds, long microseconds); |
701 | int tox_wait_cleanup(Tox *tox, uint8_t *data); | ||
696 | 702 | ||
697 | 703 | ||
698 | /* SAVING AND LOADING FUNCTIONS: */ | 704 | /* SAVING AND LOADING FUNCTIONS: */ |