From 8739f7fccb7cafc54ca0f5fa074c9a740f7048ba Mon Sep 17 00:00:00 2001 From: iphydf Date: Thu, 5 Jul 2018 10:31:29 +0000 Subject: Make tox.c unambiguously parseable. Rules: 1. Constants are uppercase names: THE_CONSTANT. 2. SUE[1] types start with an uppercase letter and have at least one lowercase letter in it: The_Type, THE_Type. 3. Function types end in "_cb": tox_friend_connection_cb. 4. Variable and function names are all lowercase: the_function. This makes it easier for humans reading the code to determine what an identifier means. I'm not convinced by the enum type name change, but I don't know a better rule. Currently, a lot of enum types are spelled like constants, which is confusing. [1] struct/union/enum --- other/DHT_bootstrap.c | 8 ++++---- other/bootstrap_daemon/src/config.c | 2 +- other/bootstrap_daemon/src/tox-bootstrapd.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'other') diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index ff73c166..f263b471 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c @@ -117,7 +117,7 @@ int main(int argc, char *argv[]) ip_init(&ip, ipv6enabled); Logger *logger = logger_new(); - DHT *dht = new_DHT(logger, new_networking(logger, ip, PORT), true); + DHT *dht = new_dht(logger, new_networking(logger, ip, PORT), true); Onion *onion = new_onion(dht); Onion_Announce *onion_a = new_onion_announce(dht); @@ -171,7 +171,7 @@ int main(int argc, char *argv[]) printf("Trying to bootstrap into the network...\n"); uint16_t port = net_htons(atoi(argv[argvoffset + 2])); uint8_t *bootstrap_key = hex_string_to_bin(argv[argvoffset + 3]); - int res = DHT_bootstrap_from_address(dht, argv[argvoffset + 1], + int res = dht_bootstrap_from_address(dht, argv[argvoffset + 1], ipv6enabled, port, bootstrap_key); free(bootstrap_key); @@ -187,12 +187,12 @@ int main(int argc, char *argv[]) lan_discovery_init(dht); while (1) { - if (is_waiting_for_dht_connection && DHT_isconnected(dht)) { + if (is_waiting_for_dht_connection && dht_isconnected(dht)) { printf("Connected to other bootstrap node successfully.\n"); is_waiting_for_dht_connection = 0; } - do_DHT(dht); + do_dht(dht); if (is_timeout(last_LANdiscovery, is_waiting_for_dht_connection ? 5 : LAN_DISCOVERY_INTERVAL)) { lan_discovery_send(net_htons(PORT), dht); diff --git a/other/bootstrap_daemon/src/config.c b/other/bootstrap_daemon/src/config.c index a3c1f250..9fde33b2 100644 --- a/other/bootstrap_daemon/src/config.c +++ b/other/bootstrap_daemon/src/config.c @@ -408,7 +408,7 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6) } bs_public_key_bin = hex_string_to_bin(bs_public_key); - address_resolved = DHT_bootstrap_from_address(dht, bs_address, enable_ipv6, net_htons(bs_port), + address_resolved = dht_bootstrap_from_address(dht, bs_address, enable_ipv6, net_htons(bs_port), bs_public_key_bin); free(bs_public_key_bin); diff --git a/other/bootstrap_daemon/src/tox-bootstrapd.c b/other/bootstrap_daemon/src/tox-bootstrapd.c index ea849673..3c6d5d2c 100644 --- a/other/bootstrap_daemon/src/tox-bootstrapd.c +++ b/other/bootstrap_daemon/src/tox-bootstrapd.c @@ -250,7 +250,7 @@ int main(int argc, char *argv[]) } } - DHT *dht = new_DHT(logger, net, true); + DHT *dht = new_dht(logger, net, true); if (dht == nullptr) { log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox DHT instance. Exiting.\n"); @@ -333,7 +333,7 @@ int main(int argc, char *argv[]) } while (1) { - do_DHT(dht); + do_dht(dht); if (enable_lan_discovery && is_timeout(last_LANdiscovery, LAN_DISCOVERY_INTERVAL)) { lan_discovery_send(net_htons_port, dht); @@ -346,7 +346,7 @@ int main(int argc, char *argv[]) networking_poll(dht_get_net(dht), nullptr); - if (waiting_for_dht_connection && DHT_isconnected(dht)) { + if (waiting_for_dht_connection && dht_isconnected(dht)) { log_write(LOG_LEVEL_INFO, "Connected to another bootstrap node successfully.\n"); waiting_for_dht_connection = 0; } -- cgit v1.2.3