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 /testing | |
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 'testing')
-rw-r--r-- | testing/DHT_test.c | 12 | ||||
-rw-r--r-- | testing/Messenger_test.c | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index 59856395..336e7e18 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -128,7 +128,7 @@ static void print_friendlist(DHT *dht) | |||
128 | 128 | ||
129 | print_client_id(dht_get_friend_public_key(dht, k)); | 129 | print_client_id(dht_get_friend_public_key(dht, k)); |
130 | 130 | ||
131 | int friendok = DHT_getfriendip(dht, dht_get_friend_public_key(dht, k), &p_ip); | 131 | int friendok = dht_getfriendip(dht, dht_get_friend_public_key(dht, k), &p_ip); |
132 | char ip_str[IP_NTOA_LEN]; | 132 | char ip_str[IP_NTOA_LEN]; |
133 | printf("\nIP: %s:%u (%d)", ip_ntoa(&p_ip.ip, ip_str, sizeof(ip_str)), net_ntohs(p_ip.port), friendok); | 133 | printf("\nIP: %s:%u (%d)", ip_ntoa(&p_ip.ip, ip_str, sizeof(ip_str)), net_ntohs(p_ip.port), friendok); |
134 | 134 | ||
@@ -190,7 +190,7 @@ int main(int argc, char *argv[]) | |||
190 | IP ip; | 190 | IP ip; |
191 | ip_init(&ip, ipv6enabled); | 191 | ip_init(&ip, ipv6enabled); |
192 | 192 | ||
193 | DHT *dht = new_DHT(nullptr, new_networking(nullptr, ip, PORT), true); | 193 | DHT *dht = new_dht(nullptr, new_networking(nullptr, ip, PORT), true); |
194 | printf("OUR ID: "); | 194 | printf("OUR ID: "); |
195 | uint32_t i; | 195 | uint32_t i; |
196 | 196 | ||
@@ -216,14 +216,14 @@ int main(int argc, char *argv[]) | |||
216 | } | 216 | } |
217 | 217 | ||
218 | uint8_t *bin_id = hex_string_to_bin(temp_id); | 218 | uint8_t *bin_id = hex_string_to_bin(temp_id); |
219 | DHT_addfriend(dht, bin_id, 0, 0, 0, 0); | 219 | dht_addfriend(dht, bin_id, 0, 0, 0, 0); |
220 | free(bin_id); | 220 | free(bin_id); |
221 | 221 | ||
222 | perror("Initialization"); | 222 | perror("Initialization"); |
223 | 223 | ||
224 | uint16_t port = net_htons(atoi(argv[argvoffset + 2])); | 224 | uint16_t port = net_htons(atoi(argv[argvoffset + 2])); |
225 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); | 225 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); |
226 | int res = DHT_bootstrap_from_address(dht, argv[argvoffset + 1], ipv6enabled, port, binary_string); | 226 | int res = dht_bootstrap_from_address(dht, argv[argvoffset + 1], ipv6enabled, port, binary_string); |
227 | free(binary_string); | 227 | free(binary_string); |
228 | 228 | ||
229 | if (!res) { | 229 | if (!res) { |
@@ -238,12 +238,12 @@ int main(int argc, char *argv[]) | |||
238 | #endif | 238 | #endif |
239 | 239 | ||
240 | while (1) { | 240 | while (1) { |
241 | do_DHT(dht); | 241 | do_dht(dht); |
242 | 242 | ||
243 | #if 0 /* TODO(slvr): */ | 243 | #if 0 /* TODO(slvr): */ |
244 | 244 | ||
245 | while (receivepacket(&ip_port, data, &length) != -1) { | 245 | while (receivepacket(&ip_port, data, &length) != -1) { |
246 | if (DHT_handlepacket(data, length, ip_port) && friendreq_handlepacket(data, length, ip_port)) { | 246 | if (dht_handlepacket(data, length, ip_port) && friendreq_handlepacket(data, length, ip_port)) { |
247 | //unhandled packet | 247 | //unhandled packet |
248 | printpacket(data, length, ip_port); | 248 | printpacket(data, length, ip_port); |
249 | } else { | 249 | } else { |
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index ebc1975a..7885779b 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c | |||
@@ -121,7 +121,7 @@ int main(int argc, char *argv[]) | |||
121 | if (argc == argvoffset + 4) { | 121 | if (argc == argvoffset + 4) { |
122 | uint16_t port = net_htons(atoi(argv[argvoffset + 2])); | 122 | uint16_t port = net_htons(atoi(argv[argvoffset + 2])); |
123 | uint8_t *bootstrap_key = hex_string_to_bin(argv[argvoffset + 3]); | 123 | uint8_t *bootstrap_key = hex_string_to_bin(argv[argvoffset + 3]); |
124 | int res = DHT_bootstrap_from_address(m->dht, argv[argvoffset + 1], | 124 | int res = dht_bootstrap_from_address(m->dht, argv[argvoffset + 1], |
125 | ipv6enabled, port, bootstrap_key); | 125 | ipv6enabled, port, bootstrap_key); |
126 | free(bootstrap_key); | 126 | free(bootstrap_key); |
127 | 127 | ||