diff options
author | irungentoo <irungentoo@gmail.com> | 2013-10-23 14:42:39 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-10-23 14:42:39 -0400 |
commit | 2e75648f5151f163908da60f4bff6b0c8387c6f8 (patch) | |
tree | dba2e553c0a9f34970d17122dd26b74b22524ece /toxcore | |
parent | a67b4f8c6d85b5d77cbd8b04a1f7a90a4470947b (diff) |
Code cleanups.
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/Messenger.c | 26 | ||||
-rw-r--r-- | toxcore/Messenger.h | 18 | ||||
-rw-r--r-- | toxcore/tox.c | 18 |
3 files changed, 31 insertions, 31 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index eb379c4c..ff64a072 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1357,7 +1357,7 @@ static void LANdiscovery(Messenger *m) | |||
1357 | } | 1357 | } |
1358 | 1358 | ||
1359 | /* Run this at startup. */ | 1359 | /* Run this at startup. */ |
1360 | Messenger *initMessenger(uint8_t ipv6enabled) | 1360 | Messenger *new_messenger(uint8_t ipv6enabled) |
1361 | { | 1361 | { |
1362 | Messenger *m = calloc(1, sizeof(Messenger)); | 1362 | Messenger *m = calloc(1, sizeof(Messenger)); |
1363 | 1363 | ||
@@ -1402,7 +1402,7 @@ Messenger *initMessenger(uint8_t ipv6enabled) | |||
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | /* Run this before closing shop. */ | 1404 | /* Run this before closing shop. */ |
1405 | void cleanupMessenger(Messenger *m) | 1405 | void kill_messenger(Messenger *m) |
1406 | { | 1406 | { |
1407 | /* FIXME TODO: ideally cleanupMessenger will mirror initMessenger. | 1407 | /* FIXME TODO: ideally cleanupMessenger will mirror initMessenger. |
1408 | * This requires the other modules to expose cleanup functions. | 1408 | * This requires the other modules to expose cleanup functions. |
@@ -1415,7 +1415,7 @@ void cleanupMessenger(Messenger *m) | |||
1415 | } | 1415 | } |
1416 | 1416 | ||
1417 | /* TODO: Make this function not suck. */ | 1417 | /* TODO: Make this function not suck. */ |
1418 | void doFriends(Messenger *m) | 1418 | void do_friends(Messenger *m) |
1419 | { | 1419 | { |
1420 | /* TODO: Add incoming connections and some other stuff. */ | 1420 | /* TODO: Add incoming connections and some other stuff. */ |
1421 | uint32_t i; | 1421 | uint32_t i; |
@@ -1725,7 +1725,7 @@ void doFriends(Messenger *m) | |||
1725 | } | 1725 | } |
1726 | } | 1726 | } |
1727 | 1727 | ||
1728 | void doInbound(Messenger *m) | 1728 | void do_inbound(Messenger *m) |
1729 | { | 1729 | { |
1730 | uint8_t secret_nonce[crypto_box_NONCEBYTES]; | 1730 | uint8_t secret_nonce[crypto_box_NONCEBYTES]; |
1731 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; | 1731 | uint8_t public_key[crypto_box_PUBLICKEYBYTES]; |
@@ -1767,14 +1767,14 @@ static char *ID2String(uint8_t *client_id) | |||
1767 | #endif | 1767 | #endif |
1768 | 1768 | ||
1769 | /* The main loop that needs to be run at least 20 times per second. */ | 1769 | /* The main loop that needs to be run at least 20 times per second. */ |
1770 | void doMessenger(Messenger *m) | 1770 | void do_messenger(Messenger *m) |
1771 | { | 1771 | { |
1772 | networking_poll(m->net); | 1772 | networking_poll(m->net); |
1773 | 1773 | ||
1774 | do_DHT(m->dht); | 1774 | do_DHT(m->dht); |
1775 | do_net_crypto(m->net_crypto); | 1775 | do_net_crypto(m->net_crypto); |
1776 | doFriends(m); | 1776 | do_friends(m); |
1777 | doInbound(m); | 1777 | do_inbound(m); |
1778 | do_allgroupchats(m); | 1778 | do_allgroupchats(m); |
1779 | LANdiscovery(m); | 1779 | LANdiscovery(m); |
1780 | 1780 | ||
@@ -1873,17 +1873,17 @@ void doMessenger(Messenger *m) | |||
1873 | /* | 1873 | /* |
1874 | * functions to avoid excessive polling | 1874 | * functions to avoid excessive polling |
1875 | */ | 1875 | */ |
1876 | int waitprepareMessenger(Messenger *m, uint8_t *data, uint16_t *lenptr) | 1876 | int wait_prepare_messenger(Messenger *m, uint8_t *data, uint16_t *lenptr) |
1877 | { | 1877 | { |
1878 | return networking_wait_prepare(m->net, sendqueue_total(m->net_crypto->lossless_udp), data, lenptr); | 1878 | return networking_wait_prepare(m->net, sendqueue_total(m->net_crypto->lossless_udp), data, lenptr); |
1879 | } | 1879 | } |
1880 | 1880 | ||
1881 | int waitexecuteMessenger(Messenger *m, uint8_t *data, uint16_t len, uint16_t milliseconds) | 1881 | int wait_execute_messenger(Messenger *m, uint8_t *data, uint16_t len, uint16_t milliseconds) |
1882 | { | 1882 | { |
1883 | return networking_wait_execute(data, len, milliseconds); | 1883 | return networking_wait_execute(data, len, milliseconds); |
1884 | }; | 1884 | }; |
1885 | 1885 | ||
1886 | void waitcleanupMessenger(Messenger *m, uint8_t *data, uint16_t len) | 1886 | void wait_cleanup_messenger(Messenger *m, uint8_t *data, uint16_t len) |
1887 | { | 1887 | { |
1888 | networking_wait_cleanup(m->net, data, len); | 1888 | networking_wait_cleanup(m->net, data, len); |
1889 | } | 1889 | } |
@@ -2037,7 +2037,7 @@ static int Messenger_load_old(Messenger *m, uint8_t *data, uint32_t length) | |||
2037 | #define MESSENGER_STATE_TYPE_NAME 4 | 2037 | #define MESSENGER_STATE_TYPE_NAME 4 |
2038 | 2038 | ||
2039 | /* return size of the messenger data (for saving) */ | 2039 | /* return size of the messenger data (for saving) */ |
2040 | uint32_t Messenger_size(Messenger *m) | 2040 | uint32_t messenger_size(Messenger *m) |
2041 | { | 2041 | { |
2042 | uint32_t size32 = sizeof(uint32_t), sizesubhead = size32 * 2; | 2042 | uint32_t size32 = sizeof(uint32_t), sizesubhead = size32 * 2; |
2043 | return size32 * 2 // global cookie | 2043 | return size32 * 2 // global cookie |
@@ -2058,7 +2058,7 @@ static uint8_t *z_state_save_subheader(uint8_t *data, uint32_t len, uint16_t typ | |||
2058 | } | 2058 | } |
2059 | 2059 | ||
2060 | /* Save the messenger in data of size Messenger_size(). */ | 2060 | /* Save the messenger in data of size Messenger_size(). */ |
2061 | void Messenger_save(Messenger *m, uint8_t *data) | 2061 | void messenger_save(Messenger *m, uint8_t *data) |
2062 | { | 2062 | { |
2063 | uint32_t len; | 2063 | uint32_t len; |
2064 | uint16_t type; | 2064 | uint16_t type; |
@@ -2161,7 +2161,7 @@ static int messenger_load_state_callback(void *outer, uint8_t *data, uint32_t le | |||
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | /* Load the messenger from data of size length. */ | 2163 | /* Load the messenger from data of size length. */ |
2164 | int Messenger_load(Messenger *m, uint8_t *data, uint32_t length) | 2164 | int messenger_load(Messenger *m, uint8_t *data, uint32_t length) |
2165 | { | 2165 | { |
2166 | uint32_t cookie_len = 2 * sizeof(uint32_t); | 2166 | uint32_t cookie_len = 2 * sizeof(uint32_t); |
2167 | 2167 | ||
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index c6ead732..aa9d8632 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h | |||
@@ -580,33 +580,33 @@ int m_msi_packet(Messenger *m, int friendnumber, uint8_t *data, uint16_t length) | |||
580 | * return allocated instance of Messenger on success. | 580 | * return allocated instance of Messenger on success. |
581 | * return 0 if there are problems. | 581 | * return 0 if there are problems. |
582 | */ | 582 | */ |
583 | Messenger *initMessenger(uint8_t ipv6enabled); | 583 | Messenger *new_messenger(uint8_t ipv6enabled); |
584 | 584 | ||
585 | /* Run this before closing shop | 585 | /* Run this before closing shop |
586 | * Free all datastructures. | 586 | * Free all datastructures. |
587 | */ | 587 | */ |
588 | void cleanupMessenger(Messenger *M); | 588 | void kill_messenger(Messenger *M); |
589 | 589 | ||
590 | /* The main loop that needs to be run at least 20 times per second. */ | 590 | /* The main loop that needs to be run at least 20 times per second. */ |
591 | void doMessenger(Messenger *m); | 591 | void do_messenger(Messenger *m); |
592 | 592 | ||
593 | /* | 593 | /* |
594 | * functions to avoid excessive polling | 594 | * functions to avoid excessive polling |
595 | */ | 595 | */ |
596 | int waitprepareMessenger(Messenger *m, uint8_t *data, uint16_t *lenptr); | 596 | int wait_prepare_messenger(Messenger *m, uint8_t *data, uint16_t *lenptr); |
597 | int waitexecuteMessenger(Messenger *m, uint8_t *data, uint16_t len, uint16_t milliseconds); | 597 | int wait_execute_messenger(Messenger *m, uint8_t *data, uint16_t len, uint16_t milliseconds); |
598 | void waitcleanupMessenger(Messenger *m, uint8_t *data, uint16_t len); | 598 | void wait_cleanup_messenger(Messenger *m, uint8_t *data, uint16_t len); |
599 | 599 | ||
600 | /* SAVING AND LOADING FUNCTIONS: */ | 600 | /* SAVING AND LOADING FUNCTIONS: */ |
601 | 601 | ||
602 | /* return size of the messenger data (for saving). */ | 602 | /* return size of the messenger data (for saving). */ |
603 | uint32_t Messenger_size(Messenger *m); | 603 | uint32_t messenger_size(Messenger *m); |
604 | 604 | ||
605 | /* Save the messenger in data (must be allocated memory of size Messenger_size()) */ | 605 | /* Save the messenger in data (must be allocated memory of size Messenger_size()) */ |
606 | void Messenger_save(Messenger *m, uint8_t *data); | 606 | void messenger_save(Messenger *m, uint8_t *data); |
607 | 607 | ||
608 | /* Load the messenger from data of size length. */ | 608 | /* Load the messenger from data of size length. */ |
609 | int Messenger_load(Messenger *m, uint8_t *data, uint32_t length); | 609 | int messenger_load(Messenger *m, uint8_t *data, uint32_t length); |
610 | 610 | ||
611 | /* Return the number of friends in the instance m. | 611 | /* Return the number of friends in the instance m. |
612 | * You should use this to determine how much memory to allocate | 612 | * You should use this to determine how much memory to allocate |
diff --git a/toxcore/tox.c b/toxcore/tox.c index 5f882965..6a0c6a62 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -609,7 +609,7 @@ int tox_isconnected(Tox *tox) | |||
609 | */ | 609 | */ |
610 | Tox *tox_new(uint8_t ipv6enabled) | 610 | Tox *tox_new(uint8_t ipv6enabled) |
611 | { | 611 | { |
612 | return initMessenger(ipv6enabled); | 612 | return new_messenger(ipv6enabled); |
613 | } | 613 | } |
614 | 614 | ||
615 | /* Run this before closing shop. | 615 | /* Run this before closing shop. |
@@ -618,14 +618,14 @@ Tox *tox_new(uint8_t ipv6enabled) | |||
618 | void tox_kill(Tox *tox) | 618 | void tox_kill(Tox *tox) |
619 | { | 619 | { |
620 | Messenger *m = tox; | 620 | Messenger *m = tox; |
621 | cleanupMessenger(m); | 621 | kill_messenger(m); |
622 | } | 622 | } |
623 | 623 | ||
624 | /* The main loop that needs to be run at least 20 times per second. */ | 624 | /* The main loop that needs to be run at least 20 times per second. */ |
625 | void tox_do(Tox *tox) | 625 | void tox_do(Tox *tox) |
626 | { | 626 | { |
627 | Messenger *m = tox; | 627 | Messenger *m = tox; |
628 | doMessenger(m); | 628 | do_messenger(m); |
629 | } | 629 | } |
630 | 630 | ||
631 | /* | 631 | /* |
@@ -634,19 +634,19 @@ void tox_do(Tox *tox) | |||
634 | int tox_wait_prepare(Tox *tox, uint8_t *data, uint16_t *lenptr) | 634 | int tox_wait_prepare(Tox *tox, uint8_t *data, uint16_t *lenptr) |
635 | { | 635 | { |
636 | Messenger *m = tox; | 636 | Messenger *m = tox; |
637 | return waitprepareMessenger(m, data, lenptr); | 637 | return wait_prepare_messenger(m, data, lenptr); |
638 | } | 638 | } |
639 | 639 | ||
640 | int tox_wait_execute(Tox *tox, uint8_t *data, uint16_t len, uint16_t milliseconds) | 640 | int tox_wait_execute(Tox *tox, uint8_t *data, uint16_t len, uint16_t milliseconds) |
641 | { | 641 | { |
642 | Messenger *m = tox; | 642 | Messenger *m = tox; |
643 | return waitexecuteMessenger(m, data, len, milliseconds); | 643 | return wait_execute_messenger(m, data, len, milliseconds); |
644 | } | 644 | } |
645 | 645 | ||
646 | void tox_wait_cleanup(Tox *tox, uint8_t *data, uint16_t len) | 646 | void tox_wait_cleanup(Tox *tox, uint8_t *data, uint16_t len) |
647 | { | 647 | { |
648 | Messenger *m = tox; | 648 | Messenger *m = tox; |
649 | waitcleanupMessenger(m, data, len); | 649 | wait_cleanup_messenger(m, data, len); |
650 | } | 650 | } |
651 | 651 | ||
652 | /* SAVING AND LOADING FUNCTIONS: */ | 652 | /* SAVING AND LOADING FUNCTIONS: */ |
@@ -655,20 +655,20 @@ void tox_wait_cleanup(Tox *tox, uint8_t *data, uint16_t len) | |||
655 | uint32_t tox_size(Tox *tox) | 655 | uint32_t tox_size(Tox *tox) |
656 | { | 656 | { |
657 | Messenger *m = tox; | 657 | Messenger *m = tox; |
658 | return Messenger_size(m); | 658 | return messenger_size(m); |
659 | } | 659 | } |
660 | 660 | ||
661 | /* Save the messenger in data (must be allocated memory of size Messenger_size()). */ | 661 | /* Save the messenger in data (must be allocated memory of size Messenger_size()). */ |
662 | void tox_save(Tox *tox, uint8_t *data) | 662 | void tox_save(Tox *tox, uint8_t *data) |
663 | { | 663 | { |
664 | Messenger *m = tox; | 664 | Messenger *m = tox; |
665 | Messenger_save(m, data); | 665 | messenger_save(m, data); |
666 | } | 666 | } |
667 | 667 | ||
668 | /* Load the messenger from data of size length. */ | 668 | /* Load the messenger from data of size length. */ |
669 | int tox_load(Tox *tox, uint8_t *data, uint32_t length) | 669 | int tox_load(Tox *tox, uint8_t *data, uint32_t length) |
670 | { | 670 | { |
671 | Messenger *m = tox; | 671 | Messenger *m = tox; |
672 | return Messenger_load(m, data, length); | 672 | return messenger_load(m, data, length); |
673 | } | 673 | } |
674 | 674 | ||