This patch, put together by Manuel Novoa III, is a merge of work

done by Evin Robertson (bug#1105) and work from Manuel to make
usage messages occupy less space and simplify how usage messages
are displayed.
This commit is contained in:
Eric Andersen
2001-02-14 21:23:06 +00:00
parent 68be2ab914
commit 67991cf824
198 changed files with 702 additions and 3979 deletions

View File

@@ -40,6 +40,7 @@
#define bb_need_full_version
#define BB_DECLARE_EXTERN
#include "messages.c"
#include "usage.h"
#include <stdio.h>
#include <string.h>
@@ -76,12 +77,23 @@ const char mtab_file[] = "/proc/mounts";
# endif
#endif
extern void usage(const char *usage)
static struct BB_applet *applet_using;
extern void show_usage(void)
{
fprintf(stderr, "%s\n\nUsage: %s\n\n", full_version, usage);
static const char no_help[] = "No help available.\n";
const char *usage_string = no_help;
if (applet_using->usage_index >= 0) {
usage_string = usage_messages[applet_using->usage_index];
}
fprintf(stderr, "%s\n\nUsage: %s %s\n", full_version,
applet_using->name, usage_string);
exit(EXIT_FAILURE);
}
static void verror_msg(const char *s, va_list p)
{
fflush(stdout);
@@ -1702,6 +1714,17 @@ struct BB_applet *find_applet_by_name(const char *name)
applet_name_compare);
}
void run_applet_by_name(const char *name, int argc, char **argv)
{
/* 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();
exit((*(applet_using->main)) (argc, argv));
}
}
#if defined BB_DD || defined BB_TAIL
unsigned long parse_number(const char *numstr,
const struct suffix_mult *suffixes)