Cleaned up source for dual build
authorScott Cantor <cantor.2@osu.edu>
Thu, 17 May 2007 03:20:27 +0000 (03:20 +0000)
committerScott Cantor <cantor.2@osu.edu>
Thu, 17 May 2007 03:20:27 +0000 (03:20 +0000)
configure.ac
xmltooling/Makefile.am
xmltooling/XMLToolingConfig.cpp
xmltooling/XMLToolingConfig.h
xmltooling/base.h
xmltooling/impl/UnknownElement.cpp
xmltooling/soap/impl/CURLSOAPTransport.cpp
xmltooling/util/TemplateEngine.cpp
xmltoolingtest/Makefile.am

index fe8c241..39563a8 100644 (file)
@@ -175,8 +175,8 @@ AC_ARG_WITH(xmlsec,
 
 if test x_$with_xmlsec != x_no; then
     if test x_$with_xmlsec != x_/usr; then
-        CPPFLAGS="-I${with_xmlsec}/include"
-        LDFLAGS="-L${with_xmlsec}/lib"
+        CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
+        LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
     fi        
     XMLSEC_LIBS="-lxml-security-c"
     
index 07d52d8..b8f756b 100644 (file)
@@ -1,9 +1,9 @@
 AUTOMAKE_OPTIONS = foreign
 
 if BUILD_XMLSEC
-lib_LTLIBRARIES = libxmltooling-lite.la
-else
 lib_LTLIBRARIES = libxmltooling-lite.la libxmltooling.la
+else
+lib_LTLIBRARIES = libxmltooling-lite.la
 endif
 
 libxmltoolingincludedir = $(includedir)/xmltooling
@@ -172,23 +172,19 @@ common_sources = \
        util/URLEncoder.cpp \
        util/XMLConstants.cpp \
        util/XMLHelper.cpp \
-       validation/ValidatorSuite.cpp \
-       ${xmlsec_sources} \
+       validation/ValidatorSuite.cpp \ 
        $(thread_sources)
 
 libxmltooling_lite_la_SOURCES = \
        ${common_sources}
-
+libxmltooling_lite_la_CPPFLAGS = -DXMLTOOLING_LITE
 libxmltooling_lite_la_LDFLAGS = -version-info 1:0:0
 
 if BUILD_XMLSEC
-libxmltooling_la_CPPFLAGS = "$(CPPFLAGS) $(XMLSEC_CPPFLAGS)"
-libxmltooling_la_LDFLAGS = "$(LDFLAGS) $(XMLSEC_LDFLAGS) $(XMLSEC_LIBS)"
+libxmltooling_la_LDFLAGS = $(XMLSEC_LIBS) -version-info 1:0:0
 libxmltooling_la_SOURCES = \
        ${common_sources} \
-       ${xmlsec_sources} \
-       $(thread_sources)
-libxmltooling_la_LDFLAGS = -version-info 1:0:0
+       ${xmlsec_sources}
 endif
 
 install-exec-hook:
index f1e929e..468a29c 100644 (file)
@@ -23,6 +23,7 @@
 #include "internal.h"
 #include "exceptions.h"
 #include "XMLToolingConfig.h"
+#include "encryption/Encryption.h"
 #include "encryption/Encrypter.h"
 #include "impl/UnknownElement.h"
 #include "security/TrustEngine.h"
@@ -80,6 +81,7 @@ DECL_XMLTOOLING_EXCEPTION_FACTORY(IOException,xmltooling);
 
 namespace xmltooling {
     static XMLToolingInternalConfig g_config;
+#ifndef XMLTOOLING_NO_XMLSEC
     static vector<Mutex*> g_openssl_locks;
 
     extern "C" void openssl_locking_callback(int mode,int n,const char *file,int line)
@@ -90,12 +92,13 @@ namespace xmltooling {
             g_openssl_locks[n]->unlock();
     }
     
-    #ifndef WIN32
+ifndef WIN32
     extern "C" unsigned long openssl_thread_id(void)
     {
         return (unsigned long)(pthread_self());
     }
-    #endif
+# endif
+#endif
 }
 
 XMLToolingConfig& XMLToolingConfig::getConfig()
@@ -260,7 +263,9 @@ bool XMLToolingInternalConfig::init()
         registerStorageServices();
 
         m_urlEncoder = new URLEncoder();
+#ifndef XMLTOOLING_NO_XMLSEC
         m_keyInfoResolver = KeyInfoResolverManager.newPlugin(INLINE_KEYINFO_RESOLVER,NULL);
+#endif
         
         // Register xml:id as an ID attribute.        
         static const XMLCh xmlid[] = UNICODE_LITERAL_2(i,d);
@@ -272,12 +277,14 @@ bool XMLToolingInternalConfig::init()
         return false;
     }
 
+#ifndef XMLTOOLING_NO_XMLSEC
     // Set up OpenSSL locking.
     for (int i=0; i<CRYPTO_num_locks(); i++)
         g_openssl_locks.push_back(Mutex::create());
     CRYPTO_set_locking_callback(openssl_locking_callback);
-#ifndef WIN32
+# ifndef WIN32
     CRYPTO_set_id_callback(openssl_thread_id);
+# endif
 #endif
 
     log.info("library initialization complete");
