]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix eCAP header includes (#1753)
authorAmos Jeffries <yadij@users.noreply.github.com>
Fri, 5 Apr 2024 03:39:57 +0000 (03:39 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 5 Apr 2024 05:54:13 +0000 (05:54 +0000)
Squid style guidelines require .h files to be wrapped with
HAVE_*_H protection and placed after all Squid internal file
includes.

Add the missing ./configure header checks to generate the
needed wrappers and refactor the include sequences to meet
current guidelines.

configure.ac
src/adaptation/ecap/Host.cc
src/adaptation/ecap/Host.h
src/adaptation/ecap/MessageRep.cc
src/adaptation/ecap/MessageRep.h
src/adaptation/ecap/ServiceRep.cc
src/adaptation/ecap/ServiceRep.h
src/adaptation/ecap/XactionRep.cc
src/adaptation/ecap/XactionRep.h

index 6054c881a909f22d10634ef107fef2a1a081c348..26804fa2e5beaadf1fceb0a0d96c92e0a0787653 100644 (file)
@@ -886,12 +886,41 @@ AS_IF([test "x$enable_ecap" != "xno"],[
   ])
 
   SQUID_STATE_SAVE(squid_ecap_state)
+  CPPFLAGS="$EXT_LIBECAP_CFLAGS $CPPFLAGS"
+  LIBS="$EXT_LIBECAP_LIBS $LIBS"
+  AC_CHECK_HEADERS([ \
+    libecap/adapter/service.h \
+    libecap/adapter/xaction.h \
+    libecap/common/area.h \
+    libecap/common/body.h \
+    libecap/common/delay.h \
+    libecap/common/forward.h \
+    libecap/common/header.h \
+    libecap/common/memory.h \
+    libecap/common/message.h \
+    libecap/common/name.h \
+    libecap/common/named_values.h \
+    libecap/common/names.h \
+    libecap/common/options.h \
+    libecap/common/registry.h \
+    libecap/common/version.h \
+    libecap/host/host.h \
+    libecap/host/xaction.h \
+  ],,,[
+/* libecap-1.0.1 headers do not build without autoconf.h magic */
+#define HAVE_CONFIG_H
+/* libecap/common/delay.h fails to include <string> */
+#include <string>
+  ])
   AC_MSG_CHECKING([whether -lecap will link])
-  CXXFLAGS="$CXXFLAGS $EXT_LIBECAP_CFLAGS"
-  LIBS="$LIBS $EXT_LIBECAP_LIBS"
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <libecap/common/names.h>]],[[
-    const libecap::Name test("test", libecap::Name::NextId());
-  ]])],[
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#if HAVE_LIBECAP_COMMON_NAMES_H
+#include <libecap/common/names.h>
+#endif
+    ]],[[
+      const libecap::Name test("test", libecap::Name::NextId());
+    ]])
+  ],[
     AC_MSG_RESULT(yes)
     squid_opt_use_adaptation=yes
   ],[
index defa5a1f2696eb25219f1b90a0e6cd7d1f464567..46a7a8b661a4ec9cc5ad4751542b785a69aac246 100644 (file)
@@ -9,9 +9,6 @@
 /* DEBUG: section 93    eCAP Interface */
 
 #include "squid.h"
-#include <libecap/adapter/service.h>
-#include <libecap/common/names.h>
-#include <libecap/common/registry.h>
 #include "adaptation/ecap/Host.h"
 #include "adaptation/ecap/MessageRep.h"
 #include "adaptation/ecap/ServiceRep.h"
 #include "HttpRequest.h"
 #include "MasterXaction.h"
 
+#if HAVE_LIBECAP_ADAPTER_SERVICE_H
+#include <libecap/adapter/service.h>
+#endif
+#if HAVE_LIBECAP_COMMON_NAMES_H
+#include <libecap/common/names.h>
+#endif
+#if HAVE_LIBECAP_COMMON_REGISTRY_H
+#include <libecap/common/registry.h>
+#endif
+
 const libecap::Name Adaptation::Ecap::protocolInternal("internal", libecap::Name::NextId());
 const libecap::Name Adaptation::Ecap::protocolIcp("ICP", libecap::Name::NextId());
 #if USE_HTCP
index 11fc67ac1001f74e2e62f479b0be481feeb01237..d84b5c86e4ed590e2422230c1054f5b57e90c4e2 100644 (file)
@@ -11,7 +11,9 @@
 #ifndef SQUID_SRC_ADAPTATION_ECAP_HOST_H
 #define SQUID_SRC_ADAPTATION_ECAP_HOST_H
 
+#if HAVE_LIBECAP_HOST_HOST_H
 #include <libecap/host/host.h>
+#endif
 
 namespace Adaptation
 {
index 1c4bdfd298500c1fe42bc8fba4f062a2b5de2dc8..5a24732d35d38657e524f958d8fc129d81f583eb 100644 (file)
@@ -9,19 +9,24 @@
 /* DEBUG: section 93    eCAP Interface */
 
 #include "squid.h"
-#include "BodyPipe.h"
-#include "HttpReply.h"
-#include "HttpRequest.h"
-#include <libecap/common/names.h>
-#include <libecap/common/area.h>
-#include <libecap/common/version.h>
-#include <libecap/common/named_values.h>
-#include "adaptation/ecap/Host.h" /* for protocol constants */
+#include "adaptation/ecap/Host.h"
 #include "adaptation/ecap/MessageRep.h"
 #include "adaptation/ecap/XactionRep.h"
 #include "base/TextException.h"
+#include "HttpReply.h"
 
-/* HeaderRep */
+#if HAVE_LIBECAP_COMMON_AREA_H
+#include <libecap/common/area.h>
+#endif
+#if HAVE_LIBECAP_COMMON_NAMED_VALUES_H
+#include <libecap/common/named_values.h>
+#endif
+#if HAVE_LIBECAP_COMMON_NAMES_H
+#include <libecap/common/names.h>
+#endif
+#if HAVE_LIBECAP_COMMON_VERSION_H
+#include <libecap/common/version.h>
+#endif
 
 Adaptation::Ecap::HeaderRep::HeaderRep(Http::Message &aMessage): theHeader(aMessage.header),
     theMessage(aMessage)
index fb13706386cb2d4c70d23adcb8ef705fa005f6eb..eed9dbfdecae94c1c4e23dca635cb09af40c0da6 100644 (file)
 #include "http/forward.h"
 #include "HttpHeader.h"
 
-#include <libecap/common/message.h>
-#include <libecap/common/header.h>
+#if HAVE_LIBECAP_COMMON_BODY_H
 #include <libecap/common/body.h>
+#endif
+#if HAVE_LIBECAP_COMMON_HEADER_H
+#include <libecap/common/header.h>
+#endif
+#if HAVE_LIBECAP_COMMON_MESSAGE_H
+#include <libecap/common/message.h>
+#endif
 
 namespace Adaptation
 {
index dac4a1f92d7dd8bd2cbbff8172408529fe2314d0..1d3339020f26c9f76781684bbe815f1b3354b0d3 100644 (file)
 #include "debug/Stream.h"
 #include "EventLoop.h"
 
+#if HAVE_LIBECAP_ADAPTER_SERVICE_H
 #include <libecap/adapter/service.h>
+#endif
+#if HAVE_LIBECAP_COMMON_OPTIONS_H
 #include <libecap/common/options.h>
+#endif
+#if HAVE_LIBECAP_COMMON_NAME_H
 #include <libecap/common/name.h>
+#endif
+#if HAVE_LIBECAP_COMMON_NAMED_VALUES_H
 #include <libecap/common/named_values.h>
+#endif
+
 #include <limits>
 #include <map>
 
index 1fa7affd3c82c43907db304bd63bcfe37049e4b8..febbb3a2849a42813d5576d024b6ac8ed5a22452 100644 (file)
 
 #include "adaptation/forward.h"
 #include "adaptation/Service.h"
+
+#if HAVE_LIBECAP_COMMON_FORWARD_H
 #include <libecap/common/forward.h>
+#endif
+#if HAVE_LIBECAP_COMMON_MEMORY_H
 #include <libecap/common/memory.h>
+#endif
 
 namespace Adaptation
 {
index 264faac87b7a28f5376785abbe62adf3656868ee..c167cd6acf73d5a43b4acffa48f4741a5686f60c 100644 (file)
@@ -9,11 +9,6 @@
 /* DEBUG: section 93    eCAP Interface */
 
 #include "squid.h"
-#include <libecap/common/area.h>
-#include <libecap/common/delay.h>
-#include <libecap/common/named_values.h>
-#include <libecap/common/names.h>
-#include <libecap/adapter/xaction.h>
 #include "adaptation/Answer.h"
 #include "adaptation/ecap/Config.h"
 #include "adaptation/ecap/XactionRep.h"
 #include "base/TextException.h"
 #include "format/Format.h"
 #include "HttpReply.h"
-#include "HttpRequest.h"
 #include "MasterXaction.h"
 
+#if HAVE_LIBECAP_COMMON_AREA_H
+#include <libecap/common/area.h>
+#endif
+#if HAVE_LIBECAP_COMMON_DELAY_H
+#include <libecap/common/delay.h>
+#endif
+#if HAVE_LIBECAP_COMMON_NAMED_VALUES_H
+#include <libecap/common/named_values.h>
+#endif
+#if HAVE_LIBECAP_COMMON_NAMES_H
+#include <libecap/common/names.h>
+#endif
+
 CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Ecap::XactionRep, XactionRep);
 
 /// a libecap Visitor for converting adapter transaction options to HttpHeader
index cc43b37179d4f57083827ee8b9cc5d0bdcd0111d..a3a622ecc304078efdf0c3a5e72133d210c0f947 100644 (file)
 #include "adaptation/Initiate.h"
 #include "adaptation/Message.h"
 #include "BodyPipe.h"
-#include <libecap/common/forward.h>
-#include <libecap/common/memory.h>
-#include <libecap/host/xaction.h>
+
+#if HAVE_LIBECAP_ADAPTER_XACTION_H
 #include <libecap/adapter/xaction.h>
+#endif
+#if HAVE_LIBECAP_HOST_XACTION_H
+#include <libecap/host/xaction.h>
+#endif
 
 namespace Adaptation
 {