--------------------- PatchSet 1489 Date: 2001/02/05 12:10:13 Author: rbcollins Branch: rbcollins_filters Tag: (none) Log: new API to make state to allow grabbing clientHttpState/HttpReply/Request_t structure for the filters Members: src/filters.c:1.1.2.8->1.1.2.9 src/typedefs.h:1.1.1.3.8.7.4.9->1.1.1.3.8.7.4.10 src/modules/htmldemo/htmldemo.c:1.1.2.3->1.1.2.4 src/modules/spy/spy.c:1.1.2.3->1.1.2.4 src/modules/textreplace/textreplace.c:1.1.2.8->1.1.2.9 Index: squid/src/filters.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/filters.c,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -r1.1.2.8 -r1.1.2.9 --- squid/src/filters.c 5 Feb 2001 11:49:08 -0000 1.1.2.8 +++ squid/src/filters.c 5 Feb 2001 12:10:13 -0000 1.1.2.9 @@ -1,6 +1,6 @@ /* - * $Id: filters.c,v 1.1.2.8 2001/02/05 11:49:08 rbcollins Exp $ + * $Id: filters.c,v 1.1.2.9 2001/02/05 12:10:13 rbcollins Exp $ * * DEBUG: section 83 Content Processing Filters * AUTHOR: Robert Collins @@ -155,12 +155,13 @@ /* hmm. what should the parameters be? the list and a config? * that allows all four cases with one insertion routine. * but perhaps the filter needs to know the direction? + * to allow for reconfigures, each filter will be given a copy of their * config with room for whatever state data they need. * Rather than require the filter to make the copy, * we will get a callback that does that. */ - instance->Add(filter_list, instance->MakeState(instance->data)); + instance->Add(filter_list, instance->MakeState(instance->data, http, rep, request)); } filter=filter->next; } Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.1.1.3.8.7.4.9 retrieving revision 1.1.1.3.8.7.4.10 diff -u -r1.1.1.3.8.7.4.9 -r1.1.1.3.8.7.4.10 --- squid/src/typedefs.h 31 Jan 2001 12:41:52 -0000 1.1.1.3.8.7.4.9 +++ squid/src/typedefs.h 5 Feb 2001 12:10:13 -0000 1.1.1.3.8.7.4.10 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.1.1.3.8.7.4.9 2001/01/31 12:41:52 rbcollins Exp $ + * $Id: typedefs.h,v 1.1.1.3.8.7.4.10 2001/02/05 12:10:13 rbcollins Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -364,7 +364,7 @@ typedef void DATAFILTER(const char *, size_t , dlink_list *, FILTER_list *, unsigned int, void *); /* self, the list, the state */ typedef void REMOVEFILTER(FILTER_list *, dlink_list *, void*); -typedef void *FILTERMKSTATE(void *); +typedef void *FILTERMKSTATE(void *, clientHttpRequest *, HttpReply *, request_t *); typedef void ADDFILTER(dlink_list *, void *); /* fillin the module fields in a instance entry */ typedef void ADDFILTERINSTANCE(FILTER_instance *); Index: squid/src/modules/htmldemo/htmldemo.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/modules/htmldemo/Attic/htmldemo.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/modules/htmldemo/htmldemo.c 3 Feb 2001 14:23:21 -0000 1.1.2.3 +++ squid/src/modules/htmldemo/htmldemo.c 5 Feb 2001 12:10:13 -0000 1.1.2.4 @@ -101,7 +101,7 @@ } static void * -HtmlDemo_MakeState(void * data) { +HtmlDemo_MakeState(void * data, clientHttpRequest * http, HttpReply *rep, request_t *request) { HtmlDemoState *state; HtmlDemoConfig *config=data; if (!config) Index: squid/src/modules/spy/spy.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/modules/spy/Attic/spy.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/modules/spy/spy.c 5 Feb 2001 11:49:08 -0000 1.1.2.3 +++ squid/src/modules/spy/spy.c 5 Feb 2001 12:10:14 -0000 1.1.2.4 @@ -1,6 +1,6 @@ /* - * $Id: spy.c,v 1.1.2.3 2001/02/05 11:49:08 rbcollins Exp $ + * $Id: spy.c,v 1.1.2.4 2001/02/05 12:10:14 rbcollins Exp $ * * DEBUG: section 83 Content Processing Filters * AUTHOR: Robert Collins @@ -38,7 +38,7 @@ typedef struct _onunloadstate OnUnloadState; struct _onunloadstate { - char *instance; + char *url; }; static REMOVEFILTER SpyFilter_Remove; @@ -81,13 +81,19 @@ } static void * -SpyFilter_MakeState (void *data) +SpyFilter_MakeState (void *data, clientHttpRequest * http, HttpReply *rep, request_t *request) { 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)); + if (request && request->canonical) + state->url=xstrdup(request->canonical); + else if (http && http->uri) + state->url=xstrdup(http->uri); + else + state->url=xstrdup("No urlpath"); return state; } @@ -98,6 +104,7 @@ OnUnloadState *state = data; dlinkDelete (&filters->node, filter_list); xfree (filters); + safe_free(state->url); xfree (state); } @@ -126,9 +133,10 @@ static void SpyFilter(const char *buf,size_t len,dlink_list *filter_list,FILTER_list *filters,unsigned int flags,void *data) { + OnUnloadState *state=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); + debug(1,1)("**** Spying my dummy filter (buf=%x,len=%d,flags=%d url=%s\n",buf,len,flags,state->url); temp_filter->filter(buf,len,filter_list,temp_filter,flags,temp_filter->data); } Index: squid/src/modules/textreplace/textreplace.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/modules/textreplace/Attic/textreplace.c,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -r1.1.2.8 -r1.1.2.9 --- squid/src/modules/textreplace/textreplace.c 4 Feb 2001 22:13:49 -0000 1.1.2.8 +++ squid/src/modules/textreplace/textreplace.c 5 Feb 2001 12:10:14 -0000 1.1.2.9 @@ -1,6 +1,6 @@ /* - * $Id: textreplace.c,v 1.1.2.8 2001/02/04 22:13:49 rbcollins Exp $ + * $Id: textreplace.c,v 1.1.2.9 2001/02/05 12:10:14 rbcollins Exp $ * * DEBUG: section 83 Content Processing Filters * AUTHOR: Robert Collins @@ -111,7 +111,7 @@ } static void * -clientFilterOnUnload_MakeState (void *data) +clientFilterOnUnload_MakeState (void *data, clientHttpRequest * http, HttpReply *rep, request_t *request) { OnUnloadState *state; OnUnloadConfig *config = data;