X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/d6bc0d17efe54a1dd7110547aae4b1bb6e223bb7..d92cb917ebcd7e8e1b78ec2e9e1ad2ae1ef8e8e4:/sbr/client.c?ds=inline diff --git a/sbr/client.c b/sbr/client.c index 7ab49a98..99788963 100644 --- a/sbr/client.c +++ b/sbr/client.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -26,7 +25,6 @@ static char **client_brkstring (char *, char *, char *); static int client_brkany (char, char *); static char **client_copyip (char **, char **, int); -static char *client_getcpy (char *); static void client_freelist(char **); @@ -39,15 +37,15 @@ client (char *args, char *service, char *response, int len_response, int debug) ap = arguments; if (args != NULL && *args != 0) { - ap = client_copyip (client_brkstring (client_getcpy (args), " ", "\n"), + ap = client_copyip (client_brkstring (mh_xstrdup(args), " ", "\n"), ap, MAXARGS); } else { if (servers != NULL && *servers != 0) - ap = client_copyip (client_brkstring (client_getcpy (servers), " ", "\n"), + ap = client_copyip (client_brkstring (mh_xstrdup(servers), " ", "\n"), ap, MAXARGS); } if (ap == arguments) { - *ap++ = client_getcpy ("localhost"); + *ap++ = mh_xstrdup("localhost"); *ap = NULL; } @@ -77,12 +75,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); @@ -135,8 +136,8 @@ static char *broken[MAXARGS + 1]; static char ** client_brkstring (char *strg, char *brksep, char *brkterm) { - register int bi; - register char c, *sp; + int bi; + char c, *sp; sp = strg; @@ -165,8 +166,8 @@ client_brkstring (char *strg, char *brksep, char *brkterm) static int client_brkany (char chr, char *strg) { - register char *sp; - + char *sp; + if (strg) for (sp = strg; *sp; sp++) if (chr == *sp) @@ -188,18 +189,3 @@ client_copyip (char **p, char **q, int len_q) return q; } - - -static char * -client_getcpy (char *str) -{ - char *cp; - size_t len; - - len = strlen(str) + 1; - cp = mh_xmalloc(len); - - memcpy (cp, str, len); - return cp; -} -