Mercurial > audlegacy
changeset 4405:15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 31 Mar 2008 06:23:31 +0300 |
parents | 7513318719a7 |
children | 98c45d6b0b7f |
files | src/audacious/rcfile.c src/audacious/rcfile.h src/audacious/ui_equalizer.c |
diffstat | 3 files changed, 103 insertions(+), 102 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/rcfile.c Mon Mar 31 06:06:39 2008 +0300 +++ b/src/audacious/rcfile.c Mon Mar 31 06:23:31 2008 +0300 @@ -31,35 +31,35 @@ #include <sys/stat.h> -static RcSection *bmp_rcfile_create_section(RcFile * file, +static RcSection *aud_rcfile_create_section(RcFile * file, const gchar * name); -static RcLine *bmp_rcfile_create_string(RcSection * section, +static RcLine *aud_rcfile_create_string(RcSection * section, const gchar * key, const gchar * value); -static RcSection *bmp_rcfile_find_section(RcFile * file, const gchar * name); -static RcLine *bmp_rcfile_find_string(RcSection * section, const gchar * key); +static RcSection *aud_rcfile_find_section(RcFile * file, const gchar * name); +static RcLine *aud_rcfile_find_string(RcSection * section, const gchar * key); /** - * bmp_rcfile_new: + * aud_rcfile_new: * * #RcFile object factory. * * Return value: A #RcFile object. **/ RcFile * -bmp_rcfile_new(void) +aud_rcfile_new(void) { return g_new0(RcFile, 1); } /** - * bmp_rcfile_free: + * aud_rcfile_free: * @file: A #RcFile object to destroy. * * #RcFile object destructor. **/ void -bmp_rcfile_free(RcFile * file) +aud_rcfile_free(RcFile * file) { RcSection *section; RcLine *line; @@ -91,7 +91,7 @@ } /** - * bmp_rcfile_open: + * aud_rcfile_open: * @filename: Path to rcfile to open. * * Opens an rcfile and returns an #RcFile object representing it. @@ -99,7 +99,7 @@ * Return value: An #RcFile object representing the rcfile given. **/ RcFile * -bmp_rcfile_open(const gchar * filename) +aud_rcfile_open(const gchar * filename) { RcFile *file; @@ -113,7 +113,7 @@ if (!g_file_get_contents(filename, &buffer, NULL, NULL)) return NULL; - file = bmp_rcfile_new(); + file = aud_rcfile_new(); lines = g_strsplit(buffer, "\n", 0); g_free(buffer); i = 0; @@ -121,7 +121,7 @@ if (lines[i][0] == '[') { if ((tmp = strchr(lines[i], ']'))) { *tmp = '\0'; - section = bmp_rcfile_create_section(file, &lines[i][1]); + section = aud_rcfile_create_section(file, &lines[i][1]); } } else if (lines[i][0] != '#' && section) { @@ -129,7 +129,7 @@ gchar **frags; frags = g_strsplit(lines[i], "=", 2); if (strlen(frags[1]) > 0) { - bmp_rcfile_create_string(section, frags[0], frags[1]); + aud_rcfile_create_string(section, frags[0], frags[1]); }; g_strfreev(frags); } @@ -141,7 +141,7 @@ } /** - * bmp_rcfile_write: + * aud_rcfile_write: * @file: A #RcFile object to write to disk. * @filename: A path to write the #RcFile object's data to. * @@ -150,7 +150,7 @@ * Return value: TRUE on success, FALSE otherwise. **/ gboolean -bmp_rcfile_write(RcFile * file, const gchar * filename) +aud_rcfile_write(RcFile * file, const gchar * filename) { FILE *fp; GList *section_list, *line_list; @@ -183,7 +183,7 @@ } /** - * bmp_rcfile_read_string: + * aud_rcfile_read_string: * @file: A #RcFile object to write to disk. * @section: The section of the RcFile to look in. * @key: The name of the identifier to look up. @@ -194,7 +194,7 @@ * Return value: TRUE on success, FALSE otherwise. **/ gboolean -bmp_rcfile_read_string(RcFile * file, const gchar * section, +aud_rcfile_read_string(RcFile * file, const gchar * section, const gchar * key, gchar ** value) { RcSection *sect; @@ -205,16 +205,16 @@ g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(value != NULL, FALSE); - if (!(sect = bmp_rcfile_find_section(file, section))) + if (!(sect = aud_rcfile_find_section(file, section))) return FALSE; - if (!(line = bmp_rcfile_find_string(sect, key))) + if (!(line = aud_rcfile_find_string(sect, key))) return FALSE; *value = g_strdup(line->value); return TRUE; } /** - * bmp_rcfile_read_int: + * aud_rcfile_read_int: * @file: A #RcFile object to write to disk. * @section: The section of the RcFile to look in. * @key: The name of the identifier to look up. @@ -225,7 +225,7 @@ * Return value: TRUE on success, FALSE otherwise. **/ gboolean -bmp_rcfile_read_int(RcFile * file, const gchar * section, +aud_rcfile_read_int(RcFile * file, const gchar * section, const gchar * key, gint * value) { gchar *str; @@ -235,7 +235,7 @@ g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(value != NULL, FALSE); - if (!bmp_rcfile_read_string(file, section, key, &str)) + if (!aud_rcfile_read_string(file, section, key, &str)) return FALSE; *value = atoi(str); g_free(str); @@ -244,7 +244,7 @@ } /** - * bmp_rcfile_read_bool: + * aud_rcfile_read_bool: * @file: A #RcFile object to write to disk. * @section: The section of the RcFile to look in. * @key: The name of the identifier to look up. @@ -255,7 +255,7 @@ * Return value: TRUE on success, FALSE otherwise. **/ gboolean -bmp_rcfile_read_bool(RcFile * file, const gchar * section, +aud_rcfile_read_bool(RcFile * file, const gchar * section, const gchar * key, gboolean * value) { gchar *str; @@ -265,7 +265,7 @@ g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(value != NULL, FALSE); - if (!bmp_rcfile_read_string(file, section, key, &str)) + if (!aud_rcfile_read_string(file, section, key, &str)) return FALSE; if (!strcasecmp(str, "TRUE")) *value = TRUE; @@ -276,7 +276,7 @@ } /** - * bmp_rcfile_read_float: + * aud_rcfile_read_float: * @file: A #RcFile object to write to disk. * @section: The section of the RcFile to look in. * @key: The name of the identifier to look up. @@ -287,7 +287,7 @@ * Return value: TRUE on success, FALSE otherwise. **/ gboolean -bmp_rcfile_read_float(RcFile * file, const gchar * section, +aud_rcfile_read_float(RcFile * file, const gchar * section, const gchar * key, gfloat * value) { gchar *str, *locale; @@ -297,7 +297,7 @@ g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(value != NULL, FALSE); - if (!bmp_rcfile_read_string(file, section, key, &str)) + if (!aud_rcfile_read_string(file, section, key, &str)) return FALSE; locale = g_strdup(setlocale(LC_NUMERIC, NULL)); @@ -311,7 +311,7 @@ } /** - * bmp_rcfile_read_double: + * aud_rcfile_read_double: * @file: A #RcFile object to write to disk. * @section: The section of the RcFile to look in. * @key: The name of the identifier to look up. @@ -322,7 +322,7 @@ * Return value: TRUE on success, FALSE otherwise. **/ gboolean -bmp_rcfile_read_double(RcFile * file, const gchar * section, +aud_rcfile_read_double(RcFile * file, const gchar * section, const gchar * key, gdouble * value) { gchar *str, *locale; @@ -332,7 +332,7 @@ g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(value != NULL, FALSE); - if (!bmp_rcfile_read_string(file, section, key, &str)) + if (!aud_rcfile_read_string(file, section, key, &str)) return FALSE; locale = g_strdup(setlocale(LC_NUMERIC, NULL)); @@ -346,7 +346,7 @@ } /** - * bmp_rcfile_write_string: + * aud_rcfile_write_string: * @file: A #RcFile object to write to disk. * @section: The section of the RcFile to set the key in. * @key: The name of the identifier to set. @@ -355,7 +355,7 @@ * Sets a value in an RcFile for %key. **/ void -bmp_rcfile_write_string(RcFile * file, const gchar * section, +aud_rcfile_write_string(RcFile * file, const gchar * section, const gchar * key, const gchar * value) { RcSection *sect; @@ -366,19 +366,19 @@ g_return_if_fail(key != NULL); g_return_if_fail(value != NULL); - sect = bmp_rcfile_find_section(file, section); + sect = aud_rcfile_find_section(file, section); if (!sect) - sect = bmp_rcfile_create_section(file, section); - if ((line = bmp_rcfile_find_string(sect, key))) { + sect = aud_rcfile_create_section(file, section); + if ((line = aud_rcfile_find_string(sect, key))) { g_free(line->value); line->value = g_strstrip(g_strdup(value)); } else - bmp_rcfile_create_string(sect, key, value); + aud_rcfile_create_string(sect, key, value); } /** - * bmp_rcfile_write_int: + * aud_rcfile_write_int: * @file: A #RcFile object to write to disk. * @section: The section of the RcFile to set the key in. * @key: The name of the identifier to set. @@ -387,7 +387,7 @@ * Sets a value in an RcFile for %key. **/ void -bmp_rcfile_write_int(RcFile * file, const gchar * section, +aud_rcfile_write_int(RcFile * file, const gchar * section, const gchar * key, gint value) { gchar *strvalue; @@ -397,12 +397,12 @@ g_return_if_fail(key != NULL); strvalue = g_strdup_printf("%d", value); - bmp_rcfile_write_string(file, section, key, strvalue); + aud_rcfile_write_string(file, section, key, strvalue); g_free(strvalue); } /** - * bmp_rcfile_write_boolean: + * aud_rcfile_write_boolean: * @file: A #RcFile object to write to disk. * @section: The section of the RcFile to set the key in. * @key: The name of the identifier to set. @@ -411,7 +411,7 @@ * Sets a value in an RcFile for %key. **/ void -bmp_rcfile_write_boolean(RcFile * file, const gchar * section, +aud_rcfile_write_boolean(RcFile * file, const gchar * section, const gchar * key, gboolean value) { g_return_if_fail(file != NULL); @@ -419,13 +419,13 @@ g_return_if_fail(key != NULL); if (value) - bmp_rcfile_write_string(file, section, key, "TRUE"); + aud_rcfile_write_string(file, section, key, "TRUE"); else - bmp_rcfile_write_string(file, section, key, "FALSE"); + aud_rcfile_write_string(file, section, key, "FALSE"); } /** - * bmp_rcfile_write_float: + * aud_rcfile_write_float: * @file: A #RcFile object to write to disk. * @section: The section of the RcFile to set the key in. * @key: The name of the identifier to set. @@ -434,7 +434,7 @@ * Sets a value in an RcFile for %key. **/ void -bmp_rcfile_write_float(RcFile * file, const gchar * section, +aud_rcfile_write_float(RcFile * file, const gchar * section, const gchar * key, gfloat value) { gchar *strvalue, *locale; @@ -447,13 +447,13 @@ setlocale(LC_NUMERIC, "C"); strvalue = g_strdup_printf("%g", value); setlocale(LC_NUMERIC, locale); - bmp_rcfile_write_string(file, section, key, strvalue); + aud_rcfile_write_string(file, section, key, strvalue); g_free(locale); g_free(strvalue); } /** - * bmp_rcfile_write_double: + * aud_rcfile_write_double: * @file: A #RcFile object to write to disk. * @section: The section of the RcFile to set the key in. * @key: The name of the identifier to set. @@ -462,7 +462,7 @@ * Sets a value in an RcFile for %key. **/ void -bmp_rcfile_write_double(RcFile * file, const gchar * section, +aud_rcfile_write_double(RcFile * file, const gchar * section, const gchar * key, gdouble value) { gchar *strvalue, *locale; @@ -475,13 +475,13 @@ setlocale(LC_NUMERIC, "C"); strvalue = g_strdup_printf("%g", value); setlocale(LC_NUMERIC, locale); - bmp_rcfile_write_string(file, section, key, strvalue); + aud_rcfile_write_string(file, section, key, strvalue); g_free(locale); g_free(strvalue); } /** - * bmp_rcfile_remove_key: + * aud_rcfile_remove_key: * @file: A #RcFile object to write to disk. * @section: The section of the RcFile to set the key in. * @key: The name of the identifier to remove. @@ -489,7 +489,7 @@ * Removes %key from an #RcFile object. **/ void -bmp_rcfile_remove_key(RcFile * file, const gchar * section, const gchar * key) +aud_rcfile_remove_key(RcFile * file, const gchar * section, const gchar * key) { RcSection *sect; RcLine *line; @@ -498,8 +498,8 @@ g_return_if_fail(section != NULL); g_return_if_fail(key != NULL); - if ((sect = bmp_rcfile_find_section(file, section)) != NULL) { - if ((line = bmp_rcfile_find_string(sect, key)) != NULL) { + if ((sect = aud_rcfile_find_section(file, section)) != NULL) { + if ((line = aud_rcfile_find_string(sect, key)) != NULL) { g_free(line->key); g_free(line->value); g_free(line); @@ -509,7 +509,7 @@ } static RcSection * -bmp_rcfile_create_section(RcFile * file, const gchar * name) +aud_rcfile_create_section(RcFile * file, const gchar * name) { RcSection *section; @@ -521,7 +521,7 @@ } static RcLine * -bmp_rcfile_create_string(RcSection * section, +aud_rcfile_create_string(RcSection * section, const gchar * key, const gchar * value) { RcLine *line; @@ -535,7 +535,7 @@ } static RcSection * -bmp_rcfile_find_section(RcFile * file, const gchar * name) +aud_rcfile_find_section(RcFile * file, const gchar * name) { RcSection *section; GList *list; @@ -551,7 +551,7 @@ } static RcLine * -bmp_rcfile_find_string(RcSection * section, const gchar * key) +aud_rcfile_find_string(RcSection * section, const gchar * key) { RcLine *line; GList *list;
--- a/src/audacious/rcfile.h Mon Mar 31 06:06:39 2008 +0300 +++ b/src/audacious/rcfile.h Mon Mar 31 06:23:31 2008 +0300 @@ -19,11 +19,13 @@ * The Audacious team does not consider modular code linking to * Audacious or using our public API to be a derived work. */ -#ifndef RCFILE_H -#define RCFILE_H +#ifndef __AUDACIOUS_RCFILE_H__ +#define __AUDACIOUS_RCFILE_H__ #include <glib.h> +G_BEGIN_DECLS + /** * RcLine: * @key: A key for the key->value mapping. @@ -58,39 +60,38 @@ GList *sections; } RcFile; -G_BEGIN_DECLS -RcFile *bmp_rcfile_new(void); -void bmp_rcfile_free(RcFile * file); +RcFile *aud_rcfile_new(void); +void aud_rcfile_free(RcFile * file); -RcFile *bmp_rcfile_open(const gchar * filename); -gboolean bmp_rcfile_write(RcFile * file, const gchar * filename); +RcFile *aud_rcfile_open(const gchar * filename); +gboolean aud_rcfile_write(RcFile * file, const gchar * filename); -gboolean bmp_rcfile_read_string(RcFile * file, const gchar * section, +gboolean aud_rcfile_read_string(RcFile * file, const gchar * section, const gchar * key, gchar ** value); -gboolean bmp_rcfile_read_int(RcFile * file, const gchar * section, +gboolean aud_rcfile_read_int(RcFile * file, const gchar * section, const gchar * key, gint * value); -gboolean bmp_rcfile_read_bool(RcFile * file, const gchar * section, +gboolean aud_rcfile_read_bool(RcFile * file, const gchar * section, const gchar * key, gboolean * value); -gboolean bmp_rcfile_read_float(RcFile * file, const gchar * section, +gboolean aud_rcfile_read_float(RcFile * file, const gchar * section, const gchar * key, gfloat * value); -gboolean bmp_rcfile_read_double(RcFile * file, const gchar * section, +gboolean aud_rcfile_read_double(RcFile * file, const gchar * section, const gchar * key, gdouble * value); -void bmp_rcfile_write_string(RcFile * file, const gchar * section, +void aud_rcfile_write_string(RcFile * file, const gchar * section, const gchar * key, const gchar * value); -void bmp_rcfile_write_int(RcFile * file, const gchar * section, +void aud_rcfile_write_int(RcFile * file, const gchar * section, const gchar * key, gint value); -void bmp_rcfile_write_boolean(RcFile * file, const gchar * section, +void aud_rcfile_write_boolean(RcFile * file, const gchar * section, const gchar * key, gboolean value); -void bmp_rcfile_write_float(RcFile * file, const gchar * section, +void aud_rcfile_write_float(RcFile * file, const gchar * section, const gchar * key, gfloat value); -void bmp_rcfile_write_double(RcFile * file, const gchar * section, +void aud_rcfile_write_double(RcFile * file, const gchar * section, const gchar * key, gdouble value); -void bmp_rcfile_remove_key(RcFile * file, const gchar * section, +void aud_rcfile_remove_key(RcFile * file, const gchar * section, const gchar * key); G_END_DECLS -#endif // RCFILE_H +#endif /* __AUDACIOUS_RCFILE_H__ */
--- a/src/audacious/ui_equalizer.c Mon Mar 31 06:06:39 2008 +0300 +++ b/src/audacious/ui_equalizer.c Mon Mar 31 06:23:31 2008 +0300 @@ -325,11 +325,11 @@ filename = g_build_filename(bmp_paths[BMP_PATH_USER_DIR], basename, NULL); - if ((rcfile = bmp_rcfile_open(filename)) == NULL) { + if ((rcfile = aud_rcfile_open(filename)) == NULL) { g_free(filename); // DATA_DIR = "{prefix}/share/audacious" ; example is "/usr/share/audacious" filename = g_build_filename(DATA_DIR, basename, NULL); - if ((rcfile = bmp_rcfile_open(filename)) == NULL) { + if ((rcfile = aud_rcfile_open(filename)) == NULL) { g_free(filename); return NULL; } @@ -343,14 +343,14 @@ gchar section[21]; g_snprintf(section, sizeof(section), "Preset%d", p++); - if (bmp_rcfile_read_string(rcfile, "Presets", section, &name)) { + if (aud_rcfile_read_string(rcfile, "Presets", section, &name)) { preset = g_new0(EqualizerPreset, 1); preset->name = name; - bmp_rcfile_read_float(rcfile, name, "Preamp", &preset->preamp); + aud_rcfile_read_float(rcfile, name, "Preamp", &preset->preamp); for (i = 0; i < 10; i++) { gchar band[7]; g_snprintf(band, sizeof(band), "Band%d", i); - bmp_rcfile_read_float(rcfile, name, band, &preset->bands[i]); + aud_rcfile_read_float(rcfile, name, band, &preset->bands[i]); } list = g_list_prepend(list, preset); } @@ -358,7 +358,7 @@ break; } list = g_list_reverse(list); - bmp_rcfile_free(rcfile); + aud_rcfile_free(rcfile); return list; } @@ -643,26 +643,26 @@ RcFile *rcfile; GList *node; - rcfile = bmp_rcfile_new(); + rcfile = aud_rcfile_new(); p = 0; for (node = list; node; node = g_list_next(node)) { preset = node->data; tmp = g_strdup_printf("Preset%d", p++); - bmp_rcfile_write_string(rcfile, "Presets", tmp, preset->name); + aud_rcfile_write_string(rcfile, "Presets", tmp, preset->name); g_free(tmp); - bmp_rcfile_write_float(rcfile, preset->name, "Preamp", + aud_rcfile_write_float(rcfile, preset->name, "Preamp", preset->preamp); for (i = 0; i < 10; i++) { tmp = g_strdup_printf("Band%d\n", i); - bmp_rcfile_write_float(rcfile, preset->name, tmp, + aud_rcfile_write_float(rcfile, preset->name, tmp, preset->bands[i]); g_free(tmp); } } filename = g_build_filename(bmp_paths[BMP_PATH_USER_DIR], basename, NULL); - bmp_rcfile_write(rcfile, filename); - bmp_rcfile_free(rcfile); + aud_rcfile_write(rcfile, filename); + aud_rcfile_free(rcfile); g_free(filename); } @@ -858,12 +858,12 @@ gfloat val; gint i; - if (bmp_rcfile_read_float(rcfile, "Equalizer preset", "Preamp", &val)) + if (aud_rcfile_read_float(rcfile, "Equalizer preset", "Preamp", &val)) ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, val); for (i = 0; i < 10; i++) { gchar tmp[7]; g_snprintf(tmp, sizeof(tmp), "Band%d", i); - if (bmp_rcfile_read_float(rcfile, "Equalizer preset", tmp, &val)) + if (aud_rcfile_read_float(rcfile, "Equalizer preset", tmp, &val)) ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], val); } equalizerwin_eq_changed(); @@ -1018,9 +1018,9 @@ { RcFile *rcfile; - if ((rcfile = bmp_rcfile_open(filename)) != NULL) { + if ((rcfile = aud_rcfile_open(filename)) != NULL) { equalizerwin_read_bmp_preset(rcfile); - bmp_rcfile_free(rcfile); + aud_rcfile_free(rcfile); } } @@ -1078,19 +1078,19 @@ RcFile *rcfile; gint i; - rcfile = bmp_rcfile_new(); - bmp_rcfile_write_float(rcfile, "Equalizer preset", "Preamp", + rcfile = aud_rcfile_new(); + aud_rcfile_write_float(rcfile, "Equalizer preset", "Preamp", ui_skinned_equalizer_slider_get_position(equalizerwin_preamp)); for (i = 0; i < 10; i++) { gchar tmp[7]; g_snprintf(tmp, sizeof(tmp), "Band%d", i); - bmp_rcfile_write_float(rcfile, "Equalizer preset", tmp, + aud_rcfile_write_float(rcfile, "Equalizer preset", tmp, ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i])); } - bmp_rcfile_write(rcfile, filename); - bmp_rcfile_free(rcfile); + aud_rcfile_write(rcfile, filename); + aud_rcfile_free(rcfile); } static void @@ -1244,10 +1244,10 @@ /* First try to find a per file preset file */ if (strlen(cfg.eqpreset_extension) > 0 && - (rcfile = bmp_rcfile_open(presetfilename)) != NULL) { + (rcfile = aud_rcfile_open(presetfilename)) != NULL) { g_free(presetfilename); equalizerwin_read_bmp_preset(rcfile); - bmp_rcfile_free(rcfile); + aud_rcfile_free(rcfile); return; } @@ -1260,9 +1260,9 @@ /* Try to find a per directory preset file */ if (strlen(cfg.eqpreset_default_file) > 0 && - (rcfile = bmp_rcfile_open(presetfilename)) != NULL) { + (rcfile = aud_rcfile_open(presetfilename)) != NULL) { equalizerwin_read_bmp_preset(rcfile); - bmp_rcfile_free(rcfile); + aud_rcfile_free(rcfile); } else if (!equalizerwin_load_preset (equalizer_auto_presets, g_basename(filename))) {