comparison m_config.c @ 8894:e6a83b140b39

better error handling for invalud suboptions
author arpi
date Sat, 11 Jan 2003 17:32:45 +0000
parents 06843e67a04b
children d3da9b617aa8
comparison
equal deleted inserted replaced
8893:268b3fbc35b7 8894:e6a83b140b39
213 assert(arg != NULL); 213 assert(arg != NULL);
214 #endif 214 #endif
215 215
216 co = m_config_get_co(config,arg); 216 co = m_config_get_co(config,arg);
217 if(!co){ 217 if(!co){
218 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Unknown option: %s\n",arg); 218 // mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Unknown option: %s\n",arg);
219 return M_OPT_UNKNOW; 219 return M_OPT_UNKNOW;
220 } 220 }
221 221
222 #ifdef MP_DEBUG 222 #ifdef MP_DEBUG
223 // This is the only mandatory function 223 // This is the only mandatory function
239 char** lst = NULL; 239 char** lst = NULL;
240 int i,sr; 240 int i,sr;
241 // Parse the child options 241 // Parse the child options
242 r = m_option_parse(co->opt,arg,param,&lst,config->mode); 242 r = m_option_parse(co->opt,arg,param,&lst,config->mode);
243 // Set them now 243 // Set them now
244 if(r >= 0)
244 for(i = 0 ; lst && lst[2*i] ; i++) { 245 for(i = 0 ; lst && lst[2*i] ; i++) {
245 int l = strlen(co->name) + 1 + strlen(lst[2*i]) + 1; 246 int l = strlen(co->name) + 1 + strlen(lst[2*i]) + 1;
246 if(r >= 0) { 247 if(r >= 0) {
247 // Build the full name 248 // Build the full name
248 char n[l]; 249 char n[l];
249 sprintf(n,"%s:%s",co->name,lst[2*i]); 250 sprintf(n,"%s:%s",co->name,lst[2*i]);
250 sr = m_config_parse_option(config,n,lst[2*i+1],set); 251 sr = m_config_parse_option(config,n,lst[2*i+1],set);
251 if(sr < 0) r = sr; 252 if(sr < 0){
253 if(sr == M_OPT_UNKNOW){
254 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Error: option '%s' has no suboption '%s'\n",co->name,lst[2*i]);
255 r = M_OPT_INVALID;
256 } else
257 r = sr;
258 }
252 } 259 }
253 free(lst[2*i]); 260 free(lst[2*i]);
254 free(lst[2*i+1]); 261 free(lst[2*i+1]);
255 } 262 }
256 if(lst) free(lst); 263 if(lst) free(lst);