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