annotate parser-cfg.c @ 18985:add5f992bba2

more c++ decl crap
author rfelker
date Mon, 10 Jul 2006 02:53:06 +0000
parents 1a14fde7680d
children 08fc089138f4
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
b0141de527df longer option buffers, needed for tv options
henry
parents: 9578
diff changeset
42 #define MAX_PARAM_LEN 1000
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
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
72 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) {
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;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
76 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
77
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
78 if ((fp = fopen(conffile, "r")) == NULL) {
13946
e632b43f0598 Reduce excessive verbosity.
diego
parents: 10595
diff changeset
79 mp_msg(MSGT_CFGPARSER,MSGL_V,": %s\n", strerror(errno));
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
80 free(line);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
81 ret = 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
82 goto out;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
83 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
84 mp_msg(MSGT_CFGPARSER,MSGL_INFO,"\n");
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 while (fgets(line, MAX_LINE_LEN, fp)) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
87 if (errors >= 16) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
88 mp_msg(MSGT_CFGPARSER,MSGL_FATAL,"too many errors\n");
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
89 goto out;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
90 }
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 line_num++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
93 line_pos = 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
94
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
95 /* skip whitespaces */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
96 while (isspace(line[line_pos]))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
97 ++line_pos;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
98
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
99 /* EOL / comment */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
100 if (line[line_pos] == '\0' || line[line_pos] == '#')
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
101 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
102
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
103 /* read option. */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
104 for (opt_pos = 0; isprint(line[line_pos]) &&
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
105 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] != '='; /* NOTHING */) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
108 opt[opt_pos++] = line[line_pos++];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
109 if (opt_pos >= MAX_OPT_LEN) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
110 PRINT_LINENUM;
9578
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
111 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
112 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
113 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
114 goto nextline;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
115 }
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 if (opt_pos == 0) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
118 PRINT_LINENUM;
9578
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
119 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
120 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
121 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
122 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
123 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
124 opt[opt_pos] = '\0';
17471
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
125
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
126 /* Profile declaration */
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
127 if(opt_pos > 2 && opt[0] == '[' && opt[opt_pos-1] == ']') {
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
128 opt[opt_pos-1] = '\0';
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
129 if(strcmp(opt+1,"default"))
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
130 profile = m_config_add_profile(config,opt+1);
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
131 else
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
132 profile = NULL;
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
133 continue;
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
134 }
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
135
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
136 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
137 PRINT_LINENUM;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
138 mp_msg(MSGT_CFGPARSER,MSGL_V,"option: %s\n", opt);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
139 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
140
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
141 /* skip whitespaces */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
142 while (isspace(line[line_pos]))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
143 ++line_pos;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
144
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
145 /* check '=' */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
146 if (line[line_pos++] != '=') {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
147 PRINT_LINENUM;
10245
a660de2556c2 1000l! crashing on broken config files finally fixed!
rfelker
parents: 9813
diff changeset
148 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
149 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
150 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
151 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
152 }
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 /* whitespaces... */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
155 while (isspace(line[line_pos]))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
156 ++line_pos;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
157
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
158 /* read the parameter */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
159 if (line[line_pos] == '"' || line[line_pos] == '\'') {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
160 c = line[line_pos];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
161 ++line_pos;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
162 for (param_pos = 0; line[line_pos] != c; /* NOTHING */) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
163 param[param_pos++] = line[line_pos++];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
164 if (param_pos >= MAX_PARAM_LEN) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
165 PRINT_LINENUM;
10245
a660de2556c2 1000l! crashing on broken config files finally fixed!
rfelker
parents: 9813
diff changeset
166 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
167 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
168 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
169 goto nextline;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
170 }
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 line_pos++; /* skip the closing " or ' */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
173 } else {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
174 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
175 && line[line_pos] != '#'; /* NOTHING */) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
176 param[param_pos++] = line[line_pos++];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
177 if (param_pos >= MAX_PARAM_LEN) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
178 PRINT_LINENUM;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
179 mp_msg(MSGT_CFGPARSER,MSGL_ERR,"too long parameter\n");
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
180 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
181 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
182 goto nextline;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
183 }
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 param[param_pos] = '\0';
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
187
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
188 /* did we read a parameter? */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
189 if (param_pos == 0) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
190 PRINT_LINENUM;
10245
a660de2556c2 1000l! crashing on broken config files finally fixed!
rfelker
parents: 9813
diff changeset
191 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
192 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
193 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
194 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
195 }
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 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
198 PRINT_LINENUM;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
199 mp_msg(MSGT_CFGPARSER,MSGL_V,"parameter: %s\n", param);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
200 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
201
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
202 /* now, check if we have some more chars on the line */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
203 /* whitespace... */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
204 while (isspace(line[line_pos]))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
205 ++line_pos;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
206
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
207 /* EOL / comment */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
208 if (line[line_pos] != '\0' && line[line_pos] != '#') {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
209 PRINT_LINENUM;
9578
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
210 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
211 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
212 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
213
17471
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
214 if(profile) {
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
215 if(!strcmp(opt,"profile-desc"))
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
216 m_profile_set_desc(profile,param), tmp = 1;
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
217 else
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
218 tmp = m_config_set_profile_option(config,profile,
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
219 opt,param);
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
220 } else
63909962d3fc Profiles support.
albeu
parents: 13946
diff changeset
221 tmp = m_config_set_option(config, opt, param);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
222 if (tmp < 0) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
223 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
224 if(tmp == M_OPT_UNKNOWN) {
9578
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
225 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
226 continue;
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
227 }
0c5454233dcf Better error messages (with line number now) and make unknow option
albeu
parents: 8164
diff changeset
228 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
229 ret = -1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
230 errors++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
231 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
232 /* break */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
233 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
234 nextline:
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
235 ;
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 free(line);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
239 fclose(fp);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
240 out:
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
241 config->mode = prev_mode;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
242 --recursion_depth;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
243 return ret;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
244 }
18265
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
245
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 17471
diff changeset
246 ///@}