> On 2014/12/03 21:13, Michal Nazarewicz <[email protected]> wrote:
>> 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.
On Wed, Dec 03 2014, Max Kellermann wrote:
> This now passes the build test, but I don't like how this adds
> unnecessary overhead to the non-TCP build.
>
> Instead of just "atoi(str)", the !ENABLE_TCP build does:
>
>> + if (!*str)
>> + return 0;
>> + if (isdigit(str[0]))
>> + return atoi(str);
>> +
>> + return 0;
>
> Now if you move the #ifdef, this gets eliminated easily.
I take this would be better received:
+static unsigned
+mpd_parse_port(const char *str)
+{
+#ifdef ENABLE_TCP
+ if (*str && !isdigit(*str)) {
+ struct servent *servent = getservbyname(str, "tcp");
+ if (servent)
+ return ntohs(servent->s_port);
+ }
+#endif
+ return atoi(str);
+}
On Wed, Dec 03 2014, Max Kellermann wrote:
> One more thing: I'd like to know what is the point of this patch.
> I mean, what is the practical use of being able to say
> "MPD_PORT=telnet"?
steve suggested authinfo parsing should accept named ports, so for
consistency I made $MPD_PORT accept them as well. I don't care about
this feature to be honest (either in $MPD_PORT or in authinfo file) and
am happy to do whatever you prefer.
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo--
_______________________________________________
mpd-devel mailing list
[email protected]
http://mailman.blarg.de/listinfo/mpd-devel