path: root/m_config.h
diff options
authorwm4 <wm4@nowhere>2012-08-06 17:45:17 +0200
committerwm4 <wm4@nowhere>2012-08-06 17:45:17 +0200
commit7aae399239d02e48de9060dded1d0232310d2141 (patch)
treec4ede71396dccdc0a661d28fb4089af4c279aa05 /m_config.h
parent0c1dd8a8f54a152755faef3d323ce6fdc7d63f73 (diff)
m_config: support auto-allocated sub-structs
Given your option struct has a field that is a pointer to another struct, this commit allows you to declare options that write into that other struct. The code in m_config will dereference the pointer field on its own if such an option is accessed. If the field is NULL on initialization of the containing m_config, the struct is automatically allocated. OPT_SUBSTRUCT() can be used to declare such a field. struct m_sub_options is used to describe the pointed-to struct, and includes size and defaults if the struct has to be allocated by m_config.
Diffstat (limited to 'm_config.h')
1 files changed, 6 insertions, 0 deletions
diff --git a/m_config.h b/m_config.h
index beeab80a53..80897ce0e4 100644
--- a/m_config.h
+++ b/m_config.h
@@ -30,6 +30,7 @@
typedef struct m_profile m_profile_t;
struct m_option;
struct m_option_type;
+struct m_sub_options;
// Config option
struct m_config_option {
@@ -38,6 +39,8 @@ struct m_config_option {
char *name;
// Option description.
const struct m_option *opt;
+ // Raw value of the option.
+ void *data;
// Raw value of the backup of the global value (or NULL).
void *global_backup;
// See \ref ConfigOptionFlags.
@@ -198,4 +201,7 @@ int m_config_set_profile_option(struct m_config *config, struct m_profile *p,
void m_config_set_profile(struct m_config *config, struct m_profile *p);
+void *m_config_alloc_struct(void *talloc_parent,
+ const struct m_sub_options *subopts);
#endif /* MPLAYER_M_CONFIG_H */