annotate m_config.c @ 18076:d30afd14867f

Segfault fix, patch by Stanislav Maslovski stanislav POIS maslovski AH gmail POIS com Original thread: Date: Mon, 10 Apr 2006 23:43:23 +0400 Subject: [MPlayer-dev-eng] [PATCH] GUI: segfault in gtk/menu.c
author gpoirier
date Tue, 11 Apr 2006 12:17:21 +0000
parents 98f0e0542cb6
children 96568be4bfdc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
1 #include "config.h"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
2
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
3 #include <stdlib.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
4 #include <stdio.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
5 #include <errno.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
6 #include <string.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
7 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
8 #include <assert.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
9 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
10
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
11 #include "m_config.h"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
12 #include "m_option.h"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
13 #include "mp_msg.h"
13699
11b249ef87b0 printf --> mp_msg by the Wanderer <inverseparadox at comcast dot net>
diego
parents: 10595
diff changeset
14 #include "help_mp.h"
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
15
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
16 #define MAX_PROFILE_DEPTH 20
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
17
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
18 static int
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
19 parse_profile(m_option_t* opt,char *name, char *param, void* dst, int src);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
20
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
21 static void
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
22 set_profile(m_option_t *opt, void* dst, void* src);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
23
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
24 static int
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
25 show_profile(m_option_t *opt, char* name, char *param);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
26
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
27 static void
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
28 m_config_add_option(m_config_t *config, m_option_t *arg, char* prefix);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
29
17472
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 17471
diff changeset
30 static int
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 17471
diff changeset
31 list_options(m_option_t *opt, char* name, char *param);
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 17471
diff changeset
32
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
33 m_config_t*
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
34 m_config_new(void) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
35 m_config_t* config;
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
36 static int inited = 0;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
37 static m_option_type_t profile_opt_type;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
38 static m_option_t ref_opts[] = {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
39 { "profile", NULL, &profile_opt_type, CONF_NOSAVE, 0, 0, NULL },
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
40 { "show-profile", show_profile, CONF_TYPE_PRINT_FUNC, CONF_NOCFG, 0, 0, NULL },
17472
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 17471
diff changeset
41 { "list-options", list_options, CONF_TYPE_PRINT_FUNC, CONF_NOCFG, 0, 0, NULL },
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
42 { NULL, NULL, NULL, 0, 0, 0, NULL }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
43 };
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
44 int i;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
45
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
46 config = (m_config_t*)calloc(1,sizeof(m_config_t));
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
47 config->lvl = 1; // 0 Is the defaults
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
48 if(!inited) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
49 inited = 1;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
50 profile_opt_type = m_option_type_string_list;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
51 profile_opt_type.parse = parse_profile;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
52 profile_opt_type.set = set_profile;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
53 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
54 config->self_opts = malloc(sizeof(ref_opts));
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
55 memcpy(config->self_opts,ref_opts,sizeof(ref_opts));
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
56 for(i = 0 ; config->self_opts[i].name ; i++)
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
57 config->self_opts[i].priv = config;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
58 m_config_register_options(config,config->self_opts);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
59
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
60 return config;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
61 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
62
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
63 void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
64 m_config_free(m_config_t* config) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
65 m_config_option_t *i = config->opts, *ct;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
66 m_config_save_slot_t *sl,*st;
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
67 m_profile_t *p,*pn;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
68 int j;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
69
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
70 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
71 assert(config != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
72 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
73
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
74 while(i) {
13824
bad703951cf9 a few 10l fixes by Wei Jiang <jiangw98@yahoo.com>
faust3
parents: 13699
diff changeset
75 if (i->flags & M_CFG_OPT_ALIAS)
bad703951cf9 a few 10l fixes by Wei Jiang <jiangw98@yahoo.com>
faust3
parents: 13699
diff changeset
76 sl = NULL;
bad703951cf9 a few 10l fixes by Wei Jiang <jiangw98@yahoo.com>
faust3
parents: 13699
diff changeset
77 else
bad703951cf9 a few 10l fixes by Wei Jiang <jiangw98@yahoo.com>
faust3
parents: 13699
diff changeset
78 sl = i->slots;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
79 while(sl) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
80 m_option_free(i->opt,sl->data);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
81 st = sl->prev;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
82 free(sl);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
83 sl = st;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
84 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
85 if(i->name != i->opt->name)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
86 free(i->name);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
87 ct = i->next;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
88 free(i);
13824
bad703951cf9 a few 10l fixes by Wei Jiang <jiangw98@yahoo.com>
faust3
parents: 13699
diff changeset
89 i = ct;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
90 }
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
91 for(p = config->profiles ; p ; p = pn) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
92 pn = p->next;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
93 free(p->name);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
94 if(p->desc) free(p->desc);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
95 for(j = 0 ; j < p->num_opts ; j++) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
96 free(p->opts[2*j]);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
97 if(p->opts[2*j+1]) free(p->opts[2*j+1]);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
98 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
99 free(p->opts);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
100 free(p);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
101 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
102 free(config->self_opts);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
103 free(config);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
104 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
105
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
106 void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
107 m_config_push(m_config_t* config) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
108 m_config_option_t *co;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
109 m_config_save_slot_t *slot;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
110
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
111 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
112 assert(config != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
113 assert(config->lvl > 0);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
114 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
115
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
116 config->lvl++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
117
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
118 for(co = config->opts ; co ; co = co->next ) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
119 if(co->opt->type->flags & M_OPT_TYPE_HAS_CHILD)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
120 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
121 if(co->opt->flags & (M_OPT_GLOBAL|M_OPT_NOSAVE))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
122 continue;
9912
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
123 if((co->opt->flags & M_OPT_OLD) && !(co->flags && M_CFG_OPT_SET))
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
124 continue;
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
125 if(co->flags & M_CFG_OPT_ALIAS)
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
126 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
127
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
128 // Update the current status
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
129 m_option_save(co->opt,co->slots->data,co->opt->p);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
130
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
131 // Allocate a new slot
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
132 slot = (m_config_save_slot_t*)calloc(1,sizeof(m_config_save_slot_t) + co->opt->type->size);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
133 slot->lvl = config->lvl;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
134 slot->prev = co->slots;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
135 co->slots = slot;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
136 m_option_copy(co->opt,co->slots->data,co->slots->prev->data);
9912
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
137 // Reset our set flag
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
138 co->flags &= ~M_CFG_OPT_SET;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
139 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
140
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
141 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Config pushed level is now %d\n",config->lvl);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
142 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
143
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
144 void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
145 m_config_pop(m_config_t* config) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
146 m_config_option_t *co;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
147 m_config_save_slot_t *slot;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
148
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
149 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
150 assert(config != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
151 assert(config->lvl > 1);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
152 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
153
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
154 for(co = config->opts ; co ; co = co->next ) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
155 int pop = 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
156 if(co->opt->type->flags & M_OPT_TYPE_HAS_CHILD)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
157 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
158 if(co->opt->flags & (M_OPT_GLOBAL|M_OPT_NOSAVE))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
159 continue;
9912
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
160 if(co->flags & M_CFG_OPT_ALIAS)
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
161 continue;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
162 if(co->slots->lvl > config->lvl)
13699
11b249ef87b0 printf --> mp_msg by the Wanderer <inverseparadox at comcast dot net>
diego
parents: 10595
diff changeset
163 mp_msg(MSGT_CFGPARSER, MSGL_WARN,MSGTR_SaveSlotTooOld,config->lvl,co->slots->lvl);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
165 while(co->slots->lvl >= config->lvl) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
166 m_option_free(co->opt,co->slots->data);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
167 slot = co->slots;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
168 co->slots = slot->prev;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
169 free(slot);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
170 pop++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
171 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
172 if(pop) // We removed some ctx -> set the previous value
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
173 m_option_set(co->opt,co->opt->p,co->slots->data);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
174 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
175
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
176 config->lvl--;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
177 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Config poped level=%d\n",config->lvl);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
178 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
179
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
180 static void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
181 m_config_add_option(m_config_t *config, m_option_t *arg, char* prefix) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
182 m_config_option_t *co;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
183 m_config_save_slot_t* sl;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
184
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
185 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
186 assert(config != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
187 assert(config->lvl > 0);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
188 assert(arg != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
189 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
190
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
191 // Allocate a new entry for this option
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
192 co = (m_config_option_t*)calloc(1,sizeof(m_config_option_t) + arg->type->size);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
193 co->opt = arg;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
194
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
195 // Fill in the full name
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
196 if(prefix && strlen(prefix) > 0) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
197 int l = strlen(prefix) + 1 + strlen(arg->name) + 1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
198 co->name = (char*) malloc(l);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
199 sprintf(co->name,"%s:%s",prefix,arg->name);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
200 } else
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
201 co->name = arg->name;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
202
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
203 // Option with childs -> add them
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
204 if(arg->type->flags & M_OPT_TYPE_HAS_CHILD) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
205 m_option_t *ol = arg->p;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
206 int i;
13824
bad703951cf9 a few 10l fixes by Wei Jiang <jiangw98@yahoo.com>
faust3
parents: 13699
diff changeset
207 co->slots = NULL;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
208 for(i = 0 ; ol[i].name != NULL ; i++)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
209 m_config_add_option(config,&ol[i], co->name);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
210 } else {
9912
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
211 m_config_option_t *i;
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
212 // Check if there is alredy an option pointing to this address
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
213 if(arg->p) {
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
214 for(i = config->opts ; i ; i = i->next ) {
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
215 if(i->opt->p == arg->p) { // So we don't save the same vars more than 1 time
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
216 co->slots = i->slots;
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
217 co->flags |= M_CFG_OPT_ALIAS;
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
218 break;
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
219 }
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
220 }
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
221 }
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
222 if(!(co->flags & M_CFG_OPT_ALIAS)) {
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
223 // Allocate a slot for the defaults
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
224 sl = (m_config_save_slot_t*)calloc(1,sizeof(m_config_save_slot_t) + arg->type->size);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
225 m_option_save(arg,sl->data,(void**)arg->p);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
226 // Hack to avoid too much trouble with dynamicly allocated data :
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
227 // We always use a dynamic version
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
228 if((arg->type->flags & M_OPT_TYPE_DYNAMIC) && arg->p && (*(void**)arg->p)) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
229 *(void**)arg->p = NULL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
230 m_option_set(arg,arg->p,sl->data);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
231 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
232 sl->lvl = 0;
13824
bad703951cf9 a few 10l fixes by Wei Jiang <jiangw98@yahoo.com>
faust3
parents: 13699
diff changeset
233 sl->prev = NULL;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
234 co->slots = (m_config_save_slot_t*)calloc(1,sizeof(m_config_save_slot_t) + arg->type->size);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
235 co->slots->prev = sl;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
236 co->slots->lvl = config->lvl;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
237 m_option_copy(co->opt,co->slots->data,sl->data);
9912
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
238 } // !M_OPT_ALIAS
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
239 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
240 co->next = config->opts;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
241 config->opts = co;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
242 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
243
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
244 int
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
245 m_config_register_options(m_config_t *config, m_option_t *args) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
246 int i;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
247
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
248 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
249 assert(config != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
250 assert(config->lvl > 0);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
251 assert(args != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
252 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
253
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
254 for(i = 0 ; args[i].name != NULL ; i++)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
255 m_config_add_option(config,&args[i],NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
256
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
257 return 1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
258 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
259
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
260 static m_config_option_t*
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
261 m_config_get_co(m_config_t *config, char* arg) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
262 m_config_option_t *co;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
263
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
264 for(co = config->opts ; co ; co = co->next ) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
265 int l = strlen(co->name) - 1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
266 if((co->opt->type->flags & M_OPT_TYPE_ALLOW_WILDCARD) &&
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
267 (co->name[l] == '*')) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
268 if(strncasecmp(co->name,arg,l) == 0)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
269 return co;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
270 } else if(strcasecmp(co->name,arg) == 0)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
271 return co;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
272 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
273 return NULL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
274 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
275
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
276 static int
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
277 m_config_parse_option(m_config_t *config, char* arg, char* param,int set) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
278 m_config_option_t *co;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
279 int r = 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
280
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
281 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
282 assert(config != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
283 assert(config->lvl > 0);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
284 assert(arg != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
285 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
286
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
287 co = m_config_get_co(config,arg);
8892
06843e67a04b print meaningful error message
arpi
parents: 8512
diff changeset
288 if(!co){
8894
e6a83b140b39 better error handling for invalud suboptions
arpi
parents: 8892
diff changeset
289 // mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Unknown option: %s\n",arg);
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
290 return M_OPT_UNKNOWN;
8892
06843e67a04b print meaningful error message
arpi
parents: 8512
diff changeset
291 }
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
292
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
293 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
294 // This is the only mandatory function
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
295 assert(co->opt->type->parse);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
296 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
297
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
298 // Check if this option isn't forbiden in the current mode
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
299 if((config->mode == M_CONFIG_FILE) && (co->opt->flags & M_OPT_NOCFG)) {
13699
11b249ef87b0 printf --> mp_msg by the Wanderer <inverseparadox at comcast dot net>
diego
parents: 10595
diff changeset
300 mp_msg(MSGT_CFGPARSER, MSGL_ERR,MSGTR_InvalidCfgfileOption,arg);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
301 return M_OPT_INVALID;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
302 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
303 if((config->mode == M_COMMAND_LINE) && (co->opt->flags & M_OPT_NOCMD)) {
13699
11b249ef87b0 printf --> mp_msg by the Wanderer <inverseparadox at comcast dot net>
diego
parents: 10595
diff changeset
304 mp_msg(MSGT_CFGPARSER, MSGL_ERR,MSGTR_InvalidCmdlineOption,arg);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
305 return M_OPT_INVALID;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
306 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
307
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
308 // Option with childs are a bit different to parse
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
309 if(co->opt->type->flags & M_OPT_TYPE_HAS_CHILD) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
310 char** lst = NULL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
311 int i,sr;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
312 // Parse the child options
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9222
diff changeset
313 r = m_option_parse(co->opt,arg,param,&lst,M_COMMAND_LINE);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
314 // Set them now
8894
e6a83b140b39 better error handling for invalud suboptions
arpi
parents: 8892
diff changeset
315 if(r >= 0)
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
316 for(i = 0 ; lst && lst[2*i] ; i++) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
317 int l = strlen(co->name) + 1 + strlen(lst[2*i]) + 1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
318 if(r >= 0) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
319 // Build the full name
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
320 char n[l];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
321 sprintf(n,"%s:%s",co->name,lst[2*i]);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
322 sr = m_config_parse_option(config,n,lst[2*i+1],set);
8894
e6a83b140b39 better error handling for invalud suboptions
arpi
parents: 8892
diff changeset
323 if(sr < 0){
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
324 if(sr == M_OPT_UNKNOWN){
13699
11b249ef87b0 printf --> mp_msg by the Wanderer <inverseparadox at comcast dot net>
diego
parents: 10595
diff changeset
325 mp_msg(MSGT_CFGPARSER, MSGL_ERR,MSGTR_InvalidSuboption,co->name,lst[2*i]);
8894
e6a83b140b39 better error handling for invalud suboptions
arpi
parents: 8892
diff changeset
326 r = M_OPT_INVALID;
e6a83b140b39 better error handling for invalud suboptions
arpi
parents: 8892
diff changeset
327 } else
9222
d3da9b617aa8 print meaningful error message for missing parameter
arpi
parents: 8894
diff changeset
328 if(sr == M_OPT_MISSING_PARAM){
13699
11b249ef87b0 printf --> mp_msg by the Wanderer <inverseparadox at comcast dot net>
diego
parents: 10595
diff changeset
329 mp_msg(MSGT_CFGPARSER, MSGL_ERR,MSGTR_MissingSuboptionParameter,lst[2*i],co->name);
9222
d3da9b617aa8 print meaningful error message for missing parameter
arpi
parents: 8894
diff changeset
330 r = M_OPT_INVALID;
d3da9b617aa8 print meaningful error message for missing parameter
arpi
parents: 8894
diff changeset
331 } else
8894
e6a83b140b39 better error handling for invalud suboptions
arpi
parents: 8892
diff changeset
332 r = sr;
e6a83b140b39 better error handling for invalud suboptions
arpi
parents: 8892
diff changeset
333 }
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
334 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
335 free(lst[2*i]);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
336 free(lst[2*i+1]);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
337 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
338 if(lst) free(lst);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
339 } else
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
340 r = m_option_parse(co->opt,arg,param,set ? co->slots->data : NULL,config->mode);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
341
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
342 // Parsing failed ?
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
343 if(r < 0)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
344 return r;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
345 // Set the option
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
346 if(set) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
347 m_option_set(co->opt,co->opt->p,co->slots->data);
9912
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 9593
diff changeset
348 co->flags |= M_CFG_OPT_SET;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
349 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
350
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
351 return r;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
352 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
353
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
354 int
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
355 m_config_set_option(m_config_t *config, char* arg, char* param) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
356 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Setting %s=%s\n",arg,param);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
357 return m_config_parse_option(config,arg,param,1);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
358 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
359
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
360 int
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
361 m_config_check_option(m_config_t *config, char* arg, char* param) {
9222
d3da9b617aa8 print meaningful error message for missing parameter
arpi
parents: 8894
diff changeset
362 int r;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
363 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Checking %s=%s\n",arg,param);
9222
d3da9b617aa8 print meaningful error message for missing parameter
arpi
parents: 8894
diff changeset
364 r=m_config_parse_option(config,arg,param,0);
d3da9b617aa8 print meaningful error message for missing parameter
arpi
parents: 8894
diff changeset
365 if(r==M_OPT_MISSING_PARAM){
13699
11b249ef87b0 printf --> mp_msg by the Wanderer <inverseparadox at comcast dot net>
diego
parents: 10595
diff changeset
366 mp_msg(MSGT_CFGPARSER, MSGL_ERR,MSGTR_MissingOptionParameter,arg);
9222
d3da9b617aa8 print meaningful error message for missing parameter
arpi
parents: 8894
diff changeset
367 return M_OPT_INVALID;
d3da9b617aa8 print meaningful error message for missing parameter
arpi
parents: 8894
diff changeset
368 }
d3da9b617aa8 print meaningful error message for missing parameter
arpi
parents: 8894
diff changeset
369 return r;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
370 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
371
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
372
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
373 m_option_t*
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
374 m_config_get_option(m_config_t *config, char* arg) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
375 m_config_option_t *co;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
376
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
377 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
378 assert(config != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
379 assert(config->lvl > 0);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
380 assert(arg != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
381 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
382
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
383 co = m_config_get_co(config,arg);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
384 if(co)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
385 return co->opt;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
386 else
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
387 return NULL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
388 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
389
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
390 void*
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
391 m_config_get_option_ptr(m_config_t *config, char* arg) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
392 m_option_t* conf;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
393
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
394 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
395 assert(config != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
396 assert(arg != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
397 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
398
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
399 conf = m_config_get_option(config,arg);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
400 if(!conf) return NULL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
401 return conf->p;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
402 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
403
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
404 void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
405 m_config_print_option_list(m_config_t *config) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
406 char min[50],max[50];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
407 m_config_option_t* co;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
408 int count = 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
409
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
410 if(!config->opts) return;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
411
17481
99c0caec4677 Fix the MSG?_FIXME and make the profiles help translatable.
albeu
parents: 17472
diff changeset
412 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_OptionListHeader);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
413 for(co = config->opts ; co ; co = co->next) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
414 m_option_t* opt = co->opt;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
415 if(opt->type->flags & M_OPT_TYPE_HAS_CHILD) continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
416 if(opt->flags & M_OPT_MIN)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
417 sprintf(min,"%-8.0f",opt->min);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
418 else
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
419 strcpy(min,"No");
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
420 if(opt->flags & M_OPT_MAX)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
421 sprintf(max,"%-8.0f",opt->max);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
422 else
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
423 strcpy(max,"No");
17481
99c0caec4677 Fix the MSG?_FIXME and make the profiles help translatable.
albeu
parents: 17472
diff changeset
424 mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %-20.20s %-15.15s %-10.10s %-10.10s %-3.3s %-3.3s %-3.3s\n",
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
425 co->name,
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
426 co->opt->type->name,
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
427 min,
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
428 max,
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
429 opt->flags & CONF_GLOBAL ? "Yes" : "No",
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
430 opt->flags & CONF_NOCMD ? "No" : "Yes",
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
431 opt->flags & CONF_NOCFG ? "No" : "Yes");
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
432 count++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
433 }
17481
99c0caec4677 Fix the MSG?_FIXME and make the profiles help translatable.
albeu
parents: 17472
diff changeset
434 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_TotalOptions,count);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
435 }
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
436
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
437 m_profile_t*
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
438 m_config_get_profile(m_config_t* config, char* name) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
439 m_profile_t* p;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
440 for(p = config->profiles ; p ; p = p->next)
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
441 if(!strcmp(p->name,name)) return p;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
442 return NULL;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
443 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
444
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
445 m_profile_t*
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
446 m_config_add_profile(m_config_t* config, char* name) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
447 m_profile_t* p = m_config_get_profile(config,name);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
448 if(p) return p;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
449 p = calloc(1,sizeof(m_profile_t));
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
450 p->name = strdup(name);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
451 p->next = config->profiles;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
452 config->profiles = p;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
453 return p;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
454 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
455
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
456 void
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
457 m_profile_set_desc(m_profile_t* p, char* desc) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
458 if(p->desc) free(p->desc);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
459 p->desc = desc ? strdup(desc) : NULL;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
460 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
461
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
462 int
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
463 m_config_set_profile_option(m_config_t* config, m_profile_t* p,
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
464 char* name, char* val) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
465 int i = m_config_check_option(config,name,val);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
466 if(i < 0) return i;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
467 if(p->opts) p->opts = realloc(p->opts,2*(p->num_opts+2)*sizeof(char*));
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
468 else p->opts = malloc(2*(p->num_opts+2)*sizeof(char*));
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
469 p->opts[p->num_opts*2] = strdup(name);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
470 p->opts[p->num_opts*2+1] = val ? strdup(val) : NULL;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
471 p->num_opts++;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
472 p->opts[p->num_opts*2] = p->opts[p->num_opts*2+1] = NULL;
17856
98f0e0542cb6 10L fix missing return statement.
albeu
parents: 17481
diff changeset
473 return 1;
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
474 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
475
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
476 static void
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
477 m_config_set_profile(m_config_t* config, m_profile_t* p) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
478 int i;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
479 if(config->profile_depth > MAX_PROFILE_DEPTH) {
17481
99c0caec4677 Fix the MSG?_FIXME and make the profiles help translatable.
albeu
parents: 17472
diff changeset
480 mp_msg(MSGT_CFGPARSER, MSGL_WARN, MSGTR_TooDeepProfileInclusion);
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
481 return;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
482 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
483 config->profile_depth++;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
484 for(i = 0 ; i < p->num_opts ; i++)
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
485 m_config_set_option(config,p->opts[2*i],p->opts[2*i+1]);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
486 config->profile_depth--;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
487 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
488
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
489 static int
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
490 parse_profile(m_option_t* opt,char *name, char *param, void* dst, int src) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
491 m_config_t* config = opt->priv;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
492 char** list = NULL;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
493 int i,r;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
494 if(param && !strcmp(param,"help")) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
495 m_profile_t* p;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
496 if(!config->profiles) {
17481
99c0caec4677 Fix the MSG?_FIXME and make the profiles help translatable.
albeu
parents: 17472
diff changeset
497 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_NoProfileDefined);
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
498 return M_OPT_EXIT-1;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
499 }
17481
99c0caec4677 Fix the MSG?_FIXME and make the profiles help translatable.
albeu
parents: 17472
diff changeset
500 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_AvailableProfiles);
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
501 for(p = config->profiles ; p ; p = p->next)
17481
99c0caec4677 Fix the MSG?_FIXME and make the profiles help translatable.
albeu
parents: 17472
diff changeset
502 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\t%s\t%s\n",p->name,
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
503 p->desc ? p->desc : "");
17481
99c0caec4677 Fix the MSG?_FIXME and make the profiles help translatable.
albeu
parents: 17472
diff changeset
504 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n");
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
505 return M_OPT_EXIT-1;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
506 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
507
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
508 r = m_option_type_string_list.parse(opt,name,param,&list,src);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
509 if(r < 0) return r;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
510 if(!list || !list[0]) return M_OPT_INVALID;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
511 for(i = 0 ; list[i] ; i++)
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
512 if(!m_config_get_profile(config,list[i])) {
17481
99c0caec4677 Fix the MSG?_FIXME and make the profiles help translatable.
albeu
parents: 17472
diff changeset
513 mp_msg(MSGT_CFGPARSER, MSGL_WARN, MSGTR_UnknownProfile,
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
514 list[i]);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
515 r = M_OPT_INVALID;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
516 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
517 if(dst)
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
518 m_option_copy(opt,dst,&list);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
519 else
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
520 m_option_free(opt,&list);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
521 return r;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
522 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
523
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
524 static void
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
525 set_profile(m_option_t *opt, void* dst, void* src) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
526 m_config_t* config = opt->priv;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
527 m_profile_t* p;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
528 char** list = NULL;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
529 int i;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
530 if(!src || !*(char***)src) return;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
531 m_option_copy(opt,&list,src);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
532 for(i = 0 ; list[i] ; i++) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
533 p = m_config_get_profile(config,list[i]);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
534 if(!p) continue;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
535 m_config_set_profile(config,p);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
536 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
537 m_option_free(opt,&list);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
538 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
539
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
540 static int
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
541 show_profile(m_option_t *opt, char* name, char *param) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
542 m_config_t* config = opt->priv;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
543 m_profile_t* p;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
544 int i,j;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
545 if(!param) return M_OPT_MISSING_PARAM;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
546 if(!(p = m_config_get_profile(config,param))) {
17481
99c0caec4677 Fix the MSG?_FIXME and make the profiles help translatable.
albeu
parents: 17472
diff changeset
547 mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_UnknownProfile, param);
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
548 return M_OPT_EXIT-1;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
549 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
550 if(!config->profile_depth)
17481
99c0caec4677 Fix the MSG?_FIXME and make the profiles help translatable.
albeu
parents: 17472
diff changeset
551 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_Profile, param,
17471
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
552 p->desc ? p->desc : "");
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
553 config->profile_depth++;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
554 for(i = 0 ; i < p->num_opts ; i++) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
555 char spc[config->profile_depth+1];
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
556 for(j = 0 ; j < config->profile_depth ; j++)
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
557 spc[j] = ' ';
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
558 spc[config->profile_depth] = '\0';
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
559
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
560 mp_msg(MSGT_CFGPARSER, MSGL_INFO, "%s%s=%s\n", spc,
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
561 p->opts[2*i], p->opts[2*i+1]);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
562
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
563
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
564 if(config->profile_depth < MAX_PROFILE_DEPTH &&
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
565 !strcmp(p->opts[2*i],"profile")) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
566 char* e,*list = p->opts[2*i+1];
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
567 while((e = strchr(list,','))) {
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
568 int l = e-list;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
569 char tmp[l+1];
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
570 if(!l) continue;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
571 memcpy(tmp,list,l);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
572 tmp[l] = '\0';
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
573 show_profile(opt,name,tmp);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
574 list = e+1;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
575 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
576 if(list[0] != '\0')
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
577 show_profile(opt,name,list);
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
578 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
579 }
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
580 config->profile_depth--;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
581 if(!config->profile_depth) mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n");
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
582 return M_OPT_EXIT-1;
63909962d3fc Profiles support.
albeu
parents: 13824
diff changeset
583 }
17472
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 17471
diff changeset
584
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 17471
diff changeset
585 static int
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 17471
diff changeset
586 list_options(m_option_t *opt, char* name, char *param) {
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 17471
diff changeset
587 m_config_t* config = opt->priv;
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 17471
diff changeset
588 m_config_print_option_list(config);
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 17471
diff changeset
589 return M_OPT_EXIT;
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 17471
diff changeset
590 }