]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3038: Detatch libmisc from libcompat
authorAmos Jeffries <amosjeffries@squid-cache.org>
Mon, 1 Nov 2010 05:44:28 +0000 (23:44 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Mon, 1 Nov 2010 05:44:28 +0000 (23:44 -0600)
* Migrates many of the remaining libmisc portability wrappers into
  libcompat.

* Splits libmisc into:
   libprofiler - Squid internal profiler (developer-only)
   libmiscencoding - Various binary encoding / crypto algorithms
   libmisccontainers - Various data container algorithms

* Makes all binaries which need to link the libmisc* pieces directly instead
  of via $(COMPAT_LIB) which now only links the libcompat and internal
  profiler due to profiling being used on some libcompat functions.

* Adds a stub_debug for binaries needing the Debug.h API without squid
  timers and globals.

Some effort has been made to identify binaries whose dependencies can be
reduced. More of this dependency removal can be done in future.

89 files changed:
Makefile.am
compat/Makefile.am
compat/compat.cc
compat/compat_shared.h
compat/os/mswin.h
compat/xalloc.cc [new file with mode: 0644]
compat/xalloc.h [new file with mode: 0644]
compat/xstrerror.cc [new file with mode: 0644]
compat/xstrerror.h [new file with mode: 0644]
compat/xstring.cc [new file with mode: 0644]
compat/xstring.h [new file with mode: 0644]
compat/xstrto.cc [moved from lib/xstrto.cc with 99% similarity]
compat/xstrto.h [moved from include/xstrto.h with 100% similarity]
configure.in
helpers/basic_auth/MSNT/Makefile.am
helpers/basic_auth/NCSA/Makefile.am
helpers/basic_auth/NCSA/basic_ncsa_auth.cc
helpers/basic_auth/NIS/Makefile.am
helpers/basic_auth/PAM/Makefile.am
helpers/basic_auth/RADIUS/Makefile.am
helpers/basic_auth/getpwnam/Makefile.am
helpers/basic_auth/getpwnam/basic_getpwnam_auth.cc
helpers/defines.h
helpers/digest_auth/file/Makefile.am
helpers/external_acl/file_userip/Makefile.am
helpers/external_acl/unix_group/Makefile.am
helpers/ntlm_auth/fake/Makefile.am
helpers/ntlm_auth/fake/ntlm_fake_auth.cc
helpers/ntlm_auth/smb_lm/Makefile.am
helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.cc
include/SquidNew.h
include/base64.h [new file with mode: 0644]
include/charset.h [new file with mode: 0644]
include/config.h
include/html_quote.h [new file with mode: 0644]
include/rfc1123.h [new file with mode: 0644]
include/rfc1738.h
include/rfc2617.h
include/util.h
include/uudecode.h [new file with mode: 0644]
lib/Makefile.am
lib/base64.c
lib/charset.c
lib/hash.c
lib/html_quote.c
lib/md5.c
lib/profiler/Makefile.am [new file with mode: 0644]
lib/profiler/Profiler.cc [moved from lib/Profiler.c with 97% similarity]
lib/profiler/Profiler.h [new file with mode: 0644]
lib/profiler/get_tick.h [new file with mode: 0644]
lib/profiler/xprof_type.h [moved from include/profiling.h with 50% similarity]
lib/rfc1123.c
lib/rfc1738.c
lib/util.c
lib/uudecode.c
lib/xusleep.c
snmplib/parse.c
src/Common.am
src/Debug.h
src/HttpHeader.cc
src/Makefile.am
src/SquidTime.h
src/adaptation/icap/ModXact.cc
src/auth/User.cci
src/auth/User.h
src/auth/basic/auth_basic.cc
src/auth/digest/auth_digest.cc
src/auth/digest/digestUserRequest.cc
src/comm.cc
src/defines.h
src/dlink.cc
src/dnsserver.cc
src/errorpage.cc
src/ftp.cc
src/gopher.cc
src/http.cc
src/icmp/Makefile.am
src/ip/Makefile.am
src/main.cc
src/protos.h
src/squid.h
src/tests/stub_debug.cc [new file with mode: 0644]
src/time.cc
src/unlinkd_daemon.cc
test-suite/Makefile.am
test-suite/test_tools.cc
tools/Makefile.am
tools/cachemgr.cc
tools/squidclient.cc

index 344cc3c975d2c3bd66851c1f263001c6d68c36e6..d839afef42f7145ddc0bc955b37f3c446b48418f 100644 (file)
@@ -2,12 +2,12 @@
 #
 
 AUTOMAKE_OPTIONS = dist-bzip2 subdir-objects 1.5 foreign
-DIST_SUBDIRS   = compat lib libltdl snmplib scripts src icons errors contrib doc helpers test-suite tools
+DIST_SUBDIRS   = compat lib libltdl snmplib scripts icons errors contrib doc helpers src test-suite tools
 SUBDIRS                = compat lib $(makesnmplib)
 if USE_LOADABLE_MODULES
 SUBDIRS += libltdl
 endif
-SUBDIRS += scripts src icons errors doc helpers test-suite tools
+SUBDIRS += scripts icons errors doc helpers src tools test-suite
 
 DISTCLEANFILES = include/stamp-h include/stamp-h[0-9]*
 DEFAULT_PINGER         = $(libexecdir)/`echo pinger | sed '$(transform);s/$$/$(EXEEXT)/'`
index 03494f72a4b80dc84c584751d23c64157fb65410..3d7fc2c3e609a19634fd44f31a3715b0e2ef2cb6 100644 (file)
@@ -11,16 +11,21 @@ include $(top_srcdir)/src/Common.am
 
 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 \
@@ -33,6 +38,14 @@ libcompat_squid_a_SOURCES = \
        types.h \
        unsafe.h \
        valgrind.h \
+       xalloc.cc \
+       xalloc.h \
+       xstrerror.cc \
+       xstrerror.h \
+       xstring.cc \
+       xstring.h \
+       xstrto.cc \
+       xstrto.h \
        \
        os/aix.h \
        os/dragonfly.h \
@@ -49,13 +62,7 @@ libcompat_squid_a_SOURCES = \
        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)
 
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e36ae437941bc54986ba3576f847b41c5915eb87 100644 (file)
@@ -0,0 +1,4 @@
+#include "config.h"
+#include "compat.h"
+
+void (*failure_notify) (const char *) = NULL;
index 35fdabb6f290d438a94a7e8f0b80d927910bb147..f5d00ee1abc66c3036ce0ee12a54b51dd0084279 100644 (file)
  * 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.
