changeset 26416:9d53b15aed02

Add options to disable some or all config files. Patch by Andrew Savchenko (Bircoph -at- list -dot- ru).
author albeu
date Mon, 14 Apr 2008 11:21:29 +0000
parents cc7c52fa5eb1
children 04effd44c46a
files cfg-common-opts.h cfg-common.h gui/cfg.c mencoder.c mpcommon.c mpcommon.h mplayer.c
diffstat 7 files changed, 42 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-common-opts.h	Mon Apr 14 11:05:52 2008 +0000
+++ b/cfg-common-opts.h	Mon Apr 14 11:21:29 2008 +0000
@@ -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 --------------------
 
--- a/cfg-common.h	Mon Apr 14 11:05:52 2008 +0000
+++ b/cfg-common.h	Mon Apr 14 11:21:29 2008 +0000
@@ -372,6 +372,8 @@
 };
 #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[];
 
--- a/gui/cfg.c	Mon Apr 14 11:05:52 2008 +0000
+++ b/gui/cfg.c	Mon Apr 14 11:21:29 2008 +0000
@@ -83,6 +83,7 @@
 
 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 @@
  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 );
--- a/mencoder.c	Mon Apr 14 11:05:52 2008 +0000
+++ b/mencoder.c	Mon Apr 14 11:21:29 2008 +0000
@@ -311,9 +311,11 @@
 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 @@
       mencoder_exit(1,MSGTR_ConfigFileError);
     free(conffile);
   }
+  }
 }
 
 
--- a/mpcommon.c	Mon Apr 14 11:05:52 2008 +0000
+++ b/mpcommon.c	Mon Apr 14 11:21:29 2008 +0000
@@ -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 @@
     }
     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}
+};
--- a/mpcommon.h	Mon Apr 14 11:05:52 2008 +0000
+++ b/mpcommon.h	Mon Apr 14 11:21:29 2008 +0000
@@ -12,4 +12,7 @@
 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 */
--- a/mplayer.c	Mon Apr 14 11:05:52 2008 +0000
+++ b/mplayer.c	Mon Apr 14 11:21:29 2008 +0000
@@ -821,7 +821,8 @@
 {
 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 @@
       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);
   }