diff options
author | Coren[m] <Break@Ocean> | 2013-09-11 00:14:20 +0200 |
---|---|---|
committer | Coren[m] <Break@Ocean> | 2013-09-11 00:14:20 +0200 |
commit | 4cf0d857bcf87ba271178e7b1734958fb93b018a (patch) | |
tree | 415ac36bb195c319418c942ffa31e8a67616818e /other/DHT_bootstrap.c | |
parent | 8ba6a5ff5b05d027bc4c131b208015ea4019026b (diff) |
cmdline parsing of --ipv4/6 plucked into util
Diffstat (limited to 'other/DHT_bootstrap.c')
-rw-r--r-- | other/DHT_bootstrap.c | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index 795e24ac..099aad80 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c | |||
@@ -89,33 +89,9 @@ int main(int argc, char *argv[]) | |||
89 | 89 | ||
90 | /* let user override default by cmdline */ | 90 | /* let user override default by cmdline */ |
91 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; /* x */ | 91 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; /* x */ |
92 | 92 | int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); | |
93 | int argvoffset = 0, argi; | 93 | if (argvoffset < 0) |
94 | for(argi = 1; argi < argc; argi++) | 94 | exit(1); |
95 | if (!strncasecmp(argv[argi], "--ipv", 5)) { | ||
96 | if (argv[argi][5] && !argv[argi][6]) { | ||
97 | char c = argv[argi][5]; | ||
98 | if (c == '4') | ||
99 | ipv6enabled = 0; | ||
100 | else if (c == '6') | ||
101 | ipv6enabled = 1; | ||
102 | else { | ||
103 | printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]); | ||
104 | exit(1); | ||
105 | } | ||
106 | } | ||
107 | else { | ||
108 | printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]); | ||
109 | exit(1); | ||
110 | } | ||
111 | |||
112 | if (argvoffset != argi - 1) { | ||
113 | printf("Argument must come first: %s.\n", argv[argi]); | ||
114 | exit(1); | ||
115 | } | ||
116 | |||
117 | argvoffset++; | ||
118 | } | ||
119 | 95 | ||
120 | /* Initialize networking - | 96 | /* Initialize networking - |
121 | Bind to ip 0.0.0.0 / [::] : PORT */ | 97 | Bind to ip 0.0.0.0 / [::] : PORT */ |