changeset 2373:ad1d7687814c trunk

[svn] made strings.h for existing strings.c, cleanups
author mf0102
date Sat, 20 Jan 2007 04:48:41 -0800
parents d68e6f302855
children 6c5d4d28cc6b
files ChangeLog src/audacious/input.c src/audacious/output.c src/audacious/playlist.c src/audacious/pluginenum.c src/audacious/signals.c src/audacious/strings.c src/audacious/strings.h src/audacious/ui_main.c src/audacious/ui_playlist.c src/audacious/ui_preferences.c src/audacious/util.c src/audacious/util.h src/audacious/widgets/textbox.c
diffstat 14 files changed, 124 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jan 20 03:39:28 2007 -0800
+++ b/ChangeLog	Sat Jan 20 04:48:41 2007 -0800
@@ -1,3 +1,11 @@
+2007-01-20 11:39:28 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [3754]
+  - that should have been in vfs_fread
+  
+  trunk/src/audacious/vfs_buffered_file.c |    9 ++++++++-
+  1 file changed, 8 insertions(+), 1 deletion(-)
+
+
 2007-01-20 11:07:30 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [3752]
   - possible fix for VFSBufferedFile crash
--- a/src/audacious/input.c	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/input.c	Sat Jan 20 04:48:41 2007 -0800
@@ -35,7 +35,7 @@
 #include "main.h"
 #include "ui_main.h"
 #include "output.h"
-#include "util.h"
+#include "strings.h"
 #include "visualization.h"
 #include "playback.h"
 #include "widgets/widgetcore.h"
--- a/src/audacious/output.c	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/output.c	Sat Jan 20 04:48:41 2007 -0800
@@ -32,7 +32,6 @@
 #include "playback.h"
 
 #include "playlist.h"
-#include "libaudacious/util.h"
 
 OutputPluginData op_data = {
     NULL,
@@ -93,39 +92,37 @@
     if (playing == TRUE)
     {
         guint time, pos;
-	PlaylistEntry *entry;
+        PlaylistEntry *entry;
 
-	/* don't stop yet, get the seek time and playlist position first */
+        /* don't stop yet, get the seek time and playlist position first */
         pos = playlist_get_position(playlist_get_active());
         time = op->output_time();
 
-	/* reset the audio system */
+        /* reset the audio system */
         mainwin_stop_pushed();
         op->close_audio();
 
-	g_usleep(300000);
+        g_usleep(300000);
 
-	/* wait for the playback thread to come online */
+        /* wait for the playback thread to come online */
         while (playback_get_playing())
             g_message("waiting for audio system shutdown...");
 
-	/* wait for the playback thread to come online */
+        /* wait for the playback thread to come online */
         playlist_set_position(playlist_get_active(), pos);
-	entry = playlist_get_entry_to_play(playlist_get_active());
+        entry = playlist_get_entry_to_play(playlist_get_active());
         playback_play_file(entry);
 
-	while (!playback_get_playing())
-	{
-	    gtk_main_iteration();
-            g_message("waiting for audio system startup...");
-	}
+        while (!playback_get_playing())
+        {
+            gtk_main_iteration();
+                g_message("waiting for audio system startup...");
+        }
 
-	/* and signal a reseek */
+        /* and signal a reseek */
         if (playlist_get_current_length(playlist_get_active()) > -1 &&
             time <= (playlist_get_current_length(playlist_get_active())))
-	{
             playback_seek(time / 1000);
-        }
     }
 }
 
@@ -186,8 +183,8 @@
 
     for (i = 0; i < 10; ++i)
     {
-	set_gain(i, 0, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]);
-	set_gain(i, 1, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]);
+    set_gain(i, 0, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]);
+    set_gain(i, 1, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]);
     }
 }
 
@@ -233,18 +230,18 @@
 
     /* Is our output port already open? */
     if ((op_state.rate != 0 && op_state.nch != 0) &&
-	(op_state.rate == rate && op_state.nch == nch && op_state.fmt == fmt))
+    (op_state.rate == rate && op_state.nch == nch && op_state.fmt == fmt))
     {
-	/* Yes, and it's the correct sampling rate. Reset the counter and go. */
-	op->flush(0);
+    /* Yes, and it's the correct sampling rate. Reset the counter and go. */
+    op->flush(0);
         return 1;
     }
     else if (op_state.rate != 0 && op_state.nch != 0)
