summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8135d7d)
raw | patch | inline | side by side (parent: 8135d7d)
author | Max Kellermann <max@duempel.org> | |
Tue, 16 Sep 2008 17:11:39 +0000 (19:11 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 16 Sep 2008 17:11:39 +0000 (19:11 +0200) |
Use a forward declared struct mpd_song instead of the typedef
mpd_Song.
mpd_Song.
src/mpdclient.c | patch | blob | history | |
src/mpdclient.h | patch | blob | history | |
src/song.c | patch | blob | history | |
src/song.h | patch | blob | history |
diff --git a/src/mpdclient.c b/src/mpdclient.c
index bf18a1c3b3bec7159b0eb9f82e954f50c8754218..c570051657443aaaa6b65138a9e450c37c8892a8 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
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;
}
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)
}
gint
-mpdclient_cmd_add(mpdclient_t *c, mpd_Song *song)
+mpdclient_cmd_add(mpdclient_t *c, struct mpd_song *song)
{
gint retval = 0;
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;
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)
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++;
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);
}
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);
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);
/* 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);
}
#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;
}
}
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;
}
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;
}
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;
}
}
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);
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 )
{
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 02ff92581686636351ccbe625982a49c66bc7544..f1b993756b2876d353838f6ff8e11fbc1466ce7f 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
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);
/* 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);
#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 2d97daf7fdb21f1907cf01a82227d763129a2da7..9090f8489c267e5cc5ca3c8b1bbd38422c3e326d 100644 (file)
--- a/src/song.c
+++ b/src/song.c
#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;
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)
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 e618a47de930943f01ad0937489bdce18874c6dc..e3ad7e95955bb01a1d0cc40fb991df1b79521599 100644 (file)
--- a/src/song.h
+++ b/src/song.h
/* 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 */
* 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