]> Pileus Git - ~andy/fetchmail/blobdiff - servport.c
Attempt merging from 6.3.24.
[~andy/fetchmail] / servport.c
index 01b8460729efe00e3a410075e1f5a452422e9b91..a775c9c93f2562070be1d4a5da2bb07145b25c28 100644 (file)
@@ -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 <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
 #include <netdb.h>
-#if defined(HAVE_NETINET_IN_H)
 #include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
-#endif
 #include <sys/socket.h>
 
 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));
@@ -63,9 +60,10 @@ int servport(const char *service) {
                break;
 #endif
                default:
+                   fm_freeaddrinfo(res);
                    goto err;
            }
-           freeaddrinfo(res);
+           fm_freeaddrinfo(res);
        }
     } else {
        if (u == 0 || u > 65535)