-	op->close_audio();
+    op->close_audio();
 
     ret = op->open_audio(fmt, rate, nch);
 
-    if (ret == 1)			 /* Success? */
+    if (ret == 1)            /* Success? */
     {
         op_state.fmt = fmt;
         op_state.rate = rate;
@@ -275,7 +272,7 @@
      * not requested a stop.  --nenolod
      */
     if (ip_data.stop == FALSE && 
-	(playlist_get_position_nolock(playlist_get_active()) < playlist_get_length_nolock(playlist_get_active()) - 1))
+    (playlist_get_position_nolock(playlist_get_active()) < playlist_get_length_nolock(playlist_get_active()) - 1))
         return;
 
     /* Sanity check. */
@@ -349,58 +346,59 @@
     OutputPlugin *op = get_current_output_plugin();
     int writeoffs;
 
-    if (!caneq && cfg.equalizer_active) {    /* wrong byte order         */
-        byteswap(length, ptr);               /*  so convert              */
+    if (!caneq && cfg.equalizer_active) {    /* wrong byte order */
+        byteswap(length, ptr);               /* so convert */
         ++swapped;
         ++caneq;
-    }                                        /*  can eq now, mark swapd  */
-    else if (caneq && !cfg.equalizer_active) /* right order but no eq    */
-        caneq = 0;                           /*  so don't eq             */
+    }                                        /* can eq now, mark swapd */
+    else if (caneq && !cfg.equalizer_active) /* right order but no eq */
+        caneq = 0;                           /* so don't eq */
 
-    if (caneq) {                /* if eq enab               */
-        if (!init) {            /*  if first run            */
-            init_iir();         /*   then init eq           */
+    if (caneq) {                /* if eq enab */
+        if (!init) {            /* if first run */
+            init_iir();         /* then init eq */
             ++init;
         }
 
         iir(&ptr, length, nch);
 
-        if (swapped)               /* if was swapped          */
-            byteswap(length, ptr); /*  swap back for output   */
+        if (swapped)               /* if was swapped */
+            byteswap(length, ptr); /* swap back for output */
     }                           
 
     /* do vis plugin(s) */
     input_add_vis_pcm(time, fmt, nch, length, ptr);
 
     writeoffs = 0;
-    while (writeoffs < length) {
-	int writable = length - writeoffs;
+    while (writeoffs < length)
+    {
+        int writable = length - writeoffs;
 
-	if (writable > 2048)
-	    writable = 2048;
+        if (writable > 2048)
+            writable = 2048;
 
-        if (writable == 0)
-	    return;
+            if (writable == 0)
+            return;
 
-	while (op->buffer_free() < writable) { /* wait output buf            */
-	    if (going && !*going)              /*   thread stopped?          */
-		return;                        /*     so finish              */
+        while (op->buffer_free() < writable) { /* wait output buf */
+            if (going && !*going)              /* thread stopped? */
+                return;                        /* so finish */
 
-            if (ip_data.stop)                  /* has a stop been requested? */
-	        return;                        /*     yes, so finish         */
+                if (ip_data.stop)              /* has a stop been requested? */
+                return;                        /* yes, so finish */
 
-	    g_usleep(10000);                   /*   else sleep for retry     */
-	}
+                g_usleep(10000);               /* else sleep for retry */
+        }
 
-	if (ip_data.stop)
-	    return;
+        if (ip_data.stop)
+            return;
 
-	if (going && !*going)                  /*   thread stopped?          */
-	    return;                            /*     so finish              */
+        if (going && !*going)                  /* thread stopped? */
+            return;                            /* so finish */
 
-	/* do output */
-	op->write_audio(((guint8 *) ptr) + writeoffs, writable);
+        /* do output */
+        op->write_audio(((guint8 *) ptr) + writeoffs, writable);
 
-	writeoffs += writable;
+        writeoffs += writable;
     }
 }
--- a/src/audacious/playlist.c	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/playlist.c	Sat Jan 20 04:48:41 2007 -0800
@@ -62,7 +62,7 @@
 #include "playlist_container.h"
 #include "playlist_manager.h"
 #include "ui_playlist.h"
-#include "util.h"
+#include "strings.h"
 #include "ui_fileinfo.h"
 
 #include "debug.h"
--- a/src/audacious/pluginenum.c	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/pluginenum.c	Sat Jan 20 04:48:41 2007 -0800
@@ -41,6 +41,7 @@
 #include "ui_main.h"
 #include "playback.h"
 #include "playlist.h"
+#include "strings.h"
 #include "util.h"
 
 #include "effect.h"
--- a/src/audacious/signals.c	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/signals.c	Sat Jan 20 04:48:41 2007 -0800
@@ -58,7 +58,7 @@
         return NULL;
     }
 
-    return old_action.sa_handler;    
+    return old_action.sa_handler;
 }
 
 /* 
--- a/src/audacious/strings.c	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/strings.c	Sat Jan 20 04:48:41 2007 -0800
@@ -22,41 +22,13 @@
  *  02110-1301, USA.
  */
 
