changeset 1549:854016a03129 trunk

[svn] - more
author nenolod
date Thu, 10 Aug 2006 18:24:11 -0700
parents d5be38600be5
children be50c53aee09
files ChangeLog audacious/playlist_container.c audacious/playlist_container.h
diffstat 3 files changed, 59 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Aug 10 18:10:25 2006 -0700
+++ b/ChangeLog	Thu Aug 10 18:24:11 2006 -0700
@@ -1,3 +1,14 @@
+2006-08-11 01:10:25 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [2010]
+  - incomplete PlaylistContainer implementation
+  
+
+  Changes:        Modified:
+  +1 -0           trunk/audacious/Makefile  
+  +39 -0          trunk/audacious/playlist_container.c  
+  +36 -0          trunk/audacious/playlist_container.h  
+
+
 2006-08-10 20:51:08 +0000  William Pitcock <nenolod@nenolod.net>
   revision [2008]
   - dependency cleanup part 2
--- a/audacious/playlist_container.c	Thu Aug 10 18:10:25 2006 -0700
+++ b/audacious/playlist_container.c	Thu Aug 10 18:24:11 2006 -0700
@@ -19,6 +19,7 @@
  */
 
 #include <glib.h>
+#include <string.h>
 #include "playlist_container.h"
 
 /*
@@ -37,3 +38,44 @@
 {
 	registered_plcs = g_list_remove(registered_plcs, plc);
 }
+
+PlaylistContainer *playlist_container_find(char *ext)
+{
+	GList *node;
+	PlaylistContainer *plc;
+
+	g_return_val_if_fail(ext != NULL, NULL);
+
+	for (node = registered_plcs; node != NULL; node = g_list_next(node)) {
+		plc = PLAYLIST_CONTAINER(node->data);
+
+		if (!g_strcasecmp(plc->ext, ext))
+			return plc;
+	}
+
+	return NULL;
+}
+
+GList *playlist_container_read(char *filename, GList *list)
+{
+	char *ext = strrchr(filename, '.') + 1;		/* optimization: skip past the dot -nenolod */
+	PlaylistContainer *plc = playlist_container_find(ext);
+
+	if (plc->plc_read == NULL)
+		return list;
+
+	list = plc->plc_read(filename, list);
+
+	return list;
+}
+
+void playlist_container_write(char *filename, GList *list)
+{
+	char *ext = strrchr(filename, '.') + 1;		/* optimization: skip past the dot -nenolod */
+	PlaylistContainer *plc = playlist_container_find(ext);
+
+	if (plc->plc_write == NULL)
+		return;
+
+	plc->plc_write(filename, list);
+}
--- a/audacious/playlist_container.h	Thu Aug 10 18:10:25 2006 -0700
+++ b/audacious/playlist_container.h	Thu Aug 10 18:24:11 2006 -0700
@@ -24,13 +24,18 @@
 struct _PlaylistContainer {
 	char *name;					/* human-readable name */
 	char *ext;					/* extension */
-	void (*plc_load)(char *filename, GList *pl);	/* plc_load */
+	GList *(*plc_read)(char *filename, GList *pl);	/* plc_load */
 	void (*plc_write)(char *filename, GList *pl);	/* plc_write */
 };
 
 typedef struct _PlaylistContainer PlaylistContainer;
 
+#define PLAYLIST_CONTAINER(x)		((PlaylistContainer *)(x))
+
 extern void playlist_container_register(PlaylistContainer *plc);
 extern void playlist_container_unregister(PlaylistContainer *plc);
+extern GList *playlist_container_read(char *filename, GList *list);
+extern void playlist_container_write(char *filename, GList *list);
+
 
 #endif