Mercurial > mplayer.hg
annotate m_config.h @ 24738:45189040161d
Reorder #includes to get rid of the FIXME
author | zuxy |
---|---|
date | Fri, 12 Oct 2007 03:17:43 +0000 |
parents | 3f0d00abc073 |
children | 51c23a18a17b |
rev | line source |
---|---|
23689
3f0d00abc073
Do not use leading underscores in multiple inclusion guards, they are reserved.
diego
parents:
18316
diff
changeset
|
1 #ifndef M_CONFIG_H |
3f0d00abc073
Do not use leading underscores in multiple inclusion guards, they are reserved.
diego
parents:
18316
diff
changeset
|
2 #define M_CONFIG_H |
8164 | 3 |
18258 | 4 /// \defgroup Config Config manager |
5 /// | |
18283 | 6 /// m_config provides an API to manipulate the config variables in MPlayer. |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
7 /// It makes use of the \ref Options API to provide a context stack that |
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
8 /// allows saving and later restoring the state of all variables. |
18258 | 9 ///@{ |
10 | |
11 /// \file | |
12 | |
8164 | 13 typedef struct m_config_option m_config_option_t; |
14 typedef struct m_config_save_slot m_config_save_slot_t; | |
18258 | 15 /// \ingroup ConfigProfiles |
17471 | 16 typedef struct m_profile m_profile_t; |
8164 | 17 struct m_option; |
18 struct m_option_type; | |
19 | |
18258 | 20 /// Config option save slot |
8164 | 21 struct m_config_save_slot { |
18258 | 22 /// Previous level slot. |
8164 | 23 m_config_save_slot_t* prev; |
18258 | 24 /// Level at which the save was made. |
8164 | 25 int lvl; |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
26 // We have to store other datatypes in this as well, |
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
27 // so make sure we get properly aligned addresses. |
13246 | 28 unsigned char data[0] __attribute__ ((aligned (8))); |
8164 | 29 }; |
30 | |
18258 | 31 /// Config option |
8164 | 32 struct m_config_option { |
33 m_config_option_t* next; | |
18258 | 34 /// Full name (ie option:subopt). |
35 char* name; | |
36 /// Option description. | |
8164 | 37 struct m_option* opt; |
18258 | 38 /// Save slot stack. |
8164 | 39 m_config_save_slot_t* slots; |
18258 | 40 /// See \ref ConfigOptionFlags. |
41 unsigned int flags; | |
8164 | 42 }; |
43 | |
18258 | 44 /// \defgroup ConfigProfiles Config profiles |
45 /// \ingroup Config | |
46 /// | |
18283 | 47 /// Profiles allow to predefine some sets of options that can then |
18258 | 48 /// be applied later on with the internal -profile option. |
49 /// | |
50 ///@{ | |
51 | |
52 /// Config profile | |
17471 | 53 struct m_profile { |
54 m_profile_t* next; | |
55 char* name; | |
56 char* desc; | |
57 int num_opts; | |
18258 | 58 /// Option/value pair array. |
17471 | 59 char** opts; |
60 }; | |
61 | |
18258 | 62 ///@} |
63 | |
64 /// Config object | |
65 /** \ingroup Config */ | |
8164 | 66 typedef struct m_config { |
18258 | 67 /// Registered options. |
18283 | 68 /** This contains all options and suboptions. |
18258 | 69 */ |
8164 | 70 m_config_option_t* opts; |
18258 | 71 /// Current stack level. |
72 int lvl; | |
73 /// \ref OptionParserModes | |
8164 | 74 int mode; |
18283 | 75 /// List of defined profiles. |
17471 | 76 m_profile_t* profiles; |
18258 | 77 /// Depth when recursively including profiles. |
17471 | 78 int profile_depth; |
18258 | 79 /// Options defined by the config itself. |
17471 | 80 struct m_option* self_opts; |
8164 | 81 } m_config_t; |
82 | |
18258 | 83 /// \defgroup ConfigOptionFlags Config option flags |
84 /// \ingroup Config | |
85 ///@{ | |
86 | |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
87 /// Set if an option has been set at the current level. |
9912
39444d65c4cb
Don't save restore all options wich point to the same variable.
albeu
parents:
8168
diff
changeset
|
88 #define M_CFG_OPT_SET (1<<0) |
18258 | 89 |
18283 | 90 /// Set if another option already uses the same variable. |
9912
39444d65c4cb
Don't save restore all options wich point to the same variable.
albeu
parents:
8168
diff
changeset
|
91 #define M_CFG_OPT_ALIAS (1<<1) |
39444d65c4cb
Don't save restore all options wich point to the same variable.
albeu
parents:
8168
diff
changeset
|
92 |
18258 | 93 ///@} |
8164 | 94 |
18258 | 95 /// Create a new config object. |
96 /** \ingroup Config | |
97 */ | |
8164 | 98 m_config_t* |
99 m_config_new(void); | |
100 | |
18258 | 101 /// Free a config object. |
8164 | 102 void |
103 m_config_free(m_config_t* config); | |
104 | |
18258 | 105 /// Push a new context. |
106 /** \param config The config object. | |
107 */ | |
8164 | 108 void |
109 m_config_push(m_config_t* config); | |
110 | |
18258 | 111 /// Pop the current context restoring the previous context state. |
112 /** \param config The config object. | |
113 */ | |
8164 | 114 void |
115 m_config_pop(m_config_t* config); | |
116 | |
18258 | 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. | |
121 */ | |
8164 | 122 int |
123 m_config_register_options(m_config_t *config, struct m_option *args); | |
124 | |
18258 | 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. | |
130 */ | |
8164 | 131 int |
132 m_config_set_option(m_config_t *config, char* arg, char* param); | |
133 | |
18258 | 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. | |
139 */ | |
8164 | 140 int |
141 m_config_check_option(m_config_t *config, char* arg, char* param); | |
142 | |
18258 | 143 /// Get the option matching the given name. |
144 /** \param config The config object. | |
145 * \param arg The option's name. | |
146 */ | |
8164 | 147 struct m_option* |
148 m_config_get_option(m_config_t *config, char* arg); | |
149 | |
18258 | 150 /// Print a list of all registered options. |
151 /** \param config The config object. | |
152 */ | |
8168 | 153 void |
154 m_config_print_option_list(m_config_t *config); | |
155 | |
18258 | 156 /// \addtogroup ConfigProfiles |
157 ///@{ | |
158 | |
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. | |
163 */ | |
17471 | 164 m_profile_t* |
165 m_config_get_profile(m_config_t* config, char* name); | |
166 | |
18258 | 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. | |
171 */ | |
17471 | 172 m_profile_t* |
173 m_config_add_profile(m_config_t* config, char* name); | |
174 | |
18258 | 175 /// Set the description of a profile. |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
176 /** Used by the config file parser when defining a profile. |
18258 | 177 * |
178 * \param p The profile object. | |
179 * \param arg The profile's name. | |
180 */ | |
17471 | 181 void |
182 m_profile_set_desc(m_profile_t* p, char* desc); | |
183 | |
18258 | 184 /// Add an option to a profile. |
18316
b3be7df634b0
spelling/grammar/wording fixes in doxygen and non-doxygen comments
diego
parents:
18283
diff
changeset
|
185 /** Used by the config file parser when defining a profile. |
18258 | 186 * |
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. | |
191 */ | |
17471 | 192 int |
193 m_config_set_profile_option(m_config_t* config, m_profile_t* p, | |
194 char* name, char* val); | |
195 | |
18258 | 196 ///@} |
197 | |
198 ///@} | |
199 | |
23689
3f0d00abc073
Do not use leading underscores in multiple inclusion guards, they are reserved.
diego
parents:
18316
diff
changeset
|
200 #endif /* M_CONFIG_H */ |