-#define WEIRD_UTF_16_PLAYLIST_ENCODING
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
+#include "strings.h"
 
-#define NEED_GLADE
-#include "util.h"
-
-#include <glib.h>
 #include <glib/gi18n.h>
-#include <glade/glade.h>
-#include <gtk/gtk.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 
-#include "platform/smartinclude.h"
-#include <gdk/gdkkeysyms.h>
-#include <X11/Xlib.h>
-//#include <sys/ipc.h>
-#include <unistd.h>
-#include <errno.h>
-
-#ifdef HAVE_FTS_H
-#  include <fts.h>
-#endif
-
-#include "glade.h"
-#include "input.h"
 #include "main.h"
-#include "playback.h"
-#include "playlist.h"
-#include "ui_playlist.h"
 
 #ifdef USE_CHARDET
     #include "../libguess/libguess.h"
@@ -275,7 +247,8 @@
 }
 
 gchar *chardet_to_utf8(const gchar *str, gssize len,
-                       gsize *arg_bytes_read, gsize *arg_bytes_write, GError **arg_error)
+                       gsize *arg_bytes_read, gsize *arg_bytes_write,
+					   GError **arg_error)
 {
 #ifdef USE_CHARDET
 	char  *det = NULL, *encoding = NULL;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/strings.h	Sat Jan 20 04:48:41 2007 -0800
@@ -0,0 +1,52 @@
+/*  Audacious
+ *  Copyright (C) 2005-2007  Audacious development team.
+ *
+ *  BMP - Cross-platform multimedia player
+ *  Copyright (C) 2003-2004  BMP development team.
+ *
+ *  Based on XMMS:
+ *  Copyright (C) 1998-2003  XMMS development team.
+ *
+ *  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.
+ */
+
+#ifndef STRINGS_H
+#define STRINGS_H
+
+#include <glib.h>
+
+gchar *escape_shell_chars(const gchar * string);
+
+gchar *str_append(gchar * str, const gchar * add_str);
+gchar *str_replace(gchar * str, gchar * new_str);
+void str_replace_in(gchar ** str, gchar * new_str);
+
+gboolean str_has_prefix_nocase(const gchar * str, const gchar * prefix);
+gboolean str_has_suffix_nocase(const gchar * str, const gchar * suffix);
+gboolean str_has_suffixes_nocase(const gchar * str, gchar * const *suffixes);
+
+gchar *str_to_utf8_fallback(const gchar * str);
+gchar *filename_to_utf8(const gchar * filename);
+gchar *str_to_utf8(const gchar * str);
+
+const gchar *str_skip_chars(const gchar * str, const gchar * chars);
+
+gchar *convert_title_text(gchar * text);
+
+gchar *chardet_to_utf8(const gchar *str, gssize len,
+                       gsize *arg_bytes_read, gsize *arg_bytes_write,
+                       GError **arg_error);
+
+#endif
--- a/src/audacious/ui_main.c	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/ui_main.c	Sat Jan 20 04:48:41 2007 -0800
@@ -76,6 +76,7 @@
 #include "playback.h"
 #include "playlist.h"
 #include "libaudacious/urldecode.h"
+#include "strings.h"
 #include "util.h"
 #include "visualization.h"
 #include "libaudacious/configdb.h"
--- a/src/audacious/ui_playlist.c	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/ui_playlist.c	Sat Jan 20 04:48:41 2007 -0800
@@ -51,7 +51,7 @@
 #include "playlist.h"
 #include "playlist_container.h"
 #include "playlist_manager.h"
-#include "util.h"
+#include "strings.h"
 
 #include "icons-stock.h"
 #include "images/audacious_playlist.xpm"
--- a/src/audacious/ui_preferences.c	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/ui_preferences.c	Sat Jan 20 04:48:41 2007 -0800
@@ -49,6 +49,7 @@
 #include "main.h"
 #include "widgets/widgetcore.h"
 #include "libaudacious/urldecode.h"
+#include "strings.h"
 #include "util.h"
 #include "dnd.h"
 #include "libaudacious/configdb.h"
--- a/src/audacious/util.c	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/util.c	Sat Jan 20 04:48:41 2007 -0800
@@ -21,8 +21,6 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#define WEIRD_UTF_16_PLAYLIST_ENCODING
-
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
 #endif
@@ -34,16 +32,11 @@
 #include <glib/gi18n.h>
 #include <glade/glade.h>
 #include <gtk/gtk.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 
 #include "platform/smartinclude.h"
-#include <gdk/gdkkeysyms.h>
-#include <X11/Xlib.h>
-//#include <sys/ipc.h>
-#include <unistd.h>
 #include <errno.h>
 
 #ifdef HAVE_FTS_H
@@ -54,7 +47,7 @@
 #include "input.h"
 #include "main.h"
 #include "playback.h"
-#include "playlist.h"
+#include "strings.h"
 #include "ui_playlist.h"
 
 #ifdef USE_CHARDET
--- a/src/audacious/util.h	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/util.h	Sat Jan 20 04:48:41 2007 -0800
@@ -46,8 +46,6 @@
                                    gpointer user_data);
 
 
