From 1c822162c25c02121b89f0b226e38c6b1e7d207b Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 27 Jul 2007 10:01:17 +0000 Subject: MPD plugin patch from michu git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@832 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- plugin_mpd.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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 * Copyright (C) 2007 Robert Buchholz + * Copyright (C) 2007 Michael Vogt * Copyright (C) 2006 The LCD4Linux Team * * 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); -- cgit v1.2.3