X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=applets%2Fapplets.c;h=f3e56a9f39b6563cd1dd88386223109561c708fe;hb=ace02dc9cd3ca0c95db5b5ebe87b9d6cd6ca1733;hp=1e31e89259917ec8f7f90e756d0838505b56ef26;hpb=aad1a88c76f208d188fd061e3723bd637437e8d5;p=oweals%2Fbusybox.git diff --git a/applets/applets.c b/applets/applets.c index 1e31e8925..f3e56a9f3 100644 --- a/applets/applets.c +++ b/applets/applets.c @@ -27,14 +27,19 @@ #include #include +#include #include "busybox.h" -#define bb_need_full_version -#define BB_DECLARE_EXTERN -#include "messages.c" +#undef APPLET +#undef APPLET_NOUSAGE +#undef PROTOTYPES +#include "applets.h" struct BB_applet *applet_using; +/* The -1 arises because of the {0,NULL,0,-1} entry above. */ +const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1); + extern void show_usage(void) { const char *format_string; @@ -62,7 +67,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) { @@ -72,13 +77,32 @@ 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; + extern int been_there_done_that; /* From busybox.c */ + + 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) - show_usage(); + if (argv[1] && strcmp(argv[1], "--help") == 0) { + if (strcmp(applet_using->name, "busybox")==0) { + if(argv[2]) + applet_using = find_applet_by_name(argv[2]); + else + applet_using = NULL; + } + if(applet_using) + show_usage(); + been_there_done_that=1; + busybox_main(0, NULL); + } 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--; }