aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-16 19:11:39 +0200
committerMax Kellermann <max@duempel.org>2008-09-16 19:11:39 +0200
commitac9b642dde4c63f35936d19ed937481bc73f8db4 (patch)
tree377cc9e6a412172389897e5922aefc384c05b3d9 /src
parent8135d7dbf86043fb5f4e960ef4d976e4908631f3 (diff)
downloadmpd-ac9b642dde4c63f35936d19ed937481bc73f8db4.tar.gz
mpd-ac9b642dde4c63f35936d19ed937481bc73f8db4.tar.xz
mpd-ac9b642dde4c63f35936d19ed937481bc73f8db4.zip
song: use struct mpd_song
Use a forward declared struct mpd_song instead of the typedef mpd_Song.
Diffstat (limited to '')
-rw-r--r--src/mpdclient.c54
-rw-r--r--src/mpdclient.h12
-rw-r--r--src/song.c14
-rw-r--r--src/song.h8
4 files changed, 44 insertions, 44 deletions
diff --git a/src/mpdclient.c b/src/mpdclient.c
index bf18a1c3b..c57005165 100644
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
@@ -163,7 +163,7 @@ mpdclient_new(void)
mpdclient_t *c;
c = g_malloc0(sizeof(mpdclient_t));
- c->playlist.list = g_array_sized_new(FALSE, FALSE, sizeof(mpd_Song *), 1024);
+ c->playlist.list = g_array_sized_new(FALSE, FALSE, sizeof(struct mpd_song *), 1024);
return c;
}
@@ -278,7 +278,7 @@ gint
mpdclient_cmd_play(mpdclient_t *c, gint idx)
{
#ifdef ENABLE_SONG_ID
- mpd_Song *song = playlist_get_song(c, idx);
+ struct mpd_song *song = playlist_get_song(c, idx);
D("Play id:%d\n", song ? song->id : -1);
if (song)
@@ -405,7 +405,7 @@ mpdclient_cmd_add_path(mpdclient_t *c, gchar *path)
}
gint
-mpdclient_cmd_add(mpdclient_t *c, mpd_Song *song)
+mpdclient_cmd_add(mpdclient_t *c, struct mpd_song *song)
{
gint retval = 0;
@@ -438,7 +438,7 @@ gint
mpdclient_cmd_delete(mpdclient_t *c, gint idx)
{
gint retval = 0;
- mpd_Song *song = playlist_get_song(c, idx);
+ struct mpd_song *song = playlist_get_song(c, idx);
if( !song )
return -1;
@@ -483,7 +483,7 @@ gint
mpdclient_cmd_move(mpdclient_t *c, gint old_index, gint new_index)
{
gint n;
- mpd_Song *song1, *song2;
+ struct mpd_song *song1, *song2;
if (old_index == new_index || new_index < 0 ||
(guint)new_index >= c->playlist.list->len)
@@ -509,8 +509,8 @@ mpdclient_cmd_move(mpdclient_t *c, gint old_index, gint new_index)
song1->pos = song2->pos;
song2->pos = n;
/* update the array */
- g_array_index(c->playlist.list, mpd_Song *, old_index) = song2;
- g_array_index(c->playlist.list, mpd_Song *, new_index) = song1;
+ g_array_index(c->playlist.list, struct mpd_song *, old_index) = song2;
+ g_array_index(c->playlist.list, struct mpd_song *, new_index) = song1;
/* increment the playlist id, so we dont retrives a new playlist */
c->playlist.id++;
@@ -653,7 +653,7 @@ mpdclient_playlist_free(mpdclient_playlist_t *playlist)
guint i;
for (i = 0; i < playlist->list->len; ++i) {
- mpd_Song *song = g_array_index(playlist->list, mpd_Song *, i);
+ struct mpd_song *song = g_array_index(playlist->list, struct mpd_song *, i);
mpd_freeSong(song);
}
@@ -679,7 +679,7 @@ mpdclient_playlist_update(mpdclient_t *c)
mpd_sendPlaylistInfoCommand(c->connection,-1);
while ((entity = mpd_getNextInfoEntity(c->connection))) {
if (entity->type == MPD_INFO_ENTITY_TYPE_SONG) {
- mpd_Song *song = mpd_songDup(entity->info.song);
+ struct mpd_song *song = mpd_songDup(entity->info.song);
g_array_append_val(c->playlist.list, song);
}
mpd_freeInfoEntity(entity);
@@ -712,16 +712,16 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
mpd_sendPlChangesCommand(c->connection, c->playlist.id);
while ((entity = mpd_getNextInfoEntity(c->connection)) != NULL) {
- mpd_Song *song = mpd_songDup(entity->info.song);
+ struct mpd_song *song = mpd_songDup(entity->info.song);
if (song->pos >= 0 && (guint)song->pos < c->playlist.list->len) {
/* update song */
D("updating pos:%d, id=%d - %s\n",
song->pos, song->id, song->file);
mpd_freeSong(g_array_index(c->playlist.list,
- mpd_Song *, song->pos));
+ struct mpd_song *, song->pos));
g_array_index(c->playlist.list,
- mpd_Song *, song->pos) = song;
+ struct mpd_song *, song->pos) = song;
} else {
/* add a new song */
D("adding song at pos %d\n", song->pos);
@@ -734,7 +734,7 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
/* remove trailing songs */
while ((guint)c->status->playlistLength < c->playlist.list->len) {
guint pos = c->playlist.list->len - 1;
- mpd_Song *song = g_array_index(c->playlist.list, mpd_Song *, pos);
+ struct mpd_song *song = g_array_index(c->playlist.list, struct mpd_song *, pos);
/* Remove the last playlist entry */
D("removing song at pos %d\n", pos);
@@ -759,23 +759,23 @@ mpdclient_playlist_update_changes(mpdclient_t *c)
}
#endif
-mpd_Song *
+struct mpd_song *
playlist_get_song(mpdclient_t *c, gint idx)
{
if (idx < 0 || (guint)idx >= c->playlist.list->len)
return NULL;
- return g_array_index(c->playlist.list, mpd_Song *, idx);
+ return g_array_index(c->playlist.list, struct mpd_song *, idx);
}
-mpd_Song *
+struct mpd_song *
playlist_lookup_song(mpdclient_t *c, gint id)
{
guint i;
for (i = 0; i < c->playlist.list->len; ++i) {
- mpd_Song *song = g_array_index(c->playlist.list,
- mpd_Song *, i);
+ struct mpd_song *song = g_array_index(c->playlist.list,
+ struct mpd_song *, i);
if (song->id == id)
return song;
}
@@ -784,12 +784,12 @@ playlist_lookup_song(mpdclient_t *c, gint id)
}
gint
-playlist_get_index(mpdclient_t *c, mpd_Song *song)
+playlist_get_index(mpdclient_t *c, struct mpd_song *song)
{
guint i;
for (i = 0; i < c->playlist.list->len; ++i) {
- if (g_array_index(c->playlist.list, mpd_Song *, i)
+ if (g_array_index(c->playlist.list, struct mpd_song *, i)
== song)
return (gint)i;
}
@@ -803,8 +803,8 @@ playlist_get_index_from_id(mpdclient_t *c, gint id)
guint i;
for (i = 0; i < c->playlist.list->len; ++i) {
- mpd_Song *song = g_array_index(c->playlist.list,
- mpd_Song *, i);
+ struct mpd_song *song = g_array_index(c->playlist.list,
+ struct mpd_song *, i);
if (song->id == id)
return (gint)i;
}
@@ -818,8 +818,8 @@ playlist_get_index_from_file(mpdclient_t *c, gchar *filename)
guint i;
for (i = 0; i < c->playlist.list->len; ++i) {
- mpd_Song *song = g_array_index(c->playlist.list,
- mpd_Song *, i);
+ struct mpd_song *song = g_array_index(c->playlist.list,
+ struct mpd_song *, i);
if(strcmp(song->file, filename) == 0)
return (gint)i;
}
@@ -978,7 +978,7 @@ mpdclient_filelist_update(mpdclient_t *c, mpdclient_filelist_t *filelist)
}
filelist_entry_t *
-mpdclient_filelist_find_song(mpdclient_filelist_t *fl, mpd_Song *song)
+mpdclient_filelist_find_song(mpdclient_filelist_t *fl, struct mpd_song *song)
{
GList *list = g_list_first(fl->list);
@@ -989,7 +989,7 @@ mpdclient_filelist_find_song(mpdclient_filelist_t *fl, mpd_Song *song)
if( entity && entity->type==MPD_INFO_ENTITY_TYPE_SONG )
{
- mpd_Song *song2 = entity->info.song;
+ struct mpd_song *song2 = entity->info.song;
if( strcmp(song->file, song2->file) == 0 )
{
@@ -1017,7 +1017,7 @@ mpdclient_filelist_add_all(mpdclient_t *c, mpdclient_filelist_t *fl)
if( entity && entity->type==MPD_INFO_ENTITY_TYPE_SONG )
{
- mpd_Song *song = entity->info.song;
+ struct mpd_song *song = entity->info.song;
mpd_sendAddCommand(c->connection, song->file);
}
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 02ff92581..f1b993756 100644
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
@@ -93,7 +93,7 @@ gint mpdclient_cmd_volume(mpdclient_t *c, gint value);
gint mpdclient_cmd_add_path(mpdclient_t *c, gchar *path);
gint mpdclient_cmd_add_path_utf8(mpdclient_t *c, gchar *path);
-gint mpdclient_cmd_add(mpdclient_t *c, mpd_Song *song);
+gint mpdclient_cmd_add(mpdclient_t *c, struct mpd_song *song);
gint mpdclient_cmd_delete(mpdclient_t *c, gint index);
gint mpdclient_cmd_move(mpdclient_t *c, gint old_index, gint new_index);
@@ -127,9 +127,9 @@ gint mpdclient_playlist_update(mpdclient_t *c);
/* get playlist changes */
gint mpdclient_playlist_update_changes(mpdclient_t *c);
-mpd_Song *playlist_lookup_song(mpdclient_t *c, gint id);
-mpd_Song *playlist_get_song(mpdclient_t *c, gint index);
-gint playlist_get_index(mpdclient_t *c, mpd_Song *song);
+struct mpd_song *playlist_lookup_song(mpdclient_t *c, gint id);
+struct mpd_song *playlist_get_song(mpdclient_t *c, gint index);
+gint playlist_get_index(mpdclient_t *c, struct mpd_song *song);
gint playlist_get_index_from_id(mpdclient_t *c, gint id);
gint playlist_get_index_from_file(mpdclient_t *c, gchar *filename);
@@ -173,13 +173,13 @@ mpdclient_filelist_t *mpdclient_filelist_update(mpdclient_t *c,
#define HIGHLIGHT (0x01)
void mpdclient_filelist_set_flags(mpdclient_filelist_t *flist,
- mpd_Song *song,
+ struct mpd_song *song,
guint flags);
void mpdclient_filelist_clear_flags(mpdclient_filelist_t *flist);
void mpdclient_filelist_clear_flags(mpdclient_filelist_t *flist);
filelist_entry_t *mpdclient_filelist_find_song(mpdclient_filelist_t *flist,
- mpd_Song *song);
+ struct mpd_song *song);
/* add all songs in filelist to the playlist */
int mpdclient_filelist_add_all(mpdclient_t *c, mpdclient_filelist_t *fl);
diff --git a/src/song.c b/src/song.c
index 2d97daf7f..9090f8489 100644
--- a/src/song.c
+++ b/src/song.c
@@ -35,7 +35,7 @@
#include <stdlib.h>
-static void mpd_initSong(mpd_Song * song) {
+static void mpd_initSong(struct mpd_song *song) {
song->file = NULL;
song->artist = NULL;
song->album = NULL;
@@ -54,7 +54,7 @@ static void mpd_initSong(mpd_Song * song) {
song->id = MPD_SONG_NO_ID;
}
-static void mpd_finishSong(mpd_Song * song) {
+static void mpd_finishSong(struct mpd_song *song) {
if (song->file)
str_pool_put(song->file);
if (song->artist)
@@ -79,21 +79,21 @@ static void mpd_finishSong(mpd_Song * song) {
str_pool_put(song->comment);
}
-mpd_Song * mpd_newSong(void) {
- mpd_Song * ret = malloc(sizeof(mpd_Song));
+struct mpd_song *mpd_newSong(void) {
+ struct mpd_song *ret = malloc(sizeof(*ret));
mpd_initSong(ret);
return ret;
}
-void mpd_freeSong(mpd_Song * song) {
+void mpd_freeSong(struct mpd_song *song) {
mpd_finishSong(song);
free(song);
}
-mpd_Song * mpd_songDup(const mpd_Song * song) {
- mpd_Song * ret = mpd_newSong();
+struct mpd_song *mpd_songDup(const struct mpd_song *song) {
+ struct mpd_song *ret = mpd_newSong();
if (song->file)
ret->file = str_pool_dup(song->file);
diff --git a/src/song.h b/src/song.h
index e618a47de..e3ad7e959 100644
--- a/src/song.h
+++ b/src/song.h
@@ -41,7 +41,7 @@
/* mpd_Song
* for storing song info returned by mpd
*/
-typedef struct _mpd_Song {
+typedef struct mpd_song {
/* filename of song */
char * file;
/* artist, maybe NULL if there is no tag */
@@ -85,17 +85,17 @@ typedef struct _mpd_Song {
* use mpd_freeSong to free the memory for the mpd_Song, it will also
* free memory for file, artist, etc, so don't do it yourself
*/
-mpd_Song * mpd_newSong(void);
+struct mpd_song *mpd_newSong(void);
/* mpd_freeSong
* use to free memory allocated by mpd_newSong
* also it will free memory pointed to by file, artist, etc, so be careful
*/
-void mpd_freeSong(mpd_Song * song);
+void mpd_freeSong(struct mpd_song *song);
/* mpd_songDup
* works like strDup, but for a mpd_Song
*/
-mpd_Song * mpd_songDup(const mpd_Song * song);
+struct mpd_song *mpd_songDup(const struct mpd_song *song);
#endif