=== modified file 'CREDITS' --- CREDITS 2009-06-20 06:50:37 +0000 +++ CREDITS 2009-07-11 09:38:22 +0000 @@ -391,8 +391,9 @@ include/IPAddress.h lib/IPAddress.cc: include/rfc3596.h lib/rfc3596.cc: src/ICMPv6.h src/ICMPv6.cc: +helpers/url_rewrite/fake/ fake.h, fake.cc, url_fake_rewrite.sh: - This code is copyright (C) 2007 by Treehouse Networks Ltd + This code is copyright (C) 2007-2009 by Treehouse Networks Ltd of New Zealand. It is published and Licensed as an extension of squid under the same conditions as the main squid application. === modified file 'compat/compat.h' --- compat/compat.h 2009-04-07 13:51:57 +0000 +++ compat/compat.h 2009-07-11 03:23:11 +0000 @@ -74,10 +74,14 @@ #include "compat/stdvarargs.h" #include "compat/assert.h" + /*****************************************************/ /* component-specific portabilities */ /*****************************************************/ +/* helper debugging requires some hacks to be clean */ +#include "compat/helper_debug.h" + /* Valgrind API macros changed between two versions squid supports */ #include "compat/valgrind.h" === added file 'compat/helper_debug.h' --- compat/helper_debug.h 1970-01-01 00:00:00 +0000 +++ compat/helper_debug.h 2009-07-11 05:17:46 +0000 @@ -0,0 +1,45 @@ +#ifndef SQUID_CONFIG_H +#include "config.h" +#endif + +#ifndef COMPAT_HELPER_DEBUG_H +#define COMPAT_HELPER_DEBUG_H + +/* + * A debug method for use of external helpers. + * It shunts the debug messages down stderr for logging by Squid + * of display to the user instead of corrupting the stdout data stream. + */ + +#if HAVE_STDIO_H +#include +#endif +#if HAVE_UNISTD_H +#include +#endif + +/* Debugging stuff */ + +/* the macro overload style is really a gcc-ism */ +#ifdef __GNUC__ + +SQUIDCEXTERN int debug_enabled; + +#define helper_debug(X...) \ + if (debug_enabled) { \ + fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \ + fprintf(stderr,X); \ + } + +#else /* __GNUC__ */ + +/* TODO: non-GCC compilers can't do the above macro define yet. */ +inline void +helper_debug(char *format,...) +{ + ; // nothing to do. +} +#endif + + +#endif /* COMPAT_HELPER_DEBUG_H */ === modified file 'configure.in' --- configure.in 2009-07-09 10:27:25 +0000 +++ configure.in 2009-07-11 04:32:04 +0000 @@ -1854,6 +1854,48 @@ fi AC_SUBST(EXTERNAL_ACL_HELPERS) +dnl Select url_rewrite helpers to build +URL_REWRITE_HELPERS=all +AC_ARG_ENABLE(url-rewrite-helpers, + AC_HELP_STRING([--enable-url-rewrite-helpers="list of helpers"], + [This option selects which url_rewrite helpers to + build and install as part of the normal build + process. For a list of available helpers see the + helpers/url_rewrite directory.]), +[ case "$enableval" in + yes) + URL_REWRITE_HELPERS=all + ;; + no) + URL_REWRITE_HELPERS="" + ;; + *) + URL_REWRITE_HELPERS="`echo $enableval| sed -e 's/,/ /g;s/ */ /g'`" + ;; + esac +]) +if test "$URL_REWRITE_HELPERS" = "all" ; then + URL_REWRITE_HELPERS="" + for dir in $srcdir/helpers/url_rewrite/*; do + helper="`basename $dir`" + if test -f $dir/config.test && sh $dir/config.test "$@"; then + URL_REWRITE_HELPERS="$URL_REWRITE_HELPERS $helper" + fi + done +fi +if test -n "$URL_REWRITE_HELPERS"; then + for helper in $URL_REWRITE_HELPERS; do + if test -f $srcdir/helpers/url_rewrite/$helper/Makefile.in; then + : + else + AC_MSG_ERROR(url_rewrite helper $helper does not exist) + fi + done + AC_MSG_NOTICE([url_rewrite helpers built: $URL_REWRITE_HELPERS]) +fi +AC_SUBST(URL_REWRITE_HELPERS) + + AC_ARG_WITH(valgrind-debug, AC_HELP_STRING([--with-valgrind-debug], [Include debug instrumentation for use with valgrind]), @@ -3915,6 +3957,8 @@ helpers/external_acl/wbinfo_group/Makefile \ helpers/external_acl/mswin_ad_group/Makefile \ helpers/external_acl/mswin_lm_group/Makefile \ + helpers/url_rewrite/Makefile \ + helpers/url_rewrite/fake/Makefile \ tools/Makefile ]) === modified file 'helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c' --- helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c 2009-04-27 12:05:38 +0000 +++ helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c 2009-07-11 09:16:21 +0000 @@ -155,7 +155,7 @@ my_program_name, my_program_name); } -char debug_enabled=0; +int debug_enabled=0; void process_options(int argc, char *argv[]) === modified file 'helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.h' --- helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.h 2008-10-26 12:49:21 +0000 +++ helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.h 2009-07-11 09:14:59 +0000 @@ -45,13 +45,13 @@ /* Debugging stuff */ - +#ifndef debug /* already provided */ #ifdef __GNUC__ /* this is really a gcc-ism */ #ifdef DEBUG #include #include static const char *__foo; -extern char debug_enabled; +extern int debug_enabled; #define debug(X...) if (debug_enabled) { \ fprintf(stderr,"ntlm-auth[%ld](%s:%d): ", (long)getpid(), \ ((__foo=strrchr(__FILE__,'/'))==NULL?__FILE__:__foo+1),\ @@ -65,9 +65,8 @@ debug(char *format,...) { } - #endif - +#endif /* debug already defined */ /* A couple of harmless helper macros */ #define SEND(X) debug("sending '%s' to squid\n",X); printf(X "\n"); === added directory 'helpers/url_rewrite' === added file 'helpers/url_rewrite/Makefile.am' --- helpers/url_rewrite/Makefile.am 1970-01-01 00:00:00 +0000 +++ helpers/url_rewrite/Makefile.am 2009-07-11 02:47:12 +0000 @@ -0,0 +1,3 @@ + +DIST_SUBDIRS = fake +SUBDIRS = @URL_REWRITE_HELPERS@ === added directory 'helpers/url_rewrite/fake' === added file 'helpers/url_rewrite/fake/Makefile.am' --- helpers/url_rewrite/fake/Makefile.am 1970-01-01 00:00:00 +0000 +++ helpers/url_rewrite/fake/Makefile.am 2009-07-11 03:56:47 +0000 @@ -0,0 +1,6 @@ +include $(top_srcdir)/src/Common.am + +libexec_PROGRAMS = url_fake_rewrite url_fake_rewrite.sh + +url_fake_rewrite_SOURCES = fake.cc +url_fake_rewrite_LDADD = $(COMPAT_LIBS) === added file 'helpers/url_rewrite/fake/config.test' --- helpers/url_rewrite/fake/config.test 1970-01-01 00:00:00 +0000 +++ helpers/url_rewrite/fake/config.test 2009-07-11 02:43:38 +0000 @@ -0,0 +1,2 @@ +#!/bin/sh +exit 0 === added file 'helpers/url_rewrite/fake/fake.cc' --- helpers/url_rewrite/fake/fake.cc 1970-01-01 00:00:00 +0000 +++ helpers/url_rewrite/fake/fake.cc 2009-07-11 09:38:04 +0000 @@ -0,0 +1,109 @@ +/* + * AUTHOR: Amos Jeffries + * + * Example url re-writer program for Squid. + * + * This code gets the url and returns it. No re-writing is done. + * It is intended for testing use and as a base for further implementation. + * + * + * This code is copyright (C) 2009 by Treehouse Networks Ltd + * of New Zealand. It is published and Licensed as an extension of + * squid under the same conditions as the main squid application. + */ + +#include "config.h" + +#define BUFFER_SIZE 10240 + +/** + * options: + * -d enable debugging. + * -h interface help. + */ +char *my_program_name = NULL; +int concurrent_detected = -1; + + +static void +usage(void) +{ + fprintf(stderr, + "Usage: %s [-d] [-v] [-h]\n" + " -d enable debugging.\n" + " -h this message\n\n", + my_program_name); +} + +static void +process_options(int argc, char *argv[]) +{ + int opt, had_error = 0; + + opterr = 0; + while (-1 != (opt = getopt(argc, argv, "hd"))) { + switch (opt) { + case 'd': + debug_enabled = 1; + break; + case 'h': + usage(); + exit(0); + case '?': + opt = optopt; + /* fall thru to default */ + default: + fprintf(stderr, "unknown option: -%c. Exiting\n", opt); + usage(); + had_error = 1; + } + } + if (had_error) + exit(1); +} + +bool +detect_concurrent(const char *) +{ + // TODO: scan the char* input and see if it is 100% numeric. + // if so, enable concurrent support IDs. +} + +int +main(int argc, char *argv[]) +{ + char buf[BUFFER_SIZE]; + int buflen = 0; + char helper_command[3]; + + setbuf(stdout, NULL); + setbuf(stderr, NULL); + + my_program_name = argv[0]; + + process_options(argc, argv); + + helper_debug("%s build " __DATE__ ", " __TIME__ " starting up...\n", my_program_name); + + while (fgets(buf, BUFFER_SIZE, stdin) != NULL) { + + if ((p = strchr(buf, '\n')) != NULL) { + *p = '\0'; /* strip \n */ + buflen = p - buf; /* length is known already */ + } + else + buflen = strlen(buf); /* keep this so we only scan the buffer for \0 once per loop */ + +/* TODO: later. + if (concurrent_detected < 0) + detect_concurrent(buf); +// */ + + helper_debug("Got %d bytes '%s' from Squid\n", buflen, buf); + + /* send 'no-change' result back to Squid */ + fprintf(stdout,"\n"); + } + helper_debug("%s build " __DATE__ ", " __TIME__ " shutting down...\n", my_program_name); + exit(0); +} === added file 'helpers/url_rewrite/fake/fake.h' === added file 'helpers/url_rewrite/fake/url_fake_rewrite.sh' --- helpers/url_rewrite/fake/url_fake_rewrite.sh 1970-01-01 00:00:00 +0000 +++ helpers/url_rewrite/fake/url_fake_rewrite.sh 2009-07-11 09:37:53 +0000 @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Author: Amos Jeffries +# +# This code is copyright (C) 2009 by Treehouse Networks Ltd +# of New Zealand. It is published and Licensed as an extension of +# squid under the same conditions as the main squid application. +# + +if test "${1}" = "-d" ; then + echo "Usage: $0 [-h] [-d logfile]" + echo " -h Help: this help text" + echo " -d logfile Debug: log all data received to the named file" + exit 1 +fi + +DEBUG=0 +if test "${1}" = "-d" ; then + DEBUG=1 + LOG="${2}" +fi + +while read url rest; do + if test ${DEBUG} ; then + echo "$url $rest" >>${LOG} + fi + echo # blank line for no change, or replace with another URL. +done === modified file 'src/Common.am' --- src/Common.am 2009-02-19 20:28:48 +0000 +++ src/Common.am 2009-07-11 02:46:33 +0000 @@ -23,3 +23,7 @@ ## make all compiled sources depend on generated files ## XXX: Do we really need this? Does auto-dependency tracking work? $(OBJS): $(top_srcdir)/include/version.h $(top_builddir)/include/autoconf.h + +COMPAT_LIBS = \ + -L$(top_builddir)/lib -lmiscutil \ + $(top_builddir)/compat/libcompat.la