#
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)/'`
noinst_LIBRARIES = libcompat-squid.a
libcompat_squid_a_SOURCES = \
+ assert.cc \
assert.h \
+ compat.cc \
compat.h \
compat_shared.h \
cpu.h \
+ debug.cc \
debug.h \
drand48.h \
eui64_aton.h \
fdsetsize.h \
getaddrinfo.h \
getnameinfo.h \
+ GnuRegex.c \
+ GnuRegex.h \
inet_ntop.h \
inet_pton.h \
initgroups.h \
types.h \
unsafe.h \
valgrind.h \
+ xalloc.cc \
+ xalloc.h \
+ xstrerror.cc \
+ xstrerror.h \
+ xstring.cc \
+ xstring.h \
+ xstrto.cc \
+ xstrto.h \
\
os/aix.h \
os/dragonfly.h \
os/sgi.h \
os/solaris.h \
os/sunos.h \
- os/windows.h \
- \
- assert.cc \
- compat.cc \
- debug.cc \
- GnuRegex.h \
- GnuRegex.c
+ os/windows.h
libcompat_squid_a_LIBADD= $(LIBOBJS)
+#include "config.h"
+#include "compat.h"
+
+void (*failure_notify) (const char *) = NULL;
* of the requirements for wrapping your hack for safe portability.
*/
+/*
+ * Define an error display handler override.
+ * If error_notify is set by the linked program it will be used by the local
+ * portability functions. Otherwise perror() will be used.
+ */
+#ifdef __cplusplus
+extern "C"
+#else
+extern
+#endif
+void (*failure_notify) (const char *);
/*
* sys/resource.h and sys/time.h are apparently order-dependant.
#endif
#endif
+/*
+ * Several function definitions which we provide for security and code safety.
+ */
+#include "compat/xalloc.h"
+#include "compat/xstrerror.h"
+#include "compat/xstring.h"
+#include "compat/xstrto.h"
+
#endif /* _SQUID_COMPAT_SHARED_H */
typedef char * caddr_t;
+#ifndef _PATH_DEVNULL
+#define _PATH_DEVNULL "NUL"
+#endif
+
#undef FD_CLOSE
#undef FD_OPEN
#undef FD_READ
--- /dev/null
+#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);
+}
--- /dev/null
+#ifndef _SQUID_COMPAT_XALLOC_H
+#define _SQUID_COMPAT_XALLOC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xcalloc() - same as calloc(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+void *xcalloc(size_t n, size_t sz);
+
+/**
+ * xmalloc() - same as malloc(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+void *xmalloc(size_t sz);
+
+/**
+ * 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 */
--- /dev/null
+#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;
+}
--- /dev/null
+#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 */
--- /dev/null
+#include "config.h"
+#include "compat/xalloc.h"
+#include "compat/xstring.h"
+
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+char *
+xstrdup(const char *s)
+{
+ size_t sz;
+ char *p;
+
+ if (s == NULL) {
+ if (failure_notify) {
+ (*failure_notify) ("xstrdup: tried to dup a NULL pointer!\n");
+ } else {
+ errno = EINVAL;
+ perror("xstrdup: tried to dup a NULL pointer!");
+ }
+ exit(1);
+ }
+
+ /* copy string, including terminating character */
+ sz = strlen(s) + 1;
+ p = (char *)xmalloc(sz);
+ memcpy(p, s, sz);
+
+ return p;
+}
+
+char *
+xstrncpy(char *dst, const char *src, size_t n)
+{
+ char *r = dst;
+
+ if (!n || !dst)
+ return dst;
+
+ if (src)
+ while (--n != 0 && *src != '\0')
+ *dst++ = *src++;
+
+ *dst = '\0';
+ return r;
+}
+
+char *
+xstrndup(const char *s, size_t n)
+{
+ size_t sz;
+ char *p;
+
+ if (s == NULL) {
+ errno = EINVAL;
+ if (failure_notify) {
+ (*failure_notify) ("xstrndup: tried to dup a NULL pointer!\n");
+ } else {
+ perror("xstrndup: tried to dup a NULL pointer!");
+ }
+ exit(1);
+ }
+ if (n < 0) {
+ errno = EINVAL;
+ if (failure_notify) {
+ (*failure_notify) ("xstrndup: tried to dup a negative length string!\n");
+ } else {
+ perror("xstrndup: tried to dup a negative length string!");
+ }
+ exit(1);
+ }
+
+ sz = strlen(s) + 1;
+ if (sz > n)
+ sz = n;
+
+ p = xstrncpy((char *)xmalloc(sz), s, sz);
+ return p;
+}
--- /dev/null
+#ifndef _SQUID_COMPAT_XSTRING_H
+#define _SQUID_COMPAT_XSTRING_H
+
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * xstrdup() - same as strdup(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Sets errno to EINVAL if a NULL pointer is passed.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+char *xstrdup(const char *s);
+
+#ifdef strdup
+#undef strdup
+#endif
+#define strdup(X) xstrdup((X))
+
+/*
+ * xstrncpy() - similar to strncpy(3) but terminates string
+ * always with '\0' if (n != 0 and dst != NULL),
+ * and doesn't do padding
+ */
+char *xstrncpy(char *dst, const char *src, size_t n);
+
+/**
+ * xstrndup() - same as strndup(3). Used for portability.
+ * Never returns NULL; fatal on error.
+ *
+ * Sets errno to EINVAL if a NULL pointer or negative
+ * length is passed.
+ *
+ * Define failure_notify to receive error message.
+ * otherwise perror() is used to display it.
+ */
+char *xstrndup(const char *s, size_t n);
+
+#ifdef strndup
+#undef strndup
+#endif
+#define strndup(X) xstrndup((X))
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SQUID_COMPAT_XSTRING_H */
*/
#include "config.h"
-#include "xstrto.h"
+#include "compat/xstrto.h"
/*
* (C) 2000-2006 by the netfilter coreteam <coreteam@netfilter.org>:
bstring.h \
cassert \
crypt.h \
+ cstdlib \
cstring \
ctype.h \
errno.h \
compat/Makefile \
lib/Makefile \
lib/ntlmauth/Makefile \
+ lib/profiler/Makefile \
lib/rfcnb/Makefile \
lib/smblib/Makefile \
scripts/Makefile \
LDADD = \
$(top_builddir)/lib/smblib/libsmblib.la \
$(top_builddir)/lib/rfcnb/librfcnb.la \
+ $(top_builddir)/lib/libmiscencoding.la \
$(COMPAT_LIB) \
$(XTRA_LIBS)
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)
#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;
nis_support.cc
basic_nis_auth_LDADD = \
+ $(top_builddir)/lib/libmiscencoding.la \
$(COMPAT_LIB) \
$(CRYPTLIB) \
$(XTRA_LIBS)
basic_pam_auth_SOURCES = basic_pam_auth.cc
basic_pam_auth_LDADD = \
+ $(top_builddir)/lib/libmiscencoding.la \
$(COMPAT_LIB) \
-lpam \
$(XTRA_LIBS)
radius-util.h
basic_radius_auth_LDADD = \
+ $(top_builddir)/lib/libmiscencoding.la \
$(COMPAT_LIB) \
$(SSLLIB) \
$(XTRA_LIBS)
basic_getpwnam_auth_SOURCES = basic_getpwnam_auth.cc
basic_getpwnam_auth_LDADD = \
+ $(top_builddir)/lib/libmiscencoding.la \
$(COMPAT_LIB) \
$(CRYPTLIB)
#include "config.h"
#include "helpers/defines.h"
#include "rfc1738.h"
-#include "util.h"
+//#include "util.h"
#if HAVE_STDIO_H
#include <stdio.h>
#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)
text_backend.h
LDADD = \
+ $(top_builddir)/lib/libmisccontainers.la \
+ $(top_builddir)/lib/libmiscencoding.la \
$(COMPAT_LIB) \
$(CRYPTLIB) \
$(SSLLIB) \
config.test
LDADD = \
+ $(top_builddir)/lib/libmiscencoding.la \
$(COMPAT_LIB) \
$(XTRA_LIBS)
ext_unix_group_acl_SOURCES = check_group.cc
LDADD = \
+ $(top_builddir)/lib/libmiscencoding.la \
$(COMPAT_LIB) \
$(XTRA_LIBS)
ntlm_fake_auth_LDADD = \
$(top_builddir)/lib/ntlmauth/libntlmauth.la \
+ $(top_builddir)/lib/libmiscencoding.la \
$(COMPAT_LIB) \
$(CRYPTLIB) \
$(XTRA_LIBS)
#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>
$(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)
*
*/
#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>
#ifndef SQUID_NEW_H
#define SQUID_NEW_H
-#include "util.h"
+#include "config.h"
#ifndef __SUNPRO_CC
/* Any code using libstdc++ must have externally resolvable overloads
}
_SQUID_EXTERNNEW_ void operator delete (void *address) throw()
{
- xfree (address);
+ xfree(address);
}
_SQUID_EXTERNNEW_ void *operator new[] (size_t size) throw (std::bad_alloc)
{
}
_SQUID_EXTERNNEW_ void operator delete[] (void *address) throw()
{
- xfree (address);
+ xfree(address);
}
--- /dev/null
+#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 */
--- /dev/null
+#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 */
*/
#include "strnstr.h"
-/*
- * xstrtoul() and xstrtoui() are strtoul() and strtoui() with limits.
- */
-#include "xstrto.h"
-
#endif /* SQUID_CONFIG_H */
--- /dev/null
+#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 */
--- /dev/null
+#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 */
#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
* \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)
* 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 */
#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,
);
/* 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 */
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 */
#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
#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
#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);
--- /dev/null
+#ifndef _SQUID_UUDECODE_H
+#define _SQUID_UUDECODE_
+
+#ifdef __cplusplus
+extern "C"
+#else
+extern
+#endif
+
+char *uudecode(const char *);
+
+#endif /* _SQUID_UUDECODE_H */
-## 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
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) \
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
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)
*/
#include "config.h"
-#include "util.h"
+#include "base64.h"
#if HAVE_STDIO_H
#include <stdio.h>
*/
#include "config.h"
-#include "util.h"
+#include "charset.h"
/** Convert ISO-LATIN-1 to UTF-8 */
char *
*/
#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
*/
#include "config.h"
+#include "html_quote.h"
#if HAVE_STDIO_H
#include <stdio.h>
#include <string.h>
#endif
-#include "util.h"
-
/*
* HTML defines these characters as special entities that should be quoted.
*/
*
*/
#include "config.h"
-
#include "md5.h"
#if HAVE_STRING_H
--- /dev/null
+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
* ... 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
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();
--- /dev/null
+#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_ */
--- /dev/null
+#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_ */
-#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,
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,
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,
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_ */
*/
#include "config.h"
-
+#include "rfc1123.h"
/*
* Adapted from HTSUtils.c in CERN httpd 3.0 (http://info.cern.ch/httpd/)
#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"
#include "config.h"
#include "rfc1738.h"
-#include "util.h"
+//#include "util.h"
#if HAVE_STDIO_H
#include <stdio.h>
#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
#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;
}
if (I == DBG_ARRY_SZ) {
+ static char msg[128];
snprintf(msg, 128, "xfree: ERROR: s=%p not found!", s);
(*failure_notify) (msg);
}
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);
#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)
{
}
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 +
}
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)
*/
#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] = {
#include "config.h"
-#include "profiling.h"
+#include "profiler/Profiler.h"
#include "xusleep.h"
#if HAVE_UNISTD_H
#if HAVE_ASSERT_H
#include <assert.h>
#endif
-
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
#include "asn1.h"
#include "snmp_vars.h"
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/include \
+ -I$(top_srcdir)/lib \
-I$(top_srcdir)/src \
-I$(top_builddir)/include \
$(SQUID_CPPUNIT_INC)
## 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)
/* 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
#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 */
*/
#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"
/*
$(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) \
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
$(EPOLL_LIBS) \
$(MINGW_LIBS) \
$(XTRA_LIBS)
-ufsdump_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
+ufsdump_DEPENDENCIES = \
$(COMMON_LIBS) \
$(DISK_LIBS) \
$(DISK_LINKOBJS) \
mib.txt
LDADD = $(COMMON_LIBS) \
- -L../lib -lmiscutil \
$(EPOLL_LIBS) \
$(MINGW_LIBS) \
$(COMPAT_LIB) \
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
#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
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 \
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 \
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 \
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
$(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 \
$(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) \
nodist_tests_testBoilerplate_SOURCES = \
$(TESTSOURCES)
tests_testBoilerplate_LDADD= \
- -L../lib -lmiscutil \
$(SQUID_CPPUNIT_LIBS) \
$(SSLLIB) \
$(COMPAT_LIB) \
$(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) \
$(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)
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)
$(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) \
$(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)
$(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) \
$(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)
$(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) \
## Tests of the HttpRequest module.
tests_testHttpRequest_SOURCES = \
$(ACL_REGISTRATION_SOURCES) \
- debug.cc \
HttpRequest.cc \
HttpRequestMethod.cc \
mem.cc \
BodyPipe.cc \
cache_manager.cc \
cache_cf.cc \
+ debug.cc \
ProtoPort.cc \
ProtoPort.h \
CacheDigest.cc \
$(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) \
$(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)
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 \
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) \
$(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.
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 = \
$(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) \
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 = \
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 = \
$(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 = \
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 = \
## TODO: Trim this down once the insanity is over.
tests_testURL_SOURCES = \
$(ACL_REGISTRATION_SOURCES) \
- debug.cc \
url.cc \
URLScheme.cc \
HttpRequest.cc \
tests/testURLScheme.cc \
tests/testURLScheme.h \
tests/testMain.cc \
+ tests/stub_debug.cc \
tests/stub_main_cc.cc \
time.cc \
BodyPipe.cc \
${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) \
$(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)
#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
#include "adaptation/Initiator.h"
#include "auth/UserRequest.h"
#include "base/TextException.h"
+#include "base64.h"
#include "ChunkedCodingParser.h"
#include "comm.h"
#include "HttpMsg.h"
#include "config.h"
-/* for xstrdup() */
-#include "util.h"
-/* for safe_free() */
-#include "defines.h"
-
char const *
AuthUser::username () const
{
* 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;
#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"
#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"
#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"
assert(!selectWaiting);
assert(!quotaQueue);
- quotaQueue = new CommQuotaQueue(this);
- cbdataReference(quotaQueue);
+ CommQuotaQueue *tmp = new CommQuotaQueue(this);
+ quotaQueue = cbdataReference(tmp);
bucketSize = anInitialBurst;
prevTime = current_dtime;
#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
/* dlink are Mem-pooled */
#include "MemPool.h"
-/* for xstrdup() */
-#include "util.h"
dlink_list ClientActiveRequests;
*/
#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
\endverbatim
*/
-#include "ip/Address.h"
-
#if LIBRESOLV_DNS_TTL_HACK
/// \ingroup dnsserver
extern int _dns_ttl_; /* this is a really *dirty* hack - bne */
#include "auth/UserRequest.h"
#include "SquidTime.h"
#include "Store.h"
+#include "html_quote.h"
#include "HttpReply.h"
#include "HttpRequest.h"
#include "MemObject.h"
#include "errorpage.h"
#include "fde.h"
#include "forward.h"
+#include "html_quote.h"
#include "HttpHdrContRange.h"
#include "HttpHeaderRange.h"
#include "HttpHeader.h"
#include "squid.h"
#include "errorpage.h"
#include "Store.h"
+#include "html_quote.h"
#include "HttpRequest.h"
#include "HttpReply.h"
#include "comm.h"
#include "auth/UserRequest.h"
#include "base/AsyncJobCalls.h"
#include "base/TextException.h"
+#include "base64.h"
#if DELAY_POOLS
#include "DelayPools.h"
#endif
-
include $(top_srcdir)/src/Common.am
include $(top_srcdir)/src/TestHeaders.am
DEFS += -DDEFAULT_CONFIG_FILE=NULL
-
# ICMP Specific Configurations
if ENABLE_PINGER
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:
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
$(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)
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= \
#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>
#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);
#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"
--- /dev/null
+/*
+ * 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;
+}
* 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
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()
{}
-
/*
* $Id$
*
#define SQUID_HELPER 1
-#include "squid.h"
+#include "config.h"
+
+#if HAVE_PATHS_H
+#include <paths.h>
+#endif
/**
\defgroup unlinkd unlinkd
printf("OK\n");
}
- exit(0);
+ return 0;
}
-#
-# Makefile for the Squid Object Cache server
-#
-# $Id$
-#
-
include $(top_srcdir)/src/Common.am
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
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..
* $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)
{
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)
{
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 */
if (m == NULL)
return;
- dlink_node_pool->freeOne(m);
+ delete m;
}
void
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;
-}
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)
*/
#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"
/*
* 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);
*/
#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 */