]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alex Rousskov <rousskov@measurement-factory.com>
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 30 Mar 2009 11:44:37 +0000 (00:44 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 30 Mar 2009 11:44:37 +0000 (00:44 +1300)
SourceLayout: esi/, take 1

Moved src/ESI* files into src/esi/.
Renamed ESI source files from ESIFoo.{cc,cci,h} to Foo.{cc,cci,h}.

Replaced implicit constructor-based Parser registration with an explicit call
to Esi::Init() which knows of all ESI parsers. Added Esi::Clean counterpart.

Made libTrie build conditional on ESI support being enabled.

No true source code changes except for parser initialization.
No functionality changes were intended.
No runtime tests with ESI performed.

TODO: I did not move the tests/ESIExpressions test into src/esi because
  we need to fix the entire testing layout before we should start
  moving individual tests: They currently depend on individual source
  and object files in src/ and in tests/ and that kind of dependency
  should not be multiplied but removed.

TODO: Move ESI types into the Esi namespace.

42 files changed:
configure.in
lib/Makefile.am
src/Makefile.am
src/Store.h
src/cache_cf.cc
src/client_side_reply.cc
src/esi/Assign.cc [moved from src/ESIAssign.cc with 98% similarity]
src/esi/Assign.h [moved from src/ESIAssign.h with 98% similarity]
src/esi/Attempt.h [moved from src/ESIAttempt.h with 97% similarity]
src/esi/Context.cc [moved from src/ESIContext.cc with 99% similarity]
src/esi/Context.h [moved from src/ESIContext.h with 99% similarity]
src/esi/CustomParser.cc [moved from src/ESICustomParser.cc with 99% similarity]
src/esi/CustomParser.h [moved from src/ESICustomParser.h with 97% similarity]
src/esi/Element.h [moved from src/ESIElement.h with 99% similarity]
src/esi/ElementList.h [moved from src/ElementList.h with 98% similarity]
src/esi/Esi.cc [moved from src/ESI.cc with 99% similarity]
src/esi/Esi.h [moved from src/ESI.h with 100% similarity]
src/esi/Except.h [moved from src/ESIExcept.h with 97% similarity]
src/esi/ExpatParser.cc [moved from src/ESIExpatParser.cc with 97% similarity]
src/esi/ExpatParser.h [moved from src/ESIExpatParser.h with 96% similarity]
src/esi/Expression.cc [moved from src/ESIExpression.cc with 99% similarity]
src/esi/Expression.h [moved from src/ESIExpression.h with 100% similarity]
src/esi/Include.cc [moved from src/ESIInclude.cc with 99% similarity]
src/esi/Include.h [moved from src/ESIInclude.h with 97% similarity]
src/esi/Libxml2Parser.cc [moved from src/ESILibxml2Parser.cc with 98% similarity]
src/esi/Libxml2Parser.h [moved from src/ESILibxml2Parser.h with 97% similarity]
src/esi/Literal.h [moved from src/ESILiteral.h with 98% similarity]
src/esi/Makefile.am [new file with mode: 0644]
src/esi/Module.cc [new file with mode: 0644]
src/esi/Module.h [new file with mode: 0644]
src/esi/Parser.cc [moved from src/ESIParser.cc with 82% similarity]
src/esi/Parser.h [moved from src/ESIParser.h with 89% similarity]
src/esi/Segment.cc [moved from src/ESISegment.cc with 99% similarity]
src/esi/Segment.h [moved from src/ESISegment.h with 100% similarity]
src/esi/Sequence.cc [moved from src/ESISequence.cc with 99% similarity]
src/esi/Sequence.h [moved from src/ESISequence.h with 98% similarity]
src/esi/Var.h [moved from src/ESIVar.h with 97% similarity]
src/esi/VarState.cc [moved from src/ESIVarState.cc with 99% similarity]
src/esi/VarState.h [moved from src/ESIVarState.h with 99% similarity]
src/main.cc
test-suite/ESIExpressions.cc
test-suite/Makefile.am

index 63e46597f4f1432f52c24f57e527bb49f63695c0..1bd2ca9217f0f1da4be179dce3d3589be662c735 100644 (file)
@@ -3791,6 +3791,7 @@ AC_CONFIG_FILES([\
        src/adaptation/Makefile \
        src/adaptation/icap/Makefile \
        src/adaptation/ecap/Makefile \
+       src/esi/Makefile \
        src/icmp/Makefile \
        src/ip/Makefile \
        contrib/Makefile \
index 8cd9e72ced2b6b61b2eadc3b6295a153da8179f4..ab4274d77e2db73dd0a7b4fb336ad1f04c4fef0c 100644 (file)
@@ -3,12 +3,16 @@
 #  $Id$
 #
 
-SUBDIRS = libTrie
+SUBDIRS =
 
 if USE_LOADABLE_MODULES
 SUBDIRS += libLtdl
 endif
 
+if USE_ESI
+SUBDIRS += libTrie
+endif
+
 CLEANFILES =
 
 
@@ -89,10 +93,8 @@ libmiscutil_a_SOURCES = \
        xusleep.c \
        $(XPROF_STATS_SOURCE) \
        $(WIN32SRC)
-libmiscutil_a_LIBADD = \
-       libTrie/src/Trie.o \
-       libTrie/src/TrieNode.o \
-       @LIBOBJS@
+libmiscutil_a_LIBADD = @LIBOBJS@
+
 # $(top_srcdir)/include/version.h should be a dependency
 libntlmauth_a_SOURCES = \
        ntlmauth.c
index c13c848ea51c8b11e05fc3d8ce2420ed33d98836..7bbd6539ec4898a28aceb3980a2bc7ef917bfac2 100644 (file)
@@ -40,6 +40,15 @@ endif
 
 ADAPTATION_LIBS = @ADAPTATION_LIBS@
 
+if USE_ESI
+SUBDIRS += esi
+ESI_LIBS = \
+       esi/libesi.la \
+       $(top_builddir)/lib/libTrie/src/libTrie.a
+else
+ESI_LIBS = 
+endif
+
 DELAY_POOL_ALL_SOURCE = \
        CommonPool.h \
        CompositePoolNode.h \
@@ -70,43 +79,6 @@ else
 DELAY_POOL_SOURCE = 
 endif
 
-ESI_ALL_SOURCE = \
-       ElementList.h \
-       ESI.cc \
-       ESI.h \
-       ESIAssign.cc \
-       ESIAssign.h \
-       ESIAttempt.h \
-       ESIContext.cc \
-       ESIContext.h \
-       ESICustomParser.cc \
-       ESICustomParser.h \
-       ESIElement.h \
-       ESIExcept.h \
-       ESIExpatParser.cc \
-       ESIExpatParser.h \
-       ESIExpression.cc \
-       ESIExpression.h \
-       ESIInclude.cc \
-       ESIInclude.h \
-       ESILiteral.h \
-       ESILibxml2Parser.cc \
-       ESILibxml2Parser.h \
-       ESIParser.cc \
-       ESIParser.h \
-       ESISegment.cc \
-       ESISegment.h \
-       ESISequence.cc \
-       ESISequence.h \
-       ESIVar.h \
-       ESIVarState.cc \
-       ESIVarState.h
-if USE_ESI
-  ESI_SOURCE = $(ESI_ALL_SOURCE)
-else
-  ESI_SOURCE = 
-endif
-
 if ENABLE_XPROF_STATS
 XPROF_STATS_SOURCE = ProfStats.cc
 else
@@ -203,7 +175,6 @@ INCLUDES = \
        -I$(top_srcdir)/src \
        -I$(top_builddir)/include \
        -I$(top_srcdir)/include \
-       -I$(top_srcdir)/lib/libTrie/include \
        -I$(top_builddir)/lib \
        -I$(top_srcdir)/lib \
        @SQUID_CPPUNIT_INC@
@@ -280,7 +251,6 @@ EXTRA_squid_SOURCES = \
        ipc.cc \
        ipc_win32.cc \
        $(IDENT_ALL_SOURCE) \
-       $(ESI_ALL_SOURCE) \
        ProfStats.cc \
        LeakFinder.cc \
        LeakFinder.h \
@@ -374,7 +344,6 @@ squid_SOURCES = \
        enums.h \
        errorpage.cc \
        errorpage.h \
-       $(ESI_SOURCE) \
        ETag.cc \
        event.cc \
        event.h \
@@ -569,6 +538,7 @@ squid_LDADD = \
        @REGEXLIB@ \
        @SNMPLIB@ \
        ${ADAPTATION_LIBS} \
+       ${ESI_LIBS} \
        @SSLLIB@ \
        -lmiscutil \
        @XTRA_LIBS@ \
@@ -1072,7 +1042,6 @@ tests_testCacheManager_SOURCES = \
        dlink.cc \
        $(DNSSOURCE) \
        errorpage.cc \
-       $(ESI_SOURCE) \
        ETag.cc \
        external_acl.cc \
        ExternalACLEntry.cc \
@@ -1170,6 +1139,7 @@ tests_testCacheManager_LDADD = \
        icmp/libicmp.la icmp/libicmp-core.la \
        @REPL_OBJS@ \
        ${ADAPTATION_LIBS} \
+       ${ESI_LIBS} \
        @REGEXLIB@ \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
@@ -1241,7 +1211,6 @@ tests_testEvent_SOURCES = \
        dlink.cc \
        $(DNSSOURCE) \
        errorpage.cc \
-       $(ESI_SOURCE) \
        ETag.cc \
        external_acl.cc \
        ExternalACLEntry.cc \
@@ -1338,6 +1307,7 @@ tests_testEvent_LDADD = \
        icmp/libicmp.la icmp/libicmp-core.la \
        @REPL_OBJS@ \
        ${ADAPTATION_LIBS} \
+       ${ESI_LIBS} \
        @REGEXLIB@ \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
@@ -1388,7 +1358,6 @@ tests_testEventLoop_SOURCES = \
        dlink.cc \
        $(DNSSOURCE) \
        errorpage.cc \
-       $(ESI_SOURCE) \
        ETag.cc \
        external_acl.cc \
        ExternalACLEntry.cc \
@@ -1485,6 +1454,7 @@ tests_testEventLoop_LDADD = \
        icmp/libicmp.la icmp/libicmp-core.la \
        @REPL_OBJS@ \
        ${ADAPTATION_LIBS} \
+       ${ESI_LIBS} \
        @REGEXLIB@ \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
@@ -1524,7 +1494,6 @@ tests_test_http_range_SOURCES = \
        dlink.cc \
        $(DNSSOURCE) \
        errorpage.cc \
-       $(ESI_SOURCE) \
        ETag.cc \
        external_acl.cc \
        ExternalACLEntry.cc \
@@ -1628,6 +1597,7 @@ tests_test_http_range_LDADD = \
        @REPL_OBJS@ \
        @STORE_LIBS_TO_ADD@ \
        ${ADAPTATION_LIBS} \
+       ${ESI_LIBS} \
        @REGEXLIB@ \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
@@ -1677,7 +1647,6 @@ tests_testHttpRequest_SOURCES = \
        dlink.cc \
        $(DNSSOURCE) \
        errorpage.cc \
-       $(ESI_SOURCE) \
        ETag.cc \
        external_acl.cc \
        ExternalACLEntry.cc \
@@ -1775,6 +1744,7 @@ tests_testHttpRequest_LDADD = \
        icmp/libicmp.la icmp/libicmp-core.la \
        @REPL_OBJS@ \
        ${ADAPTATION_LIBS} \
+       ${ESI_LIBS} \
        @REGEXLIB@ \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
@@ -2026,7 +1996,6 @@ tests_testURL_SOURCES = \
        dlink.cc \
        $(DNSSOURCE) \
        errorpage.cc \
-       $(ESI_SOURCE) \
        ETag.cc \
        external_acl.cc \
        ExternalACLEntry.cc \
@@ -2122,6 +2091,7 @@ tests_testURL_LDADD = \
        @REGEXLIB@ \
        @REPL_OBJS@ \
        ${ADAPTATION_LIBS} \
+       ${ESI_LIBS} \
        @SNMPLIB@ \
        -L../lib -lmiscutil \
        @SQUID_CPPUNIT_LIBS@ \
index 8e60c2413a4b36db5e47c16414ab9f66b638b0c9..1d6ebf3d464ed1713dad7f829b1c6c2bb9789ac9 100644 (file)
@@ -50,7 +50,7 @@
 #include "RemovalPolicy.h"
 
 #if USE_SQUID_ESI
-#include "ESIElement.h"
+#include "esi/Element.h"
 #endif
 
 class AsyncCall;
index bec35bf316d1a7f270ef3f3fa840969983104e60..0bed7904eab69a8e93be49f22f106c0bbdbd759d 100644 (file)
@@ -57,7 +57,7 @@
 #include "snmp.h"
 #endif
 #if USE_SQUID_ESI
-#include "ESIParser.h"
+#include "esi/Parser.h"
 #endif
 
 #if USE_ADAPTATION
index 1d62ea48f58fe6755954d6e5d38e47c7555cd2c9..57a51e1a034c5a4bbe48135591aba732814c6d60 100644 (file)
@@ -48,7 +48,7 @@
 #include "clientStream.h"
 #include "auth/UserRequest.h"
 #if USE_SQUID_ESI
-#include "ESI.h"
+#include "esi/Esi.h"
 #endif
 #include "MemObject.h"
 #include "fde.h"
similarity index 98%
rename from src/ESIAssign.cc
rename to src/esi/Assign.cc
index 3efc390638ed0c31a95efd7c27c5f65fe6b27a40..6b5aed741e402e56303934817ab1dd3d2924b5ef 100644 (file)
@@ -40,9 +40,9 @@
  */
 #if (USE_SQUID_ESI == 1)
 
-#include "ESIAssign.h"
-#include "ESIContext.h"
-#include "ESISequence.h"
+#include "esi/Assign.h"
+#include "esi/Context.h"
+#include "esi/Sequence.h"
 
 ESIAssign::~ESIAssign()
 {
similarity index 98%
rename from src/ESIAssign.h
rename to src/esi/Assign.h
index c107d5012628896775393edb09815bf648a7fe72..fd9fa12947d79972387b98aa07a1bbc05401ede3 100644 (file)
@@ -37,9 +37,9 @@
 #define SQUID_ESIASSIGN_H
 
 #include "squid.h"
-#include "ESIElement.h"
+#include "esi/Element.h"
 #include "SquidString.h"
-#include "ESIVarState.h"
+#include "esi/VarState.h"
 
 /* ESIVariableExpression */
 /* This is a variable that is itself and expression */
similarity index 97%
rename from src/ESIAttempt.h
rename to src/esi/Attempt.h
index f09d67971c83b2dd6b576c028811ec6bfd0d0b33..e7b0f5d5e995ff5608d2377107635cc40930f473 100644 (file)
@@ -37,8 +37,8 @@
 #define SQUID_ESIATTEMPT_H
 
 #include "squid.h"
-#include "ESIElement.h"
-#include "ESISequence.h"
+#include "esi/Element.h"
+#include "esi/Sequence.h"
 
 /* esiAttempt */
 
similarity index 99%
rename from src/ESIContext.cc
rename to src/esi/Context.cc
index 841313a0bf62b8f9e1d643681cbe5abe7f235b79..2db6adbcf551fc17c1e8e685ab16dc12b4c0e707 100644 (file)
@@ -40,7 +40,7 @@
  */
 #if (USE_SQUID_ESI == 1)
 
-#include "ESIContext.h"
+#include "esi/Context.h"
 #include "Store.h"
 #include "client_side_request.h"
 
similarity index 99%
rename from src/ESIContext.h
rename to src/esi/Context.h
index 5416a2cf41e3b941ba82713bb51acf86ae225b29..bf958dc59e9f59044fb5a55636b7e222398e9202 100644 (file)
 #ifndef SQUID_ESICONTEXT_H
 #define SQUID_ESICONTEXT_H
 
-#include "ESIElement.h"
+#include "esi/Element.h"
 #include "clientStream.h"
 
 class ESIVarState;
 
 class ClientHttpRequest;
 
-#include "ESIParser.h"
+#include "esi/Parser.h"
 
 /* ESIContext */
 
similarity index 99%
rename from src/ESICustomParser.cc
rename to src/esi/CustomParser.cc
index b59880d009856888112bd6318753c8002c5d3e55..d9bfba8f43ef8f6fd12d29197fbc9af34894e6d4 100644 (file)
  */
 
 #include "squid.h"
-#include "ESICustomParser.h"
+#include "esi/CustomParser.h"
 #include "Trie.h"
 #include "TrieCharTransform.h"
 #include "Array.h"
 
 Trie *ESICustomParser::SearchTrie=NULL;
 
-RegisterESIParser("custom", ESICustomParser);
+EsiParserDefinition(ESICustomParser);
 
 Trie *
 ESICustomParser::GetTrie()
similarity index 97%
rename from src/ESICustomParser.h
rename to src/esi/CustomParser.h
index 146a4ac44413b965d2356b527da7dc95a1106575..7bc2b9a3f76e980bf85ce5bddc9fbe969f658345 100644 (file)
@@ -35,7 +35,7 @@
 class Trie;
 
 /* inherits from */
-#include "ESIParser.h"
+#include "esi/Parser.h"
 
 /* for String variables */
 #include "SquidString.h"
@@ -54,8 +54,9 @@ public:
     long int lineNumber() const;
     char const * errorString() const;
 
+    EsiParserDeclaration;
+
 private:
-    ESI_PARSER_TYPE;
     static Trie *SearchTrie;
     static Trie *GetTrie();
     enum ESITAG_t {
similarity index 99%
rename from src/ESIElement.h
rename to src/esi/Element.h
index ef773bd153dc36a263b855081860a8ac0de13d58..b2f6d0c393fc71d3dddcce2b5ad9156d2ca58dd2 100644 (file)
@@ -34,7 +34,7 @@
 #define SQUID_ESIELEMENT_H
 
 #include "RefCount.h"
-#include "ESISegment.h"
+#include "esi/Segment.h"
 
 typedef enum {
     ESI_PROCESS_COMPLETE = 0,
similarity index 98%
rename from src/ElementList.h
rename to src/esi/ElementList.h
index aa7bef2bf317aa8c68be24cb4ab2037ac2cf8685..15ff033b0a52a47c27a0512364ee3922b1f2de15 100644 (file)
@@ -37,7 +37,7 @@
 #define SQUID_ELEMENTLIST_H
 
 #include "squid.h"
-#include "ESIElement.h"
+#include "esi/Element.h"
 
 class ElementList
 {
similarity index 99%
rename from src/ESI.cc
rename to src/esi/Esi.cc
index 875e8b25df9e4e62184d7b084eaecb8b68284744..d41513ea9e5ab8be47c8d437cf73ca934dad4fb6 100644 (file)
  */
 #if (USE_SQUID_ESI == 1)
 
-#include "ESI.h"
+#include "esi/Esi.h"
 #include "clientStream.h"
 #include "client_side_request.h"
 #include "errorpage.h"
-#include "ESISegment.h"
-#include "ESIElement.h"
-#include "ESIContext.h"
+#include "esi/Segment.h"
+#include "esi/Element.h"
+#include "esi/Context.h"
 #include "HttpHdrSc.h"
 #include "HttpHdrScTarget.h"
 #include "HttpReply.h"
-#include "ESIAttempt.h"
-#include "ESIExcept.h"
+#include "esi/Attempt.h"
+#include "esi/Except.h"
 #include "client_side.h"
-#include "ESIVarState.h"
-#include "ESIAssign.h"
-#include "ESIExpression.h"
+#include "esi/VarState.h"
+#include "esi/Assign.h"
+#include "esi/Expression.h"
 #include "HttpRequest.h"
 #include "MemBuf.h"
 #include "ip/IpAddress.h"
@@ -116,11 +116,11 @@ struct esiComment : public ESIElement {
 
 MEMPROXY_CLASS_INLINE(esiComment)              /**DOCS_NOSEMI*/
 
-#include "ESILiteral.h"
+#include "esi/Literal.h"
 
-#include "ESISequence.h"
+#include "esi/Sequence.h"
 
-#include "ESIInclude.h"
+#include "esi/Include.h"
 
 /* esiRemove */
 
@@ -181,7 +181,7 @@ private:
 
 MEMPROXY_CLASS_INLINE(esiTry)          /**DOCS_NOSEMI*/
 
-#include "ESIVar.h"
+#include "esi/Var.h"
 
 /* esiChoose */
 
similarity index 100%
rename from src/ESI.h
rename to src/esi/Esi.h
similarity index 97%
rename from src/ESIExcept.h
rename to src/esi/Except.h
index 9e432d385f9a29b091b4810496f7f159a23490f7..7c684b0cd47d18c9dedc051c389fdae4c9847075 100644 (file)
@@ -37,8 +37,8 @@
 #define SQUID_ESIEXCEPT_H
 
 #include "squid.h"
-#include "ESIElement.h"
-#include "ESISequence.h"
+#include "esi/Element.h"
+#include "esi/Sequence.h"
 
 /* esiExcept */
 
similarity index 97%
rename from src/ESIExpatParser.cc
rename to src/esi/ExpatParser.cc
index d5c1affd7acdd4af92e2080736ae2455cebbd088..6bdb0fd9c182b65a415fc59753f8203fef192063 100644 (file)
@@ -37,9 +37,9 @@
 
 #if USE_SQUID_ESI
 
-#include "ESIExpatParser.h"
+#include "esi/ExpatParser.h"
 
-RegisterESIParser("expat", ESIExpatParser);
+EsiParserDefinition(ESIExpatParser);
 
 ESIExpatParser::ESIExpatParser(ESIParserClient *aClient) : theClient (aClient)
 {
similarity index 96%
rename from src/ESIExpatParser.h
rename to src/esi/ExpatParser.h
index 32d48fb1ff09e1d4bab982b494eeb83be2261f8a..dfc5045a514190ce517a5be0206ed2791b17114e 100644 (file)
@@ -35,8 +35,8 @@
 
 #if USE_SQUID_ESI
 
-#include "ESIParser.h"
-#include "expat.h"
+#include "esi/Parser.h"
+#include <expat.h>
 
 class ESIExpatParser : public ESIParser
 {
@@ -51,8 +51,9 @@ public:
     long int lineNumber() const;
     char const * errorString() const;
 
+    EsiParserDeclaration;
+
 private:
-    ESI_PARSER_TYPE;
     /** our parser */
     mutable XML_Parser p;
     static void Start(void *data, const XML_Char *el, const char **attr);
similarity index 99%
rename from src/ESIExpression.cc
rename to src/esi/Expression.cc
index a831052522384086535a53193f55f424cbf1bf44..759171842d1ca7884b5bf04cfc7f452e6324b1f3 100644 (file)
@@ -34,7 +34,7 @@
  */
 
 #include "squid.h"
-#include "ESIExpression.h"
+#include "esi/Expression.h"
 
 /* stack precedence rules:
  * before pushing an operator onto the stack, the
similarity index 100%
rename from src/ESIExpression.h
rename to src/esi/Expression.h
similarity index 99%
rename from src/ESIInclude.cc
rename to src/esi/Include.cc
index 88d0dd675b3e573b43e7c3c8d1e82f256a261cad..d869b82204b8e137746804eaa1f298df8eace63b 100644 (file)
@@ -41,8 +41,8 @@
  */
 #if (USE_SQUID_ESI == 1)
 
-#include "ESIInclude.h"
-#include "ESIVarState.h"
+#include "esi/Include.h"
+#include "esi/VarState.h"
 #include "client_side_request.h"
 #include "HttpReply.h"
 
similarity index 97%
rename from src/ESIInclude.h
rename to src/esi/Include.h
index 6c3e701c88935e10f7adf7f312cf438a33557bea..944a6cfaf49f74f81713a7e951d963a4f7e7d3ea 100644 (file)
@@ -37,9 +37,9 @@
 #define SQUID_ESIINCLUDE_H
 
 #include "squid.h"
-#include "ESISegment.h"
-#include "ESIElement.h"
-#include "ESIContext.h"
+#include "esi/Segment.h"
+#include "esi/Element.h"
+#include "esi/Context.h"
 
 class ESIInclude;
 typedef RefCount<ESIInclude> ESIIncludePtr;
similarity index 98%
rename from src/ESILibxml2Parser.cc
rename to src/esi/Libxml2Parser.cc
index 8875ba9c2226d3b2ff63a88fb796077247df314d..e0fc3562cc4740707d0a0d6134e713970fa43206 100644 (file)
 
 #if USE_SQUID_ESI
 
-#include "ESILibxml2Parser.h"
+#include "esi/Libxml2Parser.h"
 
 // the global document that will store the resolved entity
 // definitions
 static htmlDocPtr entity_doc = NULL;
 
-RegisterESIParser("libxml2", ESILibxml2Parser);
+EsiParserDefinition(ESILibxml2Parser);
 
 // the SAX callback functions
 void esi_startElementSAXFunc(void * ctx, const xmlChar * name, const xmlChar ** atts)
similarity index 97%
rename from src/ESILibxml2Parser.h
rename to src/esi/Libxml2Parser.h
index 21ac43f68f864079268761a62d138fcd502e2faf..c360930bb9589dcfdf1ef33200a789dcf3cce248 100644 (file)
@@ -42,7 +42,7 @@
 
 #if USE_SQUID_ESI
 
-#include "ESIParser.h"
+#include "esi/Parser.h"
 // workaround for definition of "free" that prevents include of
 // parser.h from libxml2 without errors
 #ifdef free
@@ -70,8 +70,9 @@ public:
 
     ESIParserClient *getClient() { return theClient; }
 
+    EsiParserDeclaration;
+
 private:
-    ESI_PARSER_TYPE;
     mutable xmlParserCtxtPtr parser; /* our parser */
 
     ESIParserClient *theClient;
similarity index 98%
rename from src/ESILiteral.h
rename to src/esi/Literal.h
index a6e49571ec456dc6a4d74d3f4b870f484da0fa0d..19f53b58465a446f40c09d712f0dac19a84096f0 100644 (file)
@@ -37,7 +37,7 @@
 #define SQUID_ESILITERAL_H
 
 #include "squid.h"
-#include "ESIElement.h"
+#include "esi/Element.h"
 
 class ESIContext;
 /* esiLiteral */
diff --git a/src/esi/Makefile.am b/src/esi/Makefile.am
new file mode 100644 (file)
index 0000000..bbd58b7
--- /dev/null
@@ -0,0 +1,43 @@
+include $(top_srcdir)/src/Common.am
+include $(top_srcdir)/src/TestHeaders.am
+
+noinst_LTLIBRARIES = libesi.la
+
+libesi_la_SOURCES = \
+       Assign.cc \
+       Assign.h \
+       Attempt.h \
+       Context.cc \
+       Context.h \
+       CustomParser.cc \
+       CustomParser.h \
+       Element.h \
+       ElementList.h \
+       Esi.cc \
+       Esi.h \
+       Except.h \
+       ExpatParser.cc \
+       ExpatParser.h \
+       Expression.cc \
+       Expression.h \
+       Include.cc \
+       Include.h \
+       Literal.h \
+       Libxml2Parser.cc \
+       Libxml2Parser.h \
+       Module.cc \
+       Module.h \
+       Parser.cc \
+       Parser.h \
+       Segment.cc \
+       Segment.h \
+       Sequence.cc \
+       Sequence.h \
+       Var.h \
+       VarState.cc \
+       VarState.h
+
+INCLUDES += \
+       -I$(top_srcdir)/lib/libTrie/include \
+       -I$(top_builddir)/lib/libTrie/include
+
diff --git a/src/esi/Module.cc b/src/esi/Module.cc
new file mode 100644 (file)
index 0000000..cbc91c7
--- /dev/null
@@ -0,0 +1,28 @@
+#include "squid.h"
+#include "esi/Module.h"
+#include "esi/CustomParser.h"
+#include "esi/Libxml2Parser.h"
+#include "esi/ExpatParser.h" /* must follow esi/Libxml2Parser.h */
+
+static ESIParser::Register *prCustom = 0;
+static ESIParser::Register *prLibxml = 0;
+static ESIParser::Register *prExpat = 0;
+
+void Esi::Init() {
+    assert(!prCustom); // we should be called once
+    prCustom = new ESIParser::Register("custom", &ESICustomParser::NewParser);
+    prLibxml = new ESIParser::Register("libxml2", &ESILibxml2Parser::NewParser);
+    prExpat = new ESIParser::Register("expat", &ESIExpatParser::NewParser);
+}
+
+void Esi::Clean() {
+    assert(prCustom); // we should be called once, and only after Init()
+
+    delete prExpat;
+    delete prLibxml;
+    delete prCustom;
+
+    prExpat = NULL;
+    prLibxml = NULL;
+    prCustom = NULL;
+}
diff --git a/src/esi/Module.h b/src/esi/Module.h
new file mode 100644 (file)
index 0000000..98483a9
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef SQUID_ESI_MODULE_H
+#define SQUID_ESI_MODULE_H
+
+namespace Esi {
+
+    extern void Init();
+    extern void Clean();
+
+}; // namespace Esi
+
+#endif /* SQUID_ESI_MODULE_H */
similarity index 82%
rename from src/ESIParser.cc
rename to src/esi/Parser.cc
index 778e9bf5f921da2a58871fbae63be3d7210091d1..1b656071b1b80237fe0dce2e711a1e28da52a3ba 100644 (file)
@@ -33,7 +33,7 @@
  */
 
 #include "squid.h"
-#include "ESIParser.h"
+#include "esi/Parser.h"
 
 char *ESIParser::Type = NULL;
 ESIParser::Register *ESIParser::Parsers = NULL;
@@ -54,3 +54,14 @@ ESIParser::NewParser(ESIParserClient *aClient)
 
     return (Parser->newParser)(aClient);
 }
+
+ESIParser::Register::Register(const char *_name, ESIParser::Pointer (*_newParser)(ESIParserClient *aClient)) : name(_name), newParser(_newParser) {
+    this->next = ESIParser::Parsers;
+    ESIParser::Parsers = this;
+}
+
+ESIParser::Register::~Register() {
+    // TODO: support random-order deregistration
+    assert(ESIParser::Parsers == this);
+    ESIParser::Parsers = next;
+}
similarity index 89%
rename from src/ESIParser.h
rename to src/esi/Parser.h
index e6bbfb196207b1d5b37a7b4311764daffb858f2d..13ac18d4f331f8391fb909eabce7652db85f7c3c 100644 (file)
@@ -52,6 +52,7 @@ public:
 class ESIParser : public RefCountable
 {
 public:
+    class Register;
     typedef RefCount<ESIParser> Pointer;
 
     static void registerParser(const char *name, Pointer (*new_func)(ESIParserClient *aClient));
@@ -70,8 +71,6 @@ public:
 protected:
     ESIParser() {};
 
-    class Register;
-
 private:
     static Register *Parser;
     static Register *Parsers;
@@ -83,26 +82,21 @@ class ESIParser::Register
 {
 
 public:
-    Register(const char *_name, ESIParser::Pointer (*_newParser)(ESIParserClient *aClient)) : name(_name), newParser(_newParser) {
-        this->next = ESIParser::Parsers;
-        ESIParser::Parsers = this;
-    }
+    Register(const char *_name, ESIParser::Pointer (*_newParser)(ESIParserClient *aClient));
+    ~Register();
 
     const char *name;
     ESIParser::Pointer (*newParser)(ESIParserClient *aClient);
     Register * next;
 };
 
-#define RegisterESIParser(name, ThisClass) \
-    ESIParser::Register ThisClass::thisParser(name, &NewParser); \
+#define EsiParserDefinition(ThisClass) \
     ESIParser::Pointer ThisClass::NewParser(ESIParserClient *aClient) \
     { \
        return new ThisClass (aClient); \
     }
 
-#define ESI_PARSER_TYPE \
-    static ESIParser::Pointer NewParser(ESIParserClient *aClient); \
-    static ESIParser::Register thisParser
-
+#define EsiParserDeclaration \
+    static ESIParser::Pointer NewParser(ESIParserClient *aClient)
 
 #endif /* SQUID_ESIPARSER_H */
similarity index 99%
rename from src/ESISegment.cc
rename to src/esi/Segment.cc
index d82e5185e582c9808beefbb7eff69dab6625fd5a..a6f9df604d7ec915137ff1e53884d1516ee91026 100644 (file)
@@ -34,7 +34,7 @@
  */
 
 #include "squid.h"
-#include "ESISegment.h"
+#include "esi/Segment.h"
 #include "SquidString.h"
 
 CBDATA_TYPE(ESISegment);
similarity index 100%
rename from src/ESISegment.h
rename to src/esi/Segment.h
similarity index 99%
rename from src/ESISequence.cc
rename to src/esi/Sequence.cc
index 06f4d4fca4a3b7dd602566ce41793bbc5a7358d0..bb4035c7d06c4aa82175ebe3f3f229fa94ed443b 100644 (file)
  */
 #if (USE_SQUID_ESI == 1)
 
-#include "ESISequence.h"
-#include "ESILiteral.h"
-#include "ESIAttempt.h"
-#include "ESIExcept.h"
+#include "esi/Sequence.h"
+#include "esi/Literal.h"
+#include "esi/Attempt.h"
+#include "esi/Except.h"
 
 class esiExcept;
 
similarity index 98%
rename from src/ESISequence.h
rename to src/esi/Sequence.h
index f72d1e0f1ae9bdc9a1e3d349c6a63262abd505b4..9c5193cafbc7f361d52f72b44d830f992e702c4a 100644 (file)
@@ -37,8 +37,8 @@
 #define SQUID_ESISEQUENCE_H
 
 #include "squid.h"
-#include "ESIElement.h"
-#include "ElementList.h"
+#include "esi/Element.h"
+#include "esi/ElementList.h"
 
 /* esiSequence */
 
similarity index 97%
rename from src/ESIVar.h
rename to src/esi/Var.h
index bdff8c58f193075978e24901d1765c5e3473a113..412414ced7e6a27c250315c512be8de9d92949f2 100644 (file)
@@ -37,8 +37,8 @@
 #define SQUID_ESIVAR_H
 
 #include "squid.h"
-#include "ESIElement.h"
-#include "ESISequence.h"
+#include "esi/Element.h"
+#include "esi/Sequence.h"
 
 /* esiVar */
 
similarity index 99%
rename from src/ESIVarState.cc
rename to src/esi/VarState.cc
index be147a128d69cfee3273973c379a6b8378480fd7..8e7d5f9d919e26e027736129e6d7ae533b815987 100644 (file)
@@ -35,7 +35,7 @@
  */
 
 #include "squid.h"
-#include "ESIVarState.h"
+#include "esi/VarState.h"
 #include "HttpReply.h"
 
 CBDATA_TYPE (ESIVarState);
similarity index 99%
rename from src/ESIVarState.h
rename to src/esi/VarState.h
index 66c34ecaacef4991b736b7aaf1e70a0aef469132..ec66d45342882f581c9843df5b95222f4c55c8b4 100644 (file)
@@ -34,7 +34,7 @@
 #ifndef SQUID_ESIVARSTATE_H
 #define SQUID_ESIVARSTATE_H
 
-#include "ESISegment.h"
+#include "esi/Segment.h"
 #include "Trie.h"
 #include "Array.h"
 #include "HttpHeader.h"
index d02d90e0ab754337264df26a4cc6008829741c60..09e17929d52aea59350bd2b10369fae63eb6ef6b 100644 (file)
 #include "adaptation/Config.h"
 #endif
 
+#if USE_SQUID_ESI
+#include "esi/Module.h"
+#endif
+
 #if USE_WIN32_SERVICE
 
 #include "squid_windows.h"
@@ -1061,6 +1065,9 @@ mainInitialize(void)
     Adaptation::Config::Finalize(enableAdaptation);
 #endif
 
+#if USE_SQUID_ESI
+    Esi::Init();
+#endif
 
     debugs(1, 1, "Ready to serve requests.");
 
@@ -1671,6 +1678,11 @@ SquidShutdown()
 
     releaseServerSockets();
     commCloseAllSockets();
+
+#if USE_SQUID_ESI
+    Esi::Clean();
+#endif
+
 #if DELAY_POOLS
 
     DelayPools::FreePools();
index 182be9fc118e003a2411ce4c436949e6b53ac007..d7ccbf14eb2fd3a571647a0c55b83c07fc2f1a82 100644 (file)
@@ -34,7 +34,7 @@
  */
 
 #include "squid.h"
-#include "ESIExpression.h"
+#include "esi/Expression.h"
 
 int
 main ()
index e9f5ddc85470975fbdca22d824765fc794002b19..2718487481732c68a82c0d3a5f68c832f2ee32c5 100644 (file)
@@ -66,7 +66,7 @@ tcp_banger2_LDADD = -L$(top_builddir)/lib -lmiscutil
 DEBUG_SOURCE = test_tools.cc
 debug_SOURCES = debug.cc $(DEBUG_SOURCE)
 ESIExpressions_SOURCES = ESIExpressions.cc $(DEBUG_SOURCE)
-ESIExpressions_LDADD = $(top_builddir)/src/ESIExpression.o \
+ESIExpressions_LDADD = $(top_builddir)/src/esi/Expression.o \
                $(LDADD)
 mem_node_test_SOURCES = mem_node_test.cc
 mem_node_test_LDADD = $(top_builddir)/src/mem_node.o $(LDADD)