annotate cfgparser.c @ 8388:45eb2d4d633c

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