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
This commit is contained in:
albeu 2008-04-14 11:21:29 +00:00
parent c439e8b468
commit 6e62b3a85f
7 changed files with 42 additions and 4 deletions

View File

@ -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 --------------------

View File

@ -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[];

View File

@ -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 );

View File

@ -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);
}
}
}

View File

@ -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}
};

View File

@ -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 */

View File

@ -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);
}