Imported Upstream version 2.6.1
[debian/amanda] / gnulib / getaddrinfo.c
index 1b6100d90ec5a0bb6ba4563d06a47dc7748e8d0f..b14f8096bd85463e5a34188af16fc31a9da0cd98 100644 (file)
@@ -5,7 +5,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -31,6 +31,9 @@
 /* Get memcpy, strdup. */
 #include <string.h>
 
+/* Get snprintf. */
+#include <stdio.h>
+
 #include <stdbool.h>
 
 #include "gettext.h"
@@ -38,7 +41,6 @@
 #define N_(String) String
 
 #include "inet_ntop.h"
-#include "snprintf.h"
 
 extern int h_errno;
 
@@ -121,10 +123,10 @@ validate_family (int family)
 /* Translate name of a service location and/or a service name to set of
    socket addresses. */
 int
-getaddrinfo (const char *restrict nodename,
-            const char *restrict servname,
-            const struct addrinfo *restrict hints,
-            struct addrinfo **restrict res)
+getaddrinfo (const char *nodename,
+            const char *servname,
+            const struct addrinfo *hints,
+            struct addrinfo **res)
 {
   struct addrinfo *tmp;
   int port = 0;
@@ -181,13 +183,11 @@ getaddrinfo (const char *restrict nodename,
     {
       struct servent *se = NULL;
       const char *proto =
-       (hints && (hints->ai_socktype == SOCK_DGRAM)) ? "udp" : "tcp";
+       (hints && hints->ai_socktype == SOCK_DGRAM) ? "udp" : "tcp";
 
-      if ((hints == NULL) || !(hints->ai_flags & AI_NUMERICSERV))
-        {
-         /* FIXME: Use getservbyname_r if available. */
-         se = getservbyname (servname, proto);
-        }
+      if (hints == NULL || !(hints->ai_flags & AI_NUMERICSERV))
+       /* FIXME: Use getservbyname_r if available. */
+       se = getservbyname (servname, proto);
 
       if (!se)
        {
@@ -332,14 +332,14 @@ freeaddrinfo (struct addrinfo *ai)
       cur = ai;
       ai = ai->ai_next;
 
-      if (cur->ai_canonname) free (cur->ai_canonname);
+      free (cur->ai_canonname);
       free (cur);
     }
 }
 
-int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
-               char *restrict node, socklen_t nodelen,
-               char *restrict service, socklen_t servicelen,
+int getnameinfo(const struct sockaddr *sa, socklen_t salen,
+               char *node, socklen_t nodelen,
+               char *service, socklen_t servicelen,
                int flags)
 {
 #ifdef WIN32_NATIVE