aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-04-20 21:02:57 -0400
committerDenys Vlasenko <vda.linux@googlemail.com>2010-04-20 21:02:57 -0400
commit5a7c72015c0562dbe19f1e493b54b4c9db7f6f3a (patch)
treee43da66e2f894d231d96836a64d2ee02e0cfb934
parentf2c16edf99486a0ce2ca57f111831668e77d0fd1 (diff)
downloadbusybox-w32-5a7c72015c0562dbe19f1e493b54b4c9db7f6f3a.tar.gz
busybox-w32-5a7c72015c0562dbe19f1e493b54b4c9db7f6f3a.tar.bz2
busybox-w32-5a7c72015c0562dbe19f1e493b54b4c9db7f6f3a.zip
busybox --list option. +140 bytes. Rob wanted it.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/appletlib.c69
1 files changed, 44 insertions, 25 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 7a5e7ae4d..a8cd8e65f 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -595,6 +595,17 @@ static void check_suid(int applet_no)
595 595
596 596
597#if ENABLE_FEATURE_INSTALLER 597#if ENABLE_FEATURE_INSTALLER
598static const char usr_bin [] ALIGN1 = "/usr/bin/";
599static const char usr_sbin[] ALIGN1 = "/usr/sbin/";
600static const char *const install_dir[] = {
601 &usr_bin [8], /* "/" */
602 &usr_bin [4], /* "/bin/" */
603 &usr_sbin[4], /* "/sbin/" */
604 usr_bin,
605 usr_sbin
606};
607
608
598/* create (sym)links for each applet */ 609/* create (sym)links for each applet */
599static void install_links(const char *busybox, int use_symbolic_links, 610static void install_links(const char *busybox, int use_symbolic_links,
600 char *custom_install_dir) 611 char *custom_install_dir)
@@ -602,16 +613,6 @@ static void install_links(const char *busybox, int use_symbolic_links,
602 /* directory table 613 /* directory table
603 * this should be consistent w/ the enum, 614 * this should be consistent w/ the enum,
604 * busybox.h::bb_install_loc_t, or else... */ 615 * busybox.h::bb_install_loc_t, or else... */
605 static const char usr_bin [] ALIGN1 = "/usr/bin";
606 static const char usr_sbin[] ALIGN1 = "/usr/sbin";
607 static const char *const install_dir[] = {
608 &usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
609 &usr_bin [4], /* "/bin" */
610 &usr_sbin[4], /* "/sbin" */
611 usr_bin,
612 usr_sbin
613 };
614
615 int (*lf)(const char *, const char *); 616 int (*lf)(const char *, const char *);
616 char *fpc; 617 char *fpc;
617 unsigned i; 618 unsigned i;
@@ -635,8 +636,8 @@ static void install_links(const char *busybox, int use_symbolic_links,
635 } 636 }
636} 637}
637#else 638#else
638#define install_links(x,y,z) ((void)0) 639# define install_links(x,y,z) ((void)0)
639#endif /* FEATURE_INSTALLER */ 640#endif
640 641
641/* If we were called as "busybox..." */ 642/* If we were called as "busybox..." */
642static int busybox_main(char **argv) 643static int busybox_main(char **argv)
@@ -657,19 +658,20 @@ static int busybox_main(char **argv)
657 full_write2_str(bb_banner); /* reuse const string */ 658 full_write2_str(bb_banner); /* reuse const string */
658 full_write2_str(" multi-call binary.\n"); /* reuse */ 659 full_write2_str(" multi-call binary.\n"); /* reuse */
659 full_write2_str( 660 full_write2_str(
660 "Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko\n" 661 "Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko\n"
661 "and others. Licensed under GPLv2.\n" 662 "and others. Licensed under GPLv2.\n"
662 "See source distribution for full notice.\n" 663 "See source distribution for full notice.\n"
663 "\n" 664 "\n"
664 "Usage: busybox [function] [arguments]...\n" 665 "Usage: busybox [function] [arguments]...\n"
665 " or: function [arguments]...\n" 666 " or: function [arguments]...\n"
666 "\n" 667 "\n"
667 "\tBusyBox is a multi-call binary that combines many common Unix\n" 668 "\tBusyBox is a multi-call binary that combines many common Unix\n"
668 "\tutilities into a single executable. Most people will create a\n" 669 "\tutilities into a single executable. Most people will create a\n"
669 "\tlink to busybox for each function they wish to use and BusyBox\n" 670 "\tlink to busybox for each function they wish to use and BusyBox\n"
670 "\twill act like whatever it was invoked as.\n" 671 "\twill act like whatever it was invoked as.\n"
671 "\n" 672 "\n"
672 "Currently defined functions:\n"); 673 "Currently defined functions:\n"
674 );
673 col = 0; 675 col = 0;
674 a = applet_names; 676 a = applet_names;
675 /* prevent last comma to be in the very last pos */ 677 /* prevent last comma to be in the very last pos */
@@ -694,6 +696,23 @@ static int busybox_main(char **argv)
694 return 0; 696 return 0;
695 } 697 }
696 698
699 if (strncmp(argv[1], "--list", 6) == 0) {
700 unsigned i = 0;
701 const char *a = applet_names;
702 dup2(1, 2);
703 while (*a) {
704#if ENABLE_FEATURE_INSTALLER
705 if (argv[1][6]) /* --list-path? */
706 full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1);
707#endif
708 full_write2_str(a);
709 full_write2_str("\n");
710 i++;
711 a += strlen(a) + 1;
712 }
713 return 0;
714 }
715
697 if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) { 716 if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
698 int use_symbolic_links; 717 int use_symbolic_links;
699 const char *busybox; 718 const char *busybox;