aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-07-06 21:58:02 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-07-06 21:58:02 +0200
commit237bedd499c58034a1355484d6d4d906f0180308 (patch)
tree42a789f8867ba3bc6ef0cea30fb18f5553d447a0 /networking
parent0844b5afe2cd60d46b7f2ad0fac8c2818d0780b3 (diff)
downloadbusybox-w32-237bedd499c58034a1355484d6d4d906f0180308.tar.gz
busybox-w32-237bedd499c58034a1355484d6d4d906f0180308.tar.bz2
busybox-w32-237bedd499c58034a1355484d6d4d906f0180308.zip
getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST
In many cases, this aqllows to drop use of opt_complementary. Approximately -400 bytes: function old new delta getopt32 1423 1502 +79 opt_string 17 18 +1 OPT_STR 24 25 +1 uniq_main 416 406 -10 timeout_main 279 269 -10 sulogin_main 270 260 -10 readprofile_main 1825 1815 -10 ps_main 543 533 -10 pidof_main 245 235 -10 pgrep_main 611 601 -10 od_main 2600 2590 -10 mkfs_minix_main 2684 2674 -10 mkfs_ext2_main 2603 2593 -10 microcom_main 712 702 -10 makemime_main 315 305 -10 ionice_main 282 272 -10 inetd_main 2074 2064 -10 ifplugd_main 1144 1134 -10 halt_main 353 343 -10 getopt_main 636 626 -10 fdisk_main 2854 2844 -10 env_main 206 196 -10 dmesg_main 319 309 -10 conspy_main 1214 1204 -10 awk_main 981 971 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/22 up/down: 81/-220) Total: -139 bytes text data bss dec hex filename 919373 906 14060 934339 e41c3 busybox_old 918969 906 14060 933935 e402f busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/arping.c4
-rw-r--r--networking/ftpd.c6
-rw-r--r--networking/ifplugd.c5
-rw-r--r--networking/inetd.c4
-rw-r--r--networking/nc_bloaty.c4
-rw-r--r--networking/ntpd.c4
-rw-r--r--networking/ping.c4
-rw-r--r--networking/tcpudp.c4
-rw-r--r--networking/telnetd.c4
-rw-r--r--networking/traceroute.c4
-rw-r--r--networking/udhcp/d6_dhcpc.c4
-rw-r--r--networking/udhcp/dhcpc.c4
-rw-r--r--networking/wget.c3
-rw-r--r--networking/whois.c4
14 files changed, 28 insertions, 30 deletions
diff --git a/networking/arping.c b/networking/arping.c
index 4f207eaa5..46bd65e36 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -295,8 +295,8 @@ int arping_main(int argc UNUSED_PARAM, char **argv)
295 /* Dad also sets quit_on_reply. 295 /* Dad also sets quit_on_reply.
296 * Advert also sets unsolicited. 296 * Advert also sets unsolicited.
297 */ 297 */
298 opt_complementary = "=1:Df:AU:c+"; 298 opt_complementary = "=1:Df:AU";
299 opt = getopt32(argv, "DUAqfbc:w:I:s:", 299 opt = getopt32(argv, "DUAqfbc:+w:I:s:",
300 &count, &str_timeout, &device, &source); 300 &count, &str_timeout, &device, &source);
301 if (opt & 0x80) /* -w: timeout */ 301 if (opt & 0x80) /* -w: timeout */
302 timeout_us = xatou_range(str_timeout, 0, INT_MAX/2000000) * 1000000 + 500000; 302 timeout_us = xatou_range(str_timeout, 0, INT_MAX/2000000) * 1000000 + 500000;
diff --git a/networking/ftpd.c b/networking/ftpd.c
index 360d1e6be..4cbb9b6fe 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -1130,11 +1130,11 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv)
1130 abs_timeout = 1 * 60 * 60; 1130 abs_timeout = 1 * 60 * 60;
1131 verbose_S = 0; 1131 verbose_S = 0;
1132 G.timeout = 2 * 60; 1132 G.timeout = 2 * 60;
1133 opt_complementary = "t+:T+:vv:SS"; 1133 opt_complementary = "vv:SS";
1134#if BB_MMU 1134#if BB_MMU
1135 opts = getopt32(argv, "vS" IF_FEATURE_FTP_WRITE("w") "t:T:", &G.timeout, &abs_timeout, &G.verbose, &verbose_S); 1135 opts = getopt32(argv, "vS" IF_FEATURE_FTP_WRITE("w") "t:+T:+", &G.timeout, &abs_timeout, &G.verbose, &verbose_S);
1136#else 1136#else
1137 opts = getopt32(argv, "l1AvS" IF_FEATURE_FTP_WRITE("w") "t:T:", &G.timeout, &abs_timeout, &G.verbose, &verbose_S); 1137 opts = getopt32(argv, "l1AvS" IF_FEATURE_FTP_WRITE("w") "t:+T:+", &G.timeout, &abs_timeout, &G.verbose, &verbose_S);
1138 if (opts & (OPT_l|OPT_1)) { 1138 if (opts & (OPT_l|OPT_1)) {
1139 /* Our secret backdoor to ls */ 1139 /* Our secret backdoor to ls */
1140/* TODO: pass --group-directories-first? would be nice, but ls doesn't do that yet */ 1140/* TODO: pass --group-directories-first? would be nice, but ls doesn't do that yet */
diff --git a/networking/ifplugd.c b/networking/ifplugd.c
index f0defb5c8..28c49e218 100644
--- a/networking/ifplugd.c
+++ b/networking/ifplugd.c
@@ -107,9 +107,9 @@ enum {
107#endif 107#endif
108}; 108};
109#if ENABLE_FEATURE_PIDFILE 109#if ENABLE_FEATURE_PIDFILE
110# define OPTION_STR "+ansfFi:r:It:u:d:m:pqlx:Mk" 110# define OPTION_STR "+ansfFi:r:It:+u:+d:+m:pqlx:Mk"
111#else 111#else
112# define OPTION_STR "+ansfFi:r:It:u:d:m:pqlx:M" 112# define OPTION_STR "+ansfFi:r:It:+u:+d:+m:pqlx:M"
113#endif 113#endif
114 114
115enum { // interface status 115enum { // interface status
@@ -560,7 +560,6 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
560 560
561 INIT_G(); 561 INIT_G();
562 562
563 opt_complementary = "t+:u+:d+";
564 opts = getopt32(argv, OPTION_STR, 563 opts = getopt32(argv, OPTION_STR,
565 &G.iface, &G.script_name, &G.poll_time, &G.delay_up, 564 &G.iface, &G.script_name, &G.poll_time, &G.delay_up,
566 &G.delay_down, &G.api_mode, &G.extra_arg); 565 &G.delay_down, &G.api_mode, &G.extra_arg);
diff --git a/networking/inetd.c b/networking/inetd.c
index 8d44b5198..f9295e38b 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1153,8 +1153,8 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
1153 if (real_uid != 0) /* run by non-root user */ 1153 if (real_uid != 0) /* run by non-root user */
1154 config_filename = NULL; 1154 config_filename = NULL;
1155 1155
1156 opt_complementary = "R+:q+"; /* -q N, -R N */ 1156 /* -q N, -R N */
1157 opt = getopt32(argv, "R:feq:", &max_concurrency, &global_queuelen); 1157 opt = getopt32(argv, "R:+feq:+", &max_concurrency, &global_queuelen);
1158 argv += optind; 1158 argv += optind;
1159 //argc -= optind; 1159 //argc -= optind;
1160 if (argv[0]) 1160 if (argv[0])
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c
index 471ae1a12..192e42fe5 100644
--- a/networking/nc_bloaty.c
+++ b/networking/nc_bloaty.c
@@ -794,8 +794,8 @@ int nc_main(int argc UNUSED_PARAM, char **argv)
794 e_found: 794 e_found:
795 795
796 // -g -G -t -r deleted, unimplemented -a deleted too 796 // -g -G -t -r deleted, unimplemented -a deleted too
797 opt_complementary = "?2:vv:ll:w+"; /* max 2 params; -v and -l are counters; -w N */ 797 opt_complementary = "?2:vv:ll"; /* max 2 params; -v and -l are counters; -w N */
798 getopt32(argv, "np:s:uvw:" IF_NC_SERVER("lk") 798 getopt32(argv, "np:s:uvw:+" IF_NC_SERVER("lk")
799 IF_NC_EXTRA("i:o:z"), 799 IF_NC_EXTRA("i:o:z"),
800 &str_p, &str_s, &o_wait 800 &str_p, &str_s, &o_wait
801 IF_NC_EXTRA(, &str_i, &str_o), &o_verbose IF_NC_SERVER(, &cnt_l)); 801 IF_NC_EXTRA(, &str_i, &str_o), &o_verbose IF_NC_SERVER(, &cnt_l));
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 8e7175063..130cef0af 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -2197,11 +2197,11 @@ static NOINLINE void ntp_init(char **argv)
2197 2197
2198 /* Parse options */ 2198 /* Parse options */
2199 peers = NULL; 2199 peers = NULL;
2200 opt_complementary = "dd:p::wn" /* -d: counter; -p: list; -w implies -n */ 2200 opt_complementary = "dd:wn" /* -d: counter; -p: list; -w implies -n */
2201 IF_FEATURE_NTPD_SERVER(":Il"); /* -I implies -l */ 2201 IF_FEATURE_NTPD_SERVER(":Il"); /* -I implies -l */
2202 opts = getopt32(argv, 2202 opts = getopt32(argv,
2203 "nqNx" /* compat */ 2203 "nqNx" /* compat */
2204 "wp:S:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */ 2204 "wp:*S:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */
2205 IF_FEATURE_NTPD_SERVER("I:") /* compat */ 2205 IF_FEATURE_NTPD_SERVER("I:") /* compat */
2206 "d" /* compat */ 2206 "d" /* compat */
2207 "46aAbgL", /* compat, ignored */ 2207 "46aAbgL", /* compat, ignored */
diff --git a/networking/ping.c b/networking/ping.c
index d8767a39f..82d5b7a85 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -341,7 +341,7 @@ static int common_ping_main(sa_family_t af, char **argv)
341 341
342/* Full(er) version */ 342/* Full(er) version */
343 343
344#define OPT_STRING ("qvc:s:t:w:W:I:np:4" IF_PING6("6")) 344#define OPT_STRING ("qvc:+s:t:+w:+W:+I:np:4" IF_PING6("6"))
345enum { 345enum {
346 OPT_QUIET = 1 << 0, 346 OPT_QUIET = 1 << 0,
347 OPT_VERBOSE = 1 << 1, 347 OPT_VERBOSE = 1 << 1,
@@ -865,7 +865,7 @@ static int common_ping_main(int opt, char **argv)
865 INIT_G(); 865 INIT_G();
866 866
867 /* exactly one argument needed; -v and -q don't mix; -c NUM, -t NUM, -w NUM, -W NUM */ 867 /* exactly one argument needed; -v and -q don't mix; -c NUM, -t NUM, -w NUM, -W NUM */
868 opt_complementary = "=1:q--v:v--q:c+:t+:w+:W+"; 868 opt_complementary = "=1:q--v:v--q";
869 opt |= getopt32(argv, OPT_STRING, &pingcount, &str_s, &opt_ttl, &deadline, &timeout, &str_I, &str_p); 869 opt |= getopt32(argv, OPT_STRING, &pingcount, &str_s, &opt_ttl, &deadline, &timeout, &str_I, &str_p);
870 if (opt & OPT_s) 870 if (opt & OPT_s)
871 datalen = xatou16(str_s); // -s 871 datalen = xatou16(str_s); // -s
diff --git a/networking/tcpudp.c b/networking/tcpudp.c
index 31bc70459..fbd1f1c45 100644
--- a/networking/tcpudp.c
+++ b/networking/tcpudp.c
@@ -232,9 +232,9 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
232 tcp = (applet_name[0] == 't'); 232 tcp = (applet_name[0] == 't');
233 233
234 /* 3+ args, -i at most once, -p implies -h, -v is counter, -b N, -c N */ 234 /* 3+ args, -i at most once, -p implies -h, -v is counter, -b N, -c N */
235 opt_complementary = "-3:i--i:ph:vv:b+:c+"; 235 opt_complementary = "-3:i--i:ph:vv";
236#ifdef SSLSVD 236#ifdef SSLSVD
237 opts = getopt32(argv, "+c:C:i:x:u:l:Eb:hpt:vU:/:Z:K:", 237 opts = getopt32(argv, "+c:+C:i:x:u:l:Eb:+hpt:vU:/:Z:K:",
238 &cmax, &str_C, &instructs, &instructs, &user, &preset_local_hostname, 238 &cmax, &str_C, &instructs, &instructs, &user, &preset_local_hostname,
239 &backlog, &str_t, &ssluser, &root, &cert, &key, &verbose 239 &backlog, &str_t, &ssluser, &root, &cert, &key, &verbose
240 ); 240 );
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 13c36aa46..2fbdc3bb3 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -496,12 +496,12 @@ int telnetd_main(int argc UNUSED_PARAM, char **argv)
496 INIT_G(); 496 INIT_G();
497 497
498 /* -w NUM, and implies -F. -w and -i don't mix */ 498 /* -w NUM, and implies -F. -w and -i don't mix */
499 IF_FEATURE_TELNETD_INETD_WAIT(opt_complementary = "wF:w+:i--w:w--i";) 499 IF_FEATURE_TELNETD_INETD_WAIT(opt_complementary = "wF:i--w:w--i";)
500 /* Even if !STANDALONE, we accept (and ignore) -i, thus people 500 /* Even if !STANDALONE, we accept (and ignore) -i, thus people
501 * don't need to guess whether it's ok to pass -i to us */ 501 * don't need to guess whether it's ok to pass -i to us */
502 opt = getopt32(argv, "f:l:Ki" 502 opt = getopt32(argv, "f:l:Ki"
503 IF_FEATURE_TELNETD_STANDALONE("p:b:F") 503 IF_FEATURE_TELNETD_STANDALONE("p:b:F")
504 IF_FEATURE_TELNETD_INETD_WAIT("Sw:"), 504 IF_FEATURE_TELNETD_INETD_WAIT("Sw:+"),
505 &G.issuefile, &G.loginpath 505 &G.issuefile, &G.loginpath
506 IF_FEATURE_TELNETD_STANDALONE(, &opt_portnbr, &opt_bindaddr) 506 IF_FEATURE_TELNETD_STANDALONE(, &opt_portnbr, &opt_bindaddr)
507 IF_FEATURE_TELNETD_INETD_WAIT(, &sec_linger) 507 IF_FEATURE_TELNETD_INETD_WAIT(, &sec_linger)
diff --git a/networking/traceroute.c b/networking/traceroute.c
index eee4f8873..e43a36dc7 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -294,7 +294,7 @@
294 294
295#define OPT_STRING \ 295#define OPT_STRING \
296 "FIlnrdvxt:i:m:p:q:s:w:z:f:" \ 296 "FIlnrdvxt:i:m:p:q:s:w:z:f:" \
297 IF_FEATURE_TRACEROUTE_SOURCE_ROUTE("g:") \ 297 IF_FEATURE_TRACEROUTE_SOURCE_ROUTE("g:*") \
298 "4" IF_TRACEROUTE6("6") 298 "4" IF_TRACEROUTE6("6")
299enum { 299enum {
300 OPT_DONT_FRAGMNT = (1 << 0), /* F */ 300 OPT_DONT_FRAGMNT = (1 << 0), /* F */
@@ -819,7 +819,7 @@ common_traceroute_main(int op, char **argv)
819 INIT_G(); 819 INIT_G();
820 820
821 /* minimum 1 arg */ 821 /* minimum 1 arg */
822 opt_complementary = "-1:x-x" IF_FEATURE_TRACEROUTE_SOURCE_ROUTE(":g::"); 822 opt_complementary = "-1:x-x";
823 op |= getopt32(argv, OPT_STRING 823 op |= getopt32(argv, OPT_STRING
824 , &tos_str, &device, &max_ttl_str, &port_str, &nprobes_str 824 , &tos_str, &device, &max_ttl_str, &port_str, &nprobes_str
825 , &source, &waittime_str, &pausemsecs_str, &first_ttl_str 825 , &source, &waittime_str, &pausemsecs_str, &first_ttl_str
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index 12f8f1125..6ff040d9e 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -944,9 +944,9 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
944 944
945 /* Parse command line */ 945 /* Parse command line */
946 /* O,x: list; -T,-t,-A take numeric param */ 946 /* O,x: list; -T,-t,-A take numeric param */
947 opt_complementary = "O::x::T+:t+:A+" IF_UDHCP_VERBOSE(":vv") ; 947 IF_UDHCP_VERBOSE(opt_complementary = "vv";)
948 IF_LONG_OPTS(applet_long_options = udhcpc6_longopts;) 948 IF_LONG_OPTS(applet_long_options = udhcpc6_longopts;)
949 opt = getopt32(argv, "i:np:qRr:s:T:t:SA:O:ox:f" 949 opt = getopt32(argv, "i:np:qRr:s:T:+t:+SA:+O:*ox:*f"
950 USE_FOR_MMU("b") 950 USE_FOR_MMU("b")
951 ///IF_FEATURE_UDHCPC_ARPING("a") 951 ///IF_FEATURE_UDHCPC_ARPING("a")
952 IF_FEATURE_UDHCP_PORT("P:") 952 IF_FEATURE_UDHCP_PORT("P:")
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index e58acbaca..8a16e987d 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -1283,9 +1283,9 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1283 1283
1284 /* Parse command line */ 1284 /* Parse command line */
1285 /* O,x: list; -T,-t,-A take numeric param */ 1285 /* O,x: list; -T,-t,-A take numeric param */
1286 opt_complementary = "O::x::T+:t+:A+" IF_UDHCP_VERBOSE(":vv") ; 1286 IF_UDHCP_VERBOSE(opt_complementary = "vv";)
1287 IF_LONG_OPTS(applet_long_options = udhcpc_longopts;) 1287 IF_LONG_OPTS(applet_long_options = udhcpc_longopts;)
1288 opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fB" 1288 opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fB"
1289 USE_FOR_MMU("b") 1289 USE_FOR_MMU("b")
1290 IF_FEATURE_UDHCPC_ARPING("a::") 1290 IF_FEATURE_UDHCPC_ARPING("a::")
1291 IF_FEATURE_UDHCP_PORT("P:") 1291 IF_FEATURE_UDHCP_PORT("P:")
diff --git a/networking/wget.c b/networking/wget.c
index 28c12540b..37950ed39 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -1268,9 +1268,8 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0")
1268 applet_long_options = wget_longopts; 1268 applet_long_options = wget_longopts;
1269#endif 1269#endif
1270 opt_complementary = "-1" /* at least one URL */ 1270 opt_complementary = "-1" /* at least one URL */
1271 IF_FEATURE_WGET_TIMEOUT(":T+") /* -T NUM */
1272 IF_FEATURE_WGET_LONG_OPTIONS(":\xff::"); /* --header is a list */ 1271 IF_FEATURE_WGET_LONG_OPTIONS(":\xff::"); /* --header is a list */
1273 getopt32(argv, "csqO:P:Y:U:T:" 1272 getopt32(argv, "csqO:P:Y:U:T:+"
1274 /*ignored:*/ "t:" 1273 /*ignored:*/ "t:"
1275 /*ignored:*/ "n::" 1274 /*ignored:*/ "n::"
1276 /* wget has exactly four -n<letter> opts, all of which we can ignore: 1275 /* wget has exactly four -n<letter> opts, all of which we can ignore:
diff --git a/networking/whois.c b/networking/whois.c
index 6ba8dfd20..c9dfcf5ee 100644
--- a/networking/whois.c
+++ b/networking/whois.c
@@ -167,8 +167,8 @@ int whois_main(int argc UNUSED_PARAM, char **argv)
167 int port = 43; 167 int port = 43;
168 const char *host = "whois.iana.org"; 168 const char *host = "whois.iana.org";
169 169
170 opt_complementary = "-1:p+"; 170 opt_complementary = "-1";
171 getopt32(argv, "ih:p:", &host, &port); 171 getopt32(argv, "ih:p:+", &host, &port);
172 argv += optind; 172 argv += optind;
173 173
174 do { 174 do {