noinst_LIBRARIES = libcompat-squid.a
libcompat_squid_a_SOURCES = \
+ assert.cc \
assert.h \
+ compat.cc \
compat.h \
compat_shared.h \
cpu.h \
+ debug.cc \
debug.h \
drand48.h \
eui64_aton.h \
fdsetsize.h \
getaddrinfo.h \
getnameinfo.h \
+ GnuRegex.c \
+ GnuRegex.h \
inet_ntop.h \
inet_pton.h \
initgroups.h \
types.h \
unsafe.h \
valgrind.h \
+ xalloc.cc \
+ xalloc.h \
+ xstring.cc \
+ xstring.h \
\
os/aix.h \
os/dragonfly.h \
os/sgi.h \
os/solaris.h \
os/sunos.h \
- os/windows.h \
- \
- assert.cc \
- compat.cc \
- debug.cc \
- GnuRegex.h \
- GnuRegex.c
+ os/windows.h
libcompat_squid_a_LIBADD= $(LIBOBJS)
+#include "config.h"
+#include "compat.h"
+
+void (*failure_notify) (const char *) = NULL;
* of the requirements for wrapping your hack for safe portability.
*/
+/*
+ * Define an error display handler override.
+ * If error_notify is set by the linked program it will be used by the local
+ * portability functions. Otherwise perror() will be used.
+ */
+#ifdef __cplusplus
+extern "C"
+#else
+extern
+#endif
+void (*failure_notify) (const char *);
/*
* sys/resource.h and sys/time.h are apparently order-dependant.
#endif
#endif
+/*
+ * Several function definitions which we provide for security and code safety.
+ */
+#include "compat/xalloc.h"
+#include "compat/xstring.h"
+
#endif /* _SQUID_COMPAT_SHARED_H */
--- /dev/null
+#include "config.h"
+#include "compat/xalloc.h"
+
+void *
+xcalloc(size_t n, size_t sz)
+{
+ void *p;
+
+ if (n < 1)
+ n = 1;
+
+ if (sz < 1)
+ sz = 1;
+
+ p = calloc(n, sz);
+
+ if (p == NULL) {
+ if (failure_notify) {
+ static char msg[128];
+ snprintf(msg, 128, "xcalloc: Unable to allocate %u blocks of %u bytes!\n",
+ (unsigned int) n, (unsigned int) sz);
+ msg[127] = '\0';
+ (*failure_notify) (msg);
+ } else {
+ perror("xcalloc");
+ }
+ exit(1);
+ }
+
+#if XMALLOC_DEBUG
+ check_malloc(p, sz * n);
+#endif
+#if XMALLOC_STATISTICS
+ malloc_stat(sz * n);
+#endif
+#if XMALLOC_TRACE
+ xmalloc_show_trace(p, 1);
+#endif
+#if MEM_GEN_TRACE
+ if (tracefp)
+ fprintf(tracefp, "c:%u:%u:%p\n", (unsigned int) n, (unsigned int) sz, p);
+#endif
+
+ return p;
+}
+
+void *
+xmalloc(size_t sz)
+{
+ void *p;
+
+ if (sz < 1)
+ sz = 1;
+
+ p = malloc(sz);
+
+ if (p == NULL) {
+ if (failure_notify) {
+ static char msg[128];
+ snprintf(msg, 128, "xmalloc: Unable to allocate %d bytes!\n",
+ (int) sz);
+ msg[127] = '\0';
+ (*failure_notify) (msg);
+ } else {
+ perror("malloc");
+ }
+ exit(1);
+ }
+
+#if XMALLOC_DEBUG
+ check_malloc(p, sz);
+#endif
+#if XMALLOC_STATISTICS
+ malloc_stat(sz);
+#endif
+#if XMALLOC_TRACE
+ xmalloc_show_trace(p, 1);
+#endif
+#if MEM_GEN_TRACE
+ if (tracefp)
+ fprintf(tracefp, "m:%d:%p\n", sz, p);
+#endif
+
+ return (p);
+}
+
+void
+xfree(void *s)
+{
+#if XMALLOC_TRACE
+ xmalloc_show_trace(s, -1);
+#endif
+
+ if (s != NULL) {
+#if XMALLOC_DEBUG
+ check_free(s);
+#endif
+ free(s);
+ }
+
+#if MEM_GEN_TRACE
+ if (tracefp && s)
+ fprintf(tracefp, "f:%p\n", s);
+#endif
+}
--- /dev/null
+#ifndef _SQUID_COMPAT_XALLOC_H
+#define _SQUID_COMPAT_XALLOC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xcalloc() - same as calloc(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+void *xcalloc(size_t n, size_t sz);
+
+/**
+ * xmalloc() - same as malloc(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+void *xmalloc(size_t sz);
+
+/**
+ * xfree() - same as free(3). Used for portability.
+ * Will not call free(3) if s == NULL.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+void xfree(void *s);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SQUID_COMPAT_XALLOC_H */
--- /dev/null
+#include "config.h"
+#include "compat/xalloc.h"
+#include "compat/xstring.h"
+
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+char *
+xstrdup(const char *s)
+{
+ size_t sz;
+ char *p;
+
+ if (s == NULL) {
+ if (failure_notify) {
+ (*failure_notify) ("xstrdup: tried to dup a NULL pointer!\n");
+ } else {
+ errno = EINVAL;
+ perror("xstrdup: tried to dup a NULL pointer!");
+ }
+ exit(1);
+ }
+
+ /* copy string, including terminating character */
+ sz = strlen(s) + 1;
+ p = (char *)xmalloc(sz);
+ memcpy(p, s, sz);
+
+ return p;
+}
+
+char *
+xstrncpy(char *dst, const char *src, size_t n)
+{
+ char *r = dst;
+
+ if (!n || !dst)
+ return dst;
+
+ if (src)
+ while (--n != 0 && *src != '\0')
+ *dst++ = *src++;
+
+ *dst = '\0';
+ return r;
+}
+
+char *
+xstrndup(const char *s, size_t n)
+{
+ size_t sz;
+ char *p;
+
+ if (s == NULL) {
+ errno = EINVAL;
+ if (failure_notify) {
+ (*failure_notify) ("xstrndup: tried to dup a NULL pointer!\n");
+ } else {
+ perror("xstrndup: tried to dup a NULL pointer!");
+ }
+ exit(1);
+ }
+ if (n < 0) {
+ errno = EINVAL;
+ if (failure_notify) {
+ (*failure_notify) ("xstrndup: tried to dup a negative length string!\n");
+ } else {
+ perror("xstrndup: tried to dup a negative length string!");
+ }
+ exit(1);
+ }
+
+ sz = strlen(s) + 1;
+ if (sz > n)
+ sz = n;
+
+ p = xstrncpy((char *)xmalloc(sz), s, sz);
+ return p;
+}
--- /dev/null
+#ifndef _SQUID_COMPAT_XSTRING_H
+#define _SQUID_COMPAT_XSTRING_H
+
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xstrdup() - same as strdup(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Sets errno to EINVAL if a NULL pointer is passed.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+char *xstrdup(const char *s);
+
+#ifdef strdup
+#undef strdup
+#endif
+#define strdup(X) xstrdup((X))
+
+/*
+ * xstrncpy() - similar to strncpy(3) but terminates string
+ * always with '\0' if (n != 0 and dst != NULL),
+ * and doesn't do padding
+ */
+char *xstrncpy(char *dst, const char *src, size_t n);
+
+/**
+ * xstrndup() - same as strndup(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Sets errno to EINVAL if a NULL pointer or negative
+ * length is passed.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+char *xstrndup(const char *s, size_t n);
+
+#ifdef strndup
+#undef strndup
+#endif
+#define strndup(X) xstrndup((X))
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SQUID_COMPAT_XSTRING_H */
bstring.h \
cassert \
crypt.h \
+ cstdlib \
cstring \
ctype.h \
errno.h \
<sect1>New tags<label id="newtags">
<p>
<descrip>
- <tag>adapted_http_access</tag>
- <p>Access control based on altered HTTP request following adaptation alterations (ICAP, eCAP, URL rewriter).
- An upgraded drop-in replacement for <em>http_access2</em> found in Squid-2.
+ <tag>cpu_affinity_map</tag>
+ <p>New setting for SMP support to map Squid processes onto specific CPU cores.
<tag>else</tag>
- <p>Part of conditional SMP support syyntax. see <em>if</em>
+ <p>Part of conditional SMP support syntax. see <em>if</em>
<tag>endif</tag>
- <p>Part of conditional SMP support syyntax. see <em>if</em>
+ <p>Part of conditional SMP support syntax. see <em>if</em>
<tag>eui_lookup</tag>
<p>Whether to lookup the EUI or MAC address of a connected client.
+ <tag>icap_206_enable</tag>
+ <p>New option to toggle whether the ICAP 206 (Partial Content) responses extension.
+ Default is on.
+
<tag>if</tag>
<p>New conditional syntax for SMP multiple-worker.
If-statements can be used to make configuration directives depend on conditions.
1: "no SMP" mode, start one main Squid process daemon (default)
N: start N main Squid process daemons (i.e., SMP mode)
</verb>
+
+ <tag>write_timeout</tag>
+ <p>New setting to limit time spent waiting for data writes to be confirmed.
+
</descrip>
<sect1>Changes to existing tags<label id="modifiedtags">
<tag>ftp_list_width</tag>
<p>Obsolete.
+ <tag>ignore_expect_100</tag>
+ <p>Obsolete.
+
<tag>url_rewrite_concurrency</tag>
<p>Replaced by url_rewrite_children ... concurrency=N option.
#ifndef SQUID_NEW_H
#define SQUID_NEW_H
-#include "util.h"
+#include "config.h"
#ifndef __SUNPRO_CC
/* Any code using libstdc++ must have externally resolvable overloads
}
_SQUID_EXTERNNEW_ void operator delete (void *address) throw()
{
- xfree (address);
+ xfree(address);
}
_SQUID_EXTERNNEW_ void *operator new[] (size_t size) throw (std::bad_alloc)
{
}
_SQUID_EXTERNNEW_ void operator delete[] (void *address) throw()
{
- xfree (address);
+ xfree(address);
}
SQUIDCEXTERN const char *mkhttpdlogtime(const time_t *);
SQUIDCEXTERN const char *mkrfc1123(time_t);
SQUIDCEXTERN char *uudecode(const char *);
-SQUIDCEXTERN char *xstrdup(const char *);
-SQUIDCEXTERN char *xstrndup(const char *, size_t);
SQUIDCEXTERN const char *xstrerr(int xerrno);
SQUIDCEXTERN const char *xstrerror(void);
SQUIDCEXTERN int tvSubMsec(struct timeval, struct timeval);
SQUIDCEXTERN int tvSubUsec(struct timeval, struct timeval);
SQUIDCEXTERN double tvSubDsec(struct timeval, struct timeval);
-SQUIDCEXTERN char *xstrncpy(char *, const char *, size_t);
SQUIDCEXTERN size_t xcountws(const char *str);
SQUIDCEXTERN time_t parse_rfc1123(const char *str);
-SQUIDCEXTERN void *xcalloc(size_t, size_t);
-SQUIDCEXTERN void *xmalloc(size_t);
SQUIDCEXTERN void *xrealloc(void *, size_t);
SQUIDCEXTERN void Tolower(char *);
-SQUIDCEXTERN void xfree(void *);
SQUIDCEXTERN void xxfree(const void *);
#ifdef __cplusplus
/*
#endif /* XMALLOC_TRACE */
-/*
- * xmalloc() - same as malloc(3). Used for portability.
- * Never returns NULL; fatal on error.
- */
-void *
-xmalloc(size_t sz)
-{
- void *p;
-
- PROF_start(xmalloc);
-
- if (sz < 1)
- sz = 1;
-
- PROF_start(malloc);
-
- p = malloc(sz);
-
- PROF_stop(malloc);
-
- if (p == NULL) {
- if (failure_notify) {
- snprintf(msg, 128, "xmalloc: Unable to allocate %d bytes!\n",
- (int) sz);
- (*failure_notify) (msg);
- } else {
- perror("malloc");
- }
-
- exit(1);
- }
-
-#if XMALLOC_DEBUG
- check_malloc(p, sz);
-
-#endif
-#if XMALLOC_STATISTICS
-
- malloc_stat(sz);
-
-#endif
-#if XMALLOC_TRACE
-
- xmalloc_show_trace(p, 1);
-
-#endif
-#if MEM_GEN_TRACE
-
- if (tracefp)
- fprintf(tracefp, "m:%d:%p\n", sz, p);
-
-#endif
-
- PROF_stop(xmalloc);
-
- return (p);
-}
-
-/*
- * xfree() - same as free(3). Will not call free(3) if s == NULL.
- */
-void
-xfree(void *s)
-{
- PROF_start(xfree);
-#if XMALLOC_TRACE
-
- xmalloc_show_trace(s, -1);
-#endif
-
-#if XMALLOC_DEBUG
-
- if (s != NULL)
- check_free(s);
-
-#endif
-
- if (s != NULL)
- free(s);
-
-#if MEM_GEN_TRACE
-
- if (tracefp && s)
- fprintf(tracefp, "f:%p\n", s);
-
-#endif
-
- PROF_stop(xfree);
-}
-
/* xxfree() - like xfree(), but we already know s != NULL */
void
xxfree(const void *s_const)
return (p);
}
-/*
- * xcalloc() - same as calloc(3). Used for portability.
- * Never returns NULL; fatal on error.
- */
-void *
-xcalloc(size_t n, size_t sz)
-{
- void *p;
-
- PROF_start(xcalloc);
-
- if (n < 1)
- n = 1;
-
- if (sz < 1)
- sz = 1;
-
- PROF_start(calloc);
-
- p = calloc(n, sz);
-
- PROF_stop(calloc);
-
- if (p == NULL) {
- if (failure_notify) {
- snprintf(msg, 128, "xcalloc: Unable to allocate %u blocks of %u bytes!\n",
- (unsigned int) n, (unsigned int) sz);
- (*failure_notify) (msg);
- } else {
- perror("xcalloc");
- }
-
- exit(1);
- }
-
-#if XMALLOC_DEBUG
- check_malloc(p, sz * n);
-
-#endif
-#if XMALLOC_STATISTICS
-
- malloc_stat(sz * n);
-
-#endif
-#if XMALLOC_TRACE
-
- xmalloc_show_trace(p, 1);
-
-#endif
-#if MEM_GEN_TRACE
-
- if (tracefp)
- fprintf(tracefp, "c:%u:%u:%p\n", (unsigned int) n, (unsigned int) sz, p);
-
-#endif
-
- PROF_stop(xcalloc);
-
- return (p);
-}
-
-/*
- * xstrdup() - same as strdup(3). Used for portability.
- * Never returns NULL; fatal on error.
- */
-char *
-xstrdup(const char *s)
-{
- size_t sz;
- char *p;
- PROF_start(xstrdup);
-
- if (s == NULL) {
- if (failure_notify) {
- (*failure_notify) ("xstrdup: tried to dup a NULL pointer!\n");
- } else {
- fprintf(stderr, "xstrdup: tried to dup a NULL pointer!\n");
- }
-
- exit(1);
- }
-
- /* copy string, including terminating character */
- sz = strlen(s) + 1;
-
- p = (char *)xmalloc(sz);
- memcpy(p, s, sz);
-
- PROF_stop(xstrdup);
-
- return p;
-}
-
-/*
- * xstrndup() - string dup with length limit.
- */
-char *
-xstrndup(const char *s, size_t n)
-{
- size_t sz;
- char *p;
- PROF_start(xstrndup);
- assert(s != NULL);
- assert(n);
- sz = strlen(s) + 1;
-
- if (sz > n)
- sz = n;
-
- p = xstrncpy((char *)xmalloc(sz), s, sz);
-
- PROF_stop(xstrndup);
-
- return p;
-}
-
/*
* xstrerror() - strerror() wrapper
*/
(double) (t2.tv_usec - t1.tv_usec) / 1000000.0;
}
-/*
- * xstrncpy() - similar to strncpy(3) but terminates string
- * always with '\0' if (n != 0 and dst != NULL),
- * and doesn't do padding
- */
-char *
-xstrncpy(char *dst, const char *src, size_t n)
-{
- char *r = dst;
- PROF_start(xstrncpy);
-
- if (!n || !dst)
- return dst;
-
- if (src)
- while (--n != 0 && *src != '\0')
- *dst++ = *src++;
-
- *dst = '\0';
-
- PROF_stop(xstrncpy);
-
- return r;
-}
-
/* returns the number of leading white spaces in str; handy in skipping ws */
size_t
xcountws(const char *str)
$(OBJS): $(top_srcdir)/include/version.h $(top_builddir)/include/autoconf.h
## Because compatibility is almost universal. And the link order is important.
-## NP: libmisc util.cc depends on rint from math library
-COMPAT_LIB = \
- -L$(top_builddir)/lib -lmiscutil \
- -L$(top_builddir)/compat -lcompat-squid
+COMPAT_LIB = -L$(top_builddir)/compat -lcompat-squid
## Some helpers are written in Perl and need the local shell defined properly
subst_perlshell = sed -e 's,[@]PERL[@],$(PERL),g' <$(srcdir)/$@.pl.in >$@ || ($(RM) -f $@ ; exit 1)
$(SNMPLIB) \
${ADAPTATION_LIBS} \
$(ESI_LIBS) \
+ -L$(top_srcdir)/lib -lmiscutil \
$(COMPAT_LIB) \
$(SSLLIB) \
$(EPOLL_LIBS) \
mib.txt
LDADD = $(COMMON_LIBS) \
- -L../lib \
- -lmiscutil \
+ -L../lib -lmiscutil \
$(EPOLL_LIBS) \
$(MINGW_LIBS) \
$(XTRA_LIBS)
DiskIO_DiskDaemon_diskd_SOURCES = DiskIO/DiskDaemon/diskd.cc
nodist_DiskIO_DiskDaemon_diskd_SOURCES = time.cc
-DiskIO_DiskDaemon_diskd_LDADD = $(COMPAT_LIB) $(XTRA_LIBS)
+DiskIO_DiskDaemon_diskd_LDADD = \
+ -L$(top_builddir)/lib -lmiscutil \
+ $(COMPAT_LIB) \
+ $(XTRA_LIBS)
DEFAULT_HTTP_PORT = 3128
#tests_testX_LDADD=\
# $(SQUID_CPPUNIT_LIBS) \
# $(SQUID_CPPUNIT_LA) \
-# -L../lib -lmiscutil
+# $(COMPAT_LIB) \
+# $(XTRA_LIBS)
#tests_testX_DEPENDENCIES= $(SQUID_CPPUNIT_LA) \
# $(top_builddir)/lib/libmiscutil.a
$(ESI_LIBS) \
$(REGEXLIB) \
$(SNMPLIB) \
- -L../lib -lmiscutil \
+ $(COMPAT_LIB) \
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
$(ESI_LIBS) \
$(REGEXLIB) \
$(SNMPLIB) \
- -L../lib -lmiscutil \
+ $(COMPAT_LIB) \
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
$(ESI_LIBS) \
$(REGEXLIB) \
$(SNMPLIB) \
- -L../lib -lmiscutil \
+ $(COMPAT_LIB) \
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
$(ESI_LIBS) \
$(REGEXLIB) \
$(SNMPLIB) \
- -L../lib -lmiscutil \
+ $(COMPAT_LIB) \
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \
tests_testStore_LDADD= \
$(COMMON_LIBS) \
- -L../lib -lmiscutil \
+ $(COMPAT_LIB) \
$(REGEXLIB) \
$(SQUID_CPPUNIT_LIBS) \
$(SSLLIB) \
$(TESTSOURCES)
tests_testString_LDADD = \
$(COMMON_LIBS) \
- -L../lib -lmiscutil \
+ $(COMPAT_LIB) \
$(REGEXLIB) \
$(SQUID_CPPUNIT_LIBS) \
$(SSLLIB) \
$(REPL_OBJS) \
$(DISK_LIBS) \
$(DISK_OS_LIBS) \
- -L../lib -lmiscutil \
acl/libapi.la \
+ $(COMPAT_LIB) \
$(SQUID_CPPUNIT_LIBS) \
$(XTRA_LIBS)
SWAP_TEST_DS =\
${ADAPTATION_LIBS} \
$(ESI_LIBS) \
$(SNMPLIB) \
- -L../lib -lmiscutil \
+ $(COMPAT_LIB) \
$(SQUID_CPPUNIT_LIBS) \
$(SQUID_CPPUNIT_LA) \
$(SSLLIB) \