[mpd-devel] [PATCHv4 1/2] settings: support service names in MPD_PORT variable

2014-12-03 Thread Michal Nazarewicz
From: Michal Nazarewicz min...@mina86.com

If $MPD_PORT is not a number, i.e. does not start with a digit,
attempt to resolve it using getservbyname, i.e. by reading the
/etc/services database.
 src/settings.c | 33 -
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/settings.c b/src/settings.c
index f2799df..f153452 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -30,9 +30,20 @@
 #include config.h
 #include assert.h
+#include ctype.h
 #include string.h
 #include stdlib.h
+#ifdef ENABLE_TCP
+#  ifdef WIN32
+#include winsock2.h
+#  else
+#include arpa/inet.h
+#include netdb.h
+#include netinet/in.h
+#  endif
 struct mpd_settings {
char *host;
@@ -100,6 +111,26 @@ mpd_check_host(const char *host, char **password_r)
+ * Parse port number (which can be a service name).
+ */
+static unsigned
+mpd_parse_port(const char *str)
+   if (!*str)
+   return 0;
+   if (isdigit(str[0]))
+   return atoi(str);
+#ifdef ENABLE_TCP
+   struct servent *servent = getservbyname(str, tcp);
+   if (servent)
+   return ntohs(servent-s_port);
+   return 0;
  * Parses the port specification.  If not specified (0), it attempts
  * to load it from the environment variable MPD_PORT.
@@ -109,7 +140,7 @@ mpd_check_port(unsigned port)
if (port == 0) {
const char *env_port = getenv(MPD_PORT);
if (env_port != NULL)
-   port = atoi(env_port);
+   port = mpd_parse_port(env_port);
return port;

mpd-devel mailing list

Re: [mpd-devel] PATCH: Add support for configuration specified optional headers in HTTP output plugins

2014-12-03 Thread Max Kellermann
On 2014/12/03 22:00, X Ryl boite.pour.s...@gmail.com wrote:
 Please find attached a new patch, with your other remarks fixed.

How is this change related to your patch description?

-#  encoder vorbis# optional, vorbis or lame
+#  encoder vorbis# optional, vorbis or lame or 
any encoder (use mpd --verbose to get a list)

This is the very first thing I see in your patch file.

Still no documentation, and still no reason why this feature is
useful.  I don't like it at all, and the commit message needs to
convince me.
mpd-devel mailing list

Re: [mpd-devel] systemd and zeroconf: No global port, disabling zeroconf

2014-12-03 Thread Punky
Thanks Max,

Thus, MPD currently does not enable zeroconf when socket activation is
 used, because MPD does not know what port to announce.

I understand this now.

 systemd would activate the socket on behalf of the service because you
 told it to.  It is optional, and you enabled it (systemctl enable
 mpd.socket instead of systemctl enable mpd.service).

So to make zeroconf works under systemd, I need to systemctl disable
mpd.socket then systemctl enable mpd.service and systemctl restart
mpd.service.  Zeroconf works again.


Kim-man Punky Tse

* Open Source Embedded Solutions and Systems
  - Voyage Linux (http://linux.voyage.hk)
  - Voyage MPD   (http://linux.voyage.hk/voyage-mpd)
  - Voyage MuBox (http://mubox.voyage.hk)
* Voyage Store   (http://store.voyage.hk)
mpd-devel mailing list