mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Remove dependency on files from testing directory
Also remove unneeded includes and refactor sleep define.
This commit is contained in:
parent
7d86caf51f
commit
da76da6c95
@ -26,16 +26,13 @@
|
||||
#include "config_defaults.h"
|
||||
#include "log.h"
|
||||
|
||||
// C
|
||||
//#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string.h>
|
||||
|
||||
// 3rd party
|
||||
#include <libconfig.h>
|
||||
|
||||
// toxcore
|
||||
#include "../../bootstrap_node_packets.h"
|
||||
//#include "../../testing/misc_tools.c"
|
||||
|
||||
// Parses tcp relay ports from `cfg` and puts them into `tcp_relay_ports` array
|
||||
//
|
||||
@ -296,6 +293,31 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Converts a hex string with even number of characters into binary
|
||||
//
|
||||
// You are responsible for freeing the return value!
|
||||
//
|
||||
// Returns binary on success,
|
||||
// NULL on failure
|
||||
|
||||
uint8_t *hex_string_to_bin(char *hex_string)
|
||||
{
|
||||
if (strlen(hex_string) % 2 != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t len = strlen(hex_string) / 2;
|
||||
uint8_t *ret = malloc(len);
|
||||
|
||||
char *pos = hex_string;
|
||||
size_t i;
|
||||
for (i = 0; i < len; ++i, pos += 2) {
|
||||
sscanf(pos, "%2hhx", &ret[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6)
|
||||
{
|
||||
const char *NAME_BOOTSTRAP_NODES = "bootstrap_nodes";
|
||||
|
@ -22,11 +22,6 @@
|
||||
*/
|
||||
|
||||
// system provided
|
||||
#include <arpa/inet.h>
|
||||
#include <getopt.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// C
|
||||
@ -34,11 +29,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// ./configure
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
// toxcore
|
||||
#include "../../toxcore/LAN_discovery.h"
|
||||
#include "../../toxcore/onion_announce.h"
|
||||
@ -47,16 +37,13 @@
|
||||
|
||||
// misc
|
||||
#include "../bootstrap_node_packets.h"
|
||||
#include "../../testing/misc_tools.c"
|
||||
|
||||
#include "command_line_arguments.h"
|
||||
#include "config.h"
|
||||
#include "global.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
#define SLEEP_TIME_MILLISECONDS 30
|
||||
#define sleep usleep(1000*SLEEP_TIME_MILLISECONDS)
|
||||
#define SLEEP_MILLISECONDS(MS) usleep(1000*MS)
|
||||
|
||||
// Uses the already existing key or creates one if it didn't exist
|
||||
//
|
||||
@ -346,7 +333,7 @@ int main(int argc, char *argv[])
|
||||
waiting_for_dht_connection = 0;
|
||||
}
|
||||
|
||||
sleep;
|
||||
SLEEP_MILLISECONDS(30);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user