From: Amos Jeffries Date: Sat, 27 Aug 2011 04:06:39 +0000 (-0600) Subject: Portability: several issues in MinGW X-Git-Tag: SQUID_3_1_15~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e08db86469b31f5fddb4a7a305af69c701a0809;p=thirdparty%2Fsquid.git Portability: several issues in MinGW --- diff --git a/include/getaddrinfo.h b/include/getaddrinfo.h index ec34ca19e9..2ac142513a 100644 --- a/include/getaddrinfo.h +++ b/include/getaddrinfo.h @@ -108,6 +108,14 @@ SQUIDCEXTERN void xfreeaddrinfo (struct addrinfo *ai); /* Convert error return from getaddrinfo() to string */ SQUIDCEXTERN const char *xgai_strerror (int code); +<<<<<<< TREE +======= +#if !defined(gai_strerror) +>>>>>>> MERGE-SOURCE +<<<<<<< TREE +======= +#endif +>>>>>>> MERGE-SOURCE #endif /* HAVE_GETADDRINFO */ diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c index f9350d4b50..6b45a21e0e 100644 --- a/lib/getaddrinfo.c +++ b/lib/getaddrinfo.c @@ -74,10 +74,6 @@ #if HAVE_NETDB_H #include #endif -#ifdef _SQUID_MSWIN_ -#undef IN_ADDR -#include -#endif #include "getaddrinfo.h" #include "inet_pton.h" @@ -189,7 +185,9 @@ xgetaddrinfo (const char *nodename, const char *servname, return (*res == NULL) ? EAI_MEMORY : 0; } +#if HAVE_H_ERRNO h_errno = 0; +#endif errno = 0; hp = gethostbyname(nodename); if (hp == NULL) { diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c index 57567cfcbc..1a8aeac9a6 100644 --- a/lib/inet_ntop.c +++ b/lib/inet_ntop.c @@ -14,6 +14,8 @@ * * 28-Oct-2007: drop some dead code. now tested working without. * + * 04-Nov-2010: drop SPRINTF casting macro + * * Squid CVS $Id$ * * Original License and code follows. @@ -72,12 +74,6 @@ static const char rcsid[] = "inet_ntop.c,v 1.1.2.1.8.2 2005/11/03 23:08:40 marka #include #endif -#ifdef SPRINTF_CHAR -# define SPRINTF(x) strlen(sprintf/**/x) -#else -# define SPRINTF(x) ((size_t)sprintf x) -#endif - #if ! defined(NS_INADDRSZ) #define NS_INADDRSZ 4 #endif @@ -143,7 +139,7 @@ size_t size; static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; - if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) >= size) { + if (snprintf(tmp, min(sizeof("255.255.255.255"),size), fmt, src[0], src[1], src[2], src[3]) >= size) { errno = ENOSPC; return (NULL); } @@ -232,7 +228,7 @@ size_t size; tp += strlen(tp); break; } - tp += SPRINTF((tp, "%x", words[i])); + tp += snprintf(tp, (tmp + sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") - tp), "%x", words[i]); } /* Was it a trailing run of 0x00's? */ if (best.base != -1 && (best.base + best.len) ==