Make perform_getaddrinfo static
[pazpar2-moved-to-github.git] / src / getaddrinfo.c
index a5f6a3a..a815e33 100644 (file)
@@ -34,14 +34,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <sys/socket.h>
 #endif
 #ifdef WIN32
-#include <winsock.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
 #endif
 #if HAVE_NETDB_H
 #include <netdb.h>
 #endif
-#if HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
 
 #include <yaz/log.h>
 #include <yaz/nmem.h>
@@ -67,11 +65,11 @@ struct work {
 
 static int log_level = YLOG_LOG;
 
-void perform_getaddrinfo(struct work *w)
+static void perform_getaddrinfo(struct work *w)
 {
     struct addrinfo hints, *res;
     char host[512], *cp;
-    const char *port = 0;
+    char *port = 0;
     int error;
 
     hints.ai_flags = 0;
@@ -98,13 +96,14 @@ void perform_getaddrinfo(struct work *w)
     }
     else
     {
+        char n_host[512];
         if (getnameinfo((struct sockaddr *) res->ai_addr, res->ai_addrlen,
-                        host, sizeof(host)-1,
+                        n_host, sizeof(n_host)-1,
                         0, 0,
                         NI_NUMERICHOST) == 0)
         {
-            w->ipport = xmalloc(strlen(host) + (port ? strlen(port) : 0) + 2);
-            strcpy(w->ipport, host);
+            w->ipport = xmalloc(strlen(n_host) + (port ? strlen(port) : 0) + 2);
+            strcpy(w->ipport, n_host);
             if (port)
             {
                 strcat(w->ipport, ":");