summaryrefslogtreecommitdiff
path: root/applets/applets.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-04-14 10:09:57 +0000
committerDenis Vlasenko2007-04-14 10:09:57 +0000
commitf5294e1f4c56afb377ada95a7757b28ad3c89086 (patch)
tree95a0c3632c8c2b20fa6b60f1e1a33e4fc4b24d4f /applets/applets.c
parent16abcd90aefae8bdb9f7d80a555982dba6ca59b5 (diff)
downloadbusybox-f5294e1f4c56afb377ada95a7757b28ad3c89086.zip
busybox-f5294e1f4c56afb377ada95a7757b28ad3c89086.tar.gz
hush: use NOFORK applets as appropriate. Net reduction of code size.
Diffstat (limited to 'applets/applets.c')
-rw-r--r--applets/applets.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/applets/applets.c b/applets/applets.c
index 82a7eee..fb37fbe 100644
--- a/applets/applets.c
+++ b/applets/applets.c
@@ -514,14 +514,14 @@ static void install_links(const char *busybox, int use_symbolic_links)
/* If we were called as "busybox..." */
-static int busybox_main(int argc, char **argv)
+static int busybox_main(char **argv)
{
- if (ENABLE_FEATURE_INSTALLER && argc > 1 && !strcmp(argv[1], "--install")) {
+ if (ENABLE_FEATURE_INSTALLER && argv[1] && !strcmp(argv[1], "--install")) {
int use_symbolic_links = 0;
char *busybox;
/* to use symlinks, or not to use symlinks... */
- if (argc > 2)
+ if (argv[2])
if (strcmp(argv[2], "-s") == 0)
use_symbolic_links = 1;
@@ -537,11 +537,12 @@ static int busybox_main(int argc, char **argv)
/* Deal with --help. Also print help when called with no arguments */
- if (argc == 1 || !strcmp(argv[1], "--help") ) {
- if (argc > 2) {
+ if (!argv[1] || !strcmp(argv[1], "--help") ) {
+ if (argv[2]) {
/* set name for proper "<name>: applet not found" */
applet_name = argv[2];
- run_applet_and_exit(applet_name, 2, argv);
+ argv[2] = NULL;
+ run_applet_and_exit(applet_name, argv);
} else {
const struct bb_applet *a;
int col, output_width;
@@ -582,14 +583,19 @@ static int busybox_main(int argc, char **argv)
} else {
/* we want "<argv[1]>: applet not found", not "busybox: ..." */
applet_name = argv[1];
- run_applet_and_exit(argv[1], argc - 1, argv + 1);
+ run_applet_and_exit(argv[1], argv + 1);
}
bb_error_msg_and_die("applet not found");
}
-void run_current_applet_and_exit(int argc, char **argv)
+void run_current_applet_and_exit(char **argv)
{
+ int argc = 1;
+
+ while (argv[argc])
+ argc++;
+
/* Reinit some shared global data */
optind = 1;
xfunc_error_retval = EXIT_FAILURE;
@@ -602,13 +608,13 @@ void run_current_applet_and_exit(int argc, char **argv)
exit(current_applet->main(argc, argv));
}
-void run_applet_and_exit(const char *name, int argc, char **argv)
+void run_applet_and_exit(const char *name, char **argv)
{
current_applet = find_applet_by_name(name);
if (current_applet)
- run_current_applet_and_exit(argc, argv);
+ run_current_applet_and_exit(argv);
if (!strncmp(name, "busybox", 7))
- exit(busybox_main(argc, argv));
+ exit(busybox_main(argv));
}
@@ -637,6 +643,6 @@ int main(int argc, char **argv)
if (ENABLE_LOCALE_SUPPORT && getpid() != 1)
setlocale(LC_ALL, "");
- run_applet_and_exit(applet_name, argc, argv);
+ run_applet_and_exit(applet_name, argv);
bb_error_msg_and_die("applet not found");
}