]> git.webhop.me Git - lcd4linux.git/commitdiff
MPD plugin patch from michu
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 27 Jul 2007 10:01:17 +0000 (10:01 +0000)
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 27 Jul 2007 10:01:17 +0000 (10:01 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@832 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

plugin_mpd.c

index d101ed955c6806fb249103b2bba7dfaaaf4575d7..5a950c8ba5645d6d2176e2b1a10481a724782b9b 100644 (file)
@@ -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);