Mercurial > mplayer.hg
annotate m_option.c @ 28759:af274aef6b81
Add a 64 bit integer type to the suboption parser.
author | reimar |
---|---|
date | Mon, 02 Mar 2009 11:17:50 +0000 |
parents | f8625bfd9aa5 |
children | d5e0b9e3cefc |
rev | line source |
---|---|
18258 | 1 |
2 /// \file | |
3 /// \ingroup Options | |
4 | |
8164 | 5 #include "config.h" |
6 | |
7 #include <stdlib.h> | |
8 #include <string.h> | |
9 #include <math.h> | |
10 #include <stdio.h> | |
11 #include <stdarg.h> | |
12 #include <inttypes.h> | |
8262 | 13 #include <unistd.h> |
8164 | 14 |
15 #include "m_option.h" | |
16 //#include "m_config.h" | |
17 #include "mp_msg.h" | |
19271
64d82a45a05d
introduce new 'stream' directory for all stream layer related components and split them from libmpdemux
ben
parents:
19194
diff
changeset
|
18 #include "stream/url.h" |
23703
9fb716ab06a3
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents:
23423
diff
changeset
|
19 #include "libavutil/avstring.h" |
8164 | 20 |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
21 // Don't free for 'production' atm |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
22 #ifndef MP_DEBUG |
16425
7ca9d8c0ae47
Do not define NO_FREE, it causes a giant memleak with -loop 0 and a short file.
reimar
parents:
16345
diff
changeset
|
23 //#define NO_FREE |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
24 #endif |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
25 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
26 const m_option_t* m_option_list_find(const m_option_t* list,const char* name) { |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
27 int i; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
28 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
29 for(i = 0 ; list[i].name ; i++) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
30 int l = strlen(list[i].name) - 1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
31 if((list[i].type->flags & M_OPT_TYPE_ALLOW_WILDCARD) && |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
32 (l > 0) && (list[i].name[l] == '*')) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
33 if(strncasecmp(list[i].name,name,l) == 0) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
34 return &list[i]; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
35 } else if(strcasecmp(list[i].name,name) == 0) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
36 return &list[i]; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
37 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
38 return NULL; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
39 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
40 |
10641 | 41 // Default function that just does a memcpy |
8164 | 42 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
43 static void copy_opt(const m_option_t* opt,void* dst,void* src) { |
8164 | 44 if(dst && src) |
45 memcpy(dst,src,opt->type->size); | |
46 } | |
47 | |
48 // Helper for the print funcs (from man printf) | |
49 static char* dup_printf(const char *fmt, ...) { | |
50 /* Guess we need no more than 50 bytes. */ | |
51 int n, size = 50; | |
52 char *p; | |
53 va_list ap; | |
54 if ((p = malloc (size)) == NULL) | |
55 return NULL; | |
56 while (1) { | |
57 /* Try to print in the allocated space. */ | |
58 va_start(ap, fmt); | |
59 n = vsnprintf (p, size, fmt, ap); | |
60 va_end(ap); | |
61 /* If that worked, return the string. */ | |
62 if (n > -1 && n < size) | |
63 return p; | |
64 /* Else try again with more space. */ | |
65 if (n > -1) /* glibc 2.1 */ | |
66 size = n+1; /* precisely what is needed */ | |
67 else /* glibc 2.0 */ | |
68 size *= 2; /* twice the old size */ | |
69 if ((p = realloc (p, size)) == NULL) | |
70 return NULL; | |
71 } | |
72 } | |
73 | |
74 | |
75 // Flag | |
76 | |
77 #define VAL(x) (*(int*)(x)) | |
78 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
79 static int parse_flag(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
8164 | 80 if (src == M_CONFIG_FILE) { |
10355
b39a943c902f
Fix the segfault in case of missing arg for flag options
albeu
parents:
10236
diff
changeset
|
81 if(!param) return M_OPT_MISSING_PARAM; |
8164 | 82 if (!strcasecmp(param, "yes") || /* any other language? */ |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
83 !strcasecmp(param, "on") || |
8164 | 84 !strcasecmp(param, "ja") || |
85 !strcasecmp(param, "si") || | |
86 !strcasecmp(param, "igen") || | |
87 !strcasecmp(param, "y") || | |
88 !strcasecmp(param, "j") || | |
89 !strcasecmp(param, "i") || | |
11781 | 90 !strcasecmp(param, "tak") || |
11785 | 91 !strcasecmp(param, "ja") || |
12775 | 92 !strcasecmp(param, "true") || |
8164 | 93 !strcmp(param, "1")) { |
94 if(dst) VAL(dst) = opt->max; | |
95 } else if (!strcasecmp(param, "no") || | |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
96 !strcasecmp(param, "off") || |
8164 | 97 !strcasecmp(param, "nein") || |
98 !strcasecmp(param, "nicht") || | |
99 !strcasecmp(param, "nem") || | |
100 !strcasecmp(param, "n") || | |
11781 | 101 !strcasecmp(param, "nie") || |
11785 | 102 !strcasecmp(param, "nej") || |
12775 | 103 !strcasecmp(param, "false") || |
8164 | 104 !strcmp(param, "0")) { |
105 if(dst) VAL(dst) = opt->min; | |
106 } else { | |
10641 | 107 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Invalid parameter for %s flag: %s\n",name, param); |
8164 | 108 return M_OPT_INVALID; |
109 } | |
110 return 1; | |
111 } else { | |
112 if(dst) VAL(dst) = opt->max; | |
113 return 0; | |
114 } | |
115 } | |
116 | |
25229
4f611a555224
Option print functions may not and do not modify value
reimar
parents:
24966
diff
changeset
|
117 static char* print_flag(const m_option_t* opt, const void* val) { |
8164 | 118 if(VAL(val) == opt->min) |
119 return strdup("no"); | |
120 else | |
121 return strdup("yes"); | |
122 } | |
123 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
124 const m_option_type_t m_option_type_flag = { |
8164 | 125 "Flag", |
126 "need yes or no in config files", | |
127 sizeof(int), | |
128 0, | |
129 parse_flag, | |
130 print_flag, | |
131 copy_opt, | |
132 copy_opt, | |
133 NULL, | |
134 NULL | |
135 }; | |
136 | |
137 // Integer | |
138 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
139 static int parse_int(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
28758
f8625bfd9aa5
Use strtoll in parse_int to avoid discrepancies between 32 and 64 bit systems.
reimar
parents:
28757
diff
changeset
|
140 long long tmp_int; |
8164 | 141 char *endptr; |
142 src = 0; | |
143 | |
144 if (param == NULL) | |
145 return M_OPT_MISSING_PARAM; | |
146 | |
28758
f8625bfd9aa5
Use strtoll in parse_int to avoid discrepancies between 32 and 64 bit systems.
reimar
parents:
28757
diff
changeset
|
147 tmp_int = strtoll(param, &endptr, 10); |
18718
7ef29a590f3f
Do not parse numbers as octal, strip leading zeroes instead.
reimar
parents:
18258
diff
changeset
|
148 if (*endptr) |
28758
f8625bfd9aa5
Use strtoll in parse_int to avoid discrepancies between 32 and 64 bit systems.
reimar
parents:
28757
diff
changeset
|
149 tmp_int = strtoll(param, &endptr, 0); |
8164 | 150 if (*endptr) { |
151 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "The %s option must be an integer: %s\n",name, param); | |
152 return M_OPT_INVALID; | |
153 } | |
154 | |
155 if ((opt->flags & M_OPT_MIN) && (tmp_int < opt->min)) { | |
156 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "The %s option must be >= %d: %s\n", name, (int) opt->min, param); | |
157 return M_OPT_OUT_OF_RANGE; | |
158 } | |
159 | |
160 if ((opt->flags & M_OPT_MAX) && (tmp_int > opt->max)) { | |
161 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "The %s option must be <= %d: %s\n",name, (int) opt->max, param); | |
162 return M_OPT_OUT_OF_RANGE; | |
163 } | |
164 | |
28759
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
165 if(dst) { |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
166 if (opt->type->size == sizeof(int64_t)) |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
167 *(int64_t *)dst = tmp_int; |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
168 else |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
169 VAL(dst) = tmp_int; |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
170 } |
8164 | 171 |
172 return 1; | |
173 } | |
174 | |
25229
4f611a555224
Option print functions may not and do not modify value
reimar
parents:
24966
diff
changeset
|
175 static char* print_int(const m_option_t* opt, const void* val) { |
8164 | 176 opt = NULL; |
28759
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
177 if (opt->type->size == sizeof(int64_t)) |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
178 return dup_printf("%"PRId64, *(const int64_t *)val); |
8164 | 179 return dup_printf("%d",VAL(val)); |
180 } | |
181 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
182 const m_option_type_t m_option_type_int = { |
8164 | 183 "Integer", |
184 "", | |
185 sizeof(int), | |
186 0, | |
187 parse_int, | |
188 print_int, | |
189 copy_opt, | |
190 copy_opt, | |
191 NULL, | |
192 NULL | |
193 }; | |
194 | |
28759
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
195 const m_option_type_t m_option_type_int64 = { |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
196 "Integer64", |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
197 "", |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
198 sizeof(int64_t), |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
199 0, |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
200 parse_int, |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
201 print_int, |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
202 copy_opt, |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
203 copy_opt, |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
204 NULL, |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
205 NULL |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
206 }; |
af274aef6b81
Add a 64 bit integer type to the suboption parser.
reimar
parents:
28758
diff
changeset
|
207 |
8164 | 208 // Float |
209 | |
210 #undef VAL | |
11947 | 211 #define VAL(x) (*(double*)(x)) |
8164 | 212 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
213 static int parse_double(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
11947 | 214 double tmp_float; |
8164 | 215 char* endptr; |
216 src = 0; | |
217 | |
218 if (param == NULL) | |
219 return M_OPT_MISSING_PARAM; | |
220 | |
221 tmp_float = strtod(param, &endptr); | |
222 | |
223 switch(*endptr) { | |
224 case ':': | |
225 case '/': | |
226 tmp_float /= strtod(endptr+1, &endptr); | |
227 break; | |
228 case '.': | |
229 case ',': | |
230 /* we also handle floats specified with | |
231 * non-locale decimal point ::atmos | |
232 */ | |
233 if(tmp_float<0) | |
234 tmp_float -= 1.0/pow(10,strlen(endptr+1)) * strtod(endptr+1, &endptr); | |
235 else | |
236 tmp_float += 1.0/pow(10,strlen(endptr+1)) * strtod(endptr+1, &endptr); | |
237 break; | |
238 } | |
239 | |
240 if (*endptr) { | |
241 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "The %s option must be a floating point " | |
242 "number or a ratio (numerator[:/]denominator): %s\n",name, param); | |
243 return M_OPT_INVALID; | |
244 } | |
245 | |
246 if (opt->flags & M_OPT_MIN) | |
247 if (tmp_float < opt->min) { | |
248 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "The %s option must be >= %f: %s\n", name, opt->min, param); | |
249 return M_OPT_OUT_OF_RANGE; | |
250 } | |
251 | |
252 if (opt->flags & M_OPT_MAX) | |
253 if (tmp_float > opt->max) { | |
254 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "The %s option must be <= %f: %s\n", name, opt->max, param); | |
255 return M_OPT_OUT_OF_RANGE; | |
256 } | |
257 | |
258 if(dst) VAL(dst) = tmp_float; | |
259 return 1; | |
260 } | |
261 | |
25229
4f611a555224
Option print functions may not and do not modify value
reimar
parents:
24966
diff
changeset
|
262 static char* print_double(const m_option_t* opt, const void* val) { |
11947 | 263 opt = NULL; |
264 return dup_printf("%f",VAL(val)); | |
265 } | |
266 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
267 const m_option_type_t m_option_type_double = { |
11947 | 268 "Double", |
269 "double precission floating point number or ratio (numerator[:/]denominator)", | |
270 sizeof(double), | |
271 0, | |
272 parse_double, | |
273 print_double, | |
274 copy_opt, | |
275 copy_opt, | |
276 NULL, | |
277 NULL | |
278 }; | |
279 | |
280 #undef VAL | |
281 #define VAL(x) (*(float*)(x)) | |
282 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
283 static int parse_float(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
11947 | 284 double tmp; |
285 int r= parse_double(opt, name, param, &tmp, src); | |
286 if(r==1 && dst) VAL(dst) = tmp; | |
11950 | 287 return r; |
11947 | 288 } |
289 | |
25229
4f611a555224
Option print functions may not and do not modify value
reimar
parents:
24966
diff
changeset
|
290 static char* print_float(const m_option_t* opt, const void* val) { |
8164 | 291 opt = NULL; |
292 return dup_printf("%f",VAL(val)); | |
293 } | |
294 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
295 const m_option_type_t m_option_type_float = { |
8164 | 296 "Float", |
297 "floating point number or ratio (numerator[:/]denominator)", | |
298 sizeof(float), | |
299 0, | |
300 parse_float, | |
301 print_float, | |
302 copy_opt, | |
303 copy_opt, | |
304 NULL, | |
305 NULL | |
306 }; | |
307 | |
308 ///////////// Position | |
309 #undef VAL | |
310 #define VAL(x) (*(off_t*)(x)) | |
311 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
312 static int parse_position(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
8164 | 313 off_t tmp_off; |
314 char dummy; | |
315 | |
316 if (param == NULL) | |
317 return M_OPT_MISSING_PARAM; | |
318 if (sscanf(param, sizeof(off_t) == sizeof(int) ? | |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16741
diff
changeset
|
319 "%d%c" : "%"PRId64"%c", &tmp_off, &dummy) != 1) { |
8164 | 320 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "The %s option must be an integer: %s\n",opt->name,param); |
321 return M_OPT_INVALID; | |
322 } | |
323 | |
324 if (opt->flags & M_OPT_MIN) | |
325 if (tmp_off < opt->min) { | |
326 mp_msg(MSGT_CFGPARSER, MSGL_ERR, | |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16741
diff
changeset
|
327 "The %s option must be >= %"PRId64": %s\n", |
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16741
diff
changeset
|
328 name, (int64_t) opt->min, param); |
8164 | 329 return M_OPT_OUT_OF_RANGE; |
330 } | |
331 | |
332 if (opt->flags & M_OPT_MAX) | |
333 if (tmp_off > opt->max) { | |
334 mp_msg(MSGT_CFGPARSER, MSGL_ERR, | |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16741
diff
changeset
|
335 "The %s option must be <= %"PRId64": %s\n", |
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16741
diff
changeset
|
336 name, (int64_t) opt->max, param); |
8164 | 337 return M_OPT_OUT_OF_RANGE; |
338 } | |
339 | |
340 if(dst) | |
341 VAL(dst) = tmp_off; | |
342 return 1; | |
343 } | |
344 | |
25229
4f611a555224
Option print functions may not and do not modify value
reimar
parents:
24966
diff
changeset
|
345 static char* print_position(const m_option_t* opt, const void* val) { |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16741
diff
changeset
|
346 return dup_printf("%"PRId64,(int64_t)VAL(val)); |
8164 | 347 } |
348 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
349 const m_option_type_t m_option_type_position = { |
8164 | 350 "Position", |
351 "Integer (off_t)", | |
352 sizeof(off_t), | |
353 0, | |
354 parse_position, | |
355 print_position, | |
356 copy_opt, | |
357 copy_opt, | |
358 NULL, | |
359 NULL | |
360 }; | |
361 | |
362 | |
363 ///////////// String | |
364 | |
365 #undef VAL | |
366 #define VAL(x) (*(char**)(x)) | |
367 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
368 static int parse_str(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
8164 | 369 |
370 | |
371 if (param == NULL) | |
372 return M_OPT_MISSING_PARAM; | |
373 | |
374 if ((opt->flags & M_OPT_MIN) && (strlen(param) < opt->min)) { | |
10641 | 375 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Parameter must be >= %d chars: %s\n", |
8164 | 376 (int) opt->min, param); |
377 return M_OPT_OUT_OF_RANGE; | |
378 } | |
379 | |
380 if ((opt->flags & M_OPT_MAX) && (strlen(param) > opt->max)) { | |
10641 | 381 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Parameter must be <= %d chars: %s\n", |
8164 | 382 (int) opt->max, param); |
383 return M_OPT_OUT_OF_RANGE; | |
384 } | |
385 | |
386 if(dst) { | |
387 if(VAL(dst)) | |
388 free(VAL(dst)); | |
389 VAL(dst) = strdup(param); | |
390 } | |
391 | |
392 return 1; | |
393 | |
394 } | |
395 | |
25229
4f611a555224
Option print functions may not and do not modify value
reimar
parents:
24966
diff
changeset
|
396 static char* print_str(const m_option_t* opt, const void* val) { |
8168 | 397 return (val && VAL(val) && strlen(VAL(val)) > 0) ? strdup(VAL(val)) : NULL; |
8164 | 398 } |
399 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
400 static void copy_str(const m_option_t* opt,void* dst, void* src) { |
8164 | 401 if(dst && src) { |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
402 #ifndef NO_FREE |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
403 if(VAL(dst)) free(VAL(dst)); //FIXME!!! |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
404 #endif |
8164 | 405 VAL(dst) = VAL(src) ? strdup(VAL(src)) : NULL; |
406 } | |
407 } | |
408 | |
409 static void free_str(void* src) { | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
410 if(src && VAL(src)){ |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
411 #ifndef NO_FREE |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
412 free(VAL(src)); //FIXME!!! |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
413 #endif |
8164 | 414 VAL(src) = NULL; |
415 } | |
416 } | |
417 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
418 const m_option_type_t m_option_type_string = { |
8164 | 419 "String", |
420 "", | |
421 sizeof(char*), | |
422 M_OPT_TYPE_DYNAMIC, | |
423 parse_str, | |
424 print_str, | |
425 copy_str, | |
426 copy_str, | |
427 copy_str, | |
428 free_str | |
429 }; | |
430 | |
431 //////////// String list | |
432 | |
433 #define LIST_SEPARATOR ',' | |
434 #undef VAL | |
435 #define VAL(x) (*(char***)(x)) | |
436 | |
437 #define OP_NONE 0 | |
438 #define OP_ADD 1 | |
439 #define OP_PRE 2 | |
440 #define OP_DEL 3 | |
441 #define OP_CLR 4 | |
442 | |
443 static void free_str_list(void* dst) { | |
444 char** d; | |
445 int i; | |
446 | |
447 if(!dst || !VAL(dst)) return; | |
448 d = VAL(dst); | |
449 | |
9177
01a713dcaf23
disable free() in string and string_list parsers. yes, it's a hack
arpi
parents:
8736
diff
changeset
|
450 // FIXME!!! |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
451 #ifndef NO_FREE |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
452 for(i = 0 ; d[i] != NULL ; i++) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
453 free(d[i]); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
454 free(d); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
455 #endif |
8164 | 456 VAL(dst) = NULL; |
457 } | |
458 | |
459 static int str_list_add(char** add, int n,void* dst,int pre) { | |
460 char** lst = VAL(dst); | |
461 int ln; | |
462 | |
463 if(!dst) return M_OPT_PARSER_ERR; | |
464 lst = VAL(dst); | |
465 | |
466 for(ln = 0 ; lst && lst[ln] ; ln++) | |
467 /**/; | |
468 | |
469 lst = realloc(lst,(n+ln+1)*sizeof(char*)); | |
470 | |
471 if(pre) { | |
472 memmove(&lst[n],lst,(ln+1)*sizeof(char*)); | |
473 memcpy(lst,add,n*sizeof(char*)); | |
474 } else | |
475 memcpy(&lst[ln],add,(n+1)*sizeof(char*)); | |
476 | |
477 free(add); | |
478 | |
479 VAL(dst) = lst; | |
480 | |
481 return 1; | |
482 } | |
483 | |
484 static int str_list_del(char** del, int n,void* dst) { | |
485 char **lst,*ep,**d; | |
486 int i,ln,s; | |
487 long idx; | |
488 | |
489 if(!dst) return M_OPT_PARSER_ERR; | |
490 lst = VAL(dst); | |
491 | |
492 for(ln = 0 ; lst && lst[ln] ; ln++) | |
493 /**/; | |
494 s = ln; | |
495 | |
496 for(i = 0 ; del[i] != NULL ; i++) { | |
497 idx = strtol(del[i], &ep, 0); | |
498 if(*ep) { | |
499 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Invalid index: %s\n",del[i]); | |
500 free(del[i]); | |
501 continue; | |
502 } | |
503 free(del[i]); | |
504 if(idx < 0 || idx >= ln) { | |
10641 | 505 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Index %ld is out of range.\n",idx); |
8164 | 506 continue; |
507 } else if(!lst[idx]) | |
508 continue; | |
509 free(lst[idx]); | |
510 lst[idx] = NULL; | |
511 s--; | |
512 } | |
513 free(del); | |
514 | |
515 if(s == 0) { | |
516 if(lst) free(lst); | |
517 VAL(dst) = NULL; | |
518 return 1; | |
519 } | |
520 | |
521 d = calloc(s+1,sizeof(char*)); | |
522 for(i = 0, n = 0 ; i < ln ; i++) { | |
523 if(!lst[i]) continue; | |
524 d[n] = lst[i]; | |
525 n++; | |
526 } | |
527 d[s] = NULL; | |
528 | |
529 if(lst) free(lst); | |
530 VAL(dst) = d; | |
531 | |
532 return 1; | |
533 } | |
534 | |
22133 | 535 static char *get_nextsep(char *ptr, char sep, int modify) { |
536 char *last_ptr = ptr; | |
537 for(;;){ | |
538 ptr = strchr(ptr, sep); | |
539 if(ptr && ptr>last_ptr && ptr[-1]=='\\'){ | |
540 if (modify) memmove(ptr-1, ptr, strlen(ptr)+1); | |
541 else ptr++; | |
542 }else | |
543 break; | |
544 } | |
545 return ptr; | |
546 } | |
8164 | 547 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
548 static int parse_str_list(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
8164 | 549 int n = 0,len = strlen(opt->name); |
22133 | 550 char *str; |
8164 | 551 char *ptr = param, *last_ptr, **res; |
552 int op = OP_NONE; | |
553 | |
554 if(opt->name[len-1] == '*' && ((int)strlen(name) > len - 1)) { | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
555 const char* n = &name[len-1]; |
8164 | 556 if(strcasecmp(n,"-add") == 0) |
557 op = OP_ADD; | |
558 else if(strcasecmp(n,"-pre") == 0) | |
559 op = OP_PRE; | |
560 else if(strcasecmp(n,"-del") == 0) | |
561 op = OP_DEL; | |
562 else if(strcasecmp(n,"-clr") == 0) | |
563 op = OP_CLR; | |
564 else | |
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
|
565 return M_OPT_UNKNOWN; |
8164 | 566 } |
567 | |
568 // Clear the list ?? | |
569 if(op == OP_CLR) { | |
570 if(dst) | |
571 free_str_list(dst); | |
572 return 0; | |
573 } | |
574 | |
10641 | 575 // All other ops need a param |
8164 | 576 if (param == NULL || strlen(param) == 0) |
577 return M_OPT_MISSING_PARAM; | |
578 | |
579 | |
580 while(ptr[0] != '\0') { | |
22133 | 581 ptr = get_nextsep(ptr, LIST_SEPARATOR, 0); |
8164 | 582 if(!ptr) { |
583 n++; | |
584 break; | |
585 } | |
586 ptr++; | |
587 n++; | |
588 } | |
589 if(n == 0) | |
590 return M_OPT_INVALID; | |
591 if( ((opt->flags & M_OPT_MIN) && (n < opt->min)) || | |
592 ((opt->flags & M_OPT_MAX) && (n > opt->max)) ) | |
593 return M_OPT_OUT_OF_RANGE; | |
594 | |
595 if(!dst) return 1; | |
596 | |
8384
7a7980b874f5
fixed 'mplayer -nosound xxx' sig11 if configfile have string list options
arpi
parents:
8262
diff
changeset
|
597 res = malloc((n+2)*sizeof(char*)); |
22133 | 598 ptr = str = strdup(param); |
8164 | 599 n = 0; |
600 | |
601 while(1) { | |
602 last_ptr = ptr; | |
22133 | 603 ptr = get_nextsep(ptr, LIST_SEPARATOR, 1); |
8164 | 604 if(!ptr) { |
605 res[n] = strdup(last_ptr); | |
606 n++; | |
607 break; | |
608 } | |
609 len = ptr - last_ptr; | |
18869 | 610 res[n] = malloc(len + 1); |
8164 | 611 if(len) strncpy(res[n],last_ptr,len); |
612 res[n][len] = '\0'; | |
613 ptr++; | |
614 n++; | |
615 } | |
616 res[n] = NULL; | |
22133 | 617 free(str); |
8164 | 618 |
619 switch(op) { | |
620 case OP_ADD: | |
621 return str_list_add(res,n,dst,0); | |
622 case OP_PRE: | |
623 return str_list_add(res,n,dst,1); | |
624 case OP_DEL: | |
625 return str_list_del(res,n,dst); | |
626 } | |
627 | |
628 if(VAL(dst)) | |
629 free_str_list(dst); | |
630 VAL(dst) = res; | |
631 | |
632 return 1; | |
633 } | |
634 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
635 static void copy_str_list(const m_option_t* opt,void* dst, void* src) { |
8164 | 636 int n; |
637 char **d,**s; | |
638 | |
639 if(!(dst && src)) return; | |
640 s = VAL(src); | |
641 | |
642 if(VAL(dst)) | |
643 free_str_list(dst); | |
644 | |
645 if(!s) { | |
646 VAL(dst) = NULL; | |
647 return; | |
648 } | |
649 | |
650 for(n = 0 ; s[n] != NULL ; n++) | |
651 /* NOTHING */; | |
18869 | 652 d = malloc((n+1)*sizeof(char*)); |
8164 | 653 for( ; n >= 0 ; n--) |
654 d[n] = s[n] ? strdup(s[n]) : NULL; | |
655 | |
656 VAL(dst) = d; | |
657 } | |
658 | |
25229
4f611a555224
Option print functions may not and do not modify value
reimar
parents:
24966
diff
changeset
|
659 static char* print_str_list(const m_option_t* opt, const void* src) { |
8168 | 660 char **lst = NULL; |
661 char *ret = NULL,*last = NULL; | |
662 int i; | |
663 | |
664 if(!(src && VAL(src))) return NULL; | |
665 lst = VAL(src); | |
666 | |
667 for(i = 0 ; lst[i] ; i++) { | |
668 if(last) { | |
669 ret = dup_printf("%s,%s",last,lst[i]); | |
670 free(last); | |
671 } else | |
672 ret = strdup(lst[i]); | |
673 last = ret; | |
674 } | |
675 if(last && last != ret) free(last); | |
676 return ret; | |
8164 | 677 } |
678 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
679 const m_option_type_t m_option_type_string_list = { |
8164 | 680 "String list", |
10641 | 681 "A list of strings separated by ','\n" |
682 "Option with a name ending in an * permits using the following suffix: \n" | |
683 "\t-add: Add the given parameters at the end of the list.\n" | |
25489 | 684 "\t-pre: Add the given parameters at the beginning of the list.\n" |
10641 | 685 "\t-del: Remove the entry at the given indices.\n" |
686 "\t-clr: Clear the list.\n" | |
11261 | 687 "e.g: -vf-add flip,mirror -vf-del 2,5\n", |
8164 | 688 sizeof(char**), |
689 M_OPT_TYPE_DYNAMIC | M_OPT_TYPE_ALLOW_WILDCARD, | |
690 parse_str_list, | |
691 print_str_list, | |
692 copy_str_list, | |
693 copy_str_list, | |
694 copy_str_list, | |
695 free_str_list | |
696 }; | |
697 | |
698 | |
699 /////////////////// Func based options | |
700 | |
701 // A chained list to save the various calls for func_param and func_full | |
702 typedef struct m_func_save m_func_save_t; | |
703 struct m_func_save { | |
704 m_func_save_t* next; | |
705 char* name; | |
706 char* param; | |
707 }; | |
708 | |
709 #undef VAL | |
710 #define VAL(x) (*(m_func_save_t**)(x)) | |
711 | |
712 static void free_func_pf(void* src) { | |
713 m_func_save_t *s,*n; | |
714 | |
715 if(!src) return; | |
716 | |
717 s = VAL(src); | |
718 | |
719 while(s) { | |
720 n = s->next; | |
721 free(s->name); | |
722 if(s->param) free(s->param); | |
723 free(s); | |
724 s = n; | |
725 } | |
726 VAL(src) = NULL; | |
727 } | |
728 | |
729 // Parser for func_param and func_full | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
730 static int parse_func_pf(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
8164 | 731 m_func_save_t *s,*p; |
732 | |
733 if(!dst) | |
734 return 1; | |
735 | |
18879 | 736 s = calloc(1,sizeof(m_func_save_t)); |
8164 | 737 s->name = strdup(name); |
738 s->param = param ? strdup(param) : NULL; | |
739 | |
740 p = VAL(dst); | |
741 if(p) { | |
742 for( ; p->next != NULL ; p = p->next) | |
743 /**/; | |
744 p->next = s; | |
745 } else | |
746 VAL(dst) = s; | |
747 | |
748 return 1; | |
749 } | |
750 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
751 static void copy_func_pf(const m_option_t* opt,void* dst, void* src) { |
8164 | 752 m_func_save_t *d = NULL, *s,* last = NULL; |
753 | |
754 if(!(dst && src)) return; | |
755 s = VAL(src); | |
756 | |
757 if(VAL(dst)) | |
758 free_func_pf(dst); | |
759 | |
760 while(s) { | |
18879 | 761 d = calloc(1,sizeof(m_func_save_t)); |
8164 | 762 d->name = strdup(s->name); |
763 d->param = s->param ? strdup(s->param) : NULL; | |
764 if(last) | |
765 last->next = d; | |
766 else | |
767 VAL(dst) = d; | |
768 last = d; | |
769 s = s->next; | |
770 } | |
771 | |
772 | |
773 } | |
774 | |
775 /////////////////// Func_param | |
776 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
777 static void set_func_param(const m_option_t* opt, void* dst, void* src) { |
8164 | 778 m_func_save_t* s; |
779 | |
780 if(!src) return; | |
781 s = VAL(src); | |
782 | |
783 if(!s) return; | |
784 | |
785 // Revert if needed | |
786 if(opt->priv) ((m_opt_default_func_t)opt->priv)(opt,opt->name); | |
787 for( ; s != NULL ; s = s->next) | |
788 ((m_opt_func_param_t) opt->p)(opt,s->param); | |
789 } | |
790 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
791 const m_option_type_t m_option_type_func_param = { |
8164 | 792 "Func param", |
793 "", | |
794 sizeof(m_func_save_t*), | |
795 M_OPT_TYPE_INDIRECT, | |
796 parse_func_pf, | |
797 NULL, | |
798 NULL, // Nothing to do on save | |
799 set_func_param, | |
800 copy_func_pf, | |
801 free_func_pf | |
802 }; | |
803 | |
804 /////////////////// Func_full | |
805 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
806 static void set_func_full(const m_option_t* opt, void* dst, void* src) { |
8164 | 807 m_func_save_t* s; |
808 | |
809 if(!src) return; | |
810 | |
811 for(s = VAL(src) ; s ; s = s->next) { | |
812 // Revert if needed | |
813 if(opt->priv) ((m_opt_default_func_t)opt->priv)(opt,s->name); | |
814 ((m_opt_func_full_t) opt->p)(opt,s->name,s->param); | |
815 } | |
816 } | |
817 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
818 const m_option_type_t m_option_type_func_full = { |
8164 | 819 "Func full", |
820 "", | |
821 sizeof(m_func_save_t*), | |
822 M_OPT_TYPE_ALLOW_WILDCARD|M_OPT_TYPE_INDIRECT, | |
823 parse_func_pf, | |
824 NULL, | |
825 NULL, // Nothing to do on save | |
826 set_func_full, | |
827 copy_func_pf, | |
828 free_func_pf | |
829 }; | |
830 | |
831 /////////////// Func | |
832 | |
833 #undef VAL | |
834 #define VAL(x) (*(int*)(x)) | |
835 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
836 static int parse_func(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
8164 | 837 if(dst) |
838 VAL(dst) += 1; | |
839 return 0; | |
840 } | |
841 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
842 static void set_func(const m_option_t* opt,void* dst, void* src) { |
8164 | 843 int i; |
844 if(opt->priv) ((m_opt_default_func_t)opt->priv)(opt,opt->name); | |
845 for(i = 0 ; i < VAL(src) ; i++) | |
846 ((m_opt_func_t) opt->p)(opt); | |
847 } | |
848 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
849 const m_option_type_t m_option_type_func = { |
8164 | 850 "Func", |
851 "", | |
852 sizeof(int), | |
853 M_OPT_TYPE_INDIRECT, | |
854 parse_func, | |
855 NULL, | |
856 NULL, // Nothing to do on save | |
857 set_func, | |
858 NULL, | |
859 NULL | |
860 }; | |
861 | |
862 /////////////////// Print | |
863 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
864 static int parse_print(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
17468
41d8991c3632
Fix misuse of the M_OPT_TYPE_INDIRECT flag, it has nothing to do
albeu
parents:
16854
diff
changeset
|
865 if(opt->type == CONF_TYPE_PRINT_INDIRECT) |
8736 | 866 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "%s", *(char **) opt->p); |
17470
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
867 else if(opt->type == CONF_TYPE_PRINT_FUNC) |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
868 return ((m_opt_func_full_t) opt->p)(opt,name,param); |
8736 | 869 else |
870 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "%s", (char *) opt->p); | |
871 | |
8164 | 872 if(opt->priv == NULL) |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
873 return M_OPT_EXIT; |
8164 | 874 return 1; |
875 } | |
876 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
877 const m_option_type_t m_option_type_print = { |
8164 | 878 "Print", |
879 "", | |
880 0, | |
881 0, | |
882 parse_print, | |
883 NULL, | |
884 NULL, | |
885 NULL, | |
886 NULL, | |
887 NULL | |
888 }; | |
889 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
890 const m_option_type_t m_option_type_print_indirect = { |
8736 | 891 "Print", |
892 "", | |
893 0, | |
17468
41d8991c3632
Fix misuse of the M_OPT_TYPE_INDIRECT flag, it has nothing to do
albeu
parents:
16854
diff
changeset
|
894 0, |
8736 | 895 parse_print, |
896 NULL, | |
897 NULL, | |
898 NULL, | |
899 NULL, | |
900 NULL | |
901 }; | |
902 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
903 const m_option_type_t m_option_type_print_func = { |
17470
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
904 "Print", |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
905 "", |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
906 0, |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
907 M_OPT_TYPE_ALLOW_WILDCARD, |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
908 parse_print, |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
909 NULL, |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
910 NULL, |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
911 NULL, |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
912 NULL, |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
913 NULL |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
914 }; |
21123e349463
New option type to print help text with a function.
albeu
parents:
17468
diff
changeset
|
915 |
8736 | 916 |
8164 | 917 /////////////////////// Subconfig |
918 #undef VAL | |
919 #define VAL(x) (*(char***)(x)) | |
920 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
921 static int parse_subconf(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
8164 | 922 char *subparam; |
923 char *subopt; | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
924 int nr = 0,i,r; |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
925 const m_option_t *subopts; |
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
926 const char *p; |
8164 | 927 char** lst = NULL; |
928 | |
929 if (param == NULL || strlen(param) == 0) | |
930 return M_OPT_MISSING_PARAM; | |
931 | |
932 subparam = malloc(strlen(param)+1); | |
933 subopt = malloc(strlen(param)+1); | |
16741
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
934 p = param; |
8164 | 935 |
936 subopts = opt->p; | |
937 | |
16741
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
938 while(p[0]) |
8164 | 939 { |
16741
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
940 int sscanf_ret = 1; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
941 int optlen = strcspn(p, ":="); |
8164 | 942 /* clear out */ |
943 subopt[0] = subparam[0] = 0; | |
23703
9fb716ab06a3
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents:
23423
diff
changeset
|
944 av_strlcpy(subopt, p, optlen + 1); |
16741
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
945 p = &p[optlen]; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
946 if (p[0] == '=') { |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
947 sscanf_ret = 2; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
948 p = &p[1]; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
949 if (p[0] == '"') { |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
950 p = &p[1]; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
951 optlen = strcspn(p, "\""); |
23703
9fb716ab06a3
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents:
23423
diff
changeset
|
952 av_strlcpy(subparam, p, optlen + 1); |
16741
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
953 p = &p[optlen]; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
954 if (p[0] != '"') { |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
955 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Terminating '\"' missing for '%s'\n", subopt); |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
956 return M_OPT_INVALID; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
957 } |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
958 p = &p[1]; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
959 } else if (p[0] == '%') { |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
960 p = &p[1]; |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
961 optlen = (int)strtol(p, (char**)&p, 0); |
16741
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
962 if (!p || p[0] != '%' || (optlen > strlen(p) - 1)) { |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
963 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Invalid length %i for '%s'\n", optlen, subopt); |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
964 return M_OPT_INVALID; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
965 } |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
966 p = &p[1]; |
23703
9fb716ab06a3
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents:
23423
diff
changeset
|
967 av_strlcpy(subparam, p, optlen + 1); |
16741
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
968 p = &p[optlen]; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
969 } else { |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
970 optlen = strcspn(p, ":"); |
23703
9fb716ab06a3
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents:
23423
diff
changeset
|
971 av_strlcpy(subparam, p, optlen + 1); |
16741
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
972 p = &p[optlen]; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
973 } |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
974 } |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
975 if (p[0] == ':') |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
976 p = &p[1]; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
977 else if (p[0]) { |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
978 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Incorrect termination for '%s'\n", subopt); |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
979 return M_OPT_INVALID; |
ec4a53c1c40b
Add support for suboption escaping via both "" and %n%str syntax
reimar
parents:
16425
diff
changeset
|
980 } |
8164 | 981 |
982 switch(sscanf_ret) | |
983 { | |
984 case 1: | |
985 subparam[0] = 0; | |
986 case 2: | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
987 for(i = 0 ; subopts[i].name ; i++) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
988 if(!strcmp(subopts[i].name,subopt)) break; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
989 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
990 if(!subopts[i].name) { |
10397 | 991 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Unknown suboption %s\n",name,subopt); |
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
|
992 return M_OPT_UNKNOWN; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
993 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
994 r = m_option_parse(&subopts[i],subopt, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
995 subparam[0] == 0 ? NULL : subparam,NULL,src); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
996 if(r < 0) return r; |
8164 | 997 if(dst) { |
998 lst = (char**)realloc(lst,2 * (nr+2) * sizeof(char*)); | |
999 lst[2*nr] = strdup(subopt); | |
1000 lst[2*nr+1] = subparam[0] == 0 ? NULL : strdup(subparam); | |
1001 memset(&lst[2*(nr+1)],0,2*sizeof(char*)); | |
1002 nr++; | |
1003 } | |
1004 break; | |
1005 } | |
1006 } | |
1007 | |
1008 free(subparam); | |
1009 free(subopt); | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1010 if(dst) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1011 VAL(dst) = lst; |
8164 | 1012 |
1013 return 1; | |
1014 } | |
1015 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1016 const m_option_type_t m_option_type_subconfig = { |
8164 | 1017 "Subconfig", |
1018 "The syntax is -option opt1=foo:flag:opt2=blah", | |
1019 sizeof(int), | |
1020 M_OPT_TYPE_HAS_CHILD, | |
1021 parse_subconf, | |
1022 NULL, | |
1023 NULL, | |
1024 NULL, | |
1025 NULL, | |
1026 NULL | |
1027 }; | |
1028 | |
1029 #include "libmpcodecs/img_format.h" | |
9600 | 1030 |
10746
0e5e55232e9d
added nv12/nv21 and some other fourccs (still not synced)
alex
parents:
10660
diff
changeset
|
1031 /* FIXME: snyc with img_format.h */ |
9600 | 1032 static struct { |
19194
5949a654e2d4
marks some read-only char* inside structs as const, patch by Stefan Huehner, stefan At huehner-org
reynaldo
parents:
19053
diff
changeset
|
1033 const char* name; |
9600 | 1034 unsigned int fmt; |
1035 } mp_imgfmt_list[] = { | |
1036 {"444p", IMGFMT_444P}, | |
1037 {"422p", IMGFMT_422P}, | |
1038 {"411p", IMGFMT_411P}, | |
1039 {"yuy2", IMGFMT_YUY2}, | |
10746
0e5e55232e9d
added nv12/nv21 and some other fourccs (still not synced)
alex
parents:
10660
diff
changeset
|
1040 {"uyvy", IMGFMT_UYVY}, |
0e5e55232e9d
added nv12/nv21 and some other fourccs (still not synced)
alex
parents:
10660
diff
changeset
|
1041 {"yvu9", IMGFMT_YVU9}, |
0e5e55232e9d
added nv12/nv21 and some other fourccs (still not synced)
alex
parents:
10660
diff
changeset
|
1042 {"if09", IMGFMT_IF09}, |
9600 | 1043 {"yv12", IMGFMT_YV12}, |
1044 {"i420", IMGFMT_I420}, | |
1045 {"iyuv", IMGFMT_IYUV}, | |
10746
0e5e55232e9d
added nv12/nv21 and some other fourccs (still not synced)
alex
parents:
10660
diff
changeset
|
1046 {"clpl", IMGFMT_CLPL}, |
11688 | 1047 {"hm12", IMGFMT_HM12}, |
10746
0e5e55232e9d
added nv12/nv21 and some other fourccs (still not synced)
alex
parents:
10660
diff
changeset
|
1048 {"y800", IMGFMT_Y800}, |
0e5e55232e9d
added nv12/nv21 and some other fourccs (still not synced)
alex
parents:
10660
diff
changeset
|
1049 {"y8", IMGFMT_Y8}, |
0e5e55232e9d
added nv12/nv21 and some other fourccs (still not synced)
alex
parents:
10660
diff
changeset
|
1050 {"nv12", IMGFMT_NV12}, |
0e5e55232e9d
added nv12/nv21 and some other fourccs (still not synced)
alex
parents:
10660
diff
changeset
|
1051 {"nv21", IMGFMT_NV21}, |
9600 | 1052 {"bgr24", IMGFMT_BGR24}, |
1053 {"bgr32", IMGFMT_BGR32}, | |
1054 {"bgr16", IMGFMT_BGR16}, | |
1055 {"bgr15", IMGFMT_BGR15}, | |
1056 {"bgr8", IMGFMT_BGR8}, | |
1057 {"bgr4", IMGFMT_BGR4}, | |
1058 {"bg4b", IMGFMT_BG4B}, | |
1059 {"bgr1", IMGFMT_BGR1}, | |
1060 {"rgb24", IMGFMT_RGB24}, | |
1061 {"rgb32", IMGFMT_RGB32}, | |
1062 {"rgb16", IMGFMT_RGB16}, | |
1063 {"rgb15", IMGFMT_RGB15}, | |
1064 {"rgb8", IMGFMT_RGB8}, | |
1065 {"rgb4", IMGFMT_RGB4}, | |
1066 {"rg4b", IMGFMT_RG4B}, | |
1067 {"rgb1", IMGFMT_RGB1}, | |
12999 | 1068 {"rgba", IMGFMT_RGBA}, |
1069 {"argb", IMGFMT_ARGB}, | |
1070 {"bgra", IMGFMT_BGRA}, | |
1071 {"abgr", IMGFMT_ABGR}, | |
23423 | 1072 {"mjpeg", IMGFMT_MJPEG}, |
1073 {"mjpg", IMGFMT_MJPEG}, | |
9600 | 1074 { NULL, 0 } |
1075 }; | |
8164 | 1076 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1077 static int parse_imgfmt(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
8164 | 1078 uint32_t fmt = 0; |
9600 | 1079 int i; |
8164 | 1080 |
1081 if (param == NULL || strlen(param) == 0) | |
1082 return M_OPT_MISSING_PARAM; | |
1083 | |
9600 | 1084 if(!strcmp(param,"help")) { |
10641 | 1085 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "Available formats:"); |
9600 | 1086 for(i = 0 ; mp_imgfmt_list[i].name ; i++) |
1087 mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s",mp_imgfmt_list[i].name); | |
1088 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n"); | |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15789
diff
changeset
|
1089 return M_OPT_EXIT - 1; |
9600 | 1090 } |
10597
697688503349
CONF_TYPE_IMGFMT now supports 0xffffffff (hexa)-style fourccs too
alex
parents:
10595
diff
changeset
|
1091 |
697688503349
CONF_TYPE_IMGFMT now supports 0xffffffff (hexa)-style fourccs too
alex
parents:
10595
diff
changeset
|
1092 if (sscanf(param, "0x%x", &fmt) != 1) |
697688503349
CONF_TYPE_IMGFMT now supports 0xffffffff (hexa)-style fourccs too
alex
parents:
10595
diff
changeset
|
1093 { |
9600 | 1094 for(i = 0 ; mp_imgfmt_list[i].name ; i++) { |
1095 if(!strcasecmp(param,mp_imgfmt_list[i].name)) { | |
1096 fmt=mp_imgfmt_list[i].fmt; | |
1097 break; | |
1098 } | |
1099 } | |
1100 if(!mp_imgfmt_list[i].name) { | |
1101 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: unknown format name: '%s'\n",name,param); | |
8164 | 1102 return M_OPT_INVALID; |
1103 } | |
10597
697688503349
CONF_TYPE_IMGFMT now supports 0xffffffff (hexa)-style fourccs too
alex
parents:
10595
diff
changeset
|
1104 } |
8164 | 1105 |
1106 if(dst) | |
1107 *((uint32_t*)dst) = fmt; | |
1108 | |
1109 return 1; | |
1110 } | |
1111 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1112 const m_option_type_t m_option_type_imgfmt = { |
9600 | 1113 "Image format", |
10641 | 1114 "Please report any missing colorspaces.", |
8164 | 1115 sizeof(uint32_t), |
1116 0, | |
1117 parse_imgfmt, | |
1118 NULL, | |
1119 copy_opt, | |
1120 copy_opt, | |
1121 NULL, | |
1122 NULL | |
1123 }; | |
1124 | |
14246 | 1125 #include "libaf/af_format.h" |
1126 | |
1127 /* FIXME: snyc with af_format.h */ | |
1128 static struct { | |
19194
5949a654e2d4
marks some read-only char* inside structs as const, patch by Stefan Huehner, stefan At huehner-org
reynaldo
parents:
19053
diff
changeset
|
1129 const char* name; |
14246 | 1130 unsigned int fmt; |
1131 } mp_afmt_list[] = { | |
1132 // SPECIAL | |
1133 {"mulaw", AF_FORMAT_MU_LAW}, | |
1134 {"alaw", AF_FORMAT_A_LAW}, | |
1135 {"mpeg2", AF_FORMAT_MPEG2}, | |
1136 {"ac3", AF_FORMAT_AC3}, | |
1137 {"imaadpcm", AF_FORMAT_IMA_ADPCM}, | |
1138 // ORIDNARY | |
1139 {"u8", AF_FORMAT_U8}, | |
1140 {"s8", AF_FORMAT_S8}, | |
1141 {"u16le", AF_FORMAT_U16_LE}, | |
1142 {"u16be", AF_FORMAT_U16_BE}, | |
1143 {"u16ne", AF_FORMAT_U16_NE}, | |
1144 {"s16le", AF_FORMAT_S16_LE}, | |
1145 {"s16be", AF_FORMAT_S16_BE}, | |
1146 {"s16ne", AF_FORMAT_S16_NE}, | |
1147 {"u24le", AF_FORMAT_U24_LE}, | |
1148 {"u24be", AF_FORMAT_U24_BE}, | |
1149 {"u24ne", AF_FORMAT_U24_NE}, | |
1150 {"s24le", AF_FORMAT_S24_LE}, | |
1151 {"s24be", AF_FORMAT_S24_BE}, | |
1152 {"s24ne", AF_FORMAT_S24_NE}, | |
1153 {"u32le", AF_FORMAT_U32_LE}, | |
1154 {"u32be", AF_FORMAT_U32_BE}, | |
1155 {"u32ne", AF_FORMAT_U32_NE}, | |
1156 {"s32le", AF_FORMAT_S32_LE}, | |
1157 {"s32be", AF_FORMAT_S32_BE}, | |
1158 {"s32ne", AF_FORMAT_S32_NE}, | |
1159 {"floatle", AF_FORMAT_FLOAT_LE}, | |
1160 {"floatbe", AF_FORMAT_FLOAT_BE}, | |
1161 {"floatne", AF_FORMAT_FLOAT_NE}, | |
1162 { NULL, 0 } | |
1163 }; | |
1164 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1165 static int parse_afmt(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
14246 | 1166 uint32_t fmt = 0; |
1167 int i; | |
1168 | |
1169 if (param == NULL || strlen(param) == 0) | |
1170 return M_OPT_MISSING_PARAM; | |
1171 | |
1172 if(!strcmp(param,"help")) { | |
1173 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "Available formats:"); | |
1174 for(i = 0 ; mp_afmt_list[i].name ; i++) | |
1175 mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %s",mp_afmt_list[i].name); | |
1176 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n"); | |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15789
diff
changeset
|
1177 return M_OPT_EXIT - 1; |
14246 | 1178 } |
1179 | |
1180 if (sscanf(param, "0x%x", &fmt) != 1) | |
1181 { | |
1182 for(i = 0 ; mp_afmt_list[i].name ; i++) { | |
1183 if(!strcasecmp(param,mp_afmt_list[i].name)) { | |
1184 fmt=mp_afmt_list[i].fmt; | |
1185 break; | |
1186 } | |
1187 } | |
1188 if(!mp_afmt_list[i].name) { | |
1189 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: unknown format name: '%s'\n",name,param); | |
1190 return M_OPT_INVALID; | |
1191 } | |
1192 } | |
1193 | |
1194 if(dst) | |
1195 *((uint32_t*)dst) = fmt; | |
1196 | |
1197 return 1; | |
1198 } | |
1199 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1200 const m_option_type_t m_option_type_afmt = { |
14246 | 1201 "Audio format", |
1202 "Please report any missing formats.", | |
1203 sizeof(uint32_t), | |
1204 0, | |
1205 parse_afmt, | |
1206 NULL, | |
1207 copy_opt, | |
1208 copy_opt, | |
1209 NULL, | |
1210 NULL | |
1211 }; | |
1212 | |
1213 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1214 static double parse_timestring(const char *str) |
22312 | 1215 { |
1216 int a, b; | |
1217 double d; | |
1218 if (sscanf(str, "%d:%d:%lf", &a, &b, &d) == 3) | |
1219 return 3600*a + 60*b + d; | |
1220 else if (sscanf(str, "%d:%lf", &a, &d) == 2) | |
1221 return 60*a + d; | |
1222 else if (sscanf(str, "%lf", &d) == 1) | |
1223 return d; | |
1224 return -1e100; | |
1225 } | |
1226 | |
1227 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1228 static int parse_time(const m_option_t* opt,const char *name, char *param, void* dst, int src) |
22312 | 1229 { |
22356 | 1230 double time; |
1231 | |
22312 | 1232 if (param == NULL || strlen(param) == 0) |
1233 return M_OPT_MISSING_PARAM; | |
1234 | |
22356 | 1235 time = parse_timestring(param); |
22312 | 1236 if (time == -1e100) { |
1237 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: invalid time: '%s'\n", | |
1238 name,param); | |
1239 return M_OPT_INVALID; | |
1240 } | |
1241 | |
1242 if (dst) | |
1243 *(double *)dst = time; | |
1244 return 1; | |
1245 } | |
1246 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1247 const m_option_type_t m_option_type_time = { |
22312 | 1248 "Time", |
1249 "", | |
1250 sizeof(double), | |
1251 0, | |
1252 parse_time, | |
23415 | 1253 print_double, |
22312 | 1254 copy_opt, |
1255 copy_opt, | |
1256 NULL, | |
1257 NULL | |
1258 }; | |
1259 | |
1260 | |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1261 // Time or size (-endpos) |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1262 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1263 static int parse_time_size(const m_option_t* opt,const char *name, char *param, void* dst, int src) { |
20003
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1264 m_time_size_t ts; |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1265 char unit[4]; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1266 double end_at; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1267 |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1268 if (param == NULL || strlen(param) == 0) |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1269 return M_OPT_MISSING_PARAM; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1270 |
20003
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1271 ts.pos=0; |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1272 /* End at size parsing */ |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1273 if(sscanf(param, "%lf%3s", &end_at, unit) == 2) { |
20003
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1274 ts.type = END_AT_SIZE; |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1275 if(!strcasecmp(unit, "b")) |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1276 ; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1277 else if(!strcasecmp(unit, "kb")) |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1278 end_at *= 1024; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1279 else if(!strcasecmp(unit, "mb")) |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1280 end_at *= 1024*1024; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1281 else if(!strcasecmp(unit, "gb")) |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1282 end_at *= 1024*1024*1024; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1283 else |
20003
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1284 ts.type = END_AT_NONE; |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1285 |
20003
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1286 if (ts.type == END_AT_SIZE) { |
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1287 ts.pos = end_at; |
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1288 goto out; |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1289 } |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1290 } |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1291 |
22312 | 1292 /* End at time parsing. This has to be last because the parsing accepts |
1293 * even a number followed by garbage */ | |
1294 if ((end_at = parse_timestring(param)) == -1e100) { | |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1295 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: invalid time or size: '%s'\n", |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1296 name,param); |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1297 return M_OPT_INVALID; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1298 } |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1299 |
20003
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1300 ts.type = END_AT_TIME; |
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1301 ts.pos = end_at; |
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1302 out: |
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1303 if(dst) |
9f256c4066ff
Fix broken parse_time_size, it would cause MPlayer to parse its parameter twice,
reimar
parents:
19973
diff
changeset
|
1304 *(m_time_size_t *)dst = ts; |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1305 return 1; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1306 } |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1307 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1308 const m_option_type_t m_option_type_time_size = { |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1309 "Time or size", |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1310 "", |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1311 sizeof(m_time_size_t), |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1312 0, |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1313 parse_time_size, |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1314 NULL, |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1315 copy_opt, |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1316 copy_opt, |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1317 NULL, |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1318 NULL |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1319 }; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1320 |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19358
diff
changeset
|
1321 |
10641 | 1322 //// Objects (i.e. filters, etc) settings |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1323 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1324 #include "m_struct.h" |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1325 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1326 #undef VAL |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1327 #define VAL(x) (*(m_obj_settings_t**)(x)) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1328 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1329 static int find_obj_desc(const char* name,const m_obj_list_t* l,const m_struct_t** ret) { |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1330 int i; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1331 char* n; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1332 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1333 for(i = 0 ; l->list[i] ; i++) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1334 n = M_ST_MB(char*,l->list[i],l->name_off); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1335 if(!strcmp(n,name)) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1336 *ret = M_ST_MB(m_struct_t*,l->list[i],l->desc_off); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1337 return 1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1338 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1339 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1340 return 0; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1341 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1342 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1343 static int get_obj_param(const char* opt_name,const char* obj_name, const m_struct_t* desc, |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1344 char* str,int* nold,int oldmax,char** dst) { |
18958
a8e681ad7c90
Remove unused variables, patch by Stefan Huehner stefan at huehner org.
diego
parents:
18879
diff
changeset
|
1345 char* eq; |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1346 const m_option_t* opt; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1347 int r; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1348 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1349 eq = strchr(str,'='); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1350 if(eq && eq == str) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1351 eq = NULL; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1352 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1353 if(eq) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1354 char* p = eq + 1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1355 if(p[0] == '\0') p = NULL; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1356 eq[0] = '\0'; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1357 opt = m_option_list_find(desc->fields,str); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1358 if(!opt) { |
10641 | 1359 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: %s doesn't have a %s parameter.\n",opt_name,obj_name,str); |
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
|
1360 return M_OPT_UNKNOWN; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1361 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1362 r = m_option_parse(opt,str,p,NULL,M_CONFIG_FILE); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1363 if(r < 0) { |
17874 | 1364 if(r > M_OPT_EXIT) |
1365 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Error while parsing %s parameter %s (%s)\n",opt_name,obj_name,str,p); | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1366 eq[0] = '='; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1367 return r; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1368 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1369 if(dst) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1370 dst[0] = strdup(str); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1371 dst[1] = p ? strdup(p) : NULL; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1372 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1373 eq[0] = '='; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1374 } else { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1375 if((*nold) >= oldmax) { |
10641 | 1376 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: %s has only %d params, so you can't give more than %d unnamed params.\n", |
10660 | 1377 opt_name,obj_name,oldmax,oldmax); |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1378 return M_OPT_OUT_OF_RANGE; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1379 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1380 opt = &desc->fields[(*nold)]; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1381 r = m_option_parse(opt,opt->name,str,NULL,M_CONFIG_FILE); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1382 if(r < 0) { |
17874 | 1383 if(r > M_OPT_EXIT) |
1384 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Error while parsing %s parameter %s (%s)\n",opt_name,obj_name,opt->name,str); | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1385 return r; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1386 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1387 if(dst) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1388 dst[0] = strdup(opt->name); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1389 dst[1] = strdup(str); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1390 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1391 (*nold)++; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1392 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1393 return 1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1394 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1395 |
19053
75327b24e06f
marks several string parameters as const, as they are not modified inside the function, Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
18958
diff
changeset
|
1396 static int get_obj_params(const char* opt_name, const char* name,char* params, |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1397 const m_struct_t* desc,char separator, char*** _ret) { |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1398 int n = 0,nold = 0, nopts,r; |
18958
a8e681ad7c90
Remove unused variables, patch by Stefan Huehner stefan at huehner org.
diego
parents:
18879
diff
changeset
|
1399 char* ptr,*last_ptr = params; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1400 char** ret; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1401 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1402 if(!strcmp(params,"help")) { // Help |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1403 char min[50],max[50]; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1404 if(!desc->fields) { |
10641 | 1405 printf("%s doesn't have any options.\n\n",name); |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15789
diff
changeset
|
1406 return M_OPT_EXIT - 1; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1407 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1408 printf("\n Name Type Min Max\n\n"); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1409 for(n = 0 ; desc->fields[n].name ; n++) { |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1410 const m_option_t* opt = &desc->fields[n]; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1411 if(opt->type->flags & M_OPT_TYPE_HAS_CHILD) continue; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1412 if(opt->flags & M_OPT_MIN) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1413 sprintf(min,"%-8.0f",opt->min); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1414 else |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1415 strcpy(min,"No"); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1416 if(opt->flags & M_OPT_MAX) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1417 sprintf(max,"%-8.0f",opt->max); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1418 else |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1419 strcpy(max,"No"); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1420 printf(" %-20.20s %-15.15s %-10.10s %-10.10s\n", |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1421 opt->name, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1422 opt->type->name, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1423 min, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1424 max); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1425 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1426 printf("\n"); |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15789
diff
changeset
|
1427 return M_OPT_EXIT - 1; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1428 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1429 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1430 for(nopts = 0 ; desc->fields[nopts].name ; nopts++) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1431 /* NOP */; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1432 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1433 // TODO : Check that each opt can be parsed |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1434 r = 1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1435 while(last_ptr && last_ptr[0] != '\0') { |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1436 ptr = strchr(last_ptr,separator); |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1437 if(!ptr) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1438 r = get_obj_param(opt_name,name,desc,last_ptr,&nold,nopts,NULL); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1439 n++; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1440 break; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1441 } |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1442 if(ptr == last_ptr) { // Empty field, count it and go on |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1443 nold++; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1444 last_ptr = ptr+1; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1445 continue; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1446 } |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1447 ptr[0] = '\0'; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1448 r = get_obj_param(opt_name,name,desc,last_ptr,&nold,nopts,NULL); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1449 ptr[0] = separator; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1450 if(r < 0) break; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1451 n++; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1452 last_ptr = ptr+1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1453 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1454 if(r < 0) return r; |
15743 | 1455 if (!last_ptr[0]) // count an empty field at the end, too |
1456 nold++; | |
1457 if (nold > nopts) { | |
1458 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Too many options for %s\n", name); | |
1459 return M_OPT_OUT_OF_RANGE; | |
1460 } | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1461 if(!_ret) // Just test |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1462 return 1; |
15743 | 1463 if (n == 0) // No options or only empty options |
1464 return 1; | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1465 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1466 ret = malloc((n+2)*2*sizeof(char*)); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1467 n = nold = 0; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1468 last_ptr = params; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1469 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1470 while(last_ptr && last_ptr[0] != '\0') { |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1471 ptr = strchr(last_ptr,separator); |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1472 if(!ptr) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1473 get_obj_param(opt_name,name,desc,last_ptr,&nold,nopts,&ret[n*2]); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1474 n++; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1475 break; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1476 } |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1477 if(ptr == last_ptr) { // Empty field, count it and go on |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1478 last_ptr = ptr+1; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1479 nold++; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1480 continue; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1481 } |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1482 ptr[0] = '\0'; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1483 get_obj_param(opt_name,name,desc,last_ptr,&nold,nopts,&ret[n*2]); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1484 n++; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1485 last_ptr = ptr+1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1486 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1487 ret[n*2] = ret[n*2+1] = NULL; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1488 *_ret = ret; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1489 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1490 return 1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1491 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1492 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1493 static int parse_obj_params(const m_option_t* opt,const char *name, |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1494 char *param, void* dst, int src) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1495 char** opts; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1496 int r; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1497 m_obj_params_t* p = opt->priv; |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1498 const m_struct_t* desc; |
27835
28b6709b52a2
Avoid a potential memleak in parse_obj_params in case of a missing
reimar
parents:
25489
diff
changeset
|
1499 char* cpy; |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1500 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1501 // We need the object desc |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1502 if(!p) |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1503 return M_OPT_INVALID; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1504 |
20098 | 1505 desc = p->desc; |
27835
28b6709b52a2
Avoid a potential memleak in parse_obj_params in case of a missing
reimar
parents:
25489
diff
changeset
|
1506 cpy = strdup(param); |
20101
4ccb2a53b859
Avoid memleak when calling parse_obj_params only for syntax-checking (dst == NULL)
reimar
parents:
20098
diff
changeset
|
1507 r = get_obj_params(name,desc->name,cpy,desc,p->separator,dst ? &opts : NULL); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1508 free(cpy); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1509 if(r < 0) |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1510 return r; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1511 if(!dst) |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1512 return 1; |
15743 | 1513 if (!opts) // no arguments given |
1514 return 1; | |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1515 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1516 for(r = 0 ; opts[r] ; r += 2) |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1517 m_struct_set(desc,dst,opts[r],opts[r+1]); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1518 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1519 return 1; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1520 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1521 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1522 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1523 const m_option_type_t m_option_type_obj_params = { |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1524 "Object params", |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1525 "", |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1526 0, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1527 0, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1528 parse_obj_params, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1529 NULL, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1530 NULL, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1531 NULL, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1532 NULL, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1533 NULL |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1534 }; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1535 |
10641 | 1536 /// Some predefined types as a definition would be quite lengthy |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1537 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1538 /// Span arguments |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1539 static const m_span_t m_span_params_dflts = { -1, -1 }; |
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1540 static const m_option_t m_span_params_fields[] = { |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1541 {"start", M_ST_OFF(m_span_t,start), CONF_TYPE_INT, M_OPT_MIN, 1 ,0, NULL}, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1542 {"end", M_ST_OFF(m_span_t,end), CONF_TYPE_INT, M_OPT_MIN , 1 ,0, NULL}, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1543 { NULL, NULL, 0, 0, 0, 0, NULL } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1544 }; |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1545 static const struct m_struct_st m_span_opts = { |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1546 "m_span", |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1547 sizeof(m_span_t), |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1548 &m_span_params_dflts, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1549 m_span_params_fields |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1550 }; |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1551 const m_obj_params_t m_span_params_def = { |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1552 &m_span_opts, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1553 '-' |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1554 }; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1555 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1556 static int parse_obj_settings(const char* opt,char* str,const m_obj_list_t* list, |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1557 m_obj_settings_t **_ret, int ret_n) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1558 int r; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1559 char *param,**plist = NULL; |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1560 const m_struct_t* desc; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1561 m_obj_settings_t *ret = _ret ? *_ret : NULL; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1562 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1563 |
10641 | 1564 // Now check that the object exists |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1565 param = strchr(str,'='); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1566 if(param) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1567 param[0] = '\0'; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1568 param++; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1569 if(strlen(param) <= 0) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1570 param = NULL; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1571 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1572 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1573 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1574 if(!find_obj_desc(str,list,&desc)) { |
10641 | 1575 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: %s doesn't exist.\n",opt,str); |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1576 return M_OPT_INVALID; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1577 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1578 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1579 if(param) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1580 if(!desc && _ret) { |
17874 | 1581 if(!strcmp(param,"help")) { |
1582 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "Option %s: %s have no option description.\n",opt,str); | |
1583 return M_OPT_EXIT - 1; | |
1584 } | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1585 plist = calloc(4,sizeof(char*)); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1586 plist[0] = strdup("_oldargs_"); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1587 plist[1] = strdup(param); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1588 } else if(desc) { |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1589 r = get_obj_params(opt,str,param,desc,':',_ret ? &plist : NULL); |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1590 if(r < 0) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1591 return r; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1592 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1593 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1594 if(!_ret) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1595 return 1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1596 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1597 ret = realloc(ret,(ret_n+2)*sizeof(m_obj_settings_t)); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1598 memset(&ret[ret_n],0,2*sizeof(m_obj_settings_t)); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1599 ret[ret_n].name = strdup(str); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1600 ret[ret_n].attribs = plist; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1601 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1602 *_ret = ret; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1603 return 1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1604 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1605 |
9913 | 1606 static void free_obj_settings_list(void* dst); |
1607 | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1608 static int obj_settings_list_del(const char *opt_name,char *param,void* dst, int src) { |
9913 | 1609 char** str_list = NULL; |
1610 int r,i,idx_max = 0; | |
1611 char* rem_id = "_removed_marker_"; | |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1612 const m_option_t list_opt = {opt_name , NULL, CONF_TYPE_STRING_LIST, |
9913 | 1613 0, 0, 0, NULL }; |
1614 m_obj_settings_t* obj_list = dst ? VAL(dst) : NULL; | |
1615 | |
1616 if(dst && !obj_list) { | |
1617 mp_msg(MSGT_CFGPARSER, MSGL_WARN, "Option %s: the list is empty.\n",opt_name); | |
1618 return 1; | |
1619 } else if(obj_list) { | |
1620 for(idx_max = 0 ; obj_list[idx_max].name != NULL ; idx_max++) | |
1621 /* NOP */; | |
1622 } | |
1623 | |
1624 r = m_option_parse(&list_opt,opt_name,param,&str_list,src); | |
1625 if(r < 0 || !str_list) | |
1626 return r; | |
1627 | |
1628 for(r = 0 ; str_list[r] ; r++) { | |
1629 int id; | |
1630 char* endptr; | |
1631 id = strtol(str_list[r],&endptr,0); | |
1632 if(endptr == str_list[r]) { | |
10660 | 1633 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: invalid parameter. We need a list of integers which are the indices of the elements to remove.\n",opt_name); |
9913 | 1634 m_option_free(&list_opt,&str_list); |
1635 return M_OPT_INVALID; | |
1636 } | |
1637 if(!obj_list) continue; | |
1638 if(id >= idx_max || id < -idx_max) { | |
10641 | 1639 mp_msg(MSGT_CFGPARSER, MSGL_WARN, "Option %s: Index %d is out of range.\n",opt_name,id); |
9913 | 1640 continue; |
1641 } | |
1642 if(id < 0) | |
1643 id = idx_max + id; | |
1644 free(obj_list[id].name); | |
1645 free_str_list(&(obj_list[id].attribs)); | |
1646 obj_list[id].name = rem_id; | |
1647 } | |
1648 | |
1649 if(!dst) { | |
1650 m_option_free(&list_opt,&str_list); | |
1651 return 1; | |
1652 } | |
1653 | |
1654 for(i = 0 ; obj_list[i].name ; i++) { | |
1655 while(obj_list[i].name == rem_id) { | |
1656 memmove(&obj_list[i],&obj_list[i+1],sizeof(m_obj_settings_t)*(idx_max - i)); | |
1657 idx_max--; | |
1658 } | |
1659 } | |
1660 obj_list = realloc(obj_list,sizeof(m_obj_settings_t)*(idx_max+1)); | |
1661 VAL(dst) = obj_list; | |
1662 | |
1663 return 1; | |
1664 } | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1665 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1666 static int parse_obj_settings_list(const m_option_t* opt,const char *name, |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1667 char *param, void* dst, int src) { |
9913 | 1668 int n = 0,r,len = strlen(opt->name); |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1669 char *str; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1670 char *ptr, *last_ptr; |
9913 | 1671 m_obj_settings_t *res = NULL,*queue = NULL,*head = NULL; |
1672 int op = OP_NONE; | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1673 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1674 // We need the objects list |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1675 if(!opt->priv) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1676 return M_OPT_INVALID; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1677 |
9913 | 1678 if(opt->name[len-1] == '*' && ((int)strlen(name) > len - 1)) { |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1679 const char* n = &name[len-1]; |
9913 | 1680 if(strcasecmp(n,"-add") == 0) |
1681 op = OP_ADD; | |
1682 else if(strcasecmp(n,"-pre") == 0) | |
1683 op = OP_PRE; | |
1684 else if(strcasecmp(n,"-del") == 0) | |
1685 op = OP_DEL; | |
1686 else if(strcasecmp(n,"-clr") == 0) | |
1687 op = OP_CLR; | |
1688 else { | |
1689 char prefix[len]; | |
1690 strncpy(prefix,opt->name,len-1); | |
1691 prefix[len-1] = '\0'; | |
10608 | 1692 mp_msg(MSGT_VFILTER,MSGL_ERR, "Option %s: unknown postfix %s\n" |
1693 "Supported postfixes are:\n" | |
12653 | 1694 " %s-add\n" |
9913 | 1695 " Append the given list to the current list\n\n" |
12653 | 1696 " %s-pre\n" |
9913 | 1697 " Prepend the given list to the current list\n\n" |
12653 | 1698 " %s-del x,y,...\n" |
9913 | 1699 " Remove the given elements. Take the list element index (starting from 0).\n" |
10641 | 1700 " Negative index can be used (i.e. -1 is the last element)\n\n" |
12653 | 1701 " %s-clr\n" |
1702 " Clear the current list.\n",name,n,prefix,prefix,prefix,prefix); | |
9913 | 1703 |
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
|
1704 return M_OPT_UNKNOWN; |
9913 | 1705 } |
1706 } | |
1707 | |
1708 // Clear the list ?? | |
1709 if(op == OP_CLR) { | |
1710 if(dst) | |
1711 free_obj_settings_list(dst); | |
1712 return 0; | |
1713 } | |
1714 | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1715 if (param == NULL || strlen(param) == 0) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1716 return M_OPT_MISSING_PARAM; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1717 |
9913 | 1718 switch(op) { |
1719 case OP_ADD: | |
1720 if(dst) head = VAL(dst); | |
1721 break; | |
1722 case OP_PRE: | |
1723 if(dst) queue = VAL(dst); | |
1724 break; | |
1725 case OP_DEL: | |
1726 return obj_settings_list_del(name,param,dst,src); | |
1727 case OP_NONE: | |
1728 if(dst && VAL(dst)) | |
1729 free_obj_settings_list(dst); | |
1730 break; | |
1731 default: | |
1732 mp_msg(MSGT_VFILTER,MSGL_ERR, "Option %s: FIXME\n",name); | |
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
|
1733 return M_OPT_UNKNOWN; |
9913 | 1734 } |
1735 | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1736 if(!strcmp(param,"help")) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1737 m_obj_list_t* ol = opt->priv; |
14085 | 1738 mp_msg(MSGT_VFILTER,MSGL_INFO,"Available video filters:\n"); |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
17874
diff
changeset
|
1739 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_FILTERS\n"); |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1740 for(n = 0 ; ol->list[n] ; n++) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1741 mp_msg(MSGT_VFILTER,MSGL_INFO," %-15s: %s\n", |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1742 M_ST_MB(char*,ol->list[n],ol->name_off), |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1743 M_ST_MB(char*,ol->list[n],ol->info_off)); |
17727
096cb1dfb591
Make -xy help output consistent, output an empty line before and after.
diego
parents:
17667
diff
changeset
|
1744 mp_msg(MSGT_VFILTER,MSGL_INFO,"\n"); |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15789
diff
changeset
|
1745 return M_OPT_EXIT - 1; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1746 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1747 ptr = str = strdup(param); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1748 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1749 while(ptr[0] != '\0') { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1750 last_ptr = ptr; |
22133 | 1751 ptr = get_nextsep(ptr, LIST_SEPARATOR, 1); |
20314 | 1752 |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1753 if(!ptr) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1754 r = parse_obj_settings(name,last_ptr,opt->priv,dst ? &res : NULL,n); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1755 if(r < 0) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1756 free(str); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1757 return r; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1758 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1759 n++; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1760 break; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1761 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1762 ptr[0] = '\0'; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1763 r = parse_obj_settings(name,last_ptr,opt->priv,dst ? &res : NULL,n); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1764 if(r < 0) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1765 free(str); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1766 return r; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1767 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1768 ptr++; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1769 n++; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1770 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1771 free(str); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1772 if(n == 0) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1773 return M_OPT_INVALID; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1774 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1775 if( ((opt->flags & M_OPT_MIN) && (n < opt->min)) || |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1776 ((opt->flags & M_OPT_MAX) && (n > opt->max)) ) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1777 return M_OPT_OUT_OF_RANGE; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1778 |
9913 | 1779 if(dst) { |
1780 if(queue) { | |
1781 int qsize; | |
1782 for(qsize = 0 ; queue[qsize].name ; qsize++) | |
1783 /* NOP */; | |
1784 res = realloc(res,(qsize+n+1)*sizeof(m_obj_settings_t)); | |
1785 memcpy(&res[n],queue,(qsize+1)*sizeof(m_obj_settings_t)); | |
1786 n += qsize; | |
1787 free(queue); | |
1788 } | |
1789 if(head) { | |
1790 int hsize; | |
1791 for(hsize = 0 ; head[hsize].name ; hsize++) | |
1792 /* NOP */; | |
1793 head = realloc(head,(hsize+n+1)*sizeof(m_obj_settings_t)); | |
1794 memcpy(&head[hsize],res,(n+1)*sizeof(m_obj_settings_t)); | |
1795 free(res); | |
1796 res = head; | |
1797 } | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1798 VAL(dst) = res; |
9913 | 1799 } |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1800 return 1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1801 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1802 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1803 static void free_obj_settings_list(void* dst) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1804 int n; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1805 m_obj_settings_t *d; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1806 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1807 if(!dst || !VAL(dst)) return; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1808 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1809 d = VAL(dst); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1810 #ifndef NO_FREE |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1811 for(n = 0 ; d[n].name ; n++) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1812 free(d[n].name); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1813 free_str_list(&(d[n].attribs)); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1814 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1815 free(d); |
8164 | 1816 #endif |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1817 VAL(dst) = NULL; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1818 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1819 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1820 static void copy_obj_settings_list(const m_option_t* opt,void* dst, void* src) { |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1821 m_obj_settings_t *d,*s; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1822 int n; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1823 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1824 if(!(dst && src)) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1825 return; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1826 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1827 s = VAL(src); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1828 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1829 if(VAL(dst)) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1830 free_obj_settings_list(dst); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1831 if(!s) return; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1832 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1833 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1834 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1835 for(n = 0 ; s[n].name ; n++) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1836 /* NOP */; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1837 d = malloc((n+1)*sizeof(m_obj_settings_t)); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1838 for(n = 0 ; s[n].name ; n++) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1839 d[n].name = strdup(s[n].name); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1840 d[n].attribs = NULL; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1841 copy_str_list(NULL,&(d[n].attribs),&(s[n].attribs)); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1842 } |
10236 | 1843 d[n].name = NULL; |
1844 d[n].attribs = NULL; | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1845 VAL(dst) = d; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1846 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1847 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1848 const m_option_type_t m_option_type_obj_settings_list = { |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1849 "Object settings list", |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1850 "", |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1851 sizeof(m_obj_settings_t*), |
9913 | 1852 M_OPT_TYPE_DYNAMIC|M_OPT_TYPE_ALLOW_WILDCARD, |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1853 parse_obj_settings_list, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1854 NULL, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1855 copy_obj_settings_list, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1856 copy_obj_settings_list, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1857 copy_obj_settings_list, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1858 free_obj_settings_list, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1859 }; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1860 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1861 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1862 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1863 static int parse_obj_presets(const m_option_t* opt,const char *name, |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1864 char *param, void* dst, int src) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1865 m_obj_presets_t* obj_p = (m_obj_presets_t*)opt->priv; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1866 m_struct_t *in_desc,*out_desc; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1867 int s,i; |
20097 | 1868 unsigned char* pre; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1869 char* pre_name = NULL; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1870 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1871 if(!obj_p) { |
10641 | 1872 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Presets need a pointer to a m_obj_presets_t in the priv field.\n",name); |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1873 return M_OPT_PARSER_ERR; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1874 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1875 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1876 if(!param) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1877 return M_OPT_MISSING_PARAM; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1878 |
20097 | 1879 pre = obj_p->presets; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1880 in_desc = obj_p->in_desc; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1881 out_desc = obj_p->out_desc ? obj_p->out_desc : obj_p->in_desc; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1882 s = in_desc->size; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1883 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1884 if(!strcmp(param,"help")) { |
10641 | 1885 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "Available presets for %s->%s:",out_desc->name,name); |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1886 for(pre = obj_p->presets;(pre_name = M_ST_MB(char*,pre,obj_p->name_off)) ; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1887 pre += s) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1888 mp_msg(MSGT_CFGPARSER, MSGL_ERR, " %s",pre_name); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1889 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "\n"); |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15789
diff
changeset
|
1890 return M_OPT_EXIT - 1; |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1891 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1892 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1893 for(pre_name = M_ST_MB(char*,pre,obj_p->name_off) ; pre_name ; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1894 pre += s, pre_name = M_ST_MB(char*,pre,obj_p->name_off)) { |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1895 if(!strcmp(pre_name,param)) break; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1896 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1897 if(!pre_name) { |
10641 | 1898 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: There is no preset named %s\n" |
1899 "Available presets are:",name,param); | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1900 for(pre = obj_p->presets;(pre_name = M_ST_MB(char*,pre,obj_p->name_off)) ; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1901 pre += s) |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1902 mp_msg(MSGT_CFGPARSER, MSGL_ERR, " %s",pre_name); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1903 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "\n"); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1904 return M_OPT_INVALID; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1905 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1906 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1907 if(!dst) return 1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1908 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1909 for(i = 0 ; in_desc->fields[i].name ; i++) { |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1910 const m_option_t* out_opt = m_option_list_find(out_desc->fields, |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1911 in_desc->fields[i].name); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1912 if(!out_opt) { |
10641 | 1913 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Unable to find the target option for field %s.\nPlease report this to the developers.\n",name,in_desc->fields[i].name); |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1914 return M_OPT_PARSER_ERR; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1915 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1916 m_option_copy(out_opt,M_ST_MB_P(dst,out_opt->p),M_ST_MB_P(pre,in_desc->fields[i].p)); |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1917 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1918 return 1; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1919 } |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1920 |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1921 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1922 const m_option_type_t m_option_type_obj_presets = { |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1923 "Object presets", |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1924 "", |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1925 0, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1926 0, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1927 parse_obj_presets, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1928 NULL, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1929 NULL, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1930 NULL, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1931 NULL, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1932 NULL |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1933 }; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9177
diff
changeset
|
1934 |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
1935 static int parse_custom_url(const m_option_t* opt,const char *name, |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1936 char *url, void* dst, int src) { |
11771
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11688
diff
changeset
|
1937 int pos1, pos2, r, v6addr = 0; |
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11688
diff
changeset
|
1938 char *ptr1=NULL, *ptr2=NULL, *ptr3=NULL, *ptr4=NULL; |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1939 m_struct_t* desc = opt->priv; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1940 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1941 if(!desc) { |
10641 | 1942 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Custom URL needs a pointer to a m_struct_t in the priv field.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1943 return M_OPT_PARSER_ERR; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1944 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1945 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1946 // extract the protocol |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1947 ptr1 = strstr(url, "://"); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1948 if( ptr1==NULL ) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1949 // Filename only |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1950 if(m_option_list_find(desc->fields,"filename")) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1951 m_struct_set(desc,dst,"filename",url); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1952 return 1; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1953 } |
10641 | 1954 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Option %s: URL doesn't have a valid protocol!\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1955 return M_OPT_INVALID; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1956 } |
15460
fa8c3f5b7ec2
introduced -string- parameter to match everything after :// syntax
nicodvb
parents:
14246
diff
changeset
|
1957 if(m_option_list_find(desc->fields,"string")) { |
fa8c3f5b7ec2
introduced -string- parameter to match everything after :// syntax
nicodvb
parents:
14246
diff
changeset
|
1958 if(strlen(ptr1)>3) { |
fa8c3f5b7ec2
introduced -string- parameter to match everything after :// syntax
nicodvb
parents:
14246
diff
changeset
|
1959 m_struct_set(desc,dst,"string",ptr1+3); |
fa8c3f5b7ec2
introduced -string- parameter to match everything after :// syntax
nicodvb
parents:
14246
diff
changeset
|
1960 return 1; |
fa8c3f5b7ec2
introduced -string- parameter to match everything after :// syntax
nicodvb
parents:
14246
diff
changeset
|
1961 } |
fa8c3f5b7ec2
introduced -string- parameter to match everything after :// syntax
nicodvb
parents:
14246
diff
changeset
|
1962 } |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1963 pos1 = ptr1-url; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1964 if(dst && m_option_list_find(desc->fields,"protocol")) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1965 ptr1[0] = '\0'; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1966 r = m_struct_set(desc,dst,"protocol",url); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1967 ptr1[0] = ':'; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1968 if(r < 0) { |
10641 | 1969 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Error while setting protocol.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1970 return r; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1971 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1972 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1973 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1974 // jump the "://" |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1975 ptr1 += 3; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1976 pos1 += 3; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1977 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1978 // check if a username:password is given |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1979 ptr2 = strstr(ptr1, "@"); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1980 ptr3 = strstr(ptr1, "/"); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1981 if( ptr3!=NULL && ptr3<ptr2 ) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1982 // it isn't really a username but rather a part of the path |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1983 ptr2 = NULL; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1984 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1985 if( ptr2!=NULL ) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1986 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1987 // We got something, at least a username... |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1988 if(!m_option_list_find(desc->fields,"username")) { |
10641 | 1989 mp_msg(MSGT_CFGPARSER, MSGL_WARN, "Option %s: This URL doesn't have a username part.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1990 // skip |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1991 } else { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1992 ptr3 = strstr(ptr1, ":"); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1993 if( ptr3!=NULL && ptr3<ptr2 ) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1994 // We also have a password |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1995 if(!m_option_list_find(desc->fields,"password")) { |
10641 | 1996 mp_msg(MSGT_CFGPARSER, MSGL_WARN, "Option %s: This URL doesn't have a password part.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1997 // skip |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1998 } else { // Username and password |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
1999 if(dst) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2000 ptr3[0] = '\0'; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2001 r = m_struct_set(desc,dst,"username",ptr1); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2002 ptr3[0] = ':'; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2003 if(r < 0) { |
10641 | 2004 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Error while setting username.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2005 return r; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2006 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2007 ptr2[0] = '\0'; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2008 r = m_struct_set(desc,dst,"password",ptr3+1); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2009 ptr2[0] = '@'; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2010 if(r < 0) { |
10641 | 2011 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Error while setting password.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2012 return r; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2013 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2014 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2015 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2016 } else { // User name only |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2017 ptr2[0] = '\0'; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2018 r = m_struct_set(desc,dst,"username",ptr1); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2019 ptr2[0] = '@'; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2020 if(r < 0) { |
10641 | 2021 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Error while setting username.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2022 return r; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2023 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2024 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2025 } |
10592
98c885b1ff06
Fix a 10l and add escaped filename support. Needed by ftp.
albeu
parents:
10397
diff
changeset
|
2026 ptr1 = ptr2+1; |
98c885b1ff06
Fix a 10l and add escaped filename support. Needed by ftp.
albeu
parents:
10397
diff
changeset
|
2027 pos1 = ptr1-url; |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2028 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2029 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2030 // before looking for a port number check if we have an IPv6 type numeric address |
10641 | 2031 // in an IPv6 URL the numeric address should be inside square braces. |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2032 ptr2 = strstr(ptr1, "["); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2033 ptr3 = strstr(ptr1, "]"); |
11771
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11688
diff
changeset
|
2034 // If the [] is after the first it isn't the hostname |
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11688
diff
changeset
|
2035 ptr4 = strstr(ptr1, "/"); |
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11688
diff
changeset
|
2036 if( ptr2!=NULL && ptr3!=NULL && (ptr2 < ptr3) && (!ptr4 || ptr4 > ptr3)) { |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2037 // we have an IPv6 numeric address |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2038 ptr1++; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2039 pos1++; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2040 ptr2 = ptr3; |
11771
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11688
diff
changeset
|
2041 v6addr = 1; |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2042 } else { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2043 ptr2 = ptr1; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2044 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2045 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2046 // look if the port is given |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2047 ptr2 = strstr(ptr2, ":"); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2048 // If the : is after the first / it isn't the port |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2049 ptr3 = strstr(ptr1, "/"); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2050 if(ptr3 && ptr3 - ptr2 < 0) ptr2 = NULL; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2051 if( ptr2==NULL ) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2052 // No port is given |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2053 // Look if a path is given |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2054 if( ptr3==NULL ) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2055 // No path/filename |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2056 // So we have an URL like http://www.hostname.com |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2057 pos2 = strlen(url); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2058 } else { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2059 // We have an URL like http://www.hostname.com/file.txt |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2060 pos2 = ptr3-url; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2061 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2062 } else { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2063 // We have an URL beginning like http://www.hostname.com:1212 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2064 // Get the port number |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2065 if(!m_option_list_find(desc->fields,"port")) { |
10641 | 2066 mp_msg(MSGT_CFGPARSER, MSGL_WARN, "Option %s: This URL doesn't have a port part.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2067 // skip |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2068 } else { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2069 if(dst) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2070 int p = atoi(ptr2+1); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2071 char tmp[100]; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2072 snprintf(tmp,99,"%d",p); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2073 r = m_struct_set(desc,dst,"port",tmp); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2074 if(r < 0) { |
10641 | 2075 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Error while setting port.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2076 return r; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2077 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2078 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2079 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2080 pos2 = ptr2-url; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2081 } |
11771
827cae571c5c
Fix long standing bug where last (and sometimes first) char of the
albeu
parents:
11688
diff
changeset
|
2082 if( v6addr ) pos2--; |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2083 // Get the hostname |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2084 if(pos2-pos1 > 0) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2085 if(!m_option_list_find(desc->fields,"hostname")) { |
10641 | 2086 mp_msg(MSGT_CFGPARSER, MSGL_WARN, "Option %s: This URL doesn't have a hostname part.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2087 // skip |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2088 } else { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2089 char tmp[pos2-pos1+1]; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2090 strncpy(tmp,ptr1, pos2-pos1); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2091 tmp[pos2-pos1] = '\0'; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2092 r = m_struct_set(desc,dst,"hostname",tmp); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2093 if(r < 0) { |
10641 | 2094 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Error while setting hostname.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2095 return r; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2096 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2097 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2098 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2099 // Look if a path is given |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2100 ptr2 = strstr(ptr1, "/"); |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2101 if( ptr2!=NULL ) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2102 // A path/filename is given |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2103 // check if it's not a trailing '/' |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2104 if( strlen(ptr2)>1 ) { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2105 // copy the path/filename in the URL container |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2106 if(!m_option_list_find(desc->fields,"filename")) { |
10641 | 2107 mp_msg(MSGT_CFGPARSER, MSGL_WARN, "Option %s: This URL doesn't have a hostname part.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2108 // skip |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2109 } else { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2110 if(dst) { |
10592
98c885b1ff06
Fix a 10l and add escaped filename support. Needed by ftp.
albeu
parents:
10397
diff
changeset
|
2111 int l = strlen(ptr2+1) + 1; |
98c885b1ff06
Fix a 10l and add escaped filename support. Needed by ftp.
albeu
parents:
10397
diff
changeset
|
2112 char* fname = ptr2+1; |
98c885b1ff06
Fix a 10l and add escaped filename support. Needed by ftp.
albeu
parents:
10397
diff
changeset
|
2113 if(l > 1) { |
98c885b1ff06
Fix a 10l and add escaped filename support. Needed by ftp.
albeu
parents:
10397
diff
changeset
|
2114 fname = malloc(l); |
98c885b1ff06
Fix a 10l and add escaped filename support. Needed by ftp.
albeu
parents:
10397
diff
changeset
|
2115 url_unescape_string(fname,ptr2+1); |
98c885b1ff06
Fix a 10l and add escaped filename support. Needed by ftp.
albeu
parents:
10397
diff
changeset
|
2116 } |
98c885b1ff06
Fix a 10l and add escaped filename support. Needed by ftp.
albeu
parents:
10397
diff
changeset
|
2117 r = m_struct_set(desc,dst,"filename",fname); |
98c885b1ff06
Fix a 10l and add escaped filename support. Needed by ftp.
albeu
parents:
10397
diff
changeset
|
2118 if(fname != ptr2+1) |
98c885b1ff06
Fix a 10l and add escaped filename support. Needed by ftp.
albeu
parents:
10397
diff
changeset
|
2119 free(fname); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2120 if(r < 0) { |
10641 | 2121 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: Error while setting filename.\n",name); |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2122 return r; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2123 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2124 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2125 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2126 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2127 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2128 return 1; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2129 } |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2130 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2131 /// TODO : Write the other needed funcs for 'normal' options |
24966
cc170348a763
correct const usage in the option handling code so that tables can be
rfelker
parents:
23703
diff
changeset
|
2132 const m_option_type_t m_option_type_custom_url = { |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2133 "Custom URL", |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2134 "", |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2135 0, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2136 0, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2137 parse_custom_url, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2138 NULL, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2139 NULL, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2140 NULL, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2141 NULL, |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2142 NULL |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9600
diff
changeset
|
2143 }; |