changeset 1533:e0438384ce0a trunk

[svn] - byebye XMMS configfile crap
author nenolod
date Tue, 08 Aug 2006 02:20:57 -0700
parents f74a6ba233c2
children 02ce15d47ce1
files ChangeLog libaudacious/Makefile.in libaudacious/configfile.c libaudacious/configfile.h
diffstat 4 files changed, 9 insertions(+), 629 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Aug 08 02:19:55 2006 -0700
+++ b/ChangeLog	Tue Aug 08 02:20:57 2006 -0700
@@ -1,3 +1,12 @@
+2006-08-08 09:19:55 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [1978]
+  - allow configdb::pnxmms::preset to set what pn preset to load on start
+  
+
+  Changes:        Modified:
+  +5 -0           trunk/Plugins/Visualization/paranormal/client.c  
+
+
 2006-08-08 06:49:36 +0000  William Pitcock <nenolod@nenolod.net>
   revision [1976]
   - ok, with this commit, loading now works =)
--- a/libaudacious/Makefile.in	Tue Aug 08 02:19:55 2006 -0700
+++ b/libaudacious/Makefile.in	Tue Aug 08 02:20:57 2006 -0700
@@ -27,7 +27,6 @@
 	$(CONF_SRC) \
 	rcfile.c \
 	$(VFS_SRC) \
-	configfile.c \
 	beepctrl.c \
 	dirbrowser.c \
 	util.c \
@@ -41,7 +40,6 @@
 
 HEADERS = \
 	vfs.h rcfile.h configdb.h \
-	configfile.h \
 	beepctrl.h dirbrowser.h util.h \
 	formatter.h titlestring.h xml_document.h
 
