4 /// \defgroup Config Config manager
6 /// m_config provides an API to manipulate the config variables in MPlayer.
7 /// It makes use of the \ref Options API to provide a context stack that
8 /// allows saving and later restoring the state of all variables.
13 typedef struct m_config_option m_config_option_t
;
14 typedef struct m_config_save_slot m_config_save_slot_t
;
15 /// \ingroup ConfigProfiles
16 typedef struct m_profile m_profile_t
;
20 /// Config option save slot
21 struct m_config_save_slot
{
22 /// Previous level slot.
23 m_config_save_slot_t
* prev
;
24 /// Level at which the save was made.
26 // We have to store other datatypes in this as well,
27 // so make sure we get properly aligned addresses.
28 unsigned char data
[0] __attribute__ ((aligned (8)));
32 struct m_config_option
{
33 m_config_option_t
* next
;
34 /// Full name (ie option:subopt).
36 /// Option description.
39 m_config_save_slot_t
* slots
;
40 /// See \ref ConfigOptionFlags.
44 /// \defgroup ConfigProfiles Config profiles
47 /// Profiles allow to predefine some sets of options that can then
48 /// be applied later on with the internal -profile option.
58 /// Option/value pair array.
65 /** \ingroup Config */
66 typedef struct m_config
{
67 /// Registered options.
68 /** This contains all options and suboptions.
70 m_config_option_t
* opts
;
71 /// Current stack level.
73 /// \ref OptionParserModes
75 /// List of defined profiles.
76 m_profile_t
* profiles
;
77 /// Depth when recursively including profiles.
79 /// Options defined by the config itself.
80 struct m_option
* self_opts
;
83 /// \defgroup ConfigOptionFlags Config option flags
87 /// Set if an option has been set at the current level.
88 #define M_CFG_OPT_SET (1<<0)
90 /// Set if another option already uses the same variable.
91 #define M_CFG_OPT_ALIAS (1<<1)
95 /// Create a new config object.
101 /// Free a config object.
103 m_config_free(m_config_t
* config
);
105 /// Push a new context.
106 /** \param config The config object.
109 m_config_push(m_config_t
* config
);
111 /// Pop the current context restoring the previous context state.
112 /** \param config The config object.
115 m_config_pop(m_config_t
* config
);
117 /// Register some options to be used.
118 /** \param config The config object.
119 * \param args An array of \ref m_option struct.
120 * \return 1 on success, 0 on failure.
123 m_config_register_options(m_config_t
*config
, struct m_option
*args
);
126 /** \param config The config object.
127 * \param arg The option's name.
128 * \param param The value of the option, can be NULL.
129 * \return See \ref OptionParserReturn.
132 m_config_set_option(m_config_t
*config
, char* arg
, char* param
);
134 /// Check if an option setting is valid.
135 /** \param config The config object.
136 * \param arg The option's name.
137 * \param param The value of the option, can be NULL.
138 * \return See \ref OptionParserReturn.
141 m_config_check_option(m_config_t
*config
, char* arg
, char* param
);
143 /// Get the option matching the given name.
144 /** \param config The config object.
145 * \param arg The option's name.
148 m_config_get_option(m_config_t
*config
, char* arg
);
150 /// Print a list of all registered options.
151 /** \param config The config object.
154 m_config_print_option_list(m_config_t
*config
);
156 /// \addtogroup ConfigProfiles
159 /// Find the profile with the given name.
160 /** \param config The config object.
161 * \param arg The profile's name.
162 * \return The profile object or NULL.
165 m_config_get_profile(m_config_t
* config
, char* name
);
167 /// Get the profile with the given name, creating it if necessary.
168 /** \param config The config object.
169 * \param arg The profile's name.
170 * \return The profile object.
173 m_config_add_profile(m_config_t
* config
, char* name
);
175 /// Set the description of a profile.
176 /** Used by the config file parser when defining a profile.
178 * \param p The profile object.
179 * \param arg The profile's name.
182 m_profile_set_desc(m_profile_t
* p
, char* desc
);
184 /// Add an option to a profile.
185 /** Used by the config file parser when defining a profile.
187 * \param config The config object.
188 * \param p The profile object.
189 * \param name The option's name.
190 * \param val The option's value.
193 m_config_set_profile_option(m_config_t
* config
, m_profile_t
* p
,
194 char* name
, char* val
);
200 #endif /* _M_CONFIG_H */