From 27bc2077cdd539eabfb20ed051980dba4e75b51b Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Mon, 22 Mar 2010 07:05:28 -0600 Subject: [PATCH] Compat: shuffle replacement OS function fiels into libcompat * strerror() is omitted due to an emulator, and multiple replacement functions being defined with rather complicated interactions. * the .c parts must also remain in lib/ for now to simplify autoconf logics. --- CREDITS | 23 +++++++++ compat/Makefile.am | 11 ++++- compat/compat_shared.h | 32 ------------- compat/drand48.h | 13 +++++ {include => compat}/eui64_aton.h | 12 ++++- {include => compat}/getaddrinfo.h | 20 ++++---- {include => compat}/getnameinfo.h | 19 +++----- {include => compat}/inet_ntop.h | 14 +++--- {include => compat}/inet_pton.h | 14 +++--- {include => compat}/initgroups.h | 19 +++----- compat/os/mswin.h | 1 + compat/os/netbsd.h | 3 ++ {include => compat}/strsep.h | 44 +++++++++-------- compat/strtoll.h | 21 ++++++++ {include => compat}/tempnam.h | 15 +++--- .../kerberos/negotiate_kerberos_auth.cc | 16 +++---- include/strtoll.h | 31 ------------ include/util.h | 4 -- lib/getaddrinfo.c | 14 ++---- lib/getfullhostname.c | 2 +- lib/getnameinfo.c | 16 ++----- lib/initgroups.c | 7 +-- lib/rfc3596.c | 9 ++-- lib/strerror.c | 3 +- lib/strsep.c | 14 ++---- lib/strtoll.c | 9 ++-- lib/tempnam.c | 8 +--- src/HttpHeaderTools.cc | 6 +-- src/Parsing.cc | 3 +- src/SwapDir.cc | 2 +- src/acl/Ip.cc | 9 ++-- src/client_side_request.cc | 33 ++++++------- src/dnsserver.cc | 21 ++++---- src/eui/Eui64.cc | 7 +-- src/event.cc | 4 +- src/ftp.cc | 1 + src/ip/IpAddress.cc | 21 ++++---- src/ip/IpAddress.h | 6 +-- src/ip/testIpAddress.cc | 5 +- src/snmp_core.cc | 5 +- src/squid.h | 23 --------- src/tools.cc | 20 ++++---- src/wccp2.cc | 3 +- test-suite/pconn-banger.c | 48 +++---------------- tools/cachemgr.cc | 1 + 45 files changed, 263 insertions(+), 349 deletions(-) create mode 100644 compat/drand48.h rename {include => compat}/eui64_aton.h (91%) rename {include => compat}/getaddrinfo.h (95%) rename {include => compat}/getnameinfo.h (78%) rename {include => compat}/inet_ntop.h (85%) rename {include => compat}/inet_pton.h (89%) rename {include => compat}/initgroups.h (54%) rename {include => compat}/strsep.h (58%) create mode 100644 compat/strtoll.h rename {include => compat}/tempnam.h (86%) delete mode 100644 include/strtoll.h diff --git a/CREDITS b/CREDITS index 68e7936000..df3b54ba1c 100644 --- a/CREDITS +++ b/CREDITS @@ -463,3 +463,26 @@ helprs/negotiate_auth/kerberos/ * */ ============================================================================== + +compat/strsep.h, lib/strsep.c + + * Copyright (C) 2004 Free Software Foundation, Inc. + * Written by Yoann Vandoorselaere + * + * The file is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + +============================================================================== + diff --git a/compat/Makefile.am b/compat/Makefile.am index 4c9f8e2404..af4b66a197 100644 --- a/compat/Makefile.am +++ b/compat/Makefile.am @@ -10,15 +10,24 @@ include $(top_srcdir)/src/Common.am # Port Specific Configurations noinst_LTLIBRARIES = libcompat.la - libcompat_la_SOURCES = \ assert.h \ compat.h \ compat_shared.h \ debug.h \ + drand48.h \ + eui64_aton.h \ fdsetsize.h \ + getaddrinfo.h \ + getnameinfo.h \ + inet_ntop.h \ + inet_pton.h \ + initgroups.h \ osdetect.h \ stdvarargs.h \ + strsep.h \ + strtoll.h \ + tempnam.h \ types.h \ unsafe.h \ valgrind.h \ diff --git a/compat/compat_shared.h b/compat/compat_shared.h index 95c54e7224..753396e38e 100644 --- a/compat/compat_shared.h +++ b/compat/compat_shared.h @@ -134,43 +134,11 @@ max(A const & lhs, A const & rhs) #endif /* __cplusplus */ #endif /* max */ -/** - * tempnam() not provided by all systems - * TODO: detect WHICH systems and move to their OS-specific compat files - */ -#if !HAVE_TEMPNAM -#include "tempnam.h" -#endif - -/** - * strsep() not provided by all systems - * TODO: detect WHICH systems and move to their OS-specific compat files - */ -#if !HAVE_STRSEP -#include "strsep.h" -#endif - -/** - * strtoll() not provided by all systems - * TODO: detect WHICH systems and move to their OS-specific compat files - */ -#if !HAVE_STRTOLL -#include "strtoll.h" -#endif - /** * Common shared definition of what whitespace consists of for string tests */ #define w_space " \t\n\r" -/** - * initgroups() not provided by all systems - * TODO: detect WHICH systems and move to their OS-specific compat files - */ -#if !HAVE_INITGROUPS -#include "initgroups.h" -#endif - #ifndef SQUID_NONBLOCK /* REQUIRED for the below logics. If they move this needs to as well */ diff --git a/compat/drand48.h b/compat/drand48.h new file mode 100644 index 0000000000..362d12448d --- /dev/null +++ b/compat/drand48.h @@ -0,0 +1,13 @@ +#ifndef SQUID_CONFIG_H +#include "config.h" +#endif + +#ifndef _SQUID_DRAND48_H +#define _SQUID_DRAND48_H + +#if !HAVE_DRAND48 +#define HAVE_DRAND48 1 +SQUIDCEXTERN double drand48(void); +#endif + +#endif diff --git a/include/eui64_aton.h b/compat/eui64_aton.h similarity index 91% rename from include/eui64_aton.h rename to compat/eui64_aton.h index 280de84ff6..98caeeed1a 100644 --- a/include/eui64_aton.h +++ b/compat/eui64_aton.h @@ -1,3 +1,12 @@ +#ifndef SQUID_CONFIG_H +#include "config.h" +#endif + +/* If we have this system file use it. Otherwise use the below definitions. */ +#if HAVE_SYS_EUI64_H +#include +#else + /* * Squid Change History: * @@ -38,8 +47,6 @@ #ifndef _SYS_EUI64_H #define _SYS_EUI64_H -#include - /** * Size of the ASCII representation of an EUI-64. */ @@ -63,3 +70,4 @@ extern "C" int eui64_aton(const char *a, struct eui64 *e); #endif /* !_SYS_EUI64_H */ +#endif /* HAVE_SYS_EUI64_H */ diff --git a/include/getaddrinfo.h b/compat/getaddrinfo.h similarity index 95% rename from include/getaddrinfo.h rename to compat/getaddrinfo.h index a0aabf7347..96e42aaf86 100644 --- a/include/getaddrinfo.h +++ b/compat/getaddrinfo.h @@ -1,3 +1,7 @@ +#ifndef SQUID_CONFIG_H +#include "config.h" +#endif + #ifndef _getaddrinfo_h #define _getaddrinfo_h @@ -18,8 +22,6 @@ * Original License and code follows. */ -#include "config.h" - /* * This file is part of libESMTP, a library for submission of RFC 2822 * formatted electronic mail messages using the SMTP protocol described @@ -44,14 +46,8 @@ /* Structure and prototypes taken from RFC 2553 */ -#ifdef HAVE_GETADDRINFO - /* These functions are provided by the OS */ -#define xgetaddrinfo getaddrinfo -#define xfreeaddrinfo freeaddrinfo -#define xgai_strerror gai_strerror - -#else /* !HAVE_GETADDRINFO */ +#if !HAVE_GETADDRINFO /* SG 23/09/2007: On Windows the following definitions are already available, may be that @@ -102,13 +98,15 @@ struct addrinfo { /* RFC 2553 / Posix resolver */ SQUIDCEXTERN int xgetaddrinfo (const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res); +#define getaddrinfo xgetaddrinfo /* Free addrinfo structure and associated storage */ SQUIDCEXTERN void xfreeaddrinfo (struct addrinfo *ai); +#define freeaddrinfo xfreeaddrinfo /* Convert error return from getaddrinfo() to string */ SQUIDCEXTERN const char *xgai_strerror (int code); +#define gai_strerror xgai_strerror #endif /* HAVE_GETADDRINFO */ - -#endif +#endif /* _getaddrinfo_h */ diff --git a/include/getnameinfo.h b/compat/getnameinfo.h similarity index 78% rename from include/getnameinfo.h rename to compat/getnameinfo.h index 7d9c750871..0c1bba9a39 100644 --- a/include/getnameinfo.h +++ b/compat/getnameinfo.h @@ -1,19 +1,14 @@ +#ifndef SQUID_CONFIG_H +#include "config.h" +#endif + #ifndef _getnameinfo_h #define _getnameinfo_h /* * Reconstructed from KAME getnameinfo.c (in lib/) - * - * $Id$ */ -#include "config.h" - -#ifdef HAVE_GETNAMEINFO - -/* These functions are provided by the OS */ -#define xgetnameinfo getnameinfo - -#else /* !HAVE_GETNAMEINFO */ +#if !HAVE_GETNAMEINFO /* RFC 2553 / Posix resolver */ SQUIDCEXTERN int xgetnameinfo(const struct sockaddr *sa, @@ -23,8 +18,8 @@ SQUIDCEXTERN int xgetnameinfo(const struct sockaddr *sa, char *serv, size_t servlen, int flags ); +#define getnameinfo xgetnameinfo #endif /* HAVE_GETNAMEINFO */ - -#endif +#endif /* _getnameinfo_h */ diff --git a/include/inet_ntop.h b/compat/inet_ntop.h similarity index 85% rename from include/inet_ntop.h rename to compat/inet_ntop.h index a7bf206224..e9cbe4b6d1 100644 --- a/include/inet_ntop.h +++ b/compat/inet_ntop.h @@ -1,14 +1,12 @@ -#ifndef _INC_INET_NTOP_H -#define _INC_INET_NTOP_H - +#ifndef SQUID_CONFIG_H #include "config.h" +#endif -#if HAVE_INET_NTOP +#ifndef _INC_INET_NTOP_H +#define _INC_INET_NTOP_H /* Use the system provided version where possible */ -#define xinet_ntop inet_ntop - -#else +#if !HAVE_INET_NTOP /* char * * inet_ntop(af, src, dst, size) @@ -19,7 +17,7 @@ * Paul Vixie, 1996. */ SQUIDCEXTERN const char * xinet_ntop(int af, const void *src, char *dst, size_t size); +#define inet_ntop xinet_ntop #endif - #endif /* _INC_INET_NTOP_H */ diff --git a/include/inet_pton.h b/compat/inet_pton.h similarity index 89% rename from include/inet_pton.h rename to compat/inet_pton.h index 5c95540dfa..b80dc855be 100644 --- a/include/inet_pton.h +++ b/compat/inet_pton.h @@ -1,14 +1,12 @@ -#ifndef _INC_INET_PTON_H -#define _INC_INET_PTON_H - +#ifndef SQUID_CONFIG_H #include "config.h" +#endif -#if HAVE_INET_PTON +#ifndef _INC_INET_PTON_H +#define _INC_INET_PTON_H /* Use the system provided version where possible */ -#define xinet_pton inet_pton - -#else +#if !HAVE_INET_PTON /* int * inet_pton(af, src, dst) @@ -22,7 +20,7 @@ * Paul Vixie, 1996. */ SQUIDCEXTERN int xinet_pton(int af, const char *src, void *dst); +#define inet_pton xinet_pton #endif - #endif /* _INC_INET_NTOP_H */ diff --git a/include/initgroups.h b/compat/initgroups.h similarity index 54% rename from include/initgroups.h rename to compat/initgroups.h index 49b1d158d0..f67ff9a65e 100644 --- a/include/initgroups.h +++ b/compat/initgroups.h @@ -1,20 +1,13 @@ -/* - * $Id$ - */ -#ifndef SQUID_INITGROUPS_H -#define SQUID_INITGROUPS_H - -#include "config.h" - -/* if you have configure you can use this */ -#if defined(HAVE_CONFIG_H) +#ifndef SQUID_CONFIG_H #include "config.h" #endif -#if HAVE_SYS_TYPES_H -#include -#endif +#ifndef SQUID_INITGROUPS_H +#define SQUID_INITGROUPS_H + +#if !HAVE_INITGROUPS SQUIDCEXTERN int initgroups(const char *user, gid_t group); +#endif #endif /* SQUID_INITGROPS_H */ diff --git a/compat/os/mswin.h b/compat/os/mswin.h index aa90975208..6d9d58be82 100644 --- a/compat/os/mswin.h +++ b/compat/os/mswin.h @@ -323,6 +323,7 @@ SQUIDCEXTERN int _free_osfhnd(int); SQUIDCEXTERN THREADLOCAL int ws32_result; #define strerror(e) WIN32_strerror(e) +#define HAVE_STRERROR 1 #ifdef __cplusplus diff --git a/compat/os/netbsd.h b/compat/os/netbsd.h index 300f2d3646..dfc54b5b4b 100644 --- a/compat/os/netbsd.h +++ b/compat/os/netbsd.h @@ -19,5 +19,8 @@ #define SQUID_NO_ALLOC_PROTECT 1 #endif +/* NetBSD does not provide sys_errlist global for strerror */ +#define NEED_SYS_ERRLIST 1 + #endif /* _SQUID_NETBSD_ */ #endif /* SQUID_OS_NETBSD_H */ diff --git a/include/strsep.h b/compat/strsep.h similarity index 58% rename from include/strsep.h rename to compat/strsep.h index 40d2ad22e2..87d1c71bc9 100644 --- a/include/strsep.h +++ b/compat/strsep.h @@ -1,3 +1,7 @@ +#ifndef SQUID_CONFIG_H +#include "config.h" +#endif + /* Copyright (C) 2004 Free Software Foundation, Inc. * Written by Yoann Vandoorselaere * @@ -19,8 +23,6 @@ #ifndef GNULIB_STRSEP_H_ #define GNULIB_STRSEP_H_ -#include "config.h" - #if HAVE_STRSEP /* @@ -33,26 +35,26 @@ #else /** -\par -Searches the next delimiter (char listed in DELIM) starting at *STRINGP. -If one is found, it is overwritten with a NULL, and *STRINGP is advanced -to point to the next char after it. Otherwise, *STRINGP is set to NULL. -If *STRINGP was already NULL, nothing happens. -Returns the old value of *STRINGP. -\par -This is a variant of strtok() that is multithread-safe and supports -empty fields. - -\note Caveat: It modifies the original string. -\note Caveat: These functions cannot be used on constant strings. -\note Caveat: The identity of the delimiting character is lost. -\note Caveat: It doesn't work with multibyte strings unless all of the delimiter -characters are ASCII characters < 0x30. - -See also strtok_r(). -*/ + *\par + * Searches the next delimiter (char listed in DELIM) starting at *STRINGP. + * If one is found, it is overwritten with a NULL, and *STRINGP is advanced + * to point to the next char after it. Otherwise, *STRINGP is set to NULL. + * If *STRINGP was already NULL, nothing happens. + * Returns the old value of *STRINGP. + * + *\par + * This is a variant of strtok() that is multithread-safe and supports + * empty fields. + * + * \note Caveat: It modifies the original string. + * \note Caveat: These functions cannot be used on constant strings. + * \note Caveat: The identity of the delimiting character is lost. + * \note Caveat: It doesn't work with multibyte strings unless all of the delimiter + * characters are ASCII characters < 0x30. + * + * See also strtok_r(). + */ SQUIDCEXTERN char *strsep(char **stringp, const char *delim); #endif /* HAVE_STRSEP */ - #endif /* GNULIB_STRSEP_H_ */ diff --git a/compat/strtoll.h b/compat/strtoll.h new file mode 100644 index 0000000000..60c04c21a0 --- /dev/null +++ b/compat/strtoll.h @@ -0,0 +1,21 @@ +#ifndef SQUID_CONFIG_H +#include "config.h" +#endif + +#ifndef _SQUID_COMPAT_STRTOLL_H +#define _SQUID_COMPAT_STRTOLL_H + +#if !HAVE_STRTOLL + +/** + *\par + * Convert a string to a int64 integer. + * + *\par + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +SQUIDCEXTERN int64_t strtoll(const char *nptr, char **endptr, int base); + +#endif /* !HAVE_STRTOLL */ +#endif /* _SQUID_COMPAT_STRTOLL_H */ diff --git a/include/tempnam.h b/compat/tempnam.h similarity index 86% rename from include/tempnam.h rename to compat/tempnam.h index f8e4ae6b58..ab1d4c29e3 100644 --- a/include/tempnam.h +++ b/compat/tempnam.h @@ -1,9 +1,5 @@ /* - * $Id$ - */ - - -/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + * Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. * This file is part of the GNU C Library. * The GNU C Library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License as @@ -18,9 +14,16 @@ * You should have received a copy of the GNU Library General Public * License along with the GNU C Library; see the file COPYING.LIB. If * not, write to the Free Software Foundation, Inc., 675 Mass Ave, - * Cambridge, MA 02139, USA. */ + * Cambridge, MA 02139, USA. + */ + +#ifndef SQUID_CONFIG_H +#include "config.h" +#endif #ifndef SQUID_TEMPNAM_H #define SQUID_TEMPNAM_H + extern char *tempnam(const char *, const char *); + #endif /* SQUID_TEMPNAM_H */ diff --git a/helpers/negotiate_auth/kerberos/negotiate_kerberos_auth.cc b/helpers/negotiate_auth/kerberos/negotiate_kerberos_auth.cc index 1f575736a2..b48ebdc089 100644 --- a/helpers/negotiate_auth/kerberos/negotiate_kerberos_auth.cc +++ b/helpers/negotiate_auth/kerberos/negotiate_kerberos_auth.cc @@ -30,6 +30,8 @@ * Hosted at http://sourceforge.net/projects/squidkerbauth */ #include "config.h" +#include "compat/getaddrinfo.h" +#include "compat/getnameinfo.h" #if HAVE_GSSAPI @@ -57,8 +59,6 @@ #include "util.h" #include "base64.h" -#include "getaddrinfo.h" -#include "getnameinfo.h" #if HAVE_GSSAPI_GSSAPI_H #include @@ -124,11 +124,11 @@ gethost_name(void) LogTime(), PROGRAM, hostname); return NULL; } - rc = xgetaddrinfo(hostname, NULL, NULL, &hres); + rc = getaddrinfo(hostname, NULL, NULL, &hres); if (rc != 0) { fprintf(stderr, "%s| %s: ERROR: resolving hostname with getaddrinfo: %s failed\n", - LogTime(), PROGRAM, xgai_strerror(rc)); + LogTime(), PROGRAM, gai_strerror(rc)); return NULL; } hres_list = hres; @@ -137,17 +137,17 @@ gethost_name(void) count++; hres_list = hres_list->ai_next; } - rc = xgetnameinfo(hres->ai_addr, hres->ai_addrlen, hostname, + rc = getnameinfo(hres->ai_addr, hres->ai_addrlen, hostname, sizeof(hostname), NULL, 0, 0); if (rc != 0) { fprintf(stderr, "%s| %s: ERROR: resolving ip address with getnameinfo: %s failed\n", - LogTime(), PROGRAM, xgai_strerror(rc)); - xfreeaddrinfo(hres); + LogTime(), PROGRAM, gai_strerror(rc)); + freeaddrinfo(hres); return NULL; } - xfreeaddrinfo(hres); + freeaddrinfo(hres); hostname[sysconf(_SC_HOST_NAME_MAX) - 1] = '\0'; return (xstrdup(hostname)); } diff --git a/include/strtoll.h b/include/strtoll.h deleted file mode 100644 index 92e8edd044..0000000000 --- a/include/strtoll.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * $Id$ - */ -#ifndef _SQUIDINC_STRTOLL_H -#define _SQUIDINC_STRTOLL_H - -#include "config.h" - -#if HAVE_STRTOLL - -/* - * Get strtoll() declaration. - */ -#if HAVE_STDLIB_H -#include -#endif - -#else - -/** -\par -* Convert a string to a int64 integer. -\par -* Ignores `locale' stuff. Assumes that the upper and lower case -* alphabets and digits are each contiguous. -*/ -SQUIDCEXTERN int64_t strtoll(const char *nptr, char **endptr, int base); - -#endif /* !HAVE_STRTOLL */ - -#endif /* _SQUIDINC_STRTOLL_H */ diff --git a/include/util.h b/include/util.h index 0bf570b4c2..f02e042435 100644 --- a/include/util.h +++ b/include/util.h @@ -127,10 +127,6 @@ SQUIDCEXTERN double xdiv(double nom, double denom); SQUIDCEXTERN const char *xitoa(int num); SQUIDCEXTERN const char *xint64toa(int64_t num); -#if !HAVE_DRAND48 -SQUIDCEXTERN double drand48(void); -#endif - typedef struct { size_t count; size_t bytes; diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c index 25917df2af..24d2d9bffd 100644 --- a/lib/getaddrinfo.c +++ b/lib/getaddrinfo.c @@ -49,9 +49,9 @@ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE -#if HAVE_STDLIB_H -#include -#endif +#include "compat/getaddrinfo.h" +#include "compat/inet_pton.h" + #if HAVE_STRING_H #include #endif @@ -61,7 +61,6 @@ #if HAVE_ERRNO_H #include #endif - #if HAVE_SYS_SOCKET_H #include #endif @@ -79,9 +78,6 @@ #include #endif -#include "getaddrinfo.h" -#include "inet_pton.h" - static struct addrinfo * dup_addrinfo (struct addrinfo *info, void *addr, size_t addrlen) { struct addrinfo *ret; @@ -168,7 +164,7 @@ xgetaddrinfo (const char *nodename, const char *servname, return (*res == NULL) ? EAI_MEMORY : 0; } - /* If AI_NUMERIC is specified, use xinet_pton to translate numbers and + /* If AI_NUMERIC is specified, use inet_pton to translate numbers and dots notation. */ if (hints->ai_flags & AI_NUMERICHOST) { struct sockaddr_in sin; @@ -181,7 +177,7 @@ xgetaddrinfo (const char *nodename, const char *servname, sin.sin_family = result.ai_family; sin.sin_port = htons (port); - if (xinet_pton(result.ai_family, nodename, &sin.sin_addr)) + if (inet_pton(result.ai_family, nodename, &sin.sin_addr)) return EAI_NONAME; sin.sin_addr.s_addr = inet_addr (nodename); /* Duplicate result and addr and return */ diff --git a/lib/getfullhostname.c b/lib/getfullhostname.c index 5348ad7ec1..792f02bde4 100644 --- a/lib/getfullhostname.c +++ b/lib/getfullhostname.c @@ -64,7 +64,7 @@ getfullhostname(void) if (gethostname(buf, RFC2181_MAXHOSTNAMELEN) < 0) return NULL; - /** \todo convert this to a xgetaddrinfo() call */ + /** \todo convert this to a getaddrinfo() call */ if ((hp = gethostbyname(buf)) != NULL) xstrncpy(buf, hp->h_name, RFC2181_MAXHOSTNAMELEN); return buf; diff --git a/lib/getnameinfo.c b/lib/getnameinfo.c index ab8ac0f218..f94ea52e7e 100644 --- a/lib/getnameinfo.c +++ b/lib/getnameinfo.c @@ -77,9 +77,9 @@ #ifndef HAVE_GETNAMEINFO -#if HAVE_SYS_TYPES_H -#include -#endif +#include "compat/inet_ntop.h" +#include "compat/getaddrinfo.h" + #if HAVE_STDIO_H #include #endif @@ -122,12 +122,6 @@ #include #endif -#include "getaddrinfo.h" - -#if !HAVE_INET_NTOP -#include "inet_ntop.h" -#endif - static const struct afd { int a_af; int a_addrlen; @@ -330,7 +324,7 @@ numeric: } #endif default: - if (xinet_ntop(afd->a_af, addr, host, + if (inet_ntop(afd->a_af, addr, host, hostlen) == NULL) return EAI_SYSTEM; break; @@ -352,7 +346,7 @@ int flags; int numaddrlen; char numaddr[512]; - if (xinet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL) + if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL) return EAI_SYSTEM; numaddrlen = strlen(numaddr); diff --git a/lib/initgroups.c b/lib/initgroups.c index 41f8e3f68b..1a84a66a3d 100644 --- a/lib/initgroups.c +++ b/lib/initgroups.c @@ -1,11 +1,9 @@ #include "config.h" +#include "compat/initgroups.h" #if HAVE_GRP_H #include #endif -#if HAVE_SYS_TYPES_H -#include -#endif #if HAVE_UNISTD_H #include #endif @@ -18,9 +16,6 @@ #if HAVE_LIMITS_H #include #endif -#if !HAVE_INITGROUPS -#include "initgroups.h" -#endif int initgroups(const char *name, gid_t basegid) { diff --git a/lib/rfc3596.c b/lib/rfc3596.c index 24ca563603..ab93de9fc8 100644 --- a/lib/rfc3596.c +++ b/lib/rfc3596.c @@ -57,6 +57,7 @@ */ #include "config.h" +#include "compat/inet_pton.h" #include "util.h" #if HAVE_STDIO_H @@ -263,7 +264,7 @@ main(int argc, char *argv[]) ((struct sockaddr_in6 *)S)->sin6_family = AF_INET6; ((struct sockaddr_in6 *)S)->sin6_port = htons(atoi(argv[var+1])); - if ( ! xinet_pton(AF_INET6, argv[var], &((struct sockaddr_in6 *)S)->sin6_addr.s_addr) ) + if ( ! inet_pton(AF_INET6, argv[var], &((struct sockaddr_in6 *)S)->sin6_addr.s_addr) ) perror("listen address"); return 1; } @@ -278,7 +279,7 @@ else ((struct sockaddr_in *)S)->sin_family = AF_INET; ((struct sockaddr_in *)S)->sin_port = htons(atoi(argv[var+1])); - if ( ! xinet_pton(AF_INET, argv[var], &((struct sockaddr_in *)S)->sin_addr.s_addr) ) + if ( ! inet_pton(AF_INET, argv[var], &((struct sockaddr_in *)S)->sin_addr.s_addr) ) perror("listen address"); return 1; } @@ -294,10 +295,10 @@ while (fgets(input, 512, stdin)) memset(buf, '\0', 512); sz = 512; - if (xinet_pton(AF_INET6, input, &junk6)) { + if (inet_pton(AF_INET6, input, &junk6)) { sid = rfc1035BuildPTRQuery6(junk6, buf, &sz); sidb=0; - } else if (xinet_pton(AF_INET, input, &junk4)) { + } else if (inet_pton(AF_INET, input, &junk4)) { sid = rfc1035BuildPTRQuery4(junk4, buf, &sz); sidb=0; } else { diff --git a/lib/strerror.c b/lib/strerror.c index 8d7209116b..1e59172dfe 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -39,7 +39,8 @@ #endif extern int sys_nerr; -#if NEED_SYS_ERRLIST && !defined(_SQUID_NETBSD_) + +#if NEED_SYS_ERRLIST extern char *sys_errlist[]; #endif diff --git a/lib/strsep.c b/lib/strsep.c index 6335cbeda4..0e2739f682 100644 --- a/lib/strsep.c +++ b/lib/strsep.c @@ -1,7 +1,3 @@ -/* - * $Id$ - */ - /* Copyright (C) 2004 Free Software Foundation, Inc. * Written by Yoann Vandoorselaere * @@ -21,17 +17,13 @@ * USA. */ -#ifdef HAVE_CONFIG_H -#include -#endif - -/* Specification. */ -#include "strsep.h" +#include "config.h" +#include "compat/strsep.h" #include char * -strsep (char **stringp, const char *delim) +strsep(char **stringp, const char *delim) { char *start = *stringp; char *ptr; diff --git a/lib/strtoll.c b/lib/strtoll.c index 50f705da9b..666b0828d3 100644 --- a/lib/strtoll.c +++ b/lib/strtoll.c @@ -33,9 +33,9 @@ /* modified for long long 1999-08-12 */ -#ifdef HAVE_CONFIG_H -#include -#endif +#include "config.h" +#include "compat/strtoll.h" + #if HAVE_CTYPE_H #include #endif @@ -43,9 +43,6 @@ #include #endif -/* Specification. */ -#include "strtoll.h" - #ifndef INT64_MIN /* Native 64 bit system without strtoll() */ diff --git a/lib/tempnam.c b/lib/tempnam.c index 0ff9f88e35..dff1c9896f 100644 --- a/lib/tempnam.c +++ b/lib/tempnam.c @@ -1,7 +1,3 @@ -/* - * $Id$ - */ - /* A reasonably functional tmpnam. */ /* Originally by Tom Hageman, tom@basil.icce.rug.nl */ @@ -13,6 +9,7 @@ */ #include "config.h" +#include "compat/tempnam.h" #if HAVE_LIBC_H #include @@ -20,9 +17,6 @@ #if HAVE_STDIO_H #include #endif -#if HAVE_TYPES_H -#include -#endif #if HAVE_LIMITS_H #include #endif diff --git a/src/HttpHeaderTools.cc b/src/HttpHeaderTools.cc index 4ae9bfa53b..c4b995b349 100644 --- a/src/HttpHeaderTools.cc +++ b/src/HttpHeaderTools.cc @@ -1,4 +1,3 @@ - /* * $Id$ * @@ -34,9 +33,10 @@ */ #include "squid.h" -#include "HttpHeader.h" -#include "HttpHdrContRange.h" #include "acl/FilledChecklist.h" +#include "compat/strtoll.h" +#include "HttpHdrContRange.h" +#include "HttpHeader.h" #include "MemBuf.h" static void httpHeaderPutStrvf(HttpHeader * hdr, http_hdr_type id, const char *fmt, va_list vargs); diff --git a/src/Parsing.cc b/src/Parsing.cc index a20ba9efca..a69810cc05 100644 --- a/src/Parsing.cc +++ b/src/Parsing.cc @@ -1,4 +1,3 @@ - /* * $Id$ * @@ -33,6 +32,8 @@ * */ +#include "config.h" +#include "compat/strtoll.h" #include "Parsing.h" /* diff --git a/src/SwapDir.cc b/src/SwapDir.cc index 581e4ba74d..40c04099b8 100644 --- a/src/SwapDir.cc +++ b/src/SwapDir.cc @@ -1,4 +1,3 @@ - /* * $Id$ * @@ -34,6 +33,7 @@ */ #include "squid.h" +#include "compat/strtoll.h" #include "SwapDir.h" #include "StoreFileSystem.h" #include "ConfigOption.h" diff --git a/src/acl/Ip.cc b/src/acl/Ip.cc index 982293be44..9a501d58d5 100644 --- a/src/acl/Ip.cc +++ b/src/acl/Ip.cc @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "compat/getaddrinfo.h" #include "acl/Ip.h" #include "acl/Checklist.h" #include "MemBuf.h" @@ -405,7 +406,7 @@ acl_ip_data::FactoryParse(const char *t) addr2[0] = '\0'; } else if (sscanf(t, "%s", addr1) == 1) { /* - * Note, must use plain xgetaddrinfo() here because at startup + * Note, must use plain getaddrinfo() here because at startup * ipcache hasn't been initialized * TODO: offload this to one of the IpAddress lookups. */ @@ -425,11 +426,11 @@ acl_ip_data::FactoryParse(const char *t) hints.ai_flags |= AI_V4MAPPED | AI_ALL; #endif - int errcode = xgetaddrinfo(addr1,NULL,&hints,&hp); + int errcode = getaddrinfo(addr1,NULL,&hints,&hp); if (hp == NULL) { debugs(28, 0, "aclIpParseIpData: Bad host/IP: '" << addr1 << "' in '" << t << "', flags=" << hints.ai_flags << - " : (" << errcode << ") " << xgai_strerror(errcode) ); + " : (" << errcode << ") " << gai_strerror(errcode) ); self_destruct(); return NULL; } @@ -468,7 +469,7 @@ acl_ip_data::FactoryParse(const char *t) return NULL; } - xfreeaddrinfo(hp); + freeaddrinfo(hp); return q; } diff --git a/src/client_side_request.cc b/src/client_side_request.cc index e3056f20fe..85234fd4c4 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -43,24 +43,8 @@ */ #include "squid.h" -#include "clientStream.h" -#include "client_side_request.h" -#include "auth/UserRequest.h" -#include "HttpRequest.h" -#include "ProtoPort.h" #include "acl/FilledChecklist.h" #include "acl/Gadgets.h" -#include "client_side.h" -#include "client_side_reply.h" -#include "Store.h" -#include "HttpReply.h" -#include "MemObject.h" -#include "ClientRequestContext.h" -#include "SquidTime.h" -#include "wordlist.h" -#include "inet_pton.h" -#include "fde.h" - #if USE_ADAPTATION #include "adaptation/AccessCheck.h" #include "adaptation/Iterator.h" @@ -68,9 +52,22 @@ #if ICAP_CLIENT #include "adaptation/icap/History.h" #endif -//static void adaptationAclCheckDoneWrapper(Adaptation::ServicePointer service, void *data); #endif - +#include "auth/UserRequest.h" +#include "clientStream.h" +#include "client_side.h" +#include "client_side_reply.h" +#include "client_side_request.h" +#include "ClientRequestContext.h" +#include "compat/inet_pton.h" +#include "fde.h" +#include "HttpReply.h" +#include "HttpRequest.h" +#include "MemObject.h" +#include "ProtoPort.h" +#include "Store.h" +#include "SquidTime.h" +#include "wordlist.h" #if LINGERING_CLOSE diff --git a/src/dnsserver.cc b/src/dnsserver.cc index 2cf4ec5613..a5a40b2df7 100644 --- a/src/dnsserver.cc +++ b/src/dnsserver.cc @@ -31,6 +31,9 @@ */ #include "config.h" +#include "compat/inet_ntop.h" +#include "compat/getaddrinfo.h" +#include "compat/getnameinfo.h" #if HAVE_UNISTD_H #include @@ -204,10 +207,10 @@ lookup(const char *buf) hints.ai_flags = AI_CANONNAME; for (;;) { - xfreeaddrinfo(AI); + freeaddrinfo(AI); AI = NULL; - if ( 0 == (res = xgetaddrinfo(buf,NULL,&hints,&AI)) ) + if ( 0 == (res = getaddrinfo(buf,NULL,&hints,&AI)) ) break; if (res != EAI_AGAIN) @@ -255,11 +258,11 @@ lookup(const char *buf) /* annoying inet_ntop breaks the nice code by requiring the in*_addr */ switch (aiptr->ai_family) { case AF_INET: - xinet_ntop(aiptr->ai_family, &((struct sockaddr_in*)aiptr->ai_addr)->sin_addr, ntoabuf, MAX_IPSTRLEN); + inet_ntop(aiptr->ai_family, &((struct sockaddr_in*)aiptr->ai_addr)->sin_addr, ntoabuf, MAX_IPSTRLEN); break; #if USE_IPV6 case AF_INET6: - xinet_ntop(aiptr->ai_family, &((struct sockaddr_in6*)aiptr->ai_addr)->sin6_addr, ntoabuf, MAX_IPSTRLEN); + inet_ntop(aiptr->ai_family, &((struct sockaddr_in6*)aiptr->ai_addr)->sin6_addr, ntoabuf, MAX_IPSTRLEN); break; #endif default: @@ -281,7 +284,7 @@ lookup(const char *buf) */ if (NULL != AI && NULL != AI->ai_addr) { for (;;) { - if ( 0 == (res = xgetnameinfo(AI->ai_addr, AI->ai_addrlen, ntoabuf, MAX_IPSTRLEN, NULL,0,0)) ) + if ( 0 == (res = getnameinfo(AI->ai_addr, AI->ai_addrlen, ntoabuf, MAX_IPSTRLEN, NULL,0,0)) ) break; if (res != EAI_AGAIN) @@ -317,7 +320,7 @@ lookup(const char *buf) break; case EAI_FAIL: - printf("$fail DNS Domain/IP '%s' does not exist: %s.\n", buf, xgai_strerror(res)); + printf("$fail DNS Domain/IP '%s' does not exist: %s.\n", buf, gai_strerror(res)); break; #if defined(EAI_NODATA) || defined(EAI_NONAME) @@ -328,14 +331,14 @@ lookup(const char *buf) #ifdef EAI_NONAME case EAI_NONAME: #endif - printf("$fail DNS Domain/IP '%s' exists without any FQDN/IPs: %s.\n", buf, xgai_strerror(res)); + printf("$fail DNS Domain/IP '%s' exists without any FQDN/IPs: %s.\n", buf, gai_strerror(res)); break; #endif default: - printf("$fail A system error occured looking up Domain/IP '%s': %s.\n", buf, xgai_strerror(res)); + printf("$fail A system error occured looking up Domain/IP '%s': %s.\n", buf, gai_strerror(res)); } - xfreeaddrinfo(AI); + freeaddrinfo(AI); } /** diff --git a/src/eui/Eui64.cc b/src/eui/Eui64.cc index e11e6f04a8..b7be5d1466 100644 --- a/src/eui/Eui64.cc +++ b/src/eui/Eui64.cc @@ -9,17 +9,12 @@ #if USE_SQUID_EUI +#include "compat/eui64_aton.h" #include "Debug.h" #include "eui/Eui64.h" #include "globals.h" #include "ip/IpAddress.h" -#if HAVE_SYS_EUI64_H -#include -#else -#include "eui64_aton.h" -#endif - bool Eui::Eui64::decode(const char *asc) { diff --git a/src/event.cc b/src/event.cc index 612b8fcd71..dd0057884d 100644 --- a/src/event.cc +++ b/src/event.cc @@ -32,8 +32,10 @@ * */ -#include "event.h" +#include "config.h" +#include "compat/drand48.h" #include "CacheManager.h" +#include "event.h" #include "Store.h" #include "SquidTime.h" diff --git a/src/ftp.cc b/src/ftp.cc index 6d20ba8434..2a3c8fbc5f 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -35,6 +35,7 @@ #include "squid.h" #include "comm.h" #include "comm/ListenStateData.h" +#include "compat/strtoll.h" #include "ConnectionDetail.h" #include "errorpage.h" #include "fde.h" diff --git a/src/ip/IpAddress.cc b/src/ip/IpAddress.cc index 1aa2f047be..147aa161cf 100644 --- a/src/ip/IpAddress.cc +++ b/src/ip/IpAddress.cc @@ -35,11 +35,12 @@ */ #include "config.h" +#include "compat/inet_ntop.h" +#include "compat/getaddrinfo.h" #include "Debug.h" #include "ip/IpAddress.h" #include "util.h" - #if HAVE_ASSERT_H #include #endif @@ -477,11 +478,11 @@ bool IpAddress::LookupHostIP(const char *s, bool nodns) want.ai_family = AF_INET; #endif - if ( (err = xgetaddrinfo(s, NULL, &want, &res)) != 0) { - debugs(14,3, HERE << "Given Bad IP '" << s << "': " << xgai_strerror(err) ); - /* free the memory xgetaddrinfo() dynamically allocated. */ + if ( (err = getaddrinfo(s, NULL, &want, &res)) != 0) { + debugs(14,3, HERE << "Given Bad IP '" << s << "': " << gai_strerror(err) ); + /* free the memory getaddrinfo() dynamically allocated. */ if (res) { - xfreeaddrinfo(res); + freeaddrinfo(res); res = NULL; } return false; @@ -495,8 +496,8 @@ bool IpAddress::LookupHostIP(const char *s, bool nodns) operator=(*res); SetPort(port); - /* free the memory xgetaddrinfo() dynamically allocated. */ - xfreeaddrinfo(res); + /* free the memory getaddrinfo() dynamically allocated. */ + freeaddrinfo(res); res = NULL; @@ -973,16 +974,16 @@ char* IpAddress::NtoA(char* buf, const unsigned int blen, int force) const #if USE_IPV6 if ( force == AF_INET6 || (force == AF_UNSPEC && IsIPv6()) ) { - xinet_ntop(AF_INET6, &m_SocketAddr.sin6_addr, buf, blen); + inet_ntop(AF_INET6, &m_SocketAddr.sin6_addr, buf, blen); } else if ( force == AF_INET || (force == AF_UNSPEC && IsIPv4()) ) { struct in_addr tmp; GetInAddr(tmp); - xinet_ntop(AF_INET, &tmp, buf, blen); + inet_ntop(AF_INET, &tmp, buf, blen); #else if ( force == AF_UNSPEC || (force == AF_INET && IsIPv4()) ) { - xinet_ntop(AF_INET, &m_SocketAddr.sin_addr, buf, blen); + inet_ntop(AF_INET, &m_SocketAddr.sin_addr, buf, blen); #endif } else { debugs(14,0,"WARNING: Corrupt IP Address details OR required to display in unknown format (" << diff --git a/src/ip/IpAddress.h b/src/ip/IpAddress.h index d631b108c8..2b43ae0f57 100644 --- a/src/ip/IpAddress.h +++ b/src/ip/IpAddress.h @@ -36,11 +36,7 @@ #ifndef _INC_IPADDRESS_H #define _INC_IPADDRESS_H -#include "getaddrinfo.h" -#include "getnameinfo.h" -#include "inet_ntop.h" -#include "inet_pton.h" - +#include "config.h" #if HAVE_SYS_SOCKET_H #include diff --git a/src/ip/testIpAddress.cc b/src/ip/testIpAddress.cc index b86513b5be..b4841c52ce 100644 --- a/src/ip/testIpAddress.cc +++ b/src/ip/testIpAddress.cc @@ -1,4 +1,5 @@ #include "config.h" +#include "compat/getaddrinfo.h" #include "testIpAddress.h" #include "ip/IpAddress.h" @@ -610,7 +611,7 @@ testIpAddress::testAddrInfo() IpAddress anIP = "127.0.0.1"; /* assert this just to check that getaddrinfo is working properly */ - CPPUNIT_ASSERT( xgetaddrinfo("127.0.0.1", NULL, &hints, &expect ) == 0 ); + CPPUNIT_ASSERT( getaddrinfo("127.0.0.1", NULL, &hints, &expect ) == 0 ); anIP.GetAddrInfo(ipval); @@ -690,7 +691,7 @@ testIpAddress::testAddrInfo() CPPUNIT_ASSERT( memcmp( expect->ai_addr, ipval->ai_addr, expect->ai_addrlen ) == 0 ); - xfreeaddrinfo(expect); + freeaddrinfo(expect); } void diff --git a/src/snmp_core.cc b/src/snmp_core.cc index d27c781442..b5097ab3dc 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -30,9 +30,10 @@ * */ #include "squid.h" -#include "comm.h" -#include "cache_snmp.h" #include "acl/FilledChecklist.h" +#include "cache_snmp.h" +#include "comm.h" +#include "compat/strsep.h" #include "ip/IpAddress.h" #define SNMP_REQUEST_SIZE 4096 diff --git a/src/squid.h b/src/squid.h index 09e1d34924..5701aa8f41 100644 --- a/src/squid.h +++ b/src/squid.h @@ -154,44 +154,21 @@ using namespace Squid; #endif #include "md5.h" - #if USE_SSL #include "ssl_support.h" #endif - #ifdef SQUID_SNMP #include "cache_snmp.h" #endif - #include "hash.h" #include "rfc3596.h" - - #include "defines.h" #include "enums.h" #include "typedefs.h" #include "util.h" #include "profiling.h" #include "MemPool.h" - #include "ip/IpAddress.h" - -#if !HAVE_TEMPNAM -#include "tempnam.h" -#endif - -#if !HAVE_STRSEP -#include "strsep.h" -#endif - -#if !HAVE_STRTOLL -#include "strtoll.h" -#endif - -#if !HAVE_INITGROUPS -#include "initgroups.h" -#endif - #include "structs.h" #include "protos.h" #include "globals.h" diff --git a/src/tools.cc b/src/tools.cc index 91c2110e81..74ac708c9c 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -33,14 +33,18 @@ */ #include "squid.h" -#include "ProtoPort.h" -#include "SwapDir.h" +#include "compat/initgroups.h" +#include "compat/getaddrinfo.h" +#include "compat/getnameinfo.h" +#include "compat/tempnam.h" #include "fde.h" +#include "ip/IpIntercept.h" #include "MemBuf.h" -#include "wordlist.h" +#include "ProtoPort.h" #include "SquidMath.h" #include "SquidTime.h" -#include "ip/IpIntercept.h" +#include "SwapDir.h" +#include "wordlist.h" #if HAVE_SYS_PRCTL_H #include @@ -612,7 +616,7 @@ getMyHostname(void) sa.GetAddrInfo(AI); /* we are looking for a name. */ - if (xgetnameinfo(AI->ai_addr, AI->ai_addrlen, host, SQUIDHOSTNAMELEN, NULL, 0, NI_NAMEREQD ) == 0) { + if (getnameinfo(AI->ai_addr, AI->ai_addrlen, host, SQUIDHOSTNAMELEN, NULL, 0, NI_NAMEREQD ) == 0) { /* DNS lookup successful */ /* use the official name from DNS lookup */ debugs(50, 4, "getMyHostname: resolved " << sa << " to '" << host << "'"); @@ -636,7 +640,7 @@ getMyHostname(void) memset(&hints, 0, sizeof(addrinfo)); hints.ai_flags = AI_CANONNAME; - if (xgetaddrinfo(host, NULL, NULL, &AI) == 0) { + if (getaddrinfo(host, NULL, NULL, &AI) == 0) { /* DNS lookup successful */ /* use the official name from DNS lookup */ debugs(50, 6, "getMyHostname: '" << host << "' has rDNS."); @@ -644,14 +648,14 @@ getMyHostname(void) /* AYJ: do we want to flag AI_ALL and cache the result anywhere. ie as our local host IPs? */ if (AI) { - xfreeaddrinfo(AI); + freeaddrinfo(AI); AI = NULL; } return host; } - if (AI) xfreeaddrinfo(AI); + if (AI) freeaddrinfo(AI); debugs(50, 1, "WARNING: '" << host << "' rDNS test failed: " << xstrerror()); } } diff --git a/src/wccp2.cc b/src/wccp2.cc index 012be6dc77..76b4940bf6 100644 --- a/src/wccp2.cc +++ b/src/wccp2.cc @@ -35,11 +35,12 @@ #if USE_WCCPv2 #include "comm.h" +#include "compat/strsep.h" #include "event.h" +#include "ip/IpAddress.h" #include "Parsing.h" #include "Store.h" #include "SwapDir.h" -#include "ip/IpAddress.h" #if HAVE_NETDB_H #include diff --git a/test-suite/pconn-banger.c b/test-suite/pconn-banger.c index fccd83cb0c..7ca24bcd47 100644 --- a/test-suite/pconn-banger.c +++ b/test-suite/pconn-banger.c @@ -1,36 +1,5 @@ - #include "config.h" - -/* - * On some systems, FD_SETSIZE is set to something lower than the - * actual number of files which can be opened. IRIX is one case, - * NetBSD is another. So here we increase FD_SETSIZE to our - * configure-discovered maximum *before* any system includes. - */ -#define CHANGE_FD_SETSIZE 1 - -/* Cannot increase FD_SETSIZE on Linux */ -#if defined(_SQUID_LINUX_) -#undef CHANGE_FD_SETSIZE -#define CHANGE_FD_SETSIZE 0 -#endif - -/* Cannot increase FD_SETSIZE on FreeBSD before 2.2.0, causes select(2) - * to return EINVAL. */ -/* Marian Durkovic */ -/* Peter Wemm */ -#if defined(_SQUID_FREEBSD_) -#include -#if __FreeBSD_version < 220000 -#undef CHANGE_FD_SETSIZE -#define CHANGE_FD_SETSIZE 0 -#endif -#endif - -/* Increase FD_SETSIZE if SQUID_MAXFD is bigger */ -#if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE -#define FD_SETSIZE SQUID_MAXFD -#endif +#include "compat/getaddrinfo.h" #if HAVE_UNISTD_H #include @@ -81,8 +50,6 @@ #include #endif -#include "getaddrinfo.h" - #define PROXY_PORT "3128" #define PROXY_ADDR "127.0.0.1" #define MAX_FDS 1024 @@ -171,22 +138,19 @@ open_http_socket(void) hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - xgetaddrinfo(proxy_addr, proxy_port, &hints, AI); + getaddrinfo(proxy_addr, proxy_port, &hints, AI); if ((s = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol)) < 0) { perror("socket"); - xfreeaddrinfo(AI); - return -1; + s = -1; } - - if (connect(s, AI->ai_addr, AI->ai_addrlen) < 0) { + else if (connect(s, AI->ai_addr, AI->ai_addrlen) < 0) { close(s); perror("connect"); - xfreeaddrinfo(AI); - return -1; + s = -1; } - xfreeaddrinfo(AI); + freeaddrinfo(AI); return s; } diff --git a/tools/cachemgr.cc b/tools/cachemgr.cc index 0e4640dcfa..98a600b94a 100644 --- a/tools/cachemgr.cc +++ b/tools/cachemgr.cc @@ -31,6 +31,7 @@ */ #include "config.h" +#include "compat/tempnam.h" #include "rfc1738.h" #if HAVE_UNISTD_H -- 2.39.5