aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_mpd.c
diff options
context:
space:
mode:
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2007-07-27 10:01:17 +0000
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2007-07-27 10:01:17 +0000
commit1c822162c25c02121b89f0b226e38c6b1e7d207b (patch)
tree6b4a801ccebb7fe96f83406509dacb8e960f1527 /plugin_mpd.c
parent63194435c3760ea232a3dcb75c7f843e8b1a9055 (diff)
downloadlcd4linux-1c822162c25c02121b89f0b226e38c6b1e7d207b.tar.gz
MPD plugin patch from michu
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@832 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'plugin_mpd.c')
-rw-r--r--plugin_mpd.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/plugin_mpd.c b/plugin_mpd.c
index d101ed9..5a950c8 100644
--- a/plugin_mpd.c
+++ b/plugin_mpd.c
@@ -5,6 +5,7 @@
*
* Copyright (C) 2006 Stefan Kuhne <sk-privat@gmx.net>
* Copyright (C) 2007 Robert Buchholz <rbu@gentoo.org>
+ * Copyright (C) 2007 Michael Vogt <michu@neophob.com>
* Copyright (C) 2006 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
* This file is part of LCD4Linux.
@@ -258,7 +259,27 @@ static int mpd_get(int function)
int ret = -1;
MpdObj *mi = NULL;
- mi = mpd_new("localhost", 6600, NULL);
+ char *host = "localhost";
+ char *port = "6600";
+ int iport;
+ char *test;
+
+ if ((test = getenv("MPD_HOST"))) {
+ host = test;
+ }
+
+ if ((test = getenv("MPD_PORT"))) {
+ port = test;
+ }
+
+ iport = strtol(port, &test, 10);
+
+ if ((iport < 0) || (*test != '\0')) {
+ fprintf(stderr, "[MPD] MPD_PORT \"%s\" is not a positive integer\n", port);
+ exit(EXIT_FAILURE);
+ }
+
+ mi = mpd_new(host, iport, NULL);
mpd_signal_connect_error(mi, (ErrorCallback) error_callback, NULL);
mpd_set_connection_timeout(mi, 5);