Added -check/-nocheck switches to sortm(1). Also removed obsolete
[mmh] / sbr / client.c
index ae6968f..7ab49a9 100644 (file)
@@ -2,8 +2,6 @@
 /*
  * client.c -- connect to a server
  *
- * $Id$
- *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  * complete copyright information.
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netdb.h>
-
-#ifdef HAVE_ARPA_INET_H
-# include <arpa/inet.h>
-#endif
-
-#define        TRUE         1
-#define        FALSE        0
+#include <arpa/inet.h>
 
 #define        MAXARGS   1000
 
@@ -60,7 +52,9 @@ client (char *args, char *service, char *response, int len_response, int debug)
     }
 
     memset(&hints, 0, sizeof(hints));
+#ifdef AI_ADDRCONFIG
     hints.ai_flags = AI_ADDRCONFIG;
+#endif
     hints.ai_family = PF_UNSPEC;
     hints.ai_socktype = SOCK_STREAM;
 
@@ -85,7 +79,7 @@ client (char *args, char *service, char *response, int len_response, int debug)
                char address[NI_MAXHOST];
 
                rc = getnameinfo(ai->ai_addr, ai->ai_addrlen, address,
-                                sizeof(address), NULL, NULL, NI_NUMERICHOST);
+                                sizeof(address), NULL, 0, NI_NUMERICHOST);
 
                fprintf(stderr, "Connecting to %s...\n",
                        rc ? "unknown" : address);
@@ -101,7 +95,7 @@ client (char *args, char *service, char *response, int len_response, int debug)
 
            if (connect(sd, ai->ai_addr, ai->ai_addrlen) == 0) {
                freeaddrinfo(res);
-               client_freelist(ap);
+               client_freelist(arguments);
                return sd;
            }
 
@@ -111,10 +105,11 @@ client (char *args, char *service, char *response, int len_response, int debug)
 
            close(sd);
        }
+
+       freeaddrinfo(res);
     }
 
-    freeaddrinfo(res);
-    client_freelist(ap);
+    client_freelist(arguments);
     strncpy (response, "no servers available", len_response);
     return NOTOK;
 }
@@ -127,8 +122,7 @@ client (char *args, char *service, char *response, int len_response, int debug)
 static void
 client_freelist(char **list)
 {
-    while (*list++ != NULL)
-       free(*list);
+    free(*list);
 }