Code

colors: color id is the index of the "colors" array
[ncmpc.git] / src / strfsong.c
index 22f2e2e6d10d5ca1bc7229e020eab55cfa6d843e..ed3e20f9807ad56fa1c91621a1f551dfd96f879f 100644 (file)
@@ -1,6 +1,4 @@
-/* 
- * $Id$
- *
+/*
  * Based on mpc's songToFormatedString modified for glib and ncmpc
  *
  *
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "strfsong.h"
+#include "charset.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
 #include <string.h>
-#include <glib.h>
-
-#include "config.h"
-#include "libmpdclient.h"
-#include "support.h"
-#include "strfsong.h"
 
 static const gchar *
 skip(const gchar * p)
@@ -40,11 +31,12 @@ skip(const gchar * p)
        gint stack = 0;
 
        while (*p != '\0') {
-               if(*p == '[') stack++;
-               if(*p == '#' && p[1] != '\0') {
+               if (*p == '[')
+                       stack++;
+               if (*p == '#' && p[1] != '\0') {
                        /* skip escaped stuff */
                        ++p;
-               } else if(stack) {
+               } else if (stack) {
                        if(*p == ']') stack--;
                } else {
                        if(*p == '&' || *p == '|' || *p == ']') {
@@ -61,7 +53,7 @@ static gsize
 _strfsong(gchar *s,
          gsize max,
          const gchar *format,
-         mpd_Song *song,
+         const struct mpd_song *song,
          const gchar **last)
 {
        const gchar *p, *end;
@@ -70,7 +62,7 @@ _strfsong(gchar *s,
        gboolean found = FALSE;
 
        memset(s, 0, max);
-       if( song==NULL )
+       if (song == NULL)
                return 0;
 
        for (p = format; *p != '\0' && length<max;) {
@@ -177,7 +169,7 @@ _strfsong(gchar *s,
                        if( strstr(song->file, "://") )
                                temp = utf8_to_locale(song->file);
                        else
-                               temp = utf8_to_locale(basename(song->file));
+                               temp = utf8_to_locale(g_basename(song->file));
                } else if (strncmp("%time%", p, n) == 0) {
                        if (song->time != MPD_SONG_NO_TIME)  {
                                if (song->time > 3600) {
@@ -223,8 +215,9 @@ _strfsong(gchar *s,
 }
 
 gsize
-strfsong(gchar *s, gsize max, const gchar *format, mpd_Song *song)
+strfsong(gchar *s, gsize max, const gchar *format,
+        const struct mpd_song *song)
 {
-  return _strfsong(s, max, format, song, NULL);
+       return _strfsong(s, max, format, song, NULL);
 }
-     
+