Mercurial > audlegacy
changeset 2541:c399c0979e09 trunk
[svn] - put configdb back in libaudacious as the client library needs it
author | nenolod |
---|---|
date | Sat, 17 Feb 2007 02:32:37 -0800 |
parents | 6b2743b54fd7 |
children | ef01234ae265 |
files | ChangeLog src/audacious/Makefile src/audacious/build_stamp.c src/audacious/configdb.c src/audacious/configdb.h src/libaudacious/Makefile src/libaudacious/configdb.c src/libaudacious/configdb.h |
diffstat | 8 files changed, 402 insertions(+), 393 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Feb 17 02:30:32 2007 -0800 +++ b/ChangeLog Sat Feb 17 02:32:37 2007 -0800 @@ -1,3 +1,11 @@ +2007-02-17 10:30:32 +0000 William Pitcock <nenolod@sacredspiral.co.uk> + revision [4090] + - update options printout + + trunk/configure.ac | 14 ++------------ + 1 file changed, 2 insertions(+), 12 deletions(-) + + 2007-02-17 10:21:23 +0000 William Pitcock <nenolod@sacredspiral.co.uk> revision [4088] - add Teru KAGOMASHIRA to credits.
--- a/src/audacious/Makefile Sat Feb 17 02:30:32 2007 -0800 +++ b/src/audacious/Makefile Sat Feb 17 02:32:37 2007 -0800 @@ -52,7 +52,6 @@ SOURCES = \ build_stamp.c \ controlsocket.c \ - configdb.c \ dnd.c \ dock.c \ effect.c \
--- a/src/audacious/build_stamp.c Sat Feb 17 02:30:32 2007 -0800 +++ b/src/audacious/build_stamp.c Sat Feb 17 02:32:37 2007 -0800 @@ -1,2 +1,2 @@ #include <glib.h> -const gchar *svn_stamp = "20070217-4088"; +const gchar *svn_stamp = "20070217-4090";
--- a/src/audacious/configdb.c Sat Feb 17 02:30:32 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,193 +0,0 @@ -/* 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. - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "configdb.h" - -#include <stdlib.h> -#include <string.h> - -#include <libmcs/mcs.h> - - -#define RCFILE_DEFAULT_SECTION_NAME "audacious" - -static gboolean mcs_initted = FALSE; - -struct _ConfigDb -{ - mcs_handle_t *handle; -}; - - -ConfigDb * -bmp_cfg_db_open() -{ - ConfigDb *db; - - db = g_new(ConfigDb, 1); - - if (!mcs_initted) - { - mcs_init(); - mcs_initted = TRUE; - } - - db->handle = mcs_new(RCFILE_DEFAULT_SECTION_NAME); - - return db; -} - -void -bmp_cfg_db_close(ConfigDb * db) -{ - mcs_destroy(db->handle); - g_free(db); -} - -gboolean -bmp_cfg_db_get_string(ConfigDb * db, - const gchar * section, - const gchar * key, - gchar ** value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - return mcs_get_string(db->handle, section, key, value); -} - -gboolean -bmp_cfg_db_get_int(ConfigDb * db, - const gchar * section, const gchar * key, gint * value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - return mcs_get_int(db->handle, section, key, value); -} - -gboolean -bmp_cfg_db_get_bool(ConfigDb * db, - const gchar * section, - const gchar * key, - gboolean * value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - return mcs_get_bool(db->handle, section, key, value); -} - -gboolean -bmp_cfg_db_get_float(ConfigDb * db, - const gchar * section, - const gchar * key, - gfloat * value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - return mcs_get_float(db->handle, section, key, value); -} - -gboolean -bmp_cfg_db_get_double(ConfigDb * db, - const gchar * section, - const gchar * key, - gdouble * value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - return mcs_get_double(db->handle, section, key, value); -} - -void -bmp_cfg_db_set_string(ConfigDb * db, - const gchar * section, - const gchar * key, - const gchar * value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_set_string(db->handle, section, key, value); -} - -void -bmp_cfg_db_set_int(ConfigDb * db, - const gchar * section, - const gchar * key, - gint value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_set_int(db->handle, section, key, value); -} - -void -bmp_cfg_db_set_bool(ConfigDb * db, - const gchar * section, - const gchar * key, - gboolean value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_set_bool(db->handle, section, key, value); -} - -void -bmp_cfg_db_set_float(ConfigDb * db, - const gchar * section, - const gchar * key, - gfloat value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_set_float(db->handle, section, key, value); -} - -void -bmp_cfg_db_set_double(ConfigDb * db, - const gchar * section, - const gchar * key, - gdouble value) -{ - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_set_double(db->handle, section, key, value); -} - -void -bmp_cfg_db_unset_key(ConfigDb * db, - const gchar * section, - const gchar * key) -{ - g_return_if_fail(db != NULL); - g_return_if_fail(key != NULL); - - if (!section) - section = RCFILE_DEFAULT_SECTION_NAME; - - mcs_unset_key(db->handle, section, key); -}
--- a/src/audacious/configdb.h Sat Feb 17 02:30:32 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,198 +0,0 @@ -#ifndef CONFIGDB_H -#define CONFIGDB_H - -#include <glib.h> - -/** - * ConfigDb: - * - * A configuration database handle, opened with bmp_cfg_db_open(). - **/ -typedef struct _ConfigDb ConfigDb; - - -G_BEGIN_DECLS - - /** - * bmp_cfg_db_open: - * - * Opens the configuration database. - * - * Return value: A configuration database handle. - **/ - ConfigDb *bmp_cfg_db_open(); - - /** - * bmp_cfg_db_close: - * @db: A configuration database handle. - * - * Closes the configuration database. - **/ - void bmp_cfg_db_close(ConfigDb *db); - - /** - * bmp_cfg_db_get_string: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to look up. - * @value: Pointer to a buffer to put the data in. - * - * Searches the configuration database for a value. - * - * Return value: TRUE if successful, FALSE otherwise. - **/ - gboolean bmp_cfg_db_get_string(ConfigDb *db, - const gchar *section, - const gchar *key, - gchar **value); - - /** - * bmp_cfg_db_get_int: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to look up. - * @value: Pointer to an integer to put the data in. - * - * Searches the configuration database for a value. - * - * Return value: TRUE if successful, FALSE otherwise. - **/ - gboolean bmp_cfg_db_get_int(ConfigDb *db, - const gchar *section, - const gchar *key, - gint *value); - - /** - * bmp_cfg_db_get_bool: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to look up. - * @value: Pointer to a boolean to put the data in. - * - * Searches the configuration database for a value. - * - * Return value: TRUE if successful, FALSE otherwise. - **/ - gboolean bmp_cfg_db_get_bool(ConfigDb *db, - const gchar *section, - const gchar *key, - gboolean *value); - - /** - * bmp_cfg_db_get_float: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to look up. - * @value: Pointer to a floating point integer to put the data in. - * - * Searches the configuration database for a value. - * - * Return value: TRUE if successful, FALSE otherwise. - **/ - gboolean bmp_cfg_db_get_float(ConfigDb *db, - const gchar *section, - const gchar *key, - gfloat *value); - - /** - * bmp_cfg_db_get_double: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to look up. - * @value: Pointer to a double-precision floating point integer to put the data in. - * - * Searches the configuration database for a value. - * - * Return value: TRUE if successful, FALSE otherwise. - **/ - gboolean bmp_cfg_db_get_double(ConfigDb *db, - const gchar *section, - const gchar *key, - gdouble *value); - - /** - * bmp_cfg_db_set_string: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * @value: Pointer to a buffer containing the data. - * - * Sets a value in the configuration database. - **/ - void bmp_cfg_db_set_string(ConfigDb *db, - const gchar *section, - const gchar *key, - const gchar *value); - - /** - * bmp_cfg_db_set_int: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * @value: Pointer to an integer containing the data. - * - * Sets a value in the configuration database. - **/ - void bmp_cfg_db_set_int(ConfigDb *db, - const gchar *section, - const gchar *key, - gint value); - - /** - * bmp_cfg_db_set_bool: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * @value: Pointer to a boolean containing the data. - * - * Sets a value in the configuration database. - **/ - void bmp_cfg_db_set_bool(ConfigDb *db, - const gchar *section, - const gchar *key, - gboolean value); - - /** - * bmp_cfg_db_set_float: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * @value: Pointer to a floating point integer containing the data. - * - * Sets a value in the configuration database. - **/ - void bmp_cfg_db_set_float(ConfigDb *db, - const gchar *section, - const gchar *key, - gfloat value); - - /** - * bmp_cfg_db_set_double: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * @value: Pointer to a double precision floating point integer containing the data. - * - * Sets a value in the configuration database. - **/ - void bmp_cfg_db_set_double(ConfigDb *db, - const gchar *section, - const gchar *key, - gdouble value); - - /** - * bmp_cfg_db_unset_key: - * @db: A configuration database handle. - * @section: The section of the configuration database to search. - * @key: The name of the field in the configuration database to set. - * - * Removes a value from the configuration database. - **/ - void bmp_cfg_db_unset_key(ConfigDb *db, - const gchar *section, - const gchar *key); - -G_END_DECLS - -#endif /* CONFIGDB_H */ -
--- a/src/libaudacious/Makefile Sat Feb 17 02:30:32 2007 -0800 +++ b/src/libaudacious/Makefile Sat Feb 17 02:32:37 2007 -0800 @@ -20,11 +20,13 @@ -I../intl SOURCES = \ + configdb.c \ beepctrl.c OBJECTS = ${SOURCES:.c=.o} HEADERS = \ + configdb.h \ beepctrl.h include ../../mk/objective.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/libaudacious/configdb.c Sat Feb 17 02:32:37 2007 -0800 @@ -0,0 +1,193 @@ +/* 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. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "configdb.h" + +#include <stdlib.h> +#include <string.h> + +#include <libmcs/mcs.h> + + +#define RCFILE_DEFAULT_SECTION_NAME "audacious" + +static gboolean mcs_initted = FALSE; + +struct _ConfigDb +{ + mcs_handle_t *handle; +}; + + +ConfigDb * +bmp_cfg_db_open() +{ + ConfigDb *db; + + db = g_new(ConfigDb, 1); + + if (!mcs_initted) + { + mcs_init(); + mcs_initted = TRUE; + } + + db->handle = mcs_new(RCFILE_DEFAULT_SECTION_NAME); + + return db; +} + +void +bmp_cfg_db_close(ConfigDb * db) +{ + mcs_destroy(db->handle); + g_free(db); +} + +gboolean +bmp_cfg_db_get_string(ConfigDb * db, + const gchar * section, + const gchar * key, + gchar ** value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + return mcs_get_string(db->handle, section, key, value); +} + +gboolean +bmp_cfg_db_get_int(ConfigDb * db, + const gchar * section, const gchar * key, gint * value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + return mcs_get_int(db->handle, section, key, value); +} + +gboolean +bmp_cfg_db_get_bool(ConfigDb * db, + const gchar * section, + const gchar * key, + gboolean * value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + return mcs_get_bool(db->handle, section, key, value); +} + +gboolean +bmp_cfg_db_get_float(ConfigDb * db, + const gchar * section, + const gchar * key, + gfloat * value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + return mcs_get_float(db->handle, section, key, value); +} + +gboolean +bmp_cfg_db_get_double(ConfigDb * db, + const gchar * section, + const gchar * key, + gdouble * value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + return mcs_get_double(db->handle, section, key, value); +} + +void +bmp_cfg_db_set_string(ConfigDb * db, + const gchar * section, + const gchar * key, + const gchar * value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_set_string(db->handle, section, key, value); +} + +void +bmp_cfg_db_set_int(ConfigDb * db, + const gchar * section, + const gchar * key, + gint value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_set_int(db->handle, section, key, value); +} + +void +bmp_cfg_db_set_bool(ConfigDb * db, + const gchar * section, + const gchar * key, + gboolean value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_set_bool(db->handle, section, key, value); +} + +void +bmp_cfg_db_set_float(ConfigDb * db, + const gchar * section, + const gchar * key, + gfloat value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_set_float(db->handle, section, key, value); +} + +void +bmp_cfg_db_set_double(ConfigDb * db, + const gchar * section, + const gchar * key, + gdouble value) +{ + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_set_double(db->handle, section, key, value); +} + +void +bmp_cfg_db_unset_key(ConfigDb * db, + const gchar * section, + const gchar * key) +{ + g_return_if_fail(db != NULL); + g_return_if_fail(key != NULL); + + if (!section) + section = RCFILE_DEFAULT_SECTION_NAME; + + mcs_unset_key(db->handle, section, key); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/libaudacious/configdb.h Sat Feb 17 02:32:37 2007 -0800 @@ -0,0 +1,198 @@ +#ifndef CONFIGDB_H +#define CONFIGDB_H + +#include <glib.h> + +/** + * ConfigDb: + * + * A configuration database handle, opened with bmp_cfg_db_open(). + **/ +typedef struct _ConfigDb ConfigDb; + + +G_BEGIN_DECLS + + /** + * bmp_cfg_db_open: + * + * Opens the configuration database. + * + * Return value: A configuration database handle. + **/ + ConfigDb *bmp_cfg_db_open(); + + /** + * bmp_cfg_db_close: + * @db: A configuration database handle. + * + * Closes the configuration database. + **/ + void bmp_cfg_db_close(ConfigDb *db); + + /** + * bmp_cfg_db_get_string: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to look up. + * @value: Pointer to a buffer to put the data in. + * + * Searches the configuration database for a value. + * + * Return value: TRUE if successful, FALSE otherwise. + **/ + gboolean bmp_cfg_db_get_string(ConfigDb *db, + const gchar *section, + const gchar *key, + gchar **value); + + /** + * bmp_cfg_db_get_int: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to look up. + * @value: Pointer to an integer to put the data in. + * + * Searches the configuration database for a value. + * + * Return value: TRUE if successful, FALSE otherwise. + **/ + gboolean bmp_cfg_db_get_int(ConfigDb *db, + const gchar *section, + const gchar *key, + gint *value); + + /** + * bmp_cfg_db_get_bool: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to look up. + * @value: Pointer to a boolean to put the data in. + * + * Searches the configuration database for a value. + * + * Return value: TRUE if successful, FALSE otherwise. + **/ + gboolean bmp_cfg_db_get_bool(ConfigDb *db, + const gchar *section, + const gchar *key, + gboolean *value); + + /** + * bmp_cfg_db_get_float: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to look up. + * @value: Pointer to a floating point integer to put the data in. + * + * Searches the configuration database for a value. + * + * Return value: TRUE if successful, FALSE otherwise. + **/ + gboolean bmp_cfg_db_get_float(ConfigDb *db, + const gchar *section, + const gchar *key, + gfloat *value); + + /** + * bmp_cfg_db_get_double: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to look up. + * @value: Pointer to a double-precision floating point integer to put the data in. + * + * Searches the configuration database for a value. + * + * Return value: TRUE if successful, FALSE otherwise. + **/ + gboolean bmp_cfg_db_get_double(ConfigDb *db, + const gchar *section, + const gchar *key, + gdouble *value); + + /** + * bmp_cfg_db_set_string: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * @value: Pointer to a buffer containing the data. + * + * Sets a value in the configuration database. + **/ + void bmp_cfg_db_set_string(ConfigDb *db, + const gchar *section, + const gchar *key, + const gchar *value); + + /** + * bmp_cfg_db_set_int: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * @value: Pointer to an integer containing the data. + * + * Sets a value in the configuration database. + **/ + void bmp_cfg_db_set_int(ConfigDb *db, + const gchar *section, + const gchar *key, + gint value); + + /** + * bmp_cfg_db_set_bool: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * @value: Pointer to a boolean containing the data. + * + * Sets a value in the configuration database. + **/ + void bmp_cfg_db_set_bool(ConfigDb *db, + const gchar *section, + const gchar *key, + gboolean value); + + /** + * bmp_cfg_db_set_float: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * @value: Pointer to a floating point integer containing the data. + * + * Sets a value in the configuration database. + **/ + void bmp_cfg_db_set_float(ConfigDb *db, + const gchar *section, + const gchar *key, + gfloat value); + + /** + * bmp_cfg_db_set_double: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * @value: Pointer to a double precision floating point integer containing the data. + * + * Sets a value in the configuration database. + **/ + void bmp_cfg_db_set_double(ConfigDb *db, + const gchar *section, + const gchar *key, + gdouble value); + + /** + * bmp_cfg_db_unset_key: + * @db: A configuration database handle. + * @section: The section of the configuration database to search. + * @key: The name of the field in the configuration database to set. + * + * Removes a value from the configuration database. + **/ + void bmp_cfg_db_unset_key(ConfigDb *db, + const gchar *section, + const gchar *key); + +G_END_DECLS + +#endif /* CONFIGDB_H */ +