]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alex Rousskov <rousskov@measurement-factory.com>
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 8 Mar 2009 13:26:07 +0000 (02:26 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 8 Mar 2009 13:26:07 +0000 (02:26 +1300)
SourceLayout: adaptation/{icap,ecap}, take 1 with tweaks

Moved src/ICAP into src/adaptation/icap.
Moved src/eCAP into src/adaptation/ecap.

Renamed ICAP source files from ICAPFoo.{cc,h} to Foo.{cc,h}.

Placed ICAP names into Adaptation::Icap namespace, renaming ICAPFoo to
Adaptation::Icap::Foo.

Moved Ecap namespace into Adaptation namespace.

47 files changed:
configure.in
src/ICAP/ICAPClient.cc [deleted file]
src/ICAP/ICAPOptXact.cc [deleted file]
src/ICAP/Makefile.am [deleted file]
src/Makefile.am
src/adaptation/AccessCheck.cc
src/adaptation/Config.cc
src/adaptation/Makefile.am
src/adaptation/ecap/Config.cc [new file with mode: 0644]
src/adaptation/ecap/Config.h [moved from src/eCAP/Config.h with 88% similarity]
src/adaptation/ecap/Host.cc [moved from src/eCAP/Host.cc with 76% similarity]
src/adaptation/ecap/Host.h [moved from src/eCAP/Host.h with 93% similarity]
src/adaptation/ecap/Makefile.am [new file with mode: 0644]
src/adaptation/ecap/MessageRep.cc [moved from src/eCAP/MessageRep.cc with 72% similarity]
src/adaptation/ecap/MessageRep.h [moved from src/eCAP/MessageRep.h with 94% similarity]
src/adaptation/ecap/MinimalAdapter.cc [moved from src/eCAP/MinimalAdapter.cc with 100% similarity]
src/adaptation/ecap/Registry.h [moved from src/eCAP/Registry.h with 100% similarity]
src/adaptation/ecap/ServiceRep.cc [moved from src/eCAP/ServiceRep.cc with 56% similarity]
src/adaptation/ecap/ServiceRep.h [moved from src/eCAP/ServiceRep.h with 95% similarity]
src/adaptation/ecap/XactionRep.cc [moved from src/eCAP/XactionRep.cc with 80% similarity]
src/adaptation/ecap/XactionRep.h [moved from src/eCAP/XactionRep.h with 96% similarity]
src/adaptation/icap/Client.cc [new file with mode: 0644]
src/adaptation/icap/Client.h [moved from src/ICAP/ICAPClient.h with 91% similarity]
src/adaptation/icap/Config.cc [moved from src/ICAP/ICAPConfig.cc with 81% similarity]
src/adaptation/icap/Config.h [moved from src/ICAP/ICAPConfig.h with 86% similarity]
src/adaptation/icap/Elements.cc [moved from src/ICAP/ICAPElements.cc with 55% similarity]
src/adaptation/icap/Elements.h [moved from src/ICAP/ICAPElements.h with 95% similarity]
src/adaptation/icap/InOut.h [moved from src/ICAP/ICAPInOut.h with 94% similarity]
src/adaptation/icap/Launcher.cc [moved from src/ICAP/ICAPLauncher.cc with 67% similarity]
src/adaptation/icap/Launcher.h [moved from src/ICAP/ICAPLauncher.h with 85% similarity]
src/adaptation/icap/Makefile.am [new file with mode: 0644]
src/adaptation/icap/ModXact.cc [moved from src/ICAP/ICAPModXact.cc with 80% similarity]
src/adaptation/icap/ModXact.h [moved from src/ICAP/ICAPModXact.h with 90% similarity]
src/adaptation/icap/OptXact.cc [new file with mode: 0644]
src/adaptation/icap/OptXact.h [moved from src/ICAP/ICAPOptXact.h with 73% similarity]
src/adaptation/icap/Options.cc [moved from src/ICAP/ICAPOptions.cc with 69% similarity]
src/adaptation/icap/Options.h [moved from src/ICAP/ICAPOptions.h with 91% similarity]
src/adaptation/icap/ServiceRep.cc [moved from src/ICAP/ICAPServiceRep.cc with 63% similarity]
src/adaptation/icap/ServiceRep.h [moved from src/ICAP/ICAPServiceRep.h with 90% similarity]
src/adaptation/icap/Xaction.cc [moved from src/ICAP/ICAPXaction.cc with 67% similarity]
src/adaptation/icap/Xaction.h [moved from src/ICAP/ICAPXaction.h with 90% similarity]
src/cache_cf.cc
src/cbdata.h
src/cf.data.pre
src/eCAP/Config.cc [deleted file]
src/eCAP/Makefile.am [deleted file]
src/main.cc

index facfc673454317463495a78adac08704413d2be3..200c0346dec22b4df2fe53da2a94f8f52178e213 100644 (file)
@@ -810,7 +810,7 @@ AC_ARG_ENABLE(icap-client,
 if test "$use_icap_client" = "yes" ; then
   AC_DEFINE(ICAP_CLIENT,1,[Enable ICAP client features in Squid])
   AM_CONDITIONAL(USE_ICAP_CLIENT, true)
-  ICAP_LIBS="ICAP/libicap.la"
+  ICAP_LIBS="icap/libicap.la"
   use_adaptation=yes
 else
   AC_DEFINE(ICAP_CLIENT,0,[Enable ICAP client features in Squid])
@@ -857,7 +857,7 @@ AM_CONDITIONAL(USE_ECAP, test $use_ecap = yes)
 if test $use_ecap = yes;
 then
     AC_DEFINE(USE_ECAP,1,[Enable eCAP support])
-    ECAP_LIBS="eCAP/libeCAP.la $ECAP_LIBS"
+    ECAP_LIBS="ecap/libecap.la $ECAP_LIBS"
     use_adaptation=yes
 else
     AC_DEFINE(USE_ECAP,0,[Disable eCAP support])
@@ -3798,10 +3798,10 @@ AC_CONFIG_FILES([\
        src/repl/Makefile \
        src/auth/Makefile \
        src/adaptation/Makefile \
-       src/ICAP/Makefile \
+       src/adaptation/icap/Makefile \
+       src/adaptation/ecap/Makefile \
        src/icmp/Makefile \
        src/ip/Makefile \
-       src/eCAP/Makefile \
        contrib/Makefile \
        snmplib/Makefile \
        icons/Makefile \
diff --git a/src/ICAP/ICAPClient.cc b/src/ICAP/ICAPClient.cc
deleted file mode 100644 (file)
index df2fd49..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "squid.h"
-#include "ICAPClient.h"
-
-void ICAPInitModule()
-{
-    debugs(93,2, "ICAP Client module enabled.");
-}
-
-void ICAPCleanModule()
-{
-}
diff --git a/src/ICAP/ICAPOptXact.cc b/src/ICAP/ICAPOptXact.cc
deleted file mode 100644 (file)
index 92c42aa..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * DEBUG: section 93    ICAP (RFC 3507) Client
- */
-
-#include "squid.h"
-#include "comm.h"
-#include "HttpReply.h"
-
-#include "ICAPOptXact.h"
-#include "ICAPOptions.h"
-#include "TextException.h"
-
-CBDATA_CLASS_INIT(ICAPOptXact);
-CBDATA_CLASS_INIT(ICAPOptXactLauncher);
-
-
-ICAPOptXact::ICAPOptXact(Adaptation::Initiator *anInitiator, ICAPServiceRep::Pointer &aService):
-        AsyncJob("ICAPOptXact"),
-        ICAPXaction("ICAPOptXact", anInitiator, aService)
-{
-}
-
-void ICAPOptXact::start()
-{
-    ICAPXaction::start();
-
-    openConnection();
-}
-
-void ICAPOptXact::handleCommConnected()
-{
-    scheduleRead();
-
-    MemBuf requestBuf;
-    requestBuf.init();
-    makeRequest(requestBuf);
-    debugs(93, 9, "ICAPOptXact request " << status() << ":\n" <<
-           (requestBuf.terminate(), requestBuf.content()));
-
-    scheduleWrite(requestBuf);
-}
-
-void ICAPOptXact::makeRequest(MemBuf &buf)
-{
-    const Adaptation::Service &s = service();
-    const String uri = s.cfg().uri;
-    buf.Printf("OPTIONS " SQUIDSTRINGPH " ICAP/1.0\r\n", SQUIDSTRINGPRINT(uri));
-    const String host = s.cfg().host;
-    buf.Printf("Host: " SQUIDSTRINGPH ":%d\r\n", SQUIDSTRINGPRINT(host), s.cfg().port);
-    buf.append(ICAP::crlf, 2);
-}
-
-void ICAPOptXact::handleCommWrote(size_t size)
-{
-    debugs(93, 9, "ICAPOptXact finished writing " << size <<
-           "-byte request " << status());
-}
-
-// comm module read a portion of the ICAP response for us
-void ICAPOptXact::handleCommRead(size_t)
-{
-    if (HttpMsg *r = parseResponse()) {
-        sendAnswer(r);
-        Must(done()); // there should be nothing else to do
-        return;
-    }
-
-    scheduleRead();
-}
-
-HttpMsg *ICAPOptXact::parseResponse()
-{
-    debugs(93, 5, HERE << "have " << readBuf.contentSize() << " bytes to parse" <<
-           status());
-    debugs(93, 5, HERE << "\n" << readBuf.content());
-
-    HttpReply *r = new HttpReply;
-    r->protoPrefix = "ICAP/"; // TODO: make an IcapReply class?
-
-    if (!parseHttpMsg(r)) { // throws on errors
-        delete r;
-        return 0;
-    }
-
-    if (httpHeaderHasConnDir(&r->header, "close"))
-        reuseConnection = false;
-
-    return r;
-}
-
-/* ICAPOptXactLauncher */
-
-ICAPOptXactLauncher::ICAPOptXactLauncher(Adaptation::Initiator *anInitiator, Adaptation::ServicePointer aService):
-        AsyncJob("ICAPOptXactLauncher"),
-        ICAPLauncher("ICAPOptXactLauncher", anInitiator, aService)
-{
-}
-
-ICAPXaction *ICAPOptXactLauncher::createXaction()
-{
-    ICAPServiceRep::Pointer s =
-        dynamic_cast<ICAPServiceRep*>(theService.getRaw());
-    Must(s != NULL);
-    return new ICAPOptXact(this, s);
-}
diff --git a/src/ICAP/Makefile.am b/src/ICAP/Makefile.am
deleted file mode 100644 (file)
index d9b7163..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-AM_CFLAGS = @SQUID_CFLAGS@
-AM_CXXFLAGS = @SQUID_CXXFLAGS@
-CLEANFILES =
-
-INCLUDES = \
-       -I$(top_srcdir) \
-       -I$(top_builddir)/include \
-       -I$(top_srcdir)/include \
-        -I$(top_srcdir)/src
-
-noinst_LTLIBRARIES = libicap.la
-
-libicap_la_SOURCES = \
-       ICAPClient.cc \
-       ICAPClient.h \
-       ICAPInOut.h \
-       ICAPConfig.cc \
-       ICAPConfig.h \
-       ICAPElements.cc \
-       ICAPElements.h \
-       ICAPOptions.cc \
-       ICAPOptions.h \
-       ICAPServiceRep.cc \
-       ICAPServiceRep.h \
-       ICAPLauncher.cc \
-       ICAPLauncher.h \
-       ICAPOptXact.cc \
-       ICAPOptXact.h \
-       ICAPXaction.cc \
-       ICAPXaction.h \
-       ICAPModXact.cc \
-       ICAPModXact.h
-
-
-check_PROGRAMS = testHeaders
-
-## test .h correctness
-testHeaders: $(top_srcdir)/src/ICAP/*.h
-       $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "." || exit 1
-
-## No such file...
-testHeaders.c:
-       touch testHeaders.c
-CLEANFILES += testHeaders.c
index 5765cde3f1b12871eed2d9eda72e3ecf663805fe..d2570621249ce6d71598b9eed312a681f5ccfbc4 100644 (file)
@@ -38,15 +38,7 @@ if USE_ADAPTATION
 SUBDIRS += adaptation
 endif
 
-if USE_ICAP_CLIENT
-SUBDIRS += ICAP
-endif
-
-if USE_ECAP
-SUBDIRS += eCAP
-endif
-
-ADAPTATION_LIBS = @ECAP_LIBS@ @ICAP_LIBS@ @ADAPTATION_LIBS@
+ADAPTATION_LIBS = @ADAPTATION_LIBS@
 
 DELAY_POOL_ALL_SOURCE = \
        CommonPool.h \
index 290e0b3b290a668a78a8862d6eaf8252b8e93b45..0ecf67b2cdfb2cef0611b86f61291aeaee74ce9d 100644 (file)
@@ -52,7 +52,7 @@ Adaptation::AccessCheck::AccessCheck(Method aMethod,
 
     acl_checklist = NULL;
 
-    debugs(93, 5, "AccessCheck constructed for " << methodStr(method) << " " << vectPointStr(point));
+    debugs(93, 5, HERE << "AccessCheck constructed for " << methodStr(method) << " " << vectPointStr(point));
 }
 
 Adaptation::AccessCheck::~AccessCheck()
@@ -70,7 +70,7 @@ Adaptation::AccessCheck::~AccessCheck()
 void
 Adaptation::AccessCheck::check()
 {
-    debugs(93, 4, "Adaptation::AccessCheck::check");
+    debugs(93, 4, HERE << "start checking");
 
     typedef AccessRules::iterator ARI;
     for (ARI i = AllRules().begin(); i != AllRules().end(); ++i) {
@@ -84,7 +84,7 @@ Adaptation::AccessCheck::check()
         AccessRule *r = *i;
         ServicePointer service = findBestService(*r, false);
         if (service != NULL) {
-            debugs(93, 5, "Adaptation::AccessCheck::check: rule '" << r->id << "' has candidate service '" << service->cfg().key << "'");
+            debugs(93, 5, HERE << "check: rule '" << r->id << "' has candidate service '" << service->cfg().key << "'");
             candidates += r->id;
         }
     }
@@ -100,7 +100,7 @@ Adaptation::AccessCheck::check()
 void
 Adaptation::AccessCheck::checkCandidates()
 {
-    debugs(93, 4, "Adaptation::AccessCheck has " << candidates.size() << " rules");
+    debugs(93, 4, HERE << "has " << candidates.size() << " rules");
 
     while (!candidates.empty()) {
         if (AccessRule *r = FindRule(topCandidate())) {
@@ -116,14 +116,14 @@ Adaptation::AccessCheck::checkCandidates()
     }
 
     // when there are no canidates, fake answer 1
-    debugs(93, 4, "Adaptation::AccessCheck::check: NO candidates left");
+    debugs(93, 4, HERE << "NO candidates left");
     noteAnswer(1);
 }
 
 void
 Adaptation::AccessCheck::AccessCheckCallbackWrapper(int answer, void *data)
 {
-    debugs(93, 8, "AccessCheckCallbackWrapper: answer=" << answer);
+    debugs(93, 8, HERE << "callback answer=" << answer);
     AccessCheck *ac = (AccessCheck*)data;
 
     /** \todo AYJ 2008-06-12: If answer == ACCESS_REQ_PROXY_AUTH
@@ -156,7 +156,7 @@ Adaptation::AccessCheck::noteAnswer(int answer)
 void
 Adaptation::AccessCheck::do_callback()
 {
-    debugs(93, 3, "Adaptation::AccessCheck::do_callback");
+    debugs(93, 3, HERE);
 
     if (candidates.size())
         debugs(93, 3, HERE << "was checking rule" << topCandidate());
index ae46c454957b8505e1d27eca5dccdc13e2c60edb..cbc19f2ebd779929e6cb85dd81595a52e4d58288 100644 (file)
@@ -82,7 +82,7 @@ Adaptation::Config::finalize()
     // create service reps from service configs
     typedef Vector<ServiceConfig*>::const_iterator VISCI;
     const Vector<ServiceConfig*> &configs = serviceConfigs;
-    debugs(93,3, "Found " << configs.size() << " service configs.");
+    debugs(93,3, HERE << "Found " << configs.size() << " service configs.");
     for (VISCI i = configs.begin(); i != configs.end(); ++i) {
         const ServiceConfig &cfg = **i;
         if (FindService(cfg.key) != NULL) {
@@ -95,7 +95,7 @@ Adaptation::Config::finalize()
             AllServices().push_back(s);
     }
 
-    debugs(93,3, "Created " << configs.size() <<
+    debugs(93,3, HERE << "Created " << configs.size() <<
            " message adaptation services.");
 }
 
@@ -108,7 +108,7 @@ FinalizeEach(Collection &collection, const char *label)
     for (CI i = collection.begin(); i != collection.end(); ++i)
         (*i)->finalize();
 
-    debugs(93,2, "Initialized " << collection.size() << ' ' << label);
+    debugs(93,2, HERE << "Initialized " << collection.size() << ' ' << label);
 }
 
 void
index dcb27e2b6e04c11004538f996c91f551090b6f6b..0942fd25fc5f798598f6e6f34c7b0b4b241bc05f 100644 (file)
@@ -1,15 +1,20 @@
-AM_CFLAGS = @SQUID_CFLAGS@
-AM_CXXFLAGS = @SQUID_CXXFLAGS@
-CLEANFILES =
+include $(top_srcdir)/src/Common.am
+include $(top_srcdir)/src/TestHeaders.am
 
-INCLUDES = \
-       -I$(top_srcdir) \
-       -I$(top_builddir)/include \
-       -I$(top_srcdir)/include \
-        -I$(top_srcdir)/src
+## make a list of directories for configured adaptation schemes
+SUBDIRS =
+
+if USE_ICAP_CLIENT
+SUBDIRS += icap
+endif
+
+if USE_ECAP
+SUBDIRS += ecap
+endif
 
 noinst_LTLIBRARIES = libadaptation.la
 
+## start with the code shared among all adaptation schemes
 libadaptation_la_SOURCES = \
        AccessCheck.cc \
        AccessCheck.h \
@@ -33,13 +38,6 @@ libadaptation_la_SOURCES = \
        ServiceGroups.cc \
        ServiceGroups.h
 
-check_PROGRAMS = testHeaders
-
-## test .h correctness
-testHeaders: $(top_srcdir)/src/adaptation/*.h
-       $(top_srcdir)/test-suite/testheaders.sh "$(CXXCOMPILE)" "." || exit 1
+# add libraries for specific adaptation schemes
+libadaptation_la_LIBADD = @ECAP_LIBS@ @ICAP_LIBS@
 
-## No such file...
-testHeaders.c:
-       touch testHeaders.c
-CLEANFILES += testHeaders.c
diff --git a/src/adaptation/ecap/Config.cc b/src/adaptation/ecap/Config.cc
new file mode 100644 (file)
index 0000000..17d30c8
--- /dev/null
@@ -0,0 +1,37 @@
+
+/*
+ * $Id$
+ */
+
+#include "squid.h"
+
+#include <libecap/common/registry.h>
+#include "adaptation/ecap/Host.h"
+#include "adaptation/ecap/ServiceRep.h"
+#include "adaptation/ecap/Config.h"
+
+Adaptation::Ecap::Config Adaptation::Ecap::TheConfig;
+
+Adaptation::Ecap::Config::Config()
+{
+}
+
+Adaptation::Ecap::Config::~Config()
+{
+}
+
+void
+Adaptation::Ecap::Config::finalize()
+{
+    Adaptation::Config::finalize();
+    libecap::shared_ptr<Adaptation::Ecap::Host> host(new Adaptation::Ecap::Host);
+    libecap::RegisterHost(host);
+}
+
+Adaptation::ServicePointer
+Adaptation::Ecap::Config::createService(const Adaptation::ServiceConfig &cfg)
+{
+    Adaptation::ServicePointer s = new Adaptation::Ecap::ServiceRep(cfg);
+    return s.getRaw();
+}
+
similarity index 88%
rename from src/eCAP/Config.h
rename to src/adaptation/ecap/Config.h
index 5f3e11d1a9e93c4bb8ac09d164733ab2bf5d2e60..9e2f69f0e70c3c16b15001554cbedeb41f81b0ca 100644 (file)
@@ -9,8 +9,8 @@
 
 #include "adaptation/Config.h"
 
-namespace Ecap
-{
+namespace Adaptation {
+namespace Ecap {
 
 class Config: public Adaptation::Config
 {
@@ -31,5 +31,6 @@ private:
 extern Config TheConfig;
 
 } // namespace Ecap
+} // namespace Adaptation
 
 #endif /* SQUID_ECAP_CONFIG_H */
similarity index 76%
rename from src/eCAP/Host.cc
rename to src/adaptation/ecap/Host.cc
index 9fae209313fcb5adc2c59326661c27b2eb8ac56d..62995d2661c246f0d666032bd4285ea6a838b617 100644 (file)
@@ -2,17 +2,17 @@
 #include <libecap/adapter/service.h>
 #include <libecap/common/names.h>
 #include "TextException.h"
-#include "eCAP/ServiceRep.h"
-#include "eCAP/Host.h"
+#include "adaptation/ecap/ServiceRep.h"
+#include "adaptation/ecap/Host.h"
 
-const libecap::Name Ecap::protocolInternal("internal", libecap::Name::NextId());
-const libecap::Name Ecap::protocolCacheObj("cache_object", libecap::Name::NextId());
-const libecap::Name Ecap::protocolIcp("ICP", libecap::Name::NextId());
+const libecap::Name Adaptation::Ecap::protocolInternal("internal", libecap::Name::NextId());
+const libecap::Name Adaptation::Ecap::protocolCacheObj("cache_object", libecap::Name::NextId());
+const libecap::Name Adaptation::Ecap::protocolIcp("ICP", libecap::Name::NextId());
 #if USE_HTCP
-const libecap::Name Ecap::protocolHtcp("Htcp", libecap::Name::NextId());
+const libecap::Name Adaptation::Ecap::protocolHtcp("Htcp", libecap::Name::NextId());
 #endif
 
-Ecap::Host::Host()
+Adaptation::Ecap::Host::Host()
 {
     // assign our host-specific IDs to well-known names
     libecap::headerReferer.assignHostId(HDR_REFERER);
@@ -33,19 +33,19 @@ Ecap::Host::Host()
 }
 
 std::string
-Ecap::Host::uri() const
+Adaptation::Ecap::Host::uri() const
 {
     return "ecap://squid-cache.org/ecap/hosts/squid";
 }
 
 void
-Ecap::Host::describe(std::ostream &os) const
+Adaptation::Ecap::Host::describe(std::ostream &os) const
 {
     os << PACKAGE_NAME << " v" << PACKAGE_VERSION;
 }
 
 void
-Ecap::Host::noteService(const libecap::weak_ptr<libecap::adapter::Service> &weak)
+Adaptation::Ecap::Host::noteService(const libecap::weak_ptr<libecap::adapter::Service> &weak)
 {
     // Many ecap_service lines may use the same service URI. Find each
     // matching service rep, make sure it is an eCAP rep,
@@ -63,7 +63,7 @@ Ecap::Host::noteService(const libecap::weak_ptr<libecap::adapter::Service> &weak
         }
     }
 
-    debugs(93,5, "Found " << found << " ecap_service configs for " <<
+    debugs(93,5, HERE << "Found " << found << " ecap_service configs for " <<
            shared->uri());
     if (!found) {
         debugs(93,1, "Warning: ignoring loaded eCAP module service without " <<
@@ -87,7 +87,7 @@ SquidLogLevel(libecap::LogVerbosity lv)
 }
 
 std::ostream *
-Ecap::Host::openDebug(libecap::LogVerbosity lv)
+Adaptation::Ecap::Host::openDebug(libecap::LogVerbosity lv)
 {
     const int squidLevel = SquidLogLevel(lv);
     const int squidSection = 93; // XXX: this should be a global constant
@@ -99,7 +99,7 @@ Ecap::Host::openDebug(libecap::LogVerbosity lv)
 }
 
 void
-Ecap::Host::closeDebug(std::ostream *debug)
+Adaptation::Ecap::Host::closeDebug(std::ostream *debug)
 {
     if (debug)
         Debug::finishDebug();
similarity index 93%
rename from src/eCAP/Host.h
rename to src/adaptation/ecap/Host.h
index 48fa1c3fdbaacc4f4c2427108611a84667b25d2c..e0e0ef03ac4c0f4157059bcf265decde21d7c038 100644 (file)
@@ -8,8 +8,8 @@
 
 #include <libecap/host/host.h>
 
-namespace Ecap
-{
+namespace Adaptation {
+namespace Ecap {
 
 // Squid wrapper, providing host application functionality to eCAP services.
 class Host : public libecap::host::Host
@@ -37,5 +37,6 @@ extern const libecap::Name protocolHtcp;
 #endif
 
 } // namespace Ecap
+} // namespace Adaptation
 
 #endif /* SQUID_ECAP_HOST_H */
diff --git a/src/adaptation/ecap/Makefile.am b/src/adaptation/ecap/Makefile.am
new file mode 100644 (file)
index 0000000..3e80f80
--- /dev/null
@@ -0,0 +1,18 @@
+include $(top_srcdir)/src/Common.am
+include $(top_srcdir)/src/TestHeaders.am
+
+noinst_LTLIBRARIES = libecap.la
+
+libecap_la_SOURCES = \
+       Config.h \
+       Config.cc \
+       Host.h \
+       Host.cc \
+       MessageRep.h \
+       MessageRep.cc \
+       ServiceRep.h \
+       ServiceRep.cc \
+       XactionRep.h \
+       XactionRep.cc \
+       \
+       Registry.h
similarity index 72%
rename from src/eCAP/MessageRep.cc
rename to src/adaptation/ecap/MessageRep.cc
index f3b8b298ecf04ac514be16dc4e7696348cad1b72..5888a8867179e2c5e694ff11775b1abbf4bdfbfb 100644 (file)
@@ -7,23 +7,22 @@
 #include "HttpReply.h"
 #include "BodyPipe.h"
 #include "TextException.h"
-#include "adaptation/Message.h"
 #include <libecap/common/names.h>
 #include <libecap/common/area.h>
 #include <libecap/common/version.h>
-#include "eCAP/MessageRep.h"
-#include "eCAP/XactionRep.h"
-#include "eCAP/Host.h" /* for protocol constants */
+#include "adaptation/ecap/MessageRep.h"
+#include "adaptation/ecap/XactionRep.h"
+#include "adaptation/ecap/Host.h" /* for protocol constants */
 
 /* HeaderRep */
 
-Ecap::HeaderRep::HeaderRep(HttpMsg &aMessage): theHeader(aMessage.header),
+Adaptation::Ecap::HeaderRep::HeaderRep(HttpMsg &aMessage): theHeader(aMessage.header),
         theMessage(aMessage)
 {
 }
 
 bool
-Ecap::HeaderRep::hasAny(const Name &name) const
+Adaptation::Ecap::HeaderRep::hasAny(const Name &name) const
 {
     const http_hdr_type squidId = TranslateHeaderId(name);
     // XXX: optimize to remove getByName: we do not need the value here
@@ -32,8 +31,8 @@ Ecap::HeaderRep::hasAny(const Name &name) const
            (bool)theHeader.has(squidId);
 }
 
-Ecap::HeaderRep::Value
-Ecap::HeaderRep::value(const Name &name) const
+Adaptation::Ecap::HeaderRep::Value
+Adaptation::Ecap::HeaderRep::value(const Name &name) const
 {
     const http_hdr_type squidId = TranslateHeaderId(name);
     const String value = squidId == HDR_OTHER ?
@@ -43,7 +42,7 @@ Ecap::HeaderRep::value(const Name &name) const
 }
 
 void
-Ecap::HeaderRep::add(const Name &name, const Value &value)
+Adaptation::Ecap::HeaderRep::add(const Name &name, const Value &value)
 {
     const http_hdr_type squidId = TranslateHeaderId(name); // HDR_OTHER OK
     HttpHeaderEntry *e = new HttpHeaderEntry(squidId, name.image().c_str(),
@@ -52,7 +51,7 @@ Ecap::HeaderRep::add(const Name &name, const Value &value)
 }
 
 void
-Ecap::HeaderRep::removeAny(const Name &name)
+Adaptation::Ecap::HeaderRep::removeAny(const Name &name)
 {
     const http_hdr_type squidId = TranslateHeaderId(name);
     if (squidId == HDR_OTHER)
@@ -62,7 +61,7 @@ Ecap::HeaderRep::removeAny(const Name &name)
 }
 
 libecap::Area
-Ecap::HeaderRep::image() const
+Adaptation::Ecap::HeaderRep::image() const
 {
     MemBuf mb;
     mb.init();
@@ -76,7 +75,7 @@ Ecap::HeaderRep::image() const
 
 // throws on failures
 void
-Ecap::HeaderRep::parse(const Area &buf)
+Adaptation::Ecap::HeaderRep::parse(const Area &buf)
 {
     MemBuf mb;
     mb.init();
@@ -86,7 +85,7 @@ Ecap::HeaderRep::parse(const Area &buf)
 }
 
 http_hdr_type
-Ecap::HeaderRep::TranslateHeaderId(const Name &name)
+Adaptation::Ecap::HeaderRep::TranslateHeaderId(const Name &name)
 {
     if (name.assignedHostId())
         return static_cast<http_hdr_type>(name.hostId());
@@ -96,26 +95,26 @@ Ecap::HeaderRep::TranslateHeaderId(const Name &name)
 
 /* FirstLineRep */
 
-Ecap::FirstLineRep::FirstLineRep(HttpMsg &aMessage): theMessage(aMessage)
+Adaptation::Ecap::FirstLineRep::FirstLineRep(HttpMsg &aMessage): theMessage(aMessage)
 {
 }
 
 libecap::Version
-Ecap::FirstLineRep::version() const
+Adaptation::Ecap::FirstLineRep::version() const
 {
     return libecap::Version(theMessage.http_ver.major,
                             theMessage.http_ver.minor);
 }
 
 void
-Ecap::FirstLineRep::version(const libecap::Version &aVersion)
+Adaptation::Ecap::FirstLineRep::version(const libecap::Version &aVersion)
 {
     theMessage.http_ver.major = aVersion.majr;
     theMessage.http_ver.minor = aVersion.minr;
 }
 
 libecap::Name
-Ecap::FirstLineRep::protocol() const
+Adaptation::Ecap::FirstLineRep::protocol() const
 {
     // TODO: optimize?
     switch (theMessage.protocol) {
@@ -155,14 +154,14 @@ Ecap::FirstLineRep::protocol() const
 }
 
 void
-Ecap::FirstLineRep::protocol(const Name &p)
+Adaptation::Ecap::FirstLineRep::protocol(const Name &p)
 {
     // TODO: what happens if we fail to translate some protocol?
     theMessage.protocol = TranslateProtocolId(p);
 }
 
 protocol_t
-Ecap::FirstLineRep::TranslateProtocolId(const Name &name)
+Adaptation::Ecap::FirstLineRep::TranslateProtocolId(const Name &name)
 {
     if (name.assignedHostId())
         return static_cast<protocol_t>(name.hostId());
@@ -172,13 +171,13 @@ Ecap::FirstLineRep::TranslateProtocolId(const Name &name)
 
 /* RequestHeaderRep */
 
-Ecap::RequestLineRep::RequestLineRep(HttpRequest &aMessage):
+Adaptation::Ecap::RequestLineRep::RequestLineRep(HttpRequest &aMessage):
         FirstLineRep(aMessage), theMessage(aMessage)
 {
 }
 
 void
-Ecap::RequestLineRep::uri(const Area &aUri)
+Adaptation::Ecap::RequestLineRep::uri(const Area &aUri)
 {
     // TODO: if method is not set, urlPath will assume it is not connect;
     // Can we change urlParse API to remove the method parameter?
@@ -189,15 +188,15 @@ Ecap::RequestLineRep::uri(const Area &aUri)
     Must(ok);
 }
 
-Ecap::RequestLineRep::Area
-Ecap::RequestLineRep::uri() const
+Adaptation::Ecap::RequestLineRep::Area
+Adaptation::Ecap::RequestLineRep::uri() const
 {
     return Area::FromTempBuffer(theMessage.urlpath.rawBuf(),
                                 theMessage.urlpath.size());
 }
 
 void
-Ecap::RequestLineRep::method(const Name &aMethod)
+Adaptation::Ecap::RequestLineRep::method(const Name &aMethod)
 {
     if (aMethod.assignedHostId()) {
         const int id = aMethod.hostId();
@@ -211,8 +210,8 @@ Ecap::RequestLineRep::method(const Name &aMethod)
     }
 }
 
-Ecap::RequestLineRep::Name
-Ecap::RequestLineRep::method() const
+Adaptation::Ecap::RequestLineRep::Name
+Adaptation::Ecap::RequestLineRep::method() const
 {
     switch (theMessage.method.id()) {
     case METHOD_GET:
@@ -235,25 +234,25 @@ Ecap::RequestLineRep::method() const
 }
 
 libecap::Version
-Ecap::RequestLineRep::version() const
+Adaptation::Ecap::RequestLineRep::version() const
 {
     return FirstLineRep::version();
 }
 
 void
-Ecap::RequestLineRep::version(const libecap::Version &aVersion)
+Adaptation::Ecap::RequestLineRep::version(const libecap::Version &aVersion)
 {
     FirstLineRep::version(aVersion);
 }
 
 libecap::Name
-Ecap::RequestLineRep::protocol() const
+Adaptation::Ecap::RequestLineRep::protocol() const
 {
     return FirstLineRep::protocol();
 }
 
 void
-Ecap::RequestLineRep::protocol(const Name &p)
+Adaptation::Ecap::RequestLineRep::protocol(const Name &p)
 {
     FirstLineRep::protocol(p);
 }
@@ -261,79 +260,79 @@ Ecap::RequestLineRep::protocol(const Name &p)
 
 /* ReplyHeaderRep */
 
-Ecap::StatusLineRep::StatusLineRep(HttpReply &aMessage):
+Adaptation::Ecap::StatusLineRep::StatusLineRep(HttpReply &aMessage):
         FirstLineRep(aMessage), theMessage(aMessage)
 {
 }
 
 void
-Ecap::StatusLineRep::statusCode(int code)
+Adaptation::Ecap::StatusLineRep::statusCode(int code)
 {
     // TODO: why is .status a enum? Do we not support unknown statuses?
     theMessage.sline.status = static_cast<http_status>(code);
 }
 
 int
-Ecap::StatusLineRep::statusCode() const
+Adaptation::Ecap::StatusLineRep::statusCode() const
 {
     // TODO: see statusCode(code) TODO above
     return static_cast<int>(theMessage.sline.status);
 }
 
 void
-Ecap::StatusLineRep::reasonPhrase(const Area &)
+Adaptation::Ecap::StatusLineRep::reasonPhrase(const Area &)
 {
     // Squid does not support custom reason phrases
     theMessage.sline.reason = NULL;
 }
 
-Ecap::StatusLineRep::Area
-Ecap::StatusLineRep::reasonPhrase() const
+Adaptation::Ecap::StatusLineRep::Area
+Adaptation::Ecap::StatusLineRep::reasonPhrase() const
 {
     return theMessage.sline.reason ?
            Area::FromTempString(std::string(theMessage.sline.reason)) : Area();
 }
 
 libecap::Version
-Ecap::StatusLineRep::version() const
+Adaptation::Ecap::StatusLineRep::version() const
 {
     return FirstLineRep::version();
 }
 
 void
-Ecap::StatusLineRep::version(const libecap::Version &aVersion)
+Adaptation::Ecap::StatusLineRep::version(const libecap::Version &aVersion)
 {
     FirstLineRep::version(aVersion);
 }
 
 libecap::Name
-Ecap::StatusLineRep::protocol() const
+Adaptation::Ecap::StatusLineRep::protocol() const
 {
     return FirstLineRep::protocol();
 }
 
 void
-Ecap::StatusLineRep::protocol(const Name &p)
+Adaptation::Ecap::StatusLineRep::protocol(const Name &p)
 {
     FirstLineRep::protocol(p);
 }
 
 /* BodyRep */
 
-Ecap::BodyRep::BodyRep(const BodyPipe::Pointer &aBody): theBody(aBody)
+Adaptation::Ecap::BodyRep::BodyRep(const BodyPipe::Pointer &aBody): theBody(aBody)
 {
 }
 
 void
-Ecap::BodyRep::tie(const BodyPipe::Pointer &aBody)
+Adaptation::Ecap::BodyRep::tie(const BodyPipe::Pointer &aBody)
 {
     Must(!theBody);
     Must(aBody != NULL);
     theBody = aBody;
 }
 
-Ecap::BodyRep::BodySize
-Ecap::BodyRep::bodySize() const
+Adaptation::Ecap::BodyRep::BodySize
+Adaptation::Ecap::BodyRep::bodySize() const
 {
     return !theBody ? BodySize() : BodySize(theBody->bodySize());
 }
@@ -341,7 +340,7 @@ Ecap::BodyRep::bodySize() const
 
 /* MessageRep */
 
-Ecap::MessageRep::MessageRep(HttpMsg *rawHeader):
+Adaptation::Ecap::MessageRep::MessageRep(HttpMsg *rawHeader):
         theMessage(rawHeader), theFirstLineRep(NULL),
         theHeaderRep(NULL), theBodyRep(NULL)
 {
@@ -361,7 +360,7 @@ Ecap::MessageRep::MessageRep(HttpMsg *rawHeader):
         theBodyRep = new BodyRep(theMessage.body_pipe);
 }
 
-Ecap::MessageRep::~MessageRep()
+Adaptation::Ecap::MessageRep::~MessageRep()
 {
     delete theBodyRep;
     delete theHeaderRep;
@@ -369,7 +368,7 @@ Ecap::MessageRep::~MessageRep()
 }
 
 libecap::shared_ptr<libecap::Message>
-Ecap::MessageRep::clone() const
+Adaptation::Ecap::MessageRep::clone() const
 {
     HttpMsg *hdr = theMessage.header->clone();
     hdr->body_pipe = NULL; // if any; TODO: remove pipe cloning from ::clone?
@@ -383,37 +382,37 @@ Ecap::MessageRep::clone() const
 }
 
 libecap::FirstLine &
-Ecap::MessageRep::firstLine()
+Adaptation::Ecap::MessageRep::firstLine()
 {
     return *theFirstLineRep;
 }
 
 const libecap::FirstLine &
-Ecap::MessageRep::firstLine() const
+Adaptation::Ecap::MessageRep::firstLine() const
 {
     return *theFirstLineRep;
 }
 
 libecap::Header &
-Ecap::MessageRep::header()
+Adaptation::Ecap::MessageRep::header()
 {
     return *theHeaderRep;
 }
 
 const libecap::Header &
-Ecap::MessageRep::header() const
+Adaptation::Ecap::MessageRep::header() const
 {
     return *theHeaderRep;
 }
 
 libecap::Body *
-Ecap::MessageRep::body()
+Adaptation::Ecap::MessageRep::body()
 {
     return theBodyRep;
 }
 
 void
-Ecap::MessageRep::addBody()
+Adaptation::Ecap::MessageRep::addBody()
 {
     Must(!theBodyRep);
     Must(!theMessage.body_pipe); // set in tieBody()
@@ -421,7 +420,7 @@ Ecap::MessageRep::addBody()
 }
 
 void
-Ecap::MessageRep::tieBody(Ecap::XactionRep *x)
+Adaptation::Ecap::MessageRep::tieBody(Adaptation::Ecap::XactionRep *x)
 {
     Must(theBodyRep != NULL); // addBody must be called first
     Must(!theMessage.header->body_pipe);
@@ -431,7 +430,7 @@ Ecap::MessageRep::tieBody(Ecap::XactionRep *x)
     theBodyRep->tie(theMessage.body_pipe);
 }
 
-const libecap::Body *Ecap::MessageRep::body() const
+const libecap::Body *Adaptation::Ecap::MessageRep::body() const
 {
     return theBodyRep;
 }
similarity index 94%
rename from src/eCAP/MessageRep.h
rename to src/adaptation/ecap/MessageRep.h
index 2fae3830791a9bfc9c69cfe6ba0b8131d56e3c0b..bcfbb474d9fca14f1488c819ea3ba4f3fa9ee66f 100644 (file)
@@ -6,13 +6,21 @@
 #ifndef SQUID__ECAP__MESSAGE_REP_H
 #define SQUID__ECAP__MESSAGE_REP_H
 
+#include "config.h"
+#include "HttpHeader.h"
+#include "BodyPipe.h"
 #include "adaptation/forward.h"
+#include "adaptation/Message.h"
 #include <libecap/common/message.h>
 #include <libecap/common/header.h>
 #include <libecap/common/body.h>
 
-namespace Ecap
-{
+class HttpMsg;
+class HttpRequest;
+class HttpReply;
+
+namespace Adaptation {
+namespace Ecap {
 
 class XactionRep;
 
@@ -164,6 +172,7 @@ private:
     BodyRep *theBodyRep; // body wrapper
 };
 
-} // namespace Ecap;
+} // namespace Ecap
+} // namespace Adaptation
 
 #endif /* SQUID__E_CAP__MESSAGE_REP_H */
similarity index 56%
rename from src/eCAP/ServiceRep.cc
rename to src/adaptation/ecap/ServiceRep.cc
index 5440e0008ba688e48fc5d58e54b5fbde3b1e39fd..d18e7d371e6dc97608c4b2d84262f975bae509c0 100644 (file)
@@ -1,39 +1,39 @@
 #include "squid.h"
 #include <libecap/adapter/service.h>
 #include "TextException.h"
-#include "eCAP/ServiceRep.h"
-#include "eCAP/XactionRep.h"
+#include "adaptation/ecap/ServiceRep.h"
+#include "adaptation/ecap/XactionRep.h"
 
-Ecap::ServiceRep::ServiceRep(const Adaptation::ServiceConfig &cfg):
-        /*AsyncJob("Ecap::ServiceRep"),*/ Adaptation::Service(cfg)
+Adaptation::Ecap::ServiceRep::ServiceRep(const Adaptation::ServiceConfig &cfg):
+        /*AsyncJob("Adaptation::Ecap::ServiceRep"),*/ Adaptation::Service(cfg)
 {
 }
 
-Ecap::ServiceRep::~ServiceRep()
+Adaptation::Ecap::ServiceRep::~ServiceRep()
 {
 }
 
-void Ecap::ServiceRep::noteService(const AdapterService &s)
+void Adaptation::Ecap::ServiceRep::noteService(const AdapterService &s)
 {
     Must(s != NULL);
     theService = s;
-    debugs(93,7, "Matched loaded and configured eCAP services: " <<
+    debugs(93,7, HERE << "matched loaded and configured eCAP services: " <<
            s->uri() << ' ' << cfg().key << "\n");
 }
 
-void Ecap::ServiceRep::invalidate()
+void Adaptation::Ecap::ServiceRep::invalidate()
 {
     theService->retire();
     theService.reset();
 }
 
-void Ecap::ServiceRep::noteFailure()
+void Adaptation::Ecap::ServiceRep::noteFailure()
 {
     assert(false); // XXX: should this be ICAP-specific?
 }
 
 void
-Ecap::ServiceRep::finalize()
+Adaptation::Ecap::ServiceRep::finalize()
 {
     Adaptation::Service::finalize();
     if (!theService) {
@@ -42,24 +42,24 @@ Ecap::ServiceRep::finalize()
     }
 }
 
-bool Ecap::ServiceRep::probed() const
+bool Adaptation::Ecap::ServiceRep::probed() const
 {
     return true; // we "probe" the adapter in finalize().
 }
 
-bool Ecap::ServiceRep::up() const
+bool Adaptation::Ecap::ServiceRep::up() const
 {
     return theService != NULL;
 }
 
-bool Ecap::ServiceRep::wantsUrl(const String &urlPath) const
+bool Adaptation::Ecap::ServiceRep::wantsUrl(const String &urlPath) const
 {
     Must(up());
     return theService->wantsUrl(urlPath.termedBuf());
 }
 
 Adaptation::Initiate *
-Ecap::ServiceRep::makeXactLauncher(Adaptation::Initiator *initiator,
+Adaptation::Ecap::ServiceRep::makeXactLauncher(Adaptation::Initiator *initiator,
                                    HttpMsg *virgin, HttpRequest *cause)
 {
     Must(up());
@@ -70,7 +70,7 @@ Ecap::ServiceRep::makeXactLauncher(Adaptation::Initiator *initiator,
 }
 
 // returns a temporary string depicting service status, for debugging
-const char *Ecap::ServiceRep::status() const
+const char *Adaptation::Ecap::ServiceRep::status() const
 {
     assert(false); // move generic stuff from ICAP to Adaptation
     // add theService->status()?
similarity index 95%
rename from src/eCAP/ServiceRep.h
rename to src/adaptation/ecap/ServiceRep.h
index 1eadd36754c2f9d2a05352567320c05c15019bd9..603a0d183a6187e57b7ef714443f35a1ffa16fe1 100644 (file)
@@ -11,8 +11,8 @@
 #include <libecap/common/forward.h>
 #include <libecap/common/memory.h>
 
-namespace Ecap
-{
+namespace Adaptation {
+namespace Ecap {
 
 /* The eCAP service representative maintains information about a single eCAP
    service that Squid communicates with. One eCAP module may register many
@@ -50,5 +50,6 @@ private:
 };
 
 } // namespace Ecap
+} // namespace Adaptation
 
 #endif /* SQUID_ECAP_SERVICE_REP_H */
similarity index 80%
rename from src/eCAP/XactionRep.cc
rename to src/adaptation/ecap/XactionRep.cc
index e1eb8216b9158c553a080d13bc98066ef21eaa56..70b0d12a18898e93f6ed34c3757ab2629f260c80 100644 (file)
@@ -5,18 +5,16 @@
 #include "TextException.h"
 #include "HttpRequest.h"
 #include "HttpReply.h"
-#include "eCAP/XactionRep.h"
+#include "adaptation/ecap/XactionRep.h"
 
-// CBDATA_CLASS_INIT(Ecap::XactionRep);
-// TODO: add CBDATA_NAMESPACED_CLASS_INIT(namespace, classname)
-cbdata_type Ecap::XactionRep::CBDATA_XactionRep = CBDATA_UNKNOWN;
+CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Ecap::XactionRep, XactionRep);
 
 
-Ecap::XactionRep::XactionRep(Adaptation::Initiator *anInitiator,
+Adaptation::Ecap::XactionRep::XactionRep(Adaptation::Initiator *anInitiator,
                              HttpMsg *virginHeader, HttpRequest *virginCause,
                              const Adaptation::ServicePointer &aService):
-        AsyncJob("Ecap::XactionRep"),
-        Adaptation::Initiate("Ecap::XactionRep", anInitiator, aService),
+        AsyncJob("Adaptation::Ecap::XactionRep"),
+        Adaptation::Initiate("Adaptation::Ecap::XactionRep", anInitiator, aService),
         theVirginRep(virginHeader), theCauseRep(NULL),
         proxyingVb(opUndecided), proxyingAb(opUndecided), canAccessVb(false)
 {
@@ -24,7 +22,7 @@ Ecap::XactionRep::XactionRep(Adaptation::Initiator *anInitiator,
         theCauseRep = new MessageRep(virginCause);
 }
 
-Ecap::XactionRep::~XactionRep()
+Adaptation::Ecap::XactionRep::~XactionRep()
 {
     assert(!theMaster);
     delete theCauseRep;
@@ -32,7 +30,7 @@ Ecap::XactionRep::~XactionRep()
 }
 
 void
-Ecap::XactionRep::master(const AdapterXaction &x)
+Adaptation::Ecap::XactionRep::master(const AdapterXaction &x)
 {
     Must(!theMaster);
     Must(x != NULL);
@@ -40,7 +38,7 @@ Ecap::XactionRep::master(const AdapterXaction &x)
 }
 
 void
-Ecap::XactionRep::start()
+Adaptation::Ecap::XactionRep::start()
 {
     Must(theMaster);
 
@@ -53,7 +51,7 @@ Ecap::XactionRep::start()
 }
 
 void
-Ecap::XactionRep::swanSong()
+Adaptation::Ecap::XactionRep::swanSong()
 {
     // clear body_pipes, if any
     // this code does not maintain proxying* and canAccessVb states; should it?
@@ -79,27 +77,27 @@ Ecap::XactionRep::swanSong()
 }
 
 libecap::Message &
-Ecap::XactionRep::virgin()
+Adaptation::Ecap::XactionRep::virgin()
 {
     return theVirginRep;
 }
 
 const libecap::Message &
-Ecap::XactionRep::cause()
+Adaptation::Ecap::XactionRep::cause()
 {
     Must(theCauseRep != NULL);
     return *theCauseRep;
 }
 
 libecap::Message &
-Ecap::XactionRep::adapted()
+Adaptation::Ecap::XactionRep::adapted()
 {
     Must(theAnswerRep != NULL);
     return *theAnswerRep;
 }
 
 Adaptation::Message &
-Ecap::XactionRep::answer()
+Adaptation::Ecap::XactionRep::answer()
 {
     MessageRep *rep = dynamic_cast<MessageRep*>(theAnswerRep.get());
     Must(rep);
@@ -107,7 +105,7 @@ Ecap::XactionRep::answer()
 }
 
 void
-Ecap::XactionRep::terminateMaster()
+Adaptation::Ecap::XactionRep::terminateMaster()
 {
     if (theMaster) {
         AdapterXaction x = theMaster;
@@ -117,7 +115,7 @@ Ecap::XactionRep::terminateMaster()
 }
 
 bool
-Ecap::XactionRep::doneAll() const
+Adaptation::Ecap::XactionRep::doneAll() const
 {
     return proxyingVb >= opComplete && proxyingAb >= opComplete &&
            Adaptation::Initiate::doneAll();
@@ -125,7 +123,7 @@ Ecap::XactionRep::doneAll() const
 
 // stops receiving virgin and enables auto-consumption
 void
-Ecap::XactionRep::dropVirgin(const char *reason)
+Adaptation::Ecap::XactionRep::dropVirgin(const char *reason)
 {
     debugs(93,4, HERE << "because " << reason << "; status:" << status());
     Must(proxyingVb = opOn);
@@ -142,7 +140,7 @@ Ecap::XactionRep::dropVirgin(const char *reason)
 }
 
 void
-Ecap::XactionRep::useVirgin()
+Adaptation::Ecap::XactionRep::useVirgin()
 {
     debugs(93,3, HERE << status());
     Must(proxyingAb == opUndecided);
@@ -172,7 +170,7 @@ Ecap::XactionRep::useVirgin()
 }
 
 void
-Ecap::XactionRep::useAdapted(const libecap::shared_ptr<libecap::Message> &m)
+Adaptation::Ecap::XactionRep::useAdapted(const libecap::shared_ptr<libecap::Message> &m)
 {
     debugs(93,3, HERE << status());
     Must(m);
@@ -199,7 +197,7 @@ Ecap::XactionRep::useAdapted(const libecap::shared_ptr<libecap::Message> &m)
 }
 
 void
-Ecap::XactionRep::vbDiscard()
+Adaptation::Ecap::XactionRep::vbDiscard()
 {
     Must(proxyingVb == opUndecided);
     // if adapter does not need vb, we do not need to send it
@@ -208,7 +206,7 @@ Ecap::XactionRep::vbDiscard()
 }
 
 void
-Ecap::XactionRep::vbMake()
+Adaptation::Ecap::XactionRep::vbMake()
 {
     Must(proxyingVb == opUndecided);
     BodyPipePointer &p = theVirginRep.raw().body_pipe;
@@ -218,7 +216,7 @@ Ecap::XactionRep::vbMake()
 }
 
 void
-Ecap::XactionRep::vbStopMaking()
+Adaptation::Ecap::XactionRep::vbStopMaking()
 {
     // if adapter does not need vb, we do not need to receive it
     if (proxyingVb == opOn)
@@ -227,7 +225,7 @@ Ecap::XactionRep::vbStopMaking()
 }
 
 void
-Ecap::XactionRep::vbMakeMore()
+Adaptation::Ecap::XactionRep::vbMakeMore()
 {
     Must(proxyingVb == opOn); // cannot make more if done proxying
     // we cannot guarantee more vb, but we can check that there is a chance
@@ -235,7 +233,7 @@ Ecap::XactionRep::vbMakeMore()
 }
 
 libecap::Area
-Ecap::XactionRep::vbContent(libecap::size_type o, libecap::size_type s)
+Adaptation::Ecap::XactionRep::vbContent(libecap::size_type o, libecap::size_type s)
 {
     Must(canAccessVb);
     // We may not be proxyingVb yet. It should be OK, but see vbContentShift().
@@ -260,7 +258,7 @@ Ecap::XactionRep::vbContent(libecap::size_type o, libecap::size_type s)
 }
 
 void
-Ecap::XactionRep::vbContentShift(libecap::size_type n)
+Adaptation::Ecap::XactionRep::vbContentShift(libecap::size_type n)
 {
     Must(canAccessVb);
     // We may not be proxyingVb yet. It should be OK now, but if BodyPipe
@@ -275,7 +273,7 @@ Ecap::XactionRep::vbContentShift(libecap::size_type n)
 }
 
 void
-Ecap::XactionRep::noteAbContentDone(bool atEnd)
+Adaptation::Ecap::XactionRep::noteAbContentDone(bool atEnd)
 {
     Must(proxyingAb == opOn);
     stopProducingFor(answer().body_pipe, atEnd);
@@ -283,7 +281,7 @@ Ecap::XactionRep::noteAbContentDone(bool atEnd)
 }
 
 void
-Ecap::XactionRep::noteAbContentAvailable()
+Adaptation::Ecap::XactionRep::noteAbContentAvailable()
 {
     Must(proxyingAb == opOn);
     moveAbContent();
@@ -291,7 +289,7 @@ Ecap::XactionRep::noteAbContentAvailable()
 
 #if 0 /* XXX: implement */
 void
-Ecap::XactionRep::setAdaptedBodySize(const libecap::BodySize &size)
+Adaptation::Ecap::XactionRep::setAdaptedBodySize(const libecap::BodySize &size)
 {
     Must(answer().body_pipe != NULL);
     if (size.known())
@@ -301,7 +299,7 @@ Ecap::XactionRep::setAdaptedBodySize(const libecap::BodySize &size)
 #endif
 
 void
-Ecap::XactionRep::adaptationDelayed(const libecap::Delay &d)
+Adaptation::Ecap::XactionRep::adaptationDelayed(const libecap::Delay &d)
 {
     debugs(93,3, HERE << "adapter needs time: " <<
            d.state << '/' << d.progress);
@@ -309,27 +307,27 @@ Ecap::XactionRep::adaptationDelayed(const libecap::Delay &d)
 }
 
 void
-Ecap::XactionRep::adaptationAborted()
+Adaptation::Ecap::XactionRep::adaptationAborted()
 {
     tellQueryAborted(true); // should eCAP support retries?
     mustStop("adaptationAborted");
 }
 
 bool
-Ecap::XactionRep::callable() const
+Adaptation::Ecap::XactionRep::callable() const
 {
     return !done();
 }
 
 void
-Ecap::XactionRep::noteMoreBodySpaceAvailable(RefCount<BodyPipe> bp)
+Adaptation::Ecap::XactionRep::noteMoreBodySpaceAvailable(RefCount<BodyPipe> bp)
 {
     Must(proxyingAb == opOn);
     moveAbContent();
 }
 
 void
-Ecap::XactionRep::noteBodyConsumerAborted(RefCount<BodyPipe> bp)
+Adaptation::Ecap::XactionRep::noteBodyConsumerAborted(RefCount<BodyPipe> bp)
 {
     Must(proxyingAb == opOn);
     stopProducingFor(answer().body_pipe, false);
@@ -339,7 +337,7 @@ Ecap::XactionRep::noteBodyConsumerAborted(RefCount<BodyPipe> bp)
 }
 
 void
-Ecap::XactionRep::noteMoreBodyDataAvailable(RefCount<BodyPipe> bp)
+Adaptation::Ecap::XactionRep::noteMoreBodyDataAvailable(RefCount<BodyPipe> bp)
 {
     Must(proxyingVb == opOn);
     Must(theMaster);
@@ -347,7 +345,7 @@ Ecap::XactionRep::noteMoreBodyDataAvailable(RefCount<BodyPipe> bp)
 }
 
 void
-Ecap::XactionRep::noteBodyProductionEnded(RefCount<BodyPipe> bp)
+Adaptation::Ecap::XactionRep::noteBodyProductionEnded(RefCount<BodyPipe> bp)
 {
     Must(proxyingVb == opOn);
     Must(theMaster);
@@ -356,7 +354,7 @@ Ecap::XactionRep::noteBodyProductionEnded(RefCount<BodyPipe> bp)
 }
 
 void
-Ecap::XactionRep::noteBodyProducerAborted(RefCount<BodyPipe> bp)
+Adaptation::Ecap::XactionRep::noteBodyProducerAborted(RefCount<BodyPipe> bp)
 {
     Must(proxyingVb == opOn);
     Must(theMaster);
@@ -365,14 +363,14 @@ Ecap::XactionRep::noteBodyProducerAborted(RefCount<BodyPipe> bp)
 }
 
 void
-Ecap::XactionRep::noteInitiatorAborted()
+Adaptation::Ecap::XactionRep::noteInitiatorAborted()
 {
     mustStop("initiator aborted");
 }
 
 // get content from the adapter and put it into the adapted pipe
 void
-Ecap::XactionRep::moveAbContent()
+Adaptation::Ecap::XactionRep::moveAbContent()
 {
     Must(proxyingAb == opOn);
     const libecap::Area c = theMaster->abContent(0, libecap::nsize);
@@ -382,7 +380,7 @@ Ecap::XactionRep::moveAbContent()
 }
 
 const char *
-Ecap::XactionRep::status() const
+Adaptation::Ecap::XactionRep::status() const
 {
     static MemBuf buf;
     buf.reset();
similarity index 96%
rename from src/eCAP/XactionRep.h
rename to src/adaptation/ecap/XactionRep.h
index 3098ba1a5d843bd0392a5c979685134061d53e7d..d1d411bf2a8dd34fa69dcb63353e02eb8c621c9e 100644 (file)
 #include "adaptation/Initiate.h"
 #include "adaptation/Service.h"
 #include "adaptation/Message.h"
-#include "eCAP/MessageRep.h"
+#include "adaptation/ecap/MessageRep.h"
 #include <libecap/common/forward.h>
 #include <libecap/common/memory.h>
 #include <libecap/host/xaction.h>
 #include <libecap/adapter/xaction.h>
 
-namespace Ecap
-{
+namespace Adaptation {
+namespace Ecap {
 
 /* The eCAP xaction representative maintains information about a single eCAP
    xaction that Squid communicates with. One eCAP module may register many
@@ -97,5 +97,6 @@ private:
 };
 
 } // namespace Ecap
+} // namespace Adaptation
 
 #endif /* SQUID_ECAP_XACTION_REP_H */
diff --git a/src/adaptation/icap/Client.cc b/src/adaptation/icap/Client.cc
new file mode 100644 (file)
index 0000000..3825d51
--- /dev/null
@@ -0,0 +1,11 @@
+#include "squid.h"
+#include "adaptation/icap/Client.h"
+
+void Adaptation::Icap::InitModule()
+{
+    debugs(93,2, HERE << "module enabled.");
+}
+
+void Adaptation::Icap::CleanModule()
+{
+}
similarity index 91%
rename from src/ICAP/ICAPClient.h
rename to src/adaptation/icap/Client.h
index 037616cc1ff082513aa76f65604d1539029b2e4f..1d8709f4356e0394b697aa108473171615fde138 100644 (file)
 
 // ICAP-related things needed by code unaware of ICAP internals.
 
-extern void ICAPInitModule();
-extern void ICAPCleanModule();
+
+namespace Adaptation {
+namespace Icap {
+
+extern void InitModule();
+extern void CleanModule();
+
+
+} // namespace Icap
+} // namespace Adaptation
 
 #endif /* SQUID_ICAPCLIENT_H */
similarity index 81%
rename from src/ICAP/ICAPConfig.cc
rename to src/adaptation/icap/Config.cc
index 581abcc33a8ec6f68f03e6de6d2509f23a62ea62..da485431a85ecbe0c5a894052cc37b185e54e23d 100644 (file)
 #include "ACL.h"
 #include "Store.h"
 #include "Array.h"     // really Vector
-#include "ICAPConfig.h"
-#include "ICAPServiceRep.h"
+#include "adaptation/icap/Config.h"
+#include "adaptation/icap/ServiceRep.h"
 #include "HttpRequest.h"
 #include "HttpReply.h"
 #include "ACLChecklist.h"
 #include "wordlist.h"
 
-ICAPConfig TheICAPConfig;
+Adaptation::Icap::Config Adaptation::Icap::TheConfig;
 
-ICAPConfig::ICAPConfig(): preview_enable(0), preview_size(0),
+Adaptation::Icap::Config::Config(): preview_enable(0), preview_size(0),
         connect_timeout_raw(0), io_timeout_raw(0), reuse_connections(0),
         client_username_header(NULL), client_username_encode(0)
 {
 }
 
-ICAPConfig::~ICAPConfig()
+Adaptation::Icap::Config::~Config()
 {
     // TODO: delete client_username_header?
 }
 
 Adaptation::ServicePointer
-ICAPConfig::createService(const Adaptation::ServiceConfig &cfg)
+Adaptation::Icap::Config::createService(const Adaptation::ServiceConfig &cfg)
 {
-    ICAPServiceRep::Pointer s = new ICAPServiceRep(cfg);
+    Adaptation::Icap::ServiceRep::Pointer s = new Adaptation::Icap::ServiceRep(cfg);
     s->setSelf(s);
     return s.getRaw();
 }
 
-time_t ICAPConfig::connect_timeout(bool bypassable) const
+time_t Adaptation::Icap::Config::connect_timeout(bool bypassable) const
 {
     if (connect_timeout_raw > 0)
         return connect_timeout_raw; // explicitly configured
@@ -74,7 +74,7 @@ time_t ICAPConfig::connect_timeout(bool bypassable) const
     return bypassable ? ::Config.Timeout.peer_connect : ::Config.Timeout.connect;
 }
 
-time_t ICAPConfig::io_timeout(bool) const
+time_t Adaptation::Icap::Config::io_timeout(bool) const
 {
     if (io_timeout_raw > 0)
         return io_timeout_raw; // explicitly configured
similarity index 86%
rename from src/ICAP/ICAPConfig.h
rename to src/adaptation/icap/Config.h
index 1dc09093ab10648f37aeff9d62993f316e104254..ec2408169e1dbc34baf7cfc5952cb6764cacacf2 100644 (file)
 #include "event.h"
 #include "AsyncCall.h"
 #include "adaptation/Config.h"
-#include "ICAPServiceRep.h"
+#include "adaptation/icap/ServiceRep.h"
+
+
+namespace Adaptation {
+namespace Icap {
 
 class acl_access;
 
 class ConfigParser;
 
-class ICAPConfig: public Adaptation::Config
+class Config: public Adaptation::Config
 {
 
 public:
@@ -58,19 +62,23 @@ public:
     char* client_username_header;
     int client_username_encode;
 
-    ICAPConfig();
-    ~ICAPConfig();
+    Config();
+    ~Config();
 
     time_t connect_timeout(bool bypassable) const;
     time_t io_timeout(bool bypassable) const;
 
 private:
-    ICAPConfig(const ICAPConfig &); // not implemented
-    ICAPConfig &operator =(const ICAPConfig &); // not implemented
+    Config(const Config &); // not implemented
+    Config &operator =(const Config &); // not implemented
 
     virtual Adaptation::ServicePointer createService(const Adaptation::ServiceConfig &cfg);
 };
 
-extern ICAPConfig TheICAPConfig;
+extern Config TheConfig;
+
+
+} // namespace Icap
+} // namespace Adaptation
 
 #endif /* SQUID_ICAPCONFIG_H */
similarity index 55%
rename from src/ICAP/ICAPElements.cc
rename to src/adaptation/icap/Elements.cc
index 8dad155cbfd8ebf94287c514ec75ade8924fe9b3..fa269eef1cb5d8cce3498a92e7b0c394415c18ac 100644 (file)
@@ -1,4 +1,4 @@
 #include "squid.h"
-#include "ICAPElements.h"
+#include "adaptation/icap/Elements.h"
 
 // TODO: remove this file?
similarity index 95%
rename from src/ICAP/ICAPElements.h
rename to src/adaptation/icap/Elements.h
index 0c480bea055db9e61233d7364dae4a475b271f4f..fcf7ee54d2679a8ab8c7c01af070f06f76cc5933 100644 (file)
 
 // ICAP-related things shared by many ICAP classes
 
+
+namespace Adaptation {
+namespace Icap {
+
 namespace ICAP
 {
 using Adaptation::Method;
@@ -55,4 +59,8 @@ using Adaptation::methodStr;
 using Adaptation::vectPointStr;
 }
 
+
+} // namespace Icap
+} // namespace Adaptation
+
 #endif /* SQUID_ICAPCLIENT_H */
similarity index 94%
rename from src/ICAP/ICAPInOut.h
rename to src/adaptation/icap/InOut.h
index 81b9b6f695a8eb7a963efc0281d9826773e01494..954fcb8e0297bb3be4aafcda42d4a2ce9929d713 100644 (file)
 // as the "cause". ICAP transactions use this class to store virgin
 // and adapted HTTP messages.
 
-class ICAPInOut
+
+namespace Adaptation {
+namespace Icap {
+
+class InOut
 {
 
 public:
     typedef HttpMsg Header;
 
-    ICAPInOut(): header(0), cause(0) {}
+    InOut(): header(0), cause(0) {}
 
-    ~ICAPInOut() {
+    ~InOut() {
         HTTPMSGUNLOCK(cause);
         HTTPMSGUNLOCK(header);
     }
@@ -84,4 +88,8 @@ public:
 
 // TODO: s/Header/Message/i ?
 
+
+} // namespace Icap
+} // namespace Adaptation
+
 #endif /* SQUID_ICAPINOUT_H */
similarity index 67%
rename from src/ICAP/ICAPLauncher.cc
rename to src/adaptation/icap/Launcher.cc
index 575066e4843e937714234c152830ecd49e38ba02..930e652cf5d1bcea6ca437b38375677fc424943f 100644 (file)
@@ -5,12 +5,12 @@
 #include "squid.h"
 #include "TextException.h"
 #include "HttpMsg.h"
-#include "ICAPLauncher.h"
-#include "ICAPXaction.h"
-#include "ICAPServiceRep.h"
+#include "adaptation/icap/Launcher.h"
+#include "adaptation/icap/Xaction.h"
+#include "adaptation/icap/ServiceRep.h"
 
 
-ICAPLauncher::ICAPLauncher(const char *aTypeName,
+Adaptation::Icap::Launcher::Launcher(const char *aTypeName,
                            Adaptation::Initiator *anInitiator, Adaptation::ServicePointer &aService):
         AsyncJob(aTypeName),
         Adaptation::Initiate(aTypeName, anInitiator, aService),
@@ -18,12 +18,12 @@ ICAPLauncher::ICAPLauncher(const char *aTypeName,
 {
 }
 
-ICAPLauncher::~ICAPLauncher()
+Adaptation::Icap::Launcher::~Launcher()
 {
     assert(!theXaction);
 }
 
-void ICAPLauncher::start()
+void Adaptation::Icap::Launcher::start()
 {
     Adaptation::Initiate::start();
 
@@ -31,27 +31,27 @@ void ICAPLauncher::start()
     launchXaction(false);
 }
 
-void ICAPLauncher::launchXaction(bool final)
+void Adaptation::Icap::Launcher::launchXaction(bool final)
 {
     Must(!theXaction);
     ++theLaunches;
     debugs(93,4, HERE << "launching xaction #" << theLaunches);
-    ICAPXaction *x = createXaction();
+    Adaptation::Icap::Xaction *x = createXaction();
     if (final)
         x->disableRetries();
     theXaction = initiateAdaptation(x);
     Must(theXaction);
 }
 
-void ICAPLauncher::noteAdaptationAnswer(HttpMsg *message)
+void Adaptation::Icap::Launcher::noteAdaptationAnswer(HttpMsg *message)
 {
     sendAnswer(message);
     clearAdaptation(theXaction);
     Must(done());
-    debugs(93,3, HERE << "ICAPLauncher::noteAdaptationAnswer exiting ");
+    debugs(93,3, HERE << "Adaptation::Icap::Launcher::noteAdaptationAnswer exiting ");
 }
 
-void ICAPLauncher::noteInitiatorAborted()
+void Adaptation::Icap::Launcher::noteInitiatorAborted()
 {
 
     announceInitiatorAbort(theXaction); // propogate to the transaction
@@ -60,7 +60,7 @@ void ICAPLauncher::noteInitiatorAborted()
 
 }
 
-void ICAPLauncher::noteAdaptationQueryAbort(bool final)
+void Adaptation::Icap::Launcher::noteAdaptationQueryAbort(bool final)
 {
     clearAdaptation(theXaction);
 
@@ -75,12 +75,12 @@ void ICAPLauncher::noteAdaptationQueryAbort(bool final)
 
 }
 
-bool ICAPLauncher::doneAll() const
+bool Adaptation::Icap::Launcher::doneAll() const
 {
     return (!theInitiator || !theXaction) && Adaptation::Initiate::doneAll();
 }
 
-void ICAPLauncher::swanSong()
+void Adaptation::Icap::Launcher::swanSong()
 {
     if (theInitiator)
         tellQueryAborted(!service().cfg().bypass);
similarity index 85%
rename from src/ICAP/ICAPLauncher.h
rename to src/adaptation/icap/Launcher.h
index 24c4554268f3e2ba08fc7ee6865478728aac0802..4be7feec9a7e74e1932497fee1e33591d5134674 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "adaptation/Initiator.h"
 #include "adaptation/Initiate.h"
-#include "ICAP/ICAPServiceRep.h"
+#include "adaptation/icap/ServiceRep.h"
 
 /*
  * The ICAP Launcher starts an ICAP transaction. If the transaction fails
  * ICAP transactions.
  */
 
-class ICAPXaction;
 
-// Note: ICAPInitiate must be the first parent for cbdata to work. We use
-// a temporary ICAPInitaitorHolder/toCbdata hacks and do not call cbdata
+namespace Adaptation {
+namespace Icap {
+
+class Xaction;
+
+// Note: Initiate must be the first parent for cbdata to work. We use
+// a temporary InitaitorHolder/toCbdata hacks and do not call cbdata
 // operations on the initiator directly.
-class ICAPLauncher: public Adaptation::Initiate, public Adaptation::Initiator
+class Launcher: public Adaptation::Initiate, public Adaptation::Initiator
 {
 public:
-    ICAPLauncher(const char *aTypeName, Adaptation::Initiator *anInitiator, Adaptation::ServicePointer &aService);
-    virtual ~ICAPLauncher();
+    Launcher(const char *aTypeName, Adaptation::Initiator *anInitiator, Adaptation::ServicePointer &aService);
+    virtual ~Launcher();
 
     // Adaptation::Initiate: asynchronous communication with the initiator
     void noteInitiatorAborted();
@@ -83,7 +87,7 @@ protected:
     virtual void swanSong();
 
     // creates the right ICAP transaction using stored configuration params
-    virtual ICAPXaction *createXaction() = 0;
+    virtual Xaction *createXaction() = 0;
 
     void launchXaction(bool final);
 
@@ -91,4 +95,8 @@ protected:
     int theLaunches; // the number of transaction launches
 };
 
+
+} // namespace Icap
+} // namespace Adaptation
+
 #endif /* SQUID_ICAPLAUNCHER_H */
diff --git a/src/adaptation/icap/Makefile.am b/src/adaptation/icap/Makefile.am
new file mode 100644 (file)
index 0000000..dbaa577
--- /dev/null
@@ -0,0 +1,25 @@
+include $(top_srcdir)/src/Common.am
+include $(top_srcdir)/src/TestHeaders.am
+
+noinst_LTLIBRARIES = libicap.la
+
+libicap_la_SOURCES = \
+       Client.cc \
+       Client.h \
+       InOut.h \
+       Config.cc \
+       Config.h \
+       Elements.cc \
+       Elements.h \
+       Options.cc \
+       Options.h \
+       ServiceRep.cc \
+       ServiceRep.h \
+       Launcher.cc \
+       Launcher.h \
+       OptXact.cc \
+       OptXact.h \
+       Xaction.cc \
+       Xaction.h \
+       ModXact.cc \
+       ModXact.h
similarity index 80%
rename from src/ICAP/ICAPModXact.cc
rename to src/adaptation/icap/ModXact.cc
index 06cd1138e1df9a19f105e76b545509132eb843fe..6dbb850410731d6a8d2913543215437f5eff1fb8 100644 (file)
@@ -8,14 +8,14 @@
 #include "HttpRequest.h"
 #include "HttpReply.h"
 #include "adaptation/Initiator.h"
-#include "ICAPServiceRep.h"
-#include "ICAPLauncher.h"
-#include "ICAPModXact.h"
-#include "ICAPClient.h"
+#include "adaptation/icap/ServiceRep.h"
+#include "adaptation/icap/Launcher.h"
+#include "adaptation/icap/ModXact.h"
+#include "adaptation/icap/Client.h"
 #include "ChunkedCodingParser.h"
 #include "TextException.h"
 #include "AuthUserRequest.h"
-#include "ICAPConfig.h"
+#include "adaptation/icap/Config.h"
 #include "SquidTime.h"
 
 // flow and terminology:
 
 // TODO: replace gotEncapsulated() with something faster; we call it often
 
-CBDATA_CLASS_INIT(ICAPModXact);
-CBDATA_CLASS_INIT(ICAPModXactLauncher);
+CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Icap, ModXact);
+CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Icap, ModXactLauncher);
 
 static const size_t TheBackupLimit = BodyPipe::MaxCapacity;
 
-extern ICAPConfig TheICAPConfig;
+extern Adaptation::Icap::Config Adaptation::Icap::TheConfig;
 
 
-ICAPModXact::State::State()
+Adaptation::Icap::ModXact::State::State()
 {
     memset(this, 0, sizeof(*this));
 }
 
-ICAPModXact::ICAPModXact(Adaptation::Initiator *anInitiator, HttpMsg *virginHeader,
-                         HttpRequest *virginCause, ICAPServiceRep::Pointer &aService):
-        AsyncJob("ICAPModXact"),
-        ICAPXaction("ICAPModXact", anInitiator, aService),
+Adaptation::Icap::ModXact::ModXact(Adaptation::Initiator *anInitiator, HttpMsg *virginHeader,
+                         HttpRequest *virginCause, Adaptation::Icap::ServiceRep::Pointer &aService):
+        AsyncJob("Adaptation::Icap::ModXact"),
+        Adaptation::Icap::Xaction("Adaptation::Icap::ModXact", anInitiator, aService),
         icapReply(NULL),
         virginConsumed(0),
         bodyParser(NULL),
@@ -53,7 +53,7 @@ ICAPModXact::ICAPModXact(Adaptation::Initiator *anInitiator, HttpMsg *virginHead
 
     // adapted header and body are initialized when we parse them
 
-    // writing and reading ends are handled by ICAPXaction
+    // writing and reading ends are handled by Adaptation::Icap::Xaction
 
     // encoding
     // nothing to do because we are using temporary buffers
@@ -62,13 +62,13 @@ ICAPModXact::ICAPModXact(Adaptation::Initiator *anInitiator, HttpMsg *virginHead
     icapReply = new HttpReply;
     icapReply->protoPrefix = "ICAP/"; // TODO: make an IcapReply class?
 
-    debugs(93,7, "ICAPModXact initialized." << status());
+    debugs(93,7, HERE << "initialized." << status());
 }
 
 // initiator wants us to start
-void ICAPModXact::start()
+void Adaptation::Icap::ModXact::start()
 {
-    ICAPXaction::start();
+    Adaptation::Icap::Xaction::start();
 
     estimateVirginBody(); // before virgin disappears!
 
@@ -82,17 +82,17 @@ void ICAPModXact::start()
         waitForService();
 }
 
-void ICAPModXact::waitForService()
+void Adaptation::Icap::ModXact::waitForService()
 {
     Must(!state.serviceWaiting);
-    debugs(93, 7, "ICAPModXact will wait for the ICAP service" << status());
+    debugs(93, 7, HERE << "will wait for the ICAP service" << status());
     state.serviceWaiting = true;
-    AsyncCall::Pointer call = asyncCall(93,5, "ICAPModXact::noteServiceReady",
-                                        MemFun(this, &ICAPModXact::noteServiceReady));
+    AsyncCall::Pointer call = asyncCall(93,5, "Adaptation::Icap::ModXact::noteServiceReady",
+                                        MemFun(this, &Adaptation::Icap::ModXact::noteServiceReady));
     service().callWhenReady(call);
 }
 
-void ICAPModXact::noteServiceReady()
+void Adaptation::Icap::ModXact::noteServiceReady()
 {
     Must(state.serviceWaiting);
     state.serviceWaiting = false;
@@ -105,7 +105,7 @@ void ICAPModXact::noteServiceReady()
     }
 }
 
-void ICAPModXact::startWriting()
+void Adaptation::Icap::ModXact::startWriting()
 {
     state.writing = State::writingConnect;
 
@@ -116,7 +116,7 @@ void ICAPModXact::startWriting()
 }
 
 // connection with the ICAP service established
-void ICAPModXact::handleCommConnected()
+void Adaptation::Icap::ModXact::handleCommConnected()
 {
     Must(state.writing == State::writingConnect);
 
@@ -126,7 +126,7 @@ void ICAPModXact::handleCommConnected()
     requestBuf.init();
 
     makeRequestHeaders(requestBuf);
-    debugs(93, 9, "ICAPModXact ICAP will write" << status() << ":\n" <<
+    debugs(93, 9, HERE << "will write" << status() << ":\n" <<
            (requestBuf.terminate(), requestBuf.content()));
 
     // write headers
@@ -134,7 +134,7 @@ void ICAPModXact::handleCommConnected()
     scheduleWrite(requestBuf);
 }
 
-void ICAPModXact::handleCommWrote(size_t sz)
+void Adaptation::Icap::ModXact::handleCommWrote(size_t sz)
 {
     debugs(93, 5, HERE << "Wrote " << sz << " bytes");
 
@@ -144,7 +144,7 @@ void ICAPModXact::handleCommWrote(size_t sz)
         handleCommWroteBody();
 }
 
-void ICAPModXact::handleCommWroteHeaders()
+void Adaptation::Icap::ModXact::handleCommWroteHeaders()
 {
     Must(state.writing == State::writingHeaders);
 
@@ -162,7 +162,7 @@ void ICAPModXact::handleCommWroteHeaders()
     writeMore();
 }
 
-void ICAPModXact::writeMore()
+void Adaptation::Icap::ModXact::writeMore()
 {
     debugs(93, 5, HERE << "checking whether to write more" << status());
 
@@ -196,11 +196,11 @@ void ICAPModXact::writeMore()
         return;
 
     default:
-        throw TexcHere("ICAPModXact in bad writing state");
+        throw TexcHere("Adaptation::Icap::ModXact in bad writing state");
     }
 }
 
-void ICAPModXact::writePreviewBody()
+void Adaptation::Icap::ModXact::writePreviewBody()
 {
     debugs(93, 8, HERE << "will write Preview body from " <<
            virgin.body_pipe << status());
@@ -214,7 +214,7 @@ void ICAPModXact::writePreviewBody()
     // change state once preview is written
 
     if (preview.done()) {
-        debugs(93, 7, "ICAPModXact wrote entire Preview body" << status());
+        debugs(93, 7, HERE << "wrote entire Preview body" << status());
 
         if (preview.ieof())
             stopWriting(true);
@@ -223,7 +223,7 @@ void ICAPModXact::writePreviewBody()
     }
 }
 
-void ICAPModXact::writePrimeBody()
+void Adaptation::Icap::ModXact::writePrimeBody()
 {
     Must(state.writing == State::writingPrime);
     Must(virginBodyWriting.active());
@@ -237,7 +237,7 @@ void ICAPModXact::writePrimeBody()
     }
 }
 
-void ICAPModXact::writeSomeBody(const char *label, size_t size)
+void Adaptation::Icap::ModXact::writeSomeBody(const char *label, size_t size)
 {
     Must(!writer && state.writing < state.writingAlmostDone);
     Must(virgin.body_pipe != NULL);
@@ -262,7 +262,7 @@ void ICAPModXact::writeSomeBody(const char *label, size_t size)
         virginBodyWriting.progress(chunkSize);
         virginConsume();
     } else {
-        debugs(93, 7, "ICAPModXact has no writable " << label << " content");
+        debugs(93, 7, HERE << "has no writable " << label << " content");
     }
 
     const bool wroteEof = virginBodyEndReached(virginBodyWriting);
@@ -287,25 +287,25 @@ void ICAPModXact::writeSomeBody(const char *label, size_t size)
     }
 }
 
-void ICAPModXact::addLastRequestChunk(MemBuf &buf)
+void Adaptation::Icap::ModXact::addLastRequestChunk(MemBuf &buf)
 {
     const bool ieof = state.writing == State::writingPreview && preview.ieof();
     openChunk(buf, 0, ieof);
     closeChunk(buf);
 }
 
-void ICAPModXact::openChunk(MemBuf &buf, size_t chunkSize, bool ieof)
+void Adaptation::Icap::ModXact::openChunk(MemBuf &buf, size_t chunkSize, bool ieof)
 {
     buf.Printf((ieof ? "%x; ieof\r\n" : "%x\r\n"), (int) chunkSize);
 }
 
-void ICAPModXact::closeChunk(MemBuf &buf)
+void Adaptation::Icap::ModXact::closeChunk(MemBuf &buf)
 {
     buf.append(ICAP::crlf, 2); // chunk-terminating CRLF
 }
 
 // did the activity reached the end of the virgin body?
-bool ICAPModXact::virginBodyEndReached(const VirginBodyAct &act) const
+bool Adaptation::Icap::ModXact::virginBodyEndReached(const Adaptation::Icap::VirginBodyAct &act) const
 {
     return
         !act.active() || // did all (assuming it was originally planned)
@@ -314,7 +314,7 @@ bool ICAPModXact::virginBodyEndReached(const VirginBodyAct &act) const
 
 // the size of buffered virgin body data available for the specified activity
 // if this size is zero, we may be done or may be waiting for more data
-size_t ICAPModXact::virginContentSize(const VirginBodyAct &act) const
+size_t Adaptation::Icap::ModXact::virginContentSize(const Adaptation::Icap::VirginBodyAct &act) const
 {
     Must(act.active());
     // asbolute start of unprocessed data
@@ -326,7 +326,7 @@ size_t ICAPModXact::virginContentSize(const VirginBodyAct &act) const
 }
 
 // pointer to buffered virgin body data available for the specified activity
-const char *ICAPModXact::virginContentData(const VirginBodyAct &act) const
+const char *Adaptation::Icap::ModXact::virginContentData(const Adaptation::Icap::VirginBodyAct &act) const
 {
     Must(act.active());
     const uint64_t start = act.offset();
@@ -334,9 +334,9 @@ const char *ICAPModXact::virginContentData(const VirginBodyAct &act) const
     return virgin.body_pipe->buf().content() + static_cast<size_t>(start-virginConsumed);
 }
 
-void ICAPModXact::virginConsume()
+void Adaptation::Icap::ModXact::virginConsume()
 {
-    debugs(93, 9, "consumption guards: " << !virgin.body_pipe << isRetriable);
+    debugs(93, 9, HERE << "consumption guards: " << !virgin.body_pipe << isRetriable);
 
     if (!virgin.body_pipe)
         return; // nothing to consume
@@ -385,7 +385,7 @@ void ICAPModXact::virginConsume()
     }
 }
 
-void ICAPModXact::handleCommWroteBody()
+void Adaptation::Icap::ModXact::handleCommWroteBody()
 {
     writeMore();
 }
@@ -393,7 +393,7 @@ void ICAPModXact::handleCommWroteBody()
 // Called when we do not expect to call comm_write anymore.
 // We may have a pending write though.
 // If stopping nicely, we will just wait for that pending write, if any.
-void ICAPModXact::stopWriting(bool nicely)
+void Adaptation::Icap::ModXact::stopWriting(bool nicely)
 {
     if (state.writing == State::writingReallyDone)
         return;
@@ -425,24 +425,24 @@ void ICAPModXact::stopWriting(bool nicely)
     checkConsuming();
 }
 
-void ICAPModXact::stopBackup()
+void Adaptation::Icap::ModXact::stopBackup()
 {
     if (!virginBodySending.active())
         return;
 
-    debugs(93, 7, "ICAPModXact will no longer backup" << status());
+    debugs(93, 7, HERE << "will no longer backup" << status());
     virginBodySending.disable();
     virginConsume();
 }
 
-bool ICAPModXact::doneAll() const
+bool Adaptation::Icap::ModXact::doneAll() const
 {
-    return ICAPXaction::doneAll() && !state.serviceWaiting &&
+    return Adaptation::Icap::Xaction::doneAll() && !state.serviceWaiting &&
            doneSending() &&
            doneReading() && state.doneWriting();
 }
 
-void ICAPModXact::startReading()
+void Adaptation::Icap::ModXact::startReading()
 {
     Must(connection >= 0);
     Must(!reader);
@@ -453,7 +453,7 @@ void ICAPModXact::startReading()
     readMore();
 }
 
-void ICAPModXact::readMore()
+void Adaptation::Icap::ModXact::readMore()
 {
     if (reader != NULL || doneReading()) {
         debugs(93,3,HERE << "returning from readMore because reader or doneReading()");
@@ -474,14 +474,14 @@ void ICAPModXact::readMore()
 }
 
 // comm module read a portion of the ICAP response for us
-void ICAPModXact::handleCommRead(size_t)
+void Adaptation::Icap::ModXact::handleCommRead(size_t)
 {
     Must(!state.doneParsing());
     parseMore();
     readMore();
 }
 
-void ICAPModXact::echoMore()
+void Adaptation::Icap::ModXact::echoMore()
 {
     Must(state.sending == State::sendingVirgin);
     Must(adapted.body_pipe != NULL);
@@ -503,29 +503,29 @@ void ICAPModXact::echoMore()
     }
 
     if (virginBodyEndReached(virginBodySending)) {
-        debugs(93, 5, "ICAPModXact echoed all" << status());
+        debugs(93, 5, HERE << "echoed all" << status());
         stopSending(true);
     } else {
-        debugs(93, 5, "ICAPModXact has " <<
+        debugs(93, 5, HERE << "has " <<
                virgin.body_pipe->buf().contentSize() << " bytes " <<
                "and expects more to echo" << status());
         // TODO: timeout if virgin or adapted pipes are broken
     }
 }
 
-bool ICAPModXact::doneSending() const
+bool Adaptation::Icap::ModXact::doneSending() const
 {
     return state.sending == State::sendingDone;
 }
 
 // stop (or do not start) sending adapted message body
-void ICAPModXact::stopSending(bool nicely)
+void Adaptation::Icap::ModXact::stopSending(bool nicely)
 {
     if (doneSending())
         return;
 
     if (state.sending != State::sendingUndecided) {
-        debugs(93, 7, "ICAPModXact will no longer send" << status());
+        debugs(93, 7, HERE << "will no longer send" << status());
         if (adapted.body_pipe != NULL) {
             virginBodySending.disable();
             // we may leave debts if we were echoing and the virgin
@@ -534,7 +534,7 @@ void ICAPModXact::stopSending(bool nicely)
             stopProducingFor(adapted.body_pipe, nicely && !leftDebts);
         }
     } else {
-        debugs(93, 7, "ICAPModXact will not start sending" << status());
+        debugs(93, 7, HERE << "will not start sending" << status());
         Must(!adapted.body_pipe);
     }
 
@@ -543,7 +543,7 @@ void ICAPModXact::stopSending(bool nicely)
 }
 
 // should be called after certain state.writing or state.sending changes
-void ICAPModXact::checkConsuming()
+void Adaptation::Icap::ModXact::checkConsuming()
 {
     // quit if we already stopped or are still using the pipe
     if (!virgin.body_pipe || !state.doneConsumingVirgin())
@@ -553,7 +553,7 @@ void ICAPModXact::checkConsuming()
     stopConsumingFrom(virgin.body_pipe);
 }
 
-void ICAPModXact::parseMore()
+void Adaptation::Icap::ModXact::parseMore()
 {
     debugs(93, 5, HERE << "have " << readBuf.contentSize() << " bytes to parse" <<
            status());
@@ -566,23 +566,23 @@ void ICAPModXact::parseMore()
         parseBody();
 }
 
-void ICAPModXact::callException(const std::exception &e)
+void Adaptation::Icap::ModXact::callException(const std::exception &e)
 {
     if (!canStartBypass || isRetriable) {
-        ICAPXaction::callException(e);
+        Adaptation::Icap::Xaction::callException(e);
         return;
     }
 
     try {
-        debugs(93, 3, "bypassing ICAPModXact::" << inCall << " exception: " <<
-               e.what() << ' ' << status());
+        debugs(93, 3, HERE << "bypassing " << inCall << " exception: " <<
+            e.what() << ' ' << status());
         bypassFailure();
     } catch (const std::exception &bypassE) {
-        ICAPXaction::callException(bypassE);
+        Adaptation::Icap::Xaction::callException(bypassE);
     }
 }
 
-void ICAPModXact::bypassFailure()
+void Adaptation::Icap::ModXact::bypassFailure()
 {
     disableBypass("already started to bypass");
 
@@ -601,11 +601,11 @@ void ICAPModXact::bypassFailure()
         reuseConnection = false; // be conservative
         cancelRead(); // may not work; and we cannot stop connecting either
         if (!doneWithIo())
-            debugs(93, 7, "Warning: bypass failed to stop I/O" << status());
+            debugs(93, 7, HERE << "Warning: bypass failed to stop I/O" << status());
     }
 }
 
-void ICAPModXact::disableBypass(const char *reason)
+void Adaptation::Icap::ModXact::disableBypass(const char *reason)
 {
     if (canStartBypass) {
         debugs(93,7, HERE << "will never start bypass because " << reason);
@@ -616,7 +616,7 @@ void ICAPModXact::disableBypass(const char *reason)
 
 
 // note that allocation for echoing is done in handle204NoContent()
-void ICAPModXact::maybeAllocateHttpMsg()
+void Adaptation::Icap::ModXact::maybeAllocateHttpMsg()
 {
     if (adapted.header) // already allocated
         return;
@@ -629,7 +629,7 @@ void ICAPModXact::maybeAllocateHttpMsg()
         throw TexcHere("Neither res-hdr nor req-hdr in maybeAllocateHttpMsg()");
 }
 
-void ICAPModXact::parseHeaders()
+void Adaptation::Icap::ModXact::parseHeaders()
 {
     Must(state.parsingHeaders());
 
@@ -652,7 +652,7 @@ void ICAPModXact::parseHeaders()
 }
 
 // called after parsing all headers or when bypassing an exception
-void ICAPModXact::startSending()
+void Adaptation::Icap::ModXact::startSending()
 {
     disableBypass("sent headers");
     sendAnswer(adapted.header);
@@ -661,7 +661,7 @@ void ICAPModXact::startSending()
         echoMore();
 }
 
-void ICAPModXact::parseIcapHead()
+void Adaptation::Icap::ModXact::parseIcapHead()
 {
     Must(state.sending == State::sendingUndecided);
 
@@ -706,7 +706,7 @@ void ICAPModXact::parseIcapHead()
         stopWriting(true);
 }
 
-bool ICAPModXact::validate200Ok()
+bool Adaptation::Icap::ModXact::validate200Ok()
 {
     if (ICAP::methodRespmod == service().cfg().method) {
         if (!gotEncapsulated("res-hdr"))
@@ -725,7 +725,7 @@ bool ICAPModXact::validate200Ok()
     return false;
 }
 
-void ICAPModXact::handle100Continue()
+void Adaptation::Icap::ModXact::handle100Continue()
 {
     Must(state.writing == State::writingPaused);
     // server must not respond before the end of preview: we may send ieof
@@ -743,7 +743,7 @@ void ICAPModXact::handle100Continue()
     writeMore();
 }
 
-void ICAPModXact::handle200Ok()
+void Adaptation::Icap::ModXact::handle200Ok()
 {
     state.parsing = State::psHttpHeader;
     state.sending = State::sendingAdapted;
@@ -751,7 +751,7 @@ void ICAPModXact::handle200Ok()
     checkConsuming();
 }
 
-void ICAPModXact::handle204NoContent()
+void Adaptation::Icap::ModXact::handle204NoContent()
 {
     stopParsing();
     prepEchoing();
@@ -760,7 +760,7 @@ void ICAPModXact::handle204NoContent()
 // Called when we receive a 204 No Content response and
 // when we are trying to bypass a service failure.
 // We actually start sending (echoig or not) in startSending.
-void ICAPModXact::prepEchoing()
+void Adaptation::Icap::ModXact::prepEchoing()
 {
     disableBypass("preparing to echo content");
 
@@ -770,7 +770,7 @@ void ICAPModXact::prepEchoing()
     // Instead, we simply write the HTTP message and "clone" it by parsing.
 
     HttpMsg *oldHead = virgin.header;
-    debugs(93, 7, "ICAPModXact cloning virgin message " << oldHead);
+    debugs(93, 7, HERE << "cloning virgin message " << oldHead);
 
     MemBuf httpBuf;
 
@@ -802,7 +802,7 @@ void ICAPModXact::prepEchoing()
 
     httpBuf.clean();
 
-    debugs(93, 7, "ICAPModXact cloned virgin message " << oldHead << " to " <<
+    debugs(93, 7, HERE << "cloned virgin message " << oldHead << " to " <<
            newHead);
 
     // setup adapted body pipe if needed
@@ -827,7 +827,7 @@ void ICAPModXact::prepEchoing()
     }
 }
 
-void ICAPModXact::handleUnknownScode()
+void Adaptation::Icap::ModXact::handleUnknownScode()
 {
     stopParsing();
     stopBackup();
@@ -837,7 +837,7 @@ void ICAPModXact::handleUnknownScode()
     throw TexcHere("Unsupported ICAP status code");
 }
 
-void ICAPModXact::parseHttpHead()
+void Adaptation::Icap::ModXact::parseHttpHead()
 {
     if (gotEncapsulated("res-hdr") || gotEncapsulated("req-hdr")) {
         maybeAllocateHttpMsg();
@@ -863,7 +863,7 @@ void ICAPModXact::parseHttpHead()
 }
 
 // parses both HTTP and ICAP headers
-bool ICAPModXact::parseHead(HttpMsg *head)
+bool Adaptation::Icap::ModXact::parseHead(HttpMsg *head)
 {
     Must(head);
     debugs(93, 5, HERE << "have " << readBuf.contentSize() << " head bytes to parse" <<
@@ -884,7 +884,7 @@ bool ICAPModXact::parseHead(HttpMsg *head)
     return true;
 }
 
-void ICAPModXact::decideOnParsingBody()
+void Adaptation::Icap::ModXact::decideOnParsingBody()
 {
     if (gotEncapsulated("res-body") || gotEncapsulated("req-body")) {
         debugs(93, 5, HERE << "expecting a body");
@@ -899,7 +899,7 @@ void ICAPModXact::decideOnParsingBody()
     }
 }
 
-void ICAPModXact::parseBody()
+void Adaptation::Icap::ModXact::parseBody()
 {
     Must(state.parsing == State::psBody);
     Must(bodyParser);
@@ -940,12 +940,12 @@ void ICAPModXact::parseBody()
     }
 }
 
-void ICAPModXact::stopParsing()
+void Adaptation::Icap::ModXact::stopParsing()
 {
     if (state.parsing == State::psDone)
         return;
 
-    debugs(93, 7, "ICAPModXact will no longer parse" << status());
+    debugs(93, 7, HERE << "will no longer parse" << status());
 
     delete bodyParser;
 
@@ -955,7 +955,7 @@ void ICAPModXact::stopParsing()
 }
 
 // HTTP side added virgin body data
-void ICAPModXact::noteMoreBodyDataAvailable(BodyPipe::Pointer)
+void Adaptation::Icap::ModXact::noteMoreBodyDataAvailable(BodyPipe::Pointer)
 {
     writeMore();
 
@@ -964,7 +964,7 @@ void ICAPModXact::noteMoreBodyDataAvailable(BodyPipe::Pointer)
 }
 
 // HTTP side sent us all virgin info
-void ICAPModXact::noteBodyProductionEnded(BodyPipe::Pointer)
+void Adaptation::Icap::ModXact::noteBodyProductionEnded(BodyPipe::Pointer)
 {
     Must(virgin.body_pipe->productionEnded());
 
@@ -977,7 +977,7 @@ void ICAPModXact::noteBodyProductionEnded(BodyPipe::Pointer)
 
 // body producer aborted, but the initiator may still want to know
 // the answer, even though the HTTP message has been truncated
-void ICAPModXact::noteBodyProducerAborted(BodyPipe::Pointer)
+void Adaptation::Icap::ModXact::noteBodyProducerAborted(BodyPipe::Pointer)
 {
     Must(virgin.body_pipe->productionEnded());
 
@@ -990,7 +990,7 @@ void ICAPModXact::noteBodyProducerAborted(BodyPipe::Pointer)
 
 // adapted body consumer wants more adapted data and
 // possibly freed some buffer space
-void ICAPModXact::noteMoreBodySpaceAvailable(BodyPipe::Pointer)
+void Adaptation::Icap::ModXact::noteMoreBodySpaceAvailable(BodyPipe::Pointer)
 {
     if (state.sending == State::sendingVirgin)
         echoMore();
@@ -1001,13 +1001,13 @@ void ICAPModXact::noteMoreBodySpaceAvailable(BodyPipe::Pointer)
 }
 
 // adapted body consumer aborted
-void ICAPModXact::noteBodyConsumerAborted(BodyPipe::Pointer)
+void Adaptation::Icap::ModXact::noteBodyConsumerAborted(BodyPipe::Pointer)
 {
     mustStop("adapted body consumer aborted");
 }
 
 // internal cleanup
-void ICAPModXact::swanSong()
+void Adaptation::Icap::ModXact::swanSong()
 {
     debugs(93, 5, HERE << "swan sings" << status());
 
@@ -1019,10 +1019,10 @@ void ICAPModXact::swanSong()
         icapReply = NULL;
     }
 
-    ICAPXaction::swanSong();
+    Adaptation::Icap::Xaction::swanSong();
 }
 
-void ICAPModXact::makeRequestHeaders(MemBuf &buf)
+void Adaptation::Icap::ModXact::makeRequestHeaders(MemBuf &buf)
 {
     char ntoabuf[MAX_IPSTRLEN];
     /*
@@ -1033,7 +1033,7 @@ void ICAPModXact::makeRequestHeaders(MemBuf &buf)
     buf.Printf("Host: " SQUIDSTRINGPH ":%d\r\n", SQUIDSTRINGPRINT(s.host), s.port);
     buf.Printf("Date: %s\r\n", mkrfc1123(squid_curtime));
 
-    if (!TheICAPConfig.reuse_connections)
+    if (!TheConfig.reuse_connections)
         buf.Printf("Connection: close\r\n");
 
     // we must forward "Proxy-Authenticate" and "Proxy-Authorization"
@@ -1102,11 +1102,11 @@ void ICAPModXact::makeRequestHeaders(MemBuf &buf)
             virginBodySending.plan();
     }
 
-    if (TheICAPConfig.send_client_ip && request)
+    if (TheConfig.send_client_ip && request)
         if (!request->client_addr.IsAnyAddr() && !request->client_addr.IsNoAddr())
             buf.Printf("X-Client-IP: %s\r\n", request->client_addr.NtoA(ntoabuf,MAX_IPSTRLEN));
 
-    if (TheICAPConfig.send_client_username && request)
+    if (TheConfig.send_client_username && request)
         makeUsernameHeader(request, buf);
 
     // fprintf(stderr, "%s\n", buf.content());
@@ -1119,19 +1119,19 @@ void ICAPModXact::makeRequestHeaders(MemBuf &buf)
     httpBuf.clean();
 }
 
-void ICAPModXact::makeUsernameHeader(const HttpRequest *request, MemBuf &buf)
+void Adaptation::Icap::ModXact::makeUsernameHeader(const HttpRequest *request, MemBuf &buf)
 {
     if (const AuthUserRequest *auth = request->auth_user_request) {
         if (char const *name = auth->username()) {
-            const char *value = TheICAPConfig.client_username_encode ?
+            const char *value = TheConfig.client_username_encode ?
                                 base64_encode(name) : name;
-            buf.Printf("%s: %s\r\n", TheICAPConfig.client_username_header,
+            buf.Printf("%s: %s\r\n", TheConfig.client_username_header,
                        value);
         }
     }
 }
 
-void ICAPModXact::encapsulateHead(MemBuf &icapBuf, const char *section, MemBuf &httpBuf, const HttpMsg *head)
+void Adaptation::Icap::ModXact::encapsulateHead(MemBuf &icapBuf, const char *section, MemBuf &httpBuf, const HttpMsg *head)
 {
     // update ICAP header
     icapBuf.Printf("%s=%d, ", section, (int) httpBuf.contentSize());
@@ -1170,7 +1170,7 @@ void ICAPModXact::encapsulateHead(MemBuf &icapBuf, const char *section, MemBuf &
     delete headClone;
 }
 
-void ICAPModXact::packHead(MemBuf &httpBuf, const HttpMsg *head)
+void Adaptation::Icap::ModXact::packHead(MemBuf &httpBuf, const HttpMsg *head)
 {
     Packer p;
     packerToMemInit(&p, &httpBuf);
@@ -1179,9 +1179,9 @@ void ICAPModXact::packHead(MemBuf &httpBuf, const HttpMsg *head)
 }
 
 // decides whether to offer a preview and calculates its size
-void ICAPModXact::decideOnPreview()
+void Adaptation::Icap::ModXact::decideOnPreview()
 {
-    if (!TheICAPConfig.preview_enable) {
+    if (!TheConfig.preview_enable) {
         debugs(93, 5, HERE << "preview disabled by squid.conf");
         return;
     }
@@ -1192,7 +1192,7 @@ void ICAPModXact::decideOnPreview()
     const String urlPath = request ? request->urlpath : String();
     size_t wantedSize;
     if (!service().wantsPreview(urlPath, wantedSize)) {
-        debugs(93, 5, "ICAPModXact should not offer preview for " << urlPath);
+        debugs(93, 5, HERE << "should not offer preview for " << urlPath);
         return;
     }
 
@@ -1209,7 +1209,7 @@ void ICAPModXact::decideOnPreview()
         if (virginBody.knownSize())
             ad = XMIN(static_cast<uint64_t>(ad), virginBody.size()); // not more than we have
 
-    debugs(93, 5, "ICAPModXact should offer " << ad << "-byte preview " <<
+    debugs(93, 5, HERE << "should offer " << ad << "-byte preview " <<
            "(service wanted " << wantedSize << ")");
 
     preview.enable(ad);
@@ -1217,7 +1217,7 @@ void ICAPModXact::decideOnPreview()
 }
 
 // decides whether to allow 204 responses
-bool ICAPModXact::shouldAllow204()
+bool Adaptation::Icap::ModXact::shouldAllow204()
 {
     if (!service().allows204())
         return false;
@@ -1226,7 +1226,7 @@ bool ICAPModXact::shouldAllow204()
 }
 
 // used by shouldAllow204 and decideOnRetries
-bool ICAPModXact::canBackupEverything() const
+bool Adaptation::Icap::ModXact::canBackupEverything() const
 {
     if (!virginBody.expected())
         return true; // no body means no problems with backup
@@ -1243,7 +1243,7 @@ bool ICAPModXact::canBackupEverything() const
 
 // Decide whether this transaction can be retried if pconn fails
 // Must be called after decideOnPreview and before openConnection()
-void ICAPModXact::decideOnRetries()
+void Adaptation::Icap::ModXact::decideOnRetries()
 {
     if (!isRetriable)
         return; // no, already decided
@@ -1263,7 +1263,7 @@ void ICAPModXact::decideOnRetries()
 // structures were initialized. This is not the case when there is no body
 // or the body is known to be empty, because the virgin message will lack a
 // body_pipe. So we handle preview of null-body and zero-size bodies here.
-void ICAPModXact::finishNullOrEmptyBodyPreview(MemBuf &buf)
+void Adaptation::Icap::ModXact::finishNullOrEmptyBodyPreview(MemBuf &buf)
 {
     Must(!virginBodyWriting.active()); // one reason we handle it here
     Must(!virgin.body_pipe);          // another reason we handle it here
@@ -1277,9 +1277,9 @@ void ICAPModXact::finishNullOrEmptyBodyPreview(MemBuf &buf)
     Must(preview.ieof());
 }
 
-void ICAPModXact::fillPendingStatus(MemBuf &buf) const
+void Adaptation::Icap::ModXact::fillPendingStatus(MemBuf &buf) const
 {
-    ICAPXaction::fillPendingStatus(buf);
+    Adaptation::Icap::Xaction::fillPendingStatus(buf);
 
     if (state.serviceWaiting)
         buf.append("U", 1);
@@ -1311,9 +1311,9 @@ void ICAPModXact::fillPendingStatus(MemBuf &buf) const
         buf.append("Y", 1);
 }
 
-void ICAPModXact::fillDoneStatus(MemBuf &buf) const
+void Adaptation::Icap::ModXact::fillDoneStatus(MemBuf &buf) const
 {
-    ICAPXaction::fillDoneStatus(buf);
+    Adaptation::Icap::Xaction::fillDoneStatus(buf);
 
     if (!virgin.body_pipe)
         buf.append("R", 1);
@@ -1336,7 +1336,7 @@ void ICAPModXact::fillDoneStatus(MemBuf &buf) const
         buf.append("S", 1);
 }
 
-bool ICAPModXact::gotEncapsulated(const char *section) const
+bool Adaptation::Icap::ModXact::gotEncapsulated(const char *section) const
 {
     return icapReply->header.getByNameListMember("Encapsulated",
             section, ',').size() > 0;
@@ -1345,7 +1345,7 @@ bool ICAPModXact::gotEncapsulated(const char *section) const
 // calculate whether there is a virgin HTTP body and
 // whether its expected size is known
 // TODO: rename because we do not just estimate
-void ICAPModXact::estimateVirginBody()
+void Adaptation::Icap::ModXact::estimateVirginBody()
 {
     // note: lack of size info may disable previews and 204s
 
@@ -1366,7 +1366,7 @@ void ICAPModXact::estimateVirginBody()
     // expectingBody returns true for zero-sized bodies, but we will not
     // get a pipe for that body, so we treat the message as bodyless
     if (method != METHOD_NONE && msg->expectingBody(method, size) && size) {
-        debugs(93, 6, "ICAPModXact expects virgin body from " <<
+        debugs(93, 6, HERE << "expects virgin body from " <<
                virgin.body_pipe << "; size: " << size);
 
         virginBody.expect(size);
@@ -1380,13 +1380,13 @@ void ICAPModXact::estimateVirginBody()
         // make sure TheBackupLimit is in-sync with the buffer size
         Must(TheBackupLimit <= static_cast<size_t>(msg->body_pipe->buf().max_capacity));
     } else {
-        debugs(93, 6, "ICAPModXact does not expect virgin body");
+        debugs(93, 6, HERE << "does not expect virgin body");
         Must(msg->body_pipe == NULL);
         checkConsuming();
     }
 }
 
-void ICAPModXact::makeAdaptedBodyPipe(const char *what)
+void Adaptation::Icap::ModXact::makeAdaptedBodyPipe(const char *what)
 {
     Must(!adapted.body_pipe);
     Must(!adapted.header->body_pipe);
@@ -1397,29 +1397,29 @@ void ICAPModXact::makeAdaptedBodyPipe(const char *what)
 }
 
 
-// TODO: Move SizedEstimate, MemBufBackup, and ICAPPreview elsewhere
+// TODO: Move SizedEstimate and Preview elsewhere
 
-SizedEstimate::SizedEstimate()
+Adaptation::Icap::SizedEstimate::SizedEstimate()
         : theData(dtUnexpected)
 {}
 
-void SizedEstimate::expect(int64_t aSize)
+void Adaptation::Icap::SizedEstimate::expect(int64_t aSize)
 {
     theData = (aSize >= 0) ? aSize : (int64_t)dtUnknown;
 }
 
-bool SizedEstimate::expected() const
+bool Adaptation::Icap::SizedEstimate::expected() const
 {
     return theData != dtUnexpected;
 }
 
-bool SizedEstimate::knownSize() const
+bool Adaptation::Icap::SizedEstimate::knownSize() const
 {
     Must(expected());
     return theData != dtUnknown;
 }
 
-uint64_t SizedEstimate::size() const
+uint64_t Adaptation::Icap::SizedEstimate::size() const
 {
     Must(knownSize());
     return static_cast<uint64_t>(theData);
@@ -1427,39 +1427,39 @@ uint64_t SizedEstimate::size() const
 
 
 
-VirginBodyAct::VirginBodyAct(): theStart(0), theState(stUndecided)
+Adaptation::Icap::VirginBodyAct::VirginBodyAct(): theStart(0), theState(stUndecided)
 {}
 
-void VirginBodyAct::plan()
+void Adaptation::Icap::VirginBodyAct::plan()
 {
     Must(!disabled());
     Must(!theStart); // not started
     theState = stActive;
 }
 
-void VirginBodyAct::disable()
+void Adaptation::Icap::VirginBodyAct::disable()
 {
     theState = stDisabled;
 }
 
-void VirginBodyAct::progress(size_t size)
+void Adaptation::Icap::VirginBodyAct::progress(size_t size)
 {
     Must(active());
     Must(size >= 0);
     theStart += static_cast<int64_t>(size);
 }
 
-uint64_t VirginBodyAct::offset() const
+uint64_t Adaptation::Icap::VirginBodyAct::offset() const
 {
     Must(active());
     return static_cast<uint64_t>(theStart);
 }
 
 
-ICAPPreview::ICAPPreview(): theWritten(0), theAd(0), theState(stDisabled)
+Adaptation::Icap::Preview::Preview(): theWritten(0), theAd(0), theState(stDisabled)
 {}
 
-void ICAPPreview::enable(size_t anAd)
+void Adaptation::Icap::Preview::enable(size_t anAd)
 {
     // TODO: check for anAd not exceeding preview size limit
     Must(anAd >= 0);
@@ -1468,36 +1468,36 @@ void ICAPPreview::enable(size_t anAd)
     theState = stWriting;
 }
 
-bool ICAPPreview::enabled() const
+bool Adaptation::Icap::Preview::enabled() const
 {
     return theState != stDisabled;
 }
 
-size_t ICAPPreview::ad() const
+size_t Adaptation::Icap::Preview::ad() const
 {
     Must(enabled());
     return theAd;
 }
 
-bool ICAPPreview::done() const
+bool Adaptation::Icap::Preview::done() const
 {
     Must(enabled());
     return theState >= stIeof;
 }
 
-bool ICAPPreview::ieof() const
+bool Adaptation::Icap::Preview::ieof() const
 {
     Must(enabled());
     return theState == stIeof;
 }
 
-size_t ICAPPreview::debt() const
+size_t Adaptation::Icap::Preview::debt() const
 {
     Must(enabled());
     return done() ? 0 : (theAd - theWritten);
 }
 
-void ICAPPreview::wrote(size_t size, bool wroteEof)
+void Adaptation::Icap::Preview::wrote(size_t size, bool wroteEof)
 {
     Must(enabled());
 
@@ -1512,7 +1512,7 @@ void ICAPPreview::wrote(size_t size, bool wroteEof)
             theState = stDone;
 }
 
-bool ICAPModXact::fillVirginHttpHeader(MemBuf &mb) const
+bool Adaptation::Icap::ModXact::fillVirginHttpHeader(MemBuf &mb) const
 {
     if (virgin.header == NULL)
         return false;
@@ -1523,20 +1523,20 @@ bool ICAPModXact::fillVirginHttpHeader(MemBuf &mb) const
 }
 
 
-/* ICAPModXactLauncher */
+/* Adaptation::Icap::ModXactLauncher */
 
-ICAPModXactLauncher::ICAPModXactLauncher(Adaptation::Initiator *anInitiator, HttpMsg *virginHeader, HttpRequest *virginCause, Adaptation::ServicePointer aService):
-        AsyncJob("ICAPModXactLauncher"),
-        ICAPLauncher("ICAPModXactLauncher", anInitiator, aService)
+Adaptation::Icap::ModXactLauncher::ModXactLauncher(Adaptation::Initiator *anInitiator, HttpMsg *virginHeader, HttpRequest *virginCause, Adaptation::ServicePointer aService):
+        AsyncJob("Adaptation::Icap::ModXactLauncher"),
+        Adaptation::Icap::Launcher("Adaptation::Icap::ModXactLauncher", anInitiator, aService)
 {
     virgin.setHeader(virginHeader);
     virgin.setCause(virginCause);
 }
 
-ICAPXaction *ICAPModXactLauncher::createXaction()
+Adaptation::Icap::Xaction *Adaptation::Icap::ModXactLauncher::createXaction()
 {
-    ICAPServiceRep::Pointer s =
-        dynamic_cast<ICAPServiceRep*>(theService.getRaw());
+    Adaptation::Icap::ServiceRep::Pointer s =
+        dynamic_cast<Adaptation::Icap::ServiceRep*>(theService.getRaw());
     Must(s != NULL);
-    return new ICAPModXact(this, virgin.header, virgin.cause, s);
+    return new Adaptation::Icap::ModXact(this, virgin.header, virgin.cause, s);
 }
similarity index 90%
rename from src/ICAP/ICAPModXact.h
rename to src/adaptation/icap/ModXact.h
index ccd1b4d76e72d9973627795b51f53488afd6603f..a5e00616adb0e502667de1af74f3d32f0c621e0f 100644 (file)
@@ -35,9 +35,9 @@
 #define SQUID_ICAPMODXACT_H
 
 #include "BodyPipe.h"
-#include "ICAPXaction.h"
-#include "ICAPInOut.h"
-#include "ICAPLauncher.h"
+#include "adaptation/icap/Xaction.h"
+#include "adaptation/icap/InOut.h"
+#include "adaptation/icap/Launcher.h"
 
 /*
  * ICAPModXact implements ICAP REQMOD and RESPMOD transaction using
@@ -52,6 +52,9 @@
 
 class ChunkedCodingParser;
 
+namespace Adaptation {
+namespace Icap {
+
 // estimated future presence and size of something (e.g., HTTP body)
 
 class SizedEstimate
@@ -104,11 +107,11 @@ private:
 
 // maintains preview-related sizes
 
-class ICAPPreview
+class Preview
 {
 
 public:
-    ICAPPreview();            // disabled
+    Preview();            // disabled
     void enable(size_t anAd); // enabled with advertised size
     bool enabled() const;
 
@@ -127,11 +130,11 @@ private:
     enum State { stDisabled, stWriting, stIeof, stDone } theState;
 };
 
-class ICAPModXact: public ICAPXaction, public BodyProducer, public BodyConsumer
+class ModXact: public Xaction, public BodyProducer, public BodyConsumer
 {
 
 public:
-    ICAPModXact(Adaptation::Initiator *anInitiator, HttpMsg *virginHeader, HttpRequest *virginCause, ICAPServiceRep::Pointer &s);
+    ModXact(Adaptation::Initiator *anInitiator, HttpMsg *virginHeader, HttpRequest *virginCause, ServiceRep::Pointer &s);
 
     // BodyProducer methods
     virtual void noteMoreBodySpaceAvailable(BodyPipe::Pointer);
@@ -153,8 +156,8 @@ public:
     void noteServiceReady();
 
 public:
-    ICAPInOut virgin;
-    ICAPInOut adapted;
+    InOut virgin;
+    InOut adapted;
 
 protected:
     // bypasses exceptions if needed and possible
@@ -253,7 +256,7 @@ private:
     VirginBodyAct virginBodyWriting; // virgin body writing state
     VirginBodyAct virginBodySending;  // virgin body sending state
     uint64_t virginConsumed;        // virgin data consumed so far
-    ICAPPreview preview; // use for creating (writing) the preview
+    Preview preview; // use for creating (writing) the preview
 
     ChunkedCodingParser *bodyParser; // ICAP response body parser
 
@@ -302,23 +305,27 @@ private:
                      } sending;
     } state;
 
-    CBDATA_CLASS2(ICAPModXact);
+    CBDATA_CLASS2(ModXact);
 };
 
-// An ICAPLauncher that stores ICAPModXact construction info and
-// creates ICAPModXact when needed
-class ICAPModXactLauncher: public ICAPLauncher
+// An Launcher that stores ModXact construction info and
+// creates ModXact when needed
+class ModXactLauncher: public Launcher
 {
 public:
-    ICAPModXactLauncher(Adaptation::Initiator *anInitiator, HttpMsg *virginHeader, HttpRequest *virginCause, Adaptation::ServicePointer s);
+    ModXactLauncher(Adaptation::Initiator *anInitiator, HttpMsg *virginHeader, HttpRequest *virginCause, Adaptation::ServicePointer s);
 
 protected:
-    virtual ICAPXaction *createXaction();
+    virtual Xaction *createXaction();
 
-    ICAPInOut virgin;
+    InOut virgin;
 
 private:
-    CBDATA_CLASS2(ICAPModXactLauncher);
+    CBDATA_CLASS2(ModXactLauncher);
 };
 
+
+} // namespace Icap
+} // namespace Adaptation
+
 #endif /* SQUID_ICAPMOD_XACT_H */
diff --git a/src/adaptation/icap/OptXact.cc b/src/adaptation/icap/OptXact.cc
new file mode 100644 (file)
index 0000000..4696945
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * DEBUG: section 93    ICAP (RFC 3507) Client
+ */
+
+#include "squid.h"
+#include "comm.h"
+#include "HttpReply.h"
+
+#include "adaptation/icap/OptXact.h"
+#include "adaptation/icap/Options.h"
+#include "TextException.h"
+
+CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Icap, OptXact);
+CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Icap, OptXactLauncher);
+
+
+Adaptation::Icap::OptXact::OptXact(Adaptation::Initiator *anInitiator, Adaptation::Icap::ServiceRep::Pointer &aService):
+        AsyncJob("Adaptation::Icap::OptXact"),
+        Adaptation::Icap::Xaction("Adaptation::Icap::OptXact", anInitiator, aService)
+{
+}
+
+void Adaptation::Icap::OptXact::start()
+{
+    Adaptation::Icap::Xaction::start();
+
+    openConnection();
+}
+
+void Adaptation::Icap::OptXact::handleCommConnected()
+{
+    scheduleRead();
+
+    MemBuf requestBuf;
+    requestBuf.init();
+    makeRequest(requestBuf);
+    debugs(93, 9, HERE << "request " << status() << ":\n" <<
+           (requestBuf.terminate(), requestBuf.content()));
+
+    scheduleWrite(requestBuf);
+}
+
+void Adaptation::Icap::OptXact::makeRequest(MemBuf &buf)
+{
+    const Adaptation::Service &s = service();
+    const String uri = s.cfg().uri;
+    buf.Printf("OPTIONS " SQUIDSTRINGPH " ICAP/1.0\r\n", SQUIDSTRINGPRINT(uri));
+    const String host = s.cfg().host;
+    buf.Printf("Host: " SQUIDSTRINGPH ":%d\r\n", SQUIDSTRINGPRINT(host), s.cfg().port);
+    buf.append(ICAP::crlf, 2);
+}
+
+void Adaptation::Icap::OptXact::handleCommWrote(size_t size)
+{
+    debugs(93, 9, HERE << "finished writing " << size <<
+           "-byte request " << status());
+}
+
+// comm module read a portion of the ICAP response for us
+void Adaptation::Icap::OptXact::handleCommRead(size_t)
+{
+    if (HttpMsg *r = parseResponse()) {
+        sendAnswer(r);
+        Must(done()); // there should be nothing else to do
+        return;
+    }
+
+    scheduleRead();
+}
+
+HttpMsg *Adaptation::Icap::OptXact::parseResponse()
+{
+    debugs(93, 5, HERE << "have " << readBuf.contentSize() << " bytes to parse" <<
+           status());
+    debugs(93, 5, HERE << "\n" << readBuf.content());
+
+    HttpReply *r = new HttpReply;
+    r->protoPrefix = "ICAP/"; // TODO: make an IcapReply class?
+
+    if (!parseHttpMsg(r)) { // throws on errors
+        delete r;
+        return 0;
+    }
+
+    if (httpHeaderHasConnDir(&r->header, "close"))
+        reuseConnection = false;
+
+    return r;
+}
+
+/* Adaptation::Icap::OptXactLauncher */
+
+Adaptation::Icap::OptXactLauncher::OptXactLauncher(Adaptation::Initiator *anInitiator, Adaptation::ServicePointer aService):
+        AsyncJob("Adaptation::Icap::OptXactLauncher"),
+        Adaptation::Icap::Launcher("Adaptation::Icap::OptXactLauncher", anInitiator, aService)
+{
+}
+
+Adaptation::Icap::Xaction *Adaptation::Icap::OptXactLauncher::createXaction()
+{
+    Adaptation::Icap::ServiceRep::Pointer s =
+        dynamic_cast<Adaptation::Icap::ServiceRep*>(theService.getRaw());
+    Must(s != NULL);
+    return new Adaptation::Icap::OptXact(this, s);
+}
similarity index 73%
rename from src/ICAP/ICAPOptXact.h
rename to src/adaptation/icap/OptXact.h
index abbe153a2de59d84b0281cc0f374c5d4de1e9bb4..4c5f7cf3f0b5145d5b417855be3c793af0700726 100644 (file)
 #ifndef SQUID_ICAPOPTXACT_H
 #define SQUID_ICAPOPTXACT_H
 
-#include "ICAPXaction.h"
-#include "ICAPLauncher.h"
+#include "adaptation/icap/Xaction.h"
+#include "adaptation/icap/Launcher.h"
 
-class ICAPOptions;
 
+namespace Adaptation {
+namespace Icap {
 
-/* ICAPOptXact sends an ICAP OPTIONS request to the ICAP service,
+class Adaptation::Icap::Options;
+
+
+/* OptXact sends an ICAP OPTIONS request to the ICAP service,
  * parses the ICAP response, and sends it to the initiator. A NULL response
  * means the ICAP service could not be contacted or did not return any
  * valid response. */
 
-class ICAPOptXact: public ICAPXaction
+class OptXact: public Xaction
 {
 
 public:
-    ICAPOptXact(Adaptation::Initiator *anInitiator, ICAPServiceRep::Pointer &aService);
+    OptXact(Adaptation::Initiator *anInitiator, ServiceRep::Pointer &aService);
 
 protected:
     virtual void start();
@@ -62,21 +66,25 @@ protected:
     void startReading();
 
 private:
-    CBDATA_CLASS2(ICAPOptXact);
+    CBDATA_CLASS2(OptXact);
 };
 
-// An ICAPLauncher that stores ICAPOptXact construction info and
-// creates ICAPOptXact when needed
-class ICAPOptXactLauncher: public ICAPLauncher
+// An Launcher that stores OptXact construction info and
+// creates OptXact when needed
+class OptXactLauncher: public Launcher
 {
 public:
-    ICAPOptXactLauncher(Adaptation::Initiator *anInitiator, Adaptation::ServicePointer aService);
+    OptXactLauncher(Adaptation::Initiator *anInitiator, Adaptation::ServicePointer aService);
 
 protected:
-    virtual ICAPXaction *createXaction();
+    virtual Xaction *createXaction();
 
 private:
-    CBDATA_CLASS2(ICAPOptXactLauncher);
+    CBDATA_CLASS2(OptXactLauncher);
 };
 
+
+} // namespace Icap
+} // namespace Adaptation
+
 #endif /* SQUID_ICAPOPTXACT_H */
similarity index 69%
rename from src/ICAP/ICAPOptions.cc
rename to src/adaptation/icap/Options.cc
index 4d4ff1029f439aab053c93e9ceef101c07ae6b7f..50199234c7bbe55cdc2077b726a0394916fd4784 100644 (file)
@@ -1,14 +1,14 @@
 #include "squid.h"
 #include "wordlist.h"
 #include "HttpReply.h"
-#include "ICAPOptions.h"
+#include "adaptation/icap/Options.h"
 #include "TextException.h"
-#include "ICAPConfig.h"
+#include "adaptation/icap/Config.h"
 #include "SquidTime.h"
 
-extern ICAPConfig TheICAPConfig;
+extern Adaptation::Icap::Config Adaptation::Icap::TheConfig;
 
-ICAPOptions::ICAPOptions(): error("unconfigured"),
+Adaptation::Icap::Options::Options(): error("unconfigured"),
         max_connections(-1), allow204(false),
         preview(-1), theTTL(-1)
 {
@@ -24,14 +24,14 @@ ICAPOptions::ICAPOptions(): error("unconfigured"),
     theTransfers.byDefault = &theTransfers.complete;
 }
 
-ICAPOptions::~ICAPOptions()
+Adaptation::Icap::Options::~Options()
 {
 }
 
 // future optimization note: this method is called by ICAP ACL code at least
 // twice for each HTTP message to see if the message should be ignored. For any
 // non-ignored HTTP message, ICAP calls to check whether a preview is needed.
-ICAPOptions::TransferKind ICAPOptions::transferKind(const String &urlPath) const
+Adaptation::Icap::Options::TransferKind Adaptation::Icap::Options::transferKind(const String &urlPath) const
 {
     if (theTransfers.preview.matches(urlPath))
         return xferPreview;
@@ -42,34 +42,34 @@ ICAPOptions::TransferKind ICAPOptions::transferKind(const String &urlPath) const
     if (theTransfers.ignore.matches(urlPath))
         return xferIgnore;
 
-    debugs(93,7, "ICAPOptions url " << urlPath << " matches no extensions; " <<
+    debugs(93,7, HERE << "url " << urlPath << " matches no extensions; " <<
            "using default: " << theTransfers.byDefault->name);
     return theTransfers.byDefault->kind;
 }
 
-bool ICAPOptions::valid() const
+bool Adaptation::Icap::Options::valid() const
 {
     return !error;
 }
 
-bool ICAPOptions::fresh() const
+bool Adaptation::Icap::Options::fresh() const
 {
     return squid_curtime <= expire();
 }
 
-int ICAPOptions::ttl() const
+int Adaptation::Icap::Options::ttl() const
 {
     Must(valid());
-    return theTTL >= 0 ? theTTL : TheICAPConfig.default_options_ttl;
+    return theTTL >= 0 ? theTTL : TheConfig.default_options_ttl;
 }
 
-time_t ICAPOptions::expire() const
+time_t Adaptation::Icap::Options::expire() const
 {
     Must(valid());
     return theTimestamp + ttl();
 }
 
-void ICAPOptions::configure(const HttpReply *reply)
+void Adaptation::Icap::Options::configure(const HttpReply *reply)
 {
     error = NULL; // reset initial "unconfigured" value (or an old error?)
 
@@ -113,14 +113,14 @@ void ICAPOptions::configure(const HttpReply *reply)
     cfgTransferList(h, theTransfers.complete);
 }
 
-void ICAPOptions::cfgMethod(ICAP::Method m)
+void Adaptation::Icap::Options::cfgMethod(ICAP::Method m)
 {
     Must(m != ICAP::methodNone);
     methods += m;
 }
 
 // TODO: HttpHeader should provide a general method for this type of conversion
-void ICAPOptions::cfgIntHeader(const HttpHeader *h, const char *fname, int &value)
+void Adaptation::Icap::Options::cfgIntHeader(const HttpHeader *h, const char *fname, int &value)
 {
     const String s = h->getByName(fname);
 
@@ -129,10 +129,10 @@ void ICAPOptions::cfgIntHeader(const HttpHeader *h, const char *fname, int &valu
     else
         value = -1;
 
-    debugs(93,5, "ICAPOptions::cfgIntHeader " << fname << ": " << value);
+    debugs(93,5, HERE << "int header: " << fname << ": " << value);
 }
 
-void ICAPOptions::cfgTransferList(const HttpHeader *h, TransferList &list)
+void Adaptation::Icap::Options::cfgTransferList(const HttpHeader *h, TransferList &list)
 {
     const String buf = h->getByName(list.name);
     bool foundStar = false;
@@ -140,32 +140,31 @@ void ICAPOptions::cfgTransferList(const HttpHeader *h, TransferList &list)
 
     if (foundStar) {
         theTransfers.byDefault = &list;
-        debugs(93,5, "ICAPOptions::cfgTransferList: " <<
-               "set default transfer to " << list.name);
+        debugs(93,5, HERE << "set default transfer to " << list.name);
     }
 
-    list.report(5, "ICAPOptions::cfgTransferList: ");
+    list.report(5, "Adaptation::Icap::Options::cfgTransferList: ");
 }
 
 
-/* ICAPOptions::TransferList */
+/* Adaptation::Icap::Options::TransferList */
 
-ICAPOptions::TransferList::TransferList(): extensions(NULL), name(NULL),
+Adaptation::Icap::Options::TransferList::TransferList(): extensions(NULL), name(NULL),
         kind(xferNone)
 {
 };
 
-ICAPOptions::TransferList::~TransferList()
+Adaptation::Icap::Options::TransferList::~TransferList()
 {
     wordlistDestroy(&extensions);
 };
 
-void ICAPOptions::TransferList::add(const char *extension)
+void Adaptation::Icap::Options::TransferList::add(const char *extension)
 {
     wordlistAdd(&extensions, extension);
 };
 
-bool ICAPOptions::TransferList::matches(const String &urlPath) const
+bool Adaptation::Icap::Options::TransferList::matches(const String &urlPath) const
 {
     const int urlLen = urlPath.size();
     for (wordlist *e = extensions; e; e = e->next) {
@@ -178,17 +177,17 @@ bool ICAPOptions::TransferList::matches(const String &urlPath) const
             // RFC 3507 examples imply that extensions come without leading '.'
             if (urlPath[eOff-1] == '.' &&
                     strcmp(urlPath.termedBuf() + eOff, e->key) == 0) {
-                debugs(93,7, "ICAPOptions url " << urlPath << " matches " <<
+                debugs(93,7, HERE << "url " << urlPath << " matches " <<
                        name << " extension " << e->key);
                 return true;
             }
         }
     }
-    debugs(93,8, "ICAPOptions url " << urlPath << " matches no " << name << " extensions");
+    debugs(93,8, HERE << "url " << urlPath << " matches no " << name << " extensions");
     return false;
 }
 
-void ICAPOptions::TransferList::parse(const String &buf, bool &foundStar)
+void Adaptation::Icap::Options::TransferList::parse(const String &buf, bool &foundStar)
 {
     foundStar = false;
 
@@ -203,7 +202,7 @@ void ICAPOptions::TransferList::parse(const String &buf, bool &foundStar)
     }
 }
 
-void ICAPOptions::TransferList::report(int level, const char *prefix) const
+void Adaptation::Icap::Options::TransferList::report(int level, const char *prefix) const
 {
     if (extensions) {
         for (wordlist *e = extensions; e; e = e->next)
similarity index 91%
rename from src/ICAP/ICAPOptions.h
rename to src/adaptation/icap/Options.h
index 5999d3806fc4bf66529066a1b8fb2ab217329477..4ecc5c846b653f33a121e40b3cfbdc96d8a6ccae 100644 (file)
 #define SQUID_ICAPOPTIONS_H
 
 #include "squid.h"
-#include "ICAPServiceRep.h"
+#include "adaptation/icap/ServiceRep.h"
 
 class wordlist;
 
+namespace Adaptation {
+namespace Icap {
+
 /* Maintains options supported by a given ICAP service.
  * See RFC 3507, Section "4.10.2 OPTIONS Response". */
 
-class ICAPOptions
+class Options
 {
 
 public:
-    typedef void GetCallback(void *data, ICAPOptions *options);
-    static void Get(ICAPServiceRep::Pointer &service, GetCallback *cb, void *data);
+    typedef void GetCallback(void *data, Options *options);
+    static void Get(ServiceRep::Pointer &service, GetCallback *cb, void *data);
 
 public:
-    ICAPOptions();
-    ~ICAPOptions();
+    Options();
+    ~Options();
 
     void configure(const HttpReply *reply);
 
@@ -118,4 +121,8 @@ private:
 
 
 
+
+} // namespace Icap
+} // namespace Adaptation
+
 #endif /* SQUID_ICAPOPTIONS_H */
similarity index 63%
rename from src/ICAP/ICAPServiceRep.cc
rename to src/adaptation/icap/ServiceRep.cc
index bd743c09960cb32b18dd65ae9657bef0154a478e..c7b6da450f307da2fa05fceaf5b437cd6b4e702e 100644 (file)
@@ -5,39 +5,39 @@
 #include "squid.h"
 #include "TextException.h"
 #include "HttpReply.h"
-#include "ICAPServiceRep.h"
-#include "ICAPOptions.h"
-#include "ICAPOptXact.h"
+#include "adaptation/icap/ServiceRep.h"
+#include "adaptation/icap/Options.h"
+#include "adaptation/icap/OptXact.h"
 #include "ConfigParser.h"
-#include "ICAPConfig.h"
-#include "ICAPModXact.h"
+#include "adaptation/icap/Config.h"
+#include "adaptation/icap/ModXact.h"
 #include "SquidTime.h"
 
-CBDATA_CLASS_INIT(ICAPServiceRep);
+CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Icap, ServiceRep);
 
-ICAPServiceRep::ICAPServiceRep(const Adaptation::ServiceConfig &cfg):
-        AsyncJob("ICAPServiceRep"), Adaptation::Service(cfg),
+Adaptation::Icap::ServiceRep::ServiceRep(const Adaptation::ServiceConfig &cfg):
+        AsyncJob("Adaptation::Icap::ServiceRep"), Adaptation::Service(cfg),
         theOptions(NULL), theOptionsFetcher(0), theLastUpdate(0),
         theSessionFailures(0), isSuspended(0), notifying(false),
         updateScheduled(false), self(NULL),
         wasAnnouncedUp(true) // do not announce an "up" service at startup
 {}
 
-ICAPServiceRep::~ICAPServiceRep()
+Adaptation::Icap::ServiceRep::~ServiceRep()
 {
     Must(!theOptionsFetcher);
     changeOptions(0);
 }
 
 void
-ICAPServiceRep::setSelf(Pointer &aSelf)
+Adaptation::Icap::ServiceRep::setSelf(Pointer &aSelf)
 {
     assert(!self && aSelf != NULL);
     self = aSelf;
 }
 
 void
-ICAPServiceRep::finalize()
+Adaptation::Icap::ServiceRep::finalize()
 {
     Adaptation::Service::finalize();
     assert(self != NULL);
@@ -55,7 +55,7 @@ ICAPServiceRep::finalize()
     }
 }
 
-void ICAPServiceRep::invalidate()
+void Adaptation::Icap::ServiceRep::invalidate()
 {
     assert(self != NULL);
     Pointer savedSelf = self; // to prevent destruction when we nullify self
@@ -67,17 +67,17 @@ void ICAPServiceRep::invalidate()
     // TODO: it would be nice to invalidate cbdata(this) when not destroyed
 }
 
-void ICAPServiceRep::noteFailure()
+void Adaptation::Icap::ServiceRep::noteFailure()
 {
     ++theSessionFailures;
-    debugs(93,4, theSessionFailures << " ICAPService failures, out of " <<
-           TheICAPConfig.service_failure_limit << " allowed " << status());
+    debugs(93,4, HERE << " failure " << theSessionFailures << " out of " <<
+           TheConfig.service_failure_limit << " allowed " << status());
 
     if (isSuspended)
         return;
 
-    if (TheICAPConfig.service_failure_limit >= 0 &&
-            theSessionFailures > TheICAPConfig.service_failure_limit)
+    if (TheConfig.service_failure_limit >= 0 &&
+            theSessionFailures > TheConfig.service_failure_limit)
         suspend("too many failures");
 
     // TODO: Should bypass setting affect how much Squid tries to talk to
@@ -86,47 +86,47 @@ void ICAPServiceRep::noteFailure()
     // should be configurable.
 }
 
-void ICAPServiceRep::suspend(const char *reason)
+void Adaptation::Icap::ServiceRep::suspend(const char *reason)
 {
     if (isSuspended) {
-        debugs(93,4, "keeping ICAPService suspended, also for " << reason);
+        debugs(93,4, HERE << "keeping suspended, also for " << reason);
     } else {
         isSuspended = reason;
-        debugs(93,1, "suspending ICAPService for " << reason);
-        scheduleUpdate(squid_curtime + TheICAPConfig.service_revival_delay);
+        debugs(93,1, "suspending ICAP service for " << reason);
+        scheduleUpdate(squid_curtime + TheConfig.service_revival_delay);
         announceStatusChange("suspended", true);
     }
 }
 
-bool ICAPServiceRep::probed() const
+bool Adaptation::Icap::ServiceRep::probed() const
 {
     return theLastUpdate != 0;
 }
 
-bool ICAPServiceRep::hasOptions() const
+bool Adaptation::Icap::ServiceRep::hasOptions() const
 {
     return theOptions && theOptions->valid() && theOptions->fresh();
 }
 
-bool ICAPServiceRep::up() const
+bool Adaptation::Icap::ServiceRep::up() const
 {
     return self != NULL && !isSuspended && hasOptions();
 }
 
-bool ICAPServiceRep::wantsUrl(const String &urlPath) const
+bool Adaptation::Icap::ServiceRep::wantsUrl(const String &urlPath) const
 {
     Must(hasOptions());
-    return theOptions->transferKind(urlPath) != ICAPOptions::xferIgnore;
+    return theOptions->transferKind(urlPath) != Adaptation::Icap::Options::xferIgnore;
 }
 
-bool ICAPServiceRep::wantsPreview(const String &urlPath, size_t &wantedSize) const
+bool Adaptation::Icap::ServiceRep::wantsPreview(const String &urlPath, size_t &wantedSize) const
 {
     Must(hasOptions());
 
     if (theOptions->preview < 0)
         return false;
 
-    if (theOptions->transferKind(urlPath) != ICAPOptions::xferPreview)
+    if (theOptions->transferKind(urlPath) != Adaptation::Icap::Options::xferPreview)
         return false;
 
     wantedSize = theOptions->preview;
@@ -134,7 +134,7 @@ bool ICAPServiceRep::wantsPreview(const String &urlPath, size_t &wantedSize) con
     return true;
 }
 
-bool ICAPServiceRep::allows204() const
+bool Adaptation::Icap::ServiceRep::allows204() const
 {
     Must(hasOptions());
     return true; // in the future, we may have ACLs to prevent 204s
@@ -142,42 +142,42 @@ bool ICAPServiceRep::allows204() const
 
 
 static
-void ICAPServiceRep_noteTimeToUpdate(void *data)
+void ServiceRep_noteTimeToUpdate(void *data)
 {
-    ICAPServiceRep *service = static_cast<ICAPServiceRep*>(data);
+    Adaptation::Icap::ServiceRep *service = static_cast<Adaptation::Icap::ServiceRep*>(data);
     Must(service);
     service->noteTimeToUpdate();
 }
 
-void ICAPServiceRep::noteTimeToUpdate()
+void Adaptation::Icap::ServiceRep::noteTimeToUpdate()
 {
     if (self != NULL)
         updateScheduled = false;
 
     if (!self || theOptionsFetcher) {
-        debugs(93,5, "ICAPService ignores options update " << status());
+        debugs(93,5, HERE << "ignores options update " << status());
         return;
     }
 
-    debugs(93,5, "ICAPService performs a regular options update " << status());
+    debugs(93,5, HERE << "performs a regular options update " << status());
     startGettingOptions();
 }
 
 #if 0
 static
-void ICAPServiceRep_noteTimeToNotify(void *data)
+void Adaptation::Icap::ServiceRep_noteTimeToNotify(void *data)
 {
-    ICAPServiceRep *service = static_cast<ICAPServiceRep*>(data);
+    Adaptation::Icap::ServiceRep *service = static_cast<Adaptation::Icap::ServiceRep*>(data);
     Must(service);
     service->noteTimeToNotify();
 }
 #endif
 
-void ICAPServiceRep::noteTimeToNotify()
+void Adaptation::Icap::ServiceRep::noteTimeToNotify()
 {
     Must(!notifying);
     notifying = true;
-    debugs(93,7, "ICAPService notifies " << theClients.size() << " clients " <<
+    debugs(93,7, HERE << "notifies " << theClients.size() << " clients " <<
            status());
 
     // note: we must notify even if we are invalidated
@@ -193,11 +193,11 @@ void ICAPServiceRep::noteTimeToNotify()
     notifying = false;
 }
 
-void ICAPServiceRep::callWhenReady(AsyncCall::Pointer &cb)
+void Adaptation::Icap::ServiceRep::callWhenReady(AsyncCall::Pointer &cb)
 {
     Must(cb!=NULL);
 
-    debugs(93,5, HERE << "ICAPService is asked to call " << *cb <<
+    debugs(93,5, HERE << "Adaptation::Icap::Service is asked to call " << *cb <<
            " when ready " << status());
 
     Must(self != NULL);
@@ -217,20 +217,20 @@ void ICAPServiceRep::callWhenReady(AsyncCall::Pointer &cb)
         scheduleNotification();
 }
 
-void ICAPServiceRep::scheduleNotification()
+void Adaptation::Icap::ServiceRep::scheduleNotification()
 {
-    debugs(93,7, "ICAPService will notify " << theClients.size() << " clients");
-    CallJobHere(93, 5, this, ICAPServiceRep::noteTimeToNotify);
+    debugs(93,7, HERE << "will notify " << theClients.size() << " clients");
+    CallJobHere(93, 5, this, Adaptation::Icap::ServiceRep::noteTimeToNotify);
 }
 
-bool ICAPServiceRep::needNewOptions() const
+bool Adaptation::Icap::ServiceRep::needNewOptions() const
 {
     return self != NULL && !up();
 }
 
-void ICAPServiceRep::changeOptions(ICAPOptions *newOptions)
+void Adaptation::Icap::ServiceRep::changeOptions(Adaptation::Icap::Options *newOptions)
 {
-    debugs(93,8, "ICAPService changes options from " << theOptions << " to " <<
+    debugs(93,8, HERE << "changes options from " << theOptions << " to " <<
            newOptions << ' ' << status());
 
     delete theOptions;
@@ -243,7 +243,7 @@ void ICAPServiceRep::changeOptions(ICAPOptions *newOptions)
     announceStatusChange("down after an options fetch failure", true);
 }
 
-void ICAPServiceRep::checkOptions()
+void Adaptation::Icap::ServiceRep::checkOptions()
 {
     if (theOptions == NULL)
         return;
@@ -297,7 +297,7 @@ void ICAPServiceRep::checkOptions()
     }
 }
 
-void ICAPServiceRep::announceStatusChange(const char *downPhrase, bool important) const
+void Adaptation::Icap::ServiceRep::announceStatusChange(const char *downPhrase, bool important) const
 {
     if (wasAnnouncedUp == up()) // no significant changes to announce
         return;
@@ -312,68 +312,68 @@ void ICAPServiceRep::announceStatusChange(const char *downPhrase, bool important
 }
 
 // we are receiving ICAP OPTIONS response headers here or NULL on failures
-void ICAPServiceRep::noteAdaptationAnswer(HttpMsg *msg)
+void Adaptation::Icap::ServiceRep::noteAdaptationAnswer(HttpMsg *msg)
 {
     Must(theOptionsFetcher);
     clearAdaptation(theOptionsFetcher);
 
     Must(msg);
 
-    debugs(93,5, "ICAPService is interpreting new options " << status());
+    debugs(93,5, HERE << "is interpreting new options " << status());
 
-    ICAPOptions *newOptions = NULL;
+    Adaptation::Icap::Options *newOptions = NULL;
     if (HttpReply *r = dynamic_cast<HttpReply*>(msg)) {
-        newOptions = new ICAPOptions;
+        newOptions = new Adaptation::Icap::Options;
         newOptions->configure(r);
     } else {
-        debugs(93,1, "ICAPService got wrong options message " << status());
+        debugs(93,1, "ICAP service got wrong options message " << status());
     }
 
     handleNewOptions(newOptions);
 }
 
-void ICAPServiceRep::noteAdaptationQueryAbort(bool)
+void Adaptation::Icap::ServiceRep::noteAdaptationQueryAbort(bool)
 {
     Must(theOptionsFetcher);
     clearAdaptation(theOptionsFetcher);
 
-    debugs(93,3, "ICAPService failed to fetch options " << status());
+    debugs(93,3, HERE << "failed to fetch options " << status());
     handleNewOptions(0);
 }
 
-void ICAPServiceRep::handleNewOptions(ICAPOptions *newOptions)
+void Adaptation::Icap::ServiceRep::handleNewOptions(Adaptation::Icap::Options *newOptions)
 {
     // new options may be NULL
     changeOptions(newOptions);
 
-    debugs(93,3, "ICAPService got new options and is now " << status());
+    debugs(93,3, HERE << "got new options and is now " << status());
 
     scheduleUpdate(optionsFetchTime());
     scheduleNotification();
 }
 
-void ICAPServiceRep::startGettingOptions()
+void Adaptation::Icap::ServiceRep::startGettingOptions()
 {
     Must(!theOptionsFetcher);
-    debugs(93,6, "ICAPService will get new options " << status());
+    debugs(93,6, HERE << "will get new options " << status());
 
     // XXX: second "this" is "self"; this works but may stop if API changes
-    theOptionsFetcher = initiateAdaptation(new ICAPOptXactLauncher(this, this));
+    theOptionsFetcher = initiateAdaptation(new Adaptation::Icap::OptXactLauncher(this, this));
     Must(theOptionsFetcher);
-    // TODO: timeout in case ICAPOptXact never calls us back?
+    // TODO: timeout in case Adaptation::Icap::OptXact never calls us back?
     // Such a timeout should probably be a generic AsyncStart feature.
 }
 
-void ICAPServiceRep::scheduleUpdate(time_t when)
+void Adaptation::Icap::ServiceRep::scheduleUpdate(time_t when)
 {
     if (updateScheduled) {
-        debugs(93,7, "ICAPService reschedules update");
+        debugs(93,7, HERE << "reschedules update");
         // XXX: check whether the event is there because AR saw
         // an unreproducible eventDelete assertion on 2007/06/18
-        if (eventFind(&ICAPServiceRep_noteTimeToUpdate, this))
-            eventDelete(&ICAPServiceRep_noteTimeToUpdate, this);
+        if (eventFind(&ServiceRep_noteTimeToUpdate, this))
+            eventDelete(&ServiceRep_noteTimeToUpdate, this);
         else
-            debugs(93,1, "XXX: ICAPService lost an update event.");
+            debugs(93,1, "XXX: ICAP service lost an update event.");
         updateScheduled = false;
     }
 
@@ -387,33 +387,33 @@ void ICAPServiceRep::scheduleUpdate(time_t when)
     if (when < squid_curtime)
         when = squid_curtime;
 
-    // XXX: move hard-coded constants from here to TheICAPConfig
+    // XXX: move hard-coded constants from here to Adaptation::Icap::TheConfig
     const int minUpdateGap = 30; // seconds
     if (when < theLastUpdate + minUpdateGap)
         when = theLastUpdate + minUpdateGap;
 
     const int delay = when - squid_curtime;
-    debugs(93,5, "ICAPService will fetch OPTIONS in " << delay << " sec");
+    debugs(93,5, HERE << "will fetch OPTIONS in " << delay << " sec");
 
-    eventAdd("ICAPServiceRep::noteTimeToUpdate",
-             &ICAPServiceRep_noteTimeToUpdate, this, delay, 0, true);
+    eventAdd("Adaptation::Icap::ServiceRep::noteTimeToUpdate",
+             &ServiceRep_noteTimeToUpdate, this, delay, 0, true);
     updateScheduled = true;
 }
 
 // returns absolute time when OPTIONS should be fetched
 time_t
-ICAPServiceRep::optionsFetchTime() const
+Adaptation::Icap::ServiceRep::optionsFetchTime() const
 {
     if (theOptions && theOptions->valid()) {
         const time_t expire = theOptions->expire();
-        debugs(93,7, "ICAPService options expire on " << expire << " >= " << squid_curtime);
+        debugs(93,7, HERE << "options expire on " << expire << " >= " << squid_curtime);
 
         // conservative estimate of how long the OPTIONS transaction will take
-        // XXX: move hard-coded constants from here to TheICAPConfig
+        // XXX: move hard-coded constants from here to Adaptation::Icap::TheConfig
         const int expectedWait = 20; // seconds
 
         // Unknown or invalid (too small) expiration times should not happen.
-        // ICAPOptions should use the default TTL, and ICAP servers should not
+        // Adaptation::Icap::Options should use the default TTL, and ICAP servers should not
         // send invalid TTLs, but bugs and attacks happen.
         if (expire < expectedWait)
             return squid_curtime;
@@ -422,18 +422,18 @@ ICAPServiceRep::optionsFetchTime() const
     }
 
     // use revival delay as "expiration" time for a service w/o valid options
-    return squid_curtime + TheICAPConfig.service_revival_delay;
+    return squid_curtime + TheConfig.service_revival_delay;
 }
 
 Adaptation::Initiate *
-ICAPServiceRep::makeXactLauncher(Adaptation::Initiator *initiator,
+Adaptation::Icap::ServiceRep::makeXactLauncher(Adaptation::Initiator *initiator,
                                  HttpMsg *virgin, HttpRequest *cause)
 {
-    return new ICAPModXactLauncher(initiator, virgin, cause, this);
+    return new Adaptation::Icap::ModXactLauncher(initiator, virgin, cause, this);
 }
 
 // returns a temporary string depicting service status, for debugging
-const char *ICAPServiceRep::status() const
+const char *Adaptation::Icap::ServiceRep::status() const
 {
     static MemBuf buf;
 
similarity index 90%
rename from src/ICAP/ICAPServiceRep.h
rename to src/adaptation/icap/ServiceRep.h
index d47fd955b24989bb62790f9ea0329df49aea7a20..3149895c64869d32f83989498e901a336986f90e 100644 (file)
 #include "adaptation/Service.h"
 #include "adaptation/forward.h"
 #include "adaptation/Initiator.h"
-#include "ICAPElements.h"
+#include "adaptation/icap/Elements.h"
 
-class ICAPOptions;
-class ICAPOptXact;
+
+namespace Adaptation {
+namespace Icap {
+
+class Options;
+class OptXact;
 
 /* The ICAP service representative maintains information about a single ICAP
    service that Squid communicates with. The representative initiates OPTIONS
@@ -72,18 +76,18 @@ class ICAPOptXact;
  */
 
 
-class ICAPServiceRep : public RefCountable, public Adaptation::Service,
+class ServiceRep : public RefCountable, public Adaptation::Service,
             public Adaptation::Initiator
 {
 
 public:
-    typedef RefCount<ICAPServiceRep> Pointer;
+    typedef RefCount<ServiceRep> Pointer;
 
 public:
-    ICAPServiceRep(const Adaptation::ServiceConfig &config);
-    virtual ~ICAPServiceRep();
+    ServiceRep(const Adaptation::ServiceConfig &config);
+    virtual ~ServiceRep();
 
-    void setSelf(Pointer &aSelf); // needs self pointer for ICAPOptXact
+    void setSelf(Pointer &aSelf); // needs self pointer for OptXact
     virtual void finalize();
 
     void invalidate(); // call when the service is no longer needed or valid
@@ -124,7 +128,7 @@ private:
     typedef Vector<Client> Clients;
     Clients theClients; // all clients waiting for a call back
 
-    ICAPOptions *theOptions;
+    Options *theOptions;
     Adaptation::Initiate *theOptionsFetcher; // pending ICAP OPTIONS transaction
     time_t theLastUpdate; // time the options were last updated
 
@@ -149,8 +153,8 @@ private:
     void scheduleNotification();
 
     void startGettingOptions();
-    void handleNewOptions(ICAPOptions *newOptions);
-    void changeOptions(ICAPOptions *newOptions);
+    void handleNewOptions(Options *newOptions);
+    void changeOptions(Options *newOptions);
     void checkOptions();
 
     void announceStatusChange(const char *downPhrase, bool important) const;
@@ -159,7 +163,11 @@ private:
 
     Pointer self;
     mutable bool wasAnnouncedUp; // prevent sequential same-state announcements
-    CBDATA_CLASS2(ICAPServiceRep);
+    CBDATA_CLASS2(ServiceRep);
 };
 
+
+} // namespace Icap
+} // namespace Adaptation
+
 #endif /* SQUID_ICAPSERVICEREP_H */
similarity index 67%
rename from src/ICAP/ICAPXaction.cc
rename to src/adaptation/icap/Xaction.cc
index 82993b60bae7ebb91e0b224c8e47e60f554e10f7..8c76dba4f47aead8641ce30198c78458f44b12ff 100644 (file)
@@ -6,8 +6,8 @@
 #include "comm.h"
 #include "CommCalls.h"
 #include "HttpMsg.h"
-#include "ICAPXaction.h"
-#include "ICAPConfig.h"
+#include "adaptation/icap/Xaction.h"
+#include "adaptation/icap/Config.h"
 #include "TextException.h"
 #include "pconn.h"
 #include "fde.h"
@@ -15,9 +15,9 @@
 static PconnPool *icapPconnPool = new PconnPool("ICAP Servers");
 
 
-//CBDATA_CLASS_INIT(ICAPXaction);
+//CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Icap, Xaction);
 
-ICAPXaction::ICAPXaction(const char *aTypeName, Adaptation::Initiator *anInitiator, ICAPServiceRep::Pointer &aService):
+Adaptation::Icap::Xaction::Xaction(const char *aTypeName, Adaptation::Initiator *anInitiator, Adaptation::Icap::ServiceRep::Pointer &aService):
         AsyncJob(aTypeName),
         Adaptation::Initiate(aTypeName, anInitiator, aService.getRaw()),
         connection(-1),
@@ -32,28 +32,28 @@ ICAPXaction::ICAPXaction(const char *aTypeName, Adaptation::Initiator *anInitiat
            " [icapx" << id << ']'); // we should not call virtual status() here
 }
 
-ICAPXaction::~ICAPXaction()
+Adaptation::Icap::Xaction::~Xaction()
 {
     debugs(93,3, typeName << " destructed, this=" << this <<
            " [icapx" << id << ']'); // we should not call virtual status() here
 }
 
-ICAPServiceRep &
-ICAPXaction::service()
+Adaptation::Icap::ServiceRep &
+Adaptation::Icap::Xaction::service()
 {
-    ICAPServiceRep *s = dynamic_cast<ICAPServiceRep*>(&Initiate::service());
+    Adaptation::Icap::ServiceRep *s = dynamic_cast<Adaptation::Icap::ServiceRep*>(&Initiate::service());
     Must(s);
     return *s;
 }
 
-void ICAPXaction::disableRetries()
+void Adaptation::Icap::Xaction::disableRetries()
 {
     debugs(93,5, typeName << (isRetriable ? " becomes" : " remains") <<
            " final" << status());
     isRetriable = false;
 }
 
-void ICAPXaction::start()
+void Adaptation::Icap::Xaction::start()
 {
     Adaptation::Initiate::start();
 
@@ -64,7 +64,7 @@ void ICAPXaction::start()
 }
 
 // TODO: obey service-specific, OPTIONS-reported connection limit
-void ICAPXaction::openConnection()
+void Adaptation::Icap::Xaction::openConnection()
 {
     IpAddress client_addr;
 
@@ -72,7 +72,7 @@ void ICAPXaction::openConnection()
 
     const Adaptation::Service &s = service();
 
-    if (!TheICAPConfig.reuse_connections)
+    if (!TheConfig.reuse_connections)
         disableRetries(); // this will also safely drain pconn pool
 
     // TODO: check whether NULL domain is appropriate here
@@ -81,13 +81,13 @@ void ICAPXaction::openConnection()
         debugs(93,3, HERE << "reused pconn FD " << connection);
 
         // fake the connect callback
-        // TODO: can we sync call ICAPXaction::noteCommConnected here instead?
-        typedef CommCbMemFunT<ICAPXaction, CommConnectCbParams> Dialer;
-        Dialer dialer(this, &ICAPXaction::noteCommConnected);
+        // TODO: can we sync call Adaptation::Icap::Xaction::noteCommConnected here instead?
+        typedef CommCbMemFunT<Adaptation::Icap::Xaction, CommConnectCbParams> Dialer;
+        Dialer dialer(this, &Adaptation::Icap::Xaction::noteCommConnected);
        dialer.params.fd = connection;
         dialer.params.flag = COMM_OK;
         // fake other parameters by copying from the existing connection
-        connector = asyncCall(93,3, "ICAPXaction::noteCommConnected", dialer);
+        connector = asyncCall(93,3, "Adaptation::Icap::Xaction::noteCommConnected", dialer);
         ScheduleCallHere(connector);
         return;
     }
@@ -104,39 +104,39 @@ void ICAPXaction::openConnection()
     debugs(93,3, typeName << " opens connection to " << s.cfg().host << ":" << s.cfg().port);
 
     // TODO: service bypass status may differ from that of a transaction
-    typedef CommCbMemFunT<ICAPXaction, CommTimeoutCbParams> TimeoutDialer;
-    AsyncCall::Pointer timeoutCall =  asyncCall(93, 5, "ICAPXaction::noteCommTimedout",
-                                      TimeoutDialer(this,&ICAPXaction::noteCommTimedout));
+    typedef CommCbMemFunT<Adaptation::Icap::Xaction, CommTimeoutCbParams> TimeoutDialer;
+    AsyncCall::Pointer timeoutCall =  asyncCall(93, 5, "Adaptation::Icap::Xaction::noteCommTimedout",
+                                      TimeoutDialer(this,&Adaptation::Icap::Xaction::noteCommTimedout));
 
-    commSetTimeout(connection, TheICAPConfig.connect_timeout(
+    commSetTimeout(connection, TheConfig.connect_timeout(
                        service().cfg().bypass), timeoutCall);
 
-    typedef CommCbMemFunT<ICAPXaction, CommCloseCbParams> CloseDialer;
-    closer =  asyncCall(93, 5, "ICAPXaction::noteCommClosed",
-                        CloseDialer(this,&ICAPXaction::noteCommClosed));
+    typedef CommCbMemFunT<Adaptation::Icap::Xaction, CommCloseCbParams> CloseDialer;
+    closer =  asyncCall(93, 5, "Adaptation::Icap::Xaction::noteCommClosed",
+                        CloseDialer(this,&Adaptation::Icap::Xaction::noteCommClosed));
     comm_add_close_handler(connection, closer);
 
-    typedef CommCbMemFunT<ICAPXaction, CommConnectCbParams> ConnectDialer;
-    connector = asyncCall(93,3, "ICAPXaction::noteCommConnected",
-                          ConnectDialer(this, &ICAPXaction::noteCommConnected));
+    typedef CommCbMemFunT<Adaptation::Icap::Xaction, CommConnectCbParams> ConnectDialer;
+    connector = asyncCall(93,3, "Adaptation::Icap::Xaction::noteCommConnected",
+                          ConnectDialer(this, &Adaptation::Icap::Xaction::noteCommConnected));
     commConnectStart(connection, s.cfg().host.termedBuf(), s.cfg().port, connector);
 }
 
 /*
  * This event handler is necessary to work around the no-rentry policy
- * of ICAPXaction::callStart()
+ * of Adaptation::Icap::Xaction::callStart()
  */
 #if 0
 void
-ICAPXaction::reusedConnection(void *data)
+Adaptation::Icap::Xaction::reusedConnection(void *data)
 {
-    debugs(93, 5, "ICAPXaction::reusedConnection");
-    ICAPXaction *x = (ICAPXaction*)data;
+    debugs(93, 5, HERE << "reused connection");
+    Adaptation::Icap::Xaction *x = (Adaptation::Icap::Xaction*)data;
     x->noteCommConnected(COMM_OK);
 }
 #endif
 
-void ICAPXaction::closeConnection()
+void Adaptation::Icap::Xaction::closeConnection()
 {
     if (connection >= 0) {
 
@@ -177,7 +177,7 @@ void ICAPXaction::closeConnection()
 }
 
 // connection with the ICAP service established
-void ICAPXaction::noteCommConnected(const CommConnectCbParams &io)
+void Adaptation::Icap::Xaction::noteCommConnected(const CommConnectCbParams &io)
 {
     Must(connector != NULL);
     connector = NULL;
@@ -190,7 +190,7 @@ void ICAPXaction::noteCommConnected(const CommConnectCbParams &io)
     handleCommConnected();
 }
 
-void ICAPXaction::dieOnConnectionFailure()
+void Adaptation::Icap::Xaction::dieOnConnectionFailure()
 {
     debugs(93, 2, HERE << typeName <<
            " failed to connect to " << service().cfg().uri);
@@ -198,18 +198,18 @@ void ICAPXaction::dieOnConnectionFailure()
     throw TexcHere("cannot connect to the ICAP service");
 }
 
-void ICAPXaction::scheduleWrite(MemBuf &buf)
+void Adaptation::Icap::Xaction::scheduleWrite(MemBuf &buf)
 {
     // comm module will free the buffer
-    typedef CommCbMemFunT<ICAPXaction, CommIoCbParams> Dialer;
-    writer = asyncCall(93,3, "ICAPXaction::noteCommWrote",
-                       Dialer(this, &ICAPXaction::noteCommWrote));
+    typedef CommCbMemFunT<Adaptation::Icap::Xaction, CommIoCbParams> Dialer;
+    writer = asyncCall(93,3, "Adaptation::Icap::Xaction::noteCommWrote",
+                       Dialer(this, &Adaptation::Icap::Xaction::noteCommWrote));
 
     comm_write_mbuf(connection, &buf, writer);
     updateTimeout();
 }
 
-void ICAPXaction::noteCommWrote(const CommIoCbParams &io)
+void Adaptation::Icap::Xaction::noteCommWrote(const CommIoCbParams &io)
 {
     Must(writer != NULL);
     writer = NULL;
@@ -226,12 +226,12 @@ void ICAPXaction::noteCommWrote(const CommIoCbParams &io)
 }
 
 // communication timeout with the ICAP service
-void ICAPXaction::noteCommTimedout(const CommTimeoutCbParams &io)
+void Adaptation::Icap::Xaction::noteCommTimedout(const CommTimeoutCbParams &io)
 {
     handleCommTimedout();
 }
 
-void ICAPXaction::handleCommTimedout()
+void Adaptation::Icap::Xaction::handleCommTimedout()
 {
     debugs(93, 2, HERE << typeName << " failed: timeout with " <<
            theService->cfg().methodStr() << " " <<
@@ -245,18 +245,18 @@ void ICAPXaction::handleCommTimedout()
 }
 
 // unexpected connection close while talking to the ICAP service
-void ICAPXaction::noteCommClosed(const CommCloseCbParams &io)
+void Adaptation::Icap::Xaction::noteCommClosed(const CommCloseCbParams &io)
 {
     closer = NULL;
     handleCommClosed();
 }
 
-void ICAPXaction::handleCommClosed()
+void Adaptation::Icap::Xaction::handleCommClosed()
 {
     mustStop("ICAP service connection externally closed");
 }
 
-void ICAPXaction::callEnd()
+void Adaptation::Icap::Xaction::callEnd()
 {
     if (doneWithIo()) {
         debugs(93, 5, HERE << typeName << " done with I/O" << status());
@@ -265,23 +265,23 @@ void ICAPXaction::callEnd()
     Adaptation::Initiate::callEnd(); // may destroy us
 }
 
-bool ICAPXaction::doneAll() const
+bool Adaptation::Icap::Xaction::doneAll() const
 {
     return !connector && !reader && !writer && Adaptation::Initiate::doneAll();
 }
 
-void ICAPXaction::updateTimeout()
+void Adaptation::Icap::Xaction::updateTimeout()
 {
     if (reader != NULL || writer != NULL) {
         // restart the timeout before each I/O
         // XXX: why does Config.Timeout lacks a write timeout?
         // TODO: service bypass status may differ from that of a transaction
-        typedef CommCbMemFunT<ICAPXaction, CommTimeoutCbParams> TimeoutDialer;
-        AsyncCall::Pointer call =  asyncCall(93, 5, "ICAPXaction::noteCommTimedout",
-                                             TimeoutDialer(this,&ICAPXaction::noteCommTimedout));
+        typedef CommCbMemFunT<Adaptation::Icap::Xaction, CommTimeoutCbParams> TimeoutDialer;
+        AsyncCall::Pointer call =  asyncCall(93, 5, "Adaptation::Icap::Xaction::noteCommTimedout",
+                                             TimeoutDialer(this,&Adaptation::Icap::Xaction::noteCommTimedout));
 
         commSetTimeout(connection,
-                       TheICAPConfig.io_timeout(service().cfg().bypass), call);
+                       TheConfig.io_timeout(service().cfg().bypass), call);
     } else {
         // clear timeout when there is no I/O
         // Do we need a lifetime timeout?
@@ -290,26 +290,26 @@ void ICAPXaction::updateTimeout()
     }
 }
 
-void ICAPXaction::scheduleRead()
+void Adaptation::Icap::Xaction::scheduleRead()
 {
     Must(connection >= 0);
     Must(!reader);
     Must(readBuf.hasSpace());
 
     /*
-     * See comments in ICAPXaction.h about why we use commBuf
+     * See comments in Adaptation::Icap::Xaction.h about why we use commBuf
      * here instead of reading directly into readBuf.buf.
      */
-    typedef CommCbMemFunT<ICAPXaction, CommIoCbParams> Dialer;
-    reader = asyncCall(93,3, "ICAPXaction::noteCommRead",
-                       Dialer(this, &ICAPXaction::noteCommRead));
+    typedef CommCbMemFunT<Adaptation::Icap::Xaction, CommIoCbParams> Dialer;
+    reader = asyncCall(93,3, "Adaptation::Icap::Xaction::noteCommRead",
+                       Dialer(this, &Adaptation::Icap::Xaction::noteCommRead));
 
     comm_read(connection, commBuf, readBuf.spaceSize(), reader);
     updateTimeout();
 }
 
 // comm module read a portion of the ICAP response for us
-void ICAPXaction::noteCommRead(const CommIoCbParams &io)
+void Adaptation::Icap::Xaction::noteCommRead(const CommIoCbParams &io)
 {
     Must(reader != NULL);
     reader = NULL;
@@ -322,7 +322,7 @@ void ICAPXaction::noteCommRead(const CommIoCbParams &io)
     debugs(93, 3, HERE << "read " << io.size << " bytes");
 
     /*
-     * See comments in ICAPXaction.h about why we use commBuf
+     * See comments in Adaptation::Icap::Xaction.h about why we use commBuf
      * here instead of reading directly into readBuf.buf.
      */
 
@@ -337,7 +337,7 @@ void ICAPXaction::noteCommRead(const CommIoCbParams &io)
     handleCommRead(io.size);
 }
 
-void ICAPXaction::cancelRead()
+void Adaptation::Icap::Xaction::cancelRead()
 {
     if (reader != NULL) {
         comm_read_cancel(connection, reader);
@@ -345,7 +345,7 @@ void ICAPXaction::cancelRead()
     }
 }
 
-bool ICAPXaction::parseHttpMsg(HttpMsg *msg)
+bool Adaptation::Icap::Xaction::parseHttpMsg(HttpMsg *msg)
 {
     debugs(93, 5, HERE << "have " << readBuf.contentSize() << " head bytes to parse");
 
@@ -363,23 +363,23 @@ bool ICAPXaction::parseHttpMsg(HttpMsg *msg)
     return true;
 }
 
-bool ICAPXaction::mayReadMore() const
+bool Adaptation::Icap::Xaction::mayReadMore() const
 {
     return !doneReading() && // will read more data
            readBuf.hasSpace();  // have space for more data
 }
 
-bool ICAPXaction::doneReading() const
+bool Adaptation::Icap::Xaction::doneReading() const
 {
     return commEof;
 }
 
-bool ICAPXaction::doneWriting() const
+bool Adaptation::Icap::Xaction::doneWriting() const
 {
     return !writer;
 }
 
-bool ICAPXaction::doneWithIo() const
+bool Adaptation::Icap::Xaction::doneWithIo() const
 {
     return connection >= 0 && // or we could still be waiting to open it
            !connector && !reader && !writer && // fast checks, some redundant
@@ -387,7 +387,7 @@ bool ICAPXaction::doneWithIo() const
 }
 
 // initiator aborted
-void ICAPXaction::noteInitiatorAborted()
+void Adaptation::Icap::Xaction::noteInitiatorAborted()
 {
 
     if (theInitiator) {
@@ -400,7 +400,7 @@ void ICAPXaction::noteInitiatorAborted()
 // This 'last chance' method is called before a 'done' transaction is deleted.
 // It is wrong to call virtual methods from a destructor. Besides, this call
 // indicates that the transaction will terminate as planned.
-void ICAPXaction::swanSong()
+void Adaptation::Icap::Xaction::swanSong()
 {
     // kids should sing first and then call the parent method.
 
@@ -419,7 +419,7 @@ void ICAPXaction::swanSong()
 }
 
 // returns a temporary string depicting transaction status, for debugging
-const char *ICAPXaction::status() const
+const char *Adaptation::Icap::Xaction::status() const
 {
     static MemBuf buf;
     buf.reset();
@@ -437,7 +437,7 @@ const char *ICAPXaction::status() const
     return buf.content();
 }
 
-void ICAPXaction::fillPendingStatus(MemBuf &buf) const
+void Adaptation::Icap::Xaction::fillPendingStatus(MemBuf &buf) const
 {
     if (connection >= 0) {
         buf.Printf("FD %d", connection);
@@ -452,7 +452,7 @@ void ICAPXaction::fillPendingStatus(MemBuf &buf) const
     }
 }
 
-void ICAPXaction::fillDoneStatus(MemBuf &buf) const
+void Adaptation::Icap::Xaction::fillDoneStatus(MemBuf &buf) const
 {
     if (connection >= 0 && commEof)
         buf.Printf("Comm(%d)", connection);
@@ -461,7 +461,7 @@ void ICAPXaction::fillDoneStatus(MemBuf &buf) const
         buf.Printf("Stopped");
 }
 
-bool ICAPXaction::fillVirginHttpHeader(MemBuf &buf) const
+bool Adaptation::Icap::Xaction::fillVirginHttpHeader(MemBuf &buf) const
 {
     return false;
 }
similarity index 90%
rename from src/ICAP/ICAPXaction.h
rename to src/adaptation/icap/Xaction.h
index a321777eafb52933c8a2ba242e091833b4c1d2d1..c47412f84a9ca7bac96ec43867f48705f8db4cab 100644 (file)
 #include "comm.h"
 #include "CommCalls.h"
 #include "MemBuf.h"
-#include "ICAPServiceRep.h"
+#include "adaptation/icap/ServiceRep.h"
 #include "adaptation/Initiate.h"
 
 class HttpMsg;
 class CommConnectCbParams;
 
+namespace Adaptation {
+namespace Icap {
+
 /*
  * The ICAP Xaction implements common tasks for ICAP OPTIONS, REQMOD, and
- * RESPMOD transactions. It is started by an ICAPInitiator. It terminates
+ * RESPMOD transactions. It is started by an Initiator. It terminates
  * on its own, when done. Transactions communicate with Initiator using
  * asynchronous messages because a transaction or Initiator may be gone at
  * any time.
  */
 
-// Note: ICAPXaction must be the first parent for object-unaware cbdata to work
+// Note: Xaction must be the first parent for object-unaware cbdata to work
 
-class ICAPXaction: public Adaptation::Initiate
+class Xaction: public Adaptation::Initiate
 {
 
 public:
-    ICAPXaction(const char *aTypeName, Adaptation::Initiator *anInitiator, ICAPServiceRep::Pointer &aService);
-    virtual ~ICAPXaction();
+    Xaction(const char *aTypeName, Adaptation::Initiator *anInitiator, ServiceRep::Pointer &aService);
+    virtual ~Xaction();
 
     void disableRetries();
 
@@ -112,7 +115,7 @@ protected:
     // custom end-of-call checks
     virtual void callEnd();
 
-    ICAPServiceRep &service();
+    ServiceRep &service();
 
 protected:
     int connection;     // FD of the ICAP server connection
@@ -145,7 +148,11 @@ protected:
     AsyncCall::Pointer closer;
 
 private:
-    //CBDATA_CLASS2(ICAPXaction);
+    //CBDATA_CLASS2(Xaction);
 };
 
+
+} // namespace Icap
+} // namespace Adaptation
+
 #endif /* SQUID_ICAPXACTION_H */
index edeae725259f73eecc8551fc25f9c4330c33f68f..d4f563d24a5dbd3ed9269587f0c9ae11388d78a8 100644 (file)
@@ -69,21 +69,21 @@ static void parse_adaptation_access_type();
 #endif
 
 #if ICAP_CLIENT
-#include "ICAP/ICAPConfig.h"
+#include "adaptation/icap/Config.h"
 
-static void parse_icap_service_type(ICAPConfig *);
-static void dump_icap_service_type(StoreEntry *, const char *, const ICAPConfig &);
-static void free_icap_service_type(ICAPConfig *);
+static void parse_icap_service_type(Adaptation::Icap::Config *);
+static void dump_icap_service_type(StoreEntry *, const char *, const Adaptation::Icap::Config &);
+static void free_icap_service_type(Adaptation::Icap::Config *);
 static void parse_icap_class_type();
 static void parse_icap_access_type();
 
 #endif
 
 #if USE_ECAP
-#include "eCAP/Config.h"
-static void parse_ecap_service_type(Ecap::Config *);
-static void dump_ecap_service_type(StoreEntry *, const char *, const Ecap::Config &);
-static void free_ecap_service_type(Ecap::Config *);
+#include "adaptation/ecap/Config.h"
+static void parse_ecap_service_type(Adaptation::Ecap::Config *);
+static void dump_ecap_service_type(StoreEntry *, const char *, const Adaptation::Ecap::Config &);
+static void free_ecap_service_type(Adaptation::Ecap::Config *);
 #endif
 
 CBDATA_TYPE(peer);
@@ -3508,19 +3508,19 @@ parse_adaptation_access_type()
 #if ICAP_CLIENT
 
 static void
-parse_icap_service_type(ICAPConfig * cfg)
+parse_icap_service_type(Adaptation::Icap::Config * cfg)
 {
     cfg->parseService();
 }
 
 static void
-free_icap_service_type(ICAPConfig * cfg)
+free_icap_service_type(Adaptation::Icap::Config * cfg)
 {
     cfg->freeService();
 }
 
 static void
-dump_icap_service_type(StoreEntry * entry, const char *name, const ICAPConfig &cfg)
+dump_icap_service_type(StoreEntry * entry, const char *name, const Adaptation::Icap::Config &cfg)
 {
     cfg.dumpService(entry, name);
 }
@@ -3547,19 +3547,19 @@ parse_icap_access_type()
 #if USE_ECAP
 
 static void
-parse_ecap_service_type(Ecap::Config * cfg)
+parse_ecap_service_type(Adaptation::Ecap::Config * cfg)
 {
     cfg->parseService();
 }
 
 static void
-free_ecap_service_type(Ecap::Config * cfg)
+free_ecap_service_type(Adaptation::Ecap::Config * cfg)
 {
     cfg->freeService();
 }
 
 static void
-dump_ecap_service_type(StoreEntry * entry, const char *name, const Ecap::Config &cfg)
+dump_ecap_service_type(StoreEntry * entry, const char *name, const Adaptation::Ecap::Config &cfg)
 {
     cfg.dumpService(entry, name);
 }
index 80cfc53bb5d970b309f184ed2a5a15da75cecc00..1ae6492d5468dd03f71a3cab0c45af7883cbf203 100644 (file)
@@ -378,6 +378,7 @@ extern cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, in
 
 /// \ingroup CBDATAAPI
 #define CBDATA_CLASS_INIT(type) cbdata_type type::CBDATA_##type = CBDATA_UNKNOWN
+#define CBDATA_NAMESPACED_CLASS_INIT(namespace, type) cbdata_type namespace::type::CBDATA_##type = CBDATA_UNKNOWN
 
 /**
  \ingroup CBDATAAPI
index 0054f7213833b249617509671bb21fc9e26b73d5..e821d741289df3d37dfc5c946f3e6a7d92b42c81 100644 (file)
@@ -5132,7 +5132,7 @@ NAME: icap_enable
 TYPE: onoff
 IFDEF: ICAP_CLIENT
 COMMENT: on|off
-LOC: TheICAPConfig.onoff
+LOC: Adaptation::Icap::TheConfig.onoff
 DEFAULT: off
 DOC_START
        If you want to enable the ICAP module support, set this to on.
@@ -5141,7 +5141,7 @@ DOC_END
 NAME: icap_connect_timeout
 TYPE: time_t
 DEFAULT: none
-LOC: TheICAPConfig.connect_timeout_raw
+LOC: Adaptation::Icap::TheConfig.connect_timeout_raw
 IFDEF: ICAP_CLIENT
 DOC_START
        This parameter specifies how long to wait for the TCP connect to
@@ -5157,7 +5157,7 @@ NAME: icap_io_timeout
 COMMENT: time-units
 TYPE: time_t
 DEFAULT: none
-LOC: TheICAPConfig.io_timeout_raw
+LOC: Adaptation::Icap::TheConfig.io_timeout_raw
 IFDEF: ICAP_CLIENT
 DOC_START
        This parameter specifies how long to wait for an I/O activity on
@@ -5171,7 +5171,7 @@ DOC_END
 NAME: icap_service_failure_limit
 TYPE: int
 IFDEF: ICAP_CLIENT
-LOC: TheICAPConfig.service_failure_limit
+LOC: Adaptation::Icap::TheConfig.service_failure_limit
 DEFAULT: 10
 DOC_START
        The limit specifies the number of failures that Squid tolerates
@@ -5189,7 +5189,7 @@ DOC_END
 NAME: icap_service_revival_delay
 TYPE: int
 IFDEF: ICAP_CLIENT
-LOC: TheICAPConfig.service_revival_delay
+LOC: Adaptation::Icap::TheConfig.service_revival_delay
 DEFAULT: 180
 DOC_START
        The delay specifies the number of seconds to wait after an ICAP
@@ -5205,7 +5205,7 @@ NAME: icap_preview_enable
 TYPE: onoff
 IFDEF: ICAP_CLIENT
 COMMENT: on|off
-LOC: TheICAPConfig.preview_enable
+LOC: Adaptation::Icap::TheConfig.preview_enable
 DEFAULT: on
 DOC_START
        The ICAP Preview feature allows the ICAP server to handle the
@@ -5226,7 +5226,7 @@ DOC_END
 NAME: icap_preview_size
 TYPE: int
 IFDEF: ICAP_CLIENT
-LOC: TheICAPConfig.preview_size
+LOC: Adaptation::Icap::TheConfig.preview_size
 DEFAULT: -1
 DOC_START
        The default size of preview data to be sent to the ICAP server.
@@ -5237,7 +5237,7 @@ DOC_END
 NAME: icap_default_options_ttl
 TYPE: int
 IFDEF: ICAP_CLIENT
-LOC: TheICAPConfig.default_options_ttl
+LOC: Adaptation::Icap::TheConfig.default_options_ttl
 DEFAULT: 60
 DOC_START
        The default TTL value for ICAP OPTIONS responses that don't have
@@ -5248,7 +5248,7 @@ NAME: icap_persistent_connections
 TYPE: onoff
 IFDEF: ICAP_CLIENT
 COMMENT: on|off
-LOC: TheICAPConfig.reuse_connections
+LOC: Adaptation::Icap::TheConfig.reuse_connections
 DEFAULT: on
 DOC_START
        Whether or not Squid should use persistent connections to
@@ -5259,7 +5259,7 @@ NAME: icap_send_client_ip
 TYPE: onoff
 IFDEF: ICAP_CLIENT
 COMMENT: on|off
-LOC: TheICAPConfig.send_client_ip
+LOC: Adaptation::Icap::TheConfig.send_client_ip
 DEFAULT: off
 DOC_START
        This adds the header "X-Client-IP" to ICAP requests.
@@ -5269,7 +5269,7 @@ NAME: icap_send_client_username
 TYPE: onoff
 IFDEF: ICAP_CLIENT
 COMMENT: on|off
-LOC: TheICAPConfig.send_client_username
+LOC: Adaptation::Icap::TheConfig.send_client_username
 DEFAULT: off
 DOC_START
        This sends authenticated HTTP client username (if available) to
@@ -5281,7 +5281,7 @@ DOC_END
 NAME: icap_client_username_header
 TYPE: string
 IFDEF: ICAP_CLIENT
-LOC: TheICAPConfig.client_username_header
+LOC: Adaptation::Icap::TheConfig.client_username_header
 DEFAULT: X-Client-Username
 DOC_START
        ICAP request header name to use for send_client_username.
@@ -5291,7 +5291,7 @@ NAME: icap_client_username_encode
 TYPE: onoff
 IFDEF: ICAP_CLIENT
 COMMENT: on|off
-LOC: TheICAPConfig.client_username_encode
+LOC: Adaptation::Icap::TheConfig.client_username_encode
 DEFAULT: off
 DOC_START
        Whether to base64 encode the authenticated client username.
@@ -5300,7 +5300,7 @@ DOC_END
 NAME: icap_service
 TYPE: icap_service_type
 IFDEF: ICAP_CLIENT
-LOC: TheICAPConfig
+LOC: Adaptation::Icap::TheConfig
 DEFAULT: none
 DOC_START
        Defines a single ICAP service
@@ -5363,7 +5363,7 @@ NAME: ecap_enable
 TYPE: onoff
 IFDEF: USE_ECAP
 COMMENT: on|off
-LOC: Ecap::TheConfig.onoff
+LOC: Adaptation::Ecap::TheConfig.onoff
 DEFAULT: off
 DOC_START
        Controls whether eCAP support is enabled.
@@ -5372,7 +5372,7 @@ DOC_END
 NAME: ecap_service
 TYPE: ecap_service_type
 IFDEF: USE_ECAP
-LOC: Ecap::TheConfig
+LOC: Adaptation::Ecap::TheConfig
 DEFAULT: none
 DOC_START
        Defines a single eCAP service
diff --git a/src/eCAP/Config.cc b/src/eCAP/Config.cc
deleted file mode 100644 (file)
index b8d3263..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-
-/*
- * $Id$
- */
-
-#include "squid.h"
-
-#include <libecap/common/registry.h>
-#include "eCAP/Host.h"
-#include "eCAP/ServiceRep.h"
-#include "eCAP/Config.h"
-
-Ecap::Config Ecap::TheConfig;
-
-Ecap::Config::Config()
-{
-}
-
-Ecap::Config::~Config()
-{
-}
-
-void
-Ecap::Config::finalize()
-{
-    Adaptation::Config::finalize();
-    libecap::shared_ptr<Ecap::Host> host(new Ecap::Host);
-    libecap::RegisterHost(host);
-}
-
-Adaptation::ServicePointer
-Ecap::Config::createService(const Adaptation::ServiceConfig &cfg)
-{
-    Adaptation::ServicePointer s = new Ecap::ServiceRep(cfg);
-    return s.getRaw();
-}
-
diff --git a/src/eCAP/Makefile.am b/src/eCAP/Makefile.am
deleted file mode 100644 (file)
index e9d1da4..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#  Makefile for the eCAP library
-#
-#  $Id$
-#
-
-AM_CFLAGS = @SQUID_CFLAGS@
-AM_CXXFLAGS = @SQUID_CXXFLAGS@
-
-noinst_LTLIBRARIES = libeCAP.la
-
-libeCAP_la_SOURCES = \
-       Config.h \
-       Config.cc \
-       Host.h \
-       Host.cc \
-       MessageRep.h \
-       MessageRep.cc \
-       ServiceRep.h \
-       ServiceRep.cc \
-       XactionRep.h \
-       XactionRep.cc \
-       \
-       Registry.h
-
-INCLUDES = \
-       -I$(top_srcdir) \
-       -I. \
-       -I$(top_builddir)/include \
-       -I$(top_srcdir)/include \
-        -I$(top_srcdir)/src
index 92f00ee304e95e2676b1a3632f964373457726f7..c9672b44634819d81882db76673e28e22fbb170b 100644 (file)
 #endif
 
 #if ICAP_CLIENT
-#include "ICAP/ICAPConfig.h"
+#include "adaptation/icap/Config.h"
 #endif
 #if USE_ECAP
-#include "eCAP/Config.h"
+#include "adaptation/ecap/Config.h"
 #endif
 #if USE_ADAPTATION
 #include "adaptation/Config.h"
@@ -1050,12 +1050,12 @@ mainInitialize(void)
     // We can remove this dependency on specific adaptation mechanisms
     // if we create a generic Registry of such mechanisms. Should we?
 #if ICAP_CLIENT
-    TheICAPConfig.finalize();
-    enableAdaptation = TheICAPConfig.onoff || enableAdaptation;
+    Adaptation::Icap::TheConfig.finalize();
+    enableAdaptation = Adaptation::Icap::TheConfig.onoff || enableAdaptation;
 #endif
 #if USE_ECAP
-    Ecap::TheConfig.finalize(); // must be after we load modules
-    enableAdaptation = Ecap::TheConfig.onoff || enableAdaptation;
+    Adaptation::Ecap::TheConfig.finalize(); // must be after we load modules
+    enableAdaptation = Adaptation::Ecap::TheConfig.onoff || enableAdaptation;
 #endif
     // must be the last adaptation-related finalize
     Adaptation::Config::Finalize(enableAdaptation);