00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <glib.h>
00023 #include <string.h>
00024
00025 #include "misc.h"
00026 #include "playlist_container.h"
00027
00028
00029
00030
00031
00032
00033 static GList *registered_plcs = NULL;
00034
00035 void playlist_container_register(PlaylistContainer *plc)
00036 {
00037 registered_plcs = g_list_append(registered_plcs, plc);
00038 }
00039
00040 void playlist_container_unregister(PlaylistContainer *plc)
00041 {
00042 registered_plcs = g_list_remove(registered_plcs, plc);
00043 }
00044
00045 PlaylistContainer *playlist_container_find(gchar *ext)
00046 {
00047 GList *node;
00048 PlaylistContainer *plc;
00049
00050
00051 g_return_val_if_fail(ext != NULL && ext != (void *)1, NULL);
00052
00053 for (node = registered_plcs; node != NULL; node = g_list_next(node)) {
00054 plc = node->data;
00055
00056 if (!g_ascii_strncasecmp(plc->ext, ext, strlen(plc->ext)))
00057 return plc;
00058 }
00059
00060 return NULL;
00061 }
00062
00063 void playlist_container_read(gchar *filename, gint pos)
00064 {
00065 gchar *ext = strrchr(filename, '.') + 1;
00066 PlaylistContainer *plc = playlist_container_find(ext);
00067
00068 if (plc->plc_read == NULL)
00069 return;
00070
00071 plc->plc_read(filename, pos);
00072 }
00073
00074 void playlist_container_write(gchar *filename, gint pos)
00075 {
00076 gchar *ext = strrchr(filename, '.') + 1;
00077 PlaylistContainer *plc = playlist_container_find(ext);
00078
00079 if (plc->plc_write == NULL)
00080 return;
00081
00082 plc->plc_write(filename, pos);
00083 }