annotate parser-cfg.c @ 24282:92be1a6a21d4

synced with r24301
author Gabrov
date Wed, 29 Aug 2007 22:58:47 +0000
parents 0a38ad149c5c
children 65d1238b3631
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18265
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
1
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
2 /// \defgroup ConfigParsers Config parsers
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
3 ///
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
4 /// The \ref ConfigParsers make use of the \ref Config to setup the config variables,
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
5 /// the command line parsers also build the playlist.
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
6 ///@{
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
7
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
8 /// \file
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
9
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
10 #include "config.h"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
11
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
12 #include <stdio.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
13 #include <stdlib.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
14 #include <string.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
15 #include <errno.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
16 #include <ctype.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
17
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
18 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
19 #include <assert.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
20 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
21
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
22 #include "mp_msg.h"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
23 #include "m_option.h"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
24 #include "m_config.h"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
25
18265
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
26 /// Maximal include depth.
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
27 #define MAX_RECURSION_DEPTH 8
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
28
18265
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
29 /// Current include depth.
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
30 static int recursion_depth = 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
31
18265
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
32 /// Setup the \ref Config from a config file.
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
33 /** \param config The config object.
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
34 * \param conffile Path to the config file.
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
35 * \return 1 on sucess, -1 on error.
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
36 */
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
37 int m_config_parse_config_file(m_config_t* config, char *conffile)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
38 {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
39 #define PRINT_LINENUM mp_msg(MSGT_CFGPARSER,MSGL_V,"%s(%d): ", conffile, line_num)
9813
b0141de527df longer option buffers, needed for tv options
henry
parents: 9578
diff changeset
40 #define MAX_LINE_LEN 10000
b0141de527df longer option buffers, needed for tv options
henry
parents: 9578
diff changeset
41 #define MAX_OPT_LEN 1000
21799
a6911070ac6e increased a bit max param length as it can be too short to declare tv channels when you have a long list of
ben
parents: 19462
diff changeset
42 #define MAX_PARAM_LEN 1500
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
43 FILE *fp;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
44 char *line;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
45 char opt[MAX_OPT_LEN + 1];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
46 char param[MAX_PARAM_LEN + 1];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
47 char c; /* for the "" and '' check */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
48 int tmp;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
49 int line_num = 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
50 int line_pos; /* line pos */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
51 int opt_pos; /* opt pos */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
52 int param_pos; /* param pos */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
53 int ret = 1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
54 int errors = 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
55 int prev_mode = config->mode;
17471
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
56 m_profile_t* profile = NULL;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
57
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
58 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
59 assert(config != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
60 // assert(conf_list != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
61 #endif
13946
e632b43f0598 Reduce excessive verbosity.
diego
parents: 10595
diff changeset
62 mp_msg(MSGT_CFGPARSER,MSGL_V,"Reading config file %s", conffile);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
63
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
64 if (recursion_depth > MAX_RECURSION_DEPTH) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
65 mp_msg(MSGT_CFGPARSER,MSGL_ERR,": too deep 'include'. check your configfiles\n");
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
66 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
67 goto out;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
68 } else
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
69
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
70 config->mode = M_CONFIG_FILE;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
71
23806
0a38ad149c5c Remove some more useless *alloc casts
reimar
parents: 21799
diff changeset
72 if ((line = malloc(MAX_LINE_LEN + 1)) == NULL) {
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
73 mp_msg(MSGT_CFGPARSER,MSGL_FATAL,"\ncan't get memory for 'line': %s", strerror(errno));
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
74 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
75 goto out;
19462
08fc089138f4 Fix stray newline that should only be printed in verbose mode.
diego
parents: 18265
diff changeset
76 } else
08fc089138f4 Fix stray newline that should only be printed in verbose mode.
diego
parents: 18265
diff changeset
77
08fc089138f4 Fix stray newline that should only be printed in verbose mode.
diego
parents: 18265
diff changeset
78 mp_msg(MSGT_CFGPARSER,MSGL_V,"\n");
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
79
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
80 if ((fp = fopen(conffile, "r")) == NULL) {
13946
e632b43f0598 Reduce excessive verbosity.
diego
parents: 10595
diff changeset
81 mp_msg(MSGT_CFGPARSER,MSGL_V,": %s\n", strerror(errno));
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
82 free(line);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
83 ret = 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
84 goto out;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
85 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
86
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
87 while (fgets(line, MAX_LINE_LEN, fp)) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
88 if (errors >= 16) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
89 mp_msg(MSGT_CFGPARSER,MSGL_FATAL,"too many errors\n");
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
90 goto out;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
91 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
92
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
93 line_num++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
94 line_pos = 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
95
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
96 /* skip whitespaces */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
97 while (isspace(line[line_pos]))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
98 ++line_pos;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
99
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
100 /* EOL / comment */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
101 if (line[line_pos] == '\0' || line[line_pos] == '#')
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
102 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
103
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
104 /* read option. */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
105 for (opt_pos = 0; isprint(line[line_pos]) &&
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
106 line[line_pos] != ' ' &&
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
107 line[line_pos] != '#' &&
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
108 line[line_pos] != '='; /* NOTHING */) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
109 opt[opt_pos++] = line[line_pos++];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
110 if (opt_pos >= MAX_OPT_LEN) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
111 PRINT_LINENUM;
9578
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
112 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"too long option at line %d\n",line_num);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
113 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
114 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
115 goto nextline;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
116 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
117 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
118 if (opt_pos == 0) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
119 PRINT_LINENUM;
9578
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
120 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"parse error at line %d\n",line_num);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
121 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
122 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
123 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
124 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
125 opt[opt_pos] = '\0';
17471
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
126
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
127 /* Profile declaration */
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
128 if(opt_pos > 2 && opt[0] == '[' && opt[opt_pos-1] == ']') {
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
129 opt[opt_pos-1] = '\0';
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
130 if(strcmp(opt+1,"default"))
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
131 profile = m_config_add_profile(config,opt+1);
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
132 else
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
133 profile = NULL;
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
134 continue;
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
135 }
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
136
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
137 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
138 PRINT_LINENUM;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
139 mp_msg(MSGT_CFGPARSER,MSGL_V,"option: %s\n", opt);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
140 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
141
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
142 /* skip whitespaces */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
143 while (isspace(line[line_pos]))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
144 ++line_pos;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
145
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
146 /* check '=' */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
147 if (line[line_pos++] != '=') {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
148 PRINT_LINENUM;
10245
a660de2556c2 1000l! crashing on broken config files finally fixed!
rfelker
parents: 9813
diff changeset
149 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Option %s needs a parameter at line %d\n",opt,line_num);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
150 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
151 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
152 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
153 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
154
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
155 /* whitespaces... */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
156 while (isspace(line[line_pos]))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
157 ++line_pos;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
158
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
159 /* read the parameter */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
160 if (line[line_pos] == '"' || line[line_pos] == '\'') {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
161 c = line[line_pos];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
162 ++line_pos;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
163 for (param_pos = 0; line[line_pos] != c; /* NOTHING */) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
164 param[param_pos++] = line[line_pos++];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
165 if (param_pos >= MAX_PARAM_LEN) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
166 PRINT_LINENUM;
10245
a660de2556c2 1000l! crashing on broken config files finally fixed!
rfelker
parents: 9813
diff changeset
167 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Option %s has a too long parameter at line %d\n",opt,line_num);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
168 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
169 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
170 goto nextline;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
171 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
172 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
173 line_pos++; /* skip the closing " or ' */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
174 } else {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
175 for (param_pos = 0; isprint(line[line_pos]) && !isspace(line[line_pos])
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
176 && line[line_pos] != '#'; /* NOTHING */) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
177 param[param_pos++] = line[line_pos++];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
178 if (param_pos >= MAX_PARAM_LEN) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
179 PRINT_LINENUM;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
180 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"too long parameter\n");
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
181 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
182 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
183 goto nextline;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
184 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
185 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
186 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
187 param[param_pos] = '\0';
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
188
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
189 /* did we read a parameter? */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
190 if (param_pos == 0) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
191 PRINT_LINENUM;
10245
a660de2556c2 1000l! crashing on broken config files finally fixed!
rfelker
parents: 9813
diff changeset
192 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Option %s needs a parameter at line %d\n",opt,line_num);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
193 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
194 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
195 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
196 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
197
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
198 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
199 PRINT_LINENUM;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
200 mp_msg(MSGT_CFGPARSER,MSGL_V,"parameter: %s\n", param);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
201 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
202
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
203 /* now, check if we have some more chars on the line */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
204 /* whitespace... */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
205 while (isspace(line[line_pos]))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
206 ++line_pos;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
207
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
208 /* EOL / comment */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
209 if (line[line_pos] != '\0' && line[line_pos] != '#') {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
210 PRINT_LINENUM;
9578
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
211 mp_msg(MSGT_CFGPARSER,MSGL_WARN,"extra characters on line %d: %s\n",line_num, line+line_pos);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
212 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
213 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
214
17471
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
215 if(profile) {
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
216 if(!strcmp(opt,"profile-desc"))
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
217 m_profile_set_desc(profile,param), tmp = 1;
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
218 else
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
219 tmp = m_config_set_profile_option(config,profile,
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
220 opt,param);
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
221 } else
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
222 tmp = m_config_set_option(config, opt, param);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
223 if (tmp < 0) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
224 PRINT_LINENUM;
10595
522afd56703c 100l to albeu for his english grammar, and 10l to me becouse I noticed that lately (my backward compatibilty macro uses M_OPT_UNKNOWN)
alex
parents: 10594
diff changeset
225 if(tmp == M_OPT_UNKNOWN) {
9578
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
226 mp_msg(MSGT_CFGPARSER,MSGL_WARN,"Warning unknown option %s at line %d\n", opt,line_num);
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
227 continue;
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
228 }
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
229 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Error parsing option %s=%s at line %d\n",opt,param,line_num);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
230 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
231 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
232 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
233 /* break */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
234 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
235 nextline:
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
236 ;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
237 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
238
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
239 free(line);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
240 fclose(fp);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
241 out:
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
242 config->mode = prev_mode;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
243 --recursion_depth;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
244 return ret;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
245 }
18265
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
246
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
247 ///@}