Revert #undefining system functions, it is not necessary.
[mplayer/glamo.git] / m_config.h
blobe6b8bc9247da26110ebac5cc16dc4390292a118c
1 #ifndef MPLAYER_M_CONFIG_H
2 #define MPLAYER_M_CONFIG_H
4 /// \defgroup Config Config manager
5 ///
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.
9 ///@{
11 /// \file
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;
17 struct m_option;
18 struct m_option_type;
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.
25 int lvl;
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)));
31 /// Config option
32 struct m_config_option {
33 m_config_option_t* next;
34 /// Full name (ie option:subopt).
35 char* name;
36 /// Option description.
37 const struct m_option* opt;
38 /// Save slot stack.
39 m_config_save_slot_t* slots;
40 /// See \ref ConfigOptionFlags.
41 unsigned int flags;
44 /// \defgroup ConfigProfiles Config profiles
45 /// \ingroup Config
46 ///
47 /// Profiles allow to predefine some sets of options that can then
48 /// be applied later on with the internal -profile option.
49 ///
50 ///@{
52 /// Config profile
53 struct m_profile {
54 m_profile_t* next;
55 char* name;
56 char* desc;
57 int num_opts;
58 /// Option/value pair array.
59 char** opts;
62 ///@}
64 /// Config object
65 /** \ingroup Config */
66 typedef struct m_config {
67 /// Registered options.
68 /** This contains all options and suboptions.
69 */
70 m_config_option_t* opts;
71 /// Current stack level.
72 int lvl;
73 /// \ref OptionParserModes
74 int mode;
75 /// List of defined profiles.
76 m_profile_t* profiles;
77 /// Depth when recursively including profiles.
78 int profile_depth;
79 /// Options defined by the config itself.
80 struct m_option* self_opts;
81 } m_config_t;
83 /// \defgroup ConfigOptionFlags Config option flags
84 /// \ingroup Config
85 ///@{
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)
93 ///@}
95 /// Create a new config object.
96 /** \ingroup Config
98 m_config_t*
99 m_config_new(void);
101 /// Free a config object.
102 void
103 m_config_free(m_config_t* config);
105 /// Push a new context.
106 /** \param config The config object.
108 void
109 m_config_push(m_config_t* config);
111 /// Pop the current context restoring the previous context state.
112 /** \param config The config object.
114 void
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, const struct m_option *args);
125 /// Set an option.
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.
147 const struct m_option*
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.
153 void
154 m_config_print_option_list(m_config_t *config);
156 /// \addtogroup ConfigProfiles
157 ///@{
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.
164 m_profile_t*
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.
172 m_profile_t*
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.
181 void
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);
196 /// Enables profile usage
197 /** Used by the config file parser when loading a profile.
199 * \param config The config object.
200 * \param p The profile object.
202 void
203 m_config_set_profile(m_config_t* config, m_profile_t* p);
205 ///@}
207 ///@}
209 #endif /* MPLAYER_M_CONFIG_H */