summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: affc465)
raw | patch | inline | side by side (parent: affc465)
author | Max Kellermann <max@duempel.org> | |
Sat, 17 Oct 2009 23:48:05 +0000 (01:48 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sat, 17 Oct 2009 23:48:05 +0000 (01:48 +0200) |
Merge some duplicate code.
src/mpdclient.c | patch | blob | history |
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 97cf78b3d19df3b341519cab5a7c9acd217b55f9..0d8c2baa3bed341708e043edf4a2fc97b89582ab 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
}
}
+static struct mpd_status *
+mpdclient_recv_status(struct mpdclient *c)
+{
+ struct mpd_status *status;
+
+ assert(c->connection != NULL);
+
+ status = mpd_recv_status(c->connection);
+ if (status == NULL) {
+ mpdclient_handle_error(c);
+ return NULL;
+ }
+
+ if (c->status != NULL)
+ mpd_status_free(c->status);
+ return c->status = status;
+}
/****************************************************************************/
/*** MPD Commands **********************************************************/
/* receive the new status, store it in the mpdclient struct */
- status = mpd_recv_status(connection);
+ status = mpdclient_recv_status(c);
if (status == NULL)
- return mpdclient_handle_error(c);
+ return false;
if (c->status != NULL)
mpd_status_free(c->status);
c->events |= MPD_IDLE_PLAYLIST;
- status = mpd_recv_status(connection);
- if (status != NULL) {
- if (c->status != NULL)
- mpd_status_free(c->status);
- c->status = status;
- }
+ status = mpdclient_recv_status(c);
+ if (status == NULL)
+ return false;
if (!mpd_response_next(connection))
return mpdclient_handle_error(c);
c->events |= MPD_IDLE_PLAYLIST;
- status = mpd_recv_status(connection);
- if (status != NULL) {
- if (c->status != NULL)
- mpd_status_free(c->status);
- c->status = status;
- }
+ status = mpdclient_recv_status(c);
+ if (status == NULL)
+ return false;
if (!mpd_response_finish(connection))
return mpdclient_handle_error(c);
c->events |= MPD_IDLE_PLAYLIST;
- status = mpd_recv_status(connection);
- if (status != NULL) {
- if (c->status != NULL)
- mpd_status_free(c->status);
- c->status = status;
- }
+ status = mpdclient_recv_status(c);
+ if (status == NULL)
+ return false;
if (!mpd_response_finish(connection))
return mpdclient_handle_error(c);
c->events |= MPD_IDLE_PLAYLIST;
- status = mpd_recv_status(connection);
- if (status != NULL) {
- if (c->status != NULL)
- mpd_status_free(c->status);
- c->status = status;
- }
+ status = mpdclient_recv_status(c);
+ if (status == NULL)
+ return false;
if (!mpd_response_finish(connection))
return mpdclient_handle_error(c);