1 /*
2 * AVOption parsing helper
3 * Copyright (C) 2008 Michael Niedermayer
4 *
5 * This file is part of MPlayer.
6 *
7 * MPlayer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * MPlayer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 #include <stdlib.h>
23 #include <string.h>
24
25 #include "av_opts.h"
26 #include "libavutil/opt.h"
27
parse_avopts(void * v,char * str)28 int parse_avopts(void *v, char *str){
29 char *start;
30
31 if (!v)
32 return -1;
33 if (!str)
34 return 0;
35 if (strcmp(str, "help") == 0) {
36 av_opt_show2(v, NULL, -1, 0);
37 return -1;
38 }
39
40 start= str= strdup(str);
41
42 while(str && *str){
43 char *next_opt, *arg;
44
45 next_opt= strchr(str, ',');
46 if(next_opt) *next_opt++= 0;
47
48 arg = strchr(str, '=');
49 if(arg) *arg++= 0;
50
51 if (av_opt_set(v, str, arg, 0) < 0) {
52 free(start);
53 return -1;
54 }
55 str= next_opt;
56 }
57
58 free(start);
59 return 0;
60 }
61