[MPlayer-cvslog] r26448 - in trunk: cfg-common-opts.h cfg-common.h gui/cfg.c mencoder.c mpcommon.c mpcommon.h mplayer.c

albeu subversion at mplayerhq.hu
Mon Apr 14 13:21:29 CEST 2008


Author: albeu
Date: Mon Apr 14 13:21:29 2008
New Revision: 26448

Log:
Add options to disable some or all config files.
Patch by Andrew Savchenko (Bircoph -at- list -dot- ru).


Modified:
   trunk/cfg-common-opts.h
   trunk/cfg-common.h
   trunk/gui/cfg.c
   trunk/mencoder.c
   trunk/mpcommon.c
   trunk/mpcommon.h
   trunk/mplayer.c

Modified: trunk/cfg-common-opts.h
==============================================================================
--- trunk/cfg-common-opts.h	(original)
+++ trunk/cfg-common-opts.h	Mon Apr 14 13:21:29 2008
@@ -18,6 +18,7 @@
 #ifdef WIN32
 	{"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
 #endif
+	{"noconfig", noconfig_opts, CONF_TYPE_SUBCONFIG, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 0, NULL},
 
 // ------------------------- stream options --------------------
 

Modified: trunk/cfg-common.h
==============================================================================
--- trunk/cfg-common.h	(original)
+++ trunk/cfg-common.h	Mon Apr 14 13:21:29 2008
@@ -372,6 +372,8 @@ struct {
 };
 #endif /* WIN32 */
 
+extern const m_option_t noconfig_opts[];
+
 extern const m_option_t lavc_decode_opts_conf[];
 extern const m_option_t xvid_dec_opts[];
 

Modified: trunk/gui/cfg.c
==============================================================================
--- trunk/gui/cfg.c	(original)
+++ trunk/gui/cfg.c	Mon Apr 14 13:21:29 2008
@@ -83,6 +83,7 @@ gtkASS_t gtkASS;
 
 extern int    stop_xscreensaver;
 extern int    m_config_parse_config_file(m_config_t* config, char *conffile);
+int disable_gui_conf=0;
 
 static m_config_t * gui_conf;
 static const m_option_t gui_opts[] =
@@ -222,7 +223,7 @@ int cfg_read( void )
  mp_msg( MSGT_GPLAYER,MSGL_V,"[cfg] reading config file: %s\n",cfg );
  gui_conf=m_config_new();
  m_config_register_options( gui_conf,gui_opts );
- if ( m_config_parse_config_file( gui_conf,cfg ) < 0 ) 
+ if ( !disable_gui_conf && m_config_parse_config_file( gui_conf,cfg ) < 0 ) 
   {
    mp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_ConfigFileError );
 //   exit( 1 );

Modified: trunk/mencoder.c
==============================================================================
--- trunk/mencoder.c	(original)
+++ trunk/mencoder.c	Mon Apr 14 13:21:29 2008
@@ -311,9 +311,11 @@ static void mencoder_exit(int level, con
 static void parse_cfgfiles( m_config_t* conf )
 {
   char *conffile;
-  if (m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mencoder.conf") < 0)
+  if (!disable_system_conf &&
+      m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mencoder.conf") < 0)
     mencoder_exit(1,MSGTR_ConfigFileError); 
 
+  if (!disable_user_conf) {
   if ((conffile = get_path("mencoder.conf")) == NULL) {
     mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_GetpathProblem);
   } else {
@@ -321,6 +323,7 @@ static void parse_cfgfiles( m_config_t* 
       mencoder_exit(1,MSGTR_ConfigFileError);
     free(conffile);
   }
+  }
 }
 
 

Modified: trunk/mpcommon.c
==============================================================================
--- trunk/mpcommon.c	(original)
+++ trunk/mpcommon.c	Mon Apr 14 13:21:29 2008
@@ -11,6 +11,7 @@
 #include "stream/tv.h"
 #endif
 #include "libavutil/intreadwrite.h"
+#include "m_option.h"
 
 double sub_last_pts = -303;
 
@@ -205,3 +206,28 @@ int select_audio(demuxer_t* demuxer, int
     }
     return demuxer->audio->id;
 }
+
+/* Parse -noconfig common to both programs */
+int disable_system_conf=0;
+int disable_user_conf=0;
+extern int disable_gui_conf;
+
+/* Disable all configuration files */
+static void noconfig_all(void)
+{
+    disable_system_conf = 1;
+    disable_user_conf = 1;
+#ifdef HAVE_NEW_GUI
+    disable_gui_conf = 1;
+#endif /* HAVE_NEW_GUI */
+}
+
+const m_option_t noconfig_opts[] = {
+    {"all", noconfig_all, CONF_TYPE_FUNC, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 0, NULL},
+    {"system", &disable_system_conf, CONF_TYPE_FLAG, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 1, NULL},
+    {"user", &disable_user_conf, CONF_TYPE_FLAG, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 1, NULL},
+#ifdef HAVE_NEW_GUI
+    {"gui", &disable_gui_conf, CONF_TYPE_FLAG, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 1, NULL},
+#endif /* HAVE_NEW_GUI */
+    {NULL, NULL, 0, 0, 0, 0, NULL}
+};

Modified: trunk/mpcommon.h
==============================================================================
--- trunk/mpcommon.h	(original)
+++ trunk/mpcommon.h	Mon Apr 14 13:21:29 2008
@@ -12,4 +12,7 @@ void update_subtitles(sh_video_t *sh_vid
 void update_teletext(sh_video_t *sh_video, demuxer_t *demuxer, int reset);
 int select_audio(demuxer_t* demuxer, int audio_id, char* audio_lang);
 
+extern int disable_system_conf;
+extern int disable_user_conf;
+
 #endif /* MPLAYER_MPCOMMON_H */

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	(original)
+++ trunk/mplayer.c	Mon Apr 14 13:21:29 2008
@@ -821,7 +821,8 @@ static void parse_cfgfiles( m_config_t* 
 {
 char *conffile;
 int conffile_fd;
-if (m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mplayer.conf") < 0)
+if (!disable_system_conf &&
+    m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mplayer.conf") < 0)
   exit_player(NULL);
 if ((conffile = get_path("")) == NULL) {
   mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoHomeDir);
@@ -840,7 +841,8 @@ if ((conffile = get_path("")) == NULL) {
       write(conffile_fd, default_config, strlen(default_config));
       close(conffile_fd);
     }
-    if (m_config_parse_config_file(conf, conffile) < 0)
+    if (!disable_user_conf &&
+        m_config_parse_config_file(conf, conffile) < 0)
       exit_player(NULL);
     free(conffile);
   }



More information about the MPlayer-cvslog mailing list