X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/8cf1d92e52d3feac4ed32ec733e2c0ed7f384e86..e6ddebc23e12a646efed6ef7f1e785497beb0bc2:/sbr/client.c?ds=sidebyside diff --git a/sbr/client.c b/sbr/client.c index d3374ad4..7417ed54 100644 --- a/sbr/client.c +++ b/sbr/client.c @@ -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. @@ -12,17 +10,10 @@ #include #include #include -#include #include #include #include - -#ifdef HAVE_ARPA_INET_H -# include -#endif - -#define TRUE 1 -#define FALSE 0 +#include #define MAXARGS 1000 @@ -85,12 +76,15 @@ client (char *args, char *service, char *response, int len_response, int debug) for (ai = res; ai != NULL; ai = ai->ai_next) { if (debug) { char address[NI_MAXHOST]; + char port[NI_MAXSERV]; rc = getnameinfo(ai->ai_addr, ai->ai_addrlen, address, - sizeof(address), NULL, 0, NI_NUMERICHOST); + sizeof(address), port, sizeof port, + NI_NUMERICHOST | NI_NUMERICSERV); - fprintf(stderr, "Connecting to %s...\n", - rc ? "unknown" : address); + fprintf(stderr, "Connecting to %s:%s...\n", + rc ? "unknown" : address, + rc ? "--" : port); } sd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); @@ -103,7 +97,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; } @@ -117,7 +111,7 @@ client (char *args, char *service, char *response, int len_response, int debug) freeaddrinfo(res); } - client_freelist(ap); + client_freelist(arguments); strncpy (response, "no servers available", len_response); return NOTOK; } @@ -130,8 +124,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); } @@ -175,7 +168,7 @@ static int client_brkany (char chr, char *strg) { register char *sp; - + if (strg) for (sp = strg; *sp; sp++) if (chr == *sp) @@ -211,4 +204,3 @@ client_getcpy (char *str) memcpy (cp, str, len); return cp; } -