X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=applets.c;h=ca2de87d4dd2845ef65dfdd45143c66d8084b010;hb=deba6dea0340465af76624f9ef3a0bbe28130d8a;hp=51511037203e8e4ea81b80b835f56e80b6089087;hpb=2ccfef2004675cc6cb18b9cdad1ebdaf892a10c2;p=oweals%2Fbusybox.git diff --git a/applets.c b/applets.c index 515110372..ca2de87d4 100644 --- a/applets.c +++ b/applets.c @@ -27,6 +27,7 @@ #include #include +#include #include "busybox.h" #undef APPLET @@ -34,10 +35,6 @@ #undef PROTOTYPES #include "applets.h" -#define bb_need_full_version -#define BB_DECLARE_EXTERN -#include "messages.c" - struct BB_applet *applet_using; /* The -1 arises because of the {0,NULL,0,-1} entry above. */ @@ -48,6 +45,13 @@ extern void show_usage(void) const char *format_string; const char *usage_string = usage_messages; int i; + /* From busybox.c */ + extern int been_there_done_that; + + if (strcmp(applet_using->name, "busybox")==0) { + been_there_done_that=1; + busybox_main(0, NULL); + } for (i = applet_using - applets; i > 0; ) { if (!*usage_string++) { @@ -70,7 +74,7 @@ static int applet_name_compare(const void *x, const void *y) return strcmp(name, applet->name); } -extern size_t NUM_APPLETS; +extern const size_t NUM_APPLETS; struct BB_applet *find_applet_by_name(const char *name) { @@ -80,13 +84,22 @@ struct BB_applet *find_applet_by_name(const char *name) void run_applet_by_name(const char *name, int argc, char **argv) { + static int recurse_level = 0; + + recurse_level++; /* Do a binary search to find the applet entry given the name. */ if ((applet_using = find_applet_by_name(name)) != NULL) { applet_name = applet_using->name; - if (argv[1] && strcmp(argv[1], "--help") == 0) + if (argv[1] && strcmp(argv[1], "--help") == 0) { show_usage(); + } exit((*(applet_using->main)) (argc, argv)); } + /* Just in case they have renamed busybox - Check argv[1] */ + if (recurse_level == 1) { + run_applet_by_name("busybox", argc, argv); + } + recurse_level = 0; }