diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | src/c_mpdview.c | 26 |
2 files changed, 24 insertions, 3 deletions
@@ -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); } |