From: Amos Jeffries Date: Sat, 6 Aug 2011 03:45:38 +0000 (+1200) Subject: Portability: several issues in MinGW X-Git-Tag: take08~55^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b095e27d8536671d7ffeab96858fc31b0167be5f;p=thirdparty%2Fsquid.git Portability: several issues in MinGW --- diff --git a/compat/eui64_aton.h b/compat/eui64_aton.h index d4f5aade18..863a832e33 100644 --- a/compat/eui64_aton.h +++ b/compat/eui64_aton.h @@ -60,7 +60,7 @@ extern "C" { * Structure of an IEEE EUI-64. */ struct eui64 { - u_char octet[EUI64_LEN]; + uint8_t octet[EUI64_LEN]; }; int eui64_aton(const char *a, struct eui64 *e); diff --git a/compat/getaddrinfo.c b/compat/getaddrinfo.c index 2119b161d3..3c799db578 100644 --- a/compat/getaddrinfo.c +++ b/compat/getaddrinfo.c @@ -73,10 +73,6 @@ #if HAVE_NETDB_H #include #endif -#if _SQUID_MSWIN_ -#undef IN_ADDR -#include -#endif static struct addrinfo * dup_addrinfo (struct addrinfo *info, void *addr, size_t addrlen) { @@ -185,7 +181,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/compat/getaddrinfo.h b/compat/getaddrinfo.h index ba8ac2436e..272ce6a301 100644 --- a/compat/getaddrinfo.h +++ b/compat/getaddrinfo.h @@ -102,7 +102,9 @@ SQUIDCEXTERN void xfreeaddrinfo (struct addrinfo *ai); /* Convert error return from getaddrinfo() to string */ SQUIDCEXTERN const char *xgai_strerror (int code); +#if !defined(gai_strerror) #define gai_strerror xgai_strerror +#endif #endif /* HAVE_GETADDRINFO */ #endif /* _getaddrinfo_h */ diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c index 147c494de4..75315ef35d 100644 --- a/compat/inet_ntop.c +++ b/compat/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) == diff --git a/compat/psignal.c b/compat/psignal.c index 2a8b859ddb..5e07ec14e2 100644 --- a/compat/psignal.c +++ b/compat/psignal.c @@ -5,7 +5,7 @@ #include "config.h" #include "psignal.h" -#if _SQUID_AIX_ +#if _SQUID_AIX_ || _SQUID_MINGW_ extern const char* const sys_siglist[]; #define _sys_nsig 64 #define _sys_siglist sys_siglist