--------------------- PatchSet 109 Date: 2002/11/01 09:22:07 Author: rbcollins Branch: esi Tag: (none) Log: removing process macro Members: src/ESI.cc:1.1.2.17->1.1.2.18 Index: squid3/src/ESI.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESI.cc,v retrieving revision 1.1.2.17 retrieving revision 1.1.2.18 diff -u -r1.1.2.17 -r1.1.2.18 --- squid3/src/ESI.cc 1 Nov 2002 09:01:55 -0000 1.1.2.17 +++ squid3/src/ESI.cc 1 Nov 2002 09:22:07 -0000 1.1.2.18 @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.1.2.17 2002/11/01 09:01:55 rbcollins Exp $ + * $Id: ESI.cc,v 1.1.2.18 2002/11/01 09:22:07 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -188,16 +188,9 @@ return ((esiElement *)data)->process(dovars); } -static esiProcessSelf esiSequenceProcess; - -static esiProcessSelf esiIncludeProcess; struct esiInclude; static void esiIncludeSubRequestDone (esiInclude *, esiStreamContext *, int); -static esiProcessSelf esiTryProcess; - -static esiProcessSelf esiChooseProcess; - /* the types we have */ typedef enum { ESI_ELEMENT_NONE, @@ -215,18 +208,17 @@ static esiElementType _esiComment = {processThunk}; static esiElementType _esiLiteral = {processThunk}; -static esiElementType _esiSequence = {esiSequenceProcess}; -static esiElementType _esiInclude = {esiIncludeProcess}; +static esiElementType _esiSequence = {processThunk}; +static esiElementType _esiInclude = {processThunk}; static esiElementType _esiRemove = {processThunk}; -static esiElementType _esiTry = {esiTryProcess}; +static esiElementType _esiTry = {processThunk}; /* esiAttempt, esiExcept, esiVar, esiWhen and esiOtherwise are 'Sequences' */ -static esiElementType _esiAttempt = {esiSequenceProcess}; -static esiElementType _esiExcept = {esiSequenceProcess}; -static esiElementType _esiVar = {esiSequenceProcess}; -static esiElementType _esiChoose = {esiChooseProcess}; -static esiElementType _esiWhen = {esiSequenceProcess}; -static esiElementType _esiOtherwise= {esiSequenceProcess}; - +static esiElementType _esiAttempt = {processThunk}; +static esiElementType _esiExcept = {processThunk}; +static esiElementType _esiVar = {processThunk}; +static esiElementType _esiChoose = {processThunk}; +static esiElementType _esiWhen = {processThunk}; +static esiElementType _esiOtherwise= {processThunk}; /* esiComment */ struct esiComment : public esiElement { @@ -272,6 +264,7 @@ esiSequence(); void render(esiSegment *); bool addElement (esiElement *); + esiProcessResult_t process (int dovars); esiElement ** elements; /* unprocessed or rendered nodes */ int allocedcount; size_t allocedsize; @@ -294,6 +287,7 @@ esiInclude(int attributes, const char **attr, esiContext *); void render(esiSegment *); + esiProcessResult_t process (int dovars); struct { int onerrorcontinue:1; /* on error return zero data */ int failed:1; /* Failed to process completely */ @@ -342,6 +336,7 @@ esiTry(); void render(esiSegment *); bool addElement (esiElement *); + esiProcessResult_t process (int dovars); esiElement *attempt; esiElement *except; struct { @@ -368,6 +363,7 @@ esiChoose(); void render(esiSegment *); bool addElement (esiElement *); + esiProcessResult_t process (int dovars); esiElement ** elements; /* unprocessed nodes */ int allocedcount; size_t allocedsize; @@ -1921,23 +1917,22 @@ } esiProcessResult_t -esiSequenceProcess (void *data, int dovars) +esiSequence::process (int dovars) { /* process as much of the list as we can, stopping only on * faliures */ - esiSequence *thisNode = (esiSequence *)data; int i; esiProcessResult_t rv = ESI_PROCESS_COMPLETE; - if (thisNode->flags.dovars) + if (flags.dovars) dovars = 1; - for (i = thisNode->processedcount; i < thisNode->elementcount; ++i) { - switch (PROCESS(thisNode->elements[i], dovars)){ + for (i = processedcount; i < elementcount; ++i) { + switch (PROCESS(elements[i], dovars)){ case ESI_PROCESS_COMPLETE: debug (86,5)("esiSequenceProcess: element Processed OK\n"); - if (i == thisNode->processedcount) + if (i == processedcount) /* another completely ready */ - ++thisNode->processedcount; + ++processedcount; break; case ESI_PROCESS_PENDING_WONTFAIL: debug (86,5)("esiSequenceProcess: element Processed PENDING OK\n"); @@ -1955,7 +1950,7 @@ break; } } - assert (rv != ESI_PROCESS_COMPLETE || thisNode->processedcount == thisNode->elementcount); + assert (rv != ESI_PROCESS_COMPLETE || processedcount == elementcount); return rv; } @@ -2100,18 +2095,17 @@ } esiProcessResult_t -esiIncludeProcess (void *data, int dovars) +esiInclude::process (int dovars) { - esiInclude *thisNode = (esiInclude *)data; - debug (86, 5)("esiIncludeRender: Processing include %p\n", thisNode); - if (thisNode->flags.failed) { - if (thisNode->flags.onerrorcontinue) + debug (86, 5)("esiIncludeRender: Processing include %p\n", this); + if (flags.failed) { + if (flags.onerrorcontinue) return ESI_PROCESS_COMPLETE; else return ESI_PROCESS_FAILED; } - if (!thisNode->flags.finished) { - if (thisNode->flags.onerrorcontinue) + if (!flags.finished) { + if (flags.onerrorcontinue) return ESI_PROCESS_PENDING_WONTFAIL; else return ESI_PROCESS_PENDING_MAYFAIL; @@ -2335,25 +2329,24 @@ } esiProcessResult_t -esiTryProcess (void *data, int dovars) +esiTry::process (int dovars) { - esiTry *thisNode = (esiTry *)data; esiProcessResult_t rv = ESI_PROCESS_PENDING_MAYFAIL; - assert (thisNode); - if (!thisNode->attempt) { + assert (this); + if (!attempt) { debug (86,0)("esiTryProcess: Try has no attempt element - ESI template is invalid (section 3.4)\n"); return ESI_PROCESS_FAILED; } - if (!thisNode->except) { + if (!except) { debug (86,0)("esiTryProcess: Try has no except element - ESI template is invalid (section 3.4)\n"); return ESI_PROCESS_FAILED; } - if (!thisNode->flags.attemptfailed) + if (!flags.attemptfailed) /* Try the attempt branch */ - switch ((rv = PROCESS(thisNode->attempt, dovars))){ + switch ((rv = PROCESS(attempt, dovars))){ case ESI_PROCESS_COMPLETE: debug (86,5)("esiTryProcess: attempt Processed OK\n"); - thisNode->flags.attemptok = 1; + flags.attemptok = 1; return ESI_PROCESS_COMPLETE; case ESI_PROCESS_PENDING_WONTFAIL: debug (86,5)("esiTryProcess: attempt Processed PENDING OK\n"); @@ -2364,18 +2357,18 @@ break; case ESI_PROCESS_FAILED: debug (86,5)("esiSequenceProcess: elemen Processed FAILED\n"); - thisNode->flags.attemptfailed = 1; + flags.attemptfailed = 1; break; } /* attempt is either MAYFAIL or FAILED */ /* query except to see if it has a definite result */ - if (!thisNode->flags.exceptfailed) + if (!flags.exceptfailed) /* Try the except branch */ - switch (PROCESS(thisNode->except, dovars)){ + switch (PROCESS(except, dovars)){ case ESI_PROCESS_COMPLETE: debug (86,5)("esiTryProcess: except Processed OK\n"); - thisNode->flags.exceptok = 1; - if (thisNode->flags.attemptfailed) + flags.exceptok = 1; + if (flags.attemptfailed) return ESI_PROCESS_COMPLETE; else return ESI_PROCESS_PENDING_MAYFAIL; @@ -2389,11 +2382,11 @@ return ESI_PROCESS_PENDING_MAYFAIL; case ESI_PROCESS_FAILED: debug (86,5)("esiSequenceProcess: element Processed FAILED\n"); - thisNode->flags.exceptfailed = 1; + flags.exceptfailed = 1; break; } - if (thisNode->flags.exceptfailed && thisNode->flags.attemptfailed) + if (flags.exceptfailed && flags.attemptfailed) return ESI_PROCESS_FAILED; /* one of attempt or except returned PENDING MAYFAIL */ return ESI_PROCESS_PENDING_MAYFAIL; @@ -3080,19 +3073,18 @@ } esiProcessResult_t -esiChooseProcess (void *data, int dovars) +esiChoose::process (int dovars) { /* process as much of the list as we can, stopping only on * faliures */ - esiChoose *thisNode = (esiChoose *)data; /* We MUST have a when clause */ - if (!thisNode->elementcount) + if (!elementcount) return ESI_PROCESS_FAILED; - else if (thisNode->chosenelement >= 0) { - return PROCESS(thisNode->elements[thisNode->chosenelement], dovars); - } else if (thisNode->otherwise) - return PROCESS(thisNode->otherwise, dovars); + else if (chosenelement >= 0) { + return PROCESS(elements[chosenelement], dovars); + } else if (otherwise) + return PROCESS(otherwise, dovars); else return ESI_PROCESS_COMPLETE; }