diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-08-12 20:54:03 +0100 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-08-12 20:54:03 +0100 |
commit | 90bfed2c4c86e943ad850a023a28df31c558d75f (patch) | |
tree | cf8af063682a6cb40d5e6718e4c617515a9d5749 | |
parent | 50b0a0157709ed4a418012883793bf7ea9ddac13 (diff) | |
download | xine-lib-90bfed2c4c86e943ad850a023a28df31c558d75f.tar.gz xine-lib-90bfed2c4c86e943ad850a023a28df31c558d75f.tar.bz2 |
Extend config key translation to allow front ends to provide an additional list.
Intent is to allow front ends to rename their old, badly-named, config items.
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | include/xine.h.in | 10 | ||||
-rw-r--r-- | src/xine-engine/configfile.c | 39 |
4 files changed, 40 insertions, 17 deletions
@@ -6,6 +6,8 @@ xine-lib (1.1.8) (Unreleased) capable boxes it's probably worse than our own code). * Rename endianness-reading macros so that they don't collide with Solaris system macros. BE_/LE_ are now _X_BE_ and _X_LE_. + * Add an extra function to allow front ends to rename their old, + badly-named configuration items. xine-lib (1.1.7) * Support libdca (new name for libdts) by shuffling around the dts.h file. diff --git a/configure.ac b/configure.ac index 3d08dd44b..224f45773 100644 --- a/configure.ac +++ b/configure.ac @@ -49,9 +49,9 @@ dnl are platform dependent dnl * in Linux, the library will be named dnl libname.so.(XINE_LT_CURRENT - XINE_LT_AGE).XINE_LT_AGE.XINE_LT_REVISION -XINE_LT_CURRENT=18 -XINE_LT_REVISION=2 -XINE_LT_AGE=17 +XINE_LT_CURRENT=19 +XINE_LT_REVISION=0 +XINE_LT_AGE=18 dnl for a release tarball do "rm .cvsversion" before "make dist" if test -f "${srcdir-.}/.cvsversion"; then diff --git a/include/xine.h.in b/include/xine.h.in index f25038796..58507e6f1 100644 --- a/include/xine.h.in +++ b/include/xine.h.in @@ -1533,6 +1533,16 @@ void xine_config_update_entry (xine_t *self, const xine_cfg_entry_t *entry) XINE_PROTECTED; /* + * translation of old configuration entry names + */ +typedef struct { + const char *old; + const char *new; +} xine_config_entry_translation_t; + +void xine_config_set_translation_user (const xine_config_entry_translation_t *) XINE_PROTECTED; + +/* * load/save config data from/to afile (e.g. $HOME/.xine/config) */ void xine_config_load (xine_t *self, const char *cfg_filename) XINE_PROTECTED; diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index ec5f5c856..67c8ef909 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -45,13 +45,8 @@ #include "xineutils.h" #include "xine_internal.h" - -typedef struct { - const char *old; - const char *new; -} config_entry_translation_t; - -static const config_entry_translation_t config_entry_translation[] = { +static const xine_config_entry_translation_t *config_entry_translation_user = NULL; +static const xine_config_entry_translation_t config_entry_translation[] = { { "audio.a52_pass_through", "" }, { "audio.alsa_a52_device", "audio.device.alsa_passthrough_device" }, { "audio.alsa_default_device", "audio.device.alsa_default_device" }, @@ -209,7 +204,8 @@ static const config_entry_translation_t config_entry_translation[] = { { "video.xv_colorkey", "video.device.xv_colorkey" }, { "video.xv_pitch_alignment", "video.device.xv_pitch_alignment" }, { "video.xvmc_more_frames", "video.device.xvmc_more_frames" }, - { "video.xvmc_nvidia_color_fix", "video.device.xvmc_nvidia_color_fix" } + { "video.xvmc_nvidia_color_fix", "video.device.xvmc_nvidia_color_fix" }, + {} }; @@ -354,6 +350,15 @@ static void config_remove(config_values_t *this, cfg_entry_t *entry, cfg_entry_t prev->next = entry->next; } +static const char *config_xlate_internal (const char *key, const xine_config_entry_translation_t *trans) +{ + --trans; + while ((++trans)->old) + if (trans->new[0] && strcmp(key, trans->old) == 0) + return trans->new; + return NULL; +} + static const char *config_translate_key (const char *key) { /* Returns translated key or, if no translation found, NULL. * Translated key may be in a static buffer allocated within this function. @@ -373,13 +378,11 @@ static const char *config_translate_key (const char *key) { } /* search the translation table... */ - for (trans = 0; - trans < sizeof(config_entry_translation) / sizeof(config_entry_translation[0]); - trans++) - if (config_entry_translation[trans].new[0] && strcmp(key, config_entry_translation[trans].old) == 0) - return config_entry_translation[trans].new; + newkey = config_xlate_internal (key, config_entry_translation); + if (!newkey && config_entry_translation_user) + newkey = config_xlate_internal (key, config_entry_translation_user); - return NULL; + return newkey; } static void config_lookup_entry_int (config_values_t *this, const char *key, @@ -895,6 +898,14 @@ static void config_update_string (config_values_t *this, } /* + * front end config translation handling + */ +void xine_config_set_translation_user (const xine_config_entry_translation_t *xlate) +{ + config_entry_translation_user = xlate; +} + +/* * load/save config data from/to afile (e.g. $HOME/.xine/config) */ void xine_config_load (xine_t *xine, const char *filename) { |