aboutsummaryrefslogtreecommitdiff
path: root/libbb/appletlib.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-14 11:41:16 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-14 11:41:16 +1000
commit743d85e7d1c2a721baf020b9d79f45f0df2420a9 (patch)
tree9e551b726ac2bf9fd8eafb2764e7237f352bb429 /libbb/appletlib.c
parent87911f4fcd86f7abc0aefba8e9cbec2ac9d127e4 (diff)
parentc7f95d23f6bc7e17a3b79decf83eb362b389e53a (diff)
downloadbusybox-w32-743d85e7d1c2a721baf020b9d79f45f0df2420a9.tar.gz
busybox-w32-743d85e7d1c2a721baf020b9d79f45f0df2420a9.tar.bz2
busybox-w32-743d85e7d1c2a721baf020b9d79f45f0df2420a9.zip
Merge branch 'origin/master' (early part)
Diffstat (limited to 'libbb/appletlib.c')
-rw-r--r--libbb/appletlib.c73
1 files changed, 47 insertions, 26 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index f287e4522..f6dc1f171 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -105,7 +105,9 @@ static const char *unpack_usage_messages(void)
105 105
106static void full_write2_str(const char *str) 106static void full_write2_str(const char *str)
107{ 107{
108 xwrite_str(STDERR_FILENO, str); 108 // This uses stdio:
109 //xwrite_str(STDERR_FILENO, str);
110 write(STDERR_FILENO, str, strlen(str));
109} 111}
110 112
111void FAST_FUNC bb_show_usage(void) 113void FAST_FUNC bb_show_usage(void)
@@ -593,6 +595,17 @@ static void check_suid(int applet_no)
593 595
594 596
595#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
596/* create (sym)links for each applet */ 609/* create (sym)links for each applet */
597static void install_links(const char *busybox, int use_symbolic_links, 610static void install_links(const char *busybox, int use_symbolic_links,
598 char *custom_install_dir) 611 char *custom_install_dir)
@@ -600,16 +613,6 @@ static void install_links(const char *busybox, int use_symbolic_links,
600 /* directory table 613 /* directory table
601 * this should be consistent w/ the enum, 614 * this should be consistent w/ the enum,
602 * busybox.h::bb_install_loc_t, or else... */ 615 * busybox.h::bb_install_loc_t, or else... */
603 static const char usr_bin [] ALIGN1 = "/usr/bin";
604 static const char usr_sbin[] ALIGN1 = "/usr/sbin";
605 static const char *const install_dir[] = {
606 &usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
607 &usr_bin [4], /* "/bin" */
608 &usr_sbin[4], /* "/sbin" */
609 usr_bin,
610 usr_sbin
611 };
612
613 int (*lf)(const char *, const char *); 616 int (*lf)(const char *, const char *);
614 char *fpc; 617 char *fpc;
615 unsigned i; 618 unsigned i;
@@ -633,8 +636,8 @@ static void install_links(const char *busybox, int use_symbolic_links,
633 } 636 }
634} 637}
635#else 638#else
636#define install_links(x,y,z) ((void)0) 639# define install_links(x,y,z) ((void)0)
637#endif /* FEATURE_INSTALLER */ 640#endif
638 641
639/* If we were called as "busybox..." */ 642/* If we were called as "busybox..." */
640static int busybox_main(char **argv) 643static int busybox_main(char **argv)
@@ -655,19 +658,20 @@ static int busybox_main(char **argv)
655 full_write2_str(bb_banner); /* reuse const string */ 658 full_write2_str(bb_banner); /* reuse const string */
656 full_write2_str(" multi-call binary.\n"); /* reuse */ 659 full_write2_str(" multi-call binary.\n"); /* reuse */
657 full_write2_str( 660 full_write2_str(
658 "Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko\n" 661 "Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko\n"
659 "and others. Licensed under GPLv2.\n" 662 "and others. Licensed under GPLv2.\n"
660 "See source distribution for full notice.\n" 663 "See source distribution for full notice.\n"
661 "\n" 664 "\n"
662 "Usage: busybox [function] [arguments]...\n" 665 "Usage: busybox [function] [arguments]...\n"
663 " or: function [arguments]...\n" 666 " or: function [arguments]...\n"
664 "\n" 667 "\n"
665 "\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"
666 "\tutilities into a single executable. Most people will create a\n" 669 "\tutilities into a single executable. Most people will create a\n"
667 "\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"
668 "\twill act like whatever it was invoked as.\n" 671 "\twill act like whatever it was invoked as.\n"
669 "\n" 672 "\n"
670 "Currently defined functions:\n"); 673 "Currently defined functions:\n"
674 );
671 col = 0; 675 col = 0;
672 a = applet_names; 676 a = applet_names;
673 /* prevent last comma to be in the very last pos */ 677 /* prevent last comma to be in the very last pos */
@@ -692,6 +696,23 @@ static int busybox_main(char **argv)
692 return 0; 696 return 0;
693 } 697 }
694 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
695 if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) { 716 if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
696 int use_symbolic_links; 717 int use_symbolic_links;
697 const char *busybox; 718 const char *busybox;