--------------------- PatchSet 1401 Date: 2001/01/27 02:38:58 Author: rbcollins Branch: rbcollins_filters Tag: (none) Log: sample filter working Members: src/client_side.c:1.1.1.3.4.1.4.15.2.2->1.1.1.3.4.1.4.15.2.3 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.2 retrieving revision 1.1.1.3.4.1.4.15.2.3 diff -u -r1.1.1.3.4.1.4.15.2.2 -r1.1.1.3.4.1.4.15.2.3 --- squid/src/client_side.c 26 Jan 2001 13:18:32 -0000 1.1.1.3.4.1.4.15.2.2 +++ squid/src/client_side.c 27 Jan 2001 02:38:58 -0000 1.1.1.3.4.1.4.15.2.3 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.1.1.3.4.1.4.15.2.2 2001/01/26 13:18:32 rbcollins Exp $ + * $Id: client_side.c,v 1.1.1.3.4.1.4.15.2.3 2001/01/27 02:38:58 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1991,6 +1991,103 @@ // comm_write(http->conn->fd, buf, len, clientWriteBodyComplete, http, NULL); } +#define TESTFILTER 1 +#if TESTFILTER + +char * +strnchr(const char *str, char chr, size_t len) { + size_t pos=0; + while (posnode.next->data; + + chr=searchstring; + pos=0; + startpos=buf; + + while (startpos) { + startpos=strnchr(startpos, *chr, len-(startpos-buf)); + + if (startpos) { + /* possibly present in this buffer */ + chr++; + pos=startpos+1; + while (pos) { + if (tolower(*pos)==tolower(*chr)) { + chr++; + pos++; + } + if (pos-buf>=len){ + /* end of data */ + temp_filter->filter(buf,len,filter_list, temp_filter, flags, temp_filter->data); + return; + } + if (*chr=='\0') { + /* end of search string - we've got a match */ + /* send the first set of data */ + if (startpos-buf) + temp_filter->filter(buf,startpos-buf,filter_list, temp_filter, flags, temp_filter->data); + /* send the filter set of data */ + temp_filter->filter("nonsense",8,filter_list, temp_filter, flags, temp_filter->data); + /* and the rest */ + temp_filter->filter(startpos+8,len-(startpos-buf)-8,filter_list, temp_filter, flags,temp_filter->data); + return; + } + if(tolower(*pos)!=tolower(*chr)) { + /* reset the search criteria to after the corrent position */ + startpos=pos; + pos=NULL; + chr=searchstring; + } + } + } + else { + temp_filter->filter(buf,len,filter_list, temp_filter, flags, temp_filter->data); + return; + } + + } + temp_filter->filter(buf,len,filter_list, temp_filter, flags, temp_filter->data); + +} +#endif + /* * accepts chunk of a http message in buf, parses prefix, filters headers and * such, writes processed message to the client's socket @@ -2097,6 +2194,15 @@ temp_filter->data=http; /* cbDataLock(http); ? */ dlinkAdd(temp_filter, &temp_filter->node, &http->repfilters); +#if TESTFILTER + temp_filter=xmalloc(sizeof(FILTER_list)); + temp_filter->filter=clientFilterOnUnload; + temp_filter->data=http; + /* cbDataLock(http); ? */ + dlinkAddTail(temp_filter, &temp_filter->node, &http->repfilters); +#endif + + #if 0 /* this can't be done until the process for locking/freeing buffers * is looked into @@ -2334,7 +2440,6 @@ * write it. */ debug(33,8)("clientWriteComplete: Pushing queued data\n"); - http->out.offset += http->mb.size; http->flags.reply_write_in_progress=1; comm_write_mbuf(http->conn->fd, http->mb, clientWriteComplete, http); /* zero the membuf - the data is untouched */