Mercurial > audlegacy
changeset 2426:193bae6b2c8f trunk
[svn] - removed xmms_ prefix from formatter
- moved formatter from libaudacious to audacious
author | mf0102 |
---|---|
date | Sat, 27 Jan 2007 06:09:45 -0800 |
parents | 5b1b26db3a37 |
children | 64948ea58c53 |
files | ChangeLog src/audacious/Makefile src/audacious/formatter.c src/audacious/formatter.h src/libaudacious/Makefile src/libaudacious/formatter.c src/libaudacious/formatter.h |
diffstat | 7 files changed, 179 insertions(+), 171 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Jan 27 05:01:55 2007 -0800 +++ b/ChangeLog Sat Jan 27 06:09:45 2007 -0800 @@ -1,3 +1,11 @@ +2007-01-27 13:01:55 +0000 William Pitcock <nenolod@sacredspiral.co.uk> + revision [3860] + - fix an error + + trunk/src/audacious/util.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + + 2007-01-27 12:51:25 +0000 William Pitcock <nenolod@sacredspiral.co.uk> revision [3858] - vfs_get_file_contents() implementation.
--- a/src/audacious/Makefile Sat Jan 27 05:01:55 2007 -0800 +++ b/src/audacious/Makefile Sat Jan 27 06:09:45 2007 -0800 @@ -28,6 +28,7 @@ -I../intl HEADERS = \ + formatter.h \ i18n.h \ input.h \ hook.h \ @@ -51,6 +52,7 @@ dock.c \ effect.c \ fft.c \ + formatter.c \ general.c \ genevent.c \ glade.c \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/formatter.c Sat Jan 27 06:09:45 2007 -0800 @@ -0,0 +1,141 @@ +/* Audacious + * Copyright (C) 2005-2007 Audacious team + * + * XMMS - Cross-platform multimedia player + * Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas, + * Thomas Nilsson and 4Front Technologies + * Copyright (C) 1999-2003 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; under version 2 of the License. + * + * 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 <glib.h> +#include <string.h> +#include "formatter.h" + +/** + * formatter_new: + * + * Factory for #Formatter objects. + * + * Return value: A #Formatter object. + **/ +Formatter * +formatter_new(void) +{ + Formatter *formatter = g_new0(Formatter, 1); + + formatter_associate(formatter, '%', "%"); + return formatter; +} + +/** + * formatter_destroy: + * @formatter: A #Formatter object to destroy. + * + * Destroys #Formatter objects. + **/ +void +formatter_destroy(Formatter * formatter) +{ + int i; + + for (i = 0; i < 256; i++) + if (formatter->values[i]) + g_free(formatter->values[i]); + g_free(formatter); +} + +/** + * formatter_associate: + * @formatter: A #Formatter object to use. + * @id: The character to use for replacement. + * @value: The value to replace with. + * + * Adds a id->replacement set to the formatter's stack. + **/ +void +formatter_associate(Formatter * formatter, guchar id, char *value) +{ + formatter_dissociate(formatter, id); + formatter->values[id] = g_strdup(value); +} + +/** + * formatter_dissociate: + * @formatter: A #Formatter object to use. + * @id: The id to remove the id->replacement mapping for. + * + * Removes an id->replacement mapping from the formatter's stack. + **/ +void +formatter_dissociate(Formatter * formatter, guchar id) +{ + if (formatter->values[id]) + g_free(formatter->values[id]); + formatter->values[id] = 0; +} + +/** + * formatter_format: + * @formatter: A #Formatter object to use. + * @format: A string to format. + * + * Performs id->replacement substitution on a string. + * + * Returns: The formatted string. + **/ +gchar * +formatter_format(Formatter * formatter, char *format) +{ + char *p, *q, *buffer; + int len; + + for (p = format, len = 0; *p; p++) + if (*p == '%') { + if (formatter->values[(int) *++p]) + len += strlen(formatter->values[(int) *p]); + else if (!*p) { + len += 1; + p--; + } + else + len += 2; + } + else + len++; + buffer = g_malloc(len + 1); + for (p = format, q = buffer; *p; p++) + if (*p == '%') { + if (formatter->values[(int) *++p]) { + strcpy(q, formatter->values[(int) *p]); + q += strlen(q); + } + else { + *q++ = '%'; + if (*p != '\0') + *q++ = *p; + else + p--; + } + } + else + *q++ = *p; + *q = 0; + return buffer; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/formatter.h Sat Jan 27 06:09:45 2007 -0800 @@ -0,0 +1,28 @@ +#ifndef XMMS_FORMATTER_H +#define XMMS_FORMATTER_H + +#include <glib.h> + +/** + * Formatter: + * @values: The stack of values used for replacement. + * + * Formatter objects contain id->replacement mapping tables. + **/ +typedef struct { + gchar *values[256]; +} Formatter; + + +G_BEGIN_DECLS + +Formatter *formatter_new(void); +void formatter_destroy(Formatter * formatter); +void formatter_associate(Formatter * formatter, guchar id, + gchar * value); +void formatter_dissociate(Formatter * formatter, guchar id); +gchar *formatter_format(Formatter * formatter, gchar * format); + +G_END_DECLS + +#endif
--- a/src/libaudacious/Makefile Sat Jan 27 05:01:55 2007 -0800 +++ b/src/libaudacious/Makefile Sat Jan 27 06:09:45 2007 -0800 @@ -25,7 +25,6 @@ $(CONF_SRC) \ rcfile.c \ beepctrl.c \ - formatter.c \ titlestring.c \ xconvert.c @@ -35,7 +34,6 @@ rcfile.h \ configdb.h \ beepctrl.h \ - formatter.h \ titlestring.h \ xconvert.h
--- a/src/libaudacious/formatter.c Sat Jan 27 05:01:55 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -/* Audacious - * Copyright (C) 2005-2007 Audacious team - * - * XMMS - Cross-platform multimedia player - * Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas, - * Thomas Nilsson and 4Front Technologies - * Copyright (C) 1999-2003 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; under version 2 of the License. - * - * 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 <glib.h> -#include <string.h> -#include "formatter.h" - -/** - * xmms_formatter_new: - * - * Factory for #Formatter objects. - * - * Return value: A #Formatter object. - **/ -Formatter * -xmms_formatter_new(void) -{ - Formatter *formatter = g_new0(Formatter, 1); - - xmms_formatter_associate(formatter, '%', "%"); - return formatter; -} - -/** - * xmms_formatter_destroy: - * @formatter: A #Formatter object to destroy. - * - * Destroys #Formatter objects. - **/ -void -xmms_formatter_destroy(Formatter * formatter) -{ - int i; - - for (i = 0; i < 256; i++) - if (formatter->values[i]) - g_free(formatter->values[i]); - g_free(formatter); -} - -/** - * xmms_formatter_associate: - * @formatter: A #Formatter object to use. - * @id: The character to use for replacement. - * @value: The value to replace with. - * - * Adds a id->replacement set to the formatter's stack. - **/ -void -xmms_formatter_associate(Formatter * formatter, guchar id, char *value) -{ - xmms_formatter_dissociate(formatter, id); - formatter->values[id] = g_strdup(value); -} - -/** - * xmms_formatter_dissociate: - * @formatter: A #Formatter object to use. - * @id: The id to remove the id->replacement mapping for. - * - * Removes an id->replacement mapping from the formatter's stack. - **/ -void -xmms_formatter_dissociate(Formatter * formatter, guchar id) -{ - if (formatter->values[id]) - g_free(formatter->values[id]); - formatter->values[id] = 0; -} - -/** - * xmms_formatter_format: - * @formatter: A #Formatter object to use. - * @format: A string to format. - * - * Performs id->replacement substitution on a string. - * - * Returns: The formatted string. - **/ -gchar * -xmms_formatter_format(Formatter * formatter, char *format) -{ - char *p, *q, *buffer; - int len; - - for (p = format, len = 0; *p; p++) - if (*p == '%') { - if (formatter->values[(int) *++p]) - len += strlen(formatter->values[(int) *p]); - else if (!*p) { - len += 1; - p--; - } - else - len += 2; - } - else - len++; - buffer = g_malloc(len + 1); - for (p = format, q = buffer; *p; p++) - if (*p == '%') { - if (formatter->values[(int) *++p]) { - strcpy(q, formatter->values[(int) *p]); - q += strlen(q); - } - else { - *q++ = '%'; - if (*p != '\0') - *q++ = *p; - else - p--; - } - } - else - *q++ = *p; - *q = 0; - return buffer; -}
--- a/src/libaudacious/formatter.h Sat Jan 27 05:01:55 2007 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -#ifndef XMMS_FORMATTER_H -#define XMMS_FORMATTER_H - -#include <glib.h> - -/** - * Formatter: - * @values: The stack of values used for replacement. - * - * Formatter objects contain id->replacement mapping tables. - **/ -typedef struct { - gchar *values[256]; -} Formatter; - - -G_BEGIN_DECLS - -Formatter *xmms_formatter_new(void); -void xmms_formatter_destroy(Formatter * formatter); -void xmms_formatter_associate(Formatter * formatter, guchar id, - gchar * value); -void xmms_formatter_dissociate(Formatter * formatter, guchar id); -gchar *xmms_formatter_format(Formatter * formatter, gchar * format); - -G_END_DECLS - -#endif