X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=servport.c;h=a775c9c93f2562070be1d4a5da2bb07145b25c28;hb=a23a8cf8ee1da51c4392b9f52e6b72b0c01e3b5e;hp=4d0fe510ed4164e480d1ec6f986c068475cf55c9;hpb=47b40b940159a43557286fdb5ab0db74d4dcc93e;p=~andy%2Ffetchmail diff --git a/servport.c b/servport.c index 4d0fe510..a775c9c9 100644 --- a/servport.c +++ b/servport.c @@ -1,25 +1,21 @@ /** \file servport.c Resolve service name to port number. * \author Matthias Andree - * \date 2005 + * \date 2005 - 2006 * * Copyright (C) 2005 by Matthias Andree * For license terms, see the file COPYING in this directory. */ #include "fetchmail.h" #include "getaddrinfo.h" -#include "i18n.h" +#include "gettext.h" #include #include #include #include #include -#if defined(HAVE_NETINET_IN_H) #include -#endif -#ifdef HAVE_ARPA_INET_H #include -#endif #include int servport(const char *service) { @@ -47,7 +43,8 @@ int servport(const char *service) { memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - e = getaddrinfo(NULL, service, &hints, &res); + hints.ai_protocol = IPPROTO_TCP; + e = fm_getaddrinfo(NULL, service, &hints, &res); if (e) { report(stderr, GT_("getaddrinfo(NULL, \"%s\") error: %s\n"), service, gai_strerror(e)); @@ -56,14 +53,17 @@ int servport(const char *service) { switch(res->ai_addr->sa_family) { case AF_INET: port = ntohs(((struct sockaddr_in *)res->ai_addr)->sin_port); + break; #ifdef AF_INET6 case AF_INET6: port = ntohs(((struct sockaddr_in6 *)res->ai_addr)->sin6_port); + break; #endif default: + fm_freeaddrinfo(res); goto err; } - freeaddrinfo(res); + fm_freeaddrinfo(res); } } else { if (u == 0 || u > 65535)