2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_M_CONFIG_H
|
|
|
|
#define MPLAYER_M_CONFIG_H
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// \defgroup Config Config manager
|
|
|
|
///
|
2006-04-25 18:48:53 +00:00
|
|
|
/// m_config provides an API to manipulate the config variables in MPlayer.
|
2006-04-27 13:22:23 +00:00
|
|
|
/// It makes use of the \ref Options API to provide a context stack that
|
|
|
|
/// allows saving and later restoring the state of all variables.
|
2006-04-24 19:20:04 +00:00
|
|
|
///@{
|
|
|
|
|
|
|
|
/// \file
|
|
|
|
|
2002-11-12 01:56:42 +00:00
|
|
|
typedef struct m_config_option m_config_option_t;
|
|
|
|
typedef struct m_config_save_slot m_config_save_slot_t;
|
2006-04-24 19:20:04 +00:00
|
|
|
/// \ingroup ConfigProfiles
|
2006-01-24 11:16:13 +00:00
|
|
|
typedef struct m_profile m_profile_t;
|
2002-11-12 01:56:42 +00:00
|
|
|
struct m_option;
|
|
|
|
struct m_option_type;
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Config option save slot
|
2002-11-12 01:56:42 +00:00
|
|
|
struct m_config_save_slot {
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Previous level slot.
|
2002-11-12 01:56:42 +00:00
|
|
|
m_config_save_slot_t* prev;
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Level at which the save was made.
|
2002-11-12 01:56:42 +00:00
|
|
|
int lvl;
|
2006-04-27 13:22:23 +00:00
|
|
|
// We have to store other datatypes in this as well,
|
|
|
|
// so make sure we get properly aligned addresses.
|
2004-09-04 15:34:20 +00:00
|
|
|
unsigned char data[0] __attribute__ ((aligned (8)));
|
2002-11-12 01:56:42 +00:00
|
|
|
};
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Config option
|
2002-11-12 01:56:42 +00:00
|
|
|
struct m_config_option {
|
|
|
|
m_config_option_t* next;
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Full name (ie option:subopt).
|
|
|
|
char* name;
|
|
|
|
/// Option description.
|
2007-12-02 15:35:58 +00:00
|
|
|
const struct m_option* opt;
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Save slot stack.
|
2002-11-12 01:56:42 +00:00
|
|
|
m_config_save_slot_t* slots;
|
2006-04-24 19:20:04 +00:00
|
|
|
/// See \ref ConfigOptionFlags.
|
|
|
|
unsigned int flags;
|
2002-11-12 01:56:42 +00:00
|
|
|
};
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// \defgroup ConfigProfiles Config profiles
|
|
|
|
/// \ingroup Config
|
|
|
|
///
|
2006-04-25 18:48:53 +00:00
|
|
|
/// Profiles allow to predefine some sets of options that can then
|
2006-04-24 19:20:04 +00:00
|
|
|
/// be applied later on with the internal -profile option.
|
|
|
|
///
|
|
|
|
///@{
|
|
|
|
|
|
|
|
/// Config profile
|
2006-01-24 11:16:13 +00:00
|
|
|
struct m_profile {
|
|
|
|
m_profile_t* next;
|
|
|
|
char* name;
|
|
|
|
char* desc;
|
|
|
|
int num_opts;
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Option/value pair array.
|
2006-01-24 11:16:13 +00:00
|
|
|
char** opts;
|
|
|
|
};
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
///@}
|
|
|
|
|
|
|
|
/// Config object
|
|
|
|
/** \ingroup Config */
|
2002-11-12 01:56:42 +00:00
|
|
|
typedef struct m_config {
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Registered options.
|
2006-04-25 18:48:53 +00:00
|
|
|
/** This contains all options and suboptions.
|
2006-04-24 19:20:04 +00:00
|
|
|
*/
|
2002-11-12 01:56:42 +00:00
|
|
|
m_config_option_t* opts;
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Current stack level.
|
|
|
|
int lvl;
|
|
|
|
/// \ref OptionParserModes
|
2002-11-12 01:56:42 +00:00
|
|
|
int mode;
|
2006-04-25 18:48:53 +00:00
|
|
|
/// List of defined profiles.
|
2006-01-24 11:16:13 +00:00
|
|
|
m_profile_t* profiles;
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Depth when recursively including profiles.
|
2006-01-24 11:16:13 +00:00
|
|
|
int profile_depth;
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Options defined by the config itself.
|
2006-01-24 11:16:13 +00:00
|
|
|
struct m_option* self_opts;
|
2002-11-12 01:56:42 +00:00
|
|
|
} m_config_t;
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// \defgroup ConfigOptionFlags Config option flags
|
|
|
|
/// \ingroup Config
|
|
|
|
///@{
|
|
|
|
|
2006-04-27 13:22:23 +00:00
|
|
|
/// Set if an option has been set at the current level.
|
2003-04-12 13:40:30 +00:00
|
|
|
#define M_CFG_OPT_SET (1<<0)
|
|
|
|
|
2006-04-25 18:48:53 +00:00
|
|
|
/// Set if another option already uses the same variable.
|
2006-04-24 19:20:04 +00:00
|
|
|
#define M_CFG_OPT_ALIAS (1<<1)
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
///@}
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Create a new config object.
|
|
|
|
/** \ingroup Config
|
|
|
|
*/
|
2002-11-12 01:56:42 +00:00
|
|
|
m_config_t*
|
|
|
|
m_config_new(void);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Free a config object.
|
2002-11-12 01:56:42 +00:00
|
|
|
void
|
|
|
|
m_config_free(m_config_t* config);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Push a new context.
|
|
|
|
/** \param config The config object.
|
|
|
|
*/
|
2002-11-12 01:56:42 +00:00
|
|
|
void
|
|
|
|
m_config_push(m_config_t* config);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Pop the current context restoring the previous context state.
|
|
|
|
/** \param config The config object.
|
|
|
|
*/
|
2002-11-12 01:56:42 +00:00
|
|
|
void
|
|
|
|
m_config_pop(m_config_t* config);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Register some options to be used.
|
|
|
|
/** \param config The config object.
|
|
|
|
* \param args An array of \ref m_option struct.
|
|
|
|
* \return 1 on success, 0 on failure.
|
|
|
|
*/
|
2002-11-12 01:56:42 +00:00
|
|
|
int
|
2007-12-02 15:35:58 +00:00
|
|
|
m_config_register_options(m_config_t *config, const struct m_option *args);
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Set an option.
|
|
|
|
/** \param config The config object.
|
|
|
|
* \param arg The option's name.
|
|
|
|
* \param param The value of the option, can be NULL.
|
|
|
|
* \return See \ref OptionParserReturn.
|
|
|
|
*/
|
2002-11-12 01:56:42 +00:00
|
|
|
int
|
|
|
|
m_config_set_option(m_config_t *config, char* arg, char* param);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Check if an option setting is valid.
|
|
|
|
/** \param config The config object.
|
|
|
|
* \param arg The option's name.
|
|
|
|
* \param param The value of the option, can be NULL.
|
|
|
|
* \return See \ref OptionParserReturn.
|
|
|
|
*/
|
2002-11-12 01:56:42 +00:00
|
|
|
int
|
|
|
|
m_config_check_option(m_config_t *config, char* arg, char* param);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Get the option matching the given name.
|
|
|
|
/** \param config The config object.
|
|
|
|
* \param arg The option's name.
|
|
|
|
*/
|
2007-12-02 15:35:58 +00:00
|
|
|
const struct m_option*
|
2002-11-12 01:56:42 +00:00
|
|
|
m_config_get_option(m_config_t *config, char* arg);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Print a list of all registered options.
|
|
|
|
/** \param config The config object.
|
|
|
|
*/
|
2002-11-12 12:39:05 +00:00
|
|
|
void
|
|
|
|
m_config_print_option_list(m_config_t *config);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// \addtogroup ConfigProfiles
|
|
|
|
///@{
|
|
|
|
|
|
|
|
/// Find the profile with the given name.
|
|
|
|
/** \param config The config object.
|
|
|
|
* \param arg The profile's name.
|
|
|
|
* \return The profile object or NULL.
|
|
|
|
*/
|
2006-01-24 11:16:13 +00:00
|
|
|
m_profile_t*
|
|
|
|
m_config_get_profile(m_config_t* config, char* name);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Get the profile with the given name, creating it if necessary.
|
|
|
|
/** \param config The config object.
|
|
|
|
* \param arg The profile's name.
|
|
|
|
* \return The profile object.
|
|
|
|
*/
|
2006-01-24 11:16:13 +00:00
|
|
|
m_profile_t*
|
|
|
|
m_config_add_profile(m_config_t* config, char* name);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Set the description of a profile.
|
2006-04-27 13:22:23 +00:00
|
|
|
/** Used by the config file parser when defining a profile.
|
2006-04-24 19:20:04 +00:00
|
|
|
*
|
|
|
|
* \param p The profile object.
|
|
|
|
* \param arg The profile's name.
|
|
|
|
*/
|
2006-01-24 11:16:13 +00:00
|
|
|
void
|
|
|
|
m_profile_set_desc(m_profile_t* p, char* desc);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Add an option to a profile.
|
2006-04-27 13:22:23 +00:00
|
|
|
/** Used by the config file parser when defining a profile.
|
2006-04-24 19:20:04 +00:00
|
|
|
*
|
|
|
|
* \param config The config object.
|
|
|
|
* \param p The profile object.
|
|
|
|
* \param name The option's name.
|
|
|
|
* \param val The option's value.
|
|
|
|
*/
|
2006-01-24 11:16:13 +00:00
|
|
|
int
|
|
|
|
m_config_set_profile_option(m_config_t* config, m_profile_t* p,
|
|
|
|
char* name, char* val);
|
|
|
|
|
2008-01-10 18:41:21 +00:00
|
|
|
/// Enables profile usage
|
|
|
|
/** Used by the config file parser when loading a profile.
|
|
|
|
*
|
|
|
|
* \param config The config object.
|
|
|
|
* \param p The profile object.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
m_config_set_profile(m_config_t* config, m_profile_t* p);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
///@}
|
|
|
|
|
|
|
|
///@}
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_M_CONFIG_H */
|