annotate m_option.h @ 26029:4129c8cfa742

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