Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Diff of /src/xine-engine/configfile.c [01a3c3] .. [aef122] Maximize Restore

  Switch to side-by-side view

--- 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;
-
-static config_entry_translation_t config_entry_translation[] = {
+#include <xine/xineutils.h>
+#include <xine/xine_internal.h>
+
+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 @@
   { "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 @@
   { "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 @@
     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 @@
   }
 
   /* 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;
-
-  return NULL;
+  newkey = config_xlate_internal (key, config_entry_translation);
+  if (!newkey && config_entry_translation_user)
+    newkey = config_xlate_internal (key, config_entry_translation_user);
+
+  return newkey;
 }
 
 static void config_lookup_entry_int (config_values_t *this, const char *key,
@@ -903,6 +901,14 @@
   if (str_free)
     free(str_free);
   pthread_mutex_unlock(&this->config_lock);
+}
+
+/*
+ * front end config translation handling
+ */
+void xine_config_set_translation_user (const xine_config_entry_translation_t *xlate)
+{
+  config_entry_translation_user = xlate;
 }
 
 /*
@@ -1063,7 +1069,7 @@
 
       if (!entry->key[0])
         /* deleted key */
-        continue;
+        goto next;
 
       lprintf ("saving key '%s'\n", entry->key);
 
@@ -1133,6 +1139,7 @@
 	break;
       }
 
+      next:
       entry = entry->next;
     }
     pthread_mutex_unlock(&this->config_lock);
@@ -1334,7 +1341,7 @@
     }
 
     /* 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 @@
   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 @@
   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);