aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-27 17:38:09 +0100
committerMax Kellermann <max@duempel.org>2013-01-27 17:38:09 +0100
commit257a0dee758049586efbf0dc3f0339b0cef03456 (patch)
tree843392ee65fb2e1abb9dad3386ec806eb23975fd /src
parente995cd928c40ecea22fd4d1e3716bb9a656a5430 (diff)
downloadmpd-257a0dee758049586efbf0dc3f0339b0cef03456.tar.gz
mpd-257a0dee758049586efbf0dc3f0339b0cef03456.tar.xz
mpd-257a0dee758049586efbf0dc3f0339b0cef03456.zip
playlist/*: convert to C++
Diffstat (limited to '')
-rw-r--r--src/CommandLine.cxx2
-rw-r--r--src/PlaylistPlugin.hxx (renamed from src/playlist_plugin.h)7
-rw-r--r--src/PlaylistPrint.cxx2
-rw-r--r--src/PlaylistQueue.cxx2
-rw-r--r--src/PlaylistRegistry.cxx16
-rw-r--r--src/playlist/AsxPlaylistPlugin.cxx (renamed from src/playlist/asx_playlist_plugin.c)85
-rw-r--r--src/playlist/AsxPlaylistPlugin.hxx (renamed from src/playlist/asx_playlist_plugin.h)6
-rw-r--r--src/playlist/CuePlaylistPlugin.cxx (renamed from src/playlist/cue_playlist_plugin.c)36
-rw-r--r--src/playlist/CuePlaylistPlugin.hxx (renamed from src/playlist/cue_playlist_plugin.h)6
-rw-r--r--src/playlist/DespotifyPlaylistPlugin.cxx2
-rw-r--r--src/playlist/EmbeddedCuePlaylistPlugin.cxx2
-rw-r--r--src/playlist/ExtM3uPlaylistPlugin.cxx (renamed from src/playlist/extm3u_playlist_plugin.c)45
-rw-r--r--src/playlist/ExtM3uPlaylistPlugin.hxx (renamed from src/playlist/extm3u_playlist_plugin.h)6
-rw-r--r--src/playlist/LastFMPlaylistPlugin.cxx3
-rw-r--r--src/playlist/M3uPlaylistPlugin.cxx (renamed from src/playlist/m3u_playlist_plugin.c)36
-rw-r--r--src/playlist/M3uPlaylistPlugin.hxx (renamed from src/playlist/m3u_playlist_plugin.h)6
-rw-r--r--src/playlist/PlsPlaylistPlugin.cxx (renamed from src/playlist/pls_playlist_plugin.c)40
-rw-r--r--src/playlist/PlsPlaylistPlugin.hxx (renamed from src/playlist/pls_playlist_plugin.h)6
-rw-r--r--src/playlist/RssPlaylistPlugin.cxx (renamed from src/playlist/rss_playlist_plugin.c)81
-rw-r--r--src/playlist/RssPlaylistPlugin.hxx (renamed from src/playlist/rss_playlist_plugin.h)6
-rw-r--r--src/playlist/SoundCloudPlaylistPlugin.cxx2
-rw-r--r--src/playlist/XspfPlaylistPlugin.cxx (renamed from src/playlist/xspf_playlist_plugin.c)111
-rw-r--r--src/playlist/XspfPlaylistPlugin.hxx (renamed from src/playlist/xspf_playlist_plugin.h)6
23 files changed, 274 insertions, 240 deletions
diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx
index c0b449859..f04bf89b8 100644
--- a/src/CommandLine.cxx
+++ b/src/CommandLine.cxx
@@ -29,7 +29,7 @@
#include "InputRegistry.hxx"
#include "InputPlugin.hxx"
#include "PlaylistRegistry.hxx"
-#include "playlist_plugin.h"
+#include "PlaylistPlugin.hxx"
#include "mpd_error.h"
#include "glib_compat.h"
diff --git a/src/playlist_plugin.h b/src/PlaylistPlugin.hxx
index a27f651c0..38e6f8571 100644
--- a/src/playlist_plugin.h
+++ b/src/PlaylistPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,12 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PLAYLIST_PLUGIN_H
-#define MPD_PLAYLIST_PLUGIN_H
+#ifndef MPD_PLAYLIST_PLUGIN_HXX
+#define MPD_PLAYLIST_PLUGIN_HXX
#include <glib.h>
-#include <stdbool.h>
#include <stddef.h>
struct config_param;
diff --git a/src/PlaylistPrint.cxx b/src/PlaylistPrint.cxx
index 5bde8238a..ffecc8133 100644
--- a/src/PlaylistPrint.cxx
+++ b/src/PlaylistPrint.cxx
@@ -24,6 +24,7 @@
#include "PlaylistSong.hxx"
#include "Playlist.hxx"
#include "PlaylistRegistry.hxx"
+#include "PlaylistPlugin.hxx"
#include "QueuePrint.hxx"
#include "SongPrint.hxx"
#include "DatabaseGlue.hxx"
@@ -32,7 +33,6 @@
#include "input_stream.h"
extern "C" {
-#include "playlist_plugin.h"
#include "song.h"
}
diff --git a/src/PlaylistQueue.cxx b/src/PlaylistQueue.cxx
index 1335fa401..39732676a 100644
--- a/src/PlaylistQueue.cxx
+++ b/src/PlaylistQueue.cxx
@@ -19,7 +19,7 @@
#include "config.h"
#include "PlaylistQueue.hxx"
-#include "playlist_plugin.h"
+#include "PlaylistPlugin.hxx"
#include "PlaylistAny.hxx"
#include "PlaylistSong.hxx"
#include "Playlist.hxx"
diff --git a/src/PlaylistRegistry.cxx b/src/PlaylistRegistry.cxx
index 1e9edd443..551f7ef36 100644
--- a/src/PlaylistRegistry.cxx
+++ b/src/PlaylistRegistry.cxx
@@ -19,17 +19,17 @@
#include "config.h"
#include "PlaylistRegistry.hxx"
-#include "playlist_plugin.h"
-#include "playlist/extm3u_playlist_plugin.h"
-#include "playlist/m3u_playlist_plugin.h"
-#include "playlist/xspf_playlist_plugin.h"
+#include "PlaylistPlugin.hxx"
+#include "playlist/ExtM3uPlaylistPlugin.hxx"
+#include "playlist/M3uPlaylistPlugin.hxx"
+#include "playlist/XspfPlaylistPlugin.hxx"
#include "playlist/LastFMPlaylistPlugin.hxx"
#include "playlist/DespotifyPlaylistPlugin.hxx"
#include "playlist/SoundCloudPlaylistPlugin.hxx"
-#include "playlist/pls_playlist_plugin.h"
-#include "playlist/asx_playlist_plugin.h"
-#include "playlist/rss_playlist_plugin.h"
-#include "playlist/cue_playlist_plugin.h"
+#include "playlist/PlsPlaylistPlugin.hxx"
+#include "playlist/AsxPlaylistPlugin.hxx"
+#include "playlist/RssPlaylistPlugin.hxx"
+#include "playlist/CuePlaylistPlugin.hxx"
#include "playlist/EmbeddedCuePlaylistPlugin.hxx"
#include "input_stream.h"
diff --git a/src/playlist/asx_playlist_plugin.c b/src/playlist/AsxPlaylistPlugin.cxx
index 298687859..2a787f669 100644
--- a/src/playlist/asx_playlist_plugin.c
+++ b/src/playlist/AsxPlaylistPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,8 +18,8 @@
*/
#include "config.h"
-#include "playlist/asx_playlist_plugin.h"
-#include "playlist_plugin.h"
+#include "AsxPlaylistPlugin.hxx"
+#include "PlaylistPlugin.hxx"
#include "input_stream.h"
#include "song.h"
#include "tag.h"
@@ -35,7 +35,7 @@
/**
* This is the state object for the GLib XML parser.
*/
-struct asx_parser {
+struct AsxParser {
/**
* The list of songs (in reverse order because that's faster
* while adding).
@@ -61,6 +61,11 @@ struct asx_parser {
* element.
*/
struct song *song;
+
+ AsxParser()
+ :songs(nullptr),
+ state(ROOT) {}
+
};
static const gchar *
@@ -81,19 +86,19 @@ asx_start_element(G_GNUC_UNUSED GMarkupParseContext *context,
const gchar **attribute_values,
gpointer user_data, G_GNUC_UNUSED GError **error)
{
- struct asx_parser *parser = user_data;
+ AsxParser *parser = (AsxParser *)user_data;
switch (parser->state) {
- case ROOT:
+ case AsxParser::ROOT:
if (g_ascii_strcasecmp(element_name, "entry") == 0) {
- parser->state = ENTRY;
+ parser->state = AsxParser::ENTRY;
parser->song = song_remote_new("asx:");
parser->tag = TAG_NUM_OF_ITEM_TYPES;
}
break;
- case ENTRY:
+ case AsxParser::ENTRY:
if (g_ascii_strcasecmp(element_name, "ref") == 0) {
const gchar *href = get_attribute(attribute_names,
attribute_values,
@@ -130,13 +135,13 @@ asx_end_element(G_GNUC_UNUSED GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data, G_GNUC_UNUSED GError **error)
{
- struct asx_parser *parser = user_data;
+ AsxParser *parser = (AsxParser *)user_data;
switch (parser->state) {
- case ROOT:
+ case AsxParser::ROOT:
break;
- case ENTRY:
+ case AsxParser::ENTRY:
if (g_ascii_strcasecmp(element_name, "entry") == 0) {
if (strcmp(parser->song->uri, "asx:") != 0)
parser->songs = g_slist_prepend(parser->songs,
@@ -144,7 +149,7 @@ asx_end_element(G_GNUC_UNUSED GMarkupParseContext *context,
else
song_free(parser->song);
- parser->state = ROOT;
+ parser->state = AsxParser::ROOT;
} else
parser->tag = TAG_NUM_OF_ITEM_TYPES;
@@ -157,13 +162,13 @@ asx_text(G_GNUC_UNUSED GMarkupParseContext *context,
const gchar *text, gsize text_len,
gpointer user_data, G_GNUC_UNUSED GError **error)
{
- struct asx_parser *parser = user_data;
+ AsxParser *parser = (AsxParser *)user_data;
switch (parser->state) {
- case ROOT:
+ case AsxParser::ROOT:
break;
- case ENTRY:
+ case AsxParser::ENTRY:
if (parser->tag != TAG_NUM_OF_ITEM_TYPES) {
if (parser->song->tag == NULL)
parser->song->tag = tag_new();
@@ -176,15 +181,17 @@ asx_text(G_GNUC_UNUSED GMarkupParseContext *context,
}
static const GMarkupParser asx_parser = {
- .start_element = asx_start_element,
- .end_element = asx_end_element,
- .text = asx_text,
+ asx_start_element,
+ asx_end_element,
+ asx_text,
+ nullptr,
+ nullptr,
};
static void
song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
- struct song *song = data;
+ struct song *song = (struct song *)data;
song_free(song);
}
@@ -192,9 +199,9 @@ song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
static void
asx_parser_destroy(gpointer data)
{
- struct asx_parser *parser = data;
+ AsxParser *parser = (AsxParser *)data;
- if (parser->state >= ENTRY)
+ if (parser->state >= AsxParser::ENTRY)
song_free(parser->song);
g_slist_foreach(parser->songs, song_free_callback, NULL);
@@ -206,7 +213,7 @@ asx_parser_destroy(gpointer data)
*
*/
-struct asx_playlist {
+struct AsxPlaylist {
struct playlist_provider base;
GSList *songs;
@@ -215,11 +222,8 @@ struct asx_playlist {
static struct playlist_provider *
asx_open_stream(struct input_stream *is)
{
- struct asx_parser parser = {
- .songs = NULL,
- .state = ROOT,
- };
- struct asx_playlist *playlist;
+ AsxParser parser;
+ AsxPlaylist *playlist;
GMarkupParseContext *context;
char buffer[1024];
size_t nbytes;
@@ -264,9 +268,9 @@ asx_open_stream(struct input_stream *is)
return NULL;
}
- /* create a #asx_playlist object from the parsed song list */
+ /* create a #AsxPlaylist object from the parsed song list */
- playlist = g_new(struct asx_playlist, 1);
+ playlist = g_new(AsxPlaylist, 1);
playlist_provider_init(&playlist->base, &asx_playlist_plugin);
playlist->songs = g_slist_reverse(parser.songs);
parser.songs = NULL;
@@ -279,7 +283,7 @@ asx_open_stream(struct input_stream *is)
static void
asx_close(struct playlist_provider *_playlist)
{
- struct asx_playlist *playlist = (struct asx_playlist *)_playlist;
+ AsxPlaylist *playlist = (AsxPlaylist *)_playlist;
g_slist_foreach(playlist->songs, song_free_callback, NULL);
g_slist_free(playlist->songs);
@@ -289,13 +293,12 @@ asx_close(struct playlist_provider *_playlist)
static struct song *
asx_read(struct playlist_provider *_playlist)
{
- struct asx_playlist *playlist = (struct asx_playlist *)_playlist;
- struct song *song;
+ AsxPlaylist *playlist = (AsxPlaylist *)_playlist;
if (playlist->songs == NULL)
return NULL;
- song = playlist->songs->data;
+ struct song *song = (struct song *)playlist->songs->data;
playlist->songs = g_slist_remove(playlist->songs, song);
return song;
@@ -312,12 +315,16 @@ static const char *const asx_mime_types[] = {
};
const struct playlist_plugin asx_playlist_plugin = {
- .name = "asx",
+ "asx",
- .open_stream = asx_open_stream,
- .close = asx_close,
- .read = asx_read,
+ nullptr,
+ nullptr,
+ nullptr,
+ asx_open_stream,
+ asx_close,
+ asx_read,
- .suffixes = asx_suffixes,
- .mime_types = asx_mime_types,
+ nullptr,
+ asx_suffixes,
+ asx_mime_types,
};
diff --git a/src/playlist/asx_playlist_plugin.h b/src/playlist/AsxPlaylistPlugin.hxx
index 6c01c1209..240c1824a 100644
--- a/src/playlist/asx_playlist_plugin.h
+++ b/src/playlist/AsxPlaylistPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PLAYLIST_ASX_PLAYLIST_PLUGIN_H
-#define MPD_PLAYLIST_ASX_PLAYLIST_PLUGIN_H
+#ifndef MPD_ASX_PLAYLIST_PLUGIN_HXX
+#define MPD_ASX_PLAYLIST_PLUGIN_HXX
extern const struct playlist_plugin asx_playlist_plugin;
diff --git a/src/playlist/cue_playlist_plugin.c b/src/playlist/CuePlaylistPlugin.cxx
index b85de77d3..07eb5e243 100644
--- a/src/playlist/cue_playlist_plugin.c
+++ b/src/playlist/CuePlaylistPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,13 +18,16 @@
*/
#include "config.h"
-#include "playlist/cue_playlist_plugin.h"
-#include "playlist_plugin.h"
+#include "CuePlaylistPlugin.hxx"
+#include "PlaylistPlugin.hxx"
#include "tag.h"
#include "song.h"
-#include "cue/cue_parser.h"
#include "input_stream.h"
+
+extern "C" {
#include "text_input_stream.h"
+#include "cue/cue_parser.h"
+}
#include <glib.h>
#include <assert.h>
@@ -33,7 +36,7 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "cue"
-struct cue_playlist {
+struct CuePlaylist {
struct playlist_provider base;
struct input_stream *is;
@@ -44,21 +47,20 @@ struct cue_playlist {
static struct playlist_provider *
cue_playlist_open_stream(struct input_stream *is)
{
- struct cue_playlist *playlist = g_new(struct cue_playlist, 1);
+ CuePlaylist *playlist = g_new(CuePlaylist, 1);
playlist_provider_init(&playlist->base, &cue_playlist_plugin);
playlist->is = is;
playlist->tis = text_input_stream_new(is);
playlist->parser = cue_parser_new();
-
return &playlist->base;
}
static void
cue_playlist_close(struct playlist_provider *_playlist)
{
- struct cue_playlist *playlist = (struct cue_playlist *)_playlist;
+ CuePlaylist *playlist = (CuePlaylist *)_playlist;
cue_parser_free(playlist->parser);
text_input_stream_free(playlist->tis);
@@ -68,7 +70,7 @@ cue_playlist_close(struct playlist_provider *_playlist)
static struct song *
cue_playlist_read(struct playlist_provider *_playlist)
{
- struct cue_playlist *playlist = (struct cue_playlist *)_playlist;
+ CuePlaylist *playlist = (CuePlaylist *)_playlist;
struct song *song = cue_parser_get(playlist->parser);
if (song != NULL)
@@ -97,12 +99,16 @@ static const char *const cue_playlist_mime_types[] = {
};
const struct playlist_plugin cue_playlist_plugin = {
- .name = "cue",
+ "cue",
- .open_stream = cue_playlist_open_stream,
- .close = cue_playlist_close,
- .read = cue_playlist_read,
+ nullptr,
+ nullptr,
+ nullptr,
+ cue_playlist_open_stream,
+ cue_playlist_close,
+ cue_playlist_read,
- .suffixes = cue_playlist_suffixes,
- .mime_types = cue_playlist_mime_types,
+ nullptr,
+ cue_playlist_suffixes,
+ cue_playlist_mime_types,
};
diff --git a/src/playlist/cue_playlist_plugin.h b/src/playlist/CuePlaylistPlugin.hxx
index c02e2235a..cf5e3a8f0 100644
--- a/src/playlist/cue_playlist_plugin.h
+++ b/src/playlist/CuePlaylistPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PLAYLIST_CUE_PLAYLIST_PLUGIN_H
-#define MPD_PLAYLIST_CUE_PLAYLIST_PLUGIN_H
+#ifndef MPD_CUE_PLAYLIST_PLUGIN_HXX
+#define MPD_CUE_PLAYLIST_PLUGIN_HXX
extern const struct playlist_plugin cue_playlist_plugin;
diff --git a/src/playlist/DespotifyPlaylistPlugin.cxx b/src/playlist/DespotifyPlaylistPlugin.cxx
index 3466d5685..7f647d58e 100644
--- a/src/playlist/DespotifyPlaylistPlugin.cxx
+++ b/src/playlist/DespotifyPlaylistPlugin.cxx
@@ -20,7 +20,7 @@
#include "config.h"
#include "DespotifyPlaylistPlugin.hxx"
#include "DespotifyUtils.hxx"
-#include "playlist_plugin.h"
+#include "PlaylistPlugin.hxx"
#include "PlaylistRegistry.hxx"
#include "conf.h"
#include "uri.h"
diff --git a/src/playlist/EmbeddedCuePlaylistPlugin.cxx b/src/playlist/EmbeddedCuePlaylistPlugin.cxx
index 5cd941df6..f420aebfd 100644
--- a/src/playlist/EmbeddedCuePlaylistPlugin.cxx
+++ b/src/playlist/EmbeddedCuePlaylistPlugin.cxx
@@ -25,7 +25,7 @@
#include "config.h"
#include "EmbeddedCuePlaylistPlugin.hxx"
-#include "playlist_plugin.h"
+#include "PlaylistPlugin.hxx"
#include "tag.h"
#include "tag_handler.h"
#include "song.h"
diff --git a/src/playlist/extm3u_playlist_plugin.c b/src/playlist/ExtM3uPlaylistPlugin.cxx
index 19be8d1c4..ce026dab8 100644
--- a/src/playlist/extm3u_playlist_plugin.c
+++ b/src/playlist/ExtM3uPlaylistPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,20 +18,22 @@
*/
#include "config.h"
-#include "playlist/extm3u_playlist_plugin.h"
-#include "playlist_plugin.h"
-#include "text_input_stream.h"
-#include "uri.h"
+#include "ExtM3uPlaylistPlugin.hxx"
+#include "PlaylistPlugin.hxx"
#include "song.h"
#include "tag.h"
#include "string_util.h"
+extern "C" {
+#include "text_input_stream.h"
+}
+
#include <glib.h>
#include <string.h>
#include <stdlib.h>
-struct extm3u_playlist {
+struct ExtM3uPlaylist {
struct playlist_provider base;
struct text_input_stream *tis;
@@ -40,13 +42,10 @@ struct extm3u_playlist {
static struct playlist_provider *
extm3u_open_stream(struct input_stream *is)
{
- struct extm3u_playlist *playlist;
- const char *line;
-
- playlist = g_new(struct extm3u_playlist, 1);
+ ExtM3uPlaylist *playlist = g_new(ExtM3uPlaylist, 1);
playlist->tis = text_input_stream_new(is);
- line = text_input_stream_read(playlist->tis);
+ const char *line = text_input_stream_read(playlist->tis);
if (line == NULL || strcmp(line, "#EXTM3U") != 0) {
/* no EXTM3U header: fall back to the plain m3u
plugin */
@@ -62,7 +61,7 @@ extm3u_open_stream(struct input_stream *is)
static void
extm3u_close(struct playlist_provider *_playlist)
{
- struct extm3u_playlist *playlist = (struct extm3u_playlist *)_playlist;
+ ExtM3uPlaylist *playlist = (ExtM3uPlaylist *)_playlist;
text_input_stream_free(playlist->tis);
g_free(playlist);
@@ -111,7 +110,7 @@ extm3u_parse_tag(const char *line)
static struct song *
extm3u_read(struct playlist_provider *_playlist)
{
- struct extm3u_playlist *playlist = (struct extm3u_playlist *)_playlist;
+ ExtM3uPlaylist *playlist = (ExtM3uPlaylist *)_playlist;
struct tag *tag = NULL;
const char *line;
struct song *song;
@@ -151,12 +150,16 @@ static const char *const extm3u_mime_types[] = {
};
const struct playlist_plugin extm3u_playlist_plugin = {
- .name = "extm3u",
-
- .open_stream = extm3u_open_stream,
- .close = extm3u_close,
- .read = extm3u_read,
-
- .suffixes = extm3u_suffixes,
- .mime_types = extm3u_mime_types,
+ "extm3u",
+
+ nullptr,
+ nullptr,
+ nullptr,
+ extm3u_open_stream,
+ extm3u_close,
+ extm3u_read,
+
+ nullptr,
+ extm3u_suffixes,
+ extm3u_mime_types,
};
diff --git a/src/playlist/extm3u_playlist_plugin.h b/src/playlist/ExtM3uPlaylistPlugin.hxx
index 5f611ac9c..844fba15c 100644
--- a/src/playlist/extm3u_playlist_plugin.h
+++ b/src/playlist/ExtM3uPlaylistPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PLAYLIST_EXTM3U_PLAYLIST_PLUGIN_H
-#define MPD_PLAYLIST_EXTM3U_PLAYLIST_PLUGIN_H
+#ifndef MPD_EXTM3U_PLAYLIST_PLUGIN_HXX
+#define MPD_EXTM3U_PLAYLIST_PLUGIN_HXX
extern const struct playlist_plugin extm3u_playlist_plugin;
diff --git a/src/playlist/LastFMPlaylistPlugin.cxx b/src/playlist/LastFMPlaylistPlugin.cxx
index 36c89fea1..3898ce31c 100644
--- a/src/playlist/LastFMPlaylistPlugin.cxx
+++ b/src/playlist/LastFMPlaylistPlugin.cxx
@@ -19,10 +19,9 @@
#include "config.h"
#include "LastFMPlaylistPlugin.hxx"
-#include "playlist_plugin.h"
+#include "PlaylistPlugin.hxx"
#include "PlaylistRegistry.hxx"
#include "conf.h"
-#include "uri.h"
#include "song.h"
#include "input_stream.h"
diff --git a/src/playlist/m3u_playlist_plugin.c b/src/playlist/M3uPlaylistPlugin.cxx
index 45b70d2b1..eeecd2779 100644
--- a/src/playlist/m3u_playlist_plugin.c
+++ b/src/playlist/M3uPlaylistPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,15 +18,17 @@
*/
#include "config.h"
-#include "playlist/m3u_playlist_plugin.h"
-#include "playlist_plugin.h"
-#include "text_input_stream.h"
-#include "uri.h"
+#include "M3uPlaylistPlugin.hxx"
+#include "PlaylistPlugin.hxx"
#include "song.h"
+extern "C" {
+#include "text_input_stream.h"
+}
+
#include <glib.h>
-struct m3u_playlist {
+struct M3uPlaylist {
struct playlist_provider base;
struct text_input_stream *tis;
@@ -35,7 +37,7 @@ struct m3u_playlist {
static struct playlist_provider *
m3u_open_stream(struct input_stream *is)
{
- struct m3u_playlist *playlist = g_new(struct m3u_playlist, 1);
+ M3uPlaylist *playlist = g_new(M3uPlaylist, 1);
playlist_provider_init(&playlist->base, &m3u_playlist_plugin);
playlist->tis = text_input_stream_new(is);
@@ -46,7 +48,7 @@ m3u_open_stream(struct input_stream *is)
static void
m3u_close(struct playlist_provider *_playlist)
{
- struct m3u_playlist *playlist = (struct m3u_playlist *)_playlist;
+ M3uPlaylist *playlist = (M3uPlaylist *)_playlist;
text_input_stream_free(playlist->tis);
g_free(playlist);
@@ -55,7 +57,7 @@ m3u_close(struct playlist_provider *_playlist)
static struct song *
m3u_read(struct playlist_provider *_playlist)
{
- struct m3u_playlist *playlist = (struct m3u_playlist *)_playlist;
+ M3uPlaylist *playlist = (M3uPlaylist *)_playlist;
const char *line;
do {
@@ -81,12 +83,16 @@ static const char *const m3u_mime_types[] = {
};
const struct playlist_plugin m3u_playlist_plugin = {
- .name = "m3u",
+ "m3u",
- .open_stream = m3u_open_stream,
- .close = m3u_close,
- .read = m3u_read,
+ nullptr,
+ nullptr,
+ nullptr,
+ m3u_open_stream,
+ m3u_close,
+ m3u_read,
- .suffixes = m3u_suffixes,
- .mime_types = m3u_mime_types,
+ nullptr,
+ m3u_suffixes,
+ m3u_mime_types,
};
diff --git a/src/playlist/m3u_playlist_plugin.h b/src/playlist/M3uPlaylistPlugin.hxx
index 3890a5fc2..a2058bb29 100644
--- a/src/playlist/m3u_playlist_plugin.h
+++ b/src/playlist/M3uPlaylistPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PLAYLIST_M3U_PLAYLIST_PLUGIN_H
-#define MPD_PLAYLIST_M3U_PLAYLIST_PLUGIN_H
+#ifndef MPD_M3U_PLAYLIST_PLUGIN_HXX
+#define MPD_M3U_PLAYLIST_PLUGIN_HXX
extern const struct playlist_plugin m3u_playlist_plugin;
diff --git a/src/playlist/pls_playlist_plugin.c b/src/playlist/PlsPlaylistPlugin.cxx
index c4e5492af..8cb8b4f1d 100644
--- a/src/playlist/pls_playlist_plugin.c
+++ b/src/playlist/PlsPlaylistPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,21 +18,22 @@
*/
#include "config.h"
-#include "playlist/pls_playlist_plugin.h"
-#include "playlist_plugin.h"
+#include "PlsPlaylistPlugin.hxx"
+#include "PlaylistPlugin.hxx"
#include "input_stream.h"
#include "uri.h"
#include "song.h"
#include "tag.h"
+
#include <glib.h>
-struct pls_playlist {
+struct PlsPlaylist {
struct playlist_provider base;
GSList *songs;
};
-static void pls_parser(GKeyFile *keyfile, struct pls_playlist *playlist)
+static void pls_parser(GKeyFile *keyfile, PlsPlaylist *playlist)
{
gchar *key;
gchar *value;
@@ -111,7 +112,7 @@ pls_open_stream(struct input_stream *is)
char buffer[1024];
bool success;
GKeyFile *keyfile;
- struct pls_playlist *playlist;
+ PlsPlaylist *playlist;
GString *kf_data = g_string_new("");
do {
@@ -152,7 +153,7 @@ pls_open_stream(struct input_stream *is)
return NULL;
}
- playlist = g_new(struct pls_playlist, 1);
+ playlist = g_new(PlsPlaylist, 1);
playlist_provider_init(&playlist->base, &pls_playlist_plugin);
playlist->songs = NULL;
@@ -166,7 +167,7 @@ pls_open_stream(struct input_stream *is)
static void
song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
- struct song *song = data;
+ struct song *song = (struct song *)data;
song_free(song);
}
@@ -174,7 +175,7 @@ song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
static void
pls_close(struct playlist_provider *_playlist)
{
- struct pls_playlist *playlist = (struct pls_playlist *)_playlist;
+ PlsPlaylist *playlist = (PlsPlaylist *)_playlist;
g_slist_foreach(playlist->songs, song_free_callback, NULL);
g_slist_free(playlist->songs);
@@ -186,13 +187,12 @@ pls_close(struct playlist_provider *_playlist)
static struct song *
pls_read(struct playlist_provider *_playlist)
{
- struct pls_playlist *playlist = (struct pls_playlist *)_playlist;
- struct song *song;
+ PlsPlaylist *playlist = (PlsPlaylist *)_playlist;
if (playlist->songs == NULL)
return NULL;
- song = playlist->songs->data;
+ struct song *song = (struct song *)playlist->songs->data;
playlist->songs = g_slist_remove(playlist->songs, song);
return song;
@@ -209,12 +209,16 @@ static const char *const pls_mime_types[] = {
};
const struct playlist_plugin pls_playlist_plugin = {
- .name = "pls",
+ "pls",
- .open_stream = pls_open_stream,
- .close = pls_close,
- .read = pls_read,
+ nullptr,
+ nullptr,
+ nullptr,
+ pls_open_stream,
+ pls_close,
+ pls_read,
- .suffixes = pls_suffixes,
- .mime_types = pls_mime_types,
+ nullptr,
+ pls_suffixes,
+ pls_mime_types,
};
diff --git a/src/playlist/pls_playlist_plugin.h b/src/playlist/PlsPlaylistPlugin.hxx
index d03435f6d..3fafd36d0 100644
--- a/src/playlist/pls_playlist_plugin.h
+++ b/src/playlist/PlsPlaylistPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PLAYLIST_PLS_PLAYLIST_PLUGIN_H
-#define MPD_PLAYLIST_PLS_PLAYLIST_PLUGIN_H
+#ifndef MPD_PLS_PLAYLIST_PLUGIN_HXX
+#define MPD_PLS_PLAYLIST_PLUGIN_HXX
extern const struct playlist_plugin pls_playlist_plugin;
diff --git a/src/playlist/rss_playlist_plugin.c b/src/playlist/RssPlaylistPlugin.cxx
index 6740cba7e..9b95683c7 100644
--- a/src/playlist/rss_playlist_plugin.c
+++ b/src/playlist/RssPlaylistPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,8 +18,8 @@
*/
#include "config.h"
-#include "playlist/rss_playlist_plugin.h"
-#include "playlist_plugin.h"
+#include "RssPlaylistPlugin.hxx"
+#include "PlaylistPlugin.hxx"
#include "input_stream.h"
#include "song.h"
#include "tag.h"
@@ -35,7 +35,7 @@
/**
* This is the state object for the GLib XML parser.
*/
-struct rss_parser {
+struct RssParser {
/**
* The list of songs (in reverse order because that's faster
* while adding).
@@ -61,6 +61,9 @@ struct rss_parser {
* element.
*/
struct song *song;
+
+ RssParser()
+ :songs(nullptr), state(ROOT) {}
};
static const gchar *
@@ -81,19 +84,19 @@ rss_start_element(G_GNUC_UNUSED GMarkupParseContext *context,
const gchar **attribute_values,
gpointer user_data, G_GNUC_UNUSED GError **error)
{
- struct rss_parser *parser = user_data;
+ RssParser *parser = (RssParser *)user_data;
switch (parser->state) {
- case ROOT:
+ case RssParser::ROOT:
if (g_ascii_strcasecmp(element_name, "item") == 0) {
- parser->state = ITEM;
+ parser->state = RssParser::ITEM;
parser->song = song_remote_new("rss:");
parser->tag = TAG_NUM_OF_ITEM_TYPES;
}
break;
- case ITEM:
+ case RssParser::ITEM:
if (g_ascii_strcasecmp(element_name, "enclosure") == 0) {
const gchar *href = get_attribute(attribute_names,
attribute_values,
@@ -128,13 +131,13 @@ rss_end_element(G_GNUC_UNUSED GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data, G_GNUC_UNUSED GError **error)
{
- struct rss_parser *parser = user_data;
+ RssParser *parser = (RssParser *)user_data;
switch (parser->state) {
- case ROOT:
+ case RssParser::ROOT:
break;
- case ITEM:
+ case RssParser::ITEM:
if (g_ascii_strcasecmp(element_name, "item") == 0) {
if (strcmp(parser->song->uri, "rss:") != 0)
parser->songs = g_slist_prepend(parser->songs,
@@ -142,7 +145,7 @@ rss_end_element(G_GNUC_UNUSED GMarkupParseContext *context,
else
song_free(parser->song);
- parser->state = ROOT;
+ parser->state = RssParser::ROOT;
} else
parser->tag = TAG_NUM_OF_ITEM_TYPES;
@@ -155,13 +158,13 @@ rss_text(G_GNUC_UNUSED GMarkupParseContext *context,
const gchar *text, gsize text_len,
gpointer user_data, G_GNUC_UNUSED GError **error)
{
- struct rss_parser *parser = user_data;
+ RssParser *parser = (RssParser *)user_data;
switch (parser->state) {
- case ROOT:
+ case RssParser::ROOT:
break;
- case ITEM:
+ case RssParser::ITEM:
if (parser->tag != TAG_NUM_OF_ITEM_TYPES) {
if (parser->song->tag == NULL)
parser->song->tag = tag_new();
@@ -174,15 +177,17 @@ rss_text(G_GNUC_UNUSED GMarkupParseContext *context,
}
static const GMarkupParser rss_parser = {
- .start_element = rss_start_element,
- .end_element = rss_end_element,
- .text = rss_text,
+ rss_start_element,
+ rss_end_element,
+ rss_text,
+ nullptr,
+ nullptr,
};
static void
song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
- struct song *song = data;
+ struct song *song = (struct song *)data;
song_free(song);
}
@@ -190,9 +195,9 @@ song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
static void
rss_parser_destroy(gpointer data)
{
- struct rss_parser *parser = data;
+ RssParser *parser = (RssParser *)data;
- if (parser->state >= ITEM)
+ if (parser->state >= RssParser::ITEM)
song_free(parser->song);
g_slist_foreach(parser->songs, song_free_callback, NULL);
@@ -204,7 +209,7 @@ rss_parser_destroy(gpointer data)
*
*/
-struct rss_playlist {
+struct RssPlaylist {
struct playlist_provider base;
GSList *songs;
@@ -213,11 +218,8 @@ struct rss_playlist {
static struct playlist_provider *
rss_open_stream(struct input_stream *is)
{
- struct rss_parser parser = {
- .songs = NULL,
- .state = ROOT,
- };
- struct rss_playlist *playlist;
+ RssParser parser;
+ RssPlaylist *playlist;
GMarkupParseContext *context;
char buffer[1024];
size_t nbytes;
@@ -264,7 +266,7 @@ rss_open_stream(struct input_stream *is)
/* create a #rss_playlist object from the parsed song list */
- playlist = g_new(struct rss_playlist, 1);
+ playlist = g_new(RssPlaylist, 1);
playlist_provider_init(&playlist->base, &rss_playlist_plugin);
playlist->songs = g_slist_reverse(parser.songs);
parser.songs = NULL;
@@ -277,7 +279,7 @@ rss_open_stream(struct input_stream *is)
static void
rss_close(struct playlist_provider *_playlist)
{
- struct rss_playlist *playlist = (struct rss_playlist *)_playlist;
+ RssPlaylist *playlist = (RssPlaylist *)_playlist;
g_slist_foreach(playlist->songs, song_free_callback, NULL);
g_slist_free(playlist->songs);
@@ -287,13 +289,12 @@ rss_close(struct playlist_provider *_playlist)
static struct song *
rss_read(struct playlist_provider *_playlist)
{
- struct rss_playlist *playlist = (struct rss_playlist *)_playlist;
- struct song *song;
+ RssPlaylist *playlist = (RssPlaylist *)_playlist;
if (playlist->songs == NULL)
return NULL;
- song = playlist->songs->data;
+ struct song *song = (struct song *)playlist->songs->data;
playlist->songs = g_slist_remove(playlist->songs, song);
return song;
@@ -311,12 +312,16 @@ static const char *const rss_mime_types[] = {
};
const struct playlist_plugin rss_playlist_plugin = {
- .name = "rss",
+ "rss",
- .open_stream = rss_open_stream,
- .close = rss_close,
- .read = rss_read,
+ nullptr,
+ nullptr,
+ nullptr,
+ rss_open_stream,
+ rss_close,
+ rss_read,
- .suffixes = rss_suffixes,
- .mime_types = rss_mime_types,
+ nullptr,
+ rss_suffixes,
+ rss_mime_types,
};
diff --git a/src/playlist/rss_playlist_plugin.h b/src/playlist/RssPlaylistPlugin.hxx
index 3b376de79..f49f7e9cf 100644
--- a/src/playlist/rss_playlist_plugin.h
+++ b/src/playlist/RssPlaylistPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PLAYLIST_RSS_PLAYLIST_PLUGIN_H
-#define MPD_PLAYLIST_RSS_PLAYLIST_PLUGIN_H
+#ifndef MPD_RSS_PLAYLIST_PLUGIN_HXX
+#define MPD_RSS_PLAYLIST_PLUGIN_HXX
extern const struct playlist_plugin rss_playlist_plugin;
diff --git a/src/playlist/SoundCloudPlaylistPlugin.cxx b/src/playlist/SoundCloudPlaylistPlugin.cxx
index 71a2af6cd..fd2a99c6a 100644
--- a/src/playlist/SoundCloudPlaylistPlugin.cxx
+++ b/src/playlist/SoundCloudPlaylistPlugin.cxx
@@ -19,9 +19,9 @@
#include "config.h"
#include "SoundCloudPlaylistPlugin.hxx"
+#include "PlaylistPlugin.hxx"
#include "conf.h"
#include "input_stream.h"
-#include "playlist_plugin.h"
#include "song.h"
#include "tag.h"
diff --git a/src/playlist/xspf_playlist_plugin.c b/src/playlist/XspfPlaylistPlugin.cxx
index 17d9040e2..95033d4e8 100644
--- a/src/playlist/xspf_playlist_plugin.c
+++ b/src/playlist/XspfPlaylistPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,8 +18,8 @@
*/
#include "config.h"
-#include "playlist/xspf_playlist_plugin.h"
-#include "playlist_plugin.h"
+#include "XspfPlaylistPlugin.hxx"
+#include "PlaylistPlugin.hxx"
#include "input_stream.h"
#include "uri.h"
#include "song.h"
@@ -36,7 +36,7 @@
/**
* This is the state object for the GLib XML parser.
*/
-struct xspf_parser {
+struct XspfParser {
/**
* The list of songs (in reverse order because that's faster
* while adding).
@@ -63,6 +63,9 @@ struct xspf_parser {
* element.
*/
struct song *song;
+
+ XspfParser()
+ :songs(nullptr), state(ROOT) {}
};
static void
@@ -72,33 +75,33 @@ xspf_start_element(G_GNUC_UNUSED GMarkupParseContext *context,
G_GNUC_UNUSED const gchar **attribute_values,
gpointer user_data, G_GNUC_UNUSED GError **error)
{
- struct xspf_parser *parser = user_data;
+ XspfParser *parser = (XspfParser *)user_data;
switch (parser->state) {
- case ROOT:
+ case XspfParser::ROOT:
if (strcmp(element_name, "playlist") == 0)
- parser->state = PLAYLIST;
+ parser->state = XspfParser::PLAYLIST;
break;
- case PLAYLIST:
+ case XspfParser::PLAYLIST:
if (strcmp(element_name, "trackList") == 0)
- parser->state = TRACKLIST;
+ parser->state = XspfParser::TRACKLIST;
break;
- case TRACKLIST:
+ case XspfParser::TRACKLIST:
if (strcmp(element_name, "track") == 0) {
- parser->state = TRACK;
+ parser->state = XspfParser::TRACK;
parser->song = NULL;
parser->tag = TAG_NUM_OF_ITEM_TYPES;
}
break;
- case TRACK:
+ case XspfParser::TRACK:
if (strcmp(element_name, "location") == 0)
- parser->state = LOCATION;
+ parser->state = XspfParser::LOCATION;
else if (strcmp(element_name, "title") == 0)
parser->tag = TAG_TITLE;
else if (strcmp(element_name, "creator") == 0)
@@ -114,7 +117,7 @@ xspf_start_element(G_GNUC_UNUSED GMarkupParseContext *context,
break;
- case LOCATION:
+ case XspfParser::LOCATION:
break;
}
}
@@ -124,38 +127,38 @@ xspf_end_element(G_GNUC_UNUSED GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data, G_GNUC_UNUSED GError **error)
{
- struct xspf_parser *parser = user_data;
+ XspfParser *parser = (XspfParser *)user_data;
switch (parser->state) {
- case ROOT:
+ case XspfParser::ROOT:
break;
- case PLAYLIST:
+ case XspfParser::PLAYLIST:
if (strcmp(element_name, "playlist") == 0)
- parser->state = ROOT;
+ parser->state = XspfParser::ROOT;
break;
- case TRACKLIST:
+ case XspfParser::TRACKLIST:
if (strcmp(element_name, "tracklist") == 0)
- parser->state = PLAYLIST;
+ parser->state = XspfParser::PLAYLIST;
break;
- case TRACK:
+ case XspfParser::TRACK:
if (strcmp(element_name, "track") == 0) {
if (parser->song != NULL)
parser->songs = g_slist_prepend(parser->songs,
parser->song);
- parser->state = TRACKLIST;
+ parser->state = XspfParser::TRACKLIST;
} else
parser->tag = TAG_NUM_OF_ITEM_TYPES;
break;
- case LOCATION:
- parser->state = TRACK;
+ case XspfParser::LOCATION:
+ parser->state = XspfParser::TRACK;
break;
}
}
@@ -165,15 +168,15 @@ xspf_text(G_GNUC_UNUSED GMarkupParseContext *context,
const gchar *text, gsize text_len,
gpointer user_data, G_GNUC_UNUSED GError **error)
{
- struct xspf_parser *parser = user_data;
+ XspfParser *parser = (XspfParser *)user_data;
switch (parser->state) {
- case ROOT:
- case PLAYLIST:
- case TRACKLIST:
+ case XspfParser::ROOT:
+ case XspfParser::PLAYLIST:
+ case XspfParser::TRACKLIST:
break;
- case TRACK:
+ case XspfParser::TRACK:
if (parser->song != NULL &&
parser->tag != TAG_NUM_OF_ITEM_TYPES) {
if (parser->song->tag == NULL)
@@ -184,7 +187,7 @@ xspf_text(G_GNUC_UNUSED GMarkupParseContext *context,
break;
- case LOCATION:
+ case XspfParser::LOCATION:
if (parser->song == NULL) {
char *uri = g_strndup(text, text_len);
parser->song = song_remote_new(uri);
@@ -196,15 +199,17 @@ xspf_text(G_GNUC_UNUSED GMarkupParseContext *context,
}
static const GMarkupParser xspf_parser = {
- .start_element = xspf_start_element,
- .end_element = xspf_end_element,
- .text = xspf_text,
+ xspf_start_element,
+ xspf_end_element,
+ xspf_text,
+ nullptr,
+ nullptr,
};
static void
song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
- struct song *song = data;
+ struct song *song = (struct song *)data;
song_free(song);
}
@@ -212,9 +217,9 @@ song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data)
static void
xspf_parser_destroy(gpointer data)
{
- struct xspf_parser *parser = data;
+ XspfParser *parser = (XspfParser *)data;
- if (parser->state >= TRACK && parser->song != NULL)
+ if (parser->state >= XspfParser::TRACK && parser->song != NULL)
song_free(parser->song);
g_slist_foreach(parser->songs, song_free_callback, NULL);
@@ -226,7 +231,7 @@ xspf_parser_destroy(gpointer data)
*
*/
-struct xspf_playlist {
+struct XspfPlaylist {
struct playlist_provider base;
GSList *songs;
@@ -235,11 +240,8 @@ struct xspf_playlist {
static struct playlist_provider *
xspf_open_stream(struct input_stream *is)
{
- struct xspf_parser parser = {
- .songs = NULL,
- .state = ROOT,
- };
- struct xspf_playlist *playlist;
+ XspfParser parser;
+ XspfPlaylist *playlist;
GMarkupParseContext *context;
char buffer[1024];
size_t nbytes;
@@ -286,7 +288,7 @@ xspf_open_stream(struct input_stream *is)
/* create a #xspf_playlist object from the parsed song list */
- playlist = g_new(struct xspf_playlist, 1);
+ playlist = g_new(XspfPlaylist, 1);
playlist_provider_init(&playlist->base, &xspf_playlist_plugin);
playlist->songs = g_slist_reverse(parser.songs);
parser.songs = NULL;
@@ -299,7 +301,7 @@ xspf_open_stream(struct input_stream *is)
static void
xspf_close(struct playlist_provider *_playlist)
{
- struct xspf_playlist *playlist = (struct xspf_playlist *)_playlist;
+ XspfPlaylist *playlist = (XspfPlaylist *)_playlist;
g_slist_foreach(playlist->songs, song_free_callback, NULL);
g_slist_free(playlist->songs);
@@ -309,13 +311,12 @@ xspf_close(struct playlist_provider *_playlist)
static struct song *
xspf_read(struct playlist_provider *_playlist)
{
- struct xspf_playlist *playlist = (struct xspf_playlist *)_playlist;
- struct song *song;
+ XspfPlaylist *playlist = (XspfPlaylist *)_playlist;
if (playlist->songs == NULL)
return NULL;
- song = playlist->songs->data;
+ struct song *song = (struct song *)playlist->songs->data;
playlist->songs = g_slist_remove(playlist->songs, song);
return song;
@@ -332,12 +333,16 @@ static const char *const xspf_mime_types[] = {
};
const struct playlist_plugin xspf_playlist_plugin = {
- .name = "xspf",
+ "xspf",
- .open_stream = xspf_open_stream,
- .close = xspf_close,
- .read = xspf_read,
+ nullptr,
+ nullptr,
+ nullptr,
+ xspf_open_stream,
+ xspf_close,
+ xspf_read,
- .suffixes = xspf_suffixes,
- .mime_types = xspf_mime_types,
+ nullptr,
+ xspf_suffixes,
+ xspf_mime_types,
};
diff --git a/src/playlist/xspf_playlist_plugin.h b/src/playlist/XspfPlaylistPlugin.hxx
index 4636d7e83..fc9bbd2c6 100644
--- a/src/playlist/xspf_playlist_plugin.h
+++ b/src/playlist/XspfPlaylistPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PLAYLIST_XSPF_PLAYLIST_PLUGIN_H
-#define MPD_PLAYLIST_XSPF_PLAYLIST_PLUGIN_H
+#ifndef MPD_XSPF_PLAYLIST_PLUGIN_HXX
+#define MPD_XSPF_PLAYLIST_PLUGIN_HXX
extern const struct playlist_plugin xspf_playlist_plugin;