From f406134a3d5fb50ce61bdab83601203319a9cff8 Mon Sep 17 00:00:00 2001 From: Gildas Bazin Date: Wed, 27 Jun 2001 06:29:59 +0000 Subject: [PATCH] - Added command line option '--stdout ' which redirects stdout and stderr to the specified file. This option should mainly be useful on Win32. - On Win32, vlc now has an icon associated to the .exe file, and is a full GUI application (you don't have this annoying dos command box anymore) - Added INSTALL-win32.txt for specific details to the Win32 port. I've tested these changes on Win32 and Linux, let's hope I didn't break vlc for other platforms. -- Gildas --- INSTALL-win32.txt | 75 +++++++++++++++++++++++++ Makefile | 14 ++++- Makefile.opts.in | 2 +- include/config.h.in | 4 ++ share/gvlc_win32.ico | Bin 0 -> 7358 bytes share/vlc_win32_rc.rc | 1 + src/interface/main.c | 128 ++++++++++++++++++++++++++++++++++++++++-- 7 files changed, 216 insertions(+), 8 deletions(-) create mode 100644 INSTALL-win32.txt create mode 100644 share/gvlc_win32.ico create mode 100644 share/vlc_win32_rc.rc diff --git a/INSTALL-win32.txt b/INSTALL-win32.txt new file mode 100644 index 0000000000..f8619a5eee --- /dev/null +++ b/INSTALL-win32.txt @@ -0,0 +1,75 @@ +INSTALL file for the Windows9x/2k version of vlc, the VideoLAN Client + +Running VideoLAN +================ + +If you have already built vlc (see below) or are using a binary release, +just run 'vlc.exe'. + +You can also run vlc from a dos command box, in which case you'll be able +to use the command line arguments. You can obtain a list of these command +line arguments by typing 'vlc --help'. +It is also sometimes useful to display vlc's debug console. You can do so +by running 'vlc -v'. +To store a debug log of the current vlc session, you can use +'vlc -vvv --stdout=debug.txt'. + +If you want to play a DVD, run vlc and click on the Disc option in the +interface. You then have to type your drive letter in the 'Device name' +box (eg. 'D:' if your dvdrom drive is assigned the letter 'D'). +(Warning: you have to be in administrator mode (for now) on Win2k) + + +Building VideoLAN from source code +================================== + +If you want to do the tricky job of building vlc from source, follow +these instructions: +( WARNING: the win32 build process is not yet really stable, so you may have + to hack manually the MAKEFILES ) + +Getting the right tools +======================= + +You can build the win32 vlc port in two ways: +- natively on Windows +- or on Linux, using cross-compiling + +All these tools can be found on the libSDL web page: +http://www.libsdl.org/Xmingw32/ + +Configuring VideoLAN +==================== + +A typical way to configure vlc is: + + ./configure --disable-x11 --disable-xvideo --disable-dsp --without-sdl \ + --with-directx=/usr/local/cross-compile/i386-mingw32msvc + +See `./configure --help' for more information. + +To cross-compile for the Win32 platform using mingw32: + + make distclean && CC=i586-mingw32msvc-gcc CFLAGS=-I/usr/i586-mingw32msvc \ + RANLIB=i586-mingw32msvc-ranlib WINDRES=i586-mingw32msvc-windres \ + ./configure --host=i386-mingw32msvc \ + --target=i386-mingw32msvc --build=i386-linux --disable-dsp \ + --disable-x11 --disable-xvideo + + +Building VideoLAN +================= + +Have a look at the generated Makefile.opts file, you may want to choose +which modules will be compiled as plugins, and which ones will remain in +the core application. The configure script tries to guess for you. + +Once configured, run `make' to build vlc. + + + + + + + + diff --git a/Makefile b/Makefile index 838e554b28..caa4b0e993 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,10 @@ ifneq (,$(findstring darwin,$(SYS))) C_OBJ += src/misc/darwin_specific.o endif +ifneq (,$(findstring mingw32,$(SYS))) +RESOURCE_OBJ := share/vlc_win32_rc.o +endif + # # Generated header # @@ -318,11 +322,17 @@ $(CPP_OBJ): %.o: .dep/%.dpp $(CPP_OBJ): %.o: %.cpp $(CC) $(CFLAGS) -c -o $@ $< +$(RESOURCE_OBJ): %.o: Makefile.dep Makefile +ifneq (,(findstring mingw32,$(SYS))) +$(RESOURCE_OBJ): %.o: %.rc + $(WINDRES) -i $< -o $@ +endif + # # Main application target # -vlc: Makefile.opts Makefile.dep Makefile $(H_OBJ) $(C_OBJ) $(CPP_OBJ) $(BUILTIN_OBJ) - $(CC) $(CFLAGS) -o $@ $(C_OBJ) $(CPP_OBJ) $(BUILTIN_OBJ) $(LCFLAGS) $(LIB) +vlc: Makefile.opts Makefile.dep Makefile $(H_OBJ) $(C_OBJ) $(CPP_OBJ) $(BUILTIN_OBJ) $(RESOURCE_OBJ) + $(CC) $(CFLAGS) -o $@ $(C_OBJ) $(CPP_OBJ) $(BUILTIN_OBJ) $(RESOURCE_OBJ) $(LCFLAGS) $(LIB) ifeq ($(SYS),beos) xres -o $@ ./share/vlc_beos.rsrc mimeset -f $@ diff --git a/Makefile.opts.in b/Makefile.opts.in index 72374e11df..daa57953eb 100644 --- a/Makefile.opts.in +++ b/Makefile.opts.in @@ -243,7 +243,7 @@ LCFLAGS += @LCFLAGS@ $(LIB) LCFLAGS += -Wall #LCFLAGS += -s ifneq (,$(findstring mingw32,$(SYS))) -LCFLAGS += -Xlinker --force-exe-suffix +LCFLAGS += -mwindows -Xlinker --force-exe-suffix endif # diff --git a/include/config.h.in b/include/config.h.in index a53829fe67..618fbd5ada 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -147,6 +147,10 @@ #define INTF_PATH_VAR "vlc_search_path" #define INTF_PATH_DEFAULT "" +/* Environment variable containing the standard output method */ +#define INTF_STDOUT_VAR "vlc_stdout" +#define INTF_STDOUT_DEFAULT "" + /***************************************************************************** * Input thread configuration *****************************************************************************/ diff --git a/share/gvlc_win32.ico b/share/gvlc_win32.ico new file mode 100644 index 0000000000000000000000000000000000000000..8842b76a2fbe7880da56722f2c85745c7aea464d GIT binary patch literal 7358 zcmeI1dt4J&7RPVMgt?kXLI6Pwf(233DilN~gb)IRhpQrLrC=Z0t=77-1_fqK8h9yBq;%1t!6`k@ImgLn;|ra4_M3EKOBZR zckbMo^Ub-xbI$}262MP*ID(@e+Mz(GKSF32{6ZIc4t{CBV;jhuN5@}U1m=!?>X(Bg z_vowf9HN%Ci{{~iNyRum;WTDZ{{$&!@I!=&7#b!Q`s$MFb!qijfHk!m&ccZ$?jC(1 z<$7~lP=;QvqB}I4n?!~~19Ei9wMogA(wy<=_~7J`xKB&VfIZZD%l`rQf5K zcC?Dn9U8wgyXBk|_mS)3D-#o|lXT`pU2RHojgUbai$-}>sWz)sW))CjsQ?Q^4@AQ= zEWV5ul%geXJ<08s^OwAXi<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vk`zgCwu^i zyr(3c#yeL<*P5=|NuJzGW*;Prk5QiayUeb)fPjM}c(o?PsE-FWm@A$i-Q1viN6$k_7NrykOR`Jm_gW0=yLr5nob_q znm*~DkGHnua;I~x^6E#Sf)_)@^?KKAbwT6;H(<1^$Uu{H{Y4nYPHMo zUT+2j1Qfhibo%T!P{q2|uT$r$1`i(G>kyqCKw;hf$qA@m$In)rx?ERou~}^7+K=RB zgMH7@vf$w0&cl2C3?%gWj^g)AjC1$f<{W5Qe5`e42~~1YDSW5u**n9}!V2$Zk*ms6 zci5A6-kSOm`Sk&^=qSzf{15-HndSOf0+*IW7uwS!d>J z`uxxCP_uf^@7quryR}5!@<>zqz+E7<&?7-1rlmoyV$t)e%`hrr(N#o eZ$q6ep&^3jbg_c=ey4q{{k*u{f^pn;XZv4SaTSOF literal 0 HcmV?d00001 diff --git a/share/vlc_win32_rc.rc b/share/vlc_win32_rc.rc new file mode 100644 index 0000000000..19c48cafcd --- /dev/null +++ b/share/vlc_win32_rc.rc @@ -0,0 +1 @@ +VLC_ICON ICON "share/gvlc_win32.ico" diff --git a/src/interface/main.c b/src/interface/main.c index 2fdb9d2d7b..2160fa8adc 100644 --- a/src/interface/main.c +++ b/src/interface/main.c @@ -4,7 +4,7 @@ * and spawn threads. ***************************************************************************** * Copyright (C) 1998, 1999, 2000 VideoLAN - * $Id: main.c,v 1.105 2001/06/25 11:34:08 sam Exp $ + * $Id: main.c,v 1.106 2001/06/27 06:29:59 gbazin Exp $ * * Authors: Vincent Seguin * Samuel Hocevar @@ -59,6 +59,8 @@ #include /* ENOMEM */ #include /* getenv(), strtol(), */ #include /* strerror() */ +#include /* open(), O_WRONLY */ +#include /* S_IREAD */ #include "config.h" #include "common.h" @@ -127,6 +129,7 @@ #define OPT_SYNCHRO 190 #define OPT_WARNING 191 #define OPT_VERSION 192 +#define OPT_STDOUT 193 /* Usage fashion */ #define USAGE 0 @@ -156,6 +159,7 @@ static const struct option longopts[] = /* Interface options */ { "intf", 1, 0, 'I' }, { "warning", 1, 0, OPT_WARNING }, + { "stdout", 1, 0, OPT_STDOUT }, /* Audio options */ { "noaudio", 0, 0, OPT_NOAUDIO }, @@ -226,6 +230,10 @@ static void SimpleSignalHandler ( int i_signal ); static void FatalSignalHandler ( int i_signal ); static void InstructionSignalHandler( int i_signal ); static int CPUCapabilities ( void ); + +static int RedirectSTDOUT ( void ); +static void ShowConsole ( void ); + static jmp_buf env; static int i_illegal; @@ -299,6 +307,12 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] ) return( errno ); } + /* + * Redirect the standard output if required by the user, and on Win32 we + * also open a console to display the debug messages. + */ + RedirectSTDOUT(); + /* * Initialize playlist and get commandline files */ @@ -558,15 +572,48 @@ static int GetConfiguration( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] ) { /* General/common options */ case 'h': /* -h, --help */ + ShowConsole(); + RedirectSTDOUT(); Usage( SHORT_HELP ); +#ifdef WIN32 /* Pause the console because it's destroyed when we exit */ + if( strcmp( "", main_GetPszVariable( INTF_STDOUT_VAR, + INTF_STDOUT_DEFAULT ) ) == 0 ) + { + /* No stdout redirection has been asked for */ + intf_MsgImm( "\nPress the RETURN key to continue..." ); + getchar(); + } +#endif return( -1 ); break; case 'H': /* -H, --longhelp */ + ShowConsole(); + RedirectSTDOUT(); Usage( LONG_HELP ); +#ifdef WIN32 /* Pause the console because it's destroyed when we exit */ + if( strcmp( "", main_GetPszVariable( INTF_STDOUT_VAR, + INTF_STDOUT_DEFAULT ) ) == 0 ) + { + /* No stdout redirection has been asked for */ + intf_MsgImm( "\nPress the RETURN key to continue..." ); + getchar(); + } +#endif return( -1 ); break; case OPT_VERSION: /* --version */ + ShowConsole(); + RedirectSTDOUT(); Version(); +#ifdef WIN32 /* Pause the console because it's destroyed when we exit */ + if( strcmp( "", main_GetPszVariable( INTF_STDOUT_VAR, + INTF_STDOUT_DEFAULT ) ) == 0 ) + { + /* No stdout redirection has been asked for */ + intf_MsgImm( "\nPress the RETURN key to continue..." ); + getchar(); + } +#endif return( -1 ); break; case 'v': /* -v, --verbose */ @@ -582,6 +629,10 @@ static int GetConfiguration( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] ) p_main->i_warning_level = atoi(optarg); break; + case OPT_STDOUT: /* --stdout */ + main_PutPszVariable( INTF_STDOUT_VAR, optarg ); + break; + /* Audio options */ case OPT_NOAUDIO: /* --noaudio */ p_main->b_audio = 0; @@ -598,7 +649,7 @@ static int GetConfiguration( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] ) case OPT_SPDIF: /* --spdif */ main_PutIntVariable( AOUT_SPDIF_VAR, 1 ); break; - case OPT_DOWNMIX: /* --downmix */ + case OPT_DOWNMIX: /* --downmix */ main_PutPszVariable( DOWNMIX_METHOD_VAR, optarg ); break; case OPT_IMDCT: /* --imdct */ @@ -696,9 +747,20 @@ static int GetConfiguration( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] ) /* Internal error: unknown option */ case '?': default: + ShowConsole(); + RedirectSTDOUT(); intf_ErrMsg( "intf error: unknown option `%s'", ppsz_argv[optind - 1] ); Usage( USAGE ); +#ifdef WIN32 /* Pause the console because it's destroyed when we exit */ + if( strcmp( "", main_GetPszVariable( INTF_STDOUT_VAR, + INTF_STDOUT_DEFAULT ) ) == 0 ) + { + /* No stdout redirection has been asked for */ + intf_MsgImm( "\nPress the RETURN key to continue..." ); + getchar(); + } +#endif return( EINVAL ); break; } @@ -753,6 +815,7 @@ static void Usage( int i_fashion ) intf_MsgImm( "\nOptions:" "\n -I, --intf \tinterface method" "\n -v, --verbose \tverbose mode (cumulative)" + "\n --stdout \tredirect console stdout" "\n" "\n --noaudio \tdisable audio" "\n -A, --aout \taudio output method" @@ -796,9 +859,10 @@ static void Usage( int i_fashion ) /* Interface parameters */ intf_MsgImm( "\nInterface parameters:" - "\n " INTF_METHOD_VAR "= \tinterface method" - "\n " INTF_INIT_SCRIPT_VAR "= \tinitialization script" - "\n " INTF_CHANNELS_VAR "= \tchannels list" ); + "\n " INTF_METHOD_VAR "= \tinterface method" + "\n " INTF_INIT_SCRIPT_VAR "= \tinitialization script" + "\n " INTF_CHANNELS_VAR "= \tchannels list" + "\n " INTF_STDOUT_VAR "= \tredirect console stdout" ); /* Audio parameters */ intf_MsgImm( "\nAudio parameters:" @@ -1104,3 +1168,57 @@ static int CPUCapabilities( void ) #endif } +/***************************************************************************** + * RedirectSTDOUT: redirect stdout and stderr to a file + ***************************************************************************** + * This function will redirect stdout and stderr to a file if the user has + * specified so. + *****************************************************************************/ +static int RedirectSTDOUT( void ) +{ + int i_stdout_filedesc; + char *psz_stdout_filename; + + psz_stdout_filename = main_GetPszVariable( INTF_STDOUT_VAR, + INTF_STDOUT_DEFAULT ); + if( strcmp( "", psz_stdout_filename ) != 0 ) + { + ShowConsole(); + i_stdout_filedesc = open( psz_stdout_filename, + O_CREAT | O_TRUNC | O_RDWR, + S_IREAD | S_IWRITE ); + if( dup2( i_stdout_filedesc, fileno(stdout) ) == -1 ) + intf_ErrMsg("Unable to redirect stdout!\n"); + if( dup2( i_stdout_filedesc, fileno(stderr) ) == -1 ) + intf_ErrMsg("Unable to redirect stderr!\n"); + close( i_stdout_filedesc ); + } + else + { + /* No stdout redirection has been asked so open a console */ + if( p_main->i_warning_level ) + { + ShowConsole(); + } + + } + + return 0; +} + +/***************************************************************************** + * ShowConsole: On Win32, create an output console for debug messages + ***************************************************************************** + * This function is usefull only on Win32. + *****************************************************************************/ +static void ShowConsole( void ) +{ +#ifdef WIN32 /* */ + AllocConsole(); + freopen( "CONOUT$", "w", stdout ); + freopen( "CONOUT$", "w", stderr ); + freopen( "CONIN$", "r", stdin ); +#endif + return; +} + -- GitLab