--------------------- PatchSet 459 Date: 2002/12/22 05:35:55 Author: rbcollins Branch: esi Tag: (none) Log: extract Context header Members: src/ESI.cc:1.1.2.70->1.1.2.71 src/ESIContext.h:1.1->1.1.2.1 src/Makefile.am:1.4.2.3->1.4.2.4 Index: squid3/src/ESI.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESI.cc,v retrieving revision 1.1.2.70 retrieving revision 1.1.2.71 diff -u -r1.1.2.70 -r1.1.2.71 --- squid3/src/ESI.cc 22 Dec 2002 05:10:31 -0000 1.1.2.70 +++ squid3/src/ESI.cc 22 Dec 2002 05:35:55 -0000 1.1.2.71 @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.1.2.70 2002/12/22 05:10:31 rbcollins Exp $ + * $Id: ESI.cc,v 1.1.2.71 2002/12/22 05:35:55 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -41,6 +41,7 @@ #include "expat.h" #include "ESISegment.h" #include "ESIElement.h" +#include "ESIContext.h" /* quick reference on behaviour here. * The ESI specification 1.0 requires the ESI processor to be able to @@ -52,7 +53,7 @@ */ typedef struct _esiStreamContext esiStreamContext; -struct esiContext; +class esiContext; /* TODO: split this out into separate files ? */ /* Parsing: quick and dirty. ESI files are not valid XML, so a generic @@ -161,12 +162,7 @@ extern int esiExpressionEval (char const *); -typedef enum { - ESI_KICK_FAILED, - ESI_KICK_PENDING, - ESI_KICK_SENT, - ESI_KICK_INPROGRESS -} esiKick_t; +typedef esiContext::esiKick_t esiKick_t; /* some core operators */ @@ -447,95 +443,6 @@ esiOtherwise(esiTreeParentPtr aParent) : esiSequence (aParent) {} }; -/* esiContext */ -class esiContext : public esiTreeParent { -public: - void *operator new (size_t byteCount); - void operator delete (void *address); - void deleteSelf() const; - esiContext():reading_(true) {} - ~esiContext(); - - /* when esi processing completes */ - void provideData(ESISegment *, ESIElement *source); - void fail (ESIElement *source); - void startRead(); - void finishRead(); - bool reading() const; - void setError(); - - void addStackElement (ESIElement::Pointer element); - void addLiteral (const XML_Char *s, int len); - - void finishChildren (); - - clientStreamNode *thisNode; /* our stream node */ - clientHttpRequest *http; /* the request we are processing. HMM: cbdataReferencing this will result - in a circular reference, so we don't. Note: we are automatically freed when it is, so thats ok. */ - struct { - int passthrough:1; - int oktosend:1; - int finished:1; - int error:1; /* an error has occured, send full body replies - * regardless. Note that we don't fail midstream - * because we buffer until we can not fail - */ - int finishedtemplate:1; /* we've read the entire template */ - int clientwantsdata:1; /* we need to satisfy a read request */ - int kicked:1; /* note on reentering the kick routine */ - int parsing:1; /* libexpat is not reentrant on the same context */ - int detached:1; /* our downstream has detached */ - } flags; - err_type errorpage; /* if we error what page to use */ - http_status errorstatus; /* if we error, what code to return */ - char *errormessage; /* error to pass to error page */ - HttpReply *rep; /* buffered until we pass data downstream */ - ESISegment *buffered; /* unprocessed data - for whatever reason */ - ESISegment *incoming; - ESISegment *outbound; /* processed data we are waiting to send, or for - * potential errors to be resolved - */ - ESISegment *outboundtail; /* our write segment */ - size_t outbound_offset; /* the offset to the next character to send - - * non zero if we haven't sent the entire segment - * for some reason - */ - off_t readpos; /* the logical position we are reading from */ - off_t pos; /* the logical position of outbound_offset in the data stream */ - class ParserState{ - public: - ESIElement::Pointer stack[10]; /* a stack of esi elements that are open */ - int stackdepth; /* self explanatory */ - XML_Parser p; /* our parser */ - ESIElement::Pointer top(); - void init (void *); - bool inited() const; - ParserState(); - void freeResources(); - void popAll(); - private: - bool inited_; - } parserState; /* todo factor this off somewhere else; */ - esiVarState *varState; - ESIElement::Pointer tree; - - esiKick_t kick (); - RefCount cbdataLocker; - bool failed() const {return flags.error != 0;} -private: - CBDATA_CLASS(esiContext); - void fail (); - void freeResources(); - void fixupOutboundTail(); - void trimBlanks(); - size_t send (); - bool reading_; - void appendOutboundData(ESISegment *theData); - esiProcessResult_t process (); - void parse(); - void parseOneBuffer(); -}; - CBDATA_CLASS_INIT(esiContext); void esiContext::startRead() { @@ -736,15 +643,15 @@ /* Ok, not passing through */ switch (context->kick ()) { - case ESI_KICK_FAILED: + case esiContext::ESI_KICK_FAILED: /* this can not happen - processing can't fail until we have data, * and when we come here we have sent data to the client */ - case ESI_KICK_SENT: - case ESI_KICK_INPROGRESS: + case esiContext::ESI_KICK_SENT: + case esiContext::ESI_KICK_INPROGRESS: cbdataReferenceDone (context); return; - case ESI_KICK_PENDING: + case esiContext::ESI_KICK_PENDING: break; } @@ -1078,17 +985,17 @@ } switch (context->kick()) { - case ESI_KICK_FAILED: + case esiContext::ESI_KICK_FAILED: /* thisNode can not happen - processing can't fail until we have data, * and when we come here we have sent data to the client */ cbdataReferenceDone (context); return; - case ESI_KICK_SENT: - case ESI_KICK_INPROGRESS: + case esiContext::ESI_KICK_SENT: + case esiContext::ESI_KICK_INPROGRESS: cbdataReferenceDone (context); return; - case ESI_KICK_PENDING: + case esiContext::ESI_KICK_PENDING: break; } --- /dev/null Wed Feb 14 12:14:22 2007 +++ squid3/src/ESIContext.h Wed Feb 14 12:14:49 2007 @@ -0,0 +1,135 @@ +/* + * $Id: ESIContext.h,v 1.1.2.1 2002/12/22 05:35:56 rbcollins Exp $ + * + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; 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. + * + */ + +#ifndef SQUID_ESICONTEXT_H +#define SQUID_ESICONTEXT_H + +#include "ESIElement.h" + +class esiVarState; + +/* esiContext */ +class esiContext : public esiTreeParent { +public: + void *operator new (size_t byteCount); + void operator delete (void *address); + void deleteSelf() const; + esiContext():reading_(true) {} + ~esiContext(); + + enum esiKick_t { + ESI_KICK_FAILED, + ESI_KICK_PENDING, + ESI_KICK_SENT, + ESI_KICK_INPROGRESS + }; + + /* when esi processing completes */ + void provideData(ESISegment *, ESIElement *source); + void fail (ESIElement *source); + void startRead(); + void finishRead(); + bool reading() const; + void setError(); + + void addStackElement (ESIElement::Pointer element); + void addLiteral (const XML_Char *s, int len); + + void finishChildren (); + + clientStreamNode *thisNode; /* our stream node */ + clientHttpRequest *http; /* the request we are processing. HMM: cbdataReferencing this will result + in a circular reference, so we don't. Note: we are automatically freed when it is, so thats ok. */ + struct { + int passthrough:1; + int oktosend:1; + int finished:1; + int error:1; /* an error has occured, send full body replies + * regardless. Note that we don't fail midstream + * because we buffer until we can not fail + */ + int finishedtemplate:1; /* we've read the entire template */ + int clientwantsdata:1; /* we need to satisfy a read request */ + int kicked:1; /* note on reentering the kick routine */ + int parsing:1; /* libexpat is not reentrant on the same context */ + int detached:1; /* our downstream has detached */ + } flags; + err_type errorpage; /* if we error what page to use */ + http_status errorstatus; /* if we error, what code to return */ + char *errormessage; /* error to pass to error page */ + HttpReply *rep; /* buffered until we pass data downstream */ + ESISegment *buffered; /* unprocessed data - for whatever reason */ + ESISegment *incoming; + ESISegment *outbound; /* processed data we are waiting to send, or for + * potential errors to be resolved + */ + ESISegment *outboundtail; /* our write segment */ + size_t outbound_offset; /* the offset to the next character to send - + * non zero if we haven't sent the entire segment + * for some reason + */ + off_t readpos; /* the logical position we are reading from */ + off_t pos; /* the logical position of outbound_offset in the data stream */ + class ParserState{ + public: + ESIElement::Pointer stack[10]; /* a stack of esi elements that are open */ + int stackdepth; /* self explanatory */ + XML_Parser p; /* our parser */ + ESIElement::Pointer top(); + void init (void *); + bool inited() const; + ParserState(); + void freeResources(); + void popAll(); + private: + bool inited_; + } parserState; /* todo factor this off somewhere else; */ + esiVarState *varState; + ESIElement::Pointer tree; + + esiKick_t kick (); + RefCount cbdataLocker; + bool failed() const {return flags.error != 0;} +private: + CBDATA_CLASS(esiContext); + void fail (); + void freeResources(); + void fixupOutboundTail(); + void trimBlanks(); + size_t send (); + bool reading_; + void appendOutboundData(ESISegment *theData); + esiProcessResult_t process (); + void parse(); + void parseOneBuffer(); +}; +#endif /* SQUID_ESICONTEXT_H */ Index: squid3/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Makefile.am,v retrieving revision 1.4.2.3 retrieving revision 1.4.2.4 diff -u -r1.4.2.3 -r1.4.2.4 --- squid3/src/Makefile.am 19 Dec 2002 11:25:49 -0000 1.4.2.3 +++ squid3/src/Makefile.am 22 Dec 2002 05:35:56 -0000 1.4.2.4 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.4.2.3 2002/12/19 11:25:49 rbcollins Exp $ +# $Id: Makefile.am,v 1.4.2.4 2002/12/22 05:35:56 rbcollins Exp $ # # Uncomment and customize the following to suit your needs: # @@ -26,7 +26,7 @@ DELAY_POOL_SOURCE = endif -ESI_ALL_SOURCE = ESI.cc ESI.h ESIElement.h ESIExpression.cc \ +ESI_ALL_SOURCE = ESI.cc ESI.h ESIContext.h ESIElement.h ESIExpression.cc \ ESISegment.cc ESISegment.h if USE_ESI ESI_SOURCE = $(ESI_ALL_SOURCE)