aboutsummaryrefslogtreecommitdiff
path: root/libbb/appletlib.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2016-11-29 11:26:45 +0000
committerRon Yorston <rmy@pobox.com>2016-11-29 11:26:45 +0000
commitbb8d79eadbba1942dbdb9f9cee5c47833afe269f (patch)
treeb8c517e9ca895d60d7227aef7177b6291df5e2cd /libbb/appletlib.c
parent9fa1e4990e655a85025c9d270a1606983e375e47 (diff)
parent7d877fc9312a742b06125927bb1d34bd35398c6c (diff)
downloadbusybox-w32-bb8d79eadbba1942dbdb9f9cee5c47833afe269f.tar.gz
busybox-w32-bb8d79eadbba1942dbdb9f9cee5c47833afe269f.tar.bz2
busybox-w32-bb8d79eadbba1942dbdb9f9cee5c47833afe269f.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb/appletlib.c')
-rw-r--r--libbb/appletlib.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 4aa40454f..1fe0eb44f 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -821,7 +821,7 @@ static int busybox_main(char **argv)
821 col += len2; 821 col += len2;
822 a += len2 - 1; 822 a += len2 - 1;
823 } 823 }
824 full_write2_str("\n\n"); 824 full_write2_str("\n");
825 return 0; 825 return 0;
826 } 826 }
827 827
@@ -936,20 +936,21 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv)
936} 936}
937# endif /* NUM_APPLETS > 0 */ 937# endif /* NUM_APPLETS > 0 */
938 938
939# if ENABLE_BUSYBOX || NUM_APPLETS > 0
939static NORETURN void run_applet_and_exit(const char *name, char **argv) 940static NORETURN void run_applet_and_exit(const char *name, char **argv)
940{ 941{
941# if ENABLE_BUSYBOX 942# if ENABLE_BUSYBOX
942 if (is_prefixed_with(name, "busybox")) 943 if (is_prefixed_with(name, "busybox"))
943 exit(busybox_main(argv)); 944 exit(busybox_main(argv));
944# endif 945# endif
945# if NUM_APPLETS > 0 946# if NUM_APPLETS > 0
946 /* find_applet_by_name() search is more expensive, so goes second */ 947 /* find_applet_by_name() search is more expensive, so goes second */
947 { 948 {
948 int applet = find_applet_by_name(name); 949 int applet = find_applet_by_name(name);
949 if (applet >= 0) 950 if (applet >= 0)
950 run_applet_no_and_exit(applet, argv); 951 run_applet_no_and_exit(applet, argv);
951 } 952 }
952# endif 953# endif
953 954
954 /*bb_error_msg_and_die("applet not found"); - links in printf */ 955 /*bb_error_msg_and_die("applet not found"); - links in printf */
955 full_write2_str(applet_name); 956 full_write2_str(applet_name);
@@ -957,11 +958,11 @@ static NORETURN void run_applet_and_exit(const char *name, char **argv)
957 /* POSIX: "If a command is not found, the exit status shall be 127" */ 958 /* POSIX: "If a command is not found, the exit status shall be 127" */
958 exit(127); 959 exit(127);
959} 960}
961# endif
960 962
961#endif /* !defined(SINGLE_APPLET_MAIN) */ 963#endif /* !defined(SINGLE_APPLET_MAIN) */
962 964
963 965
964
965#if ENABLE_BUILD_LIBBUSYBOX 966#if ENABLE_BUILD_LIBBUSYBOX
966int lbb_main(char **argv) 967int lbb_main(char **argv)
967#else 968#else
@@ -1025,6 +1026,7 @@ int main(int argc UNUSED_PARAM, char **argv)
1025#endif 1026#endif
1026 1027
1027#if defined(SINGLE_APPLET_MAIN) 1028#if defined(SINGLE_APPLET_MAIN)
1029
1028 /* Only one applet is selected in .config */ 1030 /* Only one applet is selected in .config */
1029 if (argv[1] && is_prefixed_with(argv[0], "busybox")) { 1031 if (argv[1] && is_prefixed_with(argv[0], "busybox")) {
1030 /* "busybox <applet> <params>" should still work as expected */ 1032 /* "busybox <applet> <params>" should still work as expected */
@@ -1033,9 +1035,16 @@ int main(int argc UNUSED_PARAM, char **argv)
1033 /* applet_names in this case is just "applet\0\0" */ 1035 /* applet_names in this case is just "applet\0\0" */
1034 lbb_prepare(applet_names IF_FEATURE_INDIVIDUAL(, argv)); 1036 lbb_prepare(applet_names IF_FEATURE_INDIVIDUAL(, argv));
1035 return SINGLE_APPLET_MAIN(argc, argv); 1037 return SINGLE_APPLET_MAIN(argc, argv);
1038
1039#elif !ENABLE_BUSYBOX && NUM_APPLETS == 0
1040
1041 full_write2_str(bb_basename(argv[0]));
1042 full_write2_str(": no applets enabled\n");
1043 exit(127);
1044
1036#else 1045#else
1037 lbb_prepare("busybox" IF_FEATURE_INDIVIDUAL(, argv));
1038 1046
1047 lbb_prepare("busybox" IF_FEATURE_INDIVIDUAL(, argv));
1039# if !ENABLE_BUSYBOX 1048# if !ENABLE_BUSYBOX
1040 if (argv[1] && is_prefixed_with(bb_basename(argv[0]), "busybox")) 1049 if (argv[1] && is_prefixed_with(bb_basename(argv[0]), "busybox"))
1041 argv++; 1050 argv++;
@@ -1067,9 +1076,8 @@ int main(int argc UNUSED_PARAM, char **argv)
1067 } 1076 }
1068 } 1077 }
1069 applet_name = bb_basename(applet_name); 1078 applet_name = bb_basename(applet_name);
1070
1071 parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */ 1079 parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */
1072
1073 run_applet_and_exit(applet_name, argv); 1080 run_applet_and_exit(applet_name, argv);
1081
1074#endif 1082#endif
1075} 1083}