summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <bousset.rudy@gmail.com>2022-07-03 03:11:57 +0200
committerJoe <bousset.rudy@gmail.com>2022-07-03 03:11:57 +0200
commit051b6d160f1a0e474e7c286dbac1b55bb4d8e025 (patch)
treee959b2d1ad3855f51dc6165ec24af6333c9dc95f
parentFix (diff)
downloadmpdview-051b6d160f1a0e474e7c286dbac1b55bb4d8e025.tar.gz
mpdview-051b6d160f1a0e474e7c286dbac1b55bb4d8e025.tar.bz2
mpdview-051b6d160f1a0e474e7c286dbac1b55bb4d8e025.tar.xz
mpdview-051b6d160f1a0e474e7c286dbac1b55bb4d8e025.tar.zst
mpdview-051b6d160f1a0e474e7c286dbac1b55bb4d8e025.zip
WIP
-rw-r--r--Makefile1
-rw-r--r--src/c_mpdview.c26
2 files changed, 24 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 03337fe..abaf3aa 100644
--- a/Makefile
+++ b/Makefile
@@ -43,6 +43,7 @@ CFLAGS += -Wextra
CFLAGS += -Werror
CFLAGS += -pedantic
CFLAGS += -isystem/usr/local/include
+CFLAGS += -glldb
# CFLAGS += -march=native -O2 -pipe
LDFLAGS := -L/usr/local/lib
diff --git a/src/c_mpdview.c b/src/c_mpdview.c
index 03e46e6..9287f00 100644
--- a/src/c_mpdview.c
+++ b/src/c_mpdview.c
@@ -39,12 +39,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* mpdview: src/c_mpdview.c
- * Mon, 27 Jun 2022 21:48:06 +0200
+ * Sun, 03 Jul 2022 02:19:55 +0200
* Joe
*
* This is the entrypoint of the program.
*/
+#include <mpd/status.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -62,16 +63,35 @@ main
const char* envp[])
{
struct mpd_connection* conn;
+ struct mpd_status* status;
+ /* struct mpd_song* song; */
+ enum mpd_state state;
(void)argc;
(void)argv;
(void)envp;
- conn = mpd_connection_new("localhost", 6600, 3000);
+ state = MPD_STATE_UNKNOWN;
+ conn = mpd_connection_new(NULL, 6600, 3000);
if (mpd_connection_get_error(conn) != MPD_ERROR_SUCCESS) {
dprintf(STDERR_FILENO, "%s: %s\n", PROGNAME, mpd_connection_get_error_message(conn));
+ if (conn != NULL) {
+ mpd_connection_free(conn);
+ }
+ conn = NULL;
return (EXIT_FAILURE);
}
- mpd_connection_free(conn);
+ mpd_command_list_begin(conn, TRUE);
+ mpd_send_status(conn);
+ mpd_command_list_end(conn);
+ status = mpd_recv_status(conn);
+ state = mpd_status_get_state(status);
+ mpd_status_free(status);
+ status = NULL;
+ if (state == MPD_STATE_PLAY || state == MPD_STATE_PAUSE) {
+ }
+ if (conn != NULL) {
+ mpd_connection_free(conn);
+ }
conn = NULL;
return (EXIT_SUCCESS);
}