summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-04-14 11:21:29 +0000
committeralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-04-14 11:21:29 +0000
commit6e62b3a85fc2c7a74dd3242bf123cc5f26adaeb0 (patch)
treef049be7e07ecb9657bce2fb8e6945475583099ec
parentc439e8b46859edc563e3a7177c7b957acaeb7315 (diff)
downloadmpv-6e62b3a85fc2c7a74dd3242bf123cc5f26adaeb0.tar.bz2
mpv-6e62b3a85fc2c7a74dd3242bf123cc5f26adaeb0.tar.xz
Add options to disable some or all config files.
Patch by Andrew Savchenko (Bircoph -at- list -dot- ru). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26448 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--cfg-common-opts.h1
-rw-r--r--cfg-common.h2
-rw-r--r--gui/cfg.c3
-rw-r--r--mencoder.c5
-rw-r--r--mpcommon.c26
-rw-r--r--mpcommon.h3
-rw-r--r--mplayer.c6
7 files changed, 42 insertions, 4 deletions
diff --git a/cfg-common-opts.h b/cfg-common-opts.h
index f59efc94e9..1ebcd99eb5 100644
--- a/cfg-common-opts.h
+++ b/cfg-common-opts.h
@@ -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 --------------------
diff --git a/cfg-common.h b/cfg-common.h
index a5f03582a6..ddac0acdac 100644
--- a/cfg-common.h
+++ b/cfg-common.h
@@ -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[];
diff --git a/gui/cfg.c b/gui/cfg.c
index 821e7e4990..36332904bd 100644
--- a/gui/cfg.c
+++ b/gui/cfg.c
@@ -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 );
diff --git a/mencoder.c b/mencoder.c
index 69760c8642..ae35f3d5e2 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -311,9 +311,11 @@ static void mencoder_exit(int level, const char *how)
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* conf )
mencoder_exit(1,MSGTR_ConfigFileError);
free(conffile);
}
+ }
}
diff --git a/mpcommon.c b/mpcommon.c
index 55e3cef19c..d603623964 100644
--- a/mpcommon.c
+++ b/mpcommon.c
@@ -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 audio_id, char* audio_lang)
}
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}
+};
diff --git a/mpcommon.h b/mpcommon.h
index 0fbb612cdb..bdee63d898 100644
--- a/mpcommon.h
+++ b/mpcommon.h
@@ -12,4 +12,7 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset)
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 */
diff --git a/mplayer.c b/mplayer.c
index e005496ac5..d5ee16ebdc 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -821,7 +821,8 @@ static void parse_cfgfiles( m_config_t* conf )
{
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);
}