# HG changeset patch # User nenolod # Date 1155259451 25200 # Node ID 854016a0312972e72c990d7a3f0b0466893aafc4 # Parent d5be38600be5cc5b7dc6826604eb9f2256f0c558 [svn] - more diff -r d5be38600be5 -r 854016a03129 ChangeLog --- 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 + 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 revision [2008] - dependency cleanup part 2 diff -r d5be38600be5 -r 854016a03129 audacious/playlist_container.c --- 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 +#include #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); +} diff -r d5be38600be5 -r 854016a03129 audacious/playlist_container.h --- 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