diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-07-05 10:31:29 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-05 23:09:28 +0000 |
commit | 8739f7fccb7cafc54ca0f5fa074c9a740f7048ba (patch) | |
tree | 88e9f53fa6e734cd8095487d1896c56f844c782c /other | |
parent | 64d0297acc7d6a1697683052e15cc76383312c38 (diff) |
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
Diffstat (limited to 'other')
-rw-r--r-- | other/DHT_bootstrap.c | 8 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/config.c | 2 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/tox-bootstrapd.c | 6 |
3 files changed, 8 insertions, 8 deletions
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[]) | |||
117 | ip_init(&ip, ipv6enabled); | 117 | ip_init(&ip, ipv6enabled); |
118 | 118 | ||
119 | Logger *logger = logger_new(); | 119 | Logger *logger = logger_new(); |
120 | DHT *dht = new_DHT(logger, new_networking(logger, ip, PORT), true); | 120 | DHT *dht = new_dht(logger, new_networking(logger, ip, PORT), true); |
121 | Onion *onion = new_onion(dht); | 121 | Onion *onion = new_onion(dht); |
122 | Onion_Announce *onion_a = new_onion_announce(dht); | 122 | Onion_Announce *onion_a = new_onion_announce(dht); |
123 | 123 | ||
@@ -171,7 +171,7 @@ int main(int argc, char *argv[]) | |||
171 | printf("Trying to bootstrap into the network...\n"); | 171 | printf("Trying to bootstrap into the network...\n"); |
172 | uint16_t port = net_htons(atoi(argv[argvoffset + 2])); | 172 | uint16_t port = net_htons(atoi(argv[argvoffset + 2])); |
173 | uint8_t *bootstrap_key = hex_string_to_bin(argv[argvoffset + 3]); | 173 | uint8_t *bootstrap_key = hex_string_to_bin(argv[argvoffset + 3]); |
174 | int res = DHT_bootstrap_from_address(dht, argv[argvoffset + 1], | 174 | int res = dht_bootstrap_from_address(dht, argv[argvoffset + 1], |
175 | ipv6enabled, port, bootstrap_key); | 175 | ipv6enabled, port, bootstrap_key); |
176 | free(bootstrap_key); | 176 | free(bootstrap_key); |
177 | 177 | ||
@@ -187,12 +187,12 @@ int main(int argc, char *argv[]) | |||
187 | lan_discovery_init(dht); | 187 | lan_discovery_init(dht); |
188 | 188 | ||
189 | while (1) { | 189 | while (1) { |
190 | if (is_waiting_for_dht_connection && DHT_isconnected(dht)) { | 190 | if (is_waiting_for_dht_connection && dht_isconnected(dht)) { |
191 | printf("Connected to other bootstrap node successfully.\n"); | 191 | printf("Connected to other bootstrap node successfully.\n"); |
192 | is_waiting_for_dht_connection = 0; | 192 | is_waiting_for_dht_connection = 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | do_DHT(dht); | 195 | do_dht(dht); |
196 | 196 | ||
197 | if (is_timeout(last_LANdiscovery, is_waiting_for_dht_connection ? 5 : LAN_DISCOVERY_INTERVAL)) { | 197 | if (is_timeout(last_LANdiscovery, is_waiting_for_dht_connection ? 5 : LAN_DISCOVERY_INTERVAL)) { |
198 | lan_discovery_send(net_htons(PORT), dht); | 198 | 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) | |||
408 | } | 408 | } |
409 | 409 | ||
410 | bs_public_key_bin = hex_string_to_bin(bs_public_key); | 410 | bs_public_key_bin = hex_string_to_bin(bs_public_key); |
411 | address_resolved = DHT_bootstrap_from_address(dht, bs_address, enable_ipv6, net_htons(bs_port), | 411 | address_resolved = dht_bootstrap_from_address(dht, bs_address, enable_ipv6, net_htons(bs_port), |
412 | bs_public_key_bin); | 412 | bs_public_key_bin); |
413 | free(bs_public_key_bin); | 413 | free(bs_public_key_bin); |
414 | 414 | ||
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[]) | |||
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | DHT *dht = new_DHT(logger, net, true); | 253 | DHT *dht = new_dht(logger, net, true); |
254 | 254 | ||
255 | if (dht == nullptr) { | 255 | if (dht == nullptr) { |
256 | log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox DHT instance. Exiting.\n"); | 256 | log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox DHT instance. Exiting.\n"); |
@@ -333,7 +333,7 @@ int main(int argc, char *argv[]) | |||
333 | } | 333 | } |
334 | 334 | ||
335 | while (1) { | 335 | while (1) { |
336 | do_DHT(dht); | 336 | do_dht(dht); |
337 | 337 | ||
338 | if (enable_lan_discovery && is_timeout(last_LANdiscovery, LAN_DISCOVERY_INTERVAL)) { | 338 | if (enable_lan_discovery && is_timeout(last_LANdiscovery, LAN_DISCOVERY_INTERVAL)) { |
339 | lan_discovery_send(net_htons_port, dht); | 339 | lan_discovery_send(net_htons_port, dht); |
@@ -346,7 +346,7 @@ int main(int argc, char *argv[]) | |||
346 | 346 | ||
347 | networking_poll(dht_get_net(dht), nullptr); | 347 | networking_poll(dht_get_net(dht), nullptr); |
348 | 348 | ||
349 | if (waiting_for_dht_connection && DHT_isconnected(dht)) { | 349 | if (waiting_for_dht_connection && dht_isconnected(dht)) { |
350 | log_write(LOG_LEVEL_INFO, "Connected to another bootstrap node successfully.\n"); | 350 | log_write(LOG_LEVEL_INFO, "Connected to another bootstrap node successfully.\n"); |
351 | waiting_for_dht_connection = 0; | 351 | waiting_for_dht_connection = 0; |
352 | } | 352 | } |