Fix vf_tcdump's compilation
[mplayer/kovensky.git] / m_config.h
blobad5acfc374246c9398f845fb0cfef89afb8b43d8
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_M_CONFIG_H
20 #define MPLAYER_M_CONFIG_H
22 /// \defgroup Config Config manager
23 ///
24 /// m_config provides an API to manipulate the config variables in MPlayer.
25 /// It makes use of the \ref Options API to provide a context stack that
26 /// allows saving and later restoring the state of all variables.
27 ///@{
29 /// \file
31 typedef struct m_config_option m_config_option_t;
32 typedef struct m_config_save_slot m_config_save_slot_t;
33 /// \ingroup ConfigProfiles
34 typedef struct m_profile m_profile_t;
35 struct m_option;
36 struct m_option_type;
38 /// Config option save slot
39 struct m_config_save_slot {
40 /// Previous level slot.
41 m_config_save_slot_t* prev;
42 /// Level at which the save was made.
43 int lvl;
44 // We have to store other datatypes in this as well,
45 // so make sure we get properly aligned addresses.
46 unsigned char data[0] __attribute__ ((aligned (8)));
49 /// Config option
50 struct m_config_option {
51 m_config_option_t* next;
52 /// Full name (ie option:subopt).
53 char* name;
54 /// Option description.
55 const struct m_option* opt;
56 /// Save slot stack.
57 m_config_save_slot_t* slots;
58 /// See \ref ConfigOptionFlags.
59 unsigned int flags;
62 /// \defgroup ConfigProfiles Config profiles
63 /// \ingroup Config
64 ///
65 /// Profiles allow to predefine some sets of options that can then
66 /// be applied later on with the internal -profile option.
67 ///
68 ///@{
70 /// Config profile
71 struct m_profile {
72 m_profile_t* next;
73 char* name;
74 char* desc;
75 int num_opts;
76 /// Option/value pair array.
77 char** opts;
80 ///@}
82 /// Config object
83 /** \ingroup Config */
84 typedef struct m_config {
85 /// Registered options.
86 /** This contains all options and suboptions.
88 m_config_option_t* opts;
89 /// Current stack level.
90 int lvl;
91 /// \ref OptionParserModes
92 int mode;
93 /// List of defined profiles.
94 m_profile_t* profiles;
95 /// Depth when recursively including profiles.
96 int profile_depth;
98 void *optstruct; // struct mpopts or other
99 } m_config_t;
101 /// \defgroup ConfigOptionFlags Config option flags
102 /// \ingroup Config
103 ///@{
105 /// Set if an option has been set at the current level.
106 #define M_CFG_OPT_SET (1<<0)
108 /// Set if another option already uses the same variable.
109 #define M_CFG_OPT_ALIAS (1<<1)
111 ///@}
113 /// Create a new config object.
114 /** \ingroup Config
116 m_config_t*
117 m_config_new(void *optstruct,
118 int includefunc(struct m_option *conf, char *filename));
120 /// Free a config object.
121 void
122 m_config_free(m_config_t* config);
124 /// Push a new context.
125 /** \param config The config object.
127 void
128 m_config_push(m_config_t* config);
130 /// Pop the current context restoring the previous context state.
131 /** \param config The config object.
133 void
134 m_config_pop(m_config_t* config);
136 /// Register some options to be used.
137 /** \param config The config object.
138 * \param args An array of \ref m_option struct.
139 * \return 1 on success, 0 on failure.
142 m_config_register_options(m_config_t *config, const struct m_option *args);
144 /// Set an option.
145 /** \param config The config object.
146 * \param arg The option's name.
147 * \param param The value of the option, can be NULL.
148 * \return See \ref OptionParserReturn.
151 m_config_set_option(m_config_t *config, char* arg, char* param);
153 /// Check if an option setting is valid.
154 /** \param config The config object.
155 * \param arg The option's name.
156 * \param param The value of the option, can be NULL.
157 * \return See \ref OptionParserReturn.
160 m_config_check_option(m_config_t *config, char* arg, char* param);
162 /// Get the option matching the given name.
163 /** \param config The config object.
164 * \param arg The option's name.
166 const struct m_option*
167 m_config_get_option(m_config_t *config, char* arg);
169 /// Print a list of all registered options.
170 /** \param config The config object.
172 void
173 m_config_print_option_list(m_config_t *config);
175 /// \addtogroup ConfigProfiles
176 ///@{
178 /// Find the profile with the given name.
179 /** \param config The config object.
180 * \param arg The profile's name.
181 * \return The profile object or NULL.
183 m_profile_t*
184 m_config_get_profile(m_config_t* config, char* name);
186 /// Get the profile with the given name, creating it if necessary.
187 /** \param config The config object.
188 * \param arg The profile's name.
189 * \return The profile object.
191 m_profile_t*
192 m_config_add_profile(m_config_t* config, char* name);
194 /// Set the description of a profile.
195 /** Used by the config file parser when defining a profile.
197 * \param p The profile object.
198 * \param arg The profile's name.
200 void
201 m_profile_set_desc(m_profile_t* p, char* desc);
203 /// Add an option to a profile.
204 /** Used by the config file parser when defining a profile.
206 * \param config The config object.
207 * \param p The profile object.
208 * \param name The option's name.
209 * \param val The option's value.
212 m_config_set_profile_option(m_config_t* config, m_profile_t* p,
213 char* name, char* val);
215 /// Enables profile usage
216 /** Used by the config file parser when loading a profile.
218 * \param config The config object.
219 * \param p The profile object.
221 void
222 m_config_set_profile(m_config_t* config, m_profile_t* p);
224 ///@}
226 ///@}
228 #endif /* MPLAYER_M_CONFIG_H */