diff options
-rw-r--r-- | other/DHT_bootstrap.c | 1 | ||||
-rw-r--r-- | testing/DHT_test.c | 1 | ||||
-rw-r--r-- | testing/Lossless_UDP_testclient.c | 2 | ||||
-rw-r--r-- | testing/Lossless_UDP_testserver.c | 2 | ||||
-rw-r--r-- | testing/Messenger_test.c | 1 | ||||
-rw-r--r-- | testing/misc_tools.c | 33 | ||||
-rw-r--r-- | toxcore/util.c | 32 | ||||
-rw-r--r-- | toxcore/util.h | 2 |
8 files changed, 35 insertions, 39 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index f2e792ac..f5fa9818 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include "../toxcore/DHT.h" | 33 | #include "../toxcore/DHT.h" |
34 | #include "../toxcore/friend_requests.h" | 34 | #include "../toxcore/friend_requests.h" |
35 | #include "../testing/misc_tools.c" | 35 | #include "../testing/misc_tools.c" |
36 | #include "../toxcore/util.h" | ||
37 | 36 | ||
38 | /* Sleep function (x = milliseconds) */ | 37 | /* Sleep function (x = milliseconds) */ |
39 | #ifdef WIN32 | 38 | #ifdef WIN32 |
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index 5451c467..ba8c2f23 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -34,7 +34,6 @@ | |||
34 | //#include "../core/network.h" | 34 | //#include "../core/network.h" |
35 | #include "../toxcore/DHT.h" | 35 | #include "../toxcore/DHT.h" |
36 | #include "../toxcore/friend_requests.h" | 36 | #include "../toxcore/friend_requests.h" |
37 | #include "../toxcore/util.h" | ||
38 | #include "misc_tools.c" | 37 | #include "misc_tools.c" |
39 | 38 | ||
40 | #include <string.h> | 39 | #include <string.h> |
diff --git a/testing/Lossless_UDP_testclient.c b/testing/Lossless_UDP_testclient.c index e36ac6eb..7891ce64 100644 --- a/testing/Lossless_UDP_testclient.c +++ b/testing/Lossless_UDP_testclient.c | |||
@@ -34,7 +34,7 @@ | |||
34 | 34 | ||
35 | #include "../toxcore/network.h" | 35 | #include "../toxcore/network.h" |
36 | #include "../toxcore/Lossless_UDP.h" | 36 | #include "../toxcore/Lossless_UDP.h" |
37 | #include "../toxcore/util.h" | 37 | #include "misc_tools.c" |
38 | 38 | ||
39 | #ifdef WIN32 | 39 | #ifdef WIN32 |
40 | 40 | ||
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c index 97c3eb46..0fd4edd9 100644 --- a/testing/Lossless_UDP_testserver.c +++ b/testing/Lossless_UDP_testserver.c | |||
@@ -34,7 +34,7 @@ | |||
34 | 34 | ||
35 | #include "../toxcore/network.h" | 35 | #include "../toxcore/network.h" |
36 | #include "../toxcore/Lossless_UDP.h" | 36 | #include "../toxcore/Lossless_UDP.h" |
37 | #include "../toxcore/util.h" | 37 | #include "misc_tools.c" |
38 | 38 | ||
39 | //Sleep function (x = milliseconds) | 39 | //Sleep function (x = milliseconds) |
40 | #ifdef WIN32 | 40 | #ifdef WIN32 |
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index 93069226..14d9ca20 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c | |||
@@ -43,7 +43,6 @@ | |||
43 | 43 | ||
44 | #include "../toxcore/Messenger.h" | 44 | #include "../toxcore/Messenger.h" |
45 | #include "misc_tools.c" | 45 | #include "misc_tools.c" |
46 | #include "../toxcore/util.h" | ||
47 | 46 | ||
48 | #ifdef WIN32 | 47 | #ifdef WIN32 |
49 | 48 | ||
diff --git a/testing/misc_tools.c b/testing/misc_tools.c index c4dce1bb..824200d8 100644 --- a/testing/misc_tools.c +++ b/testing/misc_tools.c | |||
@@ -46,3 +46,36 @@ unsigned char *hex_string_to_bin(char hex_string[]) | |||
46 | 46 | ||
47 | return val; | 47 | return val; |
48 | } | 48 | } |
49 | |||
50 | |||
51 | int cmdline_parsefor_ipv46(int argc, char **argv, uint8_t *ipv6enabled) | ||
52 | { | ||
53 | int argvoffset = 0, argi; | ||
54 | for(argi = 1; argi < argc; argi++) | ||
55 | if (!strncasecmp(argv[argi], "--ipv", 5)) { | ||
56 | if (argv[argi][5] && !argv[argi][6]) { | ||
57 | char c = argv[argi][5]; | ||
58 | if (c == '4') | ||
59 | *ipv6enabled = 0; | ||
60 | else if (c == '6') | ||
61 | *ipv6enabled = 1; | ||
62 | else { | ||
63 | printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]); | ||
64 | return -1; | ||
65 | } | ||
66 | } | ||
67 | else { | ||
68 | printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]); | ||
69 | return -1; | ||
70 | } | ||
71 | |||
72 | if (argvoffset != argi - 1) { | ||
73 | printf("Argument must come first: %s.\n", argv[argi]); | ||
74 | return -1; | ||
75 | } | ||
76 | |||
77 | argvoffset++; | ||
78 | } | ||
79 | |||
80 | return argvoffset; | ||
81 | }; | ||
diff --git a/toxcore/util.c b/toxcore/util.c index 7b5ddc49..19d464d4 100644 --- a/toxcore/util.c +++ b/toxcore/util.c | |||
@@ -43,38 +43,6 @@ void id_cpy(uint8_t *dest, uint8_t *src) | |||
43 | memcpy(dest, src, CLIENT_ID_SIZE); | 43 | memcpy(dest, src, CLIENT_ID_SIZE); |
44 | } | 44 | } |
45 | 45 | ||
46 | int cmdline_parsefor_ipv46(int argc, char **argv, uint8_t *ipv6enabled) | ||
47 | { | ||
48 | int argvoffset = 0, argi; | ||
49 | for(argi = 1; argi < argc; argi++) | ||
50 | if (!strncasecmp(argv[argi], "--ipv", 5)) { | ||
51 | if (argv[argi][5] && !argv[argi][6]) { | ||
52 | char c = argv[argi][5]; | ||
53 | if (c == '4') | ||
54 | *ipv6enabled = 0; | ||
55 | else if (c == '6') | ||
56 | *ipv6enabled = 1; | ||
57 | else { | ||
58 | printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]); | ||
59 | return -1; | ||
60 | } | ||
61 | } | ||
62 | else { | ||
63 | printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]); | ||
64 | return -1; | ||
65 | } | ||
66 | |||
67 | if (argvoffset != argi - 1) { | ||
68 | printf("Argument must come first: %s.\n", argv[argi]); | ||
69 | return -1; | ||
70 | } | ||
71 | |||
72 | argvoffset++; | ||
73 | } | ||
74 | |||
75 | return argvoffset; | ||
76 | }; | ||
77 | |||
78 | #ifdef LOGGING | 46 | #ifdef LOGGING |
79 | char logbuffer[512]; | 47 | char logbuffer[512]; |
80 | static FILE *logfile = NULL; | 48 | static FILE *logfile = NULL; |
diff --git a/toxcore/util.h b/toxcore/util.h index e7be2d51..71be84ca 100644 --- a/toxcore/util.h +++ b/toxcore/util.h | |||
@@ -16,8 +16,6 @@ uint64_t random_64b(); | |||
16 | bool id_eq(uint8_t *dest, uint8_t *src); | 16 | bool id_eq(uint8_t *dest, uint8_t *src); |
17 | void id_cpy(uint8_t *dest, uint8_t *src); | 17 | void id_cpy(uint8_t *dest, uint8_t *src); |
18 | 18 | ||
19 | int cmdline_parsefor_ipv46(int argc, char **argv, uint8_t *ipv6enabled); | ||
20 | |||
21 | #undef LOGGING | 19 | #undef LOGGING |
22 | /* #define LOGGING */ | 20 | /* #define LOGGING */ |
23 | #ifdef LOGGING | 21 | #ifdef LOGGING |