]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Merge from trunk
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 21 Jan 2009 08:13:42 +0000 (21:13 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 21 Jan 2009 08:13:42 +0000 (21:13 +1300)
64 files changed:
Makefile.am
configure.in
helpers/basic_auth/LDAP/Makefile.am
helpers/basic_auth/MSNT/Makefile.am
helpers/basic_auth/NCSA/Makefile.am
helpers/basic_auth/PAM/Makefile.am
helpers/basic_auth/SASL/Makefile.am
helpers/basic_auth/SMB/Makefile.am
helpers/basic_auth/YP/Makefile.am
helpers/basic_auth/getpwnam/Makefile.am
helpers/basic_auth/mswin_sspi/Makefile.am
helpers/basic_auth/squid_radius_auth/Makefile.am
helpers/digest_auth/eDirectory/Makefile.am
helpers/digest_auth/ldap/Makefile.am
helpers/digest_auth/password/Makefile.am
helpers/external_acl/ip_user/Makefile.am
helpers/external_acl/ldap_group/Makefile.am
helpers/external_acl/mswin_ad_group/Makefile.am
helpers/external_acl/mswin_lm_group/Makefile.am
helpers/external_acl/session/Makefile.am
helpers/external_acl/unix_group/Makefile.am
helpers/ntlm_auth/fakeauth/Makefile.am
helpers/ntlm_auth/mswin_sspi/Makefile.am
helpers/ntlm_auth/smb_lm/Makefile.am
helpers/ntlm_auth/smb_lm/smbval/Makefile.am
include/config.h
lib/Makefile.am
libsquid-compat/GnuRegex.c [moved from lib/GNUregex.c with 99% similarity]
libsquid-compat/GnuRegex.h [moved from include/GNUregex.h with 97% similarity]
libsquid-compat/Makefile.am [new file with mode: 0644]
libsquid-compat/assert.h [new file with mode: 0644]
libsquid-compat/compat.cc [new file with mode: 0644]
libsquid-compat/compat.h [new file with mode: 0644]
libsquid-compat/compat_shared.h [new file with mode: 0644]
libsquid-compat/os/squid_aix.h [new file with mode: 0644]
libsquid-compat/os/squid_freebsd.h [new file with mode: 0644]
libsquid-compat/os/squid_hpux.h [new file with mode: 0644]
libsquid-compat/os/squid_linux.h [new file with mode: 0644]
libsquid-compat/os/squid_mswin.h [new file with mode: 0644]
libsquid-compat/os/squid_next.h [new file with mode: 0644]
libsquid-compat/os/squid_openbsd.h [new file with mode: 0644]
libsquid-compat/os/squid_qnx.h [new file with mode: 0644]
libsquid-compat/os/squid_sgi.h [new file with mode: 0644]
libsquid-compat/os/squid_solaris.h [new file with mode: 0644]
libsquid-compat/os/squid_sunos.h [new file with mode: 0644]
libsquid-compat/os/squid_windows.h [new file with mode: 0644]
libsquid-compat/osdetect.h [new file with mode: 0644]
libsquid-compat/squid_fdsetsize.h [new file with mode: 0644]
libsquid-compat/squid_stdvarargs.h [new file with mode: 0644]
libsquid-compat/squid_valgrind.h [new file with mode: 0644]
snmplib/Makefile.am
src/ICAP/Makefile.am
src/Makefile.am
src/adaptation/Makefile.am
src/auth/Makefile.am
src/eCAP/Makefile.am
src/fs/Makefile.am
src/globals.h
src/icmp/Makefile.am
src/ip/Makefile.am
src/repl/Makefile.am
src/squid.h
test-suite/Makefile.am
tools/Makefile.am

index f90fc200bbff643ec678dd73a7df5e6604b8504f..59a259443dc086cd880c5c8eb797ff444457898b 100644 (file)
@@ -2,8 +2,8 @@
 #
 
 AUTOMAKE_OPTIONS = dist-bzip2 subdir-objects 1.5 foreign
-DIST_SUBDIRS   = lib snmplib scripts src icons errors contrib doc helpers test-suite tools
-SUBDIRS                = lib @makesnmplib@ scripts src/ip src icons errors doc helpers test-suite tools
+DIST_SUBDIRS   = libsquid-compat lib snmplib scripts src icons errors contrib doc helpers test-suite tools
+SUBDIRS                = libsquid-compat lib @makesnmplib@ scripts src/ip src icons errors doc helpers test-suite tools
 
 DISTCLEANFILES = include/stamp-h include/stamp-h[0-9]*
 DEFAULT_PINGER         = $(libexecdir)/`echo pinger | sed '$(transform);s/$$/$(EXEEXT)/'`
index 70d847769c4d2fd897b9820ec41f981139ca75a3..96b55b8bde6ad8581d431044f44b3a44e781ca55 100644 (file)
@@ -95,7 +95,7 @@ AC_PROG_RANLIB
 
 CRYPTLIB=''
 REGEXLIB=''    # -lregex
-LIBREGEX=''    # libregex.a
+# LIBREGEX=''  # libregex.a
 
 dnl find out the exe extension for this platform. If it's not empty, use it for CGI's as well.
 AC_EXEEXT
@@ -293,15 +293,6 @@ if test -z "$PRESET_LDFLAGS"; then
     fi
 fi
 
-AC_ARG_ENABLE(gnuregex,
-  AC_HELP_STRING([--enable-gnuregex],
-                 [Compile GNUregex.  Unless you have reason to use 
-                 this option, you should not enable it.
-                 This library file is usually only required on Windows and 
-                 very old Unix boxes which do not have their own regex 
-                 library built in.]),
-[USE_GNUREGEX=$enableval])
-
 SquidInline="yes"
 
 AC_ARG_ENABLE(optimizations,
@@ -3227,6 +3218,14 @@ if test "$LINUX_TPROXY2" ; then
     fi
 fi
 
+AC_ARG_ENABLE(gnuregex,
+  AC_HELP_STRING([--enable-gnuregex],
+                 [Compile GNUregex.  Unless you have reason to use 
+                 this option, you should not enable it.
+                 This library file is usually only required on Windows and 
+                 very old Unix boxes which do not have their own regex 
+                 library built in.]),
+[USE_GNUREGEX=$enableval])
 if test -z "$USE_GNUREGEX" ; then
     case "$host" in
     *-sun-solaris2.[[0-4]])
@@ -3250,12 +3249,12 @@ fi
 fi
 AC_MSG_RESULT($USE_GNUREGEX)
 if test "$USE_GNUREGEX" = "yes"; then
-       REGEXLIB="-lregex"
-       LIBREGEX="libregex.a"
+       # override system regex with ours. Not good. But what was asked for.
+       REGEXLIB=""
        AC_DEFINE(USE_GNUREGEX,1,[Define if we should use GNU regex])
 fi
 AC_SUBST(REGEXLIB)
-AC_SUBST(LIBREGEX)
+#AC_SUBST(LIBREGEX)
 
 dnl Not cached since people are likely to tune this
 AC_MSG_CHECKING(Default FD_SETSIZE value)
@@ -3811,6 +3810,7 @@ rm -f core
 
 AC_CONFIG_FILES([\
        Makefile \
+       libsquid-compat/Makefile \
        lib/Makefile \
        scripts/Makefile \
        scripts/RunCache \
index 1f5679393061cca48b541c1478be3df52e662f16..a721893ff114e246aeb4fb797c264704fb493671 100644 (file)
@@ -11,5 +11,13 @@ man_MANS             = squid_ldap_auth.8
 EXTRA_DIST             = squid_ldap_auth.8
 squid_ldap_auth_SOURCES        = squid_ldap_auth.c
 
-LDADD = -L$(top_builddir)/lib -lmiscutil $(LIB_LDAP) $(LIB_LBER) $(XTRA_LIBS)
-INCLUDES      = -I$(top_srcdir)/include
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(LIB_LDAP) \
+       $(LIB_LBER) \
+       $(XTRA_LIBS)
+
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/include
index ba42e433bb5b77ad8d603cdd12c698372631a98a..5e68b0bd91a1108c58e9f038c293358b7c19d084 100644 (file)
@@ -27,9 +27,12 @@ EXTRA_DIST = \
 sysconf_DATA = \
        msntauth.conf.default
 
-LDADD = -L$(top_builddir)/lib -lmiscutil $(XTRA_LIBS)
+LDADD = -L$(top_builddir)/lib -lmiscutil $(XTRA_LIBS) -L$(top_builddir)/libsquid-compat/libsquid-compat.la
 
-INCLUDES      = -I$(top_srcdir)/include
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/include \
+       -I$(top_srcdir)/src
 
 confload.o: confload.c
        $(COMPILE) -DSYSCONFDIR=\"$(sysconfdir)\" -c $(srcdir)/confload.c -o $@
@@ -41,5 +44,3 @@ install-data-local:
                echo "$(INSTALL_DATA) $(srcdir)/msntauth.conf.default $(DESTDIR)$(sysconfdir)/msntauth.conf" ; \
                $(INSTALL_DATA) $(srcdir)/msntauth.conf.default $(DESTDIR)$(sysconfdir)/msntauth.conf ; \
        fi
-
-       
index fc7e8c706d822b78d73c693ba474e3c9e856d408..f41aaa752a1e049c4f4850eea23b141162c01fb9 100644 (file)
@@ -10,5 +10,14 @@ libexec_PROGRAMS     = ncsa_auth
 ncsa_auth_SOURCES      = ncsa_auth.c crypt_md5.c crypt_md5.h
 man_MANS               = ncsa_auth.8
 EXTRA_DIST             = ncsa_auth.8
-LDADD                  = -L$(top_builddir)/lib -lmiscutil $(CRYPTLIB) $(XTRA_LIBS) $(SSLLIB)
-INCLUDES      = -I$(top_srcdir)/include
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(CRYPTLIB) \
+       $(XTRA_LIBS) \
+       $(SSLLIB)
+
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/include \
+       -I$(top_srcdir)/src
index 4ffc5219f55237b9c51d9662d543aa248cc9c6dd..321027c0c133ec4f3930b597c9e9c312a50f1064 100644 (file)
@@ -6,9 +6,16 @@
 #  Uncomment and customize the following to suit your needs:
 #
 
-INCLUDES       = -I$(top_srcdir)/include
-
 man_MANS               = pam_auth.8
 EXTRA_DIST             = pam_auth.8
 libexec_PROGRAMS       = pam_auth
-LDADD                  = -L$(top_builddir)/lib -lmiscutil -lpam $(XTRA_LIBS)
+
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/include
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       -lpam \
+       $(XTRA_LIBS)
index 428bc60b496e7eff86c99824fcfa63065c7a2f96..5a4030733015e7423f913f7d54c388879bb68d22 100644 (file)
@@ -6,8 +6,16 @@
 #  Uncomment and customize the following to suit your needs:
 #
 
-INCLUDES       = -I$(top_srcdir)/include
-
 libexec_PROGRAMS       = sasl_auth
-LDADD                  = -L$(top_builddir)/lib -lmiscutil $(LIBSASL) $(XTRA_LIBS)
+
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/include
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(LIBSASL) \
+       $(XTRA_LIBS)
+
 EXTRA_DIST             = squid_sasl_auth squid_sasl_auth.conf
index 97efe5fe722170b885e3a6e0ce12c29c116f6444..fcb640a1bf96728390026f073e111774ffdab9a3 100644 (file)
@@ -22,6 +22,11 @@ libexec_PROGRAMS = smb_auth
 smb_auth_CFLAGS = -DSAMBAPREFIX=\"$(SAMBAPREFIX)\" -DHELPERSCRIPT=\"$(SMB_AUTH_HELPER_PATH)\"
 EXTRA_DIST = smb_auth.sh COPYING-2.0
 
-LDADD  = -L$(top_builddir)/lib -lmiscutil $(XTRA_LIBS)
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/include
 
-INCLUDES       = -I$(top_srcdir)/include
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(XTRA_LIBS)
index 7f08bb8b35fdfa4dbe627e5c1daea9a303b3fda8..3caad7b3729b3b414c7f35c1d86c222f59a029f6 100644 (file)
@@ -7,5 +7,13 @@
 
 libexec_PROGRAMS = yp_auth
 yp_auth_SOURCES        = yp_auth.c nis_support.h nis_support.c
-LDADD  = -L$(top_builddir)/lib -lmiscutil $(CRYPTLIB) $(XTRA_LIBS)
-INCLUDES       = -I$(top_srcdir)/include
+
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/include
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(CRYPTLIB) \
+       $(XTRA_LIBS)
index d28550e461a125050ec653306ed044e6a0ddc94c..3c0eff0d38fa06e0420537aa90b008c39815bbe8 100644 (file)
@@ -11,5 +11,13 @@ libexec_PROGRAMS = getpwname_auth
 
 getpwname_auth_SOURCES = getpwnam_auth.c 
 
-INCLUDES      = -I$(top_srcdir)/include
-LDADD = -L$(top_builddir)/lib -lmiscutil $(CRYPTLIB) $(XTRA_LIBS)
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/include \
+       -I$(top_srcdir)/src
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(CRYPTLIB) \
+       $(XTRA_LIBS)
index ec4997a9f1fc090f046d768ccf9be72d5496b7e4..5bebac8bcc47d1665d9a9dbca855a71fa4910bb8 100644 (file)
@@ -11,9 +11,15 @@ libexec_PROGRAMS = mswin_auth
 
 mswin_auth_SOURCES = mswin_auth.c valid.c valid.h
 
-LDADD  = -L$(top_builddir)/lib -lnetapi32 -ladvapi32 -lsspwin32 \
-          -lmiscutil $(XTRA_LIBS)
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       -lnetapi32 -ladvapi32 -lsspwin32 \
+       $(XTRA_LIBS)
 
-INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/src
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
 
 EXTRA_DIST = readme.txt
index e543f60323ccb2620fab3ebca66dbc6d8c045911..5e117c24cd96ba8a39a28c2a8c250cc18738e25d 100644 (file)
@@ -15,5 +15,12 @@ squid_radius_auth_SOURCES = \
                        radius-util.c \
                        radius-util.h
 
-LDADD                  = -L$(top_builddir)/lib -lmiscutil $(SSLLIB) $(XTRA_LIBS)
-INCLUDES               = -I$(top_srcdir)/include
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/include
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(SSLLIB) \
+       $(XTRA_LIBS)
index 679f800f348b7765f43f5d6551ddee94f1322bc5..3e780bb76625c4cf42762a2fda3ee0b63449befb 100644 (file)
@@ -13,7 +13,18 @@ digest_edir_auth_SOURCES = digest_pw_auth.c \
        ldap_backend.h \
        edir_ldapext.c \
        edir_ldapext.h
-INCLUDES      = -I. -I$(top_builddir)/include -I$(top_srcdir)/include \
-               -I$(top_srcdir)/src/
 
-LDADD  = -L$(top_builddir)/lib -lmiscutil $(LIB_LDAP) $(LIB_LBER) $(CRYPTLIB) $(XTRA_LIBS) $(SSLLIB)
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(LIB_LDAP) \
+       $(LIB_LBER) \
+       $(CRYPTLIB) \
+       $(XTRA_LIBS) \
+       $(SSLLIB)
index 5d7c5f44b55d43d0c109abb01e43da9ed2ced936..b28b4786ae93186fd3928c46c9868d52d9b754a7 100644 (file)
@@ -11,7 +11,18 @@ digest_ldap_auth_SOURCES = digest_pw_auth.c \
        digest_common.h \
        ldap_backend.c \
        ldap_backend.h
-INCLUDES      = -I. -I$(top_builddir)/include -I$(top_srcdir)/include \
-               -I$(top_srcdir)/src/
 
-LDADD  = -L$(top_builddir)/lib -lmiscutil $(LIB_LDAP) $(LIB_LBER) $(CRYPTLIB) $(XTRA_LIBS) $(SSLLIB)
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(LIB_LDAP) \
+       $(LIB_LBER) \
+       $(CRYPTLIB) \
+       $(XTRA_LIBS) \
+       $(SSLLIB)
index 966063b7d62575c1bd21f3e12dd261e9cf3f731a..dedc6737af1c2935c4d0d6e7259fa5964563624c 100644 (file)
@@ -11,7 +11,16 @@ digest_pw_auth_SOURCES = digest_pw_auth.c \
        digest_common.h \
        text_backend.c \
        text_backend.h
-INCLUDES      = -I. -I$(top_builddir)/include -I$(top_srcdir)/include \
-               -I$(top_srcdir)/src/
 
-LDADD  = -L$(top_builddir)/lib -lmiscutil $(CRYPTLIB) $(XTRA_LIBS) $(SSLLIB)
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(CRYPTLIB) \
+       $(XTRA_LIBS) \
+       $(SSLLIB)
index 81cfff95231f4cfedad2c8a7c1d5274059a563b8..b6943424d067abf1accad30b34e07c625f6e73e8 100644 (file)
@@ -15,7 +15,6 @@ ip_user_check_SOURCES = \
        main.c \
        match.c
 
-
 EXTRA_DIST = \
        example.conf \
        example-deny_all_but.conf \
@@ -24,5 +23,13 @@ EXTRA_DIST = \
 
 # sysconf_DATA = 
 
-LDADD          = -L$(top_builddir)/lib -lmiscutil @XTRA_LIBS@
-INCLUDES       = -I. -I$(top_builddir)/include -I$(top_srcdir)/include
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       @XTRA_LIBS@
index 9f84b705be69ba0d7daec3c1aa308c9a98da2f37..3c5ee69aef016064e7a4dfd514d0b3430d617335 100644 (file)
@@ -11,5 +11,15 @@ man_MANS                     = squid_ldap_group.8
 EXTRA_DIST                     = squid_ldap_group.8
 squid_ldap_group_SOURCES       = squid_ldap_group.c
 
-LDADD          = -L$(top_builddir)/lib -lmiscutil $(LIB_LDAP) $(LIB_LBER) @XTRA_LIBS@
-INCLUDES       = -I. -I$(top_builddir)/include -I$(top_srcdir)/include
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(LIB_LDAP) \
+       $(LIB_LBER) \
+       @XTRA_LIBS@
index 666bd717efe594dd58da1e35a1922c9765e56914..3e8a66f53f49ef1e3352db164c40b422c24eadf5 100644 (file)
@@ -11,9 +11,16 @@ libexec_PROGRAMS = mswin_check_ad_group
 
 mswin_check_ad_group_SOURCES = mswin_check_ad_group.c mswin_check_ad_group.h
 
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/include
 
-LDADD   = -L$(top_builddir)/lib -lmiscutil -lnetapi32 -ladvapi32 \
-          -lntdll $(XTRA_LIBS)
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       -lnetapi32 \
+       -ladvapi32 \
+       -lntdll \
+       $(XTRA_LIBS)
 
 EXTRA_DIST = readme.txt
index af2add15e5168ab7ec46867a5a635bc3ec0b8f39..4fce8e5ff87eb3516946215a1c180552feb9817f 100644 (file)
@@ -11,9 +11,17 @@ libexec_PROGRAMS = mswin_check_lm_group
 
 mswin_check_lm_group_SOURCES = win32_check_group.c win32_check_group.h
 
-INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/src
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
 
-LDADD   = -L$(top_builddir)/lib -lmiscutil -lnetapi32 -ladvapi32 \
-          -lntdll $(XTRA_LIBS)
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       -lnetapi32 \
+       -ladvapi32 \
+       -lntdll \
+       $(XTRA_LIBS)
 
 EXTRA_DIST = readme.txt
index 1147ee43764b13eb5e7576c586dca29767f57667..4ed4e51f0e6bd41281432308442f60335051b400 100644 (file)
@@ -11,6 +11,12 @@ man_MANS                     = squid_session.8
 EXTRA_DIST                     = squid_session.8
 squid_session_SOURCES          = squid_session.c
 
-LDADD = $(LIB_DB) 
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
 
-INCLUDES       = -I. -I$(top_builddir)/include -I$(top_srcdir)/include
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       $(LIB_DB)
index 37efbddcc0323830cd74913a3b63a2cb4b4d7c1c..3fb066105c0b9009e9da004e3bc4e319de65eac6 100644 (file)
@@ -11,5 +11,13 @@ man_MANS                     = squid_unix_group.8
 EXTRA_DIST                     = squid_unix_group.8
 squid_unix_group_SOURCES       = check_group.c
 
-LDADD          = -L$(top_builddir)/lib -lmiscutil @XTRA_LIBS@
-INCLUDES       = -I. -I$(top_builddir)/include -I$(top_srcdir)/include
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       @XTRA_LIBS@
index 1c1272557f3a058a034568e79ebbb50c8cea1325..8e03d1783dfe75a262231ad1371db31ad38ffe24 100644 (file)
@@ -8,6 +8,15 @@
 
 libexec_PROGRAMS = fakeauth_auth
 fakeauth_auth_SOURCES  = fakeauth_auth.c ntlm.h
-INCLUDES      = -I. -I$(top_builddir)/include -I$(top_srcdir)/include \
-               -I$(top_srcdir)/src/
-LDADD  = -L$(top_builddir)/lib -lmiscutil $(CRYPTLIB) $(XTRA_LIBS)
+
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(CRYPTLIB) \
+       $(XTRA_LIBS)
index a4062fa674c8d442c9f958ce517d9becd31dc48e..d0eccfd0995e3d211465271c873a967951e53261 100644 (file)
@@ -8,9 +8,18 @@ libexec_PROGRAMS = mswin_ntlm_auth
 
 mswin_ntlm_auth_SOURCES = libntlmssp.c ntlm_auth.c ntlm.h
 
-INCLUDES      = -I. -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/src
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
 
-LDADD          = -L$(top_builddir)/lib -lntlmauth -lsspwin32 -lnetapi32 \
-                 -ladvapi32 -lmiscutil $(XTRA_LIBS)
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil -lntlmauth \
+       -lsspwin32 \
+       -lnetapi32 \
+       -ladvapi32 \
+       $(XTRA_LIBS)
 
 EXTRA_DIST = readme.txt
index 4f63f10f1e8f3101fbb3c9bb871df259b601d44e..70e1f1622e0f43895cf9a2856be10c43e42eefc6 100644 (file)
@@ -6,7 +6,18 @@ SUBDIRS = smbval
 
 libexec_PROGRAMS = ntlm_smb_lm_auth
 ntlm_smb_lm_auth_SOURCES = libntlmssp.c ntlm_smb_lm_auth.c ntlm_smb_lm_auth.h
-INCLUDES      = -I. -I$(top_builddir)/include -I$(top_srcdir)/include \
-               -I$(top_srcdir)/src/ -I$(srcdir)/smbval
-LDADD          = smbval/libsmbvalid.a -L$(top_builddir)/lib -lntlmauth \
-                 -lmiscutil $(CRYPTLIB) $(XTRA_LIBS)
+
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include \
+       -I$(top_srcdir)/src \
+       -I$(srcdir)/smbval
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lntlmauth -lmiscutil \
+       smbval/libsmbvalid.a \
+       $(CRYPTLIB) \
+       $(XTRA_LIBS)
index d783611d79d96e45cb6cb767a82fbdaa049544aa..85993914b8babb3f3c33d20bb8cc406be24b28c0 100644 (file)
@@ -1,9 +1,13 @@
 # makefile for smblib
 
-INCLUDES      = -I. -I$(top_builddir)/include -I$(top_srcdir)/include \
-               -I$(top_srcdir)/src/
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include
 
 noinst_LIBRARIES = libsmbvalid.a
+
 libsmbvalid_a_SOURCES = valid.c session.c rfcnb-util.c rfcnb-io.c \
        smblib-util.c smblib.c smbencrypt.c smbdes.c md4.c byteorder.h \
        rfcnb-error.h  rfcnb-util.h  smbencrypt.h     smblib.h        valid.h \
index a267e258d1c3a9f4d7817c388dcccb97fc83a73d..a050ff9e8b7b6720006ff3df8ccb73e3bd60b4b3 100644 (file)
@@ -55,6 +55,8 @@
  *--------------------------------------------------------------------------*
  ****************************************************************************/
 
+#include "compat.h"
+
 #ifdef USE_POSIX_REGEX
 #ifndef USE_RE_SYNTAX
 #define USE_RE_SYNTAX  REG_EXTENDED    /* default Syntax */
 */
 #endif
 
-/* FD_SETSIZE must be redefined before including sys/types.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, but we can increase __FD_SETSIZE
- * with glibc 2.2 (or later? remains to be seen). We do this by including
- * bits/types.h which defines __FD_SETSIZE first, then we redefine
- * __FD_SETSIZE. Ofcourse a user program may NEVER include bits/whatever.h
- * directly, so this is a dirty hack!
- */
-#if defined(_SQUID_LINUX_)
-#undef CHANGE_FD_SETSIZE
-#define CHANGE_FD_SETSIZE 0
-#include <features.h>
-#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
-#if SQUID_MAXFD > DEFAULT_FD_SETSIZE
-#include <bits/types.h>
-#undef __FD_SETSIZE
-#define __FD_SETSIZE SQUID_MAXFD
-#endif
-#endif
-#endif
-
-/*
- * Cannot increase FD_SETSIZE on FreeBSD before 2.2.0, causes select(2)
- * to return EINVAL.
- * --Marian Durkovic <marian@svf.stuba.sk>
- * --Peter Wemm <peter@spinner.DIALix.COM>
- */
-#if defined(_SQUID_FREEBSD_)
-#include <osreldate.h>
-#if __FreeBSD_version < 220000
-#undef CHANGE_FD_SETSIZE
-#define CHANGE_FD_SETSIZE 0
-#endif
-#endif
-
-/*
- * Trying to redefine CHANGE_FD_SETSIZE causes a slew of warnings
- * on Mac OS X Server.
- */
-#if defined(_SQUID_APPLE_)
-#undef CHANGE_FD_SETSIZE
-#define CHANGE_FD_SETSIZE 0
-#endif
-
-/* Increase FD_SETSIZE if SQUID_MAXFD is bigger */
-#if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
-#define FD_SETSIZE SQUID_MAXFD
-#endif
-
 /* Typedefs for missing entries on a system */
 
 #include "squid_types.h"
index 1723963b39735d6c3bca698df6786ecfe885ca37..86c51f11a95fd11c8e50ae75357a33dd552fec83 100644 (file)
@@ -47,13 +47,12 @@ WIN32SRC=
 endif
 
 EXTRA_LIBRARIES = \
-       libregex.a \
        libsspwin32.a
 noinst_LIBRARIES = \
        libmiscutil.a \
        libntlmauth.a \
-       $(LIBSSPWIN32) \
-       @LIBREGEX@
+       $(LIBSSPWIN32)
+
 #
 # dirent.c, encrypt.c and getopt.c are needed for native Windows support.
 #
@@ -99,8 +98,6 @@ libmiscutil_a_LIBADD = \
        libTrie/src/TrieNode.o \
        @LIBOBJS@
 # $(top_srcdir)/include/version.h should be a dependency
-libregex_a_SOURCES = \
-       GNUregex.c
 libntlmauth_a_SOURCES = \
        ntlmauth.c
 libntlmauth_a_LIBADD = \
@@ -108,7 +105,7 @@ libntlmauth_a_LIBADD = \
 libsspwin32_a_SOURCES = \
        sspwin32.c
 
-INCLUDES       = -I$(top_builddir)/include -I$(top_srcdir)/include @SQUID_CPPUNIT_INC@
+INCLUDES       = -I$(top_builddir)/include -I$(top_srcdir)/include @SQUID_CPPUNIT_INC@ -I$(top_srcdir)/libsquid-compat
 ##FIXME - set these in configure.in and reuse
 
 check_PROGRAMS= \
similarity index 99%
rename from lib/GNUregex.c
rename to libsquid-compat/GnuRegex.c
index 0091bf51bba3757e45631a1ab04ac6e6babea23d..4018e1716d78ac35d931d5ef718db246a353ca95 100644 (file)
@@ -34,6 +34,8 @@
 
 #include "config.h"
 
+#if USE_GNUREGEX /* only if squid needs it. Usually not */
+
 #if !HAVE_ALLOCA
 #define REGEX_MALLOC 1
 #endif
@@ -104,7 +106,7 @@ init_syntax_once(void)
 
 \f
 /* Get the interface, including the syntax bits.  */
-#include "GNUregex.h"
+#include "GnuRegex.h"
 
 /* Compile a fastmap for the compiled pattern in BUFFER; used to
  * accelerate searches.  Return 0 if successful and -2 if was an
@@ -2362,10 +2364,14 @@ typedef struct {
  * the pattern buffer.
  *
  * Returns 0 if we succeed, -2 if an internal error.   */
-
+#ifdef STDC_HEADERS
+int
+re_compile_fastmap(struct re_pattern_buffer *bufp)
+#else
 int
 re_compile_fastmap(bufp)
 struct re_pattern_buffer *bufp;
+#endif
 {
     int j, k;
     fail_stack_type fail_stack;
@@ -4401,6 +4407,7 @@ regex_t *preg;
         free(preg->translate);
     preg->translate = NULL;
 }
+#endif /* USE_GNUREGEX */
 \f
 /*
  * Local variables:
similarity index 97%
rename from include/GNUregex.h
rename to libsquid-compat/GnuRegex.h
index 65443fefbf50654ec4de61b535105e6d4b9ed707..286e4ff6fb2f31a33f57554a2baaad5b9f536f83 100644 (file)
@@ -1,10 +1,31 @@
 /*
  * $Id$
  */
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
 #ifndef SQUID_REGEXP_LIBRARY_H
 #define SQUID_REGEXP_LIBRARY_H
 
-#include "config.h"
+#if !USE_GNUREGEX /* try the system one by default */
+
+/* POSIX says that <sys/types.h> must be included (by the caller) before
+ * <regex.h>.  */
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_REGEX_H
+#include <regex.h>
+#endif
+
+
+#else  /* USE_GNUREGEX */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
 
 /* Definitions for data structures and routines for the regular
  * expression library, version 0.12.
@@ -405,6 +426,11 @@ extern size_t regerror
               size_t errbuf_size));
 extern void regfree _RE_ARGS((regex_t * preg));
 
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* USE_GNUREGEX */
 #endif /* SQUID_REGEXP_LIBRARY_H */
 \f
 /*
diff --git a/libsquid-compat/Makefile.am b/libsquid-compat/Makefile.am
new file mode 100644 (file)
index 0000000..62b680d
--- /dev/null
@@ -0,0 +1,59 @@
+#
+#  Makefile for the Squid Portability Library
+#
+
+# Housekeeping, shared by all Squid Makefiles.
+# TODO: make this set by configure?
+AM_CFLAGS = @SQUID_CFLAGS@
+AM_CXXFLAGS = @SQUID_CXXFLAGS@
+DEFS = @DEFS@
+CLEANFILES = 
+
+INCLUDES = -I. -I$(top_srcdir)/src @SQUID_CPPUNIT_INC@ -I$(top_srcdir)/include -I$(top_builddir)/lib
+$(OBJS): $(top_srcdir)/include/version.h $(top_srcdir)/include/autoconf.h
+
+# Ideally this would be 100% inline functions and macro wrappers.
+
+# Port Specific Configurations
+
+noinst_LTLIBRARIES = libsquid-compat.la
+
+libsquid_compat_la_SOURCES = \
+       compat.h \
+       osdetect.h \
+       compat_shared.h \
+       gnuregex.h \
+       squid_fdsetsize.h \
+       squid_stdvarargs.h \
+       squid_valgrind.h \
+       \
+       os/squid_aix.h \
+       os/squid_freebsd.h \
+       os/squid_hpux.h \
+       os/squid_linux.h \
+       os/squid_mswin.h \
+       os/squid_next.h \
+       os/squid_openbsd.h \
+       os/squid_qnx.h \
+       os/squid_sgi.h \
+       os/squid_solaris.h \
+       os/squid_sunos.h \
+       os/squid_windows.h \
+       \
+       compat.cc \
+       GnuRegex.c
+
+
+check_PROGRAMS= testHeaders
+TESTS= $(check_PROGRAMS)
+
+## Special Universal .h dependency test script
+## aborts if error encountered
+testHeaders: $(top_srcdir)/libsquid-compat/*.h $(top_srcdir)/libsquid-compat/os/*.h
+       $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(top_srcdir)/libsquid-compat/" || exit 1
+       $(SHELL) $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "$(top_srcdir)/libsquid-compat/os/" || exit 1
+
+## No such file...
+testHeaders.c:
+       touch testHeaders.c
+CLEANFILES += testHeaders.c
diff --git a/libsquid-compat/assert.h b/libsquid-compat/assert.h
new file mode 100644 (file)
index 0000000..6ad63dc
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * $Id$
+ *
+ * AUTHOR: Duane Wessels
+ *
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_ASSERT_H
+#define SQUID_ASSERT_H
+
+#if defined(NODEBUG)
+#define assert(EX) ((void)0)
+#elif STDC_HEADERS
+#define assert(EX)  ((EX)?((void)0):xassert( # EX , __FILE__, __LINE__))
+#else
+#define assert(EX)  ((EX)?((void)0):xassert("EX", __FILE__, __LINE__))
+#endif
+SQUIDCEXTERN void xassert(const char *, const char *, int);
+
+#endif /* SQUID_ASSERT_H */
diff --git a/libsquid-compat/compat.cc b/libsquid-compat/compat.cc
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/libsquid-compat/compat.h b/libsquid-compat/compat.h
new file mode 100644 (file)
index 0000000..d959778
--- /dev/null
@@ -0,0 +1,91 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef _SQUID_COMPAT_H
+#define _SQUID_COMPAT_H
+
+/*
+ * From discussions it was chosen to push compat code as far down as possible.
+ * That means we can eventually have a seperate libcompat for most
+ *  compatability and portability hacks and resolutions.
+ * 
+ * This file is meant to collate all those hacks files together and
+ * provide a simple include form them in the core squid headers
+ * (presently squid.h and config.h) 
+ *
+ * It should not be included directly in any of the squid sources.
+ * If your code requires any symbols from here you should be importing
+ * squid.h at the top line of your .cc or .h file.
+ */
+
+
+/******************************************************/
+/* Define the _SQUID_TYPE_ based on a guess of the OS */
+/* NP: this MUST come first within compat.h           */
+/******************************************************/
+#include "osdetect.h"
+
+
+/*****************************************************/
+/* FDSETSIZE is messy and needs to be done before    */
+/* sys/types.h are defined.                          */
+/*****************************************************/
+#include "squid_fdsetsize.h"
+
+
+/*****************************************************/
+/* Global type re-definitions                        */
+/* this also takes care of the basic system includes */
+/*****************************************************/
+
+/** On linux this must be defined to get PRId64 and friends */
+#define __STDC_FORMAT_MACROS
+
+#include "squid_types.h"
+
+/*****************************************************/
+/* per-OS hacks. One file per OS.                    */
+/* OS-macro wrapping should be done inside the OS .h */
+/*****************************************************/
+
+#include "os/squid_aix.h"
+#include "os/squid_freebsd.h"
+#include "os/squid_hpux.h"
+#include "os/squid_linux.h"
+#include "os/squid_mswin.h"
+#include "os/squid_next.h"
+#include "os/squid_openbsd.h"
+#include "os/squid_qnx.h"
+#include "os/squid_sgi.h"
+#include "os/squid_solaris.h"
+#include "os/squid_windows.h"
+
+/*****************************************************/
+/* portabilities shared between all platforms and    */
+/* components as found to be needed                  */
+/*****************************************************/
+
+#include "compat_shared.h"
+#include "squid_stdvarargs.h"
+#include "assert.h"
+
+/*****************************************************/
+/* component-specific portabilities                  */
+/*****************************************************/
+
+/* Valgrind API macros changed between two versions squid supports */
+#include "squid_valgrind.h"
+
+/* Endian functions are usualy handled by the OS but not always. */
+#include "squid_endian.h"
+
+/**
+ * A Regular Expression library is bundled with Squid.
+ * Default is to use a system provided one, but the bundle
+ * may be used instead with explicit configuration.
+ */
+#include "GnuRegex.h"
+
+
+#endif /* _SQUID_COMPAT_H */
diff --git a/libsquid-compat/compat_shared.h b/libsquid-compat/compat_shared.h
new file mode 100644 (file)
index 0000000..a2bc9a4
--- /dev/null
@@ -0,0 +1,211 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef _SQUID_COMPAT_SHARED_H
+#define _SQUID_COMPAT_SHARED_H
+
+/*
+ * This file contains all the compatibility and portability hacks
+ * Which are general-case and shared between all OS and support programs.
+ * 
+ * If an OS-specific hack is needed there are per-OS files for that in
+ * the os/ sub-directory here.
+ *
+ * These hacks should be platform and location agnostic.
+ * A quick look-over of the code already here should give you an idea
+ * of the requirements for wrapping your hack for safe portability.
+ */
+
+
+/*
+ * sys/resource.h and sys/time.h are apparently order-dependant.
+ */
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#if HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>       /* needs sys/time.h above it */
+#endif
+
+/*
+ * DIRENT functionality can apparently come from many places.
+ * I believe these should really be done by OS-specific compat
+ * files, but for now its left here.
+ */
+#if HAVE_DIRENT_H
+#include <dirent.h>
+#define NAMLEN(dirent) strlen((dirent)->d_name)
+
+#else /* if not HAVE_DIRENT_H */
+#define dirent direct
+#define NAMLEN(dirent) (dirent)->d_namlen
+#if HAVE_SYS_NDIR_H
+#include <sys/ndir.h>
+#endif /* HAVE_SYS_NDIR_H */
+#if HAVE_SYS_DIR_H
+#include <sys/dir.h>
+#endif /* HAVE_SYS_DIR_H */
+#if HAVE_NDIR_H
+#include <ndir.h>
+#endif /* HAVE_NDIR_H */
+#endif /* HAVE_DIRENT_H */
+
+
+/*
+ * Filedescriptor limits in the different select loops
+ * 
+ * NP: FreeBSD 7 defines FD_SETSIZE as unsigned but Squid needs
+ *     it to be signed to compare it with signed values.
+ *     Linux and others including FreeBSD <7, define it as signed.
+ *     If this causes any issues please contact squid-dev@squid-cache.org
+ */
+#if defined(USE_SELECT) || defined(USE_SELECT_WIN32)
+/* Limited by design */
+# define SQUID_MAXFD_LIMIT    ((signed int)FD_SETSIZE)
+
+#elif defined(USE_POLL)
+/* Limited due to delay pools */
+# define SQUID_MAXFD_LIMIT    ((signed int)FD_SETSIZE)
+
+#elif defined(USE_KQUEUE) || defined(USE_EPOLL)
+# define SQUID_FDSET_NOUSE 1
+
+#else
+# error Unknown select loop model!
+#endif
+
+
+
+#if !HAVE_STRUCT_RUSAGE
+/**
+ * If we don't have getrusage() then we create a fake structure
+ * with only the fields Squid cares about.  This just makes the
+ * source code cleaner, so we don't need lots of #ifdefs in other
+ * places
+ */
+struct rusage
+{
+    struct timeval ru_stime;
+    struct timeval ru_utime;
+    int ru_maxrss;
+    int ru_majflt;
+};
+#endif /* !HAVE_STRUCT_RUSAGE */
+
+
+/* templates require C++ */
+#ifdef __cplusplus
+
+#ifndef min
+/**
+ * min() comparison may not always be provided.
+ * Squid bundles this template for when its needed.
+ * May be used on any type which provides operator '<'
+ */
+template<class A>
+inline A const &
+min(A const & lhs, A const & rhs)
+{
+    if (rhs < lhs)
+        return rhs;
+    return lhs;
+}
+#endif
+#define XMIN(x,y) (min (x,y))
+
+#ifndef max
+/**
+ * max() comparison may not always be provided.
+ * Squid bundles this template for when its needed.
+ * May be used on any type which provides operator '>'
+ */
+template<class A>
+inline A const &
+max(A const & lhs, A const & rhs)
+{
+    if (rhs > lhs)
+        return rhs;
+    return lhs;
+}
+#endif
+#define XMAX(a,b) (max (a,b))
+
+#endif /* __cplusplus */
+
+/**
+ * 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
+
+
+/* REQUIRED for the below logics. If they move this needs to as well */
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#if defined(O_NONBLOCK)
+/**
+ * We used to assume O_NONBLOCK was broken on Solaris, but evidence
+ * now indicates that its fine on Solaris 8, and in fact required for
+ * properly detecting EOF on FIFOs.  So now we assume that if
+ * its defined, it works correctly on all operating systems.
+ */
+#define SQUID_NONBLOCK O_NONBLOCK
+#else
+/** O_NDELAY is our fallback. */
+#define SQUID_NONBLOCK O_NDELAY
+#endif
+
+
+/**
+ * Signalling flags are apparently not always provided.
+ * TODO find out if these can be moved into specific OS portability files.
+ */
+#ifndef SA_RESTART
+#define SA_RESTART 0
+#endif
+#ifndef SA_NODEFER
+#define SA_NODEFER 0
+#endif
+#ifndef SA_RESETHAND
+#define SA_RESETHAND 0
+#endif
+#if SA_RESETHAND == 0 && defined(SA_ONESHOT)
+#undef SA_RESETHAND
+#define SA_RESETHAND SA_ONESHOT
+#endif
+
+
+#endif /* _SQUID_COMPAT_SHARED_H */
diff --git a/libsquid-compat/os/squid_aix.h b/libsquid-compat/os/squid_aix.h
new file mode 100644 (file)
index 0000000..3286eb4
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_AIX_H
+#define SQUID_OS_AIX_H
+
+#ifdef _SQUID_AIX_
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+
+/*
+ * Syslog facility on AIX requires some portability wrappers
+ */
+#ifdef HAVE_SYSLOG_H
+#define _XOPEN_EXTENDED_SOURCE
+#define _XOPEN_SOURCE_EXTENDED 1
+#endif
+
+
+#endif /* _SQUID_AIX_ */
+#endif /* SQUID_OS_AIX_H */
diff --git a/libsquid-compat/os/squid_freebsd.h b/libsquid-compat/os/squid_freebsd.h
new file mode 100644 (file)
index 0000000..e4fb395
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_FREEBSD_H
+#define SQUID_OS_FREEBSD_H
+
+#ifdef _SQUID_FREEBSD_
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+
+#if USE_ASYNC_IO && defined(LINUXTHREADS)
+#define _SQUID_LINUX_THREADS_
+#endif
+
+/*
+ * Don't allow inclusion of malloc.h
+ */
+#if defined(HAVE_MALLOC_H)
+#undef HAVE_MALLOC_H
+#endif
+
+#define _etext etext
+
+#endif /* _SQUID_FREEBSD_ */
+#endif /* SQUID_OS_FREEBSD_H */
diff --git a/libsquid-compat/os/squid_hpux.h b/libsquid-compat/os/squid_hpux.h
new file mode 100644 (file)
index 0000000..993d14d
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_HPUX_H
+#define SQUID_OS_PHUX_H
+
+#ifdef _SQUID_HPUX_
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+
+#if !defined(HAVE_GETPAGESIZE)
+#define HAVE_GETPAGESIZE
+#define getpagesize( )   sysconf(_SC_PAGE_SIZE)
+#endif
+
+/*
+ * getrusage(...) not available on some HPUX
+ */
+#if !HAVE_GETRUSAGE
+#define HAVE_GETRUSAGE 1
+#define getrusage(a, b)  syscall(SYS_GETRUSAGE, a, b)
+#endif
+
+
+#endif /* _SQUID_HPUX_ */
+#endif /* SQUID_OS_HPUX_H */
diff --git a/libsquid-compat/os/squid_linux.h b/libsquid-compat/os/squid_linux.h
new file mode 100644 (file)
index 0000000..947de98
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_LINUX_H
+#define SQUID_OS_LINUX_H
+
+#ifdef _SQUID_LINUX_
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+
+#if USE_ASYNC_IO
+#define _SQUID_LINUX_THREADS_
+#endif
+
+/*
+ * res_init() is just a macro re-definition of __res_init on Linux (Debian/Ubuntu)
+ */
+#if !defined(HAVE_RES_INIT) && defined(HAVE___RES_INIT) && !defined(res_init)
+#define res_init  __res_init
+#define HAVE_RES_INIT  HAVE___RES_INIT
+#endif
+
+
+#endif /* _SQUID_LINUX_ */
+#endif /* SQUID_OS_LINUX_H */
diff --git a/libsquid-compat/os/squid_mswin.h b/libsquid-compat/os/squid_mswin.h
new file mode 100644 (file)
index 0000000..fd0860c
--- /dev/null
@@ -0,0 +1,768 @@
+/*
+ * $Id$
+ *
+ * AUTHOR: Andrey Shorin <tolsty@tushino.com>
+ * AUTHOR: Guido Serassio <serassio@squid-cache.org>
+ *
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_MSWIN_H
+#define SQUID_OS_MSWIN_H
+
+#ifdef _SQUID_WIN32_
+
+#define ACL WindowsACL
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+#if _MSC_VER == 1400
+#define _CRT_SECURE_NO_DEPRECATE
+#pragma warning( disable : 4290 )
+#pragma warning( disable : 4996 )
+#endif
+#endif
+
+#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
+# define __USE_FILE_OFFSET64   1
+#endif
+
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned __int64 uint64_t;
+
+typedef long pid_t;
+
+#if defined __USE_FILE_OFFSET64
+typedef int64_t off_t;
+typedef uint64_t ino_t;
+
+#else
+typedef long off_t;
+typedef unsigned long ino_t;
+
+#endif
+
+#define INT64_MAX _I64_MAX
+#define INT64_MIN _I64_MIN
+
+#include "default_config_file.h"
+/* Some tricks for MS Compilers */
+#define __STDC__ 1
+#define THREADLOCAL __declspec(thread)
+
+#elif defined(__GNUC__) /* gcc environment */
+
+#define THREADLOCAL __attribute__((section(".tls")))
+
+#endif
+
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+#define alloca _alloca
+#endif
+#define chdir _chdir
+#define dup _dup
+#define dup2 _dup2
+#define fdopen _fdopen
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+#define fileno _fileno
+#define fstat _fstati64
+#endif
+#define ftruncate WIN32_ftruncate
+#define getcwd _getcwd
+#define getpid _getpid
+#define getrusage WIN32_getrusage
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+#define lseek _lseeki64
+#define memccpy _memccpy
+#define mkdir(p) _mkdir(p)
+#define mktemp _mktemp
+#endif
+#define pclose _pclose
+#define pipe WIN32_pipe
+#define popen _popen
+#define putenv _putenv
+#define setmode _setmode
+#define sleep(t) Sleep((t)*1000)
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+#define snprintf _snprintf
+#define stat _stati64
+#define strcasecmp _stricmp
+#define strdup _strdup
+#define strlwr _strlwr
+#define strncasecmp _strnicmp
+#define tempnam _tempnam
+#endif
+#define truncate WIN32_truncate
+#define umask _umask
+#define unlink _unlink
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+#define vsnprintf _vsnprintf
+#endif
+
+#define O_RDONLY        _O_RDONLY
+#define O_WRONLY        _O_WRONLY
+#define O_RDWR          _O_RDWR
+#define O_APPEND        _O_APPEND
+
+#define O_CREAT         _O_CREAT
+#define O_TRUNC         _O_TRUNC
+#define O_EXCL          _O_EXCL
+
+#define O_TEXT          _O_TEXT
+#define O_BINARY        _O_BINARY
+#define O_RAW           _O_BINARY
+#define O_TEMPORARY     _O_TEMPORARY
+#define O_NOINHERIT     _O_NOINHERIT
+#define O_SEQUENTIAL    _O_SEQUENTIAL
+#define O_RANDOM        _O_RANDOM
+#define O_NDELAY       0
+
+#define S_IFMT   _S_IFMT
+#define S_IFDIR  _S_IFDIR
+#define S_IFCHR  _S_IFCHR
+#define S_IFREG  _S_IFREG
+#define S_IREAD  _S_IREAD
+#define S_IWRITE _S_IWRITE
+#define S_IEXEC  _S_IEXEC
+
+#define S_IRWXO 007
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+#define        S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
+#endif
+
+#define        SIGHUP  1       /* hangup */
+#define        SIGKILL 9       /* kill (cannot be caught or ignored) */
+#define        SIGBUS  10      /* bus error */
+#define        SIGPIPE 13      /* write on a pipe with no one to read it */
+#define        SIGCHLD 20      /* to parent on child stop or exit */
+#define SIGUSR1 30     /* user defined signal 1 */
+#define SIGUSR2 31     /* user defined signal 2 */
+
+typedef unsigned short int ushort;
+typedef int uid_t;
+typedef int gid_t;
+
+struct passwd {
+    char    *pw_name;      /* user name */
+    char    *pw_passwd;    /* user password */
+    uid_t   pw_uid;        /* user id */
+    gid_t   pw_gid;        /* group id */
+    char    *pw_gecos;     /* real name */
+    char    *pw_dir;       /* home directory */
+    char    *pw_shell;     /* shell program */
+};
+
+struct group {
+    char    *gr_name;      /* group name */
+    char    *gr_passwd;    /* group password */
+    gid_t   gr_gid;        /* group id */
+    char    **gr_mem;      /* group members */
+};
+
+struct statfs {
+    long    f_type;     /* type of filesystem (see below) */
+    long    f_bsize;    /* optimal transfer block size */
+    long    f_blocks;   /* total data blocks in file system */
+    long    f_bfree;    /* free blocks in fs */
+    long    f_bavail;   /* free blocks avail to non-superuser */
+    long    f_files;    /* total file nodes in file system */
+    long    f_ffree;    /* free file nodes in fs */
+    long    f_fsid;     /* file system id */
+    long    f_namelen;  /* maximum length of filenames */
+    long    f_spare[6]; /* spare for later */
+};
+
+#ifndef HAVE_GETTIMEOFDAY
+struct timezone {
+    int        tz_minuteswest; /* minutes west of Greenwich */
+    int        tz_dsttime;     /* type of dst correction */
+};
+#endif
+
+#define CHANGE_FD_SETSIZE 1
+#if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
+#define FD_SETSIZE SQUID_MAXFD
+#endif
+
+#include <stddef.h>
+#include <process.h>
+#include <errno.h>
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+#include <winsock2.h>
+#endif
+#include <ws2tcpip.h>
+#if (EAI_NODATA == EAI_NONAME)
+#undef EAI_NODATA
+#define EAI_NODATA WSANO_DATA
+#endif
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+/* Hack to suppress compiler warnings on FD_SET() & FD_CLR() */
+#pragma warning (push)
+#pragma warning (disable:4142)
+#endif
+/* prevent inclusion of wingdi.h */
+#define NOGDI
+#include <ws2spi.h>
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+#pragma warning (pop)
+#endif
+#include <io.h>
+#include <stdlib.h>
+
+typedef char * caddr_t;
+
+#undef FD_CLOSE
+#undef FD_OPEN
+#undef FD_READ
+#undef FD_WRITE
+#define EISCONN WSAEISCONN
+#define EINPROGRESS WSAEINPROGRESS
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define EALREADY WSAEALREADY
+#define ETIMEDOUT WSAETIMEDOUT
+#define ECONNREFUSED WSAECONNREFUSED
+#define ECONNRESET WSAECONNRESET
+#define ENOTCONN WSAENOTCONN
+#define ERESTART WSATRY_AGAIN
+#define EAFNOSUPPORT WSAEAFNOSUPPORT
+
+#undef h_errno
+#define h_errno errno /* we'll set it ourselves */
+
+#undef FD_CLR
+#define FD_CLR(fd, set) do { \
+    u_int __i; \
+    SOCKET __sock = _get_osfhandle(fd); \
+    for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \
+        if (((fd_set FAR *)(set))->fd_array[__i] == __sock) { \
+            while (__i < ((fd_set FAR *)(set))->fd_count-1) { \
+                ((fd_set FAR *)(set))->fd_array[__i] = \
+                    ((fd_set FAR *)(set))->fd_array[__i+1]; \
+                __i++; \
+            } \
+            ((fd_set FAR *)(set))->fd_count--; \
+            break; \
+        } \
+    } \
+} while(0)
+
+#undef FD_SET
+#define FD_SET(fd, set) do { \
+    u_int __i; \
+    SOCKET __sock = _get_osfhandle(fd); \
+    for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
+        if (((fd_set FAR *)(set))->fd_array[__i] == (__sock)) { \
+            break; \
+        } \
+    } \
+    if (__i == ((fd_set FAR *)(set))->fd_count) { \
+        if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \
+            ((fd_set FAR *)(set))->fd_array[__i] = (__sock); \
+            ((fd_set FAR *)(set))->fd_count++; \
+        } \
+    } \
+} while(0)
+
+#undef FD_ISSET
+#define FD_ISSET(fd, set) Win32__WSAFDIsSet(fd, (fd_set FAR *)(set))
+
+/* internal to Microsoft CRTLIB */
+typedef struct {
+    long osfhnd;    /* underlying OS file HANDLE */
+    char osfile;    /* attributes of file (e.g., open in text mode?) */
+    char pipech;    /* one char buffer for handles opened on pipes */
+#ifdef _MT
+    int lockinitflag;
+    CRITICAL_SECTION lock;
+#endif  /* _MT */
+}   ioinfo;
+#define IOINFO_L2E          5
+#define IOINFO_ARRAY_ELTS   (1 << IOINFO_L2E)
+#define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)) )
+#define _osfile(i)  ( _pioinfo(i)->osfile )
+#define _osfhnd(i)  ( _pioinfo(i)->osfhnd )
+#define FOPEN           0x01    /* file handle open */
+
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+
+SQUIDCEXTERN _CRTIMP ioinfo * __pioinfo[];
+SQUIDCEXTERN int __cdecl _free_osfhnd(int);
+
+#elif defined(__MINGW32__) /* MinGW environment */
+
+__MINGW_IMPORT ioinfo * __pioinfo[];
+SQUIDCEXTERN int _free_osfhnd(int);
+
+#endif
+
+SQUIDCEXTERN THREADLOCAL int ws32_result;
+
+#define strerror(e) WIN32_strerror(e)
+
+#ifdef __cplusplus
+
+inline
+int close(int fd)
+{
+    char l_so_type[sizeof(int)];
+    int l_so_type_siz = sizeof(l_so_type);
+    SOCKET sock = _get_osfhandle(fd);
+
+    if (::getsockopt(sock, SOL_SOCKET, SO_TYPE, l_so_type, &l_so_type_siz) == 0) {
+        int result = 0;
+        if (closesocket(sock) == SOCKET_ERROR) {
+            errno = WSAGetLastError();
+            result = 1;
+        }
+        _free_osfhnd(fd);
+        _osfile(fd) = 0;
+        return result;
+    } else
+        return _close(fd);
+}
+
+#if defined(_MSC_VER) /* Microsoft C Compiler ONLY */
+
+#ifndef _S_IREAD
+#define _S_IREAD 0x0100
+#endif
+
+#ifndef _S_IWRITE
+#define _S_IWRITE 0x0080
+#endif
+
+inline
+int open(const char *filename, int oflag, int pmode = 0)
+{
+    return _open(filename, oflag, pmode & (_S_IREAD | _S_IWRITE));
+}
+#endif
+
+inline
+int read(int fd, void * buf, size_t siz)
+{
+    char l_so_type[sizeof(int)];
+    int l_so_type_siz = sizeof(l_so_type);
+    SOCKET sock = _get_osfhandle(fd);
+
+    if (::getsockopt(sock, SOL_SOCKET, SO_TYPE, l_so_type, &l_so_type_siz) == 0)
+        return ::recv(sock, (char FAR *) buf, (int)siz, 0);
+    else
+        return _read(fd, buf, (unsigned int)siz);
+}
+
+inline
+int write(int fd, const void * buf, size_t siz)
+{
+    char l_so_type[sizeof(int)];
+    int l_so_type_siz = sizeof(l_so_type);
+    SOCKET sock = _get_osfhandle(fd);
+
+    if (::getsockopt(sock, SOL_SOCKET, SO_TYPE, l_so_type, &l_so_type_siz) == 0)
+        return ::send(sock, (char FAR *) buf, siz, 0);
+    else
+        return _write(fd, buf, siz);
+}
+
+inline
+char *index(const char *s, int c)
+{
+    return (char *)strchr(s,c);
+}
+
+/** \cond AUTODOCS-IGNORE */
+namespace Squid
+{
+/** \endcond */
+
+inline
+int accept(int s, struct sockaddr * a, size_t * l)
+{
+    SOCKET result;
+    if ((result = ::accept(_get_osfhandle(s), a, (int *)l)) == INVALID_SOCKET) {
+        if (WSAEMFILE == (errno = WSAGetLastError()))
+            errno = EMFILE;
+        return -1;
+    } else
+        return _open_osfhandle(result, 0);
+}
+
+inline
+int bind(int s, struct sockaddr * n, int l)
+{
+    if (::bind(_get_osfhandle(s),n,l) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return 0;
+}
+
+inline
+int connect(int s, const struct sockaddr * n, int l)
+{
+    if (::connect(_get_osfhandle(s),n,l) == SOCKET_ERROR) {
+        if (WSAEMFILE == (errno = WSAGetLastError()))
+            errno = EMFILE;
+        return -1;
+    } else
+        return 0;
+}
+
+inline
+struct hostent * gethostbyname (const char *n) {
+    HOSTENT FAR * result;
+    if ((result = ::gethostbyname(n)) == NULL)
+        errno = WSAGetLastError();
+    return result;
+}
+#define gethostbyname(n) Squid::gethostbyname(n)
+
+inline
+SERVENT FAR* getservbyname (const char * n, const char * p)
+{
+    SERVENT FAR * result;
+    if ((result = ::getservbyname(n, p)) == NULL)
+        errno = WSAGetLastError();
+    return result;
+}
+#define getservbyname(n,p) Squid::getservbyname(n,p)
+
+inline
+HOSTENT FAR * gethostbyaddr(const char * a, int l, int t)
+{
+    HOSTENT FAR * result;
+    if ((result = ::gethostbyaddr(a, l, t)) == NULL)
+        errno = WSAGetLastError();
+    return result;
+}
+#define gethostbyaddr(a,l,t) Squid::gethostbyaddr(a,l,t)
+
+inline
+int getsockname(int s, struct sockaddr * n, size_t * l)
+{
+    if ((::getsockname(_get_osfhandle(s), n, (int *)l)) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return 0;
+}
+
+inline
+int gethostname(char * n, size_t l)
+{
+    if ((::gethostname(n, l)) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return 0;
+}
+#define gethostname(n,l) Squid::gethostname(n,l)
+
+inline
+int getsockopt(int s, int l, int o, void * v, int * n)
+{
+    Sleep(1);
+    if ((::getsockopt(_get_osfhandle(s), l, o,(char *) v, n)) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return 0;
+}
+
+/* Simple ioctl() emulation */
+inline
+int ioctl(int s, int c, void * a)
+{
+    if ((::ioctlsocket(_get_osfhandle(s), c, (u_long FAR *)a)) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return 0;
+}
+
+inline
+int ioctlsocket(int s, long c, u_long FAR * a)
+{
+    if ((::ioctlsocket(_get_osfhandle(s), c, a)) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return 0;
+}
+
+inline
+int listen(int s, int b)
+{
+    if (::listen(_get_osfhandle(s), b) == SOCKET_ERROR) {
+        if (WSAEMFILE == (errno = WSAGetLastError()))
+            errno = EMFILE;
+        return -1;
+    } else
+        return 0;
+}
+#define listen(s,b) Squid::listen(s,b)
+
+inline
+int recv(int s, void * b, size_t l, int f)
+{
+    int result;
+    if ((result = ::recv(_get_osfhandle(s), (char *)b, l, f)) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return result;
+}
+
+inline
+int recvfrom(int s, void * b, size_t l, int f, struct sockaddr * fr, size_t * fl)
+{
+    int result;
+    if ((result = ::recvfrom(_get_osfhandle(s), (char *)b, l, f, fr, (int *)fl)) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return result;
+}
+
+inline
+int select(int n, fd_set * r, fd_set * w, fd_set * e, struct timeval * t)
+{
+    int result;
+    if ((result = ::select(n,r,w,e,t)) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return result;
+}
+#define select(n,r,w,e,t) Squid::select(n,r,w,e,t)
+
+inline
+int send(int s, const void * b, size_t l, int f)
+{
+    int result;
+    if ((result = ::send(_get_osfhandle(s), (char *)b, l, f)) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return result;
+}
+
+inline
+int sendto(int s, const void * b, size_t l, int f, const struct sockaddr * t, int tl)
+{
+    int result;
+    if ((result = ::sendto(_get_osfhandle(s), (char *)b, l, f, t, tl)) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return result;
+}
+
+inline
+int setsockopt(SOCKET s, int l, int o, const char * v, int n)
+{
+    SOCKET socket;
+
+    socket = ((s == INVALID_SOCKET) ? s : (SOCKET)_get_osfhandle((int)s));
+
+    if (::setsockopt(socket, l, o, v, n) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return 0;
+}
+#define setsockopt(s,l,o,v,n) Squid::setsockopt(s,l,o,v,n)
+
+inline
+int shutdown(int s, int h)
+{
+    if (::shutdown(_get_osfhandle(s),h) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return 0;
+}
+
+inline
+int socket(int f, int t, int p)
+{
+    SOCKET result;
+    if ((result = ::socket(f, t, p)) == INVALID_SOCKET) {
+        if (WSAEMFILE == (errno = WSAGetLastError()))
+            errno = EMFILE;
+        return -1;
+    } else
+        return _open_osfhandle(result, 0);
+}
+#define socket(f,t,p) Squid::socket(f,t,p)
+
+inline
+int WSAAsyncSelect(int s, HWND h, unsigned int w, long e)
+{
+    if (::WSAAsyncSelect(_get_osfhandle(s), h, w, e) == SOCKET_ERROR) {
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return 0;
+}
+
+#undef WSADuplicateSocket
+inline
+int WSADuplicateSocket(int s, DWORD n, LPWSAPROTOCOL_INFO l)
+{
+#ifdef UNICODE
+    if (::WSADuplicateSocketW(_get_osfhandle(s), n, l) == SOCKET_ERROR) {
+#else
+    if (::WSADuplicateSocketA(_get_osfhandle(s), n, l) == SOCKET_ERROR) {
+#endif
+        errno = WSAGetLastError();
+        return -1;
+    } else
+        return 0;
+}
+
+#undef WSASocket
+inline
+int WSASocket(int a, int t, int p, LPWSAPROTOCOL_INFO i, GROUP g, DWORD f) {
+    SOCKET result;
+#ifdef UNICODE
+    if ((result = ::WSASocketW(a, t, p, i, g, f)) == INVALID_SOCKET) {
+#else
+    if ((result = ::WSASocketA(a, t, p, i, g, f)) == INVALID_SOCKET) {
+#endif
+        if (WSAEMFILE == (errno = WSAGetLastError()))
+            errno = EMFILE;
+        return -1;
+    } else
+        return _open_osfhandle(result, 0);
+}
+
+} /* namespace Squid */
+
+#else /* #ifdef __cplusplus */
+#define connect(s,n,l) \
+       (SOCKET_ERROR == connect(_get_osfhandle(s),n,l) ? \
+       (WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1, -1) : 0)
+#define gethostbyname(n) \
+       (NULL == ((HOSTENT FAR*)(ws32_result = (int)gethostbyname(n))) ? \
+       (errno = WSAGetLastError()), (HOSTENT FAR*)NULL : (HOSTENT FAR*)ws32_result)
+#define gethostname(n,l) \
+       (SOCKET_ERROR == gethostname(n,l) ? \
+       (errno = WSAGetLastError()), -1 : 0)
+#define recv(s,b,l,f) \
+       (SOCKET_ERROR == (ws32_result = recv(_get_osfhandle(s),b,l,f)) ? \
+       (errno = WSAGetLastError()), -1 : ws32_result)
+#define sendto(s,b,l,f,t,tl) \
+       (SOCKET_ERROR == (ws32_result = sendto(_get_osfhandle(s),b,l,f,t,tl)) ? \
+       (errno = WSAGetLastError()), -1 : ws32_result)
+#define select(n,r,w,e,t) \
+       (SOCKET_ERROR == (ws32_result = select(n,r,w,e,t)) ? \
+       (errno = WSAGetLastError()), -1 : ws32_result)
+#define socket(f,t,p) \
+       (INVALID_SOCKET == ((SOCKET)(ws32_result = (int)socket(f,t,p))) ? \
+       ((WSAEMFILE == (errno = WSAGetLastError()) ? errno = EMFILE : -1), -1) : \
+       (SOCKET)_open_osfhandle(ws32_result,0))
+#define write      _write /* Needed in util.c */
+#define open       _open /* Needed in win32lib.c */
+#endif /* #ifdef __cplusplus */
+
+#define        RUSAGE_SELF     0               /* calling process */
+#define        RUSAGE_CHILDREN -1              /* terminated child processes */
+
+struct rusage {
+    struct timeval ru_utime;   /* user time used */
+    struct timeval ru_stime;   /* system time used */
+    long ru_maxrss;                    /* integral max resident set size */
+    long ru_ixrss;                     /* integral shared text memory size */
+    long ru_idrss;                     /* integral unshared data size */
+    long ru_isrss;                     /* integral unshared stack size */
+    long ru_minflt;                    /* page reclaims */
+    long ru_majflt;                    /* page faults */
+    long ru_nswap;                     /* swaps */
+    long ru_inblock;           /* block input operations */
+    long ru_oublock;           /* block output operations */
+    long ru_msgsnd;                    /* messages sent */
+    long ru_msgrcv;                    /* messages received */
+    long ru_nsignals;          /* signals received */
+    long ru_nvcsw;                     /* voluntary context switches */
+    long ru_nivcsw;                    /* involuntary context switches */
+};
+
+#undef ACL
+
+
+/** \cond AUTODOCS-IGNORE */
+using namespace Squid;
+/** \endcond */
+
+
+/* win32lib.c */
+SQUIDCEXTERN int chroot (const char *);
+SQUIDCEXTERN int ftruncate(int, off_t);
+#ifndef HAVE_GETTIMEOFDAY
+SQUIDCEXTERN int gettimeofday(struct timeval * ,void *);
+#endif
+SQUIDCEXTERN int kill(pid_t, int);
+SQUIDCEXTERN int statfs(const char *, struct statfs *);
+SQUIDCEXTERN int truncate(const char *, off_t);
+SQUIDCEXTERN const char * wsastrerror(int);
+SQUIDCEXTERN struct passwd *getpwnam(char *);
+SQUIDCEXTERN struct group *getgrnam(char *);
+SQUIDCEXTERN uid_t geteuid(void);
+SQUIDCEXTERN uid_t getuid(void);
+SQUIDCEXTERN int setuid(uid_t);
+SQUIDCEXTERN int seteuid(uid_t);
+SQUIDCEXTERN gid_t getgid(void);
+SQUIDCEXTERN gid_t getegid(void);
+SQUIDCEXTERN int setgid(gid_t);
+SQUIDCEXTERN int setegid(gid_t);
+SQUIDCEXTERN const char *WIN32_strerror(int);
+SQUIDCEXTERN void WIN32_maperror(unsigned long);
+
+// Moved in from squid.h and other duplicates.
+// BUT was already included up the top there with a wrapped conditional.
+// that may need checking....
+//#include <io.h>
+
+/* Windows may lack getpagesize() prototype */
+// Moved in from squid.h
+// NP: there may be a header include needed before this to prevent duplicate-definitions
+//     if that is true it will need including here as part of the hack.
+//     if not then this comment can be dropped.
+#if !defined(getpagesize)
+SQUIDCEXTERN size_t getpagesize(void);
+#endif
+
+
+#endif /* _SQUID_WIN32_ */
+#endif /* SQUID_OS_MSWIN_H */
diff --git a/libsquid-compat/os/squid_next.h b/libsquid-compat/os/squid_next.h
new file mode 100644 (file)
index 0000000..5278f1c
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_NEXT_H
+#define SQUID_OS_NEXT_H
+
+#ifdef _SQUID_NEXT_
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+
+/*
+ * Don't allow inclusion of malloc.h
+ */
+#if defined(HAVE_MALLOC_H)
+#undef HAVE_MALLOC_H
+#endif
+
+/*
+ * S_ISDIR() may not be defined on Next
+ */
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#if !defined(S_ISDIR)
+#define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
+#endif
+
+/*
+ * WAS: lots of special wrappers labeled only 'protect NEXTSTEP'
+ * I'm assuming its an incomplete definition problem on that OS.
+ * Or a missing safety wrapper by the looks of the _SQUID_NETDB_H_
+ * 
+ * Anyway, this file is included before all general non-type headers.
+ * doing the include here for Next and undefining HAVE_NETDB_H will
+ * save us from including it again in general.
+ */
+// All the hacks included this first without safety wrapping, then netdb.h.
+#include <netinet/in_systm.h>
+#if HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#undef HAVE_NETDB_H
+#define HAVE_NETDB_H 0
+
+
+#endif /* _SQUID_NEXT_ */
+#endif /* SQUID_OS_NEXT_H */
diff --git a/libsquid-compat/os/squid_openbsd.h b/libsquid-compat/os/squid_openbsd.h
new file mode 100644 (file)
index 0000000..eae2cdf
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_OPENBSD_H
+#define SQUID_OS_OPENBSD_H
+
+#ifdef _SQUID_OPENBSD_
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+/*
+ * Don't allow inclusion of malloc.h
+ */
+#ifdef HAVE_MALLOC_H
+#undef HAVE_MALLOC_H
+#endif
+
+
+#endif /* _SQUID_OPENBSD_ */
+#endif /* SQUID_OS_OPENBSD_H */
diff --git a/libsquid-compat/os/squid_qnx.h b/libsquid-compat/os/squid_qnx.h
new file mode 100644 (file)
index 0000000..f1f4940
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_QNX_H
+#define SQUID_OS_QNX_H
+
+#ifdef _SQUID_QNX_
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+/*
+ * Requires unix.h header file
+ */
+#include <unix.h>
+
+
+#endif /* _SQUID_QNX_ */
+#endif /* SQUID_OS_QNX_H */
diff --git a/libsquid-compat/os/squid_sgi.h b/libsquid-compat/os/squid_sgi.h
new file mode 100644 (file)
index 0000000..5fc9e67
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_SGI_H
+#define SQUID_OS_SGI_H
+
+#if _SQUID_SGI_
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+#if !defined(_SVR4_SOURCE)
+#define _SVR4_SOURCE           /* for tempnam(3) */
+#endif
+
+#if USE_ASYNC_IO
+#define _ABI_SOURCE
+#endif /* USE_ASYNC_IO */
+
+
+#endif /* _SQUID_SGI_ */
+#endif /* SQUID_OS_SGI_H */
diff --git a/libsquid-compat/os/squid_solaris.h b/libsquid-compat/os/squid_solaris.h
new file mode 100644 (file)
index 0000000..40ffdb7
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_SOLARIS_H
+#define SQUID_OS_SOLARIS_H
+
+#ifdef _SQUID_SOLARIS_
+
+/*
+ * On Solaris 9 x86, gcc may includes a "fixed" set of old system
+ * include files that is incompatible with the updated Solaris
+ * header files.
+ */
+#if defined(i386) || defined(__i386)
+#ifndef HAVE_PAD128_T
+typedef union {
+       long double     _q;
+       int32_t         _l[4];
+} pad128_t;
+#endif
+#ifndef HAVE_UPAD128_T
+typedef union {
+       long double     _q;
+       uint32_t        _l[4];
+} upad128_t;
+#endif
+#endif
+
+/**
+ * prototypes for system function missing from system includes
+ */
+SQUIDCEXTERN int getrusage(int, struct rusage *);
+
+
+/**
+ * prototypes for system function missing from system includes
+ * on some Solaris systems.
+ */
+SQUIDCEXTERN int getpagesize(void);
+#if !defined(_XPG4_2) && !(defined(__EXTENSIONS__) || \
+        (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)))
+SQUIDCEXTERN int gethostname(char *, int);
+#endif
+
+
+
+#endif /* _SQUID_SOLARIS_ */
+#endif /* SQUID_OS_SOALRIS_H */
diff --git a/libsquid-compat/os/squid_sunos.h b/libsquid-compat/os/squid_sunos.h
new file mode 100644 (file)
index 0000000..25f891e
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_SUNOS_H
+#define SQUID_OS_SUNOS_H
+
+#ifdef _SQUID_SUNOS_
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+
+/*
+ * We assume O_NONBLOCK is broken, or does not exist, on SunOS.
+ */
+#define SQUID_NONBLOCK O_NDELAY
+
+
+
+#endif /* _SQUID_SUNOS_ */
+#endif /* SQUID_OS_SUNOS_H */
diff --git a/libsquid-compat/os/squid_windows.h b/libsquid-compat/os/squid_windows.h
new file mode 100644 (file)
index 0000000..ad11de1
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * $Id$
+ *
+ * AUTHOR: Guido Serassio <serassio@squid-cache.org>
+ *
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_WINDOWS_H
+#define SQUID_OS_WINDOWS_H
+
+#ifdef _SQUID_WIN32_
+
+#ifndef ACL
+#define ACL WindowsACL
+#define _MSWIN_ACL_WAS_NOT_DEFINED 1
+#endif
+#include <windows.h>
+#if _MSWIN_ACL_WAS_NOT_DEFINED
+#undef ACL
+#undef _MSWIN_ACL_WAS_NOT_DEFINED
+#endif
+
+#endif /* _SQUID_WIN32_ */
+#endif /* SQUID_OS_WINDOWS_H */
diff --git a/libsquid-compat/osdetect.h b/libsquid-compat/osdetect.h
new file mode 100644 (file)
index 0000000..e32b629
--- /dev/null
@@ -0,0 +1,92 @@
+#ifndef SQUID_COMPAT_OSDETECT_H
+#define SQUID_COMPAT_OSDETECT_H
+
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+/*
+ * Define the _SQUID_TYPE_ based on a guess of the OS.
+ *
+ * NP: This MUST come first in compat.h with no OS-specific includes
+ *     or other definitions within this if-else structure.
+ */
+
+#if defined(__sun__) || defined(__sun) /* SUN */
+#define _SQUID_SUN_
+#if defined(__SVR4)            /* SOLARIS */
+#define _SQUID_SOLARIS_
+#else /* SUNOS */
+#define _SQUID_SUNOS_
+#endif
+
+#elif defined(__hpux)          /* HP-UX - SysV-like? */
+#define _SQUID_HPUX_
+#define _SQUID_SYSV_
+
+#elif defined(__osf__)         /* OSF/1 */
+#define _SQUID_OSF_
+
+#elif defined(__ultrix)                /* Ultrix */
+#define _SQUID_ULTRIX_
+
+#elif defined(_AIX)            /* AIX */
+#define _SQUID_AIX_
+
+#elif defined(__linux__)       /* Linux */
+#define _SQUID_LINUX_
+
+#elif defined(__FreeBSD__)     /* FreeBSD */
+#define _SQUID_FREEBSD_
+
+#elif defined(__sgi__) || defined(sgi) || defined(__sgi)       /* SGI */
+#define _SQUID_SGI_
+
+#elif defined(__NeXT__)
+#define _SQUID_NEXT_
+
+#elif defined(__bsdi__)
+#define _SQUID_BSDI_           /* BSD/OS */
+
+#elif defined(__NetBSD__)
+#define _SQUID_NETBSD_
+
+#elif defined(__OpenBSD__)
+#define _SQUID_OPENBSD_
+
+#elif defined(__DragonFly__)
+#define _SQUID_DRAGONFLY_
+
+#elif defined(__CYGWIN32__)  || defined(__CYGWIN__)
+#define _SQUID_CYGWIN_
+#define _SQUID_WIN32_
+
+#elif defined(WIN32) || defined(WINNT) || defined(__WIN32__) || defined(__WIN32)
+#define _SQUID_MSWIN_
+#define _SQUID_WIN32_
+
+#elif defined(__APPLE__)
+#define _SQUID_APPLE_
+
+#elif defined(sony_news) && defined(__svr4)
+#define _SQUID_NEWSOS6_
+
+#elif defined(__QNX__)
+#define _SQUID_QNX_
+
+#elif defined(__EMX__) || defined(OS2) || defined(__OS2__)
+#define _SQUID_OS2_
+/*
+ *  FIXME: the os2 port of bash seems to have problems checking
+ *  the return codes of programs in if statements.  These options
+ *  need to be overridden.
+ */
+
+#endif /* OS automatic detection */
+
+
+
+#endif /* SQUID_COMPAT_OSDETECT_H */
diff --git a/libsquid-compat/squid_fdsetsize.h b/libsquid-compat/squid_fdsetsize.h
new file mode 100644 (file)
index 0000000..ad8ddf6
--- /dev/null
@@ -0,0 +1,90 @@
+#ifndef SQUID_FDSETSIZE_H
+#define SQUID_FDSETSIZE_H
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+/* FD_SETSIZE must be redefined before including sys/types.h */
+#if 0
+/* AYJ: would dearly like to use this to enforce include order
+       but at present some helpers don't follow the squid include methodology.
+       that will need fixing later.
+*/
+#ifdef _SYS_TYPES_H
+#error squid_fdsetsize.h for FDSETSIZE must be included before sys/types.h
+#error Make sure that squid.h or config.h is the first file included by your .cc
+#endif
+#endif /* 0 */
+/*
+ * 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, but we can increase __FD_SETSIZE
+ * with glibc 2.2 (or later? remains to be seen). We do this by including
+ * bits/types.h which defines __FD_SETSIZE first, then we redefine
+ * __FD_SETSIZE. Ofcourse a user program may NEVER include bits/whatever.h
+ * directly, so this is a dirty hack!
+ */
+#if defined(_SQUID_LINUX_)
+#undef CHANGE_FD_SETSIZE
+#define CHANGE_FD_SETSIZE 0
+#include <features.h>
+#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
+#if SQUID_MAXFD > DEFAULT_FD_SETSIZE
+#include <bits/types.h>
+#undef __FD_SETSIZE
+#define __FD_SETSIZE SQUID_MAXFD
+#endif
+#endif
+#endif
+
+/*
+ * Cannot increase FD_SETSIZE on FreeBSD before 2.2.0, causes select(2)
+ * to return EINVAL.
+ * --Marian Durkovic <marian@svf.stuba.sk>
+ * --Peter Wemm <peter@spinner.DIALix.COM>
+ */
+#if defined(_SQUID_FREEBSD_)
+#include <osreldate.h>
+#if __FreeBSD_version < 220000
+#undef CHANGE_FD_SETSIZE
+#define CHANGE_FD_SETSIZE 0
+#endif
+#endif
+
+/*
+ * Trying to redefine CHANGE_FD_SETSIZE causes a slew of warnings
+ * on Mac OS X Server.
+ */
+#if defined(_SQUID_APPLE_)
+#undef CHANGE_FD_SETSIZE
+#define CHANGE_FD_SETSIZE 0
+#endif
+
+/* Increase FD_SETSIZE if SQUID_MAXFD is bigger */
+#if CHANGE_FD_SETSIZE && SQUID_MAXFD > DEFAULT_FD_SETSIZE
+#define FD_SETSIZE SQUID_MAXFD
+#endif
+
+
+/*
+ * Trap unintentional use of fd_set. Must not be used outside the
+ * select code as it only supports FD_SETSIZE number of filedescriptors
+ * and Squid may be running with a lot more..
+ * But only for code linked into Squid, not the helpers.. (unlinkd, pinger)
+ */
+#ifdef SQUID_FDSET_NOUSE
+# ifndef SQUID_HELPER
+#  define fd_set ERROR_FD_SET_USED
+# endif
+#endif
+
+#endif /* SQUID_FDSETSIZE_H */
diff --git a/libsquid-compat/squid_stdvarargs.h b/libsquid-compat/squid_stdvarargs.h
new file mode 100644 (file)
index 0000000..c38a2cf
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef _SQUID_STDVARARGS_H
+#define _SQUID_STDVARARGS_H
+
+/*
+ * va_* variables come from various places on different platforms.
+ * We provide a clean set of wrappers for the variosu operations
+ * Depending on what is available and needed.
+ */
+#if defined(HAVE_STDARG_H)
+#include <stdarg.h>
+#define HAVE_STDARGS            /* let's hope that works everywhere (mj) */
+#define VA_LOCAL_DECL va_list ap;
+#define VA_START(f) va_start(ap, f)
+#define VA_SHIFT(v,t) ;         /* no-op for ANSI */
+#define VA_END va_end(ap)
+#else
+#if defined(HAVE_VARARGS_H)
+#include <varargs.h>
+#undef HAVE_STDARGS
+#define VA_LOCAL_DECL va_list ap;
+#define VA_START(f) va_start(ap)        /* f is ignored! */
+#define VA_SHIFT(v,t) v = va_arg(ap,t)
+#define VA_END va_end(ap)
+#else
+#error XX **NO VARARGS ** XX
+#endif
+#endif
+
+/* Make sure syslog goes after stdarg/varargs */
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+#endif
+
+#endif /* _SQUID_STDVARARGS_H */
diff --git a/libsquid-compat/squid_valgrind.h b/libsquid-compat/squid_valgrind.h
new file mode 100644 (file)
index 0000000..7c3bc46
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_VALGRIND_H
+#define SQUID_VALGRIND_H
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+/*
+ * valgrind debug support
+ */
+#if WITH_VALGRIND
+#include <valgrind/memcheck.h>
+#undef VALGRIND_MAKE_NOACCESS
+#undef VALGRIND_MAKE_WRITABLE
+#undef VALGRIND_MAKE_READABLE
+/* A little glue for older valgrind version prior to 3.2.0 */
+#ifndef VALGRIND_MAKE_MEM_NOACCESS
+#define VALGRIND_MAKE_MEM_NOACCESS VALGRIND_MAKE_NOACCESS
+#define VALGRIND_MAKE_MEM_UNDEFINED VALGRIND_MAKE_WRITABLE
+#define VALGRIND_MAKE_MEM_DEFINED VALGRIND_MAKE_READABLE
+#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE VALGRIND_CHECK_WRITABLE
+#endif
+#else
+#define VALGRIND_MAKE_MEM_NOACCESS(a,b) (0)
+#define VALGRIND_MAKE_MEM_UNDEFINED(a,b) (0)
+#define VALGRIND_MAKE_MEM_DEFINED(a,b) (0)
+#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,b) (0)
+#define VALGRIND_CHECK_MEM_IS_DEFINED(a,b) (0)
+#define VALGRIND_MALLOCLIKE_BLOCK(a,b,c,d)
+#define VALGRIND_FREELIKE_BLOCK(a,b)
+#define RUNNING_ON_VALGRIND 0
+#endif /* WITH_VALGRIND */
+
+#endif /* SQUID_CONFIG_H */
index b86226c51e8689720efc47081230be45992b76eb..bac6f1bec56d0ec0bb9fdc47e62da3a5590d5768 100644 (file)
@@ -10,7 +10,7 @@ libsnmp_a_SOURCES  = asn1.c parse.c snmp_vars.c \
        mib.c snmp_api_error.c   \
        snmp_msg.c \
        snmp_pdu.c  snmplib_debug.c
-INCLUDES       = -I$(top_builddir)/include -I$(top_srcdir)/include
+INCLUDES       = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/libsquid-compat
 
 VERSION                = 3.4
 DEFS           = -DSQUID_SNMP=1
index 0767983ff7d2602848339d44d90d71cf1dbdfbcf..f36cdd216ea7aa97f546acdd517e677115729b1e 100644 (file)
@@ -3,6 +3,7 @@ AM_CXXFLAGS = @SQUID_CXXFLAGS@
 CLEANFILES =
 
 INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
        -I$(top_builddir)/include \
        -I$(top_srcdir)/include \
         -I$(top_srcdir)/src
index 9e16c4ebb2884e471806e6e9a626a336aa277d30..7b8b6851a5e90062deb3ab42e9c6af159ebc9d7f 100644 (file)
@@ -210,9 +210,15 @@ EXTRA_LIBRARIES = libAIO.a libBlocking.a libDiskDaemon.a libDiskThreads.a
 noinst_LIBRARIES = @DISK_LIBS@
 noinst_LTLIBRARIES = libsquid.la libauth.la
 
-INCLUDES        = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/lib/libTrie/include
-INCLUDES        += -I$(top_builddir)/lib -I$(top_srcdir)/lib
-INCLUDES       += @SQUID_CPPUNIT_INC@
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/src \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include \
+       -I$(top_srcdir)/lib/libTrie/include \
+       -I$(top_builddir)/lib \
+       -I$(top_srcdir)/lib \
+       @SQUID_CPPUNIT_INC@
 
 EXTRA_PROGRAMS = \
        DiskIO/DiskDaemon/diskd \
index 11a760b9c74937d128f58da5db325558d5ade692..f4ddb9a4bb07fc7ef645d9ab9251bdbe78aa0515 100644 (file)
@@ -3,6 +3,7 @@ AM_CXXFLAGS = @SQUID_CXXFLAGS@
 CLEANFILES =
 
 INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
        -I$(top_builddir)/include \
        -I$(top_srcdir)/include \
         -I$(top_srcdir)/src
index c1883e0b5e077c656443a6fb828a6072ab192bea..d2725e748043195c750c614e429385399336c46c 100644 (file)
@@ -15,7 +15,11 @@ libdigest_a_SOURCES  = digest/auth_digest.cc digest/auth_digest.h
 libntlm_a_SOURCES      = ntlm/auth_ntlm.cc ntlm/auth_ntlm.h
 libnegotiate_a_SOURCES = negotiate/auth_negotiate.cc negotiate/auth_negotiate.h negotiate/negotiateScheme.cc negotiate/negotiateScheme.h
 
-INCLUDES      = -I. -I$(top_builddir)/include -I$(top_srcdir)/include \
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include \
        -I$(top_srcdir)/src
 
 check_PROGRAMS= testHeaders
index d52aac9b905c09e3042e5328dc66fa8bfabcfac3..98ab01eec10a2e7a74469f48ecb47c4c949cb507 100644 (file)
@@ -22,5 +22,9 @@ libeCAP_la_SOURCES = \
        \
        Registry.h
 
-INCLUDES = -I. -I$(top_builddir)/include -I$(top_srcdir)/include \
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include \
         -I$(top_srcdir)/src
index 67c87c799e90765d36b1dda07788f158a1116058..36f3e65e8d71f77c6b13271e4d48f8d5b149257d 100644 (file)
@@ -28,7 +28,11 @@ EXTRA_DIST = \
        coss/StoreFScoss.h \
        ufs/StoreFSufs.h
 
-INCLUDES      = -I. -I$(top_builddir)/include -I$(top_srcdir)/include \
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include \
        -I$(top_srcdir)/src
 
 check_PROGRAMS=testHeaders
index f1db789a59165c612788e427eab3a10071a9632f..2e679e9f4f2a4605c1f06b171e2401a6f2399554 100644 (file)
@@ -70,7 +70,6 @@ extern "C"
     extern const char *const version_string;   /* VERSION */
 //MOVED:versions.h:APP_FULLNAME    extern const char *const full_appname_string;       /* PACKAGE "/" VERSION */
     extern const char *const appname_string;   /* PACKAGE */
-    extern const char *const w_space;  /* " \t\n\r" */
     extern char const * visible_appname_string; /* NULL */
     extern const char *fdTypeStr[];
     extern const char *hier_strings[];
index dbdc3debd02318851ca1d3fe6d6e847fbb3d0e94..e4e8d1e12b4047c17627f45a22e4dd44c9602cc2 100644 (file)
@@ -9,7 +9,13 @@ AM_CXXFLAGS = @SQUID_CXXFLAGS@
 DEFS = @DEFS@
 CLEANFILES = 
 
-INCLUDES = -I$(top_srcdir)/src @SQUID_CPPUNIT_INC@ -I$(top_srcdir)/include -I$(top_builddir)/lib
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/src \
+       -I$(top_srcdir)/include \
+       -I$(top_builddir)/lib \
+       @SQUID_CPPUNIT_INC@
+
 $(OBJS): $(top_srcdir)/include/version.h $(top_srcdir)/include/autoconf.h
 
 # TODO: get rid of this when config filename is no longer a global constant.
index e36db69f4b9897d9598344359add5546e7559b4f..d075c3390ab8ce540f05c3450af01dc24b092406 100644 (file)
@@ -9,7 +9,13 @@ AM_CXXFLAGS = @SQUID_CXXFLAGS@
 DEFS = @DEFS@
 CLEANFILES = 
 
-INCLUDES = -I$(top_srcdir)/src @SQUID_CPPUNIT_INC@ -I$(top_srcdir)/include -I$(top_builddir)/lib
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I$(top_srcdir)/include \
+       -I$(top_builddir)/lib \
+       -I$(top_srcdir)/src \
+       @SQUID_CPPUNIT_INC@ 
+
 $(OBJS): $(top_srcdir)/include/version.h $(top_srcdir)/include/autoconf.h
 
 
@@ -46,6 +52,7 @@ testIpAddress_SOURCES= \
 nodist_testIpAddress_SOURCES= \
        ../tests/testMain.cc
 testIpAddress_LDADD= \
+       $(top_builddir)/libsquid-compat/libsquid-compat.la \
        libip.la \
        -L$(top_builddir)/lib -lmiscutil \
        @SQUID_CPPUNIT_LA@ \
index 46fa4560e0460407e9109553c150221f239b2a52..303036fc5aa38df2bda2b15614ff52d4b6575117 100644 (file)
@@ -16,7 +16,11 @@ noinst_LIBRARIES = @REPL_LIBS@
 liblru_a_SOURCES = lru/store_repl_lru.cc
 libheap_a_SOURCES = heap/store_heap_replacement.h heap/store_heap_replacement.cc heap/store_repl_heap.cc
 
-INCLUDES      = -I. -I$(top_builddir)/include -I$(top_srcdir)/include \
+INCLUDES = \
+       -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include \
        -I$(top_srcdir)/src
 
 check_PROGRAMS= testHeaders
index ea015a78390271b0ab43f00923fa7acc13350fa0..defc84096743ca9d17b03455aa5f9c1f1e42d6a5 100644 (file)
 #ifndef SQUID_H
 #define SQUID_H
 
-/*
- * On linux this must be defined to get PRId64 and friends
- */
-#define __STDC_FORMAT_MACROS
-
 #include "config.h"
 
 #ifdef _SQUID_MSWIN_
@@ -191,26 +186,6 @@ using namespace Squid;
 #endif /* HAVE_POLL_H */
 #endif /* USE_POLL */
 
-/*
- * Filedescriptor limits in the different select loops
- *
- * NP: FreeBSD 7 defines FD_SETSIZE as unsigned but Squid needs
- *     it to be signed to compare it with signed values.
- *     Linux and others including FreeBSD <7, define it as signed.
- *     If this causes any issues please contact squid-dev@squid-cache.org
- */
-#if defined(USE_SELECT) || defined(USE_SELECT_WIN32)
-/* Limited by design */
-# define SQUID_MAXFD_LIMIT ((signed int)FD_SETSIZE)
-#elif defined(USE_POLL)
-/* Limited due to delay pools */
-# define SQUID_MAXFD_LIMIT ((signed int)FD_SETSIZE)
-#elif defined(USE_KQUEUE) || defined(USE_EPOLL)
-# define SQUID_FDSET_NOUSE 1
-#else
-# error Unknown select loop model!
-#endif
-
 
 /*
  * Trap unintentional use of fd_set. Must not be used outside the
@@ -224,35 +199,6 @@ using namespace Squid;
 # endif
 #endif
 
-#if defined(HAVE_STDARG_H)
-#include <stdarg.h>
-#define HAVE_STDARGS           /* let's hope that works everywhere (mj) */
-#define VA_LOCAL_DECL va_list ap;
-#define VA_START(f) va_start(ap, f)
-#define VA_SHIFT(v,t) ;                /* no-op for ANSI */
-#define VA_END va_end(ap)
-#else
-#if defined(HAVE_VARARGS_H)
-#include <varargs.h>
-#undef HAVE_STDARGS
-#define VA_LOCAL_DECL va_list ap;
-#define VA_START(f) va_start(ap)       /* f is ignored! */
-#define VA_SHIFT(v,t) v = va_arg(ap,t)
-#define VA_END va_end(ap)
-#else
-#error XX **NO VARARGS ** XX
-#endif
-#endif
-
-/* Make sure syslog goes after stdarg/varargs */
-#ifdef HAVE_SYSLOG_H
-#ifdef _SQUID_AIX_
-#define _XOPEN_EXTENDED_SOURCE
-#define _XOPEN_SOURCE_EXTENDED 1
-#endif
-#include <syslog.h>
-#endif
-
 #if HAVE_MATH_H
 #include <math.h>
 #endif
@@ -266,13 +212,6 @@ using namespace Squid;
 #define MAXPATHLEN SQUID_MAXPATHLEN
 #endif
 
-#if !HAVE_GETRUSAGE
-#if defined(_SQUID_HPUX_)
-#define HAVE_GETRUSAGE 1
-#define getrusage(a, b)  syscall(SYS_GETRUSAGE, a, b)
-#endif
-#endif
-
 #if !HAVE_STRUCT_RUSAGE
 /*
  * If we don't have getrusage() then we create a fake structure
@@ -329,20 +268,6 @@ SQUIDCEXTERN size_t getpagesize(void);
 #define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
 #endif
 
-#ifdef USE_GNUREGEX
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-#include "GNUregex.h"
-#ifdef __cplusplus
-}
-
-#endif
-#elif HAVE_REGEX_H
-#include <regex.h>
-#endif
-
 #include "md5.h"
 
 #if USE_SSL
@@ -392,36 +317,6 @@ extern "C"
 #include "initgroups.h"
 #endif
 
-#ifndef min
-
-template<class A>
-inline A const &
-min(A const & lhs, A const & rhs)
-{
-    if (rhs < lhs)
-        return rhs;
-
-    return lhs;
-}
-
-#endif
-
-#define XMIN(x,y) (min (x,y))
-#ifndef max
-template<class A>
-inline A const &
-max(A const & lhs, A const & rhs)
-{
-    if (rhs > lhs)
-        return rhs;
-
-    return lhs;
-}
-
-#endif
-
-#define XMAX(a,b) (max (a,b))
-
 #include "structs.h"
 #include "protos.h"
 #include "globals.h"
index 2d1780845de222dfc0886a0774a0d19ed4c9c497..9ce219d90ebe34aa7c5c6e4a5ea3cd9b3d0aac05 100644 (file)
@@ -9,9 +9,20 @@ AUTOMAKE_OPTIONS = subdir-objects
 AM_CFLAGS = @SQUID_CFLAGS@
 AM_CXXFLAGS = @SQUID_CXXFLAGS@
 
-INCLUDES        = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/src
+INCLUDES = -I$(top_srcdir)/libsquid-compat \
+       -I. \
+       -I$(top_builddir)/include \
+       -I$(top_srcdir)/include \
+       -I$(top_srcdir)/src
+
+LDADD = \
+       -L$(top_builddir)/libsquid-compat/libsquid-compat.la \
+       -L$(top_builddir)/lib -lmiscutil \
+       $(top_builddir)/src/globals.o \
+       $(top_builddir)/src/time.o
 
 EXTRA_PROGRAMS = mem_node_test membanger splay tcp-banger2 rfc1738
+
 EXTRA_DIST = testheaders.sh
 
 ESI_ALL_TESTS = \
@@ -50,7 +61,6 @@ check_PROGRAMS= debug \
                VirtualDeleteOperator
 
 
-LDADD =$(top_builddir)/src/globals.o $(top_builddir)/src/time.o -L$(top_builddir)/lib -lmiscutil
 tcp_banger2_LDADD = -L$(top_builddir)/lib -lmiscutil
 DEBUG_SOURCE = test_tools.cc
 debug_SOURCES = debug.cc $(DEBUG_SOURCE)
index e898cc11c670ffc6d9625ae559ea691efabb738c..9147394ef8bbd2744fd8f233a9a1a5c813854edc 100644 (file)
@@ -8,6 +8,7 @@
 AUTOMAKE_OPTIONS = subdir-objects
 
 INCLUDES        = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/lib/libTrie/include -I$(top_srcdir)/src
+INCLUDES       += -I$(top_srcdir)/libsquid-compat
 INCLUDES       += @SQUID_CPPUNIT_INC@
 
 TESTS=$(check_PROGRAMS)