aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-11-29 03:31:20 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-11-29 03:31:20 +0000
commit745cd17926a9d75cdd6482d5ce58227b492d1ebe (patch)
tree568f3236704000eed61d3460f9eef92e9535b746 /libbb
parentc253778de92441b61806e1e4e7806e91f17ea50f (diff)
downloadbusybox-w32-745cd17926a9d75cdd6482d5ce58227b492d1ebe.tar.gz
busybox-w32-745cd17926a9d75cdd6482d5ce58227b492d1ebe.tar.bz2
busybox-w32-745cd17926a9d75cdd6482d5ce58227b492d1ebe.zip
Further optimize applet tables; prettify build output
text data bss dec hex filename 775923 929 9100 785952 bfe20 busybox_old 775565 929 9100 785594 bfcba busybox_unstripped
Diffstat (limited to 'libbb')
-rw-r--r--libbb/appletlib.c14
-rw-r--r--libbb/vfork_daemon_rexec.c2
2 files changed, 8 insertions, 8 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index dcf24f5a9..d5a2d06af 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -101,19 +101,17 @@ void bb_show_usage(void)
101} 101}
102 102
103 103
104/* NB: any char pointer will work as well, not necessarily applet_names */
104static int applet_name_compare(const void *name, const void *v) 105static int applet_name_compare(const void *name, const void *v)
105{ 106{
106 int i = (const char *)v - applet_names; 107 int i = (const char *)v - applet_names;
107 return strcmp(name, APPLET_NAME(i)); 108 return strcmp(name, APPLET_NAME(i));
108} 109}
109
110int find_applet_by_name(const char *name) 110int find_applet_by_name(const char *name)
111{ 111{
112 const char *p;
113 /* Do a binary search to find the applet entry given the name. */ 112 /* Do a binary search to find the applet entry given the name. */
114 113 const char *p;
115 /* NB: any char pointer will work as well, not necessarily applet_names */ 114 p = bsearch(name, applet_names, ARRAY_SIZE(applet_main), 1, applet_name_compare);
116 p = bsearch(name, applet_names, ARRAY_SIZE(applet_mains), 1, applet_name_compare);
117 if (!p) 115 if (!p)
118 return -1; 116 return -1;
119 return p - applet_names; 117 return p - applet_names;
@@ -543,10 +541,12 @@ static void install_links(const char *busybox, int use_symbolic_links)
543 if (use_symbolic_links) 541 if (use_symbolic_links)
544 lf = symlink; 542 lf = symlink;
545 543
546 for (i = 0; i < ARRAY_SIZE(applet_mains); i++) { 544 for (i = 0; i < ARRAY_SIZE(applet_main); i++) {
547 fpc = concat_path_file( 545 fpc = concat_path_file(
548 install_dir[APPLET_INSTALL_LOC(i)], 546 install_dir[APPLET_INSTALL_LOC(i)],
549 APPLET_NAME(i)); 547 APPLET_NAME(i));
548 // debug: bb_error_msg("%slinking %s to busybox",
549 // use_symbolic_links ? "sym" : "", fpc);
550 rc = lf(busybox, fpc); 550 rc = lf(busybox, fpc);
551 if (rc != 0 && errno != EEXIST) { 551 if (rc != 0 && errno != EEXIST) {
552 bb_simple_perror_msg(fpc); 552 bb_simple_perror_msg(fpc);
@@ -644,7 +644,7 @@ void run_applet_no_and_exit(int applet_no, char **argv)
644 bb_show_usage(); 644 bb_show_usage();
645 if (ENABLE_FEATURE_SUID) 645 if (ENABLE_FEATURE_SUID)
646 check_suid(applet_no); 646 check_suid(applet_no);
647 exit(applet_mains[applet_no](argc, argv)); 647 exit(applet_main[applet_no](argc, argv));
648} 648}
649 649
650void run_applet_and_exit(const char *name, char **argv) 650void run_applet_and_exit(const char *name, char **argv)
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index 1d6817ee6..d6e233ac3 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -143,7 +143,7 @@ int run_nofork_applet_prime(struct nofork_save_area *old, int applet_no, char **
143 char *tmp_argv[argc+1]; 143 char *tmp_argv[argc+1];
144 memcpy(tmp_argv, argv, (argc+1) * sizeof(tmp_argv[0])); 144 memcpy(tmp_argv, argv, (argc+1) * sizeof(tmp_argv[0]));
145 /* Finally we can call NOFORK applet's main() */ 145 /* Finally we can call NOFORK applet's main() */
146 rc = applet_mains[applet_no](argc, tmp_argv); 146 rc = applet_main[applet_no](argc, tmp_argv);
147 } else { /* xfunc died in NOFORK applet */ 147 } else { /* xfunc died in NOFORK applet */
148 /* in case they meant to return 0... */ 148 /* in case they meant to return 0... */
149 if (rc == -2222) 149 if (rc == -2222)