From b4c27011d20196aeeb104edb3c2e3dd97861e8d8 Mon Sep 17 00:00:00 2001 From: Kalle Wallin Date: Mon, 29 Mar 2004 18:09:38 +0000 Subject: Added password support. git-svn-id: https://svn.musicpd.org/ncmpc/trunk@534 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- mpc.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'mpc.c') diff --git a/mpc.c b/mpc.c index 785117fc9..00a044462 100644 --- a/mpc.c +++ b/mpc.c @@ -63,7 +63,7 @@ mpc_close(mpd_client_t *c) } mpd_client_t * -mpc_connect(char *host, int port) +mpc_connect(char *host, int port, char *password) { mpd_Connection *connection; mpd_client_t *c; @@ -80,11 +80,17 @@ mpc_connect(char *host, int port) c->connection = connection; c->cwd = g_strdup(""); + if( password ) + { + mpd_sendPasswordCommand(connection, password); + mpd_finishCommand(connection); + } + return c; } int -mpc_reconnect(mpd_client_t *c, char *host, int port) +mpc_reconnect(mpd_client_t *c, char *host, int port, char *password) { mpd_Connection *connection; @@ -99,6 +105,12 @@ mpc_reconnect(mpd_client_t *c, char *host, int port) c->connection = connection; + if( password ) + { + mpd_sendPasswordCommand(connection, password); + mpd_finishCommand(connection); + } + return 0; } @@ -109,7 +121,7 @@ mpc_error(mpd_client_t *c) if( c == NULL || c->connection == NULL ) return 1; if( c->connection->error ) - return 1; + return c->connection->error; return 0; } -- cgit v1.2.3