diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-05 18:05:09 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-05 18:05:09 +0000 |
commit | d8df0a9bd2e6fdc7a30156ed4114808b1ff1e3fb (patch) | |
tree | 8a5a2783a458269715a05dc48236cae8b1cb1ee0 /networking | |
parent | a76b1a148dd871587bfc6a579a6b245684e6b5ce (diff) | |
download | busybox-w32-d8df0a9bd2e6fdc7a30156ed4114808b1ff1e3fb.tar.gz busybox-w32-d8df0a9bd2e6fdc7a30156ed4114808b1ff1e3fb.tar.bz2 busybox-w32-d8df0a9bd2e6fdc7a30156ed4114808b1ff1e3fb.zip |
rename: compare_string_array -> index_in_str_array
introduce index_in_substr_array and use it in
iproute2
git-svn-id: svn://busybox.net/trunk/busybox@16515 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ip.c | 13 | ||||
-rw-r--r-- | networking/libiproute/ipaddress.c | 19 | ||||
-rw-r--r-- | networking/libiproute/iproute.c | 10 | ||||
-rw-r--r-- | networking/libiproute/utils.c | 5 |
4 files changed, 18 insertions, 29 deletions
diff --git a/networking/ip.c b/networking/ip.c index fe5714f16..636315597 100644 --- a/networking/ip.c +++ b/networking/ip.c | |||
@@ -12,20 +12,11 @@ | |||
12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <stdio.h> | 15 | #include "busybox.h" |
16 | #include <stdlib.h> | ||
17 | #include <unistd.h> | ||
18 | #include <syslog.h> | ||
19 | #include <fcntl.h> | ||
20 | #include <sys/socket.h> | ||
21 | #include <netinet/in.h> | ||
22 | #include <string.h> | ||
23 | 16 | ||
24 | #include "libiproute/utils.h" | 17 | #include "libiproute/utils.h" |
25 | #include "libiproute/ip_common.h" | 18 | #include "libiproute/ip_common.h" |
26 | 19 | ||
27 | #include "busybox.h" | ||
28 | |||
29 | int ip_main(int argc, char **argv) | 20 | int ip_main(int argc, char **argv) |
30 | { | 21 | { |
31 | int ret = EXIT_FAILURE; | 22 | int ret = EXIT_FAILURE; |
@@ -57,5 +48,5 @@ int ip_main(int argc, char **argv) | |||
57 | if (ret) { | 48 | if (ret) { |
58 | bb_show_usage(); | 49 | bb_show_usage(); |
59 | } | 50 | } |
60 | return(EXIT_SUCCESS); | 51 | return EXIT_SUCCESS; |
61 | } | 52 | } |
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index fdbe6117c..fc6cf7beb 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c | |||
@@ -441,7 +441,7 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush) | |||
441 | } | 441 | } |
442 | 442 | ||
443 | while (argc > 0) { | 443 | while (argc > 0) { |
444 | const int option_num = compare_string_array(option, *argv); | 444 | const int option_num = index_in_str_array(option, *argv); |
445 | switch (option_num) { | 445 | switch (option_num) { |
446 | case 0: /* to */ | 446 | case 0: /* to */ |
447 | NEXT_ARG(); | 447 | NEXT_ARG(); |
@@ -653,7 +653,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv) | |||
653 | req.ifa.ifa_family = preferred_family; | 653 | req.ifa.ifa_family = preferred_family; |
654 | 654 | ||
655 | while (argc > 0) { | 655 | while (argc > 0) { |
656 | const int option_num = compare_string_array(option, *argv); | 656 | const int option_num = index_in_str_array(option, *argv); |
657 | switch (option_num) { | 657 | switch (option_num) { |
658 | case 0: /* peer */ | 658 | case 0: /* peer */ |
659 | case 1: /* remote */ | 659 | case 1: /* remote */ |
@@ -800,25 +800,24 @@ static int ipaddr_modify(int cmd, int argc, char **argv) | |||
800 | int do_ipaddr(int argc, char **argv) | 800 | int do_ipaddr(int argc, char **argv) |
801 | { | 801 | { |
802 | static const char *const commands[] = { | 802 | static const char *const commands[] = { |
803 | "add", "del", "delete", "list", "show", "lst", "flush", 0 | 803 | "add", "delete", "list", "show", "lst", "flush", 0 |
804 | }; | 804 | }; |
805 | 805 | ||
806 | int command_num = 2; | 806 | int command_num = 2; |
807 | 807 | ||
808 | if (*argv) { | 808 | if (*argv) { |
809 | command_num = compare_string_array(commands, *argv); | 809 | command_num = index_in_substr_array(commands, *argv); |
810 | } | 810 | } |
811 | switch (command_num) { | 811 | switch (command_num) { |
812 | case 0: /* add */ | 812 | case 0: /* add */ |
813 | return ipaddr_modify(RTM_NEWADDR, argc-1, argv+1); | 813 | return ipaddr_modify(RTM_NEWADDR, argc-1, argv+1); |
814 | case 1: /* del */ | 814 | case 1: /* delete */ |
815 | case 2: /* delete */ | ||
816 | return ipaddr_modify(RTM_DELADDR, argc-1, argv+1); | 815 | return ipaddr_modify(RTM_DELADDR, argc-1, argv+1); |
817 | case 3: /* list */ | 816 | case 2: /* list */ |
818 | case 4: /* show */ | 817 | case 3: /* show */ |
819 | case 5: /* lst */ | 818 | case 4: /* lst */ |
820 | return ipaddr_list_or_flush(argc-1, argv+1, 0); | 819 | return ipaddr_list_or_flush(argc-1, argv+1, 0); |
821 | case 6: /* flush */ | 820 | case 5: /* flush */ |
822 | return ipaddr_list_or_flush(argc-1, argv+1, 1); | 821 | return ipaddr_list_or_flush(argc-1, argv+1, 1); |
823 | } | 822 | } |
824 | bb_error_msg_and_die("unknown command %s", *argv); | 823 | bb_error_msg_and_die("unknown command %s", *argv); |
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 3b2a677d9..9c3b87040 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
@@ -670,7 +670,7 @@ static int iproute_get(int argc, char **argv) | |||
670 | req.r.rtm_tos = 0; | 670 | req.r.rtm_tos = 0; |
671 | 671 | ||
672 | while (argc > 0) { | 672 | while (argc > 0) { |
673 | switch (compare_string_array(options, *argv)) { | 673 | switch (index_in_str_array(options, *argv)) { |
674 | case 0: /* from */ | 674 | case 0: /* from */ |
675 | { | 675 | { |
676 | inet_prefix addr; | 676 | inet_prefix addr; |
@@ -811,14 +811,16 @@ static int iproute_get(int argc, char **argv) | |||
811 | int do_iproute(int argc, char **argv) | 811 | int do_iproute(int argc, char **argv) |
812 | { | 812 | { |
813 | static const char * const ip_route_commands[] = | 813 | static const char * const ip_route_commands[] = |
814 | { "add", "append", "change", "chg", "delete", "del", "get", | 814 | { "add", "append", "change", "chg", "delete", "get", |
815 | "list", "show", "prepend", "replace", "test", "flush", 0 }; | 815 | "list", "show", "prepend", "replace", "test", "flush", 0 }; |
816 | int command_num = 7; | 816 | int command_num = 6; |
817 | unsigned int flags = 0; | 817 | unsigned int flags = 0; |
818 | int cmd = RTM_NEWROUTE; | 818 | int cmd = RTM_NEWROUTE; |
819 | 819 | ||
820 | /* "Standard" 'ip r a' treats 'a' as 'add', not 'append' */ | ||
821 | /* It probably means that it is using "first match" rule */ | ||
820 | if (*argv) { | 822 | if (*argv) { |
821 | command_num = compare_string_array(ip_route_commands, *argv); | 823 | command_num = index_in_substr_array(ip_route_commands, *argv); |
822 | } | 824 | } |
823 | switch (command_num) { | 825 | switch (command_num) { |
824 | case 0: /* add*/ | 826 | case 0: /* add*/ |
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index 552f4bf77..f92179c40 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c | |||
@@ -263,10 +263,7 @@ int matches(char *cmd, char *pattern) | |||
263 | { | 263 | { |
264 | int len = strlen(cmd); | 264 | int len = strlen(cmd); |
265 | 265 | ||
266 | if (len > strlen(pattern)) { | 266 | return strncmp(pattern, cmd, len); |
267 | return -1; | ||
268 | } | ||
269 | return memcmp(pattern, cmd, len); | ||
270 | } | 267 | } |
271 | 268 | ||
272 | int inet_addr_match(inet_prefix * a, inet_prefix * b, int bits) | 269 | int inet_addr_match(inet_prefix * a, inet_prefix * b, int bits) |