summaryrefslogtreecommitdiff
path: root/libbb/appletlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/appletlib.c')
-rw-r--r--libbb/appletlib.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 54300bd87..dba66cc93 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -187,6 +187,10 @@ void lbb_prepare(const char *applet
187 if (ENABLE_LOCALE_SUPPORT) 187 if (ENABLE_LOCALE_SUPPORT)
188 setlocale(LC_ALL, ""); 188 setlocale(LC_ALL, "");
189 189
190#if ENABLE_PLATFORM_MINGW32
191 init_winsock();
192#endif
193
190#if ENABLE_FEATURE_INDIVIDUAL 194#if ENABLE_FEATURE_INDIVIDUAL
191 /* Redundant for busybox (run_applet_and_exit covers that case) 195 /* Redundant for busybox (run_applet_and_exit covers that case)
192 * but needed for "individual applet" mode */ 196 * but needed for "individual applet" mode */
@@ -642,10 +646,19 @@ static int busybox_main(char **argv)
642 ) 646 )
643 " or: function [arguments]...\n" 647 " or: function [arguments]...\n"
644 "\n" 648 "\n"
649 IF_NOT_FEATURE_SH_STANDALONE(
645 "\tBusyBox is a multi-call binary that combines many common Unix\n" 650 "\tBusyBox is a multi-call binary that combines many common Unix\n"
646 "\tutilities into a single executable. Most people will create a\n" 651 "\tutilities into a single executable. Most people will create a\n"
647 "\tlink to busybox for each function they wish to use and BusyBox\n" 652 "\tlink to busybox for each function they wish to use and BusyBox\n"
648 "\twill act like whatever it was invoked as.\n" 653 "\twill act like whatever it was invoked as.\n"
654 )
655 IF_FEATURE_SH_STANDALONE(
656 "\tBusyBox is a multi-call binary that combines many common Unix\n"
657 "\tutilities into a single executable. This version has been\n"
658 "\tconfigured to prefer built-in utilities to external binaries.\n"
659 "\tThis avoids having to install a link to busybox for each\n"
660 "\tfunction to be invoked.\n"
661 )
649 "\n" 662 "\n"
650 "Currently defined functions:\n" 663 "Currently defined functions:\n"
651 ); 664 );
@@ -815,6 +828,18 @@ int main(int argc UNUSED_PARAM, char **argv)
815 } 828 }
816#endif 829#endif
817 830
831#if defined(__MINGW64_VERSION_MAJOR)
832 if ( stdin ) {
833 _setmode(fileno(stdin), _O_BINARY);
834 }
835 if ( stdout ) {
836 _setmode(fileno(stdout), _O_BINARY);
837 }
838 if ( stderr ) {
839 _setmode(fileno(stderr), _O_BINARY);
840 }
841#endif
842
818#if defined(SINGLE_APPLET_MAIN) 843#if defined(SINGLE_APPLET_MAIN)
819 /* Only one applet is selected in .config */ 844 /* Only one applet is selected in .config */
820 if (argv[1] && strncmp(argv[0], "busybox", 7) == 0) { 845 if (argv[1] && strncmp(argv[0], "busybox", 7) == 0) {
@@ -830,6 +855,25 @@ int main(int argc UNUSED_PARAM, char **argv)
830 applet_name = argv[0]; 855 applet_name = argv[0];
831 if (applet_name[0] == '-') 856 if (applet_name[0] == '-')
832 applet_name++; 857 applet_name++;
858 if (ENABLE_PLATFORM_MINGW32) {
859 const char *applet_name_env = getenv("BUSYBOX_APPLET_NAME");
860 if (applet_name_env && *applet_name_env) {
861 applet_name = applet_name_env;
862 unsetenv("BUSYBOX_APPLET_NAME");
863 }
864 else {
865 char *s = argv[0];
866 int i, len = strlen(s);
867
868 for ( i=0; i < len; ++i ) {
869 s[i] = tolower(s[i]);
870 }
871 if (len > 4 && !strcmp(s+len-4, ".exe")) {
872 len -= 4;
873 s[len] = '\0';
874 }
875 }
876 }
833 applet_name = bb_basename(applet_name); 877 applet_name = bb_basename(applet_name);
834 878
835 parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */ 879 parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */