Mercurial > mplayer.hg
annotate cfgparser.c @ 6420:370b50a47a18
Darwin/Mac OS X dvd support. Patch from Joey Parrish <joey@yunamusic.com>
author | atmos4 |
---|---|
date | Thu, 13 Jun 2002 22:39:59 +0000 |
parents | 42127864a2b3 |
children | 79187bd813a6 |
rev | line source |
---|---|
147 | 1 /* |
2 * command line and config file parser | |
336 | 3 * by Szabolcs Berecz <szabi@inf.elte.hu> |
4 * (C) 2001 | |
2619 | 5 * |
6 * subconfig support by alex | |
147 | 7 */ |
8 | |
9 //#define DEBUG | |
10 | |
11 #include <stdlib.h> | |
12 #include <stdio.h> | |
13 #include <ctype.h> | |
14 #include <unistd.h> | |
15 #include <fcntl.h> | |
16 #include <string.h> | |
336 | 17 #include <errno.h> |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
18 #include "config.h" |
147 | 19 |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
20 #include "mp_msg.h" |
147 | 21 |
22 #define COMMAND_LINE 0 | |
23 #define CONFIG_FILE 1 | |
24 | |
5215 | 25 #define LIST_SEPARATOR ',' |
26 | |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
27 #define CONFIG_GLOBAL (1<<0) |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
28 #define CONFIG_RUNNING (1<<1) |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
29 |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
30 #define SET_GLOBAL(c) (c->flags |= CONFIG_GLOBAL) |
5655
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
31 #ifdef GLOBAL_OPTIONS_ONLY |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
32 #define UNSET_GLOBAL(c) |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
33 #else |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
34 #define UNSET_GLOBAL(c) (c->flags &= (!CONFIG_GLOBAL)) |
5655
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
35 #endif |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
36 #define IS_GLOBAL(c) (c->flags & CONFIG_GLOBAL) |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
37 #define SET_RUNNING(c) (c->flags |= CONFIG_RUNNING) |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
38 #define IS_RUNNING(c) (c->flags & CONFIG_RUNNING) |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
39 |
177 | 40 #define MAX_RECURSION_DEPTH 8 |
166 | 41 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
42 #ifdef MP_DEBUG |
147 | 43 #include <assert.h> |
44 #endif | |
45 | |
46 #include "cfgparser.h" | |
47 | |
5215 | 48 static void m_config_list_options(m_config_t *config); |
49 static void m_config_error(int err,char* opt,char* val); | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
50 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
51 static void |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
52 m_config_save_option(m_config_t* config, config_t* conf,char* opt, char *param) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
53 config_save_t* save; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
54 int sl=0; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
55 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
56 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
57 assert(config != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
58 assert(config->cs_level >= 0); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
59 assert(conf != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
60 assert(opt != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
61 assert( ! (conf->flags & CONF_NOSAVE)); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
62 #endif |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
63 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
64 switch(conf->type) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
65 case CONF_TYPE_PRINT : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
66 case CONF_TYPE_SUBCONFIG : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
67 return; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
68 default : |
4384 | 69 ; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
70 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
71 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
72 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Saving option %s\n",opt); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
73 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
74 save = config->config_stack[config->cs_level]; |
147 | 75 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
76 if(save) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
77 for(sl = 0; save[sl].opt != NULL; sl++){ |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
78 // Check to not save the same arg two times |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
79 if(save[sl].opt == conf && (save[sl].opt_name == NULL || strcasecmp(save[sl].opt_name,opt) == 0)) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
80 break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
81 } |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
82 if(save[sl].opt) |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
83 return; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
84 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
85 |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
86 save = (config_save_t*)realloc(save,(sl+2)*sizeof(config_save_t)); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
87 if(save == NULL) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
88 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Can't allocate %d bytes of memory : %s\n",(sl+2)*sizeof(config_save_t),strerror(errno)); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
89 return; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
90 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
91 memset(&save[sl],0,2*sizeof(config_save_t)); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
92 save[sl].opt = conf; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
93 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
94 switch(conf->type) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
95 case CONF_TYPE_FLAG : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
96 case CONF_TYPE_INT : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
97 save[sl].param.as_int = *((int*)conf->p); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
98 break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
99 case CONF_TYPE_FLOAT : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
100 save[sl].param.as_float = *((float*)conf->p); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
101 break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
102 case CONF_TYPE_STRING : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
103 save[sl].param.as_pointer = *((char**)conf->p); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
104 break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
105 case CONF_TYPE_FUNC_FULL : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
106 if(strcasecmp(conf->name,opt) != 0) save->opt_name = strdup(opt); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
107 case CONF_TYPE_FUNC_PARAM : |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
108 if(param) |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
109 save->param.as_pointer = strdup(param); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
110 case CONF_TYPE_FUNC : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
111 break; |
5215 | 112 case CONF_TYPE_STRING_LIST : |
113 save[sl].param.as_pointer = *((char***)conf->p); | |
114 break; | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
115 default : |
5115 | 116 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Should never append in m_config_save_option : conf->type=%d\n",conf->type); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
117 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
118 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
119 config->config_stack[config->cs_level] = save; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
120 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
121 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
122 static int |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
123 m_config_revert_option(m_config_t* config, config_save_t* save) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
124 char* arg = NULL; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
125 config_save_t* iter=NULL; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
126 int i=-1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
127 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
128 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
129 assert(config != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
130 assert(config->cs_level >= 0); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
131 assert(save != NULL); |
147 | 132 #endif |
133 | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
134 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
135 arg = save->opt_name ? save->opt_name : save->opt->name; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
136 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Reverting option %s\n",arg); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
137 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
138 if(save->opt->default_func) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
139 save->opt->default_func(save->opt,arg); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
140 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
141 switch(save->opt->type) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
142 case CONF_TYPE_FLAG : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
143 case CONF_TYPE_INT : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
144 *((int*)save->opt->p) = save->param.as_int; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
145 break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
146 case CONF_TYPE_FLOAT : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
147 *((float*)save->opt->p) = save->param.as_float; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
148 break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
149 case CONF_TYPE_STRING : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
150 *((char**)save->opt->p) = save->param.as_pointer; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
151 break; |
5215 | 152 case CONF_TYPE_STRING_LIST : |
153 *((char***)save->opt->p) = save->param.as_pointer; | |
154 break; | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
155 case CONF_TYPE_FUNC_PARAM : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
156 case CONF_TYPE_FUNC_FULL : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
157 case CONF_TYPE_FUNC : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
158 if(config->cs_level > 0) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
159 for(i = config->cs_level - 1 ; i >= 0 ; i--){ |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
160 if(config->config_stack[i] == NULL) continue; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
161 for(iter = config->config_stack[i]; iter != NULL && iter->opt != NULL ; iter++) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
162 if(iter->opt == save->opt && |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
163 ((save->param.as_pointer == NULL || iter->param.as_pointer == NULL) || strcasecmp(save->param.as_pointer,iter->param.as_pointer) == 0) && |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
164 (save->opt_name == NULL || |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
165 (iter->opt_name && strcasecmp(save->opt_name,iter->opt_name)))) break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
166 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
167 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
168 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
169 free(save->param.as_pointer); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
170 if(save->opt_name) free(save->opt_name); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
171 save->opt_name = save->param.as_pointer = NULL; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
172 if(i < 0) break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
173 arg = iter->opt_name ? iter->opt_name : iter->opt->name; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
174 switch(iter->opt->type) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
175 case CONF_TYPE_FUNC : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
176 if ((((cfg_func_t) iter->opt->p)(iter->opt)) < 0) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
177 return -1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
178 break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
179 case CONF_TYPE_FUNC_PARAM : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
180 if (iter->param.as_pointer == NULL) { |
5115 | 181 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"We lost param for option %s?\n",iter->opt->name); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
182 return -1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
183 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
184 if ((((cfg_func_param_t) iter->opt->p)(iter->opt, (char*)iter->param.as_pointer)) < 0) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
185 return -1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
186 break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
187 case CONF_TYPE_FUNC_FULL : |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
188 if (iter->param.as_pointer != NULL && ((char*)iter->param.as_pointer)[0]=='-'){ |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
189 if( ((cfg_func_arg_param_t) iter->opt->p)(iter->opt, arg, NULL) < 0) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
190 return -1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
191 }else { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
192 if (((cfg_func_arg_param_t) save->opt->p)(iter->opt, arg, (char*)iter->param.as_pointer) < 0) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
193 return -1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
194 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
195 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
196 break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
197 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
198 break; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
199 default : |
5115 | 200 mp_msg(MSGT_CFGPARSER,MSGL_WARN,"Why do we reverse this : name=%s type=%d ?\n",save->opt->name,save->opt->type); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
201 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
202 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
203 return 1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
204 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
205 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
206 void |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
207 m_config_push(m_config_t* config) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
208 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
209 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
210 assert(config != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
211 assert(config->cs_level >= 0); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
212 #endif |
147 | 213 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
214 config->cs_level++; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
215 config->config_stack = (config_save_t**)realloc(config->config_stack ,sizeof(config_save_t*)*(config->cs_level+1)); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
216 if(config->config_stack == NULL) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
217 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Can't allocate %d bytes of memory : %s\n",sizeof(config_save_t*)*(config->cs_level+1),strerror(errno)); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
218 config->cs_level = -1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
219 return; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
220 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
221 config->config_stack[config->cs_level] = NULL; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
222 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Config pushed level=%d\n",config->cs_level); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
223 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
224 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
225 int |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
226 m_config_pop(m_config_t* config) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
227 int i,ret= 1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
228 config_save_t* cs; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
229 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
230 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
231 assert(config != NULL); |
4771 | 232 //assert(config->cs_level > 0); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
233 #endif |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
234 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
235 if(config->config_stack[config->cs_level] != NULL) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
236 cs = config->config_stack[config->cs_level]; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
237 for(i=0; cs[i].opt != NULL ; i++ ) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
238 if (m_config_revert_option(config,&cs[i]) < 0) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
239 ret = -1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
240 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
241 free(config->config_stack[config->cs_level]); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
242 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
243 config->config_stack = (config_save_t**)realloc(config->config_stack ,sizeof(config_save_t*)*config->cs_level); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
244 config->cs_level--; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
245 if(config->cs_level > 0 && config->config_stack == NULL) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
246 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Can't allocate %d bytes of memory : %s\n",sizeof(config_save_t*)*config->cs_level,strerror(errno)); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
247 config->cs_level = -1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
248 return -1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
249 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
250 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Config poped level=%d\n",config->cs_level); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
251 return ret; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
252 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
253 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
254 m_config_t* |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
255 m_config_new(play_tree_t* pt) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
256 m_config_t* config; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
257 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
258 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
259 assert(pt != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
260 #endif |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
261 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
262 config = (m_config_t*)calloc(1,sizeof(m_config_t)); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
263 if(config == NULL) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
264 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Can't allocate %d bytes of memory : %s\n",sizeof(m_config_t),strerror(errno)); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
265 return NULL; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
266 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
267 config->config_stack = (config_save_t**)calloc(1,sizeof(config_save_t*)); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
268 if(config->config_stack == NULL) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
269 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Can't allocate %d bytes of memory : %s\n",sizeof(config_save_t*),strerror(errno)); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
270 free(config); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
271 return NULL; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
272 } |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
273 SET_GLOBAL(config); // We always start with global options |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
274 config->pt = pt; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
275 return config; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
276 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
277 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
278 void |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
279 m_config_free(m_config_t* config) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
280 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
281 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
282 assert(config != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
283 #endif |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
284 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
285 free(config->opt_list); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
286 free(config->config_stack); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
287 free(config); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
288 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
289 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
290 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
291 static int init_conf(m_config_t *config, int mode) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
292 { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
293 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
294 assert(config != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
295 assert(config->pt != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
296 assert(config->last_entry == NULL || config->last_entry->parent == config->pt); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
297 |
147 | 298 if (mode != COMMAND_LINE && mode != CONFIG_FILE) { |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
299 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "init_conf: wrong mode!\n"); |
147 | 300 return -1; |
301 } | |
302 #endif | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
303 config->parser_mode = mode; |
147 | 304 return 1; |
305 } | |
306 | |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
307 static int config_is_entry_option(m_config_t *config, char *opt, char *param) { |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
308 play_tree_t* entry = NULL; |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
309 |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
310 #ifdef MP_DEBUG |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
311 assert(config->pt != NULL); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
312 #endif |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
313 |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
314 if(strcasecmp(opt,"playlist") == 0) { // We handle playlist here |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
315 if(!param) |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
316 return ERR_MISSING_PARAM; |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
317 entry = parse_playlist_file(param); |
4890
0c1526391dd3
New option use-stdin to use when stdin will be used as a file
albeu
parents:
4771
diff
changeset
|
318 if(!entry) { |
0c1526391dd3
New option use-stdin to use when stdin will be used as a file
albeu
parents:
4771
diff
changeset
|
319 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Playlist parsing failed: %s\n",param); |
0c1526391dd3
New option use-stdin to use when stdin will be used as a file
albeu
parents:
4771
diff
changeset
|
320 return 1; |
0c1526391dd3
New option use-stdin to use when stdin will be used as a file
albeu
parents:
4771
diff
changeset
|
321 } |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
322 } |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
323 |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
324 if(! IS_RUNNING(config)) { |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
325 if(strcasecmp(opt,"vcd") == 0) { |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
326 char* s; |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
327 if(!param) |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
328 return ERR_MISSING_PARAM; |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
329 s = (char*)malloc((strlen(param) + 6 + 1)*sizeof(char)); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
330 sprintf(s,"vcd://%s",param); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
331 entry = play_tree_new(); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
332 play_tree_add_file(entry,s); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
333 free(s); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
334 } else if(strcasecmp(opt,"dvd") == 0) { |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
335 char* s; |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
336 if(!param) |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
337 return ERR_MISSING_PARAM; |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
338 s = (char*)malloc((strlen(param) + 6 + 1)*sizeof(char)); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
339 sprintf(s,"dvd://%s",param); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
340 entry = play_tree_new(); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
341 play_tree_add_file(entry,s); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
342 free(s); |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
343 } else if(strcasecmp(opt,"tv") == 0) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
344 char *s,*pr,*prs; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
345 char *ps,*pe,*channel=NULL; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
346 char *as; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
347 int on=0; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
348 if(!param) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
349 return ERR_MISSING_PARAM; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
350 ps = param; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
351 pe = strchr(param,':'); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
352 pr = prs = (char*)malloc((strlen(param)+1)*sizeof(char)); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
353 pr[0] = '\0'; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
354 while(ps) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
355 if(!pe) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
356 pe = ps + strlen(ps); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
357 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
358 as = strchr(ps,'='); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
359 if(as && as[1] != '\0' && pe-as > 0) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
360 as++; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
361 else |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
362 as = NULL; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
363 if( !as && pe-ps == 2 && strncasecmp("on",ps,2) == 0 ) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
364 on = 1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
365 else if(as && as-ps == 8 && strncasecmp("channel",ps,6) == 0 && pe-as > 0) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
366 channel = (char*)realloc(channel,(pe-as+1)*sizeof(char)); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
367 strncpy(channel,as,pe-as); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
368 channel[pe-as] = '\0'; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
369 } else if(pe-ps > 0) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
370 if(prs != pr) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
371 prs[0] = ':'; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
372 prs++; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
373 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
374 strncpy(prs,ps,pe-ps); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
375 prs += pe-ps; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
376 prs[0] = '\0'; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
377 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
378 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
379 if(pe[0] != '\0') { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
380 ps = pe+1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
381 pe = strchr(ps,':'); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
382 } else |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
383 ps = NULL; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
384 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
385 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
386 if(on) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
387 int l=5; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
388 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
389 if(channel) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
390 l += strlen(channel); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
391 s = (char*) malloc((l+1)*sizeof(char)); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
392 if(channel) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
393 sprintf(s,"tv://%s",channel); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
394 else |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
395 sprintf(s,"tv://"); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
396 entry = play_tree_new(); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
397 play_tree_add_file(entry,s); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
398 if(strlen(pr) > 0) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
399 play_tree_set_param(entry,"tv",pr); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
400 free(s); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
401 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
402 free(pr); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
403 if(channel) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
404 free(channel); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
405 |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
406 } |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
407 } |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
408 |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
409 if(entry) { |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
410 if(config->last_entry) |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
411 play_tree_append_entry(config->last_entry,entry); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
412 else |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
413 play_tree_set_child(config->pt,entry); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
414 config->last_entry = entry; |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
415 if(config->parser_mode == COMMAND_LINE) |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
416 UNSET_GLOBAL(config); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
417 return 1; |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
418 } else |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
419 return 0; |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
420 } |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
421 |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
422 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
423 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
424 static int config_read_option(m_config_t *config,config_t** conf_list, char *opt, char *param) |
147 | 425 { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
426 int i=0,nconf = 0; |
195 | 427 long tmp_int; |
428 double tmp_float; | |
160 | 429 int ret = -1; |
195 | 430 char *endptr; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
431 config_t* conf=NULL; |
147 | 432 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
433 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
434 assert(config != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
435 assert(conf_list != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
436 assert(opt != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
437 #endif |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
438 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
439 mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "read_option: conf=%p opt='%s' param='%s'\n", |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
440 conf, opt, param); |
4220
fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
albeu
parents:
4156
diff
changeset
|
441 for(nconf = 0 ; conf_list[nconf] != NULL; nconf++) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
442 conf = conf_list[nconf]; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
443 for (i = 0; conf[i].name != NULL; i++) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
444 int namelength; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
445 /* allow 'aa*' in config.name */ |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
446 namelength=strlen(conf[i].name); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
447 if ( (conf[i].name[namelength-1]=='*') && |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
448 !memcmp(opt, conf[i].name, namelength-1)) |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
449 goto option_found; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
450 if (!strcasecmp(opt, conf[i].name)) |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
451 goto option_found; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
452 } |
147 | 453 } |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
454 if (config->parser_mode == CONFIG_FILE) |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
455 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "invalid option: %s\n",opt); |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
456 ret = ERR_NOT_AN_OPTION; |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
457 goto out; |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
458 option_found : |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
459 mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "read_option: name='%s' p=%p type=%d\n", |
2621 | 460 conf[i].name, conf[i].p, conf[i].type); |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
461 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
462 if (conf[i].flags & CONF_NOCFG && config->parser_mode == CONFIG_FILE) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
463 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "this option can only be used on command line:\n", opt); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
464 ret = ERR_NOT_AN_OPTION; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
465 goto out; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
466 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
467 if (conf[i].flags & CONF_NOCMD && config->parser_mode == COMMAND_LINE) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
468 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "this option can only be used in config file:\n", opt); |
160 | 469 ret = ERR_NOT_AN_OPTION; |
470 goto out; | |
471 } | |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
472 ret = config_is_entry_option(config,opt,param); |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
473 if(ret != 0) |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
474 return ret; |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
475 else |
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
476 ret = -1; |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
477 if(! IS_RUNNING(config) && ! IS_GLOBAL(config) && |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
478 ! (conf[i].flags & CONF_GLOBAL) && conf[i].type != CONF_TYPE_SUBCONFIG ) |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
479 m_config_push(config); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
480 if( !(conf[i].flags & CONF_NOSAVE) && ! (conf[i].flags & CONF_GLOBAL) ) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
481 m_config_save_option(config,&conf[i],opt,param); |
2619 | 482 switch (conf[i].type) { |
147 | 483 case CONF_TYPE_FLAG: |
484 /* flags need a parameter in config file */ | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
485 if (config->parser_mode == CONFIG_FILE) { |
147 | 486 if (!strcasecmp(param, "yes") || /* any other language? */ |
487 !strcasecmp(param, "ja") || | |
161
9008302e2dc0
Added support for spanish (Yes, I'm a C programer also ;o)
telenieko
parents:
160
diff
changeset
|
488 !strcasecmp(param, "si") || |
147 | 489 !strcasecmp(param, "igen") || |
490 !strcasecmp(param, "y") || | |
1536
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
1304
diff
changeset
|
491 !strcasecmp(param, "j") || |
147 | 492 !strcasecmp(param, "i") || |
493 !strcmp(param, "1")) | |
2619 | 494 *((int *) conf[i].p) = conf[i].max; |
151 | 495 else if (!strcasecmp(param, "no") || |
147 | 496 !strcasecmp(param, "nein") || |
497 !strcasecmp(param, "nicht") || | |
498 !strcasecmp(param, "nem") || | |
499 !strcasecmp(param, "n") || | |
500 !strcmp(param, "0")) | |
2619 | 501 *((int *) conf[i].p) = conf[i].min; |
160 | 502 else { |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
503 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "invalid parameter for flag: %s\n", param); |
160 | 504 ret = ERR_OUT_OF_RANGE; |
505 goto out; | |
506 } | |
507 ret = 1; | |
147 | 508 } else { /* parser_mode == COMMAND_LINE */ |
2619 | 509 *((int *) conf[i].p) = conf[i].max; |
160 | 510 ret = 0; |
147 | 511 } |
512 break; | |
513 case CONF_TYPE_INT: | |
514 if (param == NULL) | |
160 | 515 goto err_missing_param; |
195 | 516 |
517 tmp_int = strtol(param, &endptr, 0); | |
518 if (*endptr) { | |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
519 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be an integer: %s\n", param); |
160 | 520 ret = ERR_OUT_OF_RANGE; |
521 goto out; | |
522 } | |
147 | 523 |
2619 | 524 if (conf[i].flags & CONF_MIN) |
525 if (tmp_int < conf[i].min) { | |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
526 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be >= %d: %s\n", (int) conf[i].min, param); |
160 | 527 ret = ERR_OUT_OF_RANGE; |
528 goto out; | |
529 } | |
147 | 530 |
2619 | 531 if (conf[i].flags & CONF_MAX) |
532 if (tmp_int > conf[i].max) { | |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
533 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be <= %d: %s\n", (int) conf[i].max, param); |
160 | 534 ret = ERR_OUT_OF_RANGE; |
535 goto out; | |
536 } | |
147 | 537 |
2619 | 538 *((int *) conf[i].p) = tmp_int; |
160 | 539 ret = 1; |
147 | 540 break; |
541 case CONF_TYPE_FLOAT: | |
542 if (param == NULL) | |
160 | 543 goto err_missing_param; |
195 | 544 |
545 tmp_float = strtod(param, &endptr); | |
2031
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1629
diff
changeset
|
546 |
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1629
diff
changeset
|
547 if ((*endptr == ':') || (*endptr == '/')) |
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1629
diff
changeset
|
548 tmp_float /= strtod(endptr+1, &endptr); |
624df8ea0e0e
New aspect prescale code, parses aspect value from mpeg sequence header or commandline.
atmos4
parents:
1629
diff
changeset
|
549 |
195 | 550 if (*endptr) { |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
551 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be a floating point number" |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
552 " or a ratio (numerator[:/]denominator): %s\n", param); |
160 | 553 ret = ERR_MISSING_PARAM; |
554 goto out; | |
555 } | |
147 | 556 |
2619 | 557 if (conf[i].flags & CONF_MIN) |
558 if (tmp_float < conf[i].min) { | |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
559 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be >= %f: %s\n", conf[i].min, param); |
160 | 560 ret = ERR_OUT_OF_RANGE; |
561 goto out; | |
562 } | |
147 | 563 |
2619 | 564 if (conf[i].flags & CONF_MAX) |
565 if (tmp_float > conf[i].max) { | |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
566 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be <= %f: %s\n", conf[i].max, param); |
160 | 567 ret = ERR_OUT_OF_RANGE; |
568 goto out; | |
569 } | |
147 | 570 |
2619 | 571 *((float *) conf[i].p) = tmp_float; |
160 | 572 ret = 1; |
147 | 573 break; |
574 case CONF_TYPE_STRING: | |
575 if (param == NULL) | |
160 | 576 goto err_missing_param; |
147 | 577 |
2619 | 578 if (conf[i].flags & CONF_MIN) |
579 if (strlen(param) < conf[i].min) { | |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
580 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be >= %d chars: %s\n", |
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
581 (int) conf[i].min, param); |
160 | 582 ret = ERR_OUT_OF_RANGE; |
583 goto out; | |
584 } | |
147 | 585 |
2619 | 586 if (conf[i].flags & CONF_MAX) |
587 if (strlen(param) > conf[i].max) { | |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
588 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be <= %d chars: %s\n", |
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
589 (int) conf[i].max, param); |
160 | 590 ret = ERR_OUT_OF_RANGE; |
591 goto out; | |
592 } | |
2619 | 593 *((char **) conf[i].p) = strdup(param); |
160 | 594 ret = 1; |
147 | 595 break; |
5215 | 596 case CONF_TYPE_STRING_LIST: |
597 if (param == NULL) | |
598 goto err_missing_param; | |
599 else { | |
600 int n = 0,len; | |
601 char *ptr = param, *last_ptr, **res; | |
602 | |
603 while(ptr[0] != '\0') { | |
604 last_ptr = ptr; | |
605 ptr = strchr(ptr,LIST_SEPARATOR); | |
606 if(!ptr) { | |
607 if(strlen(last_ptr) > 0) | |
608 n++; | |
609 break; | |
610 } | |
611 ptr++; | |
612 n++; | |
613 } | |
614 if(n == 0) | |
615 goto err_missing_param; | |
616 else if( (conf[i].flags & CONF_MIN && n < conf[i].min) || | |
617 (conf[i].flags & CONF_MAX && n > conf[i].max) ) { | |
618 ret = ERR_OUT_OF_RANGE; | |
619 goto out; | |
620 } | |
621 ret = 1; | |
622 res = malloc((n+1)*sizeof(char*)); | |
623 ptr = param; | |
624 n = 0; | |
625 while(ptr[0] != '\0') { | |
626 last_ptr = ptr; | |
627 ptr = strchr(ptr,LIST_SEPARATOR); | |
628 if(!ptr) { | |
629 if(strlen(last_ptr) > 0) { | |
630 res[n] = strdup(last_ptr); | |
631 n++; | |
632 } | |
633 break; | |
634 } | |
635 len = ptr - last_ptr; | |
636 res[n] = (char*)malloc(len + 1); | |
637 strncpy(res[n],last_ptr,len); | |
638 res[n][len] = '\0'; | |
639 ptr++; | |
640 n++; | |
641 } | |
642 res[n] = NULL; | |
643 *((char ***) conf[i].p) = res; | |
644 } | |
645 break; | |
151 | 646 case CONF_TYPE_FUNC_PARAM: |
647 if (param == NULL) | |
160 | 648 goto err_missing_param; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
649 if ((((cfg_func_param_t) conf[i].p)(conf + i, param)) < 0) { |
160 | 650 ret = ERR_FUNC_ERR; |
651 goto out; | |
652 } | |
653 ret = 1; | |
151 | 654 break; |
1536
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
1304
diff
changeset
|
655 case CONF_TYPE_FUNC_FULL: |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
1304
diff
changeset
|
656 if (param!=NULL && param[0]=='-'){ |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
657 ret=((cfg_func_arg_param_t) conf[i].p)(conf + i, opt, NULL); |
1536
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
1304
diff
changeset
|
658 if (ret>=0) ret=0; |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
1304
diff
changeset
|
659 /* if we return >=0: param is processed again (if there is any) */ |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
1304
diff
changeset
|
660 }else{ |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
661 ret=((cfg_func_arg_param_t) conf[i].p)(conf + i, opt, param); |
1536
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
1304
diff
changeset
|
662 /* if we return 0: need no param, precess it again */ |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
1304
diff
changeset
|
663 /* if we return 1: accepted param */ |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
1304
diff
changeset
|
664 } |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
1304
diff
changeset
|
665 break; |
150 | 666 case CONF_TYPE_FUNC: |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
667 if ((((cfg_func_t) conf[i].p)(conf + i)) < 0) { |
160 | 668 ret = ERR_FUNC_ERR; |
669 goto out; | |
670 } | |
671 ret = 0; | |
150 | 672 break; |
2619 | 673 case CONF_TYPE_SUBCONFIG: |
674 { | |
675 char *subparam; | |
676 char *subopt; | |
677 int subconf_optnr; | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
678 config_t *subconf; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
679 config_t *sublist[] = { NULL , NULL }; |
2619 | 680 char *token; |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
681 char *p; |
2619 | 682 |
683 if (param == NULL) | |
684 goto err_missing_param; | |
685 | |
3613 | 686 subparam = malloc(strlen(param)+1); |
687 subopt = malloc(strlen(param)+1); | |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
688 p = strdup(param); // In case that param is a static string (cf man strtok) |
2619 | 689 |
690 subconf = conf[i].p; | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
691 sublist[0] = subconf; |
2619 | 692 for (subconf_optnr = 0; subconf[subconf_optnr].name != NULL; subconf_optnr++) |
693 /* NOTHING */; | |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
694 config->sub_conf = opt; |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
695 token = strtok(p, (char *)&(":")); |
2619 | 696 while(token) |
697 { | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
698 int sscanf_ret; |
3761 | 699 /* clear out */ |
700 subopt[0] = subparam[0] = 0; | |
2619 | 701 |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
702 sscanf_ret = sscanf(token, "%[^=]=%s", subopt, subparam); |
3761 | 703 |
704 mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "token: '%s', i=%d, subopt='%s', subparam='%s' (ret: %d)\n", token, i, subopt, subparam, sscanf_ret); | |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
705 switch(sscanf_ret) |
2621 | 706 { |
707 case 1: | |
3761 | 708 subparam[0] = 0; |
2621 | 709 case 2: |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
710 if ((ret = config_read_option(config,sublist, subopt, subparam)) < 0) |
2621 | 711 { |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
712 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Subconfig parsing returned error: %d in token: %s\n", |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
713 ret, token); |
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
714 goto out; |
2621 | 715 } |
716 break; | |
717 default: | |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
718 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Invalid subconfig argument! ('%s')\n", token); |
3559
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
719 ret = ERR_NOT_AN_OPTION; |
f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
alex
parents:
2650
diff
changeset
|
720 goto out; |
2621 | 721 } |
2619 | 722 token = strtok(NULL, (char *)&(":")); |
723 } | |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
724 config->sub_conf = NULL; |
2619 | 725 free(subparam); |
726 free(subopt); | |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
727 free(p); |
2619 | 728 ret = 1; |
729 break; | |
730 } | |
152 | 731 case CONF_TYPE_PRINT: |
5115 | 732 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "%s", (char *) conf[i].p); |
152 | 733 exit(1); |
147 | 734 default: |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
735 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Unknown config type specified in conf-mplayer.h!\n"); |
147 | 736 break; |
737 } | |
160 | 738 out: |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
739 if(ret >= 0 && ! IS_RUNNING(config) && ! IS_GLOBAL(config) && ! (conf[i].flags & CONF_GLOBAL) && conf[i].type != CONF_TYPE_SUBCONFIG ) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
740 play_tree_t* dest = config->last_entry ? config->last_entry : config->last_parent; |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
741 char* o; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
742 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
743 assert(dest != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
744 #endif |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
745 if(config->sub_conf) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
746 o = (char*)malloc((strlen(config->sub_conf) + 1 + strlen(opt) + 1)*sizeof(char)); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
747 sprintf(o,"%s:%s",config->sub_conf,opt); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
748 } else |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
749 o =strdup(opt); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
750 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
751 if(ret == 0) |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
752 play_tree_set_param(dest,o,NULL); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
753 else if(ret > 0) |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
754 play_tree_set_param(dest,o,param); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
755 free(o); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
756 m_config_pop(config); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
757 } |
160 | 758 return ret; |
759 err_missing_param: | |
3684
00bd914b6fb1
subconfig fix (if sscanf()==1, then null out second (non-present) parameter) and some errormessage fixes
alex
parents:
3613
diff
changeset
|
760 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "missing parameter for option: %s\n", opt); |
160 | 761 ret = ERR_MISSING_PARAM; |
762 goto out; | |
147 | 763 } |
764 | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
765 int m_config_set_option(m_config_t *config,char *opt, char *param) { |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
766 char *e; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
767 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
768 assert(config != NULL); |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
769 assert(config->opt_list != NULL); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
770 assert(opt != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
771 #endif |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
772 mp_msg(MSGT_CFGPARSER, MSGL_DBG2, "Setting option %s=%s\n",opt,param); |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
773 e = strchr(opt,':'); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
774 if(e && e[1] != '\0') { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
775 int ret; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
776 config_t* opt_list[] = { NULL, NULL }; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
777 char* s = (char*)malloc((e-opt+1)*sizeof(char)); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
778 strncpy(s,opt,e-opt); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
779 s[e-opt] = '\0'; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
780 opt_list[0] = m_config_get_option_ptr(config,s); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
781 if(!opt_list[0]) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
782 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"m_config_set_option %s=%s : no %s subconfig\n",opt,param,s); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
783 free(s); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
784 return ERR_NOT_AN_OPTION; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
785 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
786 e++; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
787 s = (char*)realloc(s,strlen(e) + 1); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
788 strcpy(s,e); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
789 ret = config_read_option(config,opt_list,s,param); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
790 free(s); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
791 return ret; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
792 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
793 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
794 return config_read_option(config,config->opt_list,opt,param); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
795 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
796 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
797 int m_config_parse_config_file(m_config_t *config, char *conffile) |
147 | 798 { |
5115 | 799 #define PRINT_LINENUM mp_msg(MSGT_CFGPARSER,MSGL_INFO,"%s(%d): ", conffile, line_num) |
147 | 800 #define MAX_LINE_LEN 1000 |
801 #define MAX_OPT_LEN 100 | |
802 #define MAX_PARAM_LEN 100 | |
803 FILE *fp; | |
804 char *line; | |
179 | 805 char opt[MAX_OPT_LEN + 1]; |
806 char param[MAX_PARAM_LEN + 1]; | |
167 | 807 char c; /* for the "" and '' check */ |
147 | 808 int tmp; |
809 int line_num = 0; | |
810 int line_pos; /* line pos */ | |
811 int opt_pos; /* opt pos */ | |
812 int param_pos; /* param pos */ | |
813 int ret = 1; | |
1090 | 814 int errors = 0; |
147 | 815 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
816 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
817 assert(config != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
818 // assert(conf_list != NULL); |
147 | 819 #endif |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
820 if (++config->recursion_depth > 1) |
5115 | 821 mp_msg(MSGT_CFGPARSER,MSGL_INFO,"Reading config file: %s", conffile); |
1089 | 822 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
823 if (config->recursion_depth > MAX_RECURSION_DEPTH) { |
5934 | 824 mp_msg(MSGT_CFGPARSER,MSGL_ERR,": too deep 'include'. check your configfiles\n"); |
1089 | 825 ret = -1; |
826 goto out; | |
827 } | |
166 | 828 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
829 if (init_conf(config, CONFIG_FILE) == -1) { |
166 | 830 ret = -1; |
831 goto out; | |
832 } | |
147 | 833 |
179 | 834 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) { |
5934 | 835 mp_msg(MSGT_CFGPARSER,MSGL_FATAL,"\ncan't get memory for 'line': %s", strerror(errno)); |
166 | 836 ret = -1; |
837 goto out; | |
147 | 838 } |
839 | |
840 if ((fp = fopen(conffile, "r")) == NULL) { | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
841 if (config->recursion_depth > 1) |
5934 | 842 mp_msg(MSGT_CFGPARSER,MSGL_ERR,": %s\n", strerror(errno)); |
147 | 843 free(line); |
166 | 844 ret = 0; |
845 goto out; | |
147 | 846 } |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
847 if (config->recursion_depth > 1) |
5115 | 848 mp_msg(MSGT_CFGPARSER,MSGL_INFO,"\n"); |
147 | 849 |
850 while (fgets(line, MAX_LINE_LEN, fp)) { | |
1090 | 851 if (errors >= 16) { |
5934 | 852 mp_msg(MSGT_CFGPARSER,MSGL_FATAL,"too many errors\n"); |
1090 | 853 goto out; |
854 } | |
855 | |
147 | 856 line_num++; |
857 line_pos = 0; | |
858 | |
859 /* skip whitespaces */ | |
860 while (isspace(line[line_pos])) | |
861 ++line_pos; | |
862 | |
863 /* EOL / comment */ | |
864 if (line[line_pos] == '\0' || line[line_pos] == '#') | |
865 continue; | |
866 | |
480 | 867 /* read option. */ |
868 for (opt_pos = 0; isprint(line[line_pos]) && | |
869 line[line_pos] != ' ' && | |
870 line[line_pos] != '#' && | |
871 line[line_pos] != '='; /* NOTHING */) { | |
147 | 872 opt[opt_pos++] = line[line_pos++]; |
873 if (opt_pos >= MAX_OPT_LEN) { | |
874 PRINT_LINENUM; | |
5934 | 875 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"too long option\n"); |
1090 | 876 errors++; |
147 | 877 ret = -1; |
1090 | 878 goto nextline; |
147 | 879 } |
880 } | |
881 if (opt_pos == 0) { | |
882 PRINT_LINENUM; | |
5934 | 883 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"parse error\n"); |
147 | 884 ret = -1; |
1090 | 885 errors++; |
147 | 886 continue; |
887 } | |
888 opt[opt_pos] = '\0'; | |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
889 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
890 #ifdef MP_DEBUG |
147 | 891 PRINT_LINENUM; |
5115 | 892 mp_msg(MSGT_CFGPARSER,MSGL_INFO,"option: %s\n", opt); |
147 | 893 #endif |
894 | |
895 /* skip whitespaces */ | |
896 while (isspace(line[line_pos])) | |
897 ++line_pos; | |
898 | |
899 /* check '=' */ | |
900 if (line[line_pos++] != '=') { | |
901 PRINT_LINENUM; | |
5934 | 902 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"option without parameter\n"); |
147 | 903 ret = -1; |
1090 | 904 errors++; |
147 | 905 continue; |
906 } | |
907 | |
908 /* whitespaces... */ | |
909 while (isspace(line[line_pos])) | |
910 ++line_pos; | |
911 | |
912 /* read the parameter */ | |
167 | 913 if (line[line_pos] == '"' || line[line_pos] == '\'') { |
914 c = line[line_pos]; | |
915 ++line_pos; | |
916 for (param_pos = 0; line[line_pos] != c; /* NOTHING */) { | |
917 param[param_pos++] = line[line_pos++]; | |
918 if (param_pos >= MAX_PARAM_LEN) { | |
919 PRINT_LINENUM; | |
5934 | 920 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"too long parameter\n"); |
167 | 921 ret = -1; |
1090 | 922 errors++; |
923 goto nextline; | |
167 | 924 } |
925 } | |
926 line_pos++; /* skip the closing " or ' */ | |
927 } else { | |
928 for (param_pos = 0; isprint(line[line_pos]) && !isspace(line[line_pos]) | |
929 && line[line_pos] != '#'; /* NOTHING */) { | |
930 param[param_pos++] = line[line_pos++]; | |
931 if (param_pos >= MAX_PARAM_LEN) { | |
932 PRINT_LINENUM; | |
5934 | 933 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"too long parameter\n"); |
167 | 934 ret = -1; |
1090 | 935 errors++; |
936 goto nextline; | |
167 | 937 } |
147 | 938 } |
939 } | |
940 param[param_pos] = '\0'; | |
941 | |
942 /* did we read a parameter? */ | |
943 if (param_pos == 0) { | |
944 PRINT_LINENUM; | |
5934 | 945 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"option without parameter\n"); |
147 | 946 ret = -1; |
1090 | 947 errors++; |
147 | 948 continue; |
949 } | |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
950 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
951 #ifdef MP_DEBUG |
147 | 952 PRINT_LINENUM; |
5115 | 953 mp_msg(MSGT_CFGPARSER,MSGL_INFO,"parameter: %s\n", param); |
147 | 954 #endif |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
955 |
147 | 956 /* now, check if we have some more chars on the line */ |
957 /* whitespace... */ | |
958 while (isspace(line[line_pos])) | |
959 ++line_pos; | |
960 | |
961 /* EOL / comment */ | |
962 if (line[line_pos] != '\0' && line[line_pos] != '#') { | |
963 PRINT_LINENUM; | |
5934 | 964 mp_msg(MSGT_CFGPARSER,MSGL_WARN,"extra characters on line: %s\n", line+line_pos); |
147 | 965 ret = -1; |
966 } | |
967 | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
968 tmp = m_config_set_option(config, opt, param); |
147 | 969 switch (tmp) { |
970 case ERR_NOT_AN_OPTION: | |
971 case ERR_MISSING_PARAM: | |
972 case ERR_OUT_OF_RANGE: | |
150 | 973 case ERR_FUNC_ERR: |
974 PRINT_LINENUM; | |
5115 | 975 mp_msg(MSGT_CFGPARSER,MSGL_INFO,"%s\n", opt); |
150 | 976 ret = -1; |
1090 | 977 errors++; |
150 | 978 continue; |
979 /* break */ | |
147 | 980 } |
1093 | 981 nextline: |
1304 | 982 ; |
147 | 983 } |
984 | |
985 free(line); | |
986 fclose(fp); | |
166 | 987 out: |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
988 --config->recursion_depth; |
147 | 989 return ret; |
990 } | |
991 | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
992 int m_config_parse_command_line(m_config_t *config, int argc, char **argv, char **envp) |
147 | 993 { |
994 int i; | |
995 int tmp; | |
996 char *opt; | |
2615 | 997 int no_more_opts = 0; |
147 | 998 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
999 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1000 assert(config != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1001 assert(config->pt != NULL); |
147 | 1002 assert(argv != NULL); |
1003 assert(envp != NULL); | |
1004 assert(argc >= 1); | |
1005 #endif | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1006 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1007 if (init_conf(config, COMMAND_LINE) == -1) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1008 return -1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1009 if(config->last_parent == NULL) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1010 config->last_parent = config->pt; |
1089 | 1011 /* in order to work recursion detection properly in parse_config_file */ |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1012 ++config->recursion_depth; |
1089 | 1013 |
147 | 1014 for (i = 1; i < argc; i++) { |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1015 //next: |
147 | 1016 opt = argv[i]; |
2650
bf7248edcc20
fixed commandline bug: handling '-' as option when '--' unused
alex
parents:
2624
diff
changeset
|
1017 /* check for -- (no more options id.) except --help! */ |
2623 | 1018 if ((*opt == '-') && (*(opt+1) == '-') && (*(opt+2) != 'h')) |
2615 | 1019 { |
1020 no_more_opts = 1; | |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
1021 if (i+1 >= argc) |
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
1022 { |
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
1023 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "You added '--' but no filenames presented!\n"); |
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
1024 goto err_out; |
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
1025 } |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1026 continue; |
2615 | 1027 } |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1028 if((opt[0] == '{') && (opt[1] == '\0')) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1029 { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1030 play_tree_t* entry = play_tree_new(); |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
1031 UNSET_GLOBAL(config); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1032 if(config->last_entry == NULL) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1033 play_tree_set_child(config->last_parent,entry); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1034 } else { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1035 play_tree_append_entry(config->last_entry,entry); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1036 config->last_entry = NULL; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1037 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1038 config->last_parent = entry; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1039 continue; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1040 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1041 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1042 if((opt[0] == '}') && (opt[1] == '\0')) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1043 { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1044 if( ! config->last_parent || ! config->last_parent->parent) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1045 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "too much }-\n"); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1046 goto err_out; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1047 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1048 config->last_entry = config->last_parent; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1049 config->last_parent = config->last_entry->parent; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1050 continue; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1051 } |
2615 | 1052 |
2650
bf7248edcc20
fixed commandline bug: handling '-' as option when '--' unused
alex
parents:
2624
diff
changeset
|
1053 if ((no_more_opts == 0) && (*opt == '-') && (*(opt+1) != 0)) /* option */ |
2615 | 1054 { |
1055 /* remove trailing '-' */ | |
1056 opt++; | |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
1057 |
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
1058 mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "this_opt = option: %s\n", opt); |
5655
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1059 // We handle here some specific option |
5215 | 1060 if(strcasecmp(opt,"list-options") == 0) { |
1061 m_config_list_options(config); | |
1062 exit(1); | |
5655
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1063 // Loop option when it apply to a group |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1064 } else if(strcasecmp(opt,"loop") == 0 && |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1065 (! config->last_entry || config->last_entry->child) ) { |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1066 int l; |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1067 char* end; |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1068 l = strtol(argv[i+1],&end,0); |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1069 if(!end) |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1070 tmp = ERR_OUT_OF_RANGE; |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1071 else { |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1072 play_tree_t* pt = config->last_entry ? config->last_entry : config->last_parent; |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1073 l = l <= 0 ? -1 : l; |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1074 pt->loop = l; |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1075 tmp = 1; |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1076 } |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1077 } else // All normal options |
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1078 tmp = m_config_set_option(config, opt, argv[i + 1]); |
1629 | 1079 |
2615 | 1080 switch (tmp) { |
1081 case ERR_NOT_AN_OPTION: | |
1082 case ERR_MISSING_PARAM: | |
1083 case ERR_OUT_OF_RANGE: | |
1084 case ERR_FUNC_ERR: | |
5215 | 1085 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Error: "); |
1086 m_config_error(tmp,opt,argv[i+1]); | |
160 | 1087 goto err_out; |
2615 | 1088 default: |
1075 | 1089 i += tmp; |
2615 | 1090 break; |
1091 } | |
1092 } | |
1093 else /* filename */ | |
1094 { | |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1095 play_tree_t* entry = play_tree_new(); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1096 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Adding file %s\n",argv[i]); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1097 play_tree_add_file(entry,argv[i]); |
4890
0c1526391dd3
New option use-stdin to use when stdin will be used as a file
albeu
parents:
4771
diff
changeset
|
1098 if(strcasecmp(argv[i],"-") == 0) |
0c1526391dd3
New option use-stdin to use when stdin will be used as a file
albeu
parents:
4771
diff
changeset
|
1099 m_config_set_option(config,"use-stdin",NULL); |
2615 | 1100 /* opt is not an option -> treat it as a filename */ |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
1101 UNSET_GLOBAL(config); // We start entry specific options |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1102 if(config->last_entry == NULL) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1103 play_tree_set_child(config->last_parent,entry); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1104 else |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1105 play_tree_append_entry(config->last_entry,entry); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1106 config->last_entry = entry; |
147 | 1107 } |
1089 | 1108 } |
2615 | 1109 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1110 --config->recursion_depth; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1111 if(config->last_parent != config->pt) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1112 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Missing }- ?\n"); |
5655
117f34bb7097
Add correct loop option parsing in command line parser.
albeu
parents:
5215
diff
changeset
|
1113 config->flags &= (!CONFIG_GLOBAL); |
4268
83aedfde69f8
Some improvment and make -vcd -dvd options considered as playlist entry
albeu
parents:
4254
diff
changeset
|
1114 SET_RUNNING(config); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1115 return 1; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1116 #if 0 |
1629 | 1117 err_out_mem: |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
1118 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "can't allocate memory for filenames (%s)\n", strerror(errno)); |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1119 #endif |
160 | 1120 err_out: |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1121 --config->recursion_depth; |
2624
64844fccf623
partly upgraded to mp_msg and fixed minor bug in parse_command_line
alex
parents:
2623
diff
changeset
|
1122 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "command line: %s\n", argv[i]); |
160 | 1123 return -1; |
147 | 1124 } |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1125 |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1126 int |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1127 m_config_register_options(m_config_t *config,config_t *args) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1128 int list_len = 0; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1129 config_t** conf_list = config->opt_list; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1130 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1131 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1132 assert(config != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1133 assert(args != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1134 #endif |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1135 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1136 if(conf_list) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1137 for ( ; conf_list[list_len] != NULL; list_len++) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1138 /* NOTHING */; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1139 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1140 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1141 conf_list = (config_t**)realloc(conf_list,sizeof(struct conf*)*(list_len+2)); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1142 if(conf_list == NULL) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1143 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Can't allocate %d bytes of memory : %s\n",sizeof(struct conf*)*(list_len+2),strerror(errno)); |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1144 return 0; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1145 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1146 conf_list[list_len] = args; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1147 conf_list[list_len+1] = NULL; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1148 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1149 config->opt_list = conf_list; |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1150 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1151 return 1; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1152 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1153 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1154 config_t* |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1155 m_config_get_option(m_config_t *config, char* arg) { |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1156 int i,j; |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1157 char *e; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1158 config_t *conf; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1159 config_t **conf_list; |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1160 config_t* cl[] = { NULL, NULL }; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1161 |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1162 #ifdef MP_DEBUG |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1163 assert(config != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1164 assert(arg != NULL); |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1165 #endif |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1166 |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1167 e = strchr(arg,':'); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1168 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1169 if(e) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1170 char *s; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1171 s = (char*)malloc((e-arg+1)*sizeof(char)); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1172 strncpy(s,arg,e-arg); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1173 s[e-arg] = '\0'; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1174 cl[0] = m_config_get_option(config,s); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1175 conf_list = cl; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1176 free(s); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1177 } else |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1178 conf_list = config->opt_list; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1179 |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1180 if(conf_list) { |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1181 for(j = 0 ; conf_list[j] != NULL ; j++) { |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1182 conf = conf_list[j]; |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1183 for(i=0; conf[i].name != NULL; i++) { |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1184 if(strcasecmp(conf[i].name,arg) == 0) |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1185 return &conf[i]; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1186 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1187 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1188 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1189 return NULL; |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1190 } |
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1191 |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1192 void* |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1193 m_config_get_option_ptr(m_config_t *config, char* arg) { |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1194 config_t* conf; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1195 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1196 #ifdef MP_DEBUG |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1197 assert(config != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1198 assert(arg != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1199 #endif |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1200 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1201 conf = m_config_get_option(config,arg); |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1202 if(!conf) return NULL; |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1203 return conf->p; |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1204 } |
4156
22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
arpi
parents:
3761
diff
changeset
|
1205 |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1206 int |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1207 m_config_get_int (m_config_t *config, char* arg,int* err_ret) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1208 int *ret; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1209 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1210 #ifdef MP_DEBUG |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1211 assert(config != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1212 assert(arg != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1213 #endif |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1214 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1215 ret = m_config_get_option_ptr(config,arg); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1216 if(err_ret) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1217 *err_ret = 0; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1218 if(!ret) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1219 if(err_ret) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1220 *err_ret = 1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1221 return -1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1222 } else |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1223 return (*ret); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1224 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1225 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1226 float |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1227 m_config_get_float (m_config_t *config, char* arg,int* err_ret) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1228 float *ret; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1229 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1230 #ifdef MP_DEBUG |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1231 assert(config != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1232 assert(arg != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1233 #endif |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1234 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1235 ret = m_config_get_option_ptr(config,arg); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1236 if(err_ret) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1237 *err_ret = 0; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1238 if(!ret) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1239 if(err_ret) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1240 *err_ret = 1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1241 return -1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1242 } else |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1243 return (*ret); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1244 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1245 |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1246 #define AS_INT(c) (*((int*)c->p)) |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1247 |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1248 int |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1249 m_config_set_int(m_config_t *config, char* arg,int val) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1250 config_t* opt; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1251 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1252 #ifdef MP_DEBUG |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1253 assert(config != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1254 assert(arg != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1255 #endif |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1256 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1257 opt = m_config_get_option(config,arg); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1258 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1259 if(!opt || opt->type != CONF_TYPE_INT) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1260 return ERR_NOT_AN_OPTION; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1261 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1262 if(opt->flags & CONF_MIN && val < opt->min) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1263 return ERR_OUT_OF_RANGE; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1264 if(opt->flags & CONF_MAX && val > opt->max) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1265 return ERR_OUT_OF_RANGE; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1266 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1267 m_config_save_option(config,opt,arg,NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1268 AS_INT(opt) = val; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1269 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1270 return 1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1271 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1272 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1273 int |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1274 m_config_set_float(m_config_t *config, char* arg,float val) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1275 config_t* opt; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1276 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1277 #ifdef MP_DEBUG |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1278 assert(config != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1279 assert(arg != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1280 #endif |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1281 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1282 opt = m_config_get_option(config,arg); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1283 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1284 if(!opt || opt->type != CONF_TYPE_FLOAT) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1285 return ERR_NOT_AN_OPTION; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1286 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1287 if(opt->flags & CONF_MIN && val < opt->min) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1288 return ERR_OUT_OF_RANGE; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1289 if(opt->flags & CONF_MAX && val > opt->max) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1290 return ERR_OUT_OF_RANGE; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1291 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1292 m_config_save_option(config,opt,arg,NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1293 *((float*)opt->p) = val; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1294 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1295 return 1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1296 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1297 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1298 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1299 int |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1300 m_config_switch_flag(m_config_t *config, char* opt) { |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1301 config_t *conf; |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1302 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1303 #ifdef MP_DEBUG |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1304 assert(config != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1305 assert(opt != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1306 #endif |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1307 |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1308 conf = m_config_get_option(config,opt); |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1309 if(!conf || conf->type != CONF_TYPE_FLAG) return 0; |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1310 if( AS_INT(conf) == conf->min) AS_INT(conf) = conf->max; |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1311 else if(AS_INT(conf) == conf->max) AS_INT(conf) = conf->min; |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1312 else return 0; |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1313 |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1314 return 1; |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1315 } |
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1316 |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1317 int |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1318 m_config_set_flag(m_config_t *config, char* opt, int state) { |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1319 config_t *conf; |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1320 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1321 #ifdef MP_DEBUG |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1322 assert(config != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1323 assert(opt != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1324 #endif |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1325 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1326 conf = m_config_get_option(config,opt); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1327 if(!conf || conf->type != CONF_TYPE_FLAG) return 0; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1328 if(state) AS_INT(conf) = conf->max; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1329 else AS_INT(conf) = conf->min; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1330 return 1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1331 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1332 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1333 int |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1334 m_config_get_flag(m_config_t *config, char* opt) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1335 config_t *conf; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1336 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1337 #ifdef MP_DEBUG |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1338 assert(config != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1339 assert(opt != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1340 #endif |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1341 |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1342 conf = m_config_get_option(config,opt); |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1343 if(!conf || conf->type != CONF_TYPE_FLAG) return -1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1344 if(AS_INT(conf) == conf->max) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1345 return 1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1346 else if(AS_INT(conf) == conf->min) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1347 return 0; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1348 else |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1349 return -1; |
4254
f04c49aa2408
Few bug fix and improvment in config/playtree system
albeu
parents:
4220
diff
changeset
|
1350 } |
4292
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1351 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1352 int m_config_is_option_set(m_config_t *config, char* arg) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1353 config_t* opt; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1354 config_save_t* save; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1355 int l,i; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1356 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1357 #ifdef MP_DEBUG |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1358 assert(config != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1359 assert(arg != NULL); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1360 #endif |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1361 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1362 opt = m_config_get_option(config,arg); |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1363 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1364 if(!opt) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1365 return -1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1366 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1367 for(l = config->cs_level ; l >= 0 ; l--) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1368 save = config->config_stack[l]; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1369 if(!save) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1370 continue; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1371 for(i = 0 ; save[i].opt != NULL ; i++) { |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1372 if(save[i].opt == opt) |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1373 return 1; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1374 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1375 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1376 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1377 return 0; |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1378 } |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1379 |
1cee88ee8db5
Bug fix for subconfig option. A -tv option containing the on parameter
albeu
parents:
4268
diff
changeset
|
1380 #undef AS_INT |
5215 | 1381 |
1382 static void m_config_print_option_list(char* prefix, config_t* opt_list) { | |
1383 char* pf = NULL; | |
1384 config_t* opt; | |
1385 char min[50],max[50],*type; | |
1386 | |
1387 | |
1388 for(opt = opt_list ; opt->name != NULL ; opt++) { | |
1389 if(opt->type == CONF_TYPE_SUBCONFIG) { | |
1390 if(prefix) { | |
1391 pf = (char*)malloc(strlen(prefix) + strlen(opt->name) + 1); | |
1392 sprintf(pf,"%s:%s",prefix,opt->name); | |
1393 } else | |
1394 pf = strdup(opt->name); | |
1395 m_config_print_option_list(pf,(config_t*)opt->p); | |
1396 free(pf); | |
1397 continue; | |
1398 } | |
1399 if(prefix) | |
1400 printf("%1.15s:",prefix); | |
1401 if(opt->flags & CONF_MIN) | |
1402 sprintf(min,"%-8.0f",opt->min); | |
1403 else | |
1404 strcpy(min,"No"); | |
1405 if(opt->flags & CONF_MAX) | |
1406 sprintf(max,"%-8.0f",opt->max); | |
1407 else | |
1408 strcpy(max,"No"); | |
1409 switch(opt->type) { | |
1410 case CONF_TYPE_FLAG: | |
1411 type = "Flag"; | |
1412 break; | |
1413 case CONF_TYPE_INT: | |
1414 type = "Integer"; | |
1415 break; | |
1416 case CONF_TYPE_FLOAT: | |
1417 type = "Float"; | |
1418 break; | |
1419 case CONF_TYPE_STRING: | |
1420 type = "String"; | |
1421 break; | |
1422 case CONF_TYPE_FUNC: | |
1423 case CONF_TYPE_FUNC_PARAM: | |
1424 case CONF_TYPE_FUNC_FULL: | |
1425 type = "Function"; | |
1426 break; | |
1427 case CONF_TYPE_PRINT: | |
1428 type = "Print"; | |
1429 break; | |
1430 case CONF_TYPE_STRING_LIST: | |
1431 type = "String list"; | |
1432 break; | |
1433 default: | |
1434 type = ""; | |
1435 break; | |
1436 } | |
1437 printf("%-*.15s %-13.13s %-10.10s %-10.10s %-3.3s %-3.3s %-3.3s\n", | |
1438 30 - (prefix ? strlen(prefix) + 1 : 0), | |
1439 opt->name, | |
1440 type, | |
1441 min, | |
1442 max, | |
1443 opt->flags & CONF_GLOBAL ? "Yes" : "No", | |
1444 opt->flags & CONF_NOCMD ? "No" : "Yes", | |
1445 opt->flags & CONF_NOCFG ? "No" : "Yes"); | |
1446 } | |
1447 | |
1448 } | |
1449 | |
1450 | |
1451 static void m_config_list_options(m_config_t *config) { | |
1452 int i; | |
1453 | |
1454 printf("\nName Type Min Max Glob CL Cfg\n\n"); | |
1455 for(i = 0; config->opt_list[i] ; i++) | |
1456 m_config_print_option_list(NULL,config->opt_list[i]); | |
1457 } | |
1458 | |
1459 | |
1460 | |
1461 static void m_config_error(int err,char* opt,char* val) { | |
1462 switch(err) { | |
1463 case ERR_NOT_AN_OPTION: | |
5785 | 1464 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"'%s' is not a mplayer/mencoder option\n",opt); |
5215 | 1465 break; |
1466 case ERR_MISSING_PARAM: | |
1467 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"option '%s' need a parameter\n",opt); | |
1468 break; | |
1469 case ERR_OUT_OF_RANGE: | |
1470 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"value '%s' of option '%s' is out of range\n",val,opt); | |
1471 break; | |
1472 case ERR_FUNC_ERR: | |
1473 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"while parsing option '%s'\n",opt); | |
1474 break; | |
1475 } | |
1476 } |