diff options
Diffstat (limited to 'src/xine-engine/configfile.c')
-rw-r--r-- | src/xine-engine/configfile.c | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 38f2c5a6c..550c0372f 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -15,12 +15,9 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - * $Id: configfile.c,v 1.85 2007/02/22 15:49:16 dgp85 Exp $ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * * config object (was: file) management - implementation - * */ #ifdef HAVE_CONFIG_H @@ -34,8 +31,8 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <xine/configfile.h> #include "bswap.h" -#include "configfile.h" #define LOG_MODULE "configfile" #define LOG_VERBOSE @@ -43,16 +40,11 @@ #define LOG */ -#include "xineutils.h" -#include "xine_internal.h" - - -typedef struct { - const char *old; - const char *new; -} config_entry_translation_t; +#include <xine/xineutils.h> +#include <xine/xine_internal.h> -static 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" }, @@ -191,8 +183,6 @@ static config_entry_translation_t config_entry_translation[] = { { "video.pgx64_overlay_mode", "" }, { "video.pgx64_saturation", "video.output.pgx64_saturation" }, { "video.sdl_hw_accel", "video.device.sdl_hw_accel" }, - { "video.syncfb_default_repeat", "video.device.syncfb_default_repeat" }, - { "video.syncfb_device", "video.device.syncfb_device" }, { "video.unichrome_cpu_save", "video.device.unichrome_cpu_save" }, { "video.vertical_position", "video.output.vertical_position" }, { "video.vidix_blue_intensity", "video.output.vidix_blue_intensity" }, @@ -210,12 +200,13 @@ static 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" }, + {} }; static int config_section_enum(const char *sect) { - static char *known_section[] = { + static const char *const known_section[] = { "gui", "ui", "audio", @@ -355,6 +346,15 @@ static void config_remove(config_values_t *this, cfg_entry_t *entry, cfg_entry_t prev->next = entry->next; } +static char *config_xlate_internal (const char *key, const xine_config_entry_translation_t *trans) +{ + --trans; + while ((++trans)->old_name) + if (trans->new_name[0] && strcmp(key, trans->old_name) == 0) + return trans->new_name; + 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. @@ -374,13 +374,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, @@ -906,6 +904,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) { @@ -1063,7 +1069,7 @@ void xine_config_save (xine_t *xine, const char *filename) { if (!entry->key[0]) /* deleted key */ - continue; + goto next; lprintf ("saving key '%s'\n", entry->key); @@ -1133,6 +1139,7 @@ void xine_config_save (xine_t *xine, const char *filename) { break; } + next: entry = entry->next; } pthread_mutex_unlock(&this->config_lock); @@ -1334,7 +1341,7 @@ static char* config_get_serialized_entry (config_values_t *this, const char *key } /* and now the output encoding */ - output = base64_encode (buffer, total_len, &output_len); + output = xine_base64_encode (buffer, total_len, &output_len); free(buffer); } @@ -1350,7 +1357,7 @@ static int get_int(uint8_t *buffer, int buffer_size, int pos, int *value) { if ((pos + sizeof(int32_t)) > buffer_size) return 0; - value_int32 = LE_32(&buffer[pos]); + value_int32 = _X_LE_32(&buffer[pos]); *value = (int)value_int32; return sizeof(int32_t); } @@ -1406,7 +1413,7 @@ static char* config_register_serialized_entry (config_values_t *this, const char int value_count = 0; int i; - output = base64_decode (value, strlen(value), &output_len); + output = xine_base64_decode (value, strlen(value), &output_len); pos = 0; pos += bytes = get_int(output, output_len, pos, &type); |