--------------------- PatchSet 1463 Date: 2001/01/31 21:07:43 Author: rbcollins Branch: rbcollins_filters Tag: (none) Log: added spy filter, partial fix for no terminal call to the filter chain Members: src/client_side.c:1.1.1.3.4.1.4.15.2.13->1.1.1.3.4.1.4.15.2.14 src/filters.c:1.1.2.3->1.1.2.4 src/modules/spy/Makefile.in:1.1->1.1.2.1 src/modules/spy/spy.c:1.1->1.1.2.1 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.1.1.3.4.1.4.15.2.13 retrieving revision 1.1.1.3.4.1.4.15.2.14 diff -u -r1.1.1.3.4.1.4.15.2.13 -r1.1.1.3.4.1.4.15.2.14 --- squid/src/client_side.c 30 Jan 2001 11:00:01 -0000 1.1.1.3.4.1.4.15.2.13 +++ squid/src/client_side.c 31 Jan 2001 21:07:43 -0000 1.1.1.3.4.1.4.15.2.14 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.1.1.3.4.1.4.15.2.13 2001/01/30 11:00:01 rbcollins Exp $ + * $Id: client_side.c,v 1.1.1.3.4.1.4.15.2.14 2001/01/31 21:07:43 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -2468,6 +2468,8 @@ debug(33, 5) ("clientWriteComplete: FD %d transfer is DONE\n", fd); /* why are we finished? */ debug(33,8) ("clientWriteComplete: done %d size %d tetest %d\n",done,size,http->oldte_rv & TE_BUFFERING_OUTPUT); + +#if 0 /* We're finished case */ http->oldte_rv = free_te = perform_te (http->te_translations,NULL,0, &stuck_data, &stuckdatasize); @@ -2496,6 +2498,15 @@ { http->flags.done_copying = 1; } +#endif + /* we're finished, but the filters haven't been given a termination case */ + if (http->repfilters.head != NULL && size>0) { + FILTER_list *temp_filter; + temp_filter=http->repfilters.head->data; + temp_filter->filter(NULL, 0, &http->repfilters, temp_filter, 0, temp_filter->data); + return; + } + if (httpReplyBodySize(http->request->method, entry->mem_obj->reply) < 0) { debug(33, 5) ("clientWriteComplete: closing, content_length < 0\n"); comm_close(fd); Index: squid/src/filters.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/filters.c,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid/src/filters.c 31 Jan 2001 12:41:52 -0000 1.1.2.3 +++ squid/src/filters.c 31 Jan 2001 21:07:43 -0000 1.1.2.4 @@ -1,6 +1,6 @@ /* - * $Id: filters.c,v 1.1.2.3 2001/01/31 12:41:52 rbcollins Exp $ + * $Id: filters.c,v 1.1.2.4 2001/01/31 21:07:43 rbcollins Exp $ * * DEBUG: section 83 Content Processing Filters * AUTHOR: Robert Collins @@ -107,11 +107,11 @@ FILTER_module * filterByName(const char *namestr) { - int i = 0; - for (i = 0; filter_list && filter_list[i].namestr; i++) { - if (strncasecmp(namestr, filter_list[i].namestr, strlen(filter_list[i].namestr)) == 0) { - return &filter_list[i]; - } + FILTER_module *filter=filter_list; + while (filter) { + if (strncasecmp(namestr, filter->namestr, strlen(filter->namestr)) == 0) + return filter; + filter=filter->next; } return NULL; } --- /dev/null Wed Feb 14 00:48:56 2007 +++ squid/src/modules/spy/Makefile.in Wed Feb 14 00:49:32 2007 @@ -0,0 +1,70 @@ +# +# Makefile for the ntlm authentication scheme module for the Squid Object Cache server +# +# $Id: Makefile.in,v 1.1.2.1 2001/01/31 21:07:43 rbcollins Exp $ +# + +MODULE = spy + +#SUBDIRS = helpers + +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ + +CC = @CC@ +MAKEDEPEND = @MAKEDEPEND@ +AR_R = @AR_R@ +RANLIB = @RANLIB@ +AC_CFLAGS = @CFLAGS@ +SHELL = /bin/sh + +INCLUDE = -I../../../include -I$(top_srcdir)/include -I$(top_srcdir)/src/ +CFLAGS = $(AC_CFLAGS) $(INCLUDE) $(DEFINES) + +OUT = ../$(MODULE).a + +OBJS = \ + spy.o + + +all install: $(OUT) + @for dir in $(SUBDIRS); do \ + if [ -f $$dir/Makefile ]; then \ + sh -c "cd $$dir && $(MAKE) $@" || exit 1; \ + fi; \ + done; + +$(OUT): $(OBJS) + @rm -f ../stamp + $(AR_R) $(OUT) $(OBJS) + $(RANLIB) $(OUT) + +$(OBJS): $(top_srcdir)/include/version.h ../../../include/autoconf.h + +.c.o: + @rm -f ../stamp + $(CC) $(CFLAGS) -c $< + +clean: + -rm -rf *.o *pure_* core ../$(MODULE).a + -for dir in *; do \ + if [ -f $$dir/Makefile ]; then \ + sh -c "cd $$dir && $(MAKE) clean"; \ + fi; \ + done + +distclean: clean + -rm -f Makefile + -rm -f Makefile.bak + -rm -f tags + -for dir in *; do \ + if [ -f $$dir/Makefile ]; then \ + sh -c "cd $$dir && $(MAKE) distclean"; \ + fi; \ + done + +tags: + ctags *.[ch] $(top_srcdir)/src/*.[ch] $(top_srcdir)/include/*.h $(top_srcdir)/lib/*.[ch] + +depend: + $(MAKEDEPEND) $(INCLUDE) -fMakefile *.c --- /dev/null Wed Feb 14 00:48:56 2007 +++ squid/src/modules/spy/spy.c Wed Feb 14 00:49:32 2007 @@ -0,0 +1,136 @@ + +/* + * $Id: spy.c,v 1.1.2.1 2001/01/31 21:07:43 rbcollins Exp $ + * + * DEBUG: section 83 Content Processing Filters + * AUTHOR: Robert Collins + * + * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from the + * Internet community. Development is led by Duane Wessels of the + * National Laboratory for Applied Network Research and funded by the + * National Science Foundation. Squid is Copyrighted (C) 1998 by + * the Regents of the University of California. Please see the + * COPYRIGHT file for full details. Squid incorporates software + * developed and/or copyrighted by other sources. Please see the + * CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include "squid.h" + +/* The textreplace filter */ +typedef struct _onunloadstate OnUnloadState; +struct _onunloadstate +{ + /* allow for searching across buffer breaks */ + /* not implemented just yet :] */ + char *pos; + size_t seen; +}; + +static REMOVEFILTER SpyFilter_Remove; +static ADDFILTER SpyFilter_Add; +static FILTERMKSTATE SpyFilter_MakeState; +static FILTERPARSE SpyFilter_Parse; +static DATAFILTER SpyFilter; + +static void +SpyFilter_AddInstance (FILTER_instance * instance) +{ + instance->Add = SpyFilter_Add; + instance->MakeState = SpyFilter_MakeState; + instance->Parse = SpyFilter_Parse; + instance->data = NULL; + /* Set defaults, if sensible defaults exist */ +} + +static void +SpyFilter_RemInstance (FILTER_instance * instance) +{ + instance->Add = NULL; + instance->MakeState = NULL; + instance->data = NULL; +} + +static void +SpyFilter_Add (dlink_list * filters, void *filter_config) +{ + FILTER_list *temp_filter; + temp_filter = xmalloc (sizeof (FILTER_list)); + temp_filter->filter = SpyFilter; + temp_filter->Remove = SpyFilter_Remove; + temp_filter->data = filter_config; + /* cbDataLock(http); ? */ + dlinkAddTail (temp_filter, &temp_filter->node, filters); +} + +static void * +SpyFilter_MakeState (void *data) +{ + OnUnloadState *state; + /* it's up to the filter writer wether to refcount the config, + * or copy it. For now, to save learning cbdata, I copy it + */ + state = xmalloc (sizeof (OnUnloadState)); + state->seen = 0; + return state; +} + +static void +SpyFilter_Remove (FILTER_list * filters, dlink_list * filter_list, + void *data) +{ + OnUnloadState *state = data; + dlinkDelete (&filters->node, filter_list); + xfree (filters); + xfree (state); +} + +static void +SpyFilter_Parse (void *data, const char *namestr, char *param_str) +{ + debug (33, 0) ("unrecognised parameter '%s' for filter %s\n", param_str, + namestr); +} + +/* register as a module */ +void +mod_install_spy (const char *namestr) +{ + /* Register as a potential client_side reply filter */ + filterRegisterModule (namestr, SpyFilter_AddInstance, + SpyFilter_RemInstance); +} + +/* deregister as a module */ +void +mod_uninstall_spy(const char *namestr) { + filterDeregisterModule(namestr); +} + +static +void SpyFilter(const char *buf,size_t len,dlink_list *filter_list,FILTER_list *filters,unsigned int flags,void *data) +{ + FILTER_list *temp_filter=filters->node.next->data; + + debug(1,1)("**** Spying my dummy filter (buf=%x,len=%d,flags=%d\n",buf,len,flags); + temp_filter->filter(buf,len,filter_list,temp_filter,flags,temp_filter->data); +} +