1 #ifndef MPLAYER_M_CONFIG_H
2 #define MPLAYER_M_CONFIG_H
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.
37 const struct m_option
* opt
;
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.
80 void *optstruct
; // struct mpopts or other
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.
99 m_config_new(void *optstruct
,
100 int includefunc(struct m_option
*conf
, char *filename
));
102 /// Free a config object.
104 m_config_free(m_config_t
* config
);
106 /// Push a new context.
107 /** \param config The config object.
110 m_config_push(m_config_t
* config
);
112 /// Pop the current context restoring the previous context state.
113 /** \param config The config object.
116 m_config_pop(m_config_t
* config
);
118 /// Register some options to be used.
119 /** \param config The config object.
120 * \param args An array of \ref m_option struct.
121 * \return 1 on success, 0 on failure.
124 m_config_register_options(m_config_t
*config
, const struct m_option
*args
);
127 /** \param config The config object.
128 * \param arg The option's name.
129 * \param param The value of the option, can be NULL.
130 * \return See \ref OptionParserReturn.
133 m_config_set_option(m_config_t
*config
, char* arg
, char* param
);
135 /// Check if an option setting is valid.
136 /** \param config The config object.
137 * \param arg The option's name.
138 * \param param The value of the option, can be NULL.
139 * \return See \ref OptionParserReturn.
142 m_config_check_option(m_config_t
*config
, char* arg
, char* param
);
144 /// Get the option matching the given name.
145 /** \param config The config object.
146 * \param arg The option's name.
148 const struct m_option
*
149 m_config_get_option(m_config_t
*config
, char* arg
);
151 /// Print a list of all registered options.
152 /** \param config The config object.
155 m_config_print_option_list(m_config_t
*config
);
157 /// \addtogroup ConfigProfiles
160 /// Find the profile with the given name.
161 /** \param config The config object.
162 * \param arg The profile's name.
163 * \return The profile object or NULL.
166 m_config_get_profile(m_config_t
* config
, char* name
);
168 /// Get the profile with the given name, creating it if necessary.
169 /** \param config The config object.
170 * \param arg The profile's name.
171 * \return The profile object.
174 m_config_add_profile(m_config_t
* config
, char* name
);
176 /// Set the description of a profile.
177 /** Used by the config file parser when defining a profile.
179 * \param p The profile object.
180 * \param arg The profile's name.
183 m_profile_set_desc(m_profile_t
* p
, char* desc
);
185 /// Add an option to a profile.
186 /** Used by the config file parser when defining a profile.
188 * \param config The config object.
189 * \param p The profile object.
190 * \param name The option's name.
191 * \param val The option's value.
194 m_config_set_profile_option(m_config_t
* config
, m_profile_t
* p
,
195 char* name
, char* val
);
197 /// Enables profile usage
198 /** Used by the config file parser when loading a profile.
200 * \param config The config object.
201 * \param p The profile object.
204 m_config_set_profile(m_config_t
* config
, m_profile_t
* p
);
210 #endif /* MPLAYER_M_CONFIG_H */