mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-27 19:23:40 +00:00
Use enum number for val of long options (#1155)
This commit is contained in:
committed by
Max Lv
parent
c0030f0d7d
commit
a3d0f02c3e
+31
-31
@@ -1186,16 +1186,15 @@ main(int argc, char **argv)
|
||||
ss_addr_t remote_addr[MAX_REMOTE_NUM];
|
||||
char *remote_port = NULL;
|
||||
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{ "fast-open", no_argument, 0, 0 },
|
||||
{ "acl", required_argument, 0, 0 },
|
||||
{ "mtu", required_argument, 0, 0 },
|
||||
{ "mptcp", no_argument, 0, 0 },
|
||||
{ "plugin", required_argument, 0, 0 },
|
||||
{ "plugin-opts", required_argument, 0, 0 },
|
||||
{ "help", no_argument, 0, 0 },
|
||||
{ 0, 0, 0, 0 }
|
||||
{ "fast-open", no_argument, NULL, GETOPT_VAL_FAST_OPEN },
|
||||
{ "acl", required_argument, NULL, GETOPT_VAL_ACL },
|
||||
{ "mtu", required_argument, NULL, GETOPT_VAL_MTU },
|
||||
{ "mptcp", no_argument, NULL, GETOPT_VAL_MPTCP },
|
||||
{ "plugin", required_argument, NULL, GETOPT_VAL_PLUGIN },
|
||||
{ "plugin-opts", required_argument, NULL, GETOPT_VAL_PLUGIN_OPTS },
|
||||
{ "help", no_argument, NULL, GETOPT_VAL_HELP },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
opterr = 0;
|
||||
@@ -1204,32 +1203,32 @@ main(int argc, char **argv)
|
||||
|
||||
#ifdef ANDROID
|
||||
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:huUvV6",
|
||||
long_options, &option_index)) != -1) {
|
||||
long_options, NULL)) != -1) {
|
||||
#else
|
||||
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:huUv6",
|
||||
long_options, &option_index)) != -1) {
|
||||
long_options, NULL)) != -1) {
|
||||
#endif
|
||||
switch (c) {
|
||||
case 0:
|
||||
if (option_index == 0) {
|
||||
fast_open = 1;
|
||||
} else if (option_index == 1) {
|
||||
LOGI("initializing acl...");
|
||||
acl = !init_acl(optarg);
|
||||
} else if (option_index == 2) {
|
||||
mtu = atoi(optarg);
|
||||
LOGI("set MTU to %d", mtu);
|
||||
} else if (option_index == 3) {
|
||||
mptcp = 1;
|
||||
LOGI("enable multipath TCP");
|
||||
} else if (option_index == 4) {
|
||||
plugin = optarg;
|
||||
} else if (option_index == 5) {
|
||||
plugin_opts = optarg;
|
||||
} else if (option_index == 6) {
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
case GETOPT_VAL_FAST_OPEN:
|
||||
fast_open = 1;
|
||||
break;
|
||||
case GETOPT_VAL_ACL:
|
||||
LOGI("initializing acl...");
|
||||
acl = !init_acl(optarg);
|
||||
break;
|
||||
case GETOPT_VAL_MTU:
|
||||
mtu = atoi(optarg);
|
||||
LOGI("set MTU to %d", mtu);
|
||||
break;
|
||||
case GETOPT_VAL_MPTCP:
|
||||
mptcp = 1;
|
||||
LOGI("enable multipath TCP");
|
||||
break;
|
||||
case GETOPT_VAL_PLUGIN:
|
||||
plugin = optarg;
|
||||
break;
|
||||
case GETOPT_VAL_PLUGIN_OPTS:
|
||||
plugin_opts = optarg;
|
||||
break;
|
||||
case 's':
|
||||
if (remote_num < MAX_REMOTE_NUM) {
|
||||
@@ -1283,6 +1282,7 @@ main(int argc, char **argv)
|
||||
verbose = 1;
|
||||
break;
|
||||
case 'h':
|
||||
case GETOPT_VAL_HELP:
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
case '6':
|
||||
|
||||
+33
-30
@@ -894,17 +894,18 @@ main(int argc, char **argv)
|
||||
|
||||
jconf_t *conf = NULL;
|
||||
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{ "fast-open", no_argument, 0, 0 },
|
||||
{ "acl", required_argument, 0, 0 },
|
||||
{ "manager-address", required_argument, 0, 0 },
|
||||
{ "executable", required_argument, 0, 0 },
|
||||
{ "mtu", required_argument, 0, 0 },
|
||||
{ "plugin", required_argument, 0, 0 },
|
||||
{ "plugin-opts", required_argument, 0, 0 },
|
||||
{ "help", no_argument, 0, 0 },
|
||||
{ 0, 0, 0, 0 }
|
||||
{ "fast-open", no_argument, NULL, GETOPT_VAL_FAST_OPEN },
|
||||
{ "acl", required_argument, NULL, GETOPT_VAL_ACL },
|
||||
{ "manager-address", required_argument, NULL,
|
||||
GETOPT_VAL_MANAGER_ADDRESS },
|
||||
{ "executable", required_argument, NULL,
|
||||
GETOPT_VAL_EXECUTABLE },
|
||||
{ "mtu", required_argument, NULL, GETOPT_VAL_MTU },
|
||||
{ "plugin", required_argument, NULL, GETOPT_VAL_PLUGIN },
|
||||
{ "plugin-opts", required_argument, NULL, GETOPT_VAL_PLUGIN_OPTS },
|
||||
{ "help", no_argument, NULL, GETOPT_VAL_HELP },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
opterr = 0;
|
||||
@@ -912,27 +913,28 @@ main(int argc, char **argv)
|
||||
USE_TTY();
|
||||
|
||||
while ((c = getopt_long(argc, argv, "f:s:l:k:t:m:c:i:d:a:n:6huUvA",
|
||||
long_options, &option_index)) != -1)
|
||||
long_options, NULL)) != -1)
|
||||
switch (c) {
|
||||
case 0:
|
||||
if (option_index == 0) {
|
||||
fast_open = 1;
|
||||
} else if (option_index == 1) {
|
||||
acl = optarg;
|
||||
} else if (option_index == 2) {
|
||||
manager_address = optarg;
|
||||
} else if (option_index == 3) {
|
||||
executable = optarg;
|
||||
} else if (option_index == 4) {
|
||||
mtu = atoi(optarg);
|
||||
} else if (option_index == 5) {
|
||||
plugin = optarg;
|
||||
} else if (option_index == 6) {
|
||||
plugin_opts = optarg;
|
||||
} else if (option_index == 7) {
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
case GETOPT_VAL_FAST_OPEN:
|
||||
fast_open = 1;
|
||||
break;
|
||||
case GETOPT_VAL_ACL:
|
||||
acl = optarg;
|
||||
break;
|
||||
case GETOPT_VAL_MANAGER_ADDRESS:
|
||||
manager_address = optarg;
|
||||
break;
|
||||
case GETOPT_VAL_EXECUTABLE:
|
||||
executable = optarg;
|
||||
break;
|
||||
case GETOPT_VAL_MTU:
|
||||
mtu = atoi(optarg);
|
||||
break;
|
||||
case GETOPT_VAL_PLUGIN:
|
||||
plugin = optarg;
|
||||
break;
|
||||
case GETOPT_VAL_PLUGIN_OPTS:
|
||||
plugin_opts = optarg;
|
||||
break;
|
||||
case 's':
|
||||
if (server_num < MAX_REMOTE_NUM) {
|
||||
@@ -978,6 +980,7 @@ main(int argc, char **argv)
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case GETOPT_VAL_HELP:
|
||||
case 'h':
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
+21
-23
@@ -798,14 +798,13 @@ main(int argc, char **argv)
|
||||
ss_addr_t remote_addr[MAX_REMOTE_NUM];
|
||||
char *remote_port = NULL;
|
||||
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{ "mtu", required_argument, 0, 0 },
|
||||
{ "mptcp", no_argument, 0, 0 },
|
||||
{ "plugin", required_argument, 0, 0 },
|
||||
{ "plugin-opts", required_argument, 0, 0 },
|
||||
{ "help", no_argument, 0, 0 },
|
||||
{ 0, 0, 0, 0 }
|
||||
{ "mtu", required_argument, NULL, GETOPT_VAL_MTU },
|
||||
{ "mptcp", no_argument, NULL, GETOPT_VAL_MPTCP },
|
||||
{ "plugin", required_argument, NULL, GETOPT_VAL_PLUGIN },
|
||||
{ "plugin-opts", required_argument, NULL, GETOPT_VAL_PLUGIN_OPTS },
|
||||
{ "help", no_argument, NULL, GETOPT_VAL_HELP },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
opterr = 0;
|
||||
@@ -813,23 +812,21 @@ main(int argc, char **argv)
|
||||
USE_TTY();
|
||||
|
||||
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:c:b:a:n:huUv6",
|
||||
long_options, &option_index)) != -1) {
|
||||
long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 0:
|
||||
if (option_index == 0) {
|
||||
mtu = atoi(optarg);
|
||||
LOGI("set MTU to %d", mtu);
|
||||
} else if (option_index == 1) {
|
||||
mptcp = 1;
|
||||
LOGI("enable multipath TCP");
|
||||
} else if (option_index == 2) {
|
||||
plugin = optarg;
|
||||
} else if (option_index == 3) {
|
||||
plugin_opts = optarg;
|
||||
} else if (option_index == 4) {
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
case GETOPT_VAL_MTU:
|
||||
mtu = atoi(optarg);
|
||||
LOGI("set MTU to %d", mtu);
|
||||
break;
|
||||
case GETOPT_VAL_MPTCP:
|
||||
mptcp = 1;
|
||||
LOGI("enable multipath TCP");
|
||||
break;
|
||||
case GETOPT_VAL_PLUGIN:
|
||||
plugin = optarg;
|
||||
break;
|
||||
case GETOPT_VAL_PLUGIN_OPTS:
|
||||
plugin_opts = optarg;
|
||||
break;
|
||||
case 's':
|
||||
if (remote_num < MAX_REMOTE_NUM) {
|
||||
@@ -879,6 +876,7 @@ main(int argc, char **argv)
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case GETOPT_VAL_HELP:
|
||||
case 'h':
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
+36
-34
@@ -1351,50 +1351,51 @@ main(int argc, char **argv)
|
||||
char *nameservers[MAX_DNS_NUM + 1];
|
||||
int nameserver_num = 0;
|
||||
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{ "fast-open", no_argument, 0, 0 },
|
||||
{ "acl", required_argument, 0, 0 },
|
||||
{ "manager-address", required_argument, 0, 0 },
|
||||
{ "mtu", required_argument, 0, 0 },
|
||||
{ "help", no_argument, 0, 0 },
|
||||
{ "plugin", required_argument, 0, 0 },
|
||||
{ "plugin-opts", required_argument, 0, 0 },
|
||||
{ "fast-open", no_argument, NULL, GETOPT_VAL_FAST_OPEN },
|
||||
{ "acl", required_argument, NULL, GETOPT_VAL_ACL },
|
||||
{ "manager-address", required_argument, NULL,
|
||||
GETOPT_VAL_MANAGER_ADDRESS },
|
||||
{ "mtu", required_argument, NULL, GETOPT_VAL_MTU },
|
||||
{ "help", no_argument, NULL, GETOPT_VAL_HELP },
|
||||
{ "plugin", required_argument, NULL, GETOPT_VAL_PLUGIN },
|
||||
{ "plugin-opts", required_argument, NULL, GETOPT_VAL_PLUGIN_OPTS },
|
||||
#ifdef __linux__
|
||||
{ "mptcp", no_argument, 0, 0 },
|
||||
{ "mptcp", no_argument, NULL, GETOPT_VAL_MPTCP },
|
||||
#endif
|
||||
{ 0, 0, 0, 0 }
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
opterr = 0;
|
||||
|
||||
USE_TTY();
|
||||
|
||||
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:b:c:i:d:a:n:huUvA6",
|
||||
long_options, &option_index)) != -1) {
|
||||
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:b:c:i:d:a:n:huUv6",
|
||||
long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 0:
|
||||
if (option_index == 0) {
|
||||
fast_open = 1;
|
||||
} else if (option_index == 1) {
|
||||
LOGI("initializing acl...");
|
||||
acl = !init_acl(optarg);
|
||||
} else if (option_index == 2) {
|
||||
manager_address = optarg;
|
||||
} else if (option_index == 3) {
|
||||
mtu = atoi(optarg);
|
||||
LOGI("set MTU to %d", mtu);
|
||||
} else if (option_index == 4) {
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
} else if (option_index == 5) {
|
||||
plugin = optarg;
|
||||
} else if (option_index == 6) {
|
||||
plugin_opts = optarg;
|
||||
} else if (option_index == 7) {
|
||||
mptcp = 1;
|
||||
LOGI("enable multipath TCP");
|
||||
}
|
||||
case GETOPT_VAL_FAST_OPEN:
|
||||
fast_open = 1;
|
||||
break;
|
||||
case GETOPT_VAL_ACL:
|
||||
LOGI("initializing acl...");
|
||||
acl = !init_acl(optarg);
|
||||
break;
|
||||
case GETOPT_VAL_MANAGER_ADDRESS:
|
||||
manager_address = optarg;
|
||||
break;
|
||||
case GETOPT_VAL_MTU:
|
||||
mtu = atoi(optarg);
|
||||
LOGI("set MTU to %d", mtu);
|
||||
break;
|
||||
case GETOPT_VAL_PLUGIN:
|
||||
plugin = optarg;
|
||||
break;
|
||||
case GETOPT_VAL_PLUGIN_OPTS:
|
||||
plugin_opts = optarg;
|
||||
break;
|
||||
case GETOPT_VAL_MPTCP:
|
||||
mptcp = 1;
|
||||
LOGI("enable multipath TCP");
|
||||
break;
|
||||
case 's':
|
||||
if (server_num < MAX_REMOTE_NUM) {
|
||||
@@ -1448,6 +1449,7 @@ main(int argc, char **argv)
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case GETOPT_VAL_HELP:
|
||||
case 'h':
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
+22
-24
@@ -745,14 +745,13 @@ main(int argc, char **argv)
|
||||
ss_addr_t tunnel_addr = { .host = NULL, .port = NULL };
|
||||
char *tunnel_addr_str = NULL;
|
||||
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{ "mtu", required_argument, 0, 0 },
|
||||
{ "mptcp", no_argument, 0, 0 },
|
||||
{ "plugin", required_argument, 0, 0 },
|
||||
{ "plugin-opts", required_argument, 0, 0 },
|
||||
{ "help", no_argument, 0, 0 },
|
||||
{ 0, 0, 0, 0 }
|
||||
{ "mtu", required_argument, NULL, GETOPT_VAL_MTU },
|
||||
{ "mptcp", no_argument, NULL, GETOPT_VAL_MPTCP },
|
||||
{ "plugin", required_argument, NULL, GETOPT_VAL_PLUGIN },
|
||||
{ "plugin-opts", required_argument, NULL, GETOPT_VAL_PLUGIN_OPTS },
|
||||
{ "help", no_argument, NULL, GETOPT_VAL_HELP },
|
||||
{ NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
opterr = 0;
|
||||
@@ -761,27 +760,25 @@ main(int argc, char **argv)
|
||||
|
||||
#ifdef ANDROID
|
||||
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:L:a:n:huUvV6",
|
||||
long_options, &option_index)) != -1) {
|
||||
long_options, NULL)) != -1) {
|
||||
#else
|
||||
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:L:a:n:huUv6",
|
||||
long_options, &option_index)) != -1) {
|
||||
long_options, NULL)) != -1) {
|
||||
#endif
|
||||
switch (c) {
|
||||
case 0:
|
||||
if (option_index == 0) {
|
||||
mtu = atoi(optarg);
|
||||
LOGI("set MTU to %d", mtu);
|
||||
} else if (option_index == 1) {
|
||||
mptcp = 1;
|
||||
LOGI("enable multipath TCP");
|
||||
} else if (option_index == 2) {
|
||||
plugin = optarg;
|
||||
} else if (option_index == 3) {
|
||||
plugin_opts = optarg;
|
||||
} else if (option_index == 4) {
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
case GETOPT_VAL_MTU:
|
||||
mtu = atoi(optarg);
|
||||
LOGI("set MTU to %d", mtu);
|
||||
break;
|
||||
case GETOPT_VAL_MPTCP:
|
||||
mptcp = 1;
|
||||
LOGI("enable multipath TCP");
|
||||
break;
|
||||
case GETOPT_VAL_PLUGIN:
|
||||
plugin = optarg;
|
||||
break;
|
||||
case GETOPT_VAL_PLUGIN_OPTS:
|
||||
plugin_opts = optarg;
|
||||
break;
|
||||
case 's':
|
||||
if (remote_num < MAX_REMOTE_NUM) {
|
||||
@@ -837,6 +834,7 @@ main(int argc, char **argv)
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case GETOPT_VAL_HELP:
|
||||
case 'h':
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
+12
@@ -161,6 +161,18 @@ extern int use_syslog;
|
||||
|
||||
#endif // if ANDROID
|
||||
|
||||
/* Vals for long options */
|
||||
enum { GETOPT_VAL_HELP = 257,
|
||||
GETOPT_VAL_FAST_OPEN,
|
||||
GETOPT_VAL_ACL,
|
||||
GETOPT_VAL_MTU,
|
||||
GETOPT_VAL_MPTCP,
|
||||
GETOPT_VAL_PLUGIN,
|
||||
GETOPT_VAL_PLUGIN_OPTS,
|
||||
GETOPT_VAL_MANAGER_ADDRESS,
|
||||
GETOPT_VAL_EXECUTABLE
|
||||
};
|
||||
|
||||
void ERROR(const char *s);
|
||||
|
||||
char *ss_itoa(int i);
|
||||
|
||||
Reference in New Issue
Block a user