summaryrefslogtreecommitdiffstats
path: root/cfgparser.c
diff options
context:
space:
mode:
authoralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-04-17 12:23:52 +0000
committeralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-04-17 12:23:52 +0000
commit152a7563a769b5e1adc098f2972c5cfe2765095a (patch)
treecf4d9026bb64dfc4d58fad8b7820e32b749fdf95 /cfgparser.c
parent3746ce4734abc712a3d628cda4a085364301b786 (diff)
downloadmpv-152a7563a769b5e1adc098f2972c5cfe2765095a.tar.bz2
mpv-152a7563a769b5e1adc098f2972c5cfe2765095a.tar.xz
Add correct loop option parsing in command line parser.
Reset the config while looping inside a file You can now define GLOBAL_OPTIONS_ONLY in your config.h to have only global options (ie no per file option) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5656 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'cfgparser.c')
-rw-r--r--cfgparser.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/cfgparser.c b/cfgparser.c
index 0e34a12bec..36a7b08d2d 100644
--- a/cfgparser.c
+++ b/cfgparser.c
@@ -28,7 +28,11 @@
#define CONFIG_RUNNING (1<<1)
#define SET_GLOBAL(c) (c->flags |= CONFIG_GLOBAL)
+#ifdef GLOBAL_OPTIONS_ONLY
+#define UNSET_GLOBAL(c)
+#else
#define UNSET_GLOBAL(c) (c->flags &= (!CONFIG_GLOBAL))
+#endif
#define IS_GLOBAL(c) (c->flags & CONFIG_GLOBAL)
#define SET_RUNNING(c) (c->flags |= CONFIG_RUNNING)
#define IS_RUNNING(c) (c->flags & CONFIG_RUNNING)
@@ -1052,11 +1056,26 @@ int m_config_parse_command_line(m_config_t *config, int argc, char **argv, char
opt++;
mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "this_opt = option: %s\n", opt);
+ // We handle here some specific option
if(strcasecmp(opt,"list-options") == 0) {
m_config_list_options(config);
exit(1);
- }
- tmp = m_config_set_option(config, opt, argv[i + 1]);
+ // Loop option when it apply to a group
+ } else if(strcasecmp(opt,"loop") == 0 &&
+ (! config->last_entry || config->last_entry->child) ) {
+ int l;
+ char* end;
+ l = strtol(argv[i+1],&end,0);
+ if(!end)
+ tmp = ERR_OUT_OF_RANGE;
+ else {
+ play_tree_t* pt = config->last_entry ? config->last_entry : config->last_parent;
+ l = l <= 0 ? -1 : l;
+ pt->loop = l;
+ tmp = 1;
+ }
+ } else // All normal options
+ tmp = m_config_set_option(config, opt, argv[i + 1]);
switch (tmp) {
case ERR_NOT_AN_OPTION:
@@ -1091,7 +1110,7 @@ int m_config_parse_command_line(m_config_t *config, int argc, char **argv, char
--config->recursion_depth;
if(config->last_parent != config->pt)
mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Missing }- ?\n");
- UNSET_GLOBAL(config);
+ config->flags &= (!CONFIG_GLOBAL);
SET_RUNNING(config);
return 1;
#if 0