2003-08-13 16:29:32 +00:00
|
|
|
#ifndef _M_CONFIG_H
|
|
|
|
#define _M_CONFIG_H
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// \defgroup Config Config manager
|
|
|
|
///
|
|
|
|
/// m_config provide an API to manipulate the config variables in MPlayer.
|
|
|
|
/// It make use of the \ref Options API to provide a context stack that
|
|
|
|
/// allow saving and later restoring the state of all variables.
|
|
|
|
///@{
|
|
|
|
|
|
|
|
/// \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;
|
2004-09-04 15:34:20 +00:00
|
|
|
// we have to store other datatypes in this as well,
|
|
|
|
// so make sure we get properly aligned addresses
|
|
|
|
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.
|
2002-11-12 01:56:42 +00:00
|
|
|
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
|
|
|
|
///
|
|
|
|
/// Profiles allow to predefine some set of options that can then
|
|
|
|
/// 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.
|
|
|
|
/** This contain all options and suboptions.
|
|
|
|
*/
|
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-24 19:20:04 +00:00
|
|
|
/// List of the 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
|
|
|
|
///@{
|
|
|
|
|
|
|
|
/// Set if an option have been set at the current level.
|
2003-04-12 13:40:30 +00:00
|
|
|
#define M_CFG_OPT_SET (1<<0)
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Set if another option already use the same variable.
|
|
|
|
#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
|
|
|
|
m_config_register_options(m_config_t *config, struct m_option *args);
|
|
|
|
|
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.
|
|
|
|
*/
|
2002-11-12 01:56:42 +00:00
|
|
|
struct m_option*
|
|
|
|
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.
|
|
|
|
/** This is used by the config file parser when defining a profile.
|
|
|
|
*
|
|
|
|
* \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.
|
|
|
|
/** This is used by the config file parser when defining a profile.
|
|
|
|
*
|
|
|
|
* \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);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
///@}
|
|
|
|
|
|
|
|
///@}
|
|
|
|
|
2003-08-13 16:29:32 +00:00
|
|
|
#endif /* _M_CONFIG_H */
|