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 --- toxcore/ping.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'toxcore/ping.c') diff --git a/toxcore/ping.c b/toxcore/ping.c index 3daeff86..3767805d 100644 --- a/toxcore/ping.c +++ b/toxcore/ping.c @@ -72,7 +72,7 @@ int32_t ping_send_request(Ping *ping, IP_Port ipp, const uint8_t *public_key) uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE]; // generate key to encrypt ping_id with recipient privkey - DHT_get_shared_key_sent(ping->dht, shared_key, public_key); + dht_get_shared_key_sent(ping->dht, shared_key, public_key); // Generate random ping_id. uint8_t data[PING_DATA_SIZE]; id_copy(data, public_key); @@ -154,7 +154,7 @@ static int handle_ping_request(void *object, IP_Port source, const uint8_t *pack uint8_t ping_plain[PING_PLAIN_SIZE]; // Decrypt ping_id - DHT_get_shared_key_recv(dht, shared_key, packet + 1); + dht_get_shared_key_recv(dht, shared_key, packet + 1); rc = decrypt_data_symmetric(shared_key, packet + 1 + CRYPTO_PUBLIC_KEY_SIZE, packet + 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE, @@ -196,7 +196,7 @@ static int handle_ping_response(void *object, IP_Port source, const uint8_t *pac uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE]; // generate key to encrypt ping_id with recipient privkey - DHT_get_shared_key_sent(ping->dht, shared_key, packet + 1); + dht_get_shared_key_sent(ping->dht, shared_key, packet + 1); uint8_t ping_plain[PING_PLAIN_SIZE]; // Decrypt ping_id @@ -291,7 +291,7 @@ int32_t ping_add(Ping *ping, const uint8_t *public_key, IP_Port ip_port) IP_Port temp; - if (DHT_getfriendip(ping->dht, public_key, &temp) == 0) { + if (dht_getfriendip(ping->dht, public_key, &temp) == 0) { ping_send_request(ping, ip_port, public_key); return -1; } -- cgit v1.2.3