@@ -194,5 +205,13 @@ extern "C" {
 #endif
 #endif
 
+/*
+ * Several function definitions which we provide for security and code safety.
+ */
+#include "compat/xalloc.h"
+#include "compat/xstrerror.h"
+#include "compat/xstring.h"
+#include "compat/xstrto.h"
+
 
 #endif /* _SQUID_COMPAT_SHARED_H */
index 35751b919fbd062507c2ea9499630fdf48bc9cdf..d01f57c8a8b9fa0c039d4b741acd2f2684e8d7a0 100644 (file)
@@ -238,6 +238,10 @@ struct timezone {
 
 typedef char * caddr_t;
 
+#ifndef _PATH_DEVNULL
+#define _PATH_DEVNULL "NUL"
+#endif
+
 #undef FD_CLOSE
 #undef FD_OPEN
 #undef FD_READ
diff --git a/compat/xalloc.cc b/compat/xalloc.cc
new file mode 100644 (file)
index 0000000..ee04da3
--- /dev/null
@@ -0,0 +1,228 @@
+#include "config.h"
+#include "compat/xalloc.h"
+#include "profiler/Profiler.h"
+
+#if XMALLOC_STATISTICS
+#define XMS_DBG_MAXSIZE   (1024*1024)
+#define XMS_DBG_SPLIT     (256)     /* mallocs below this value are tracked with DBG_GRAIN_SM precision instead of DBG_GRAIN */
+#define XMS_DBG_GRAIN     (16)
+#define XMS_DBG_GRAIN_SM  (4)
+#define XMS_DBG_OFFSET    (XMS_DBG_SPLIT/XMS_DBG_GRAIN_SM - XMS_DBG_SPLIT/XMS_DBG_GRAIN )
+#define XMS_DBG_MAXINDEX  (XMS_DBG_MAXSIZE/XMS_DBG_GRAIN + XMS_DBG_OFFSET)
+static int malloc_sizes[XMS_DBG_MAXINDEX + 1];
+static int malloc_histo[XMS_DBG_MAXINDEX + 1];
+static int dbg_stat_init = 0;
+
+static int
+XMS_DBG_INDEX(int sz)
+{
+    if (sz >= XMS_DBG_MAXSIZE)
+        return XMS_DBG_MAXINDEX;
+
+    if (sz <= XMS_DBG_SPLIT)
+        return (sz + XMS_DBG_GRAIN_SM - 1) / XMS_DBG_GRAIN_SM;
+        
+    return (sz + XMS_DBG_GRAIN - 1) / XMS_DBG_GRAIN + XMS_DBG_OFFSET;
+}
+
+static void
+stat_init(void)
+{
+    for (int i = 0; i <= XMS_DBG_MAXINDEX; i++)
+        malloc_sizes[i] = malloc_histo[i] = 0;
+        
+    dbg_stat_init = 1;
+}
+static int
+malloc_stat(int sz)
+{
+    if (!dbg_stat_init)
+        stat_init();   
+        
+    return malloc_sizes[XMS_DBG_INDEX(sz)] += 1;
+}
+
+void
+malloc_statistics(void (*func) (int, int, int, void *), void *data)
+{
+    int i = 0;
+
+    for (; i <= XMS_DBG_SPLIT; i += XMS_DBG_GRAIN_SM)
+        func(i, malloc_sizes[XMS_DBG_INDEX(i)], malloc_histo[XMS_DBG_INDEX(i)], data);
+
+    i -= XMS_DBG_GRAIN_SM;
+
+    for (; i <= XMS_DBG_MAXSIZE; i += XMS_DBG_GRAIN)
+        func(i, malloc_sizes[XMS_DBG_INDEX(i)], malloc_histo[XMS_DBG_INDEX(i)], data);
+
+    xmemcpy(&malloc_histo, &malloc_sizes, sizeof(malloc_sizes));
+}
+#endif /* XMALLOC_STATISTICS */
+
+void *
+xcalloc(size_t n, size_t sz)
+{
+    PROF_start(xcalloc);
+
+    if (n < 1)
+        n = 1;
+
+    if (sz < 1)
+        sz = 1;
+
+    PROF_start(calloc);
+    void *p = calloc(n, sz);
+    PROF_stop(calloc);
+
+    if (p == NULL) {
+        if (failure_notify) {
+            static char msg[128];
+            snprintf(msg, 128, "xcalloc: Unable to allocate %Zu blocks of %Zu bytes!\n", n, 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;
+}
+
+void *
+xmalloc(size_t sz)
+{
+    PROF_start(xmalloc);
+
+    if (sz < 1)
+        sz = 1;
+
+    PROF_start(malloc);
+    void *p = malloc(sz);
+    PROF_stop(malloc);
+
+    if (p == NULL) {
+        if (failure_notify) {
+            static char msg[128];
+            snprintf(msg, 128, "xmalloc: Unable to allocate %Zu bytes!\n", 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);
+}
+
+void *
+xrealloc(void *s, size_t sz)   
+{
+    PROF_start(xrealloc);
+#if XMALLOC_TRACE
+    xmalloc_show_trace(s, -1);
+#endif   
+    if (sz < 1) 
+        sz = 1;
+#if XMALLOC_DEBUG
+    if (s != NULL)
+        check_free(s);
+#endif
+    PROF_start(realloc);
+    void *p= realloc(s, sz);
+    PROF_stop(realloc);
+
+    if (p == NULL) {
+        if (failure_notify) {
+            static char msg[128];
+            snprintf(msg, 128, "xrealloc: Unable to reallocate %Zu bytes!\n", sz);
+            (*failure_notify) (msg);
+        } else {
+            perror("realloc");
+        }
+         
+        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)                /* new ptr, old ptr, new size */
+        fprintf(tracefp, "r:%p:%p:%d\n", p, s, sz);
+#endif
+    PROF_stop(xrealloc);
+    return (p);
+}
+
+void
+xfree(void *s)
+{
+    if (s == NULL)
+        return;
+
+    free_const(s);
+}
+
+void
+free_const(const void *s_const)
+{
+    void *s = const_cast<void *>(s_const);
+
+    PROF_start(free_const);
+#if XMALLOC_TRACE
+      xmalloc_show_trace(s, -1);
+#endif
+
+#if XMALLOC_DEBUG
+    check_free(s);
+#endif
+
+    PROF_start(free);
+    free(s);
+    PROF_stop(free);
+
+#if MEM_GEN_TRACE
+    if (tracefp)
+        fprintf(tracefp, "f:%p\n", s);
+#endif
+    PROF_stop(free_const);
+}
diff --git a/compat/xalloc.h b/compat/xalloc.h
new file mode 100644 (file)
index 0000000..14cb5dd
--- /dev/null
@@ -0,0 +1,74 @@
+#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);
+
+/**
+ * xrealloc() - same as realloc(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ */
+void *xrealloc(void *s, 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);
+
+/**
+ * xxfree() / free_const() - Same as free(3).  Used for portability.
+ * Accepts pointers to dynamically allocated const data.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+void free_const(const void *s);
+
+/// Backward compatibility alias for free_const(const void *s)
+#define xxfree(x)  free_const((x))
+
+/**
+ * Accepts pointers to dynamically allocated const data.
+ * Will not call free(3) if the pointer is NULL.
+ * Sets the pointer to NULL on completion.
+ *
+ * Use xfree() if the pointer does not need to be set afterward.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+#define safe_free(x)    if ((x)) { xxfree((x)); (x) = NULL; } else (void)0
+
+
+#if XMALLOC_STATISTICS
+void malloc_statistics(void (*func) (int, int, int, void *), void *data);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SQUID_COMPAT_XALLOC_H */
diff --git a/compat/xstrerror.cc b/compat/xstrerror.cc
new file mode 100644 (file)
index 0000000..0cf722d
--- /dev/null
@@ -0,0 +1,20 @@
+#include "config.h"
+#include "compat/xstrerror.h"
+
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+
+const char *
+xstrerr(int error)
+{
+    static char xstrerror_buf[BUFSIZ];
+    const char *errmsg = strerror(error);
+
+    if (!errmsg || !*errmsg)
+        errmsg = "Unknown error";
+
+    snprintf(xstrerror_buf, BUFSIZ, "(%d) %s", error, errmsg);
+
+    return xstrerror_buf;
+}
diff --git a/compat/xstrerror.h b/compat/xstrerror.h
new file mode 100644 (file)
index 0000000..8a55f16
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _SQUID_COMPAT_XSTRERROR_H
+#define _SQUID_COMPAT_XSTRERROR_H
+
+/** strerror() wrapper replacement.
+ *
+ * Provides the guarantee that a string is always returned.
+ * Where strerror() would have provided NULL this will report the error as unknown.
+ */
+#define xstrerror() xstrerr(errno)
+
+/** Provide the textual display of a system error number.
+ * A string is always returned.
+ */
+extern const char * xstrerr(int error);
+
+#endif /* _SQUID_COMPAT_XSTRERROR_H */
diff --git a/compat/xstring.cc b/compat/xstring.cc
new file mode 100644 (file)
index 0000000..1e8376c
--- /dev/null
@@ -0,0 +1,80 @@
+#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;
+}
diff --git a/compat/xstring.h b/compat/xstring.h
new file mode 100644 (file)
index 0000000..4c8d71a
--- /dev/null
@@ -0,0 +1,57 @@
+#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 */
similarity index 99%
rename from lib/xstrto.cc
rename to compat/xstrto.cc
index dcbd03247ac4dc3a28862d914e59ae961066dced..20bdeddab8a1b4752c110a3b903b36eadc07482b 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 #include "config.h"
-#include "xstrto.h"
+#include "compat/xstrto.h"
 
 /*
  * (C) 2000-2006 by the netfilter coreteam <coreteam@netfilter.org>:
similarity index 100%
rename from include/xstrto.h
rename to compat/xstrto.h
index 3e64fe0b15a342bb12efde44a5c3338a65176ef9..981889715b51ca60dc1b91d3dfc444766616708c 100644 (file)
@@ -2185,6 +2185,7 @@ AC_CHECK_HEADERS( \
   bstring.h \
   cassert \
   crypt.h \
+  cstdlib \
   cstring \
   ctype.h \
   errno.h \
@@ -3304,6 +3305,7 @@ AC_CONFIG_FILES([\
        compat/Makefile \
        lib/Makefile \
        lib/ntlmauth/Makefile \
+       lib/profiler/Makefile \
        lib/rfcnb/Makefile \
        lib/smblib/Makefile \
        scripts/Makefile \
index 6d74bd64728d160a8fe2d3e0d068c96a33f41fc2..9237952c16e977c70925a0113c7ca8d88a0bbb2f 100644 (file)
@@ -29,6 +29,7 @@ CXXFLAGS += -DSYSCONFDIR=\"$(sysconfdir)\"
 LDADD = \
        $(top_builddir)/lib/smblib/libsmblib.la \
        $(top_builddir)/lib/rfcnb/librfcnb.la \
+       $(top_builddir)/lib/libmiscencoding.la \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
 
index 1e0226a2804553df83462c634e700ea10d77a6cc..d89f6ee3663152ee12078175ba8d4b95746c6e0b 100644 (file)
@@ -5,10 +5,12 @@ basic_ncsa_auth_SOURCES       = basic_ncsa_auth.cc crypt_md5.cc crypt_md5.h
 man_MANS               = basic_ncsa_auth.8
 EXTRA_DIST             = basic_ncsa_auth.8 config.test
 LDADD = \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
        $(COMPAT_LIB) \
        $(CRYPTLIB) \
-       $(XTRA_LIBS) \
-       $(SSLLIB)
+       $(SSLLIB) \
+       $(XTRA_LIBS)
 
 ## we need our local files too (but avoid -I. at all costs)
 INCLUDES += -I$(srcdir)
index 19fb48e3835f113a5ca3b0957fd529980f72cdd4..bdd7311f94fb4d11755fe8710adaa7243c675a05 100644 (file)
@@ -37,6 +37,9 @@
 #if HAVE_CRYPT_H
 #include <crypt.h>
 #endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
 
 static hash_table *hash = NULL;
 static HASHFREE my_free;
index 79791ee52dc302c4561c160e3184f9e4cf40bf28..1680500c9f7e7d8e29e8e65be46164dc079371dd 100644 (file)
@@ -11,6 +11,7 @@ basic_nis_auth_SOURCES = \
        nis_support.cc
 
 basic_nis_auth_LDADD = \
+       $(top_builddir)/lib/libmiscencoding.la \
        $(COMPAT_LIB) \
        $(CRYPTLIB) \
        $(XTRA_LIBS)
index b7a294a53aa081358715eaf6a35a8d91b9628f6b..d1dbf3c57eb6848ae89c5038cc3c0eeee00c9314 100644 (file)
@@ -6,6 +6,7 @@ libexec_PROGRAMS        = basic_pam_auth
 basic_pam_auth_SOURCES = basic_pam_auth.cc
 
 basic_pam_auth_LDADD = \
+       $(top_builddir)/lib/libmiscencoding.la \
        $(COMPAT_LIB) \
        -lpam \
        $(XTRA_LIBS)
index 85745704c816fcf1f0c4869c86deac660ad851bd..b6e32241a44094ffb5088fe7d0926839ed137e80 100644 (file)
@@ -13,6 +13,7 @@ basic_radius_auth_SOURCES = \
                        radius-util.h
 
 basic_radius_auth_LDADD = \
+       $(top_builddir)/lib/libmiscencoding.la \
        $(COMPAT_LIB) \
        $(SSLLIB) \
        $(XTRA_LIBS)
index 0819be60dfa0c6db030e629fe284ec6422522ec8..21047fdffbe490c0a1d51642a701b3780b8eb336 100644 (file)
@@ -4,6 +4,7 @@ libexec_PROGRAMS = basic_getpwnam_auth
 
 basic_getpwnam_auth_SOURCES = basic_getpwnam_auth.cc
 basic_getpwnam_auth_LDADD = \
+       $(top_builddir)/lib/libmiscencoding.la \
        $(COMPAT_LIB) \
        $(CRYPTLIB)
 
index c05f2e04d5f4eb24bb0274004a3dd5bf797b497d..7e57b2e59f25adf2160a9561319734addcf651d3 100644 (file)
@@ -27,7 +27,7 @@
 #include "config.h"
 #include "helpers/defines.h"
 #include "rfc1738.h"
-#include "util.h"
+//#include "util.h"
 
 #if HAVE_STDIO_H
 #include <stdio.h>
index 9cd7fbcd0870e24965b88de96b6203b8acbadb37..57823acf806ab40a77338c01ad145fede483a82c 100644 (file)
@@ -8,8 +8,6 @@
 
 #define HELPER_INPUT_BUFFER    8196
 
-#define safe_free(x)    if (x) { free(x); x = NULL; }
-
 /* send OK result to Squid with a string parameter. */
 #define SEND_OK(x)     fprintf(stdout, "OK %s\n",x)
 
index f0206a419ee2170ead21aa573e0b5d28f910250c..9ed0c15445a4e8212560205d85f7fc541e9b8881 100644 (file)
@@ -11,6 +11,8 @@ digest_file_auth_SOURCES = digest_file_auth.cc \
        text_backend.h
 
 LDADD = \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
        $(COMPAT_LIB) \
        $(CRYPTLIB) \
        $(SSLLIB) \
index af5813efa6ff8ac959f3d432f49ffdcff7424980..90c915d374f21792eb99cb7069a2810db7d0d112 100644 (file)
@@ -11,5 +11,6 @@ EXTRA_DIST = \
        config.test
 
 LDADD = \
+       $(top_builddir)/lib/libmiscencoding.la \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
index 532bf7128807addf9bcc89190e8fa74d47f610db..16c7dbc6efe6fccc879f9e8fc549e13ce17c1be6 100644 (file)
@@ -6,5 +6,6 @@ EXTRA_DIST                      = ext_unix_group_acl.8 config.test
 ext_unix_group_acl_SOURCES     = check_group.cc
 
 LDADD = \
+       $(top_builddir)/lib/libmiscencoding.la \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
index 8cb2b7fb04845525738db957dbfdfedae6b756bd..97d198e41bc154fd6091b7b19f8e23162ae008f5 100644 (file)
@@ -5,6 +5,7 @@ ntlm_fake_auth_SOURCES  = ntlm_fake_auth.cc
 
 ntlm_fake_auth_LDADD = \
        $(top_builddir)/lib/ntlmauth/libntlmauth.la \
+       $(top_builddir)/lib/libmiscencoding.la \
        $(COMPAT_LIB) \
        $(CRYPTLIB) \
        $(XTRA_LIBS)
index 816a6ae71d1948743281a3d4c67b291f1ba10550..85b7761528c227165b0f6271240755fcc4ba244c 100644 (file)
 #define IGNORANCE_IS_BLISS
 
 #include "config.h"
+#include "base64.h"
 #include "helpers/defines.h"
 #include "ntlmauth/ntlmauth.h"
 #include "ntlmauth/support_bits.cci"
-#include "util.h"
+//#include "util.h"
 
 #if HAVE_CTYPE_H
 #include <ctype.h>
index 78bae08f7349e2a9d218d5dced38a3950f3f8444..5f60194623d2522ac9876ebac45f35ff93fab75e 100644 (file)
@@ -7,6 +7,7 @@ ntlm_smb_lm_auth_LDADD = \
        $(top_builddir)/lib/smblib/libsmblib.la \
        $(top_builddir)/lib/rfcnb/librfcnb.la \
        $(top_builddir)/lib/ntlmauth/libntlmauth.la \
+       $(top_builddir)/lib/libmiscencoding.la \
        $(COMPAT_LIB) \
        $(CRYPTLIB) \
        $(XTRA_LIBS)
index 36f1845f9bd4800cdb0a97d9d393acdd584e1755..6319e3056526abf429e103ef7b753415811d3c40 100644 (file)
  *
  */
 #include "config.h"
+#include "base64.h"
 #include "compat/debug.h"
 #include "ntlmauth/ntlmauth.h"
 #include "ntlmauth/support_bits.cci"
 #include "rfcnb/rfcnb.h"
 #include "smblib/smblib.h"
-#include "util.h"
+//#include "util.h"
 
 #if HAVE_STRING_H
 #include <string.h>
index e30f7b46c12ed9b0ded05d8e634ad270f965af20..74c92135c0d29f3c5783f4bd8dda75927ed0fffe 100644 (file)
@@ -33,7 +33,7 @@
 #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
@@ -50,7 +50,7 @@ _SQUID_EXTERNNEW_ void *operator new(size_t size) throw (std::bad_alloc)
 }
 _SQUID_EXTERNNEW_ void operator delete (void *address) throw()
 {
-    xfree (address);
+    xfree(address);
 }
 _SQUID_EXTERNNEW_ void *operator new[] (size_t size) throw (std::bad_alloc)
 {
@@ -58,7 +58,7 @@ _SQUID_EXTERNNEW_ void *operator new[] (size_t size) throw (std::bad_alloc)
 }
 _SQUID_EXTERNNEW_ void operator delete[] (void *address) throw()
 {
-    xfree (address);
+    xfree(address);
 }
 
 
diff --git a/include/base64.h b/include/base64.h
new file mode 100644 (file)
index 0000000..8276610
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef _SQUID_BASE64_H
+#define _SQUID_BASE64_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern char *base64_decode(const char *coded);
+extern const char *base64_encode(const char *decoded);
+extern const char *base64_encode_bin(const char *data, int len);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _SQUID_BASE64_H */
diff --git a/include/charset.h b/include/charset.h
new file mode 100644 (file)
index 0000000..5d385b2
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _SQUID_CHARSET_H
+#define _SQUID_CHARSET_H
+
+#ifdef __cplusplus
+extern "C"
+#else
+extern
+#endif
+
+char *latin1_to_utf8(char *out, size_t size, const char *in);
+
+#endif /* _SQUID_CHARSET_H */
index 386aa89e563516642ebb1e973cd288872a24d4e2..4ae2da08ffcd6e566d6427b115c37b4319ccddde 100644 (file)
  */
 #include "strnstr.h"
 
-/*
- * xstrtoul() and xstrtoui() are strtoul() and strtoui() with limits.
- */
-#include "xstrto.h"
-
 #endif /* SQUID_CONFIG_H */
diff --git a/include/html_quote.h b/include/html_quote.h
new file mode 100644 (file)
index 0000000..4ad42ed
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _SQUID_HTML_QUOTE_H
+#define _SQUID_HTML_QUOTE_H
+
+#ifdef __cplusplus
+extern "C"
+#else
+extern
+#endif
+
+char *html_quote(const char *);
+
+#endif /* _SQUID_HTML_QUOTE_H */
diff --git a/include/rfc1123.h b/include/rfc1123.h
new file mode 100644 (file)
index 0000000..04f0b56
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef _SQUID_RFC1123_H
+#define _SQUID_RFC1123_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const char *mkhttpdlogtime(const time_t *);
+extern const char *mkrfc1123(time_t);
+extern time_t parse_rfc1123(const char *str);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _SQUID_RFC1123_H */
index b3538ecad0045d8063c49de500eca9806658629a..7189bb98afb2f05cf7483f5536add28b060cdb3d 100644 (file)
@@ -1,9 +1,9 @@
 #ifndef _SQUID_INCLUDE_RFC1738_H
 #define _SQUID_INCLUDE_RFC1738_H
 
-/* for SQUIDCEXTERN */
-#include "config.h"
-
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Encoder rfc1738_do_escape flag values. */
 #define RFC1738_ESCAPE_UNSAFE     0
@@ -27,7 +27,7 @@
  * \param flags  RFC1738_ESCAPE_RESERVED  Encode all unsafe and reserved characters.
  * \param flags  RFC1738_ESCAPE_UNESCAPED Encode all unsafe characters which have not already been encoded.
  */
-SQUIDCEXTERN char *rfc1738_do_escape(const char *url, int flags);
+extern char *rfc1738_do_escape(const char *url, int flags);
 
 /* Old API functions */
 #define rfc1738_escape(x)  rfc1738_do_escape(x, RFC1738_ESCAPE_UNSAFE)
@@ -39,7 +39,9 @@ SQUIDCEXTERN char *rfc1738_do_escape(const char *url, int flags);
  * Unescape a URL string according to RFC 1738 specification.
  * String is unescaped in-place
  */
-SQUIDCEXTERN void rfc1738_unescape(char *url);
-
+extern void rfc1738_unescape(char *url);
 
+#ifdef __cplusplus
+}
+#endif
 #endif /* _SQUID_INCLUDE_RFC1738_H */
index 5c5152343b4306bad33bc9273a421a6c4cdfb1fa..fcb79ed37b087b4342cee78822c95f3861d02310 100644 (file)
 
 #include "config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define HASHLEN 16
 typedef char HASH[HASHLEN];
 #define HASHHEXLEN 32
 typedef char HASHHEX[HASHHEXLEN + 1];
 
 /* calculate H(A1) as per HTTP Digest spec */
-SQUIDCEXTERN void DigestCalcHA1(
+extern void DigestCalcHA1(
     const char *pszAlg,
     const char *pszUserName,
     const char *pszRealm,
@@ -69,7 +73,7 @@ SQUIDCEXTERN void DigestCalcHA1(
 );
 
 /* calculate request-digest/response-digest as per HTTP Digest spec */
-SQUIDCEXTERN void DigestCalcResponse(
+extern void DigestCalcResponse(
     const HASHHEX HA1,         /* H(A1) */
     const char *pszNonce,      /* nonce from server */
     const char *pszNonceCount, /* 8 hex digits */
@@ -81,8 +85,11 @@ SQUIDCEXTERN void DigestCalcResponse(
     HASHHEX Response           /* request-digest or response-digest */
 );
 
-SQUIDCEXTERN void CvtHex(const HASH Bin, HASHHEX Hex);
+extern void CvtHex(const HASH Bin, HASHHEX Hex);
 
-SQUIDCEXTERN void CvtBin(const HASHHEX Hex, HASH Bin);
+extern void CvtBin(const HASHHEX Hex, HASH Bin);
 
+#ifdef __cplusplus
+}
+#endif
 #endif /* SQUID_RFC2617_H */
index 52110691573e4afb43bf61509c509bf1b7d6ad67..300affb74596d7ab13767d49585a512e0c66cb9f 100644 (file)
 #include <arpa/inet.h>
 #endif
 
-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
 /*
  * Any code using libstdc++ must have externally resolvable overloads
@@ -83,13 +68,7 @@ SQUIDCEXTERN void xxfree(const void *);
 #include "SquidNew.h"
 #endif
 
-/* charset.c */
-SQUIDCEXTERN char *latin1_to_utf8(char *out, size_t size, const char *in);
-
-/* html.c */
-SQUIDCEXTERN char *html_quote(const char *);
-
-#if XMALLOC_STATISTICS
+#if 0 && XMALLOC_STATISTICS
 SQUIDCEXTERN void malloc_statistics(void (*)(int, int, int, void *), void *);
 #endif
 
@@ -109,9 +88,6 @@ extern void xmalloc_find_leaks(void);
 #endif
 
 SQUIDCEXTERN time_t parse_iso3307_time(const char *buf);
-SQUIDCEXTERN char *base64_decode(const char *coded);
-SQUIDCEXTERN const char *base64_encode(const char *decoded);
-SQUIDCEXTERN const char *base64_encode_bin(const char *data, int len);
 
 SQUIDCEXTERN double xpercent(double part, double whole);
 SQUIDCEXTERN int xpercentInt(double part, double whole);
diff --git a/include/uudecode.h b/include/uudecode.h
new file mode 100644 (file)
index 0000000..edef387
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef _SQUID_UUDECODE_H
+#define _SQUID_UUDECODE_
+
+#ifdef __cplusplus
+extern "C"
+#else
+extern
+#endif
+
+char *uudecode(const char *);
+
+#endif /* _SQUID_UUDECODE_H */
index eb3dca3b4a124ffad9574131edcea91cea547e7f..f30ad06f00533cc80ce61ee5d52a755db80e04a4 100644 (file)
@@ -1,11 +1,7 @@
-## Process this file with automake to produce Makefile.in
-#
-#  $Id$
-#
-
 include $(top_srcdir)/src/Common.am
 
-DIST_SUBDIRS = ntlmauth rfcnb smblib libTrie
+DIST_SUBDIRS = ntlmauth profiler rfcnb smblib libTrie
+EXTRA_DIST=
 
 SUBDIRS = rfcnb smblib
 if ENABLE_AUTH_NTLM
@@ -14,60 +10,61 @@ endif
 if USE_ESI
 SUBDIRS += libTrie
 endif
+if ENABLE_XPROF_STATS
+SUBDIRS += profiler
+endif
 
 
 install: all
 install-strip: all
 
-
-if ENABLE_XPROF_STATS
-XPROF_STATS_SOURCE = Profiler.c
-else
-XPROF_STATS_SOURCE = 
-endif
-
 if ENABLE_WIN32SPECIFIC
-LIBSSPWIN32=libsspwin32.a
+LIBSSPWIN32=libsspwin32.la
 WIN32SRC = win32lib.c
 else
 LIBSSPWIN32=
 WIN32SRC=
+EXTRA_LTLIBRARIES = \
+       libsspwin32.la
 endif
 
-EXTRA_LIBRARIES = \
-       libsspwin32.a
-noinst_LIBRARIES = \
-       libmiscutil.a \
+noinst_LTLIBRARIES = \
+       libmiscencoding.la \
+       libmisccontainers.la \
+       libmiscutil.la \
        $(LIBSSPWIN32)
 
 #
 # dirent.c, encrypt.c and getopt.c are needed for native Windows support.
 #
-EXTRA_libmiscutil_a_SOURCES = \
+EXTRA_libmiscutil_la_SOURCES = \
        dirent.c \
        encrypt.c \
        getopt.c \
-       md5.c \
-       Profiler.c \
        win32lib.c
 
-libmiscutil_a_SOURCES = \
+libmiscencoding_la_SOURCES = \
+       base64.c \
+       charset.c \
+       html_quote.c \
+       md5.c \
+       rfc1738.c \
+       rfc2617.c \
+       uudecode.c
+
+libmisccontainers_la_SOURCES = \
+       hash.c
+
+libmiscutil_la_SOURCES = \
        MemPool.cc \
        MemPoolChunked.cc \
        MemPoolMalloc.cc \
-       base64.c \
-       charset.c \
        getfullhostname.c \
-       hash.c \
        heap.c \
-       html_quote.c \
        iso3307.c \
-       md5.c \
        radix.c \
        rfc1035.c \
        rfc1123.c \
-       rfc1738.c \
-       rfc2617.c \
        rfc2671.c \
        rfc3596.c \
        $(SNPRINTFSOURCE) \
@@ -75,15 +72,11 @@ libmiscutil_a_SOURCES = \
        strnstr.cc \
        stub_memaccount.c \
        util.c \
-       uudecode.c \
-       xstrto.cc \
        xusleep.c \
-       $(XPROF_STATS_SOURCE) \
        $(WIN32SRC)
 
 # $(top_srcdir)/include/version.h should be a dependency
-libsspwin32_a_SOURCES = \
-       base64.c \
+libsspwin32_la_SOURCES = \
        sspwin32.c
 
 TESTS += tests/testAll
@@ -97,12 +90,13 @@ tests_testAll_SOURCES= \
        tests/testRFC1035.cc \
        tests/testRFC1738.h \
        tests/testRFC1738.cc \
-       tests/testMain.cc \
-       $(XPROF_STATS_SOURCE) \
-       $(WIN32SRC) \
-       util.c
+       tests/testMain.cc
 
-tests_testAll_LDADD= $(SQUID_CPPUNIT_LA) $(SQUID_CPPUNIT_LIBS)
+tests_testAll_LDADD= \
+       $(SQUID_CPPUNIT_LA) $(SQUID_CPPUNIT_LIBS) \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
+       $(COMPAT_LIB)
 
 tests_testAll_LDFLAGS = $(LIBADD_DL)
 
index b4ff2f04cb4c0967c1ea37e0e25b7e9796316579..7ca5c9829eb4859b5c39023219cc7d9ebfb748c4 100644 (file)
@@ -3,7 +3,7 @@
  */
 
 #include "config.h"
-#include "util.h"
+#include "base64.h"
 
 #if HAVE_STDIO_H
 #include <stdio.h>
index b885941efe7f170e95032c2e482777f7dad80140..b58b535dc5d641310f929496590428db447f8b3a 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 #include "config.h"
-#include "util.h"
+#include "charset.h"
 
 /** Convert ISO-LATIN-1 to UTF-8 */
 char *
index 5a410ab36234d8cd2d10df807a00cb855e2aa129..f962ad2548d85367b2dcfbb501471bc05e33beb7 100644 (file)
@@ -34,6 +34,8 @@
  */
 
 #include "config.h"
+#include "hash.h"
+#include "profiler/Profiler.h"
 
 #if HAVE_STDIO_H
 #include <stdio.h>
 #include <math.h>
 #endif
 
-#include "hash.h"
-#include "util.h"
-#include "profiling.h"
-
 static void hash_next_bucket(hash_table * hid);
 
 unsigned int
index 9425105bbeea73367049a2199a054ae78ed4958e..bd9bee06b359e9e097cdbf072a4fc0d1f5d6d824 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include "config.h"
+#include "html_quote.h"
 
 #if HAVE_STDIO_H
 #include <stdio.h>
@@ -41,8 +42,6 @@
 #include <string.h>
 #endif
 
-#include "util.h"
-
 /*
  *  HTML defines these characters as special entities that should be quoted.
  */
index 2322e5edd3a1fbde064efd42835b84df8f306386..6df0ce5256bb8334f7e1a5f781b07e951c094259 100644 (file)
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -30,7 +30,6 @@
  *
  */
 #include "config.h"
-
 #include "md5.h"
 
 #if HAVE_STRING_H
diff --git a/lib/profiler/Makefile.am b/lib/profiler/Makefile.am
new file mode 100644 (file)
index 0000000..9bd9f76
--- /dev/null
@@ -0,0 +1,15 @@
+include $(top_srcdir)/src/Common.am
+include $(top_srcdir)/src/TestHeaders.am
+
+XPROFSRC= \
+       get_tick.h \
+       Profiler.cc \
+       Profiler.h \
+       xprof_type.h
+
+if ENABLE_XPROF_STATS
+libprofiler_la_SOURCES = $(XPROFSRC)
+noinst_LTLIBRARIES = libprofiler.la
+else
+EXTRA_DIST = $(XPROFSRC)
+endif
similarity index 97%
rename from lib/Profiler.c
rename to lib/profiler/Profiler.cc
index 32b82ad7ad5586e372ee4699d14844f850d11463..1c01ecdfe1a9c1507d2edcf32e10350351a87019 100644 (file)
@@ -54,7 +54,7 @@
  *     ...  section of code measured ...
  *    PROF_stop(probename);
  *
- *   probename must be added to profiling.h into xprof_type enum list
+ *   probename must be added to the xprof_type.h enum list
  *   with prepended "XPROF_" string.
  *
  * \section description Description.
  */
 
 #include "config.h"
-
-/* This include needs to be BELOW config, as it may undef USE_XPROF_STATS */
-#include "profiling.h"
+#include "profiler/Profiler.h"
 
 #if USE_XPROF_STATS
 
@@ -175,7 +173,7 @@ xprof_InitLib(void)
     if (xprof_inited)
         return;
 
-    xprof_Timers = calloc(XPROF_LAST + 2, sizeof(xprof_stats_node));
+    xprof_Timers = static_cast<TimersArray *>(calloc(XPROF_LAST + 2, sizeof(xprof_stats_node)));
 
     xprof_Timers[XPROF_PROF_UNACCOUNTED]->name = "PROF_UNACCOUNTED";
     xprof_Timers[XPROF_PROF_UNACCOUNTED]->accu.start = get_tick();
diff --git a/lib/profiler/Profiler.h b/lib/profiler/Profiler.h
new file mode 100644 (file)
index 0000000..d59abc3
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef _PROFILER_H_
+#define _PROFILER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// NP: CPU support for get_tick() determines whether we can profile.
+//     always include get_tick.h first since it may undefine USE_XPROF_STATS
+
+#include "profiler/get_tick.h"
+#include "profiler/xprof_type.h"
+
+#if !USE_XPROF_STATS
+
+#define PROF_start(ARGS) ((void)0)
+#define PROF_stop(ARGS) ((void)0)
+
+#else /* USE_XPROF_STATS */
+
+#define XP_NOBEST (hrtime_t)-1
+
+typedef struct _xprof_stats_node xprof_stats_node;
+
+typedef struct _xprof_stats_data xprof_stats_data;
+
+struct _xprof_stats_data {
+    hrtime_t start;
+    hrtime_t stop;
+    hrtime_t delta;
+    hrtime_t best;
+    hrtime_t worst;
+    hrtime_t count;
+    hrtime_t accum;
+    int64_t summ;
+};
+
+struct _xprof_stats_node {
+    const char *name;
+    xprof_stats_data accu;
+    xprof_stats_data hist;
+};
+
+typedef xprof_stats_node TimersArray[1];
+
+/* public Data */
+extern TimersArray *xprof_Timers;
+
+/* Exported functions */
+extern void xprof_start(xprof_type type, const char *timer);
+extern void xprof_stop(xprof_type type, const char *timer);
+extern void xprof_event(void *data);
+
+#define PROF_start(type) xprof_start(XPROF_##type, #type)
+#define PROF_stop(type) xprof_stop(XPROF_##type, #type)
+
+#endif /* USE_XPROF_STATS */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _PROFILING_H_ */
diff --git a/lib/profiler/get_tick.h b/lib/profiler/get_tick.h
new file mode 100644 (file)
index 0000000..e05e493
--- /dev/null
@@ -0,0 +1,68 @@
+#ifndef _PROFILER_GET_TICK_H_
+#define _PROFILER_GET_TICK_H_
+
+#include "config.h"
+
+#if USE_XPROF_STATS
+
+#if !_SQUID_SOLARIS_
+typedef int64_t  hrtime_t;
+#endif
+
+#if defined(__GNUC__) && ( defined(__i386) || defined(__i386__) )
+static inline hrtime_t
+get_tick(void)
+{
+    hrtime_t regs;
+
+asm volatile ("rdtsc":"=A" (regs));
+    return regs;
+    /* We need return value, we rely on CC to optimise out needless subf calls */
+    /* Note that "rdtsc" is relatively slow OP and stalls the CPU pipes, so use it wisely */
+}
+
+#elif defined(__GNUC__) && ( defined(__x86_64) || defined(__x86_64__) )
+static inline hrtime_t
+get_tick(void)
+{
+    uint32_t lo, hi;
+    // Based on an example in Wikipedia
+    /* We cannot use "=A", since this would use %rax on x86_64 */
+asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
+    return (hrtime_t)hi << 32 | lo;
+}
+
+#elif defined(__GNUC__) && defined(__alpha)
+static inline hrtime_t
+get_tick(void)
+{
+    hrtime_t regs;
+
+asm volatile ("rpcc %0" : "=r" (regs));
+    return regs;
+}
+
+#elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */
+static __inline hrtime_t
+get_tick(void)
+{
+    hrtime_t regs;
+
+    __asm {
+        cpuid
+        rdtsc
+        mov eax,DWORD PTR regs[0]
+        mov edx,DWORD PTR regs[4]
+    }
+    return regs;
+}
+
+#else
+/* This CPU is unsupported. Short-circuit, no profiling here */
+#define get_tick() 0
+#undef USE_XPROF_STATS
+#define USE_XPROF_STATS 0
+#endif
+
+#endif /* USE_XPROF_STATS */
+#endif /* _PROFILING_H_ */
similarity index 50%
rename from include/profiling.h
rename to lib/profiler/xprof_type.h
index 02d5687f352b2865f8e4f4b012a94bb2b698b1eb..9315aafe6b7498f4ac16676c574c0ad5721cb030 100644 (file)
@@ -1,78 +1,12 @@
-#ifndef _PROFILING_H_
-#define _PROFILING_H_
-
-#include "config.h"
-
-/* forward decls (C++ only) */
-#if __cplusplus
-
-class CacheManager;
-#endif
+#ifndef _PROFILER_XPROF_TYPE_H_
+#define _PROFILER_XPROF_TYPE_H_
 
 #if USE_XPROF_STATS
 
-#if !_SQUID_SOLARIS_
-typedef int64_t  hrtime_t;
-#endif
-
-#if defined(__GNUC__) && ( defined(__i386) || defined(__i386__) )
-static inline hrtime_t
-get_tick(void)
-{
-    hrtime_t regs;
-
-asm volatile ("rdtsc":"=A" (regs));
-    return regs;
-    /* We need return value, we rely on CC to optimise out needless subf calls */
-    /* Note that "rdtsc" is relatively slow OP and stalls the CPU pipes, so use it wisely */
-}
-
-#elif defined(__GNUC__) && ( defined(__x86_64) || defined(__x86_64__) )
-static inline hrtime_t
-get_tick(void)
-{
-    uint32_t lo, hi;
-    // Based on an example in Wikipedia
-    /* We cannot use "=A", since this would use %rax on x86_64 */
-asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
-    return (hrtime_t)hi << 32 | lo;
-}
-
-#elif defined(__GNUC__) && defined(__alpha)
-static inline hrtime_t
-get_tick(void)
-{
-    hrtime_t regs;
+// TODO: auto-generate this list from a scan of the source code.
 
-asm volatile ("rpcc %0" : "=r" (regs));
-    return regs;
-}
-
-#elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */
-static __inline hrtime_t
-get_tick(void)
-{
-    hrtime_t regs;
-
-    __asm {
-        cpuid
-        rdtsc
-        mov eax,DWORD PTR regs[0]
-        mov edx,DWORD PTR regs[4]
-    }
-    return regs;
-}
-
-#else
-/* This CPU is unsupported. Short-circuit, no profiling here */
-#define get_tick() 0
-#undef USE_XPROF_STATS
-#define USE_XPROF_STATS 0
-#endif
-
-#endif /* USE_XPROF_STATS - maybe disabled above */
-
-#if USE_XPROF_STATS
+// This list MUST be kept in sync with the PROF_start()/PROF_stop() macros
+// used throughout the rest of the sources.
 
 typedef enum {
     XPROF_PROF_UNACCOUNTED,
@@ -81,9 +15,10 @@ typedef enum {
     XPROF_splay_splay,
     XPROF_xmalloc,
     XPROF_malloc,
-    XPROF_xfree,
-    XPROF_xxfree,
+    XPROF_free,
+    XPROF_free_const,
     XPROF_xrealloc,
+    XPROF_realloc,
     XPROF_xcalloc,
     XPROF_calloc,
     XPROF_xstrdup,
@@ -126,11 +61,9 @@ typedef enum {
     XPROF_file_read,
     XPROF_file_write,
     XPROF_file_close,
-#if USE_SQUID_ESI
     XPROF_esiExpressionEval,
     XPROF_esiProcessing,
     XPROF_esiParsing,
-#endif
     XPROF_storeClient_kickReads,
     XPROF_eventRun,
     XPROF_storeDirCallback,
@@ -178,47 +111,5 @@ typedef enum {
     XPROF_LAST
 } xprof_type;
 
-#define XP_NOBEST (hrtime_t)-1
-
-typedef struct _xprof_stats_node xprof_stats_node;
-
-typedef struct _xprof_stats_data xprof_stats_data;
-
-struct _xprof_stats_data {
-    hrtime_t start;
-    hrtime_t stop;
-    hrtime_t delta;
-    hrtime_t best;
-    hrtime_t worst;
-    hrtime_t count;
-    hrtime_t accum;
-    int64_t summ;
-};
-
-struct _xprof_stats_node {
-    const char *name;
-    xprof_stats_data accu;
-    xprof_stats_data hist;
-};
-
-typedef xprof_stats_node TimersArray[1];
-
-/* public Data */
-SQUIDCEXTERN TimersArray *xprof_Timers;
-
-/* Exported functions */
-SQUIDCEXTERN void xprof_start(xprof_type type, const char *timer);
-SQUIDCEXTERN void xprof_stop(xprof_type type, const char *timer);
-SQUIDCEXTERN void xprof_event(void *data);
-
-#define PROF_start(type) xprof_start(XPROF_##type, #type)
-#define PROF_stop(type) xprof_stop(XPROF_##type, #type)
-
-#else /* USE_XPROF_STATS */
-
-#define PROF_start(ARGS) ((void)0)
-#define PROF_stop(ARGS) ((void)0)
-
 #endif /* USE_XPROF_STATS */
-
 #endif /* _PROFILING_H_ */
index 91c588dc17c08e2f398928ead558ffbf2fe90d26..7d5573743709ac536756a03344cf17a229caa71a 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #include "config.h"
-
+#include "rfc1123.h"
 
 /*
  *  Adapted from HTSUtils.c in CERN httpd 3.0 (http://info.cern.ch/httpd/)
@@ -51,7 +51,6 @@
 #if HAVE_TIME_H
 #include <time.h>
 #endif
-#include "util.h"
 
 #define RFC850_STRFTIME "%A, %d-%b-%y %H:%M:%S GMT"
 #define RFC1123_STRFTIME "%a, %d %b %Y %H:%M:%S GMT"
index 70289b4545a53bd6237a06916051d88079271f6a..382a5c72a90cd9380fdc5148fd0308e59fb4ab57 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "config.h"
 #include "rfc1738.h"
-#include "util.h"
+//#include "util.h"
 
 #if HAVE_STDIO_H
 #include <stdio.h>
index 6685dff34a0c19e99d50585f18a31796a1fb23cd..cc5979e411af94b5eb3890b00a24a8fa0d9d16ea 100644 (file)
@@ -35,7 +35,8 @@
 #define _etext etext
 
 #include "config.h"
-#include "profiling.h"
+#include "profiler/Profiler.h"
+#include "util.h"
 
 #if HAVE_STDIO_H
 #include <stdio.h>
 #include <assert.h>
 #endif
 
-#include "util.h"
-
 static void default_failure_notify(const char *);
 
 void (*failure_notify) (const char *) = default_failure_notify;
-static char msg[128];
 
 #if MEM_GEN_TRACE
 
@@ -95,72 +93,6 @@ log_trace_done()
 
 #endif
 
-#if XMALLOC_STATISTICS
-#define DBG_MAXSIZE   (1024*1024)
-#define DBG_SPLIT     (256)    /* mallocs below this value are tracked with DBG_GRAIN_SM precision instead of DBG_GRAIN */
-#define DBG_GRAIN     (16)
-#define DBG_GRAIN_SM  (4)
-#define DBG_OFFSET    (DBG_SPLIT/DBG_GRAIN_SM - DBG_SPLIT/DBG_GRAIN )
-#define DBG_MAXINDEX  (DBG_MAXSIZE/DBG_GRAIN + DBG_OFFSET)
-#if 0 /* function version defined below */
-#define DBG_INDEX(sz) (sz<DBG_MAXSIZE?(sz+DBG_GRAIN-1)/DBG_GRAIN:DBG_MAXINDEX)
-#endif
-static int malloc_sizes[DBG_MAXINDEX + 1];
-static int malloc_histo[DBG_MAXINDEX + 1];
-static int dbg_stat_init = 0;
-
-static int
-DBG_INDEX(int sz)
-{
-    if (sz >= DBG_MAXSIZE)
-        return DBG_MAXINDEX;
-
-    if (sz <= DBG_SPLIT)
-        return (sz + DBG_GRAIN_SM - 1) / DBG_GRAIN_SM;
-
-    return (sz + DBG_GRAIN - 1) / DBG_GRAIN + DBG_OFFSET;
-}
-
-static void
-stat_init(void)
-{
-    int i;
-
-    for (i = 0; i <= DBG_MAXINDEX; i++)
-        malloc_sizes[i] = malloc_histo[i] = 0;
-
-    dbg_stat_init = 1;
-}
-
-static int
-malloc_stat(int sz)
-{
-    if (!dbg_stat_init)
-        stat_init();
-
-    return malloc_sizes[DBG_INDEX(sz)] += 1;
-}
-
-void
-malloc_statistics(void (*func) (int, int, int, void *), void *data)
-{
-    int i;
-
-    for (i = 0; i <= DBG_SPLIT; i += DBG_GRAIN_SM)
-        func(i, malloc_sizes[DBG_INDEX(i)], malloc_histo[DBG_INDEX(i)], data);
-
-    i -= DBG_GRAIN_SM;
-
-    for (i = i; i <= DBG_MAXSIZE; i += DBG_GRAIN)
-        func(i, malloc_sizes[DBG_INDEX(i)], malloc_histo[DBG_INDEX(i)], data);
-
-    xmemcpy(&malloc_histo, &malloc_sizes, sizeof(malloc_sizes));
-}
-
-#endif /* XMALLOC_STATISTICS */
-
-
-
 #if XMALLOC_TRACE
 char *xmalloc_file = "";
 int xmalloc_line = 0;
@@ -242,6 +174,7 @@ check_free(void *s)
     }
 
     if (I == DBG_ARRY_SZ) {
+        static char msg[128];
         snprintf(msg, 128, "xfree: ERROR: s=%p not found!", s);
         (*failure_notify) (msg);
     }
@@ -265,6 +198,7 @@ check_malloc(void *p, size_t sz)
         Q = P + malloc_size[B][I];
 
         if (P <= p && p < Q) {
+            static char msg[128];
             snprintf(msg, 128, "xmalloc: ERROR: p=%p falls in P=%p+%d",
                      p, P, malloc_size[B][I]);
             (*failure_notify) (msg);
@@ -485,326 +419,6 @@ xmalloc_find_leaks(void)
 
 #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)
-{
-    void *s = (void *) s_const;
-    PROF_start(xxfree);
-#if XMALLOC_TRACE
-
-    xmalloc_show_trace(s, -1);
-#endif
-#if XMALLOC_DEBUG
-
-    check_free(s);
-#endif
-
-    free(s);
-#if MEM_GEN_TRACE
-
-    if (tracefp && s)
-        fprintf(tracefp, "f:%p\n", s);
-
-#endif
-
-    PROF_stop(xxfree);
-}
-
-/*
- *  xrealloc() - same as realloc(3). Used for portability.
- *  Never returns NULL; fatal on error.
- */
-void *
-xrealloc(void *s, size_t sz)
-{
-    void *p;
-
-    PROF_start(xrealloc);
-#if XMALLOC_TRACE
-
-    xmalloc_show_trace(s, -1);
-#endif
-
-    if (sz < 1)
-        sz = 1;
-
-#if XMALLOC_DEBUG
-
-    if (s != NULL)
-        check_free(s);
-
-#endif
-
-    if ((p = realloc(s, sz)) == NULL) {
-        if (failure_notify) {
-            snprintf(msg, 128, "xrealloc: Unable to reallocate %d bytes!\n",
-                     (int) sz);
-            (*failure_notify) (msg);
-        } else {
-            perror("realloc");
-        }
-
-        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)               /* new ptr, old ptr, new size */
-        fprintf(tracefp, "r:%p:%p:%d\n", p, s, sz);
-
-#endif
-
-    PROF_stop(xrealloc);
-
-    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
- */
-const char *
-xstrerr(int error)
-{
-    static char xstrerror_buf[BUFSIZ];
-    const char *errmsg;
-
-    errmsg = strerror(error);
-
-    if (!errmsg || !*errmsg)
-        errmsg = "Unknown error";
-
-    snprintf(xstrerror_buf, BUFSIZ, "(%d) %s", error, errmsg);
-
-    return xstrerror_buf;
-}
-
-const char *
-xstrerror(void)
-{
-    return xstrerr(errno);
-}
-
 void
 Tolower(char *q)
 {
@@ -817,15 +431,6 @@ Tolower(char *q)
 }
 
 int
-
-tvSubMsec(struct timeval t1, struct timeval t2)
-{
-    return (t2.tv_sec - t1.tv_sec) * 1000 +
-           (t2.tv_usec - t1.tv_usec) / 1000;
-}
-
-int
-
 tvSubUsec(struct timeval t1, struct timeval t2)
 {
     return (t2.tv_sec - t1.tv_sec) * 1000000 +
@@ -833,38 +438,12 @@ tvSubUsec(struct timeval t1, struct timeval t2)
 }
 
 double
-
 tvSubDsec(struct timeval t1, struct timeval t2)
 {
     return (double) (t2.tv_sec - t1.tv_sec) +
            (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)
index fc342d9b24e577e6200215f97f86bb8d6666a2aa..a9f5f94a77ba9d5b1af85021b70c3b5c008a1658 100644 (file)
@@ -3,7 +3,7 @@
  */
 
 #include "config.h"
-#include "util.h"
+#include "uudecode.h"
 
 /* aaaack but it's fast and const should make it shared text page. */
 const int pr2six[256] = {
index 8de597ab86534dfb0a3aa31a4f71c4a9a3375c20..d4490a3a01f9debc5f2d3572d5c8edb15033b064 100644 (file)
@@ -1,5 +1,5 @@
 #include "config.h"
-#include "profiling.h"
+#include "profiler/Profiler.h"
 #include "xusleep.h"
 
 #if HAVE_UNISTD_H
index 9c56c957afcc42ac777ac630de66a9b09382d52a..cad1cc31e046b4dfa71223d880b51f79dbddc305 100644 (file)
@@ -74,7 +74,9 @@ SOFTWARE.
 #if HAVE_ASSERT_H
 #include <assert.h>
 #endif
-
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
 
 #include "asn1.h"
 #include "snmp_vars.h"
index 9e71907d9adef0de5472f665012e7710adf37a5e..036d501c9c8ecac804f816d915a4f6beb0a43fb9 100644 (file)
@@ -16,6 +16,7 @@ TESTS =
 INCLUDES = \
        -I$(top_srcdir) \
        -I$(top_srcdir)/include \
+       -I$(top_srcdir)/lib \
        -I$(top_srcdir)/src \
        -I$(top_builddir)/include \
        $(SQUID_CPPUNIT_INC)
@@ -34,11 +35,15 @@ endif
 ## XXX: Do we really need this? Does auto-dependency tracking work?
 $(OBJS): $(top_srcdir)/include/version.h $(top_builddir)/include/autoconf.h
 
+## Internal profiler is used even by some of the compat library stuff.
+if ENABLE_XPROF_STATS
+LIBPROFILER = $(top_builddir)/lib/profiler/libprofiler.la
+else
+LIBPROFILER=
+endif
+
 ## 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 $(LIBPROFILER)
 
 ## 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)
index 79073ab108e1819f72151b43dcd8bca1edda1e5a..484fe459457e0f8aae8b5df11201c3e38f96b945 100644 (file)
@@ -63,6 +63,8 @@
 
 /* context-based debugging, the actual type is subject to change */
 typedef int Ctx;
+extern Ctx ctx_enter(const char *descr);
+extern void ctx_exit(Ctx ctx);
 
 /* defined debug section limits */
 #define MAX_DEBUG_SECTIONS 100
@@ -141,6 +143,9 @@ inline std::ostream& operator <<(std::ostream &os, const uint8_t d)
 #define old_debug(SECTION, LEVEL)  if( (Debug::level=(LEVEL)) <= Debug::Levels[SECTION] ) _db_print
 
 /* Legacy debug function definitions */
-SQUIDCEXTERN void _db_print(const char *,...) PRINTF_FORMAT_ARG1;
+extern void _db_init(const char *logfile, const char *options);
+extern void _db_print(const char *,...) PRINTF_FORMAT_ARG1;
+extern void _db_set_syslog(const char *facility);
+extern void _db_rotate_log(void);
 
 #endif /* SQUID_DEBUG_H */
index c2fa9904af5bbd78c3424800283d0fff99acab8a..057ac4af362f2de82b83cc6e6f1d0c5dc3fe6738 100644 (file)
  */
 
 #include "squid.h"
+#include "base64.h"
 #include "HttpHdrContRange.h"
 #include "HttpHdrSc.h"
 #include "HttpHeader.h"
 #include "MemBuf.h"
 #include "mgr/Registration.h"
+#include "rfc1123.h"
 #include "Store.h"
 
 /*
index eef3d09d50dde113199d6358649a061a600627ce..495c95d1f5b0bd01e41131b35e9a5c025fdd595a 100644 (file)
@@ -567,13 +567,16 @@ squid_LDADD = \
        $(SNMPLIB) \
        ${ADAPTATION_LIBS} \
        $(ESI_LIBS) \
-       $(COMPAT_LIB) \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
        $(SSLLIB) \
        $(EPOLL_LIBS) \
        $(MINGW_LIBS) \
        $(KRB5LIBS) \
+       $(COMPAT_LIB) \
        $(XTRA_LIBS)
-squid_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
+squid_DEPENDENCIES = \
        $(DISK_LIBS) \
        $(DISK_LINKOBJS) \
        $(REPL_OBJS) \
@@ -597,10 +600,9 @@ endif
 INCLUDES += $(KRB5INCS)
 
 
-unlinkd_SOURCES = unlinkd_daemon.cc SquidNew.cc
-
-dnsserver_SOURCES = dnsserver.cc SquidNew.cc test_tools.cc time.cc
-recv_announce_SOURCES = recv-announce.cc SquidNew.cc
+unlinkd_SOURCES = unlinkd_daemon.cc
+dnsserver_SOURCES = dnsserver.cc SquidNew.cc tests/stub_debug.cc test_tools.cc time.cc
+recv_announce_SOURCES = recv-announce.cc
 
 ## What requires what..
 ## many things want ACLChecklist.cc
@@ -666,7 +668,7 @@ ufsdump_LDADD = \
        $(EPOLL_LIBS) \
        $(MINGW_LIBS) \
        $(XTRA_LIBS)
-ufsdump_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
+ufsdump_DEPENDENCIES = \
        $(COMMON_LIBS) \
        $(DISK_LIBS) \
        $(DISK_LINKOBJS) \
@@ -684,7 +686,6 @@ data_DATA = \
        mib.txt
 
 LDADD = $(COMMON_LIBS) \
-       -L../lib -lmiscutil \
        $(EPOLL_LIBS) \
        $(MINGW_LIBS) \
        $(COMPAT_LIB) \
@@ -745,7 +746,12 @@ libDiskThreads_a_SOURCES = \
 
 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 = \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
+       $(COMPAT_LIB) \
+       $(XTRA_LIBS)
 
 
 DEFAULT_HTTP_PORT      = 3128
@@ -938,10 +944,8 @@ TESTS += $(check_PROGRAMS)
 #tests_testX_LDADD=\
 #      $(SQUID_CPPUNIT_LIBS) \
 #      $(SQUID_CPPUNIT_LA) \
-#      -L../lib -lmiscutil
 #      $(COMPAT_LIB) \
-#tests_testX_DEPENDENCIES= $(SQUID_CPPUNIT_LA) \
-#      $(top_builddir)/lib/libmiscutil.a
+#tests_testX_DEPENDENCIES= $(SQUID_CPPUNIT_LA)
 
 
 # - add other component .(h|cc) files needed to link and run tests
@@ -980,6 +984,7 @@ tests_testHttpReply_SOURCES=\
        Packer.h \
        Packer.cc \
        tests/stub_cache_manager.cc \
+       tests/stub_debug.cc \
        tests/stub_HelperChildConfig.cc \
        tests/stub_StatHist.cc \
        tests/stub_store.cc \
@@ -996,12 +1001,13 @@ tests_testHttpReply_LDADD=\
        auth/libauth.la \
        ip/libip.la \
        base/libbase.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
        $(SQUID_CPPUNIT_LIBS) \
        $(SQUID_CPPUNIT_LA) \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
-tests_testHttpReply_DEPENDENCIES= $(SQUID_CPPUNIT_LA) \
-       $(top_builddir)/lib/libmiscutil.a
+tests_testHttpReply_DEPENDENCIES= $(SQUID_CPPUNIT_LA)
 
 tests_testAuth_SOURCES = \
        tests/testAuth.cc tests/testMain.cc  tests/testAuth.h \
@@ -1009,6 +1015,7 @@ tests_testAuth_SOURCES = \
        HelperChildConfig.h \
        HelperChildConfig.cc \
        tests/stub_acl.cc tests/stub_cache_cf.cc \
+       tests/stub_debug.cc \
        tests/stub_helper.cc cbdata.cc String.cc \
        tests/stub_store.cc HttpHeaderTools.cc HttpHeader.cc mem.cc ClientInfo.h \
        MemBuf.cc HttpHdrContRange.cc Packer.cc HttpHdrCc.cc HttpHdrSc.cc \
@@ -1028,23 +1035,21 @@ tests_testAuth_SOURCES = \
        URLScheme.cc \
        $(TEST_CALL_SOURCES) \
        wordlist.cc
-##     acl.cc cache_cf.cc tools.cc \
-##     helper.cc String.cc cbdata.cc HttpHeaderTools.cc store.cc cache_manager.cc \
-##     HttpHeader.cc url.cc mem.cc HttpRequest.cc Packer.cc \
-##     MemBuf.cc StatHist.cc
 nodist_tests_testAuth_SOURCES = \
        $(TESTSOURCES)
 
 tests_testAuth_LDADD= \
        $(COMMON_LIBS) \
-       -L../lib -lmiscutil \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
        $(REGEXLIB) \
        $(SQUID_CPPUNIT_LIBS) \
        $(SSLLIB) \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testAuth_LDFLAGS = $(LIBADD_DL)
-tests_testAuth_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
+tests_testAuth_DEPENDENCIES = \
        $(SQUID_CPPUNIT_LA)
 
 ## Tests for the ACLMaxUserIP class
@@ -1088,6 +1093,7 @@ tests_testACLMaxUserIP_SOURCES= \
        $(TEST_CALL_SOURCES) \
        tests/stub_cache_cf.cc \
        tests/stub_comm.cc \
+       tests/stub_debug.cc \
        tests/stub_DelayId.cc \
        tests/stub_MemObject.cc \
        tests/stub_store.cc \
@@ -1103,7 +1109,9 @@ nodist_tests_testACLMaxUserIP_SOURCES= \
        $(TESTSOURCES)
 tests_testACLMaxUserIP_LDADD= \
        $(COMMON_LIBS) \
-       -L../lib -lmiscutil \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
        $(REGEXLIB) \
        $(SQUID_CPPUNIT_LIBS) \
        $(SSLLIB) \
@@ -1123,7 +1131,6 @@ tests_testBoilerplate_SOURCES = \
 nodist_tests_testBoilerplate_SOURCES = \
        $(TESTSOURCES)
 tests_testBoilerplate_LDADD= \
-       -L../lib -lmiscutil \
        $(SQUID_CPPUNIT_LIBS) \
        $(SSLLIB) \
        $(COMPAT_LIB) \
@@ -1278,9 +1285,11 @@ tests_testCacheManager_LDADD = \
        $(REPL_OBJS) \
        ${ADAPTATION_LIBS} \
        $(ESI_LIBS) \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
        $(REGEXLIB) \
        $(SNMPLIB) \
-       -L../lib -lmiscutil \
        $(SQUID_CPPUNIT_LIBS) \
        $(SQUID_CPPUNIT_LA) \
        $(SSLLIB) \
@@ -1288,7 +1297,7 @@ tests_testCacheManager_LDADD = \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testCacheManager_LDFLAGS = $(LIBADD_DL)
-tests_testCacheManager_DEPENDENCIES =  $(top_builddir)/lib/libmiscutil.a \
+tests_testCacheManager_DEPENDENCIES = \
        $(REPL_OBJS) \
        $(SQUID_CPPUNIT_LA)
 
@@ -1308,17 +1317,25 @@ nodist_tests_testDiskIO_SOURCES= \
        SquidMath.h \
        swap_log_op.cc
 tests_testDiskIO_LDADD = \
-       $(SWAP_TEST_LDADD) \
-       $(DISK_LIBS) \
-       $(DISK_OS_LIBS) \
-       $(COMMON_LIBS) \
        SquidConfig.o \
        CommCalls.o \
        DnsLookupDetails.o \
+       $(COMMON_LIBS) \
+       $(REPL_OBJS) \
+       $(DISK_LIBS) \
+       $(DISK_OS_LIBS) \
+       acl/libapi.la \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
+       $(REGEXLIB) \
+       $(SQUID_CPPUNIT_LIBS) \
+       $(SSLLIB) \
+       $(COMPAT_LIB) \
        $(XTRA_LIBS)
 
 tests_testDiskIO_LDFLAGS = $(LIBADD_DL)
-tests_testDiskIO_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
+tests_testDiskIO_DEPENDENCIES = \
        $(DISK_LIBS) \
        $(SWAP_TEST_DS) \
        $(SQUID_CPPUNIT_LA)
@@ -1471,9 +1488,11 @@ tests_testEvent_LDADD = \
        $(REPL_OBJS) \
        ${ADAPTATION_LIBS} \
        $(ESI_LIBS) \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
        $(REGEXLIB) \
        $(SNMPLIB) \
-       -L../lib -lmiscutil \
        $(SQUID_CPPUNIT_LIBS) \
        $(SQUID_CPPUNIT_LA) \
        $(SSLLIB) \
@@ -1481,7 +1500,7 @@ tests_testEvent_LDADD = \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testEvent_LDFLAGS = $(LIBADD_DL)
-tests_testEvent_DEPENDENCIES =  $(top_builddir)/lib/libmiscutil.a \
+tests_testEvent_DEPENDENCIES = \
        $(REPL_OBJS) \
        $(SQUID_CPPUNIT_LA)
 
@@ -1632,9 +1651,11 @@ tests_testEventLoop_LDADD = \
        $(REPL_OBJS) \
        ${ADAPTATION_LIBS} \
        $(ESI_LIBS) \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
        $(REGEXLIB) \
        $(SNMPLIB) \
-       -L../lib -lmiscutil \
        $(SQUID_CPPUNIT_LIBS) \
        $(SQUID_CPPUNIT_LA) \
        $(SSLLIB) \
@@ -1642,7 +1663,7 @@ tests_testEventLoop_LDADD = \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testEventLoop_LDFLAGS = $(LIBADD_DL)
-tests_testEventLoop_DEPENDENCIES =  $(top_builddir)/lib/libmiscutil.a \
+tests_testEventLoop_DEPENDENCIES = \
        $(REPL_OBJS) \
        $(SQUID_CPPUNIT_LA)
 
@@ -1788,9 +1809,11 @@ tests_test_http_range_LDADD = \
        $(REPL_OBJS) \
        ${ADAPTATION_LIBS} \
        $(ESI_LIBS) \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
        $(REGEXLIB) \
        $(SNMPLIB) \
-       -L../lib -lmiscutil \
        $(SQUID_CPPUNIT_LIBS) \
        $(SQUID_CPPUNIT_LA) \
        $(SSLLIB) \
@@ -1805,7 +1828,6 @@ tests_test_http_range_DEPENDENCIES = \
 ## Tests of the HttpRequest module.
 tests_testHttpRequest_SOURCES = \
        $(ACL_REGISTRATION_SOURCES) \
-       debug.cc \
        HttpRequest.cc \
        HttpRequestMethod.cc \
        mem.cc \
@@ -1820,6 +1842,7 @@ tests_testHttpRequest_SOURCES = \
        BodyPipe.cc \
        cache_manager.cc \
        cache_cf.cc \
+       debug.cc \
        ProtoPort.cc \
        ProtoPort.h \
        CacheDigest.cc \
@@ -1949,9 +1972,11 @@ tests_testHttpRequest_LDADD = \
        $(REPL_OBJS) \
        ${ADAPTATION_LIBS} \
        $(ESI_LIBS) \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
        $(REGEXLIB) \
        $(SNMPLIB) \
-       -L../lib -lmiscutil \
        $(SQUID_CPPUNIT_LIBS) \
        $(SQUID_CPPUNIT_LA) \
        $(SSLLIB) \
@@ -1959,7 +1984,7 @@ tests_testHttpRequest_LDADD = \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testHttpRequest_LDFLAGS = $(LIBADD_DL)
-tests_testHttpRequest_DEPENDENCIES =  $(top_builddir)/lib/libmiscutil.a \
+tests_testHttpRequest_DEPENDENCIES = \
        $(REPL_OBJS) \
        $(SQUID_CPPUNIT_LA)
 
@@ -1984,6 +2009,7 @@ STORE_TEST_SOURCES=\
        tests/stub_acl.cc tests/stub_cache_cf.cc \
        tests/stub_helper.cc cbdata.cc String.cc \
        tests/stub_comm.cc \
+       tests/stub_debug.cc \
        tests/stub_client_side_request.cc \
        tests/stub_http.cc \
        mem_node.cc \
@@ -2037,7 +2063,9 @@ nodist_tests_testStore_SOURCES= \
 
 tests_testStore_LDADD= \
        $(COMMON_LIBS) \
-       -L../lib -lmiscutil \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
        $(REGEXLIB) \
        $(SQUID_CPPUNIT_LIBS) \
        $(SSLLIB) \
@@ -2046,7 +2074,7 @@ tests_testStore_LDADD= \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testStore_LDFLAGS = $(LIBADD_DL)
-tests_testStore_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
+tests_testStore_DEPENDENCIES = \
        $(SQUID_CPPUNIT_LA)
 
 ## string needs mem.cc.
@@ -2060,20 +2088,21 @@ tests_testString_SOURCES = \
        tests/testString.cc \
        tests/testString.h \
        tests/stub_cache_manager.cc \
+       tests/stub_debug.cc \
        tests/stub_HelperChildConfig.cc \
        time.cc
 nodist_tests_testString_SOURCES = \
        $(TESTSOURCES)
 tests_testString_LDADD = \
        $(COMMON_LIBS) \
-       -L../lib -lmiscutil \
+       $(top_builddir)/lib/libmiscutil.la \
        $(REGEXLIB) \
        $(SQUID_CPPUNIT_LIBS) \
        $(SSLLIB) \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testString_LDFLAGS = $(LIBADD_DL)
-tests_testString_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
+tests_testString_DEPENDENCIES = \
        $(SQUID_CPPUNIT_LA)
 
 SWAP_TEST_SOURCES = \
@@ -2111,19 +2140,7 @@ SWAP_TEST_GEN_SOURCES = \
        $(TESTSOURCES) \
        $(DISKIO_GEN_SOURCE)
 
-SWAP_TEST_LDADD = \
-       $(REGEXLIB) \
-       $(COMMON_LIBS) \
-       $(REPL_OBJS) \
-       $(DISK_LIBS) \
-       $(DISK_OS_LIBS) \
-       -L../lib -lmiscutil \
-       acl/libapi.la \
-       $(SQUID_CPPUNIT_LIBS) \
-       $(COMPAT_LIB) \
-       $(XTRA_LIBS)
 SWAP_TEST_DS =\
-       $(top_builddir)/lib/libmiscutil.a \
        repl_modules.o \
        $(DISK_LIBS) \
        $(COMMON_LIBS) \
@@ -2146,11 +2163,20 @@ nodist_tests_testUfs_SOURCES = \
        SquidMath.h \
        swap_log_op.cc
 tests_testUfs_LDADD = \
-       $(SWAP_TEST_LDADD) \
-       $(COMMON_LIBS) \
-       $(SSLLIB) \
        CommCalls.o \
        DnsLookupDetails.o \
+       $(COMMON_LIBS) \
+       $(REPL_OBJS) \
+       $(DISK_LIBS) \
+       $(DISK_OS_LIBS) \
+       acl/libapi.la \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
+       $(REGEXLIB) \
+       $(SQUID_CPPUNIT_LIBS) \
+       $(SSLLIB) \
+       $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testUfs_LDFLAGS = $(LIBADD_DL)
 tests_testUfs_DEPENDENCIES = \
@@ -2161,6 +2187,7 @@ tests_testCoss_SOURCES = \
        tests/testMain.cc \
        tests/testCoss.h \
        tests/stub_cache_manager.cc \
+       tests/stub_debug.cc \
        tests/stub_HelperChildConfig.cc \
        $(SWAP_TEST_SOURCES)
 nodist_tests_testCoss_SOURCES = \
@@ -2170,8 +2197,18 @@ nodist_tests_testCoss_SOURCES = \
        $(SWAP_TEST_GEN_SOURCES)
 tests_testCoss_LDADD = \
        libsquid.la \
-       $(SWAP_TEST_LDADD) \
+       $(REGEXLIB) \
+       $(COMMON_LIBS) \
+       $(REPL_OBJS) \
+       $(DISK_LIBS) \
+       $(DISK_OS_LIBS) \
+       acl/libapi.la \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
+       $(SQUID_CPPUNIT_LIBS) \
        $(SSLLIB) \
+       $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testCoss_LDFLAGS = $(LIBADD_DL)
 tests_testCoss_DEPENDENCIES = \
@@ -2185,8 +2222,18 @@ tests_testNull_SOURCES = \
 nodist_tests_testNull_SOURCES = \
        $(SWAP_TEST_GEN_SOURCES)
 tests_testNull_LDADD = \
-       $(SWAP_TEST_LDADD) \
+       $(REGEXLIB) \
+       $(COMMON_LIBS) \
+       $(REPL_OBJS) \
+       $(DISK_LIBS) \
+       $(DISK_OS_LIBS) \
+       acl/libapi.la \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
+       $(SQUID_CPPUNIT_LIBS) \
        $(SSLLIB) \
+       $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testNull_LDFLAGS = $(LIBADD_DL)
 tests_testNull_DEPENDENCIES = \
@@ -2196,7 +2243,6 @@ tests_testNull_DEPENDENCIES = \
 ## TODO: Trim this down once the insanity is over.
 tests_testURL_SOURCES = \
        $(ACL_REGISTRATION_SOURCES) \
-       debug.cc \
        url.cc \
        URLScheme.cc \
        HttpRequest.cc \
@@ -2209,6 +2255,7 @@ tests_testURL_SOURCES = \
        tests/testURLScheme.cc \
        tests/testURLScheme.h \
        tests/testMain.cc \
+       tests/stub_debug.cc \
        tests/stub_main_cc.cc \
        time.cc \
        BodyPipe.cc \
@@ -2342,7 +2389,10 @@ tests_testURL_LDADD = \
        ${ADAPTATION_LIBS} \
        $(ESI_LIBS) \
        $(SNMPLIB) \
-       -L../lib -lmiscutil \
+       $(top_builddir)/lib/libmisccontainers.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
+       $(COMPAT_LIB) \
        $(SQUID_CPPUNIT_LIBS) \
        $(SQUID_CPPUNIT_LA) \
        $(SSLLIB) \
@@ -2350,7 +2400,7 @@ tests_testURL_LDADD = \
        $(COMPAT_LIB) \
        $(XTRA_LIBS)
 tests_testURL_LDFLAGS = $(LIBADD_DL)
-tests_testURL_DEPENDENCIES =  $(top_builddir)/lib/libmiscutil.a \
+tests_testURL_DEPENDENCIES = \
        $(REPL_OBJS) \
        $(SQUID_CPPUNIT_LA)
 
index 411bcfd072ca1e5c3793c29a7b3e15e64477034f..4decb63abe932df2c9c46ea8f71917b557efd00b 100644 (file)
@@ -33,6 +33,7 @@
 #define   SQUID_TIME_H
 
 #include "config.h"
+#include "rfc1123.h"
 
 #if HAVE_TIME_H
 #include <time.h>
 /* globals for accessing time */
 extern struct timeval current_time;
 extern double current_dtime;
-
-extern time_t squid_curtime;   /* 0 */
+extern time_t squid_curtime;
 
 time_t getCurrentTime(void);
+int tvSubMsec(struct timeval, struct timeval);
 
 /** event class for doing synthetic time etc */
 class TimeEngine
index d1c9f9d77f851da853e979aa656b638a9b2fe8e5..8e679921f95c5bc6a89cf487cbeec4b30da78ed6 100644 (file)
@@ -14,6 +14,7 @@
 #include "adaptation/Initiator.h"
 #include "auth/UserRequest.h"
 #include "base/TextException.h"
+#include "base64.h"
 #include "ChunkedCodingParser.h"
 #include "comm.h"
 #include "HttpMsg.h"
index f7d31b38450c70a3dfca460cd41490542b2d7d10..865e6fc08a6da3a5b75bdc166ce35ca25642c9bd 100644 (file)
 
 #include "config.h"
 
-/* for xstrdup() */
-#include "util.h"
-/* for safe_free() */
-#include "defines.h"
-
 char const *
 AuthUser::username () const
 {
index ba00233ab4b9df6605872d642ce30fa50850ce77..a01f45487a176ba0ac0de27a052dfe10c6044cb6 100644 (file)
@@ -122,7 +122,7 @@ private:
      * The username_ memory will be allocated via
      * xstrdup().  It is our responsibility.
      */
-    char const *username_;
+    const char *username_;
 
     /** what ip addresses has this user been seen at?, plus a list length cache */
     dlink_list ip_list;
index 1c40a97844651f45a5f8cb5dd9ce437b210468d3..414518d59c16afb87832b9e9caf729de08279c0b 100644 (file)
 #include "auth/basic/basicUserRequest.h"
 #include "auth/Gadgets.h"
 #include "auth/State.h"
+#include "charset.h"
 #include "mgr/Registration.h"
 #include "Store.h"
 #include "HttpReply.h"
 #include "rfc1738.h"
+#include "uudecode.h"
 #include "wordlist.h"
 #include "SquidTime.h"
 
index 90ed714b99658b231cdb2b96acb94631eda58dbf..c6ff1b3a1eaded7edd773e4e2e86be0fe2f9ee93 100644 (file)
@@ -41,6 +41,7 @@
 #include "rfc2617.h"
 #include "auth/digest/auth_digest.h"
 #include "auth/Gadgets.h"
+#include "base64.h"
 #include "event.h"
 #include "mgr/Registration.h"
 #include "Store.h"
index 0816f98743eaaa637f33ac6700b354f6914c3db9..d7d9d8fa4e7757d27e74b8891e73d350725f700c 100644 (file)
@@ -2,6 +2,7 @@
 #include "auth/digest/auth_digest.h"
 #include "auth/digest/digestUserRequest.h"
 #include "auth/State.h"
+#include "charset.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
 #include "SquidTime.h"
index f6ddba52736956079a93d588260966dc2b81272f..180b30151b7b6df4c8890d718dd7de7802f931f5 100644 (file)
@@ -2152,8 +2152,8 @@ ClientInfo::setWriteLimiter(const int aWriteSpeedLimit, const double anInitialBu
 
         assert(!selectWaiting);
         assert(!quotaQueue);
-        quotaQueue = new CommQuotaQueue(this);
-        cbdataReference(quotaQueue);
+        CommQuotaQueue *tmp = new CommQuotaQueue(this);
+        quotaQueue = cbdataReference(tmp);
 
         bucketSize = anInitialBurst;
         prevTime = current_dtime;
index a6ac3eeaecdb0f213ebe7b497392e5caa702cc69..1496edf250c77948353d1f5bbf3cc370c4e94205 100644 (file)
@@ -68,8 +68,6 @@
 #define COMM_TRANSPARENT       0x08
 #define COMM_DOBIND            0x10
 
-#define safe_free(x)   if (x) { xxfree(x); x = NULL; }
-
 #define DISK_OK                   (0)
 #define DISK_ERROR               (-1)
 #define DISK_EOF                 (-2)
 #define URI_WHITESPACE_CHOP 3
 #define URI_WHITESPACE_DENY 4
 
-#ifndef _PATH_DEVNULL
-#ifdef _SQUID_MSWIN_
-#define _PATH_DEVNULL "NUL"
-#else
-#define _PATH_DEVNULL "/dev/null"
-#endif
-#endif
-
 #ifndef O_TEXT
 #define O_TEXT 0
 #endif
index 6094bb612428ed1d21abc6441612328127e816c4..88120f1d70a17fb908fc90e986d674e9a20402e9 100644 (file)
@@ -6,8 +6,6 @@
 
 /* dlink are Mem-pooled */
 #include "MemPool.h"
-/* for xstrdup() */
-#include "util.h"
 
 
 dlink_list ClientActiveRequests;
index 4cde6f0ec5aa33747decf68f13620310d68df356..62051389558a2c94586812535e8c07922414fd39 100644 (file)
  */
 
 #include "config.h"
-#include "compat/inet_ntop.h"
-#include "compat/getaddrinfo.h"
-#include "compat/getnameinfo.h"
+//#include "compat/inet_ntop.h"
+//#include "compat/getaddrinfo.h"
+//#include "compat/getnameinfo.h"
+#include "ip/Address.h"
+//#include "util.h"
 
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #include <resolv.h>
 #endif
 
-#include "util.h"
-
 /**
  \defgroup dnsserver dnsserver
  \ingroup ExternalPrograms
@@ -150,8 +150,6 @@ usage: dnsserver -Dhv -s nameserver
  \endverbatim
  */
 
-#include "ip/Address.h"
-
 #if LIBRESOLV_DNS_TTL_HACK
 /// \ingroup dnsserver
 extern int _dns_ttl_;          /* this is a really *dirty* hack - bne */
index feec181c4a2a8143c337e1423bfb41d493c4313c..cc8acc96883758f557780df1447ffb1c8f286594 100644 (file)
@@ -37,6 +37,7 @@
 #include "auth/UserRequest.h"
 #include "SquidTime.h"
 #include "Store.h"
+#include "html_quote.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
 #include "MemObject.h"
index 9a0e61e97b1777228191d82a219e05b6a29e943b..8973d26624da95df32ffd117ea55113f323ced6c 100644 (file)
@@ -40,6 +40,7 @@
 #include "errorpage.h"
 #include "fde.h"
 #include "forward.h"
+#include "html_quote.h"
 #include "HttpHdrContRange.h"
 #include "HttpHeaderRange.h"
 #include "HttpHeader.h"
index 6b47c0afdde34d120d9097e7822bf2490a5bc06e..26e232a268d30174ce1f2e0941b334f92f0e66f1 100644 (file)
@@ -36,6 +36,7 @@
 #include "squid.h"
 #include "errorpage.h"
 #include "Store.h"
+#include "html_quote.h"
 #include "HttpRequest.h"
 #include "HttpReply.h"
 #include "comm.h"
index 59cef61db4a9754a4fbac1c125203a4b5a8c73f7..37f8996f3a1edc6aaac7571ab96cc3219e9d9ff9 100644 (file)
@@ -44,6 +44,7 @@
 #include "auth/UserRequest.h"
 #include "base/AsyncJobCalls.h"
 #include "base/TextException.h"
+#include "base64.h"
 #if DELAY_POOLS
 #include "DelayPools.h"
 #endif
index b637923da684b3253ed022910b54b882c3b69d1d..bbc76b59e883639af738bf5fbf9829f1976eed77 100644 (file)
@@ -1,4 +1,3 @@
-
 include $(top_srcdir)/src/Common.am
 include $(top_srcdir)/src/TestHeaders.am
 
@@ -7,7 +6,6 @@ include $(top_srcdir)/src/TestHeaders.am
 DEFS += -DDEFAULT_CONFIG_FILE=NULL
 
 
-
 # ICMP Specific Configurations
 
 if ENABLE_PINGER
@@ -62,12 +60,8 @@ pinger_LDFLAGS = $(LIBADD_DL)
 pinger_LDADD=\
        libicmp-core.la \
        ../ip/libip.la \
-       $(XTRA_LIBS) \
-       $(top_builddir)/lib/libmiscutil.a
-pinger_DEPENDENCIES= \
-       libicmp-core.la \
-       $(top_builddir)/lib/libmiscutil.a
-
+       $(COMPAT_LIB) \
+       $(XTRA_LIBS)
 
 
 ##install-pinger:
@@ -96,6 +90,7 @@ testIcmp_SOURCES = \
 nodist_testIcmp_SOURCES = \
        $(top_srcdir)/src/tests/testMain.cc \
        $(top_srcdir)/src/SquidTime.h \
+       $(top_srcdir)/src/tests/stub_debug.cc \
        $(top_srcdir)/src/time.cc \
        $(top_srcdir)/test-suite/test_tools.cc \
        $(top_builddir)/src/globals.cc
@@ -105,8 +100,6 @@ testIcmp_LDADD=\
        $(SQUID_CPPUNIT_LA) \
        libicmp-core.la \
        ../ip/libip.la \
-       $(XTRA_LIBS) \
-       $(top_builddir)/lib/libmiscutil.a
-testIcmp_DEPENDENCIES= $(SQUID_CPPUNIT_LA) \
-       libicmp-core.la \
-       $(top_builddir)/lib/libmiscutil.a
+       $(COMPAT_LIB) \
+       $(XTRA_LIBS)
+testIcmp_DEPENDENCIES= $(SQUID_CPPUNIT_LA)
index 989f29d2911173b575bc798d52b894d789665c26..17b8823e191466d95fae5ede50e2b7ea72cda00b 100644 (file)
@@ -23,6 +23,7 @@ testIpAddress_SOURCES= \
        testAddress.cc \
        testAddress.h
 nodist_testIpAddress_SOURCES= \
+       $(top_srcdir)/src/tests/stub_debug.cc \
        $(top_srcdir)/src/tests/testMain.cc \
        $(top_srcdir)/test-suite/test_tools.cc
 testIpAddress_LDADD= \
index e8bc8b0d4ee0d9972050bed3f1d068a4bae0a3a5..182474ed60ba5c2f1de5db2fc3e83d58b74571fe 100644 (file)
 #if USE_ADAPTATION
 #include "adaptation/Config.h"
 #endif
-
 #if USE_SQUID_ESI
 #include "esi/Module.h"
 #endif
-
 #include "fs/Module.h"
 
-#if USE_WIN32_SERVICE
+#if HAVE_PATHS_H
+#include <paths.h>
+#endif
 
+#if USE_WIN32_SERVICE
 #include "squid_windows.h"
 #include <process.h>
 
index 9b71b3d4968a8e004c70c0975c2590d9d6b80c9a..c78891c23ffeea7e89d5963e1244483ce7a1f2cf 100644 (file)
@@ -104,14 +104,6 @@ extern void clientAccessCheck(void *);
 
 #include "Debug.h"
 
-/* see debug.c for info on context-based debugging */
-SQUIDCEXTERN Ctx ctx_enter(const char *descr);
-SQUIDCEXTERN void ctx_exit(Ctx ctx);
-
-SQUIDCEXTERN void _db_set_syslog(const char *facility);
-SQUIDCEXTERN void _db_init(const char *logfile, const char *options);
-SQUIDCEXTERN void _db_rotate_log(void);
-
 /* packs, then prints an object using debugs() */
 SQUIDCEXTERN void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm);
 
index 4cdda62bb7c2fb1dd3006a1574e9629e1e47e1aa..81cba215cefeb9dfa7d2f4052ca152323296874a 100644 (file)
@@ -166,7 +166,7 @@ using namespace Squid;
 #include "enums.h"
 #include "typedefs.h"
 #include "util.h"
-#include "profiling.h"
+#include "profiler/Profiler.h"
 #include "MemPool.h"
 #include "ip/Address.h"
 #include "structs.h"
diff --git a/src/tests/stub_debug.cc b/src/tests/stub_debug.cc
new file mode 100644 (file)
index 0000000..556d3b4
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * A stub implementation of the Debug.h API.
+ * For use by test binaries which do not need the full context debugging
+ */
+#include "config.h"
+#include "Debug.h"
+
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+
+FILE *debug_log = NULL;
+int Debug::TheDepth = 0;
+
+char *Debug::debugOptions;
+char *Debug::cache_log= NULL;
+int Debug::rotateNumber = 0;
+int Debug::Levels[MAX_DEBUG_SECTIONS];
+int Debug::level;
+int Debug::override_X = 0;
+int Debug::log_stderr = 1;
+bool Debug::log_syslog = false;
+
+Ctx
+ctx_enter(const char *descr)
+{
+    return -1;
+}
+
+void
+ctx_exit(Ctx ctx)
+{
+}
+
+void
+_db_init(const char *logfile, const char *options)
+{}
+
+void
+_db_set_syslog(const char *facility)
+{}
+
+void
+_db_rotate_log(void)
+{}
+
+static void
+_db_print_stderr(const char *format, va_list args);
+
+void
+_db_print(const char *format,...)
+{
+    static char f[BUFSIZ];
+    va_list args1;
+    va_list args2;
+    va_list args3;
+
+    va_start(args1, format);
+    va_start(args2, format);
+    va_start(args3, format);
+
+    snprintf(f, BUFSIZ, "%s| %s",
+             "stub time", //debugLogTime(squid_curtime),
+             format);
+
+    _db_print_stderr(f, args2);
+
+    va_end(args1);
+    va_end(args2);
+    va_end(args3);
+}
+
+static void
+_db_print_stderr(const char *format, va_list args)
+{
+    /* FIXME? */
+    // if (opt_debug_stderr < Debug::level)
+
+    if (1 < Debug::level)
+        return;
+
+    vfprintf(stderr, format, args);
+}
+
+std::ostream &
+Debug::getDebugOut()
+{
+    assert(TheDepth >= 0);
+    ++TheDepth;
+    if (TheDepth > 1) {
+        assert(CurrentDebug);
+        *CurrentDebug << std::endl << "reentrant debuging " << TheDepth << "-{";
+    } else {
+        assert(!CurrentDebug);
+        CurrentDebug = new std::ostringstream();
+        // set default formatting flags
+        CurrentDebug->setf(std::ios::fixed);
+        CurrentDebug->precision(2);
+    }
+    return *CurrentDebug;
+}
+
+void
+Debug::parseOptions(char const *)
+{
+    return;
+}
+
+void
+Debug::finishDebug()
+{
+    assert(TheDepth >= 0);
+    assert(CurrentDebug);
+    if (TheDepth > 1) {
+        *CurrentDebug << "}-" << TheDepth << std::endl;
+    } else {
+        assert(TheDepth == 1);
+        _db_print("%s\n", CurrentDebug->str().c_str());
+        delete CurrentDebug;
+        CurrentDebug = NULL;
+    }
+    --TheDepth;
+}
+
+void
+Debug::xassert(const char *msg, const char *file, int line)
+{
+
+    if (CurrentDebug) {
+        *CurrentDebug << "assertion failed: " << file << ":" << line <<
+        ": \"" << msg << "\"";
+    }
+    abort();
+}
+
+std::ostringstream *Debug::CurrentDebug (NULL);
+
+const char*
+SkipBuildPrefix(const char* path)
+{
+    return path;
+}
index 20cf69a9e2b809793bb4bb5132c957f5aa28b52a..064e514be3dbbd51d7f738e32b9b3eb9f7d53a5a 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
  *
  */
-
+#include "config.h"
 #include "SquidTime.h"
 
 struct timeval current_time;
 double current_dtime;
-
 time_t squid_curtime = 0;
 
 time_t
@@ -54,6 +53,13 @@ getCurrentTime(void)
     return squid_curtime = current_time.tv_sec;
 }
 
+int
+tvSubMsec(struct timeval t1, struct timeval t2)
+{
+    return (t2.tv_sec - t1.tv_sec) * 1000 +
+           (t2.tv_usec - t1.tv_usec) / 1000;
+} 
+
 TimeEngine::~TimeEngine()
 {}
 
index 8ad87dd08c093b156513c93e13e198c929b1bce2..292b036968e60f5aeece8268cf42bd56c63a67c6 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * $Id$
  *
 
 #define SQUID_HELPER 1
 
-#include "squid.h"
+#include "config.h"
+
+#if HAVE_PATHS_H
+#include <paths.h>
+#endif
 
 /**
  \defgroup unlinkd unlinkd
@@ -88,5 +91,5 @@ main(int argc, char *argv[])
             printf("OK\n");
     }
 
-    exit(0);
+    return 0;
 }
index 0a7bc208868c92d097d8e66847e0588a52b3f2bb..cedd9833ef59654fed5bfed5efb032bc6633ca28 100644 (file)
@@ -1,9 +1,3 @@
-#
-#  Makefile for the Squid Object Cache server
-#
-#  $Id$
-#
-
 include $(top_srcdir)/src/Common.am
 
 AUTOMAKE_OPTIONS = subdir-objects
@@ -12,9 +6,11 @@ AUTOMAKE_OPTIONS = subdir-objects
 INCLUDES += -I$(srcdir)
 
 LDADD = \
-       $(COMPAT_LIB) \
        $(top_builddir)/src/globals.o \
-       $(top_builddir)/src/time.o
+       $(top_builddir)/src/time.o \
+       $(top_builddir)/lib/libmiscutil.la \
+       $(COMPAT_LIB) \
+       $(XTRA_LIBS)
 
 EXTRA_PROGRAMS = mem_node_test membanger splay tcp-banger2
 
@@ -54,24 +50,42 @@ check_PROGRAMS += debug \
                VirtualDeleteOperator
 
 
-tcp_banger2_LDADD = -L$(top_builddir)/lib -lmiscutil
-DEBUG_SOURCE = test_tools.cc
+tcp_banger2_LDADD = $(top_builddir)/lib/libmiscutil.la
+
+
+DEBUG_SOURCE = test_tools.cc stub_debug.cc
+
+stub_debug.cc: $(top_srcdir)/src/tests/stub_debug.cc
+       cp $(top_srcdir)/src/tests/stub_debug.cc .
+
+CLEANFILES += stub_debug.cc
+
+## XXX: somewhat broken. Its meant to test our debugs() implementation.
+## but it has never been linked to the actual src/debug.cc implementation !!
+## all it tests are the stream operators and macro in src/Debug.h
 debug_SOURCES = debug.cc $(DEBUG_SOURCE)
+
 ESIExpressions_SOURCES = ESIExpressions.cc $(DEBUG_SOURCE)
 ESIExpressions_LDADD = $(top_builddir)/src/esi/Expression.o \
                $(LDADD)
+
 mem_node_test_SOURCES = mem_node_test.cc
 mem_node_test_LDADD = $(top_builddir)/src/mem_node.o $(LDADD)
+
 mem_hdr_test_SOURCES = mem_hdr_test.cc $(DEBUG_SOURCE)
 mem_hdr_test_LDADD = $(top_builddir)/src/stmem.o \
                     $(top_builddir)/src/mem_node.o $(LDADD)
+
 MemPoolTest_SOURCES = MemPoolTest.cc
+
 refcount_SOURCES = refcount.cc
 
 splay_SOURCES = splay.cc
 
 StackTest_SOURCES = StackTest.cc $(DEBUG_SOURCE)
+
 syntheticoperators_SOURCES = syntheticoperators.cc $(DEBUG_SOURCE)
+
 VirtualDeleteOperator_SOURCES = VirtualDeleteOperator.cc $(DEBUG_SOURCE)
 
 ## membanger won't link today. Bitrot..
index 0f6754acfea224fe32d3516bc4e1fb0c92605aa5..1f76733a1a0619faa5db867aa53df1648fa2c4ee 100644 (file)
@@ -2,19 +2,11 @@
  * $Id$
  */
 
-// XXX: This file is made of large pieces of src/debug.cc and src/tools.cc
+// XXX: This file is made of large pieces of src/tools.cc
 // with only a few minor modifications. TODO: redesign or delete.
 
 #include "squid.h"
 
-/* AYJ: the debug stuff here should really be in a stub_debug.cc file for tests to link */
-
-/* for correct pre-definitions of debug objects */
-/* and stream headers */
-#include "Debug.h"
-
-FILE *debug_log = NULL;
-
 void
 xassert(const char *msg, const char *file, int line)
 {
@@ -22,47 +14,6 @@ xassert(const char *msg, const char *file, int line)
     exit (1);
 }
 
-int Debug::Levels[MAX_DEBUG_SECTIONS];
-int Debug::level;
-
-static void
-_db_print_stderr(const char *format, va_list args);
-
-void
-_db_print(const char *format,...)
-{
-    LOCAL_ARRAY(char, f, BUFSIZ);
-    va_list args1;
-    va_list args2;
-    va_list args3;
-
-    va_start(args1, format);
-    va_start(args2, format);
-    va_start(args3, format);
-
-    snprintf(f, BUFSIZ, "%s| %s",
-             "stub time", //debugLogTime(squid_curtime),
-             format);
-
-    _db_print_stderr(f, args2);
-
-    va_end(args1);
-    va_end(args2);
-    va_end(args3);
-}
-
-static void
-_db_print_stderr(const char *format, va_list args)
-{
-    /* FIXME? */
-    // if (opt_debug_stderr < Debug::level)
-
-    if (1 < Debug::level)
-        return;
-
-    vfprintf(stderr, format, args);
-}
-
 void
 fatal_dump(const char *message)
 {
@@ -102,65 +53,10 @@ debug_trap(const char *message)
     fatal(message);
 }
 
-int Debug::TheDepth = 0;
-
-std::ostream &
-Debug::getDebugOut()
-{
-    assert(TheDepth >= 0);
-    ++TheDepth;
-    if (TheDepth > 1) {
-        assert(CurrentDebug);
-        *CurrentDebug << std::endl << "reentrant debuging " << TheDepth << "-{";
-    } else {
-        assert(!CurrentDebug);
-        CurrentDebug = new std::ostringstream();
-        // set default formatting flags
-        CurrentDebug->setf(std::ios::fixed);
-        CurrentDebug->precision(2);
-    }
-    return *CurrentDebug;
-}
-
-void
-Debug::finishDebug()
-{
-    assert(TheDepth >= 0);
-    assert(CurrentDebug);
-    if (TheDepth > 1) {
-        *CurrentDebug << "}-" << TheDepth << std::endl;
-    } else {
-        assert(TheDepth == 1);
-        _db_print("%s\n", CurrentDebug->str().c_str());
-        delete CurrentDebug;
-        CurrentDebug = NULL;
-    }
-    --TheDepth;
-}
-
-void
-Debug::xassert(const char *msg, const char *file, int line)
-{
-
-    if (CurrentDebug) {
-        *CurrentDebug << "assertion failed: " << file << ":" << line <<
-        ": \"" << msg << "\"";
-    }
-    abort();
-}
-
-std::ostringstream *Debug::CurrentDebug(NULL);
-
-MemAllocator *dlink_node_pool = NULL;
-
 dlink_node *
 dlinkNodeNew()
 {
-    if (dlink_node_pool == NULL)
-        dlink_node_pool = memPoolCreate("Dlink list nodes", sizeof(dlink_node));
-
-    /* where should we call memPoolDestroy(dlink_node_pool); */
-    return static_cast<dlink_node *>(dlink_node_pool->alloc());
+    return new dlink_node;
 }
 
 /* the node needs to be unlinked FIRST */
@@ -170,7 +66,7 @@ dlinkNodeDelete(dlink_node * m)
     if (m == NULL)
         return;
 
-    dlink_node_pool->freeOne(m);
+    delete m;
 }
 
 void
@@ -239,18 +135,3 @@ dlinkDelete(dlink_node * m, dlink_list * list)
 
     m->next = m->prev = NULL;
 }
-
-Ctx
-ctx_enter(const char *descr)
-{
-    return 0;
-}
-
-void
-ctx_exit(Ctx ctx) {}
-
-// for debugs()
-const char* SkipBuildPrefix(const char* path)
-{
-    return path;
-}
index abdab389c2ee38877ded1c97565744573f67e400..8763081bdd50664de9e046e766846febdaef981c 100644 (file)
@@ -17,8 +17,11 @@ man_MANS =
 DISTCLEANFILES = 
 
 LDADD = \
+       $(top_builddir)/src/tests/stub_debug.o \
        $(top_builddir)/src/time.o \
        $(top_builddir)/src/ip/libip.la \
+       $(top_builddir)/lib/libmiscencoding.la \
+       $(top_builddir)/lib/libmiscutil.la \
        $(COMPAT_LIB) \
        $(KRB5LIBS) \
        $(XTRA_LIBS)
index 39816cda7cd7a0a3ea014ea34ef4f7eb378954cc..6a77e8832912a84df1457472317614c9c60f2f62 100644 (file)
  */
 
 #include "config.h"
-#include "compat/tempnam.h"
+#include "base64.h"
 #include "getfullhostname.h"
+#include "html_quote.h"
 #include "ip/Address.h"
+#include "rfc1123.h"
 #include "rfc1738.h"
 #include "util.h"
 
@@ -143,7 +145,6 @@ static time_t now;
 /*
  * Function prototypes
  */
-#define safe_free(str) { if (str) { xfree(str); (str) = NULL; } }
 static const char *safe_str(const char *str);
 static const char *xstrtok(char **str, char del);
 static void print_trailer(void);
index 4eea9e0bc32985c3a965ca7a6d9e388ec7ccd582..07b6371c635c6958c7e5fb6a9a6bb38d97c61a7c 100644 (file)
  */
 
 #include "config.h"
+#include "base64.h"
 #include "ip/Address.h"
-#include "util.h"
+#include "rfc1123.h"
+#include "SquidTime.h"
 
 #ifdef _SQUID_MSWIN_
 /** \cond AUTODOCS-IGNORE */