]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Portability: several issues in MinGW
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 27 Aug 2011 04:06:39 +0000 (22:06 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 27 Aug 2011 04:06:39 +0000 (22:06 -0600)
include/getaddrinfo.h
lib/getaddrinfo.c
lib/inet_ntop.c

index ec34ca19e95f68b308cea2b5851671033b8c1575..2ac142513a7befaa2610b99f1000ad4a1dd359aa 100644 (file)
@@ -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 */
 
index f9350d4b505efa724e646b5b932b72e6722f43be..6b45a21e0e840ee0fbd5828c989e311be8b9efcf 100644 (file)
 #if HAVE_NETDB_H
 #include <netdb.h>
 #endif
-#ifdef _SQUID_MSWIN_
-#undef IN_ADDR
-#include <ws2tcpip.h>
-#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) {
index 57567cfcbcda10dc9f76c807d72338a17b0df8e6..1a8aeac9a614b9abfa08156df7e0d0668de21282 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) ==