]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Portability: several issues in MinGW
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 6 Aug 2011 03:45:38 +0000 (15:45 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 6 Aug 2011 03:45:38 +0000 (15:45 +1200)
compat/eui64_aton.h
compat/getaddrinfo.c
compat/getaddrinfo.h
compat/inet_ntop.c
compat/psignal.c

index d4f5aade1863020028058436cbe2e158bea585ea..863a832e33618a7e2c4fdc70bbc3b7f4f3c9d73e 100644 (file)
@@ -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);
index 2119b161d3c026f9d0687f2d7f28f3471f832e71..3c799db578d921885c9676745efea55718694668 100644 (file)
 #if HAVE_NETDB_H
 #include <netdb.h>
 #endif
-#if _SQUID_MSWIN_
-#undef IN_ADDR
-#include <ws2tcpip.h>
-#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) {
index ba8ac2436ee5d95358c7d6d608aebf6edc4181b3..272ce6a3014f1123a5d343e54a7ab14330175b50 100644 (file)
@@ -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 */
index 147c494de42e89740d92bd3dc1da701da4961146..75315ef35d25e0d65e15ff7a40f56a45424f9adc 100644 (file)
@@ -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 <string.h>
 #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) ==
index 2a8b859ddba3bbfe3f76d4bb51cabf177737c99a..5e07ec14e2100144ba67c77e914d135f53e0cc03 100644 (file)
@@ -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