toxcore/util.h:

- moved cmdline_parsefor_ipv46() to testing/misc_tools.c
This commit is contained in:
Coren[m] 2013-09-11 15:19:39 +02:00
parent a326e851ba
commit d35fee43ba
8 changed files with 35 additions and 39 deletions

View File

@ -33,7 +33,6 @@
#include "../toxcore/DHT.h"
#include "../toxcore/friend_requests.h"
#include "../testing/misc_tools.c"
#include "../toxcore/util.h"
/* Sleep function (x = milliseconds) */
#ifdef WIN32

View File

@ -34,7 +34,6 @@
//#include "../core/network.h"
#include "../toxcore/DHT.h"
#include "../toxcore/friend_requests.h"
#include "../toxcore/util.h"
#include "misc_tools.c"
#include <string.h>

View File

@ -34,7 +34,7 @@
#include "../toxcore/network.h"
#include "../toxcore/Lossless_UDP.h"
#include "../toxcore/util.h"
#include "misc_tools.c"
#ifdef WIN32

View File

@ -34,7 +34,7 @@
#include "../toxcore/network.h"
#include "../toxcore/Lossless_UDP.h"
#include "../toxcore/util.h"
#include "misc_tools.c"
//Sleep function (x = milliseconds)
#ifdef WIN32

View File

@ -43,7 +43,6 @@
#include "../toxcore/Messenger.h"
#include "misc_tools.c"
#include "../toxcore/util.h"
#ifdef WIN32

View File

@ -46,3 +46,36 @@ unsigned char *hex_string_to_bin(char hex_string[])
return val;
}
int cmdline_parsefor_ipv46(int argc, char **argv, uint8_t *ipv6enabled)
{
int argvoffset = 0, argi;
for(argi = 1; argi < argc; argi++)
if (!strncasecmp(argv[argi], "--ipv", 5)) {
if (argv[argi][5] && !argv[argi][6]) {
char c = argv[argi][5];
if (c == '4')
*ipv6enabled = 0;
else if (c == '6')
*ipv6enabled = 1;
else {
printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]);
return -1;
}
}
else {
printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]);
return -1;
}
if (argvoffset != argi - 1) {
printf("Argument must come first: %s.\n", argv[argi]);
return -1;
}
argvoffset++;
}
return argvoffset;
};

View File

@ -43,38 +43,6 @@ void id_cpy(uint8_t *dest, uint8_t *src)
memcpy(dest, src, CLIENT_ID_SIZE);
}
int cmdline_parsefor_ipv46(int argc, char **argv, uint8_t *ipv6enabled)
{
int argvoffset = 0, argi;
for(argi = 1; argi < argc; argi++)
if (!strncasecmp(argv[argi], "--ipv", 5)) {
if (argv[argi][5] && !argv[argi][6]) {
char c = argv[argi][5];
if (c == '4')
*ipv6enabled = 0;
else if (c == '6')
*ipv6enabled = 1;
else {
printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]);
return -1;
}
}
else {
printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]);
return -1;
}
if (argvoffset != argi - 1) {
printf("Argument must come first: %s.\n", argv[argi]);
return -1;
}
argvoffset++;
}
return argvoffset;
};
#ifdef LOGGING
char logbuffer[512];
static FILE *logfile = NULL;

View File

@ -16,8 +16,6 @@ uint64_t random_64b();
bool id_eq(uint8_t *dest, uint8_t *src);
void id_cpy(uint8_t *dest, uint8_t *src);
int cmdline_parsefor_ipv46(int argc, char **argv, uint8_t *ipv6enabled);
#undef LOGGING
/* #define LOGGING */
#ifdef LOGGING