Mercurial > mplayer.hg
annotate m_option.h @ 21686:79bb02931e40
Fix compilation of non-MMX code with gcc 2.95
author | lucabe |
---|---|
date | Wed, 20 Dec 2006 15:58:15 +0000 |
parents | 02a18c52a42a |
children | cca9ff25bed2 |
rev | line source |
---|---|
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.
alex
parents:
10590
diff
changeset
|
1 #ifndef _M_OPTION_H |
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.
alex
parents:
10590
diff
changeset
|
2 #define _M_OPTION_H |
8164 | 3 |
18258 | 4 /// \defgroup Options |
18283 | 5 /// m_option allows to parse, print and copy data of various types. |
18258 | 6 /// It is the base of the \ref OptionsStruct, \ref Config and |
7 /// \ref Properties APIs. | |
8 ///@{ | |
9 | |
10 /// \file m_option.h | |
11 | |
12 /// \ingroup OptionTypes | |
8164 | 13 typedef struct m_option_type m_option_type_t; |
14 typedef struct m_option m_option_t; | |
9793 | 15 struct m_struct_st; |
8164 | 16 |
18258 | 17 /// \defgroup OptionTypes Options types |
18 /// \ingroup Options | |
19 ///@{ | |
20 | |
8164 | 21 ///////////////////////////// Options types declarations //////////////////////////// |
22 | |
23 // Simple types | |
24 extern m_option_type_t m_option_type_flag; | |
25 extern m_option_type_t m_option_type_int; | |
26 extern m_option_type_t m_option_type_float; | |
11947 | 27 extern m_option_type_t m_option_type_double; |
8164 | 28 extern m_option_type_t m_option_type_string; |
29 extern m_option_type_t m_option_type_string_list; | |
30 extern m_option_type_t m_option_type_position; | |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19053
diff
changeset
|
31 extern m_option_type_t m_option_type_time_size; |
8164 | 32 |
33 extern m_option_type_t m_option_type_print; | |
8736 | 34 extern m_option_type_t m_option_type_print_indirect; |
17470
21123e349463
New option type to print help text with a function.
albeu
parents:
17456
diff
changeset
|
35 extern m_option_type_t m_option_type_print_func; |
8164 | 36 extern m_option_type_t m_option_type_subconfig; |
37 extern m_option_type_t m_option_type_imgfmt; | |
14246 | 38 extern m_option_type_t m_option_type_afmt; |
8164 | 39 |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
40 // Func-based types |
8164 | 41 extern m_option_type_t m_option_type_func_full; |
42 extern m_option_type_t m_option_type_func_param; | |
43 extern m_option_type_t m_option_type_func; | |
44 | |
18258 | 45 /// Callback used to reset func options. |
8164 | 46 typedef void (*m_opt_default_func_t)(m_option_t *, char*); |
18258 | 47 |
48 /// Callback used by m_option_type_func_full options. | |
8164 | 49 typedef int (*m_opt_func_full_t)(m_option_t *, char *, char *); |
18258 | 50 |
51 /// Callback used by m_option_type_func_param options. | |
8164 | 52 typedef int (*m_opt_func_param_t)(m_option_t *, char *); |
18258 | 53 |
54 /// Callback used by m_option_type_func options. | |
8164 | 55 typedef int (*m_opt_func_t)(m_option_t *); |
18258 | 56 |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
57 // Backwards compatibility |
8164 | 58 typedef m_opt_default_func_t cfg_default_func_t; |
59 typedef m_opt_func_full_t cfg_func_arg_param_t; | |
60 typedef m_opt_func_param_t cfg_func_param_t; | |
61 typedef m_opt_func_t cfg_func_t; | |
62 | |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19053
diff
changeset
|
63 #define END_AT_NONE 0 |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19053
diff
changeset
|
64 #define END_AT_TIME 1 |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19053
diff
changeset
|
65 #define END_AT_SIZE 2 |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19053
diff
changeset
|
66 typedef struct { |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19053
diff
changeset
|
67 double pos; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19053
diff
changeset
|
68 int type; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19053
diff
changeset
|
69 } m_time_size_t; |
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19053
diff
changeset
|
70 |
18258 | 71 /// Extra definition needed for \ref m_option_type_obj_settings_list options. |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
72 typedef struct { |
18258 | 73 /// Pointer to an array of pointer to some object type description struct. |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
74 void** list; |
18258 | 75 /// Offset of the object type name (char*) in the description struct. |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
76 void* name_off; |
18258 | 77 /// Offset of the object type info string (char*) in the description struct. |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
78 void* info_off; |
18258 | 79 /// \brief Offset of the object type parameter description (\ref m_struct_st) |
80 /// in the description struct. | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
81 void* desc_off; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
82 } m_obj_list_t; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
83 |
18258 | 84 /// The data type used by \ref m_option_type_obj_settings_list. |
85 typedef struct m_obj_settings { | |
86 /// Type of the object. | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
87 char* name; |
18258 | 88 /// NULL terminated array of parameter/value pairs. |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
89 char** attribs; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
90 } m_obj_settings_t; |
18258 | 91 |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
92 /// A parser to set up a list of objects. |
18283 | 93 /** It creates a NULL terminated array \ref m_obj_settings. The option priv |
18258 | 94 * field (\ref m_option::priv) must point to a \ref m_obj_list_t describing |
95 * the available object types. | |
96 */ | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
97 extern m_option_type_t m_option_type_obj_settings_list; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
98 |
18258 | 99 /// Extra definition needed for \ref m_option_type_obj_presets options. |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
100 typedef struct { |
18258 | 101 /// Description of the struct holding the presets. |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
102 struct m_struct_st* in_desc; |
18258 | 103 /// Description of the struct that should be set by the presets. |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
104 struct m_struct_st* out_desc; |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
105 /// Pointer to an array of structs defining the various presets. |
18258 | 106 void* presets; |
107 /// Offset of the preset's name inside the in_struct. | |
108 void* name_off; | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
109 } m_obj_presets_t; |
18258 | 110 |
111 /// Set several fields in a struct at once. | |
18283 | 112 /** For this two struct descriptions are used. One for the struct holding the |
18258 | 113 * preset and one for the struct beeing set. Every field present in both |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
114 * structs will be copied from the preset struct to the destination one. |
18258 | 115 * The option priv field (\ref m_option::priv) must point to a correctly |
116 * filled \ref m_obj_presets_t. | |
117 */ | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
118 extern m_option_type_t m_option_type_obj_presets; |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
119 |
18258 | 120 /// Parse an URL into a struct. |
121 /** The option priv field (\ref m_option::priv) must point to a | |
122 * \ref m_struct_st describing which fields of the URL must be used. | |
123 */ | |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
124 extern m_option_type_t m_option_type_custom_url; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
125 |
18258 | 126 /// Extra definition needed for \ref m_option_type_obj_params options. |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
127 typedef struct { |
18283 | 128 /// Field descriptions. |
18258 | 129 struct m_struct_st* desc; |
130 /// Field separator to use. | |
131 char separator; | |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
132 } m_obj_params_t; |
18258 | 133 |
134 /// Parse a set of parameters. | |
135 /** Parameters are separated by the given separator and each one | |
18283 | 136 * successively sets a field from the struct. The option priv field |
18258 | 137 * (\ref m_option::priv) must point to a \ref m_obj_params_t. |
138 */ | |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
139 extern m_option_type_t m_option_type_obj_params; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
140 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
141 typedef struct { |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
142 int start; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
143 int end; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
144 } m_span_t; |
18258 | 145 /// Ready made settings to parse a \ref m_span_t with a start-end syntax. |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
146 extern m_obj_params_t m_span_params_def; |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
147 |
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
148 |
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.
alex
parents:
10590
diff
changeset
|
149 // FIXME: backward compatibility |
8164 | 150 #define CONF_TYPE_FLAG (&m_option_type_flag) |
151 #define CONF_TYPE_INT (&m_option_type_int) | |
152 #define CONF_TYPE_FLOAT (&m_option_type_float) | |
11947 | 153 #define CONF_TYPE_DOUBLE (&m_option_type_double) |
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.
alex
parents:
10590
diff
changeset
|
154 #define CONF_TYPE_STRING (&m_option_type_string) |
8164 | 155 #define CONF_TYPE_FUNC (&m_option_type_func) |
156 #define CONF_TYPE_FUNC_PARAM (&m_option_type_func_param) | |
157 #define CONF_TYPE_PRINT (&m_option_type_print) | |
8736 | 158 #define CONF_TYPE_PRINT_INDIRECT (&m_option_type_print_indirect) |
17470
21123e349463
New option type to print help text with a function.
albeu
parents:
17456
diff
changeset
|
159 #define CONF_TYPE_PRINT_FUNC (&m_option_type_print_func) |
8164 | 160 #define CONF_TYPE_FUNC_FULL (&m_option_type_func_full) |
161 #define CONF_TYPE_SUBCONFIG (&m_option_type_subconfig) | |
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.
alex
parents:
10590
diff
changeset
|
162 #define CONF_TYPE_STRING_LIST (&m_option_type_string_list) |
8164 | 163 #define CONF_TYPE_POSITION (&m_option_type_position) |
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.
alex
parents:
10590
diff
changeset
|
164 #define CONF_TYPE_IMGFMT (&m_option_type_imgfmt) |
14246 | 165 #define CONF_TYPE_AFMT (&m_option_type_afmt) |
8164 | 166 #define CONF_TYPE_SPAN (&m_option_type_span) |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8736
diff
changeset
|
167 #define CONF_TYPE_OBJ_SETTINGS_LIST (&m_option_type_obj_settings_list) |
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.
alex
parents:
10590
diff
changeset
|
168 #define CONF_TYPE_OBJ_PRESETS (&m_option_type_obj_presets) |
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.
alex
parents:
10590
diff
changeset
|
169 #define CONF_TYPE_CUSTOM_URL (&m_option_type_custom_url) |
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.
alex
parents:
10590
diff
changeset
|
170 #define CONF_TYPE_OBJ_PARAMS (&m_option_type_obj_params) |
19973
02a18c52a42a
after a long time, finally i could add -endpos option to mplayer executable.
ptt
parents:
19053
diff
changeset
|
171 #define CONF_TYPE_TIME_SIZE (&m_option_type_time_size) |
8164 | 172 |
173 ///////////////////////////////////////////////////////////////////////////////////////////// | |
174 | |
18258 | 175 /// Option type description |
8164 | 176 struct m_option_type { |
177 char* name; | |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
178 /// Syntax description, etc |
18258 | 179 char* comments; |
180 /// Size needed for the data. | |
181 unsigned int size; | |
182 /// See \ref OptionTypeFlags. | |
8164 | 183 unsigned int flags; |
18258 | 184 |
185 /// Parse the data from a string. | |
186 /** It is the only required function, all others can be NULL. | |
187 * | |
188 * \param opt The option that is parsed. | |
189 * \param name The full option name. | |
190 * \param param The parameter to parse. | |
18283 | 191 * \param dst Pointer to the memory where the data should be written. |
18258 | 192 * If NULL the parameter validity should still be checked. |
193 * \param src Source of the option, see \ref OptionParserModes. | |
18283 | 194 * \return On error a negative value is returned, on success the number of arguments |
18258 | 195 * consumed. For details see \ref OptionParserReturn. |
196 */ | |
8164 | 197 int (*parse)(m_option_t* opt,char *name, char *param, void* dst, int src); |
18258 | 198 |
199 /// Print back a value in string form. | |
200 /** \param opt The option to print. | |
201 * \param val Pointer to the memory holding the data to be printed. | |
202 * \return An allocated string containing the text value or (void*)-1 | |
203 * on error. | |
204 */ | |
8164 | 205 char* (*print)(m_option_t* opt, void* val); |
206 | |
18258 | 207 /** \name |
208 * These functions are called to save/set/restore the status of the | |
18283 | 209 * variables. The difference between the 3 only matters for types like |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
210 * \ref m_option_type_func where 'setting' needs to do more than just |
18258 | 211 * copying some data. |
212 */ | |
213 //@{ | |
214 | |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
215 /// Update a save slot (dst) from the current value in the program (src). |
18258 | 216 /** \param opt The option to copy. |
217 * \param dst Pointer to the destination memory. | |
218 * \param src Pointer to the source memory. | |
219 */ | |
8164 | 220 void (*save)(m_option_t* opt,void* dst, void* src); |
18258 | 221 |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
222 /// Set the value in the program (dst) from a save slot. |
18258 | 223 /** \param opt The option to copy. |
224 * \param dst Pointer to the destination memory. | |
225 * \param src Pointer to the source memory. | |
226 */ | |
8164 | 227 void (*set)(m_option_t* opt,void* dst, void* src); |
18258 | 228 |
229 /// Copy the data between two save slots. If NULL and size is > 0 a memcpy will be used. | |
230 /** \param opt The option to copy. | |
231 * \param dst Pointer to the destination memory. | |
232 * \param src Pointer to the source memory. | |
233 */ | |
8164 | 234 void (*copy)(m_option_t* opt,void* dst, void* src); |
18258 | 235 //@} |
236 | |
237 /// Free the data allocated for a save slot. | |
238 /** This is only needed for dynamic types like strings. | |
239 * \param dst Pointer to the data, usually a pointer that should be freed and | |
240 * set to NULL. | |
241 */ | |
8164 | 242 void (*free)(void* dst); |
243 }; | |
244 | |
18258 | 245 ///@} |
246 | |
247 /// Option description | |
248 /** \ingroup Options | |
249 */ | |
8164 | 250 struct m_option { |
18258 | 251 /// Option name. |
8164 | 252 char *name; |
18258 | 253 |
254 /// Reserved for higher level APIs, it shouldn't be used by parsers. | |
255 /** The suboption parser and func types do use it. They should instead | |
18283 | 256 * use the priv field but this was inherited from older versions of the |
18258 | 257 * config code. |
258 */ | |
259 void *p; | |
260 | |
261 /// Option type. | |
8164 | 262 m_option_type_t* type; |
18258 | 263 |
264 /// See \ref OptionFlags. | |
8164 | 265 unsigned int flags; |
18258 | 266 |
18283 | 267 /// \brief Mostly useful for numeric types, the \ref M_OPT_MIN flags must |
18258 | 268 /// also be set. |
269 double min; | |
270 | |
18283 | 271 /// \brief Mostly useful for numeric types, the \ref M_OPT_MAX flags must |
18258 | 272 /// also be set. |
273 double max; | |
274 | |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
275 /// Type dependent data (for all kinds of extended settings). |
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
276 /** This used to be a function pointer to hold a 'reverse to defaults' func. |
18258 | 277 * Now it can be used to pass any type of extra args needed by the parser. |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
278 * Passing a 'default func' is still valid for all func based option types. |
18258 | 279 */ |
280 void* priv; | |
8164 | 281 }; |
282 | |
283 | |
18258 | 284 /// \defgroup OptionFlags Option flags |
285 ///@{ | |
8164 | 286 |
18283 | 287 /// The option has a minimum set in \ref m_option::min. |
8164 | 288 #define M_OPT_MIN (1<<0) |
18258 | 289 |
18283 | 290 /// The option has a maximum set in \ref m_option::max. |
8164 | 291 #define M_OPT_MAX (1<<1) |
18258 | 292 |
18283 | 293 /// The option has a minimum and maximum in \ref m_option::min and \ref m_option::max. |
8164 | 294 #define M_OPT_RANGE (M_OPT_MIN|M_OPT_MAX) |
18258 | 295 |
296 /// The option is forbidden in config files. | |
8164 | 297 #define M_OPT_NOCFG (1<<2) |
18258 | 298 |
18283 | 299 /// The option is forbidden on the command line. |
8164 | 300 #define M_OPT_NOCMD (1<<3) |
18258 | 301 |
302 /// The option is global in the \ref Config. | |
303 /** It won't be saved on push and the command line parser will set it when | |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
304 * it's parsed (i.e. it won't be set later) |
18258 | 305 * e.g options : -v, -quiet |
306 */ | |
8164 | 307 #define M_OPT_GLOBAL (1<<4) |
18258 | 308 |
309 /// The \ref Config won't save this option on push. | |
18283 | 310 /** It won't be saved on push but the command line parser will add it with |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
311 * its entry (i.e. it may be set later) |
18258 | 312 * e.g options : -include |
313 */ | |
8164 | 314 #define M_OPT_NOSAVE (1<<5) |
18258 | 315 |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
316 /// \brief The \ref Config will emulate the old behavior by pushing the |
18258 | 317 /// option only if it was set by the user. |
8164 | 318 #define M_OPT_OLD (1<<6) |
319 | |
18258 | 320 /// \defgroup OldOptionFlags Backward compatibility |
321 /// | |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
322 /// These are kept for compatibility with older code. |
18258 | 323 /// @{ |
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.
alex
parents:
10590
diff
changeset
|
324 #define CONF_MIN M_OPT_MIN |
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.
alex
parents:
10590
diff
changeset
|
325 #define CONF_MAX M_OPT_MAX |
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.
alex
parents:
10590
diff
changeset
|
326 #define CONF_RANGE M_OPT_RANGE |
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.
alex
parents:
10590
diff
changeset
|
327 #define CONF_NOCFG M_OPT_NOCFG |
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.
alex
parents:
10590
diff
changeset
|
328 #define CONF_NOCMD M_OPT_NOCMD |
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.
alex
parents:
10590
diff
changeset
|
329 #define CONF_GLOBAL M_OPT_GLOBAL |
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.
alex
parents:
10590
diff
changeset
|
330 #define CONF_NOSAVE M_OPT_NOSAVE |
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.
alex
parents:
10590
diff
changeset
|
331 #define CONF_OLD M_OPT_OLD |
18258 | 332 ///@} |
8164 | 333 |
18258 | 334 ///@} |
8164 | 335 |
18258 | 336 /// \defgroup OptionTypeFlags Option type flags |
337 /// \ingroup OptionTypes | |
338 /// | |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
339 /// These flags are used to describe special parser capabilities or behavior. |
18258 | 340 /// |
341 ///@{ | |
342 | |
343 /// Suboption parser flag. | |
344 /** When this flag is set, m_option::p should point to another m_option | |
345 * array. Only the parse function will be called. If dst is set, it should | |
346 * create/update an array of char* containg opt/val pairs. The options in | |
347 * the child array will then be set automatically by the \ref Config. | |
18283 | 348 * Also note that suboptions may be directly accessed by using |
18258 | 349 * -option:subopt blah. |
350 */ | |
8164 | 351 #define M_OPT_TYPE_HAS_CHILD (1<<0) |
18258 | 352 |
353 /// Wildcard matching flag. | |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
354 /** If set the option type has a use for option names ending with a * |
18283 | 355 * (used for -aa*), this only affects the option name matching. |
18258 | 356 */ |
8164 | 357 #define M_OPT_TYPE_ALLOW_WILDCARD (1<<1) |
18258 | 358 |
359 /// Dynamic data type. | |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
360 /** This flag indicates that the data is dynamically allocated (m_option::p |
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
361 * points to a pointer). It enables a little hack in the \ref Config wich |
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
362 * replaces the initial value of such variables with a dynamic copy in case |
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
363 * the initial value is statically allocated (pretty common with strings). |
18258 | 364 */ |
8164 | 365 #define M_OPT_TYPE_DYNAMIC (1<<2) |
18258 | 366 |
367 /// Indirect option type. | |
368 /** If this is set the parse function doesn't directly return | |
369 * the wanted thing. Options use this if for some reasons they have to wait | |
370 * until the set call to be able to correctly set the target var. | |
371 * So for those types new values must first be parsed, then set to the target | |
372 * var. If this flag isn't set then new values can be parsed directly to the | |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
373 * target var. It's used by the callback-based options as the callback call |
18258 | 374 * may append later on. |
375 */ | |
8164 | 376 #define M_OPT_TYPE_INDIRECT (1<<3) |
377 | |
18258 | 378 ///@} |
8164 | 379 |
380 ///////////////////////////// Parser flags //////////////////////////////////////// | |
381 | |
18258 | 382 /// \defgroup OptionParserModes Option parser modes |
383 /// \ingroup Options | |
384 /// | |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
385 /// Some parsers behave differently depending on the mode passed in the src |
18258 | 386 /// parameter of m_option_type::parse. For example the flag type doesn't take |
387 /// an argument when parsing from the command line. | |
388 ///@{ | |
389 | |
390 /// Set when parsing from a config file. | |
8164 | 391 #define M_CONFIG_FILE 0 |
18258 | 392 /// Set when parsing command line arguments. |
8164 | 393 #define M_COMMAND_LINE 1 |
394 | |
18258 | 395 ///@} |
396 | |
397 /// \defgroup OptionParserReturn Option parser return code | |
398 /// \ingroup Options | |
399 /// | |
18283 | 400 /// On success parsers return the number of arguments consumed: 0 or 1. |
18258 | 401 /// |
18283 | 402 /// To indicate that MPlayer should exit without playing anything, |
18258 | 403 /// parsers return M_OPT_EXIT minus the number of parameters they |
404 /// consumed: \ref M_OPT_EXIT or \ref M_OPT_EXIT-1. | |
405 /// | |
18283 | 406 /// On error one of the following (negative) error codes is returned: |
18258 | 407 ///@{ |
408 | |
18283 | 409 /// For use by higher level APIs when the option name is invalid. |
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
|
410 #define M_OPT_UNKNOWN -1 |
18258 | 411 |
412 /// Returned when a parameter is needed but wasn't provided. | |
8164 | 413 #define M_OPT_MISSING_PARAM -2 |
18258 | 414 |
415 /// Returned when the given parameter couldn't be parsed. | |
8164 | 416 #define M_OPT_INVALID -3 |
18258 | 417 |
418 /// \brief Returned if the value is "out of range". The exact meaning may | |
419 /// vary from type to type. | |
8164 | 420 #define M_OPT_OUT_OF_RANGE -4 |
18258 | 421 |
422 /// Returned if the parser failed for any other reason than a bad parameter. | |
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.
alex
parents:
10590
diff
changeset
|
423 #define M_OPT_PARSER_ERR -5 |
18258 | 424 |
425 /// Returned when MPlayer should exit. Used by various help stuff. | |
426 /** M_OPT_EXIT must be the lowest number on this list. | |
427 */ | |
9791
c5b63e88253d
Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents:
9593
diff
changeset
|
428 #define M_OPT_EXIT -6 |
8164 | 429 |
18258 | 430 /// \defgroup OldOptionParserReturn Backward compatibility |
431 /// | |
18283 | 432 /// These are kept for compatibility with older code. |
18258 | 433 /// |
434 ///@{ | |
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.
alex
parents:
10590
diff
changeset
|
435 #define ERR_NOT_AN_OPTION M_OPT_UNKNOWN |
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.
alex
parents:
10590
diff
changeset
|
436 #define ERR_MISSING_PARAM M_OPT_MISSING_PARAM |
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.
alex
parents:
10590
diff
changeset
|
437 #define ERR_OUT_OF_RANGE M_OPT_OUT_OF_RANGE |
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.
alex
parents:
10590
diff
changeset
|
438 #define ERR_FUNC_ERR M_OPT_PARSER_ERR |
18258 | 439 ///@} |
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.
alex
parents:
10590
diff
changeset
|
440 |
18258 | 441 ///@} |
442 | |
443 /// Find the option matching the given name in the list. | |
444 /** \ingroup Options | |
18283 | 445 * This function takes the possible wildcards into account (see |
18258 | 446 * \ref M_OPT_TYPE_ALLOW_WILDCARD). |
447 * | |
448 * \param list Pointer to an array of \ref m_option. | |
449 * \param name Name of the option. | |
450 * \return The matching option or NULL. | |
451 */ | |
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:
18316
diff
changeset
|
452 m_option_t* m_option_list_find(m_option_t* list,const char* name); |
8164 | 453 |
18258 | 454 /// Helper to parse options, see \ref m_option_type::parse. |
8164 | 455 inline static int |
456 m_option_parse(m_option_t* opt,char *name, char *param, void* dst, int src) { | |
457 return opt->type->parse(opt,name,param,dst,src); | |
458 } | |
459 | |
18258 | 460 /// Helper to print options, see \ref m_option_type::print. |
8164 | 461 inline static char* |
462 m_option_print(m_option_t* opt, void* val_ptr) { | |
463 if(opt->type->print) | |
464 return opt->type->print(opt,val_ptr); | |
465 else | |
8168 | 466 return (char*)-1; |
8164 | 467 } |
468 | |
18258 | 469 /// Helper around \ref m_option_type::save. |
8164 | 470 inline static void |
471 m_option_save(m_option_t* opt,void* dst, void* src) { | |
472 if(opt->type->save) | |
473 opt->type->save(opt,dst,src); | |
474 } | |
475 | |
18258 | 476 /// Helper around \ref m_option_type::set. |
8164 | 477 inline static void |
478 m_option_set(m_option_t* opt,void* dst, void* src) { | |
479 if(opt->type->set) | |
480 opt->type->set(opt,dst,src); | |
481 } | |
482 | |
18258 | 483 /// Helper around \ref m_option_type::copy. |
8164 | 484 inline static void |
485 m_option_copy(m_option_t* opt,void* dst, void* src) { | |
486 if(opt->type->copy) | |
17456
b8ce59172e6a
100L m_option_copy should use the copy callback and not the set one.
albeu
parents:
16345
diff
changeset
|
487 opt->type->copy(opt,dst,src); |
8164 | 488 else if(opt->type->size > 0) |
489 memcpy(dst,src,opt->type->size); | |
490 } | |
491 | |
18258 | 492 /// Helper around \ref m_option_type::free. |
8164 | 493 inline static void |
494 m_option_free(m_option_t* opt,void* dst) { | |
495 if(opt->type->free) | |
496 opt->type->free(dst); | |
497 } | |
498 | |
18258 | 499 /*@}*/ |
500 | |
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.
alex
parents:
10590
diff
changeset
|
501 #endif /* _M_OPTION_H */ |