annotate m_config.h @ 24096:30abd1f03434

sync tag update
author voroshil
date Wed, 22 Aug 2007 09:05:59 +0000
parents 3f0d00abc073
children 51c23a18a17b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23689
3f0d00abc073 Do not use leading underscores in multiple inclusion guards, they are reserved.
diego
parents: 18316
diff changeset
1 #ifndef M_CONFIG_H
3f0d00abc073 Do not use leading underscores in multiple inclusion guards, they are reserved.
diego
parents: 18316
diff changeset
2 #define M_CONFIG_H
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
3
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
4 /// \defgroup Config Config manager
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
5 ///
18283
67d35fe89c8d Fix most of the mistakes pointed out by Diego.
albeu
parents: 18258
diff changeset
6 /// m_config provides an API to manipulate the config variables in MPlayer.
18316
b3be7df634b0 spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents: 18283
diff changeset
7 /// It makes use of the \ref Options API to provide a context stack that
b3be7df634b0 spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents: 18283
diff changeset
8 /// allows saving and later restoring the state of all variables.
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
9 ///@{
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
10
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
11 /// \file
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
12
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
13 typedef struct m_config_option m_config_option_t;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
14 typedef struct m_config_save_slot m_config_save_slot_t;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
15 /// \ingroup ConfigProfiles
17471
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
16 typedef struct m_profile m_profile_t;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
17 struct m_option;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
18 struct m_option_type;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
19
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
20 /// Config option save slot
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
21 struct m_config_save_slot {
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
22 /// Previous level slot.
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
23 m_config_save_slot_t* prev;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
24 /// Level at which the save was made.
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
25 int lvl;
18316
b3be7df634b0 spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents: 18283
diff changeset
26 // We have to store other datatypes in this as well,
b3be7df634b0 spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents: 18283
diff changeset
27 // so make sure we get properly aligned addresses.
13246
5dea9e3618ba alignment for SPARC64, second try
reimar
parents: 10594
diff changeset
28 unsigned char data[0] __attribute__ ((aligned (8)));
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
29 };
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
30
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
31 /// Config option
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
32 struct m_config_option {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
33 m_config_option_t* next;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
34 /// Full name (ie option:subopt).
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
35 char* name;
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
36 /// Option description.
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
37 struct m_option* opt;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
38 /// Save slot stack.
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
39 m_config_save_slot_t* slots;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
40 /// See \ref ConfigOptionFlags.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
41 unsigned int flags;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
42 };
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
43
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
44 /// \defgroup ConfigProfiles Config profiles
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
45 /// \ingroup Config
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
46 ///
18283
67d35fe89c8d Fix most of the mistakes pointed out by Diego.
albeu
parents: 18258
diff changeset
47 /// Profiles allow to predefine some sets of options that can then
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
48 /// be applied later on with the internal -profile option.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
49 ///
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
50 ///@{
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
51
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
52 /// Config profile
17471
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
53 struct m_profile {
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
54 m_profile_t* next;
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
55 char* name;
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
56 char* desc;
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
57 int num_opts;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
58 /// Option/value pair array.
17471
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
59 char** opts;
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
60 };
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
61
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
62 ///@}
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
63
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
64 /// Config object
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
65 /** \ingroup Config */
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
66 typedef struct m_config {
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
67 /// Registered options.
18283
67d35fe89c8d Fix most of the mistakes pointed out by Diego.
albeu
parents: 18258
diff changeset
68 /** This contains all options and suboptions.
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
69 */
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
70 m_config_option_t* opts;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
71 /// Current stack level.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
72 int lvl;
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
73 /// \ref OptionParserModes
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
74 int mode;
18283
67d35fe89c8d Fix most of the mistakes pointed out by Diego.
albeu
parents: 18258
diff changeset
75 /// List of defined profiles.
17471
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
76 m_profile_t* profiles;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
77 /// Depth when recursively including profiles.
17471
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
78 int profile_depth;
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
79 /// Options defined by the config itself.
17471
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
80 struct m_option* self_opts;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
81 } m_config_t;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
82
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
83 /// \defgroup ConfigOptionFlags Config option flags
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
84 /// \ingroup Config
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
85 ///@{
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
86
18316
b3be7df634b0 spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents: 18283
diff changeset
87 /// Set if an option has been set at the current level.
9912
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 8168
diff changeset
88 #define M_CFG_OPT_SET (1<<0)
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
89
18283
67d35fe89c8d Fix most of the mistakes pointed out by Diego.
albeu
parents: 18258
diff changeset
90 /// Set if another option already uses the same variable.
9912
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 8168
diff changeset
91 #define M_CFG_OPT_ALIAS (1<<1)
39444d65c4cb Don't save restore all options wich point to the same variable.
albeu
parents: 8168
diff changeset
92
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
93 ///@}
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
94
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
95 /// Create a new config object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
96 /** \ingroup Config
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
97 */
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
98 m_config_t*
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
99 m_config_new(void);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
100
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
101 /// Free a config object.
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
102 void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
103 m_config_free(m_config_t* config);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
104
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
105 /// Push a new context.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
106 /** \param config The config object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
107 */
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
108 void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
109 m_config_push(m_config_t* config);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
110
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
111 /// Pop the current context restoring the previous context state.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
112 /** \param config The config object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
113 */
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
114 void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
115 m_config_pop(m_config_t* config);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
116
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
117 /// Register some options to be used.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
118 /** \param config The config object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
119 * \param args An array of \ref m_option struct.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
120 * \return 1 on success, 0 on failure.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
121 */
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
122 int
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
123 m_config_register_options(m_config_t *config, struct m_option *args);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
124
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
125 /// Set an option.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
126 /** \param config The config object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
127 * \param arg The option's name.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
128 * \param param The value of the option, can be NULL.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
129 * \return See \ref OptionParserReturn.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
130 */
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
131 int
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
132 m_config_set_option(m_config_t *config, char* arg, char* param);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
133
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
134 /// Check if an option setting is valid.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
135 /** \param config The config object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
136 * \param arg The option's name.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
137 * \param param The value of the option, can be NULL.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
138 * \return See \ref OptionParserReturn.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
139 */
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
140 int
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
141 m_config_check_option(m_config_t *config, char* arg, char* param);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
142
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
143 /// Get the option matching the given name.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
144 /** \param config The config object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
145 * \param arg The option's name.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
146 */
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
147 struct m_option*
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
148 m_config_get_option(m_config_t *config, char* arg);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
149
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
150 /// Print a list of all registered options.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
151 /** \param config The config object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
152 */
8168
ff6a98628e6c Fix the Gui with NEW_CONFIG
albeu
parents: 8164
diff changeset
153 void
ff6a98628e6c Fix the Gui with NEW_CONFIG
albeu
parents: 8164
diff changeset
154 m_config_print_option_list(m_config_t *config);
ff6a98628e6c Fix the Gui with NEW_CONFIG
albeu
parents: 8164
diff changeset
155
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
156 /// \addtogroup ConfigProfiles
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
157 ///@{
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
158
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
159 /// Find the profile with the given name.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
160 /** \param config The config object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
161 * \param arg The profile's name.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
162 * \return The profile object or NULL.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
163 */
17471
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
164 m_profile_t*
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
165 m_config_get_profile(m_config_t* config, char* name);
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
166
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
167 /// Get the profile with the given name, creating it if necessary.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
168 /** \param config The config object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
169 * \param arg The profile's name.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
170 * \return The profile object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
171 */
17471
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
172 m_profile_t*
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
173 m_config_add_profile(m_config_t* config, char* name);
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
174
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
175 /// Set the description of a profile.
18316
b3be7df634b0 spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents: 18283
diff changeset
176 /** Used by the config file parser when defining a profile.
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
177 *
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
178 * \param p The profile object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
179 * \param arg The profile's name.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
180 */
17471
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
181 void
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
182 m_profile_set_desc(m_profile_t* p, char* desc);
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
183
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
184 /// Add an option to a profile.
18316
b3be7df634b0 spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents: 18283
diff changeset
185 /** Used by the config file parser when defining a profile.
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
186 *
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
187 * \param config The config object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
188 * \param p The profile object.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
189 * \param name The option's name.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
190 * \param val The option's value.
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
191 */
17471
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
192 int
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
193 m_config_set_profile_option(m_config_t* config, m_profile_t* p,
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
194 char* name, char* val);
63909962d3fc Profiles support.
albeu
parents: 13246
diff changeset
195
18258
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
196 ///@}
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
197
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
198 ///@}
96568be4bfdc Doxygen attack!
albeu
parents: 17471
diff changeset
199
23689
3f0d00abc073 Do not use leading underscores in multiple inclusion guards, they are reserved.
diego
parents: 18316
diff changeset
200 #endif /* M_CONFIG_H */