-gchar *escape_shell_chars(const gchar * string);
-
 gchar *find_file_recursively(const gchar * dirname, const gchar * file);
 void del_directory(const gchar * dirname);
 gboolean dir_foreach(const gchar * path, DirForeachFunc function,
@@ -83,20 +81,6 @@
 
 guint gint_count_digits(gint n);
 
-gchar *convert_title_text(gchar * text);
-
-gchar *str_append(gchar * str, const gchar * add_str);
-gchar *str_replace(gchar * str, gchar * new_str);
-void str_replace_in(gchar ** str, gchar * new_str);
-
-gboolean str_has_prefix_nocase(const gchar * str, const gchar * prefix);
-gboolean str_has_suffix_nocase(const gchar * str, const gchar * suffix);
-gboolean str_has_suffixes_nocase(const gchar * str, gchar * const *suffixes);
-const gchar *str_skip_chars(const gchar * str, const gchar * chars);
-
-gchar *filename_to_utf8(const gchar * filename);
-gchar *str_to_utf8(const gchar * str);
-gchar *str_to_utf8_fallback(const gchar * str);
 
 #if ENABLE_NLS
 gchar *bmp_menu_translate(const gchar * path, gpointer func_data);
@@ -112,8 +96,6 @@
     gint y;
 } MenuPos;
 
-gchar *chardet_to_utf8(const gchar *str, gssize len,
-		       gsize *arg_bytes_read, gsize *arg_bytes_write, GError **arg_error);
 
 GdkPixmap *audacious_pixmap_resize(GdkWindow *src, GdkGC *src_gc, GdkPixmap *in, gint width, gint height);
 
--- a/src/audacious/widgets/textbox.c	Sat Jan 20 03:39:28 2007 -0800
+++ b/src/audacious/widgets/textbox.c	Sat Jan 20 04:48:41 2007 -0800
@@ -29,6 +29,7 @@
 #include <ctype.h>
 
 #include "main.h"
+#include "strings.h"
 #include "util.h"
 
 static void textbox_generate_pixmap(TextBox * tb);