--- a/libaudacious/configfile.c	Tue Aug 08 02:19:55 2006 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,495 +0,0 @@
-/*  XMMS - Cross-platform multimedia player
- *  Copyright (C) 1998-2002  Peter Alm, Mikael Alm, Olle Hallnas,
- *                           Thomas Nilsson and 4Front Technologies
- *  Copyright (C) 1999-2002  Haavard Kvaalen
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#if defined(HAVE_CONFIG_H)
-#include "../config.h"
-#endif
-
-/* bypass the poisoning of the symbols we need */
-#define I_AM_A_THIRD_PARTY_DEVELOPER_WHO_NEEDS_TO_BE_KICKED_IN_THE_HEAD_BY_CHUCK_NORRIS
-
-#include "configfile.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <locale.h>
-
-#include <unistd.h>
-#include <sys/stat.h>
-
-typedef gboolean(*XmmsCfgValueReadFunc) (ConfigFile * config_file,
-                                         const gchar * section,
-                                         const gchar * key,
-                                         gpointer * value);
-
-typedef void (*XmmsCfgValueWriteFunc) (ConfigFile * config_file,
-                                       const gchar * section,
-                                       const gchar * key,
-                                       gpointer * value);
-
-struct _XmmsCfgValueTypeInfo {
-    XmmsCfgValueReadFunc read;
-    XmmsCfgValueWriteFunc write;
-};
-
-typedef struct _XmmsCfgValueTypeInfo XmmsCfgValueTypeInfo;
-
-
-static XmmsCfgValueTypeInfo xmms_cfg_value_type_func[] = {
-    {(XmmsCfgValueReadFunc) xmms_cfg_read_int,
-     (XmmsCfgValueWriteFunc) xmms_cfg_write_int},
-    {(XmmsCfgValueReadFunc) xmms_cfg_read_float,
-     (XmmsCfgValueWriteFunc) xmms_cfg_write_float},
-    {(XmmsCfgValueReadFunc) xmms_cfg_read_boolean,
-     (XmmsCfgValueWriteFunc) xmms_cfg_write_boolean},
-    {(XmmsCfgValueReadFunc) xmms_cfg_read_string,
-     (XmmsCfgValueWriteFunc) xmms_cfg_write_string}
-};
-
-
-static ConfigSection *xmms_cfg_create_section(ConfigFile * cfg,
-                                              const gchar * name);
-static ConfigLine *xmms_cfg_create_string(ConfigSection * section,
-                                          const gchar * key,
-                                          const gchar * value);
-static ConfigSection *xmms_cfg_find_section(ConfigFile * cfg,
-                                            const gchar * name);
-static ConfigLine *xmms_cfg_find_string(ConfigSection * section,
-                                        const gchar * key);
-
-
-ConfigFile *xmms_cfg_new(void)
-{
-    return g_new0(ConfigFile, 1);
-}
-
-gboolean xmms_cfg_read_value(ConfigFile * config_file,
-                             const gchar * section, const gchar * key,
-                             XmmsCfgValueType value_type, gpointer * value)
-{
-    return xmms_cfg_value_type_func[value_type].read(config_file,
-                                                     section, key, value);
-}
-
-void xmms_cfg_write_value(ConfigFile * config_file,
-                          const gchar * section, const gchar * key,
-                          XmmsCfgValueType value_type, gpointer * value)
-{
-    xmms_cfg_value_type_func[value_type].read(config_file,
-                                              section, key, value);
-}
-
-ConfigFile *xmms_cfg_open_file(const gchar * filename)
-{
-    ConfigFile *cfg;
-
-    gchar *buffer, **lines, *tmp;
-    gint i;
-    ConfigSection *section = NULL;
-
-    g_return_val_if_fail(filename != NULL, FALSE);
-
-    if (!g_file_get_contents(filename, &buffer, NULL, NULL))
-        return NULL;
-
-    cfg = g_malloc0(sizeof(ConfigFile));
-    lines = g_strsplit(buffer, "\n", 0);
-    g_free(buffer);
-    i = 0;
-    while (lines[i]) {
-        if (lines[i][0] == '[') {
-            if ((tmp = strchr(lines[i], ']'))) {
-                *tmp = '\0';
-                section = xmms_cfg_create_section(cfg, &lines[i][1]);
-            }
-        } else if (lines[i][0] != '#' && section) {
-            if ((tmp = strchr(lines[i], '='))) {
-                *tmp = '\0';
-                tmp++;
-                xmms_cfg_create_string(section, lines[i], tmp);
-            }
-        }
-        i++;
-    }
-    g_strfreev(lines);
-    return cfg;
-}
-
-gchar *xmms_cfg_get_default_filename(void)
-{
-    static gchar *filename = NULL;
-    if (!filename)
-        filename =
-            g_strconcat(g_get_home_dir(), "/", BMP_RCPATH, "/config",
-                        NULL);
-    return filename;
-}
-
-ConfigFile *xmms_cfg_open_default_file(void)
-{
-    ConfigFile *ret;
-
-    ret = xmms_cfg_open_file(xmms_cfg_get_default_filename());
-    if (!ret)
-        ret = xmms_cfg_new();
-    return ret;
-}
-
-gboolean xmms_cfg_write_file(ConfigFile * cfg, const gchar * filename)
-{
-    FILE *file;
-    GList *section_list, *line_list;
-    ConfigSection *section;
-    ConfigLine *line;
-
-    g_return_val_if_fail(cfg != NULL, FALSE);
-    g_return_val_if_fail(filename != NULL, FALSE);
-
-    if (!(file = fopen(filename, "w")))
-        return FALSE;
-
-    section_list = cfg->sections;
-    while (section_list) {
-        section = (ConfigSection *) section_list->data;
-        if (section->lines) {
-            fprintf(file, "[%s]\n", section->name);
-            line_list = section->lines;
-            while (line_list) {
-                line = (ConfigLine *) line_list->data;
-                fprintf(file, "%s=%s\n", line->key, line->value);
-                line_list = g_list_next(line_list);
-            }
-            fprintf(file, "\n");
-        }
-        section_list = g_list_next(section_list);
-    }
-    fclose(file);
-    return TRUE;
-}
-
-gboolean xmms_cfg_write_default_file(ConfigFile * cfg)
-{
-    return xmms_cfg_write_file(cfg, xmms_cfg_get_default_filename());
-}
-
-gboolean xmms_cfg_read_string(ConfigFile * cfg, const gchar * section,
-                              const gchar * key, gchar ** value)
-{
-    ConfigSection *sect;
-    ConfigLine *line;
-
-    g_return_val_if_fail(cfg != NULL, FALSE);
-    g_return_val_if_fail(section != NULL, FALSE);
-    g_return_val_if_fail(key != NULL, FALSE);
-    g_return_val_if_fail(value != NULL, FALSE);
-
-    if (!(sect = xmms_cfg_find_section(cfg, section)))
-        return FALSE;
-    if (!(line = xmms_cfg_find_string(sect, key)))
-        return FALSE;
-    *value = g_strdup(line->value);
-    return TRUE;
-}
-
-gboolean xmms_cfg_read_int(ConfigFile * cfg, const gchar * section,
-                           const gchar * key, gint * value)
-{
-    gchar *str;
-
-    g_return_val_if_fail(cfg != NULL, FALSE);
-    g_return_val_if_fail(section != NULL, FALSE);
-    g_return_val_if_fail(key != NULL, FALSE);
-    g_return_val_if_fail(value != NULL, FALSE);
-
-    if (!xmms_cfg_read_string(cfg, section, key, &str))
-        return FALSE;
-    *value = atoi(str);
-    g_free(str);
-
-    return TRUE;
-}
-
-gboolean xmms_cfg_read_boolean(ConfigFile * cfg,
-                               const gchar * section, const gchar * key,
-                               gboolean * value)
-{
-    gchar *str;
-
-    g_return_val_if_fail(cfg != NULL, FALSE);
-    g_return_val_if_fail(section != NULL, FALSE);
-    g_return_val_if_fail(key != NULL, FALSE);
-    g_return_val_if_fail(value != NULL, FALSE);
-
-    if (!xmms_cfg_read_string(cfg, section, key, &str))
-        return FALSE;
-    if (!strcasecmp(str, "TRUE"))
-        *value = TRUE;
-    else
-        *value = FALSE;
-    g_free(str);
-    return TRUE;
-}
-
-gboolean xmms_cfg_read_float(ConfigFile * cfg,
-                             const gchar * section, const gchar * key,
-                             gfloat * value)
-{
-    gchar *str, *locale;
-
-    g_return_val_if_fail(cfg != NULL, FALSE);
-    g_return_val_if_fail(section != NULL, FALSE);
-    g_return_val_if_fail(key != NULL, FALSE);
-    g_return_val_if_fail(value != NULL, FALSE);
-
-    if (!xmms_cfg_read_string(cfg, section, key, &str))
-        return FALSE;
-
-    locale = g_strdup(setlocale(LC_NUMERIC, NULL));
-    setlocale(LC_NUMERIC, "C");
-    *value = strtod(str, NULL);
-    setlocale(LC_NUMERIC, locale);
-    g_free(locale);
-    g_free(str);
-
-    return TRUE;
-}
-
-gboolean xmms_cfg_read_double(ConfigFile * cfg,
-                              const gchar * section, const gchar * key,
-                              gdouble * value)
-{
-    gchar *str, *locale;
-
-    g_return_val_if_fail(cfg != NULL, FALSE);
-    g_return_val_if_fail(section != NULL, FALSE);
-    g_return_val_if_fail(key != NULL, FALSE);
-    g_return_val_if_fail(value != NULL, FALSE);
-
-    if (!xmms_cfg_read_string(cfg, section, key, &str))
-        return FALSE;
-
-    locale = g_strdup(setlocale(LC_NUMERIC, NULL));
-    setlocale(LC_NUMERIC, "C");
-    *value = strtod(str, NULL);
-    setlocale(LC_NUMERIC, locale);
-    g_free(locale);
-    g_free(str);
-
-    return TRUE;
-}
-
-void xmms_cfg_write_string(ConfigFile * cfg,
-                           const gchar * section, const gchar * key,
-                           gchar * value)
-{
-    ConfigSection *sect;
-    ConfigLine *line;
-
-    g_return_if_fail(cfg != NULL);
-    g_return_if_fail(section != NULL);
-    g_return_if_fail(key != NULL);
-    g_return_if_fail(value != NULL);
-
-    sect = xmms_cfg_find_section(cfg, section);
-    if (!sect)
-        sect = xmms_cfg_create_section(cfg, section);
-    if ((line = xmms_cfg_find_string(sect, key))) {
-        g_free(line->value);
-        line->value = g_strstrip(g_strdup(value));
-    } else
-        xmms_cfg_create_string(sect, key, value);
-}
-
-void xmms_cfg_write_int(ConfigFile * cfg,
-                        const gchar * section, const gchar * key,
-                        gint value)
-{
-    gchar *strvalue;
-
-    g_return_if_fail(cfg != NULL);
-    g_return_if_fail(section != NULL);
-    g_return_if_fail(key != NULL);
-
-    strvalue = g_strdup_printf("%d", value);
-    xmms_cfg_write_string(cfg, section, key, strvalue);
-    g_free(strvalue);
-}
-
-void xmms_cfg_write_boolean(ConfigFile * cfg,
-                            const gchar * section, const gchar * key,
-                            gboolean value)
-{
-    g_return_if_fail(cfg != NULL);
-    g_return_if_fail(section != NULL);
-    g_return_if_fail(key != NULL);
-
-    if (value)
-        xmms_cfg_write_string(cfg, section, key, "TRUE");
-    else
-        xmms_cfg_write_string(cfg, section, key, "FALSE");
-}
-
-void xmms_cfg_write_float(ConfigFile * cfg,
-                          const gchar * section, const gchar * key,
-                          gfloat value)
-{
-    gchar *strvalue, *locale;
-
-    g_return_if_fail(cfg != NULL);
-    g_return_if_fail(section != NULL);
-    g_return_if_fail(key != NULL);
-
-    locale = g_strdup(setlocale(LC_NUMERIC, NULL));
-    setlocale(LC_NUMERIC, "C");
-    strvalue = g_strdup_printf("%g", value);
-    setlocale(LC_NUMERIC, locale);
-    xmms_cfg_write_string(cfg, section, key, strvalue);
-    g_free(locale);
-    g_free(strvalue);
-}
-
-void xmms_cfg_write_double(ConfigFile * cfg,
-                           const gchar * section, const gchar * key,
-                           gdouble value)
-{
-    gchar *strvalue, *locale;
-
-    g_return_if_fail(cfg != NULL);
-    g_return_if_fail(section != NULL);
-    g_return_if_fail(key != NULL);
-
-    locale = g_strdup(setlocale(LC_NUMERIC, NULL));
-    setlocale(LC_NUMERIC, "C");
-    strvalue = g_strdup_printf("%g", value);
-    setlocale(LC_NUMERIC, locale);
-    xmms_cfg_write_string(cfg, section, key, strvalue);
-    g_free(locale);
-    g_free(strvalue);
-}
-
-void xmms_cfg_remove_key(ConfigFile * cfg,
-                         const gchar * section, const gchar * key)
-{
-    ConfigSection *sect;
-    ConfigLine *line;
-
-    g_return_if_fail(cfg != NULL);
-    g_return_if_fail(section != NULL);
-    g_return_if_fail(key != NULL);
-
-    if ((sect = xmms_cfg_find_section(cfg, section)) != NULL) {
-        if ((line = xmms_cfg_find_string(sect, key)) != NULL) {
-            g_free(line->key);
-            g_free(line->value);
-            g_free(line);
-            sect->lines = g_list_remove(sect->lines, line);
-        }
-    }
-}
-
-void xmms_cfg_free(ConfigFile * cfg)
-{
-    ConfigSection *section;
-    ConfigLine *line;
-    GList *section_list, *line_list;
-
-    if (cfg == NULL)
-        return;
-
-    section_list = cfg->sections;
-    while (section_list) {
-        section = (ConfigSection *) section_list->data;
-        g_free(section->name);
-
-        line_list = section->lines;
-        while (line_list) {
-            line = (ConfigLine *) line_list->data;
-            g_free(line->key);
-            g_free(line->value);
-            g_free(line);
-            line_list = g_list_next(line_list);
-        }
-        g_list_free(section->lines);
-        g_free(section);
-
-        section_list = g_list_next(section_list);
-    }
-    g_list_free(cfg->sections);
-    g_free(cfg);
-}
-
-static ConfigSection *xmms_cfg_create_section(ConfigFile * cfg,
-                                              const gchar * name)
-{
-    ConfigSection *section;
-
-    section = g_new0(ConfigSection, 1);
-    section->name = g_strdup(name);
-    cfg->sections = g_list_append(cfg->sections, section);
-
-    return section;
-}
-
-static ConfigLine *xmms_cfg_create_string(ConfigSection * section,
-                                          const gchar * key,
-                                          const gchar * value)
-{
-    ConfigLine *line;
-
-    line = g_new0(ConfigLine, 1);
-    line->key = g_strstrip(g_strdup(key));
-    line->value = g_strstrip(g_strdup(value));
-    section->lines = g_list_append(section->lines, line);
-
-    return line;
-}
-
-static ConfigSection *xmms_cfg_find_section(ConfigFile * cfg,
-                                            const gchar * name)
-{
-    ConfigSection *section;
-    GList *list;
-
-    list = cfg->sections;
-    while (list) {
-        section = (ConfigSection *) list->data;
-        if (!strcasecmp(section->name, name))
-            return section;
-        list = g_list_next(list);
-    }
-    return NULL;
-}
-
-static ConfigLine *xmms_cfg_find_string(ConfigSection * section,
-                                        const gchar * key)
-{
-    ConfigLine *line;
-    GList *list;
-
-    list = section->lines;
-    while (list) {
-        line = (ConfigLine *) list->data;
-        if (!strcasecmp(line->key, key))
-            return line;
-        list = g_list_next(list);
-    }
-    return NULL;
-}
--- a/libaudacious/configfile.h	Tue Aug 08 02:19:55 2006 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
-/*  XMMS - Cross-platform multimedia player
- *  Copyright (C) 1998-2000  Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-#ifndef XMMS_CONFIGFILE_H
-#define XMMS_CONFIGFILE_H
-
-#include <glib.h>
-
-
-typedef enum {
-    XMMS_CFG_INT,
-    XMMS_CFG_FLOAT,
-    XMMS_CFG_BOOLEAN,
-    XMMS_CFG_STRING
-} XmmsCfgValueType;
-
-
-struct _ConfigLine {
-    gchar *key;
-    gchar *value;
-};
-
-struct _ConfigSection {
-    gchar *name;
-    GList *lines;
-};
-
-struct _ConfigFile {
-    GList *sections;
-};
-
-typedef struct _ConfigLine ConfigLine;
-typedef struct _ConfigSection ConfigSection;
-typedef struct _ConfigFile ConfigFile;
-
-/*
- * Poison all of the xmms ConfigFile interfaces as we are to
- * no longer use these anymore. They have been deprecated since 0.2,
- * and will be REMOVED in 1.2.
- *
- * If you are a third party developer and you need a quick fix, add
- *   #define I_AM_A_THIRD_PARTY_DEVELOPER_WHO_NEEDS_TO_BE_KICKED_IN_THE_HEAD_BY_CHUCK_NORRIS
- * to your code.
- *
- * - nenolod, 05/09/2006
- */
-#ifndef I_AM_A_THIRD_PARTY_DEVELOPER_WHO_NEEDS_TO_BE_KICKED_IN_THE_HEAD_BY_CHUCK_NORRIS
-#pragma GCC poison xmms_cfg_new
-#pragma GCC poison xmms_cfg_open_file
-#pragma GCC poison xmms_cfg_write_file
-#pragma GCC poison xmms_cfg_open_default_file
-#pragma GCC poison xmms_cfg_write_default_file
-#pragma GCC poison xmms_cfg_read_value
-#pragma GCC poison xmms_cfg_write_value
-#pragma GCC poison xmms_cfg_read_string
-#pragma GCC poison xmms_cfg_read_int
-#pragma GCC poison xmms_cfg_read_boolean
-#pragma GCC poison xmms_cfg_read_float
-#pragma GCC poison xmms_cfg_read_double
-#pragma GCC poison xmms_cfg_write_string
-#pragma GCC poison xmms_cfg_write_int
-#pragma GCC poison xmms_cfg_write_boolean
-#pragma GCC poison xmms_cfg_write_float
-#pragma GCC poison xmms_cfg_write_double
-#pragma GCC poison xmms_cfg_remove_key
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-    ConfigFile *xmms_cfg_new(void);
-    ConfigFile *xmms_cfg_open_file(const gchar * filename);
-    gboolean xmms_cfg_write_file(ConfigFile * cfg, const gchar * filename);
-    void xmms_cfg_free(ConfigFile * cfg);
-    ConfigFile *xmms_cfg_open_default_file(void);
-    gboolean xmms_cfg_write_default_file(ConfigFile * cfg);
-
-    gboolean xmms_cfg_read_value(ConfigFile * config_file,
-                                 const gchar * section, const gchar * key,
-                                 XmmsCfgValueType value_type,
-                                 gpointer * value);
-
-    void xmms_cfg_write_value(ConfigFile * config_file,
-                              const gchar * section, const gchar * key,
-                              XmmsCfgValueType value_type,
-                              gpointer * value);
-
-    gboolean xmms_cfg_read_string(ConfigFile * cfg, const gchar * section,
-                                  const gchar * key, gchar ** value);
-    gboolean xmms_cfg_read_int(ConfigFile * cfg, const gchar * section,
-                               const gchar * key, gint * value);
-    gboolean xmms_cfg_read_boolean(ConfigFile * cfg, const gchar * section,
-                                   const gchar * key, gboolean * value);
-    gboolean xmms_cfg_read_float(ConfigFile * cfg, const gchar * section,
-                                 const gchar * key, gfloat * value);
-    gboolean xmms_cfg_read_double(ConfigFile * cfg, const gchar * section,
-                                  const gchar * key, gdouble * value);
-
-    void xmms_cfg_write_string(ConfigFile * cfg, const gchar * section,
-                               const gchar * key, gchar * value);
-    void xmms_cfg_write_int(ConfigFile * cfg, const gchar * section,
-                            const gchar * key, gint value);
-    void xmms_cfg_write_boolean(ConfigFile * cfg, const gchar * section,
-                                const gchar * key, gboolean value);
-    void xmms_cfg_write_float(ConfigFile * cfg, const gchar * section,
-                              const gchar * key, gfloat value);
-    void xmms_cfg_write_double(ConfigFile * cfg, const gchar * section,
-                               const gchar * key, gdouble value);
-
-    void xmms_cfg_remove_key(ConfigFile * cfg, const gchar * section,
-                             const gchar * key);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif