diff options
Diffstat (limited to 'options/parse_commandline.c')
-rw-r--r-- | options/parse_commandline.c | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/options/parse_commandline.c b/options/parse_commandline.c index 182844ccc9..11ef85a871 100644 --- a/options/parse_commandline.c +++ b/options/parse_commandline.c @@ -25,9 +25,11 @@ #include <assert.h> #include <stdbool.h> +#include "common/global.h" #include "common/msg.h" #include "m_option.h" #include "m_config.h" +#include "options.h" #include "common/playlist.h" #include "common/playlist_parser.h" #include "parse_commandline.h" @@ -104,17 +106,16 @@ static bool split_opt(struct parse_state *p) return r == 0; p->error = true; - mp_msg(MSGT_CFGPARSER, MSGL_FATAL, - "Error parsing commandline option %.*s: %s\n", - BSTR_P(p->arg), m_option_strerror(r)); + MP_FATAL(p->config, "Error parsing commandline option %.*s: %s\n", + BSTR_P(p->arg), m_option_strerror(r)); return false; } // returns M_OPT_... error code int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, + struct mpv_global *global, int argc, char **argv) { - struct MPOpts *opts = config->optstruct; int ret = M_OPT_UNKNOWN; int mode = 0; struct playlist_entry *local_start = NULL; @@ -138,9 +139,8 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, goto err_out; } if (r < 0) { - mp_msg(MSGT_CFGPARSER, MSGL_FATAL, - "Setting commandline option --%.*s=%.*s failed.\n", - BSTR_P(p.arg), BSTR_P(p.param)); + MP_FATAL(config, "Setting commandline option --%.*s=%.*s failed.\n", + BSTR_P(p.arg), BSTR_P(p.param)); goto err_out; } @@ -148,8 +148,7 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, if (!bstrcmp0(p.arg, "{")) { if (mode != GLOBAL) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, - "'--{' can not be nested.\n"); + MP_ERR(config, "'--{' can not be nested.\n"); goto err_out; } mode = LOCAL; @@ -160,8 +159,7 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, if (!bstrcmp0(p.arg, "}")) { if (mode != LOCAL) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, - "Too many closing '--}'.\n"); + MP_ERR(config, "Too many closing '--}'.\n"); goto err_out; } if (local_params_count) { @@ -172,7 +170,7 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, struct playlist_entry *cur = local_start ? local_start->next : files->first; if (!cur) - mp_msg(MSGT_CFGPARSER, MSGL_WARN, "Ignored options!\n"); + MP_WARN(config, "Ignored options!\n"); while (cur) { playlist_entry_add_params(cur, local_params, local_params_count); @@ -189,11 +187,10 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, if (bstrcmp0(p.arg, "playlist") == 0) { // append the playlist to the local args char *param0 = bstrdup0(NULL, p.param); - struct playlist *pl = playlist_parse_file(param0, opts); + struct playlist *pl = playlist_parse_file(param0, global); talloc_free(param0); if (!pl) { - mp_msg(MSGT_CFGPARSER, MSGL_FATAL, - "Error reading playlist '%.*s'", BSTR_P(p.param)); + MP_FATAL(config, "Error reading playlist '%.*s'", BSTR_P(p.param)); goto err_out; } playlist_transfer_entries(files, pl); @@ -233,8 +230,7 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, playlist_add_file(files, f); } } else - mp_msg(MSGT_CFGPARSER, MSGL_ERR, - "Invalid play entry %s\n", file0); + MP_ERR(config, "Invalid play entry %s\n", file0); } else // dvd:// or dvd://x entry playlist_add_file(files, file0); @@ -252,8 +248,7 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, goto err_out; if (mode != GLOBAL) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, - "Missing closing --} on command line.\n"); + MP_ERR(config, "Missing closing --} on command line.\n"); goto err_out; } @@ -265,18 +260,18 @@ err_out: return ret; } -extern int mp_msg_levels[]; - /* Parse some command line options early before main parsing. * --no-config prevents reading configuration files (otherwise done before * command line parsing), and --really-quiet suppresses messages printed * during normal options parsing. */ -void m_config_preparse_command_line(m_config_t *config, int argc, char **argv) +void m_config_preparse_command_line(m_config_t *config, struct mpv_global *global, + int argc, char **argv) { + struct MPOpts *opts = global->opts; + // Hack to shut up parser error messages - int msg_lvl_backup = mp_msg_levels[MSGT_CFGPARSER]; - mp_msg_levels[MSGT_CFGPARSER] = -11; + mp_msg_mute(global, true); struct parse_state p = {config, argc, argv}; while (split_opt_silent(&p) == 0) { @@ -286,9 +281,9 @@ void m_config_preparse_command_line(m_config_t *config, int argc, char **argv) int flags = M_SETOPT_FROM_CMDLINE | M_SETOPT_PRE_PARSE_ONLY; m_config_set_option_ext(config, p.arg, p.param, flags); if (bstrcmp0(p.arg, "v") == 0) - verbose++; + opts->verbose++; } } - mp_msg_levels[MSGT_CFGPARSER] = msg_lvl_backup; + mp_msg_mute(global, false); } |