summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2001-11-18 03:53:23 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2001-11-18 03:53:23 +0000
commit4c71c84391e9a607394b7f7a23877ba15dffbf67 (patch)
tree53bf6a2b06b97cde43a11cafda54942a3a9bea45 /include
parent4b36ff207a52ea90bfd9b8c34c97f14963f0960d (diff)
downloadxine-lib-4c71c84391e9a607394b7f7a23877ba15dffbf67.tar.gz
xine-lib-4c71c84391e9a607394b7f7a23877ba15dffbf67.tar.bz2
new configfile interface, code cleanup, xprintf is gone
CVS patchset: 1064 CVS date: 2001/11/18 03:53:23
Diffstat (limited to 'include')
-rw-r--r--include/xine.h.tmpl.in175
1 files changed, 131 insertions, 44 deletions
diff --git a/include/xine.h.tmpl.in b/include/xine.h.tmpl.in
index 04cd4f3c0..0e271a5fd 100644
--- a/include/xine.h.tmpl.in
+++ b/include/xine.h.tmpl.in
@@ -28,7 +28,7 @@
\endverbatim
*/
/*
- * $Id: xine.h.tmpl.in,v 1.54 2001/11/10 06:26:01 mlampard Exp $
+ * $Id: xine.h.tmpl.in,v 1.55 2001/11/18 03:53:23 guenter Exp $
*
*/
@@ -483,59 +483,146 @@ typedef void xine_t;
* Opaque data type.
*/
typedef void ao_driver_t;
-/**
- * \struct cfg_data_t
- * Opaque data type.
- */
-typedef void cfg_data_t;
-/**
- * \struct config_values_t
- * \brief Data type of structure config_values_s.
- * \sa config_values_s.
+typedef struct cfg_entry_s cfg_entry_t;
+typedef void (*config_cb_t) (void *, cfg_entry_t *);
+
+struct cfg_entry_s {
+ cfg_entry_t *next;
+
+ char *key;
+ int type;
+
+ /* type unknown */
+ char *unknown_value;
+
+ /* type string */
+ char *str_value;
+ char *str_default;
+
+ /* common to range, enum, num, bool: */
+
+ int num_value;
+ int num_default;
+
+ /* type range specific: */
+ int range_min;
+ int range_max;
+
+ /* type enum specific: */
+ char **enum_values;
+
+ /* help info for the user */
+ char *description;
+ char *help;
+
+ /* callback function and data for live changeable values */
+ config_cb_t callback;
+ void *callback_data;
+};
+
+/*
+ * config entry data types
*/
+
+#define CONFIG_TYPE_UNKNOWN 0
+#define CONFIG_TYPE_RANGE 1
+#define CONFIG_TYPE_STRING 2
+#define CONFIG_TYPE_ENUM 3
+#define CONFIG_TYPE_NUM 4
+#define CONFIG_TYPE_BOOL 5
+
typedef struct config_values_s config_values_t;
-/**
- * \struct config_values_s
- * Configuration file manipulation.
- * \sa config_file_init()
- */
struct config_values_s {
- /**
- * Lookup string values in configuration file.
- */
- char* (*lookup_str) (config_values_t *self,
- char *key, char *str_default);
- /**
- * Lookup integer values in configuration file.
- */
- int (*lookup_int) (config_values_t *self,
- char *key, int n_default);
- /**
- * Set string values in configuration file.
+
+ /*
+ * register config values
+ *
+ * these functions return the current value of the
+ * registered item, i.e. the default value if it was
+ * not found in the config file or the current value
+ * from the config file otherwise
*/
- void (*set_str) (config_values_t *self,
- char *key, char *value) ;
- /**
- * Set integer values in configuration file.
+
+ char* (*register_string) (config_values_t *this,
+ char *key,
+ char *def_value,
+ char *description,
+ char *help,
+ config_cb_t changed_cb,
+ void *cb_data);
+
+ int (*register_range) (config_values_t *this,
+ char *key,
+ int def_value,
+ int min, int max,
+ char *description,
+ char *help,
+ config_cb_t changed_cb,
+ void *cb_data);
+
+ int (*register_enum) (config_values_t *this,
+ char *key,
+ int def_value,
+ char **values,
+ char *description,
+ char *help,
+ config_cb_t changed_cb,
+ void *cb_data);
+
+ int (*register_num) (config_values_t *this,
+ char *key,
+ int def_value,
+ char *description,
+ char *help,
+ config_cb_t changed_cb,
+ void *cb_data);
+
+ int (*register_bool) (config_values_t *this,
+ char *key,
+ int def_value,
+ char *description,
+ char *help,
+ config_cb_t changed_cb,
+ void *cb_data);
+
+ /* convenience function to update range, enum, num and bool values */
+ void (*update_num) (config_values_t *this,
+ char *key, int value);
+
+ /* convenience function to update string values */
+ void (*update_string) (config_values_t *this,
+ char *key, char *value);
+
+ /* small utility function for enum handling */
+ int (*parse_enum) (char *str, char **values);
+
+ /*
+ * lookup config entries
+ *
+ * remember to call the changed_cb if it exists
+ * and you changed the value of this item
*/
- void (*set_int) (config_values_t *self,
- char *key, int value) ;
- /**
- * Write configuration file to disk.
+
+ cfg_entry_t* (*lookup_entry) (config_values_t *this,
+ char *key);
+
+ /*
+ * write config file to disk
*/
- void (*save) (config_values_t *self);
- /**
- * Read configuration file from disk, overriding values in memory.
- * If you also want to clear values that are not in the file,
- * use config_file_init() instead!
+ void (*save) (config_values_t *this);
+
+ /*
+ * read config file from disk, overriding values in memory
*/
- void (*read) (config_values_t *self, char *filename);
- /**
- * Contains private data of this configuration file.
+ void (*read) (config_values_t *this, char *filename);
+
+ /*
+ * config values are stored here:
*/
- cfg_data_t *data;
+ cfg_entry_t *first, *last;
};
+
/** @} end of config_group */