Mercurial > mplayer.hg
comparison m_option.h @ 10594:57bdcdb061d7
Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
author | alex |
---|---|
date | Wed, 13 Aug 2003 16:29:32 +0000 |
parents | 73e7a5165bcd |
children | 522afd56703c |
comparison
equal
deleted
inserted
replaced
10593:27711ab2889f | 10594:57bdcdb061d7 |
---|---|
1 | 1 #ifndef _M_OPTION_H |
2 #ifndef NEW_CONFIG | 2 #define _M_OPTION_H |
3 #warning "Including m_option.h but NEW_CONFIG is disabled" | |
4 #else | |
5 | 3 |
6 typedef struct m_option_type m_option_type_t; | 4 typedef struct m_option_type m_option_type_t; |
7 typedef struct m_option m_option_t; | 5 typedef struct m_option m_option_t; |
8 struct m_struct_st; | 6 struct m_struct_st; |
9 | 7 |
74 int end; | 72 int end; |
75 } m_span_t; | 73 } m_span_t; |
76 extern m_obj_params_t m_span_params_def; | 74 extern m_obj_params_t m_span_params_def; |
77 | 75 |
78 | 76 |
79 // Don't be stupid keep tho old names ;-) | 77 // FIXME: backward compatibility |
80 #define CONF_TYPE_FLAG (&m_option_type_flag) | 78 #define CONF_TYPE_FLAG (&m_option_type_flag) |
81 #define CONF_TYPE_INT (&m_option_type_int) | 79 #define CONF_TYPE_INT (&m_option_type_int) |
82 #define CONF_TYPE_FLOAT (&m_option_type_float) | 80 #define CONF_TYPE_FLOAT (&m_option_type_float) |
83 #define CONF_TYPE_STRING (&m_option_type_string) | 81 #define CONF_TYPE_STRING (&m_option_type_string) |
84 #define CONF_TYPE_FUNC (&m_option_type_func) | 82 #define CONF_TYPE_FUNC (&m_option_type_func) |
85 #define CONF_TYPE_FUNC_PARAM (&m_option_type_func_param) | 83 #define CONF_TYPE_FUNC_PARAM (&m_option_type_func_param) |
86 #define CONF_TYPE_PRINT (&m_option_type_print) | 84 #define CONF_TYPE_PRINT (&m_option_type_print) |
87 #define CONF_TYPE_PRINT_INDIRECT (&m_option_type_print_indirect) | 85 #define CONF_TYPE_PRINT_INDIRECT (&m_option_type_print_indirect) |
88 #define CONF_TYPE_FUNC_FULL (&m_option_type_func_full) | 86 #define CONF_TYPE_FUNC_FULL (&m_option_type_func_full) |
89 #define CONF_TYPE_SUBCONFIG (&m_option_type_subconfig) | 87 #define CONF_TYPE_SUBCONFIG (&m_option_type_subconfig) |
90 #define CONF_TYPE_STRING_LIST (&m_option_type_string_list) | 88 #define CONF_TYPE_STRING_LIST (&m_option_type_string_list) |
91 #define CONF_TYPE_POSITION (&m_option_type_position) | 89 #define CONF_TYPE_POSITION (&m_option_type_position) |
92 #define CONF_TYPE_IMGFMT (&m_option_type_imgfmt) | 90 #define CONF_TYPE_IMGFMT (&m_option_type_imgfmt) |
93 #define CONF_TYPE_SPAN (&m_option_type_span) | 91 #define CONF_TYPE_SPAN (&m_option_type_span) |
94 #define CONF_TYPE_OBJ_SETTINGS_LIST (&m_option_type_obj_settings_list) | 92 #define CONF_TYPE_OBJ_SETTINGS_LIST (&m_option_type_obj_settings_list) |
95 #define CONF_TYPE_OBJ_PRESETS (&m_option_type_obj_presets) | 93 #define CONF_TYPE_OBJ_PRESETS (&m_option_type_obj_presets) |
96 #define CONF_TYPE_CUSTOM_URL (&m_option_type_custom_url) | 94 #define CONF_TYPE_CUSTOM_URL (&m_option_type_custom_url) |
97 #define CONF_TYPE_OBJ_PARAMS (&m_option_type_obj_params) | 95 #define CONF_TYPE_OBJ_PARAMS (&m_option_type_obj_params) |
98 | 96 |
99 ///////////////////////////////////////////////////////////////////////////////////////////// | 97 ///////////////////////////////////////////////////////////////////////////////////////////// |
100 | 98 |
101 struct m_option_type { | 99 struct m_option_type { |
102 char* name; | 100 char* name; |
124 void (*copy)(m_option_t* opt,void* dst, void* src); | 122 void (*copy)(m_option_t* opt,void* dst, void* src); |
125 // Free the data allocated for a save slot if needed | 123 // Free the data allocated for a save slot if needed |
126 void (*free)(void* dst); | 124 void (*free)(void* dst); |
127 }; | 125 }; |
128 | 126 |
129 /// This is the same thing as a struct config it have been renamed | |
130 /// to remove this config_t, m_config_t mess. Sorry about that, | |
131 /// config_t is still provided for backward compat. | |
132 struct m_option { | 127 struct m_option { |
133 char *name; | 128 char *name; |
134 void *p; | 129 void *p; |
135 m_option_type_t* type; | 130 m_option_type_t* type; |
136 unsigned int flags; | 131 unsigned int flags; |
158 // line parser will put it with it's entry (ie : it may be set later) | 153 // line parser will put it with it's entry (ie : it may be set later) |
159 // e.g options : -include | 154 // e.g options : -include |
160 #define M_OPT_NOSAVE (1<<5) | 155 #define M_OPT_NOSAVE (1<<5) |
161 // Emulate old behaviour by pushing the option only if it was set by the user | 156 // Emulate old behaviour by pushing the option only if it was set by the user |
162 #define M_OPT_OLD (1<<6) | 157 #define M_OPT_OLD (1<<6) |
158 | |
159 // FIXME: backward compatibility | |
160 #define CONF_MIN M_OPT_MIN | |
161 #define CONF_MAX M_OPT_MAX | |
162 #define CONF_RANGE M_OPT_RANGE | |
163 #define CONF_NOCFG M_OPT_NOCFG | |
164 #define CONF_NOCMD M_OPT_NOCMD | |
165 #define CONF_GLOBAL M_OPT_GLOBAL | |
166 #define CONF_NOSAVE M_OPT_NOSAVE | |
167 #define CONF_OLD M_OPT_OLD | |
163 | 168 |
164 | 169 |
165 ///////////////////////////// Option type flags /////////////////////////////////// | 170 ///////////////////////////// Option type flags /////////////////////////////////// |
166 | 171 |
167 // These flags are for the parsers. The description here apply to the m_config_t | 172 // These flags are for the parsers. The description here apply to the m_config_t |
204 // Option parser error code | 209 // Option parser error code |
205 #define M_OPT_UNKNOW -1 | 210 #define M_OPT_UNKNOW -1 |
206 #define M_OPT_MISSING_PARAM -2 | 211 #define M_OPT_MISSING_PARAM -2 |
207 #define M_OPT_INVALID -3 | 212 #define M_OPT_INVALID -3 |
208 #define M_OPT_OUT_OF_RANGE -4 | 213 #define M_OPT_OUT_OF_RANGE -4 |
209 #define M_OPT_PARSER_ERR -5 | 214 #define M_OPT_PARSER_ERR -5 |
210 #define M_OPT_EXIT -6 | 215 #define M_OPT_EXIT -6 |
216 | |
217 // FIXME: backward compatibility | |
218 #define ERR_NOT_AN_OPTION M_OPT_UNKNOWN | |
219 #define ERR_MISSING_PARAM M_OPT_MISSING_PARAM | |
220 #define ERR_OUT_OF_RANGE M_OPT_OUT_OF_RANGE | |
221 #define ERR_FUNC_ERR M_OPT_PARSER_ERR | |
211 | 222 |
212 m_option_t* m_option_list_find(m_option_t* list,char* name); | 223 m_option_t* m_option_list_find(m_option_t* list,char* name); |
213 | 224 |
214 inline static int | 225 inline static int |
215 m_option_parse(m_option_t* opt,char *name, char *param, void* dst, int src) { | 226 m_option_parse(m_option_t* opt,char *name, char *param, void* dst, int src) { |
248 m_option_free(m_option_t* opt,void* dst) { | 259 m_option_free(m_option_t* opt,void* dst) { |
249 if(opt->type->free) | 260 if(opt->type->free) |
250 opt->type->free(dst); | 261 opt->type->free(dst); |
251 } | 262 } |
252 | 263 |
253 #endif | 264 #endif /* _M_OPTION_H */ |