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