--------------------- PatchSet 1419 Date: 2001/01/29 20:15:33 Author: rbcollins Branch: rbcollins_filters Tag: (none) Log: dynamic multi instance filters test base in place and compiles Members: src/client_side.c:1.1.1.3.4.1.4.15.2.7->1.1.1.3.4.1.4.15.2.8 src/structs.h:1.1.1.3.4.1.4.12.2.6->1.1.1.3.4.1.4.12.2.7 src/typedefs.h:1.1.1.3.8.7.4.4->1.1.1.3.8.7.4.5 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.7 retrieving revision 1.1.1.3.4.1.4.15.2.8 diff -u -r1.1.1.3.4.1.4.15.2.7 -r1.1.1.3.4.1.4.15.2.8 --- squid/src/client_side.c 29 Jan 2001 13:35:42 -0000 1.1.1.3.4.1.4.15.2.7 +++ squid/src/client_side.c 29 Jan 2001 20:15:33 -0000 1.1.1.3.4.1.4.15.2.8 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.1.1.3.4.1.4.15.2.7 2001/01/29 13:35:42 rbcollins Exp $ + * $Id: client_side.c,v 1.1.1.3.4.1.4.15.2.8 2001/01/29 20:15:33 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1348,6 +1348,7 @@ static REMOVEFILTER clientFilterOnUnload_Remove; static ADDFILTER clientFilterOnUnload_Add; static FILTERMKSTATE clientFilterOnUnload_MakeState; +static FILTERPARSE clientFilterOnUnload_Parse; void clientFilterFreeConfig(void *data) { @@ -1363,7 +1364,9 @@ clientFilterOnUnload_AddInstance(FILTER_instance *instance) { instance->Add=clientFilterOnUnload_Add; instance->MakeState=clientFilterOnUnload_MakeState; + instance->Parse =clientFilterOnUnload_Parse; instance->data=xmalloc(sizeof(OnUnloadConfig)); + /* Set defaults, if sensible defaults exist */ } void @@ -1374,7 +1377,7 @@ instance->data=NULL; } -void +static void clientFilterOnUnload_Add(dlink_list *filters, void *filter_config) { FILTER_list *temp_filter; temp_filter=xmalloc(sizeof(FILTER_list)); @@ -1401,7 +1404,7 @@ return state; } -void +static void clientFilterOnUnload_Remove(FILTER_list *filters, dlink_list *filter_list, void *data) { OnUnloadState *state=data; dlinkDelete(&filters->node, filter_list); @@ -1411,6 +1414,28 @@ xfree(state); } +static void +clientFilterOnUnload_Parse(void *data, const char *namestr, char *param_str) { + OnUnloadConfig *config=data; +#if 0 + if (scheme->scheme_data == NULL) { + assert(basicConfig == NULL); + /* this is the first param to be found */ + scheme->scheme_data = xmalloc(sizeof(auth_basic_config)); + memset(scheme->scheme_data, 0, sizeof(auth_basic_config)); + basicConfig = scheme->scheme_data; + basicConfig->authenticateChildren = 5; + } +#endif + if (strcasecmp(param_str, "replace") == 0) { + parse_eol(&config->replace); + } else if (strcasecmp(param_str, "search") == 0) { + parse_eol(&config->searchstring); + } else { + debug(28, 0) ("unrecognised parameter '%s' for filter %s\n", param_str,namestr); + } +} + /* * filters out unwanted entries from original reply header * adds extra entries if we have more info than origin server @@ -1487,12 +1512,12 @@ #create an instance aka filter config filter_add textreplace onunload*/ instances[0].namestr="onunload"; - instances[0].module=modules[0]; + instances[0].module=&modules[0]; modules[0].AddInstance(&instances[0]); /*filter_add textreplace onclick*/ instances[1].namestr="onclick"; - instances[1].module=modules[0]; + instances[1].module=&modules[0]; modules[0].AddInstance(&instances[1]); /* @@ -1500,23 +1525,23 @@ filter_config onunload search onunload filter_config onunload replace nonsense */ - instances[0].parse("search onunload"); - instances[0].parse("replace nonsense"); + instances[0].Parse(instances[0].data,instances[0].module->namestr,"search onunload"); + instances[0].Parse(instances[0].data,instances[0].module->namestr,"replace nonsense"); /* filter_config onclick search onclick filter_config onclick replace non1234 */ + instances[1].Parse(instances[1].data,instances[1].module->namestr,"search onclick"); + instances[1].Parse(instances[1].data,instances[1].module->namestr,"replace non4321"); + ch = aclChecklistCreate(Config.accessList.onunload, http->request, NULL); ch->reply = rep; rv = aclCheckFast(Config.accessList.onunload, ch); aclChecklistFree(ch); if (rv==1) { - OnUnloadConfig filtercfg; - filtercfg.searchstring="onunload"; - filtercfg.replace="nonsense"; debug(33,8)("\n\nAdding the filter OnUnload!!\n\n"); /* hmm. what should the parameters be? the list and a config? * that allows all four cases with one insertion routine. @@ -1526,12 +1551,10 @@ * Rather than require the filter to make the copy, * we will get a callback that does that. */ - clientFilterOnUnload_Add(&http->repfilters, clientFilterOnUnload_MakeState(&filtercfg)); - filtercfg.searchstring="onclick"; - filtercfg.replace="non1234"; - clientFilterOnUnload_Add(&http->repfilters, clientFilterOnUnload_MakeState(&filtercfg)); - } + instances[0].Add(&http->repfilters, instances[0].MakeState(instances[0].data)); + instances[1].Add(&http->repfilters, instances[1].MakeState(instances[1].data)); } + /* remove all the config details. This simulates what happens when a reconfigure occurs * during a request's process */ @@ -1539,7 +1562,7 @@ /* for each instance */ instances[1].module->RemInstance(&instances[1]); instances[0].module->RemInstance(&instances[0]); - + } /* the following should happen: while (filter_list test) Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.1.1.3.4.1.4.12.2.6 retrieving revision 1.1.1.3.4.1.4.12.2.7 diff -u -r1.1.1.3.4.1.4.12.2.6 -r1.1.1.3.4.1.4.12.2.7 --- squid/src/structs.h 29 Jan 2001 13:35:42 -0000 1.1.1.3.4.1.4.12.2.6 +++ squid/src/structs.h 29 Jan 2001 20:15:34 -0000 1.1.1.3.4.1.4.12.2.7 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.1.1.3.4.1.4.12.2.6 2001/01/29 13:35:42 rbcollins Exp $ + * $Id: structs.h,v 1.1.1.3.4.1.4.12.2.7 2001/01/29 20:15:34 rbcollins Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -917,6 +917,7 @@ FILTER_module *module; ADDFILTER *Add; FILTERMKSTATE *MakeState; + FILTERPARSE *Parse; void *data; }; Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.1.1.3.8.7.4.4 retrieving revision 1.1.1.3.8.7.4.5 diff -u -r1.1.1.3.8.7.4.4 -r1.1.1.3.8.7.4.5 --- squid/src/typedefs.h 29 Jan 2001 13:35:42 -0000 1.1.1.3.8.7.4.4 +++ squid/src/typedefs.h 29 Jan 2001 20:15:34 -0000 1.1.1.3.8.7.4.5 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.1.1.3.8.7.4.4 2001/01/29 13:35:42 rbcollins Exp $ + * $Id: typedefs.h,v 1.1.1.3.8.7.4.5 2001/01/29 20:15:34 rbcollins Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -362,5 +362,11 @@ typedef void REMOVEFILTER(FILTER_list *, dlink_list *, void*); typedef void *FILTERMKSTATE(void *); typedef void ADDFILTER(dlink_list *, void *); +/* fillin the module fields in a instance entry */ typedef void ADDFILTERINSTANCE(FILTER_instance *); +/* free any instance data, and clear the fields in an instance entry */ +typedef void REMFILTERINSTANCE(FILTER_instance *); +/* config, namestr, param_str */ +typedef void FILTERPARSE(void *,const char *, char *); + #endif /* _TYPEDEFS_H_ */