mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
47a527509d
Removed a pointless declaration of a function in lan_discovery_test and cleaned up the one error message there. Did an entire restructuring of the version_test using macros that resulted in fewer lines of code but more thorough testing. Formatting of version_test.c back to old way, save comments and one change Missing space My greatest enemy Add `#include <cstdio>` for `std::printf`. 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 Use run_auto_test.h test fixture for some auto-tests. Most of the auto-tests should use this fixture, but I've only done a few to set an example.
33 lines
878 B
C
33 lines
878 B
C
#ifndef _XOPEN_SOURCE
|
|
#define _XOPEN_SOURCE 600
|
|
#endif
|
|
|
|
#include "helpers.h"
|
|
|
|
int main(void)
|
|
{
|
|
setvbuf(stdout, nullptr, _IONBF, 0);
|
|
Tox *tox1 = tox_new_log_lan(nullptr, nullptr, nullptr, /* lan_discovery */true);
|
|
Tox *tox2 = tox_new_log_lan(nullptr, nullptr, nullptr, /* lan_discovery */true);
|
|
|
|
printf("Waiting for LAN discovery. This loop will attempt to run until successful.");
|
|
|
|
while (tox_self_get_connection_status(tox1) == TOX_CONNECTION_NONE ||
|
|
tox_self_get_connection_status(tox2) == TOX_CONNECTION_NONE) {
|
|
printf(".");
|
|
fflush(stdout);
|
|
|
|
tox_iterate(tox1, nullptr);
|
|
tox_iterate(tox2, nullptr);
|
|
c_sleep(1000);
|
|
}
|
|
|
|
printf(" %d <-> %d\n",
|
|
tox_self_get_connection_status(tox1),
|
|
tox_self_get_connection_status(tox2));
|
|
|
|
tox_kill(tox2);
|
|
tox_kill(tox1);
|
|
return 0;
|
|
}
|