@@ -286,9 +293,11 @@ bool XMLToolingInternalConfig::init()
 
 void XMLToolingInternalConfig::term()
 {
+#ifndef XMLTOOLING_NO_XMLSEC
     CRYPTO_set_locking_callback(NULL);
     for_each(g_openssl_locks.begin(), g_openssl_locks.end(), xmltooling::cleanup<Mutex>());
     g_openssl_locks.clear();
+#endif
 
     SchemaValidators.destroyValidators();
     XMLObjectBuilder::destroyBuilders();
@@ -298,15 +307,16 @@ void XMLToolingInternalConfig::term()
     StorageServiceManager.deregisterFactories();
     termSOAPTransports();
     SOAPTransportManager.deregisterFactories();
+
 #ifndef XMLTOOLING_NO_XMLSEC
     TrustEngineManager.deregisterFactories();
     CredentialResolverManager.deregisterFactories();
     KeyInfoResolverManager.deregisterFactories();
     m_algorithmMap.clear();
-#endif
 
     delete m_keyInfoResolver;
     m_keyInfoResolver = NULL;
+#endif
 
     delete m_replayCache;
     m_replayCache = NULL;
index f9f1946..1cbb650 100644 (file)
@@ -60,10 +60,14 @@ namespace xmltooling {
     {
         MAKE_NONCOPYABLE(XMLToolingConfig);
     protected:
+#ifndef XMLTOOLING_NO_XMLSEC
         XMLToolingConfig() : m_keyInfoResolver(NULL), m_replayCache(NULL), m_templateEngine(NULL), m_urlEncoder(NULL), clock_skew_secs(180) {}
-        
+
         /** Global KeyInfoResolver instance. */
         KeyInfoResolver* m_keyInfoResolver;
+#else
+        XMLToolingConfig() : m_replayCache(NULL), m_templateEngine(NULL), m_urlEncoder(NULL), clock_skew_secs(180) {}
+#endif
 
         /** Global ReplayCache instance. */
         ReplayCache* m_replayCache;
@@ -146,6 +150,7 @@ namespace xmltooling {
          */
         virtual ParserPool& getValidatingParser() const=0;
 
+#ifndef XMLTOOLING_NO_XMLSEC
         /**
          * Sets the global KeyInfoResolver instance.
          * This method must be externally synchronized with any code that uses the object.
@@ -163,6 +168,7 @@ namespace xmltooling {
         const KeyInfoResolver* getKeyInfoResolver() const {
             return m_keyInfoResolver;
         }
+#endif
 
         /**
          * Sets the global ReplayCache instance.
index cb13d98..237f798 100644 (file)
   #include <xmltooling/config_pub.h>
 #endif
 
+#ifdef XMLTOOLING_LITE
+# define XMLTOOLING_NO_XMLSEC 1
+#endif
+
 // Windows and GCC4 Symbol Visibility Macros
 #ifdef WIN32
   #define XMLTOOL_IMPORT __declspec(dllimport)
index 83ba6b8..5a6c2c9 100644 (file)
@@ -34,7 +34,9 @@
 using namespace xmltooling;
 using namespace log4cpp;
 using namespace std;
+#ifndef XMLTOOLING_NO_XMLSEC
 using xmlsignature::Signature;
+#endif
 
 void UnknownElementImpl::releaseDOM() const
 {
index 796b313..6f599f4 100644 (file)
@@ -412,7 +412,11 @@ void CURLSOAPTransport::send(istream& in)
     // Set request headers.
     curl_easy_setopt(m_handle,CURLOPT_HTTPHEADER,m_headers);
 
+#ifndef XMLTOOLING_NO_XMLSEC
     if (m_ssl_callback || m_cred || m_trustEngine) {
+#else
+    if (m_ssl_callback) {
+#endif
         curl_easy_setopt(m_handle,CURLOPT_SSL_CTX_FUNCTION,xml_ssl_ctx_callback);
         curl_easy_setopt(m_handle,CURLOPT_SSL_CTX_DATA,this);
 
index 510a8f1..c9f44b8 100644 (file)
@@ -23,8 +23,6 @@
 #include "internal.h"
 #include "util/TemplateEngine.h"
 
-#include <ctime>
-
 using namespace xmltooling;
 using namespace std;
 
@@ -86,15 +84,6 @@ void TemplateEngine::process(
     const XMLToolingException* e
     ) const
 {
-    // Create a timestamp
-    time_t now = time(NULL);
-#ifdef HAVE_CTIME_R
-    char nowbuf[32];
-    ctime_r(&now);
-#else
-    const char* nowbuf = ctime(&now);
-#endif
-
     const char* line = buf.c_str();
     const char* thispos;
 
index 6705fd9..ea120ed 100644 (file)
@@ -1,10 +1,20 @@
 AUTOMAKE_OPTIONS = foreign
 
 if BUILD_UNITTEST
+
 bin_PROGRAMS = xmltoolingtest
-xmltoolingtest_CXXFLAGS = $(CXXFLAGS) $(CXXTESTFLAGS)
+xmltoolingtest_CXXFLAGS = $(CXXTESTFLAGS)
+if BUILD_XMLSEC
+xmltoolingtest_LDFLAGS = $(XMLSEC_LIBS)
+xmltoolingtest_LDADD = $(top_builddir)/xmltooling/libxmltooling.la
+else
+xmltoolingtest_LDADD = $(top_builddir)/xmltooling/libxmltooling-lite.la
+endif
+
 else
+
 bin_PROGRAMS = 
+
 endif
 
 if BUILD_XMLSEC
@@ -45,10 +55,4 @@ do-cxxtestgen:
 $(nodist_xmltoolingtest_SOURCES): %.cpp: %.h
        $(MAKE) do-cxxtestgen HFILE=$< CPPFILE=$@
 
-if BUILD_XMLSEC
-xmltoolingtest_LDADD = $(top_builddir)/xmltooling/libxmltooling.la
-else
-xmltoolingtest_LDADD = $(top_builddir)/xmltooling/libxmltooling-lite.la
-endif
-
 EXTRA_DIST = xmltoolingtest.vcproj $(xmltoolingtest_h) data