aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-17 09:09:09 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-17 09:09:09 +0000
commit1d42665b6b0571b9fa5d3b10fbf2dd03382f0ba2 (patch)
tree7ec8969fc2b07a2b7dc37f96435e5eddf7daf7fd /networking
parent62a90cdd7435f09f4bb8673e8b7b213067f9d5cc (diff)
downloadbusybox-w32-1d42665b6b0571b9fa5d3b10fbf2dd03382f0ba2.tar.gz
busybox-w32-1d42665b6b0571b9fa5d3b10fbf2dd03382f0ba2.tar.bz2
busybox-w32-1d42665b6b0571b9fa5d3b10fbf2dd03382f0ba2.zip
*: shrink: use Vladimir's "o+" specifier instead of xatou(opt_param)
function old new delta getopt32 1370 1385 +15 sulogin_main 490 494 +4 realpath_main 84 86 +2 sleep_main 76 77 +1 mt_main 256 257 +1 printenv_main 75 74 -1 fdformat_main 546 545 -1 usleep_main 44 42 -2 setlogcons_main 77 75 -2 ed_main 2654 2649 -5 deallocvt_main 69 64 -5 addgroup_main 373 368 -5 mkfs_minix_main 2989 2982 -7 tail_main 1221 1213 -8 sv_main 1254 1241 -13 du_main 348 328 -20 tftp_main 325 302 -23 split_main 581 558 -23 nc_main 1000 977 -23 diff_main 891 868 -23 arping_main 1797 1770 -27 ls_main 893 847 -46 od_main 2797 2750 -47 readprofile_main 1944 1895 -49 tcpudpsvd_main 1973 1922 -51 udhcpc_main 2590 2513 -77 grep_main 824 722 -102 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/22 up/down: 23/-560) Total: -537 bytes text data bss dec hex filename 796973 658 7428 805059 c48c3 busybox_old 796479 662 7420 804561 c46d1 busybox_unstripped
Diffstat (limited to 'networking')
-rw-r--r--networking/arping.c8
-rw-r--r--networking/nc_bloaty.c10
-rw-r--r--networking/tftp.c16
-rw-r--r--networking/udhcp/dhcpc.c17
4 files changed, 20 insertions, 31 deletions
diff --git a/networking/arping.c b/networking/arping.c
index 6a17b18ee..39dcb7cc2 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -264,16 +264,14 @@ int arping_main(int argc ATTRIBUTE_UNUSED, char **argv)
264 err_str = xasprintf("interface %s %%s", device); 264 err_str = xasprintf("interface %s %%s", device);
265 { 265 {
266 unsigned opt; 266 unsigned opt;
267 char *str_count, *str_timeout; 267 char *str_timeout;
268 268
269 /* Dad also sets quit_on_reply. 269 /* Dad also sets quit_on_reply.
270 * Advert also sets unsolicited. 270 * Advert also sets unsolicited.
271 */ 271 */
272 opt_complementary = "=1:Df:AU"; 272 opt_complementary = "=1:Df:AU:c+";
273 opt = getopt32(argv, "DUAqfbc:w:I:s:", 273 opt = getopt32(argv, "DUAqfbc:w:I:s:",
274 &str_count, &str_timeout, &device, &source); 274 &count, &str_timeout, &device, &source);
275 if (opt & 0x40) /* -c: count */
276 count = xatoi_u(str_count);
277 if (opt & 0x80) /* -w: timeout */ 275 if (opt & 0x80) /* -w: timeout */
278 timeout_us = xatou_range(str_timeout, 0, INT_MAX/2000000) * 1000000 + 500000; 276 timeout_us = xatou_range(str_timeout, 0, INT_MAX/2000000) * 1000000 + 500000;
279 //if (opt & 0x200) /* -s: source */ 277 //if (opt & 0x200) /* -s: source */
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c
index 34f715fc5..dd94a1460 100644
--- a/networking/nc_bloaty.c
+++ b/networking/nc_bloaty.c
@@ -674,7 +674,7 @@ Debug("wrote %d to net, errno %d", rr, errno);
674int nc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 674int nc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
675int nc_main(int argc, char **argv) 675int nc_main(int argc, char **argv)
676{ 676{
677 char *str_p, *str_s, *str_w; 677 char *str_p, *str_s;
678 USE_NC_EXTRA(char *str_i, *str_o;) 678 USE_NC_EXTRA(char *str_i, *str_o;)
679 char *themdotted = themdotted; /* gcc */ 679 char *themdotted = themdotted; /* gcc */
680 char **proggie; 680 char **proggie;
@@ -710,10 +710,10 @@ int nc_main(int argc, char **argv)
710 e_found: 710 e_found:
711 711
712 // -g -G -t -r deleted, unimplemented -a deleted too 712 // -g -G -t -r deleted, unimplemented -a deleted too
713 opt_complementary = "?2:vv"; /* max 2 params, -v is a counter */ 713 opt_complementary = "?2:vv:w+"; /* max 2 params; -v is a counter; -w N */
714 getopt32(argv, "hnp:s:uvw:" USE_NC_SERVER("l") 714 getopt32(argv, "hnp:s:uvw:" USE_NC_SERVER("l")
715 USE_NC_EXTRA("i:o:z"), 715 USE_NC_EXTRA("i:o:z"),
716 &str_p, &str_s, &str_w 716 &str_p, &str_s, &o_wait
717 USE_NC_EXTRA(, &str_i, &str_o, &o_verbose)); 717 USE_NC_EXTRA(, &str_i, &str_o, &o_verbose));
718 argv += optind; 718 argv += optind;
719#if ENABLE_NC_EXTRA 719#if ENABLE_NC_EXTRA
@@ -731,9 +731,7 @@ int nc_main(int argc, char **argv)
731 //if (option_mask32 & OPT_r) /* randomize various things */ 731 //if (option_mask32 & OPT_r) /* randomize various things */
732 //if (option_mask32 & OPT_u) /* use UDP */ 732 //if (option_mask32 & OPT_u) /* use UDP */
733 //if (option_mask32 & OPT_v) /* verbose */ 733 //if (option_mask32 & OPT_v) /* verbose */
734 if (option_mask32 & OPT_w) { /* wait time */ 734 //if (option_mask32 & OPT_w) /* wait time */
735 o_wait = xatoi_u(str_w);
736 }
737 //if (option_mask32 & OPT_z) /* little or no data xfer */ 735 //if (option_mask32 & OPT_z) /* little or no data xfer */
738 736
739 /* We manage our fd's so that they are never 0,1,2 */ 737 /* We manage our fd's so that they are never 0,1,2 */
diff --git a/networking/tftp.c b/networking/tftp.c
index 14c340b22..187261568 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -397,9 +397,6 @@ int tftp_main(int argc ATTRIBUTE_UNUSED, char **argv)
397 len_and_sockaddr *peer_lsa; 397 len_and_sockaddr *peer_lsa;
398 const char *localfile = NULL; 398 const char *localfile = NULL;
399 const char *remotefile = NULL; 399 const char *remotefile = NULL;
400#if ENABLE_FEATURE_TFTP_BLOCKSIZE
401 const char *sblocksize = NULL;
402#endif
403 int port; 400 int port;
404 USE_GETPUT(int cmd;) 401 USE_GETPUT(int cmd;)
405 int fd = -1; 402 int fd = -1;
@@ -409,13 +406,14 @@ int tftp_main(int argc ATTRIBUTE_UNUSED, char **argv)
409 406
410 /* -p or -g is mandatory, and they are mutually exclusive */ 407 /* -p or -g is mandatory, and they are mutually exclusive */
411 opt_complementary = "" USE_FEATURE_TFTP_GET("g:") USE_FEATURE_TFTP_PUT("p:") 408 opt_complementary = "" USE_FEATURE_TFTP_GET("g:") USE_FEATURE_TFTP_PUT("p:")
412 USE_GETPUT("?g--p:p--g"); 409 USE_GETPUT("g--p:p--g:")
410 USE_FEATURE_TFTP_BLOCKSIZE("b+");
413 411
414 USE_GETPUT(cmd =) getopt32(argv, 412 USE_GETPUT(cmd =) getopt32(argv,
415 USE_FEATURE_TFTP_GET("g") USE_FEATURE_TFTP_PUT("p") 413 USE_FEATURE_TFTP_GET("g") USE_FEATURE_TFTP_PUT("p")
416 "l:r:" USE_FEATURE_TFTP_BLOCKSIZE("b:"), 414 "l:r:" USE_FEATURE_TFTP_BLOCKSIZE("b:"),
417 &localfile, &remotefile 415 &localfile, &remotefile
418 USE_FEATURE_TFTP_BLOCKSIZE(, &sblocksize)); 416 USE_FEATURE_TFTP_BLOCKSIZE(, &blocksize));
419 argv += optind; 417 argv += optind;
420 418
421 flags = O_RDONLY; 419 flags = O_RDONLY;
@@ -423,12 +421,8 @@ int tftp_main(int argc ATTRIBUTE_UNUSED, char **argv)
423 flags = O_WRONLY | O_CREAT | O_TRUNC; 421 flags = O_WRONLY | O_CREAT | O_TRUNC;
424 422
425#if ENABLE_FEATURE_TFTP_BLOCKSIZE 423#if ENABLE_FEATURE_TFTP_BLOCKSIZE
426 if (sblocksize) { 424 if (!tftp_blocksize_check(blocksize, 0))
427 blocksize = xatoi_u(sblocksize); 425 return EXIT_FAILURE;
428 if (!tftp_blocksize_check(blocksize, 0)) {
429 return EXIT_FAILURE;
430 }
431 }
432#endif 426#endif
433 427
434 if (!localfile) 428 if (!localfile)
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 576b1cbb8..fe8f4c8fa 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -132,7 +132,7 @@ int udhcpc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
132int udhcpc_main(int argc ATTRIBUTE_UNUSED, char **argv) 132int udhcpc_main(int argc ATTRIBUTE_UNUSED, char **argv)
133{ 133{
134 uint8_t *temp, *message; 134 uint8_t *temp, *message;
135 char *str_c, *str_V, *str_h, *str_F, *str_r, *str_T, *str_A, *str_t; 135 char *str_c, *str_V, *str_h, *str_F, *str_r;
136 USE_FEATURE_UDHCP_PORT(char *str_P;) 136 USE_FEATURE_UDHCP_PORT(char *str_P;)
137 llist_t *list_O = NULL; 137 llist_t *list_O = NULL;
138#if ENABLE_FEATURE_UDHCPC_ARPING 138#if ENABLE_FEATURE_UDHCPC_ARPING
@@ -223,7 +223,8 @@ int udhcpc_main(int argc ATTRIBUTE_UNUSED, char **argv)
223 client_config.script = DEFAULT_SCRIPT; 223 client_config.script = DEFAULT_SCRIPT;
224 224
225 /* Parse command line */ 225 /* Parse command line */
226 opt_complementary = "c--C:C--c:O::"; // Cc: mutually exclusive; O: list 226 /* Cc: mutually exclusive; O: list; -T,-t,-A take numeric param */
227 opt_complementary = "c--C:C--c:O::T+:t+:A+";
227#if ENABLE_GETOPT_LONG 228#if ENABLE_GETOPT_LONG
228 applet_long_options = udhcpc_longopts; 229 applet_long_options = udhcpc_longopts;
229#endif 230#endif
@@ -233,7 +234,8 @@ int udhcpc_main(int argc ATTRIBUTE_UNUSED, char **argv)
233 "O:" 234 "O:"
234 , &str_c, &str_V, &str_h, &str_h, &str_F 235 , &str_c, &str_V, &str_h, &str_h, &str_F
235 , &client_config.interface, &client_config.pidfile, &str_r 236 , &client_config.interface, &client_config.pidfile, &str_r
236 , &client_config.script, &str_T, &str_t, &str_A 237 , &client_config.script
238 , &discover_timeout, &discover_retries, &tryagain_timeout
237 USE_FEATURE_UDHCPC_ARPING(, &str_W) 239 USE_FEATURE_UDHCPC_ARPING(, &str_W)
238 USE_FEATURE_UDHCP_PORT(, &str_P) 240 USE_FEATURE_UDHCP_PORT(, &str_P)
239 , &list_O 241 , &list_O
@@ -273,12 +275,9 @@ int udhcpc_main(int argc ATTRIBUTE_UNUSED, char **argv)
273 if (opt & OPT_r) 275 if (opt & OPT_r)
274 requested_ip = inet_addr(str_r); 276 requested_ip = inet_addr(str_r);
275 // if (opt & OPT_s) client_config.script = ... 277 // if (opt & OPT_s) client_config.script = ...
276 if (opt & OPT_T) 278 // if (opt & OPT_T) discover_timeout = xatoi_u(str_T);
277 discover_timeout = xatoi_u(str_T); 279 // if (opt & OPT_t) discover_retries = xatoi_u(str_t);
278 if (opt & OPT_t) 280 // if (opt & OPT_A) tryagain_timeout = xatoi_u(str_A);
279 discover_retries = xatoi_u(str_t);
280 if (opt & OPT_A)
281 tryagain_timeout = xatoi_u(str_A);
282 if (opt & OPT_v) { 281 if (opt & OPT_v) {
283 puts("version "BB_VER); 282 puts("version "BB_VER);
284 return 0; 283 return 0;