summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Biro <nurupo.contributions@gmail.com>2016-01-01 00:55:09 -0500
committerMaxim Biro <nurupo.contributions@gmail.com>2016-01-01 00:55:09 -0500
commitda76da6c95fedf6014b69ed475cce074ad0afda9 (patch)
tree6df3ca30e72982a5166b526be192ee745a9161ef
parent7d86caf51fd2f127a7f12c90293981650f6aae3c (diff)
Remove dependency on files from testing directory
Also remove unneeded includes and refactor sleep define.
-rw-r--r--other/bootstrap_daemon/src/config.c32
-rw-r--r--other/bootstrap_daemon/src/tox-bootstrapd.c17
2 files changed, 29 insertions, 20 deletions
diff --git a/other/bootstrap_daemon/src/config.c b/other/bootstrap_daemon/src/config.c
index 270d399f..ee9fbdd2 100644
--- a/other/bootstrap_daemon/src/config.c
+++ b/other/bootstrap_daemon/src/config.c
@@ -26,16 +26,13 @@
26#include "config_defaults.h" 26#include "config_defaults.h"
27#include "log.h" 27#include "log.h"
28 28
29// C 29#include <stdlib.h>
30//#include <stdlib.h> 30#include <string.h>
31#include <string.h> 31#include <string.h>
32 32
33// 3rd party
34#include <libconfig.h> 33#include <libconfig.h>
35 34
36// toxcore
37#include "../../bootstrap_node_packets.h" 35#include "../../bootstrap_node_packets.h"
38//#include "../../testing/misc_tools.c"
39 36
40// Parses tcp relay ports from `cfg` and puts them into `tcp_relay_ports` array 37// Parses tcp relay ports from `cfg` and puts them into `tcp_relay_ports` array
41// 38//
@@ -296,6 +293,31 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
296 return 1; 293 return 1;
297} 294}
298 295
296// Converts a hex string with even number of characters into binary
297//
298// You are responsible for freeing the return value!
299//
300// Returns binary on success,
301// NULL on failure
302
303uint8_t *hex_string_to_bin(char *hex_string)
304{
305 if (strlen(hex_string) % 2 != 0) {
306 return NULL;
307 }
308
309 size_t len = strlen(hex_string) / 2;
310 uint8_t *ret = malloc(len);
311
312 char *pos = hex_string;
313 size_t i;
314 for (i = 0; i < len; ++i, pos += 2) {
315 sscanf(pos, "%2hhx", &ret[i]);
316 }
317
318 return ret;
319}
320
299int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6) 321int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6)
300{ 322{
301 const char *NAME_BOOTSTRAP_NODES = "bootstrap_nodes"; 323 const char *NAME_BOOTSTRAP_NODES = "bootstrap_nodes";
diff --git a/other/bootstrap_daemon/src/tox-bootstrapd.c b/other/bootstrap_daemon/src/tox-bootstrapd.c
index 8ffef009..45b7add0 100644
--- a/other/bootstrap_daemon/src/tox-bootstrapd.c
+++ b/other/bootstrap_daemon/src/tox-bootstrapd.c
@@ -22,11 +22,6 @@
22 */ 22 */
23 23
24// system provided 24// system provided
25#include <arpa/inet.h>
26#include <getopt.h>
27#include <syslog.h>
28#include <sys/stat.h>
29#include <sys/types.h>
30#include <unistd.h> 25#include <unistd.h>
31 26
32// C 27// C
@@ -34,11 +29,6 @@
34#include <stdlib.h> 29#include <stdlib.h>
35#include <string.h> 30#include <string.h>
36 31
37// ./configure
38#ifdef HAVE_CONFIG_H
39#include "config.h"
40#endif
41
42// toxcore 32// toxcore
43#include "../../toxcore/LAN_discovery.h" 33#include "../../toxcore/LAN_discovery.h"
44#include "../../toxcore/onion_announce.h" 34#include "../../toxcore/onion_announce.h"
@@ -47,16 +37,13 @@
47 37
48// misc 38// misc
49#include "../bootstrap_node_packets.h" 39#include "../bootstrap_node_packets.h"
50#include "../../testing/misc_tools.c"
51 40
52#include "command_line_arguments.h" 41#include "command_line_arguments.h"
53#include "config.h" 42#include "config.h"
54#include "global.h" 43#include "global.h"
55#include "log.h" 44#include "log.h"
56 45
57 46#define SLEEP_MILLISECONDS(MS) usleep(1000*MS)
58#define SLEEP_TIME_MILLISECONDS 30
59#define sleep usleep(1000*SLEEP_TIME_MILLISECONDS)
60 47
61// Uses the already existing key or creates one if it didn't exist 48// Uses the already existing key or creates one if it didn't exist
62// 49//
@@ -346,7 +333,7 @@ int main(int argc, char *argv[])
346 waiting_for_dht_connection = 0; 333 waiting_for_dht_connection = 0;
347 } 334 }
348 335
349 sleep; 336 SLEEP_MILLISECONDS(30);
350 } 337 }
351 338
352 return 1; 339 return 1;