0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

options: move -noconfig to option struct, simplify

This commit is contained in:
Uoti Urpala 2011-01-11 17:28:10 +02:00
parent 0b59e33b4e
commit b26fbeddd8
5 changed files with 6 additions and 25 deletions

View File

@ -381,7 +381,8 @@ const m_option_t common_opts[] = {
{"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
#endif
{"codecpath", &codec_path, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"noconfig", (void *) noconfig_opts, CONF_TYPE_SUBCONFIG, CONF_GLOBAL|CONF_NOCFG|CONF_PRE_PARSE, 0, 0, NULL},
OPT_CHOICE("noconfig", noconfig, CONF_GLOBAL | CONF_NOCFG | CONF_PRE_PARSE,
({"off", 0}, {"user", 1}, {"system", 2}, {"all", 3})),
// ------------------------- stream options --------------------

View File

@ -346,22 +346,3 @@ bool attachment_is_font(struct demux_attachment *att)
}
return false;
}
/* Parse -noconfig common to both programs */
int disable_system_conf=0;
int disable_user_conf=0;
/* Disable all configuration files */
static void noconfig_all(void)
{
disable_system_conf = 1;
disable_user_conf = 1;
}
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},
{NULL, NULL, 0, 0, 0, 0, NULL}
};

View File

@ -27,9 +27,6 @@ extern double sub_last_pts;
extern struct ass_track *ass_track;
extern struct subtitle *vo_sub_last;
extern int disable_system_conf;
extern int disable_user_conf;
extern const char *mencoder_version;
extern const char *mplayer_version;

View File

@ -869,9 +869,10 @@ static int cfg_include(m_option_t *conf, char *filename)
static void parse_cfgfiles(struct MPContext *mpctx, m_config_t* conf)
{
struct MPOpts *opts = &mpctx->opts;
char *conffile;
int conffile_fd;
if (!disable_system_conf &&
if (!(opts->noconfig & 2) &&
m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mplayer.conf") < 0)
exit_player(mpctx, EXIT_NONE);
if ((conffile = get_path("")) == NULL) {
@ -891,7 +892,7 @@ if ((conffile = get_path("")) == NULL) {
write(conffile_fd, default_config, strlen(default_config));
close(conffile_fd);
}
if (!disable_user_conf &&
if (!(opts->noconfig & 1) &&
m_config_parse_config_file(conf, conffile) < 0)
exit_player(mpctx, EXIT_NONE);
free(conffile);

View File

@ -39,6 +39,7 @@ typedef struct MPOpts {
int ordered_chapters;
int chapter_merge_threshold;
int quiet;
int noconfig;
float stream_cache_min_percent;
float stream_cache_seek_min_percent;
int chapterrange[2];