Multi-line svn commit, see body.
authorScott Cantor <cantor.2@osu.edu>
Tue, 31 Jul 2007 17:52:04 +0000 (17:52 +0000)
committerScott Cantor <cantor.2@osu.edu>
Tue, 31 Jul 2007 17:52:04 +0000 (17:52 +0000)
Backport libcurl-based Xerces net access.
Convert logging to log4shib via compile time switch.

33 files changed:
config_win32.h
configure.ac
xmltooling/AbstractXMLObject.cpp
xmltooling/AbstractXMLObject.h
xmltooling/XMLObjectBuilder.cpp
xmltooling/XMLToolingConfig.cpp
xmltooling/config_pub.h.in
xmltooling/config_pub_win32.h
xmltooling/encryption/impl/Decrypter.cpp
xmltooling/impl/MemoryStorageService.cpp
xmltooling/impl/UnknownElement.cpp
xmltooling/logging.h [new file with mode: 0644]
xmltooling/security/impl/AbstractPKIXTrustEngine.cpp
xmltooling/security/impl/ChainingCredentialResolver.cpp
xmltooling/security/impl/ChainingTrustEngine.cpp
xmltooling/security/impl/CredentialCriteria.cpp
xmltooling/security/impl/ExplicitKeyTrustEngine.cpp
xmltooling/security/impl/FilesystemCredentialResolver.cpp
xmltooling/security/impl/InlineKeyResolver.cpp
xmltooling/signature/impl/XMLSecSignatureImpl.cpp
xmltooling/soap/impl/CURLSOAPTransport.cpp
xmltooling/soap/impl/SOAPClient.cpp
xmltooling/util/CurlNetAccessor.cpp [new file with mode: 0644]
xmltooling/util/CurlNetAccessor.hpp [new file with mode: 0644]
xmltooling/util/CurlURLInputStream.cpp [new file with mode: 0644]
xmltooling/util/CurlURLInputStream.hpp [new file with mode: 0644]
xmltooling/util/NDC.cpp
xmltooling/util/ParserPool.cpp
xmltooling/util/ReloadableXMLFile.cpp
xmltooling/util/ReloadableXMLFile.h
xmltooling/util/Win32Threads.cpp
xmltooling/xmltooling-lite.vcproj
xmltooling/xmltooling.vcproj

index 1fbb096..63a1a56 100644 (file)
@@ -3,9 +3,8 @@
 /* Define if C++ compiler supports covariant virtual methods. */
 #define HAVE_COVARIANT_RETURNS 1
 
 /* Define if C++ compiler supports covariant virtual methods. */
 #define HAVE_COVARIANT_RETURNS 1
 
-/* Define to 1 if you have the <dlfcn.h> header file.
-#define HAVE_DLFCN_H 1
-*/
+/* Define to 1 if you have the <dlfcn.h> header file. */
+/* #undef HAVE_DLFCN_H */
 
 /* Define to 1 if you have the `gmtime_r' function. */
 /* #undef HAVE_GMTIME_R */
 
 /* Define to 1 if you have the `gmtime_r' function. */
 /* #undef HAVE_GMTIME_R */
    specialization. */
 #define HAVE_GOOD_STL 1
 
    specialization. */
 #define HAVE_GOOD_STL 1
 
-/* Define to 1 if you have the <inttypes.h> header file.
-#define HAVE_INTTYPES_H 1
-*/
+/* Define to 1 if you have the <inttypes.h> header file. */
+/* #undef HAVE_INTTYPES_H */
 
 
-/* Define if log4cpp library was found */
-#define HAVE_LIBLOG4CPP 1
+/* Define if log4shib library is used. */
+#define XMLTOOLING_LOG4SHIB 1
+
+/* Define if log4cpp library is used. */
+/* #undef XMLTOOLING_LOG4CPP */
 
 /* Define if Xerces-C library was found */
 #define HAVE_LIBXERCESC 1
 
 /* Define if Xerces-C library was found */
 #define HAVE_LIBXERCESC 1
@@ -42,9 +43,8 @@
 /* Define to 1 if you have the `strdup' function. */
 #define HAVE_STRDUP 1
 
 /* Define to 1 if you have the `strdup' function. */
 #define HAVE_STRDUP 1
 
-/* Define to 1 if you have the <strings.h> header file.
-#define HAVE_STRINGS_H 1
-*/
+/* Define to 1 if you have the <strings.h> header file. */
+/* #undef HAVE_STRINGS_H */
 
 /* Define to 1 if you have the <string.h> header file. */
 #define HAVE_STRING_H 1
 
 /* Define to 1 if you have the <string.h> header file. */
 #define HAVE_STRING_H 1
@@ -58,9 +58,8 @@
 /* Define to 1 if you have the <sys/types.h> header file. */
 #define HAVE_SYS_TYPES_H 1
 
 /* Define to 1 if you have the <sys/types.h> header file. */
 #define HAVE_SYS_TYPES_H 1
 
-/* Define to 1 if you have the <unistd.h> header file.
-#define HAVE_UNISTD_H 1
-*/
+/* Define to 1 if you have the <unistd.h> header file. */
+/* #undef HAVE_UNISTD_H */
 
 /* Name of package */
 #define PACKAGE "xmltooling"
 
 /* Name of package */
 #define PACKAGE "xmltooling"
index d81ed42..6242c3a 100644 (file)
@@ -93,30 +93,54 @@ AC_TRY_LINK(
      [ class derived: virtual public base { public: virtual derived *GetPtr( void ) { return this; } }; ],
      [AC_DEFINE(HAVE_COVARIANT_RETURNS,1,[Define if C++ compiler supports covariant virtual methods.])])
 
      [ class derived: virtual public base { public: virtual derived *GetPtr( void ) { return this; } }; ],
      [AC_DEFINE(HAVE_COVARIANT_RETURNS,1,[Define if C++ compiler supports covariant virtual methods.])])
 
-# log4cpp settings
-AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
-AC_ARG_WITH(log4cpp,
-    AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
+# log4shib settings (favor this version over the log4cpp code)
+AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
+AC_ARG_WITH(log4shib,
+    AC_HELP_STRING([--with-log4shib=PATH], [where log4shib-config is installed]),
     [
     [
-    LOG4CPP_CONFIG="${with_log4cpp}"
-    if ! test -f "${LOG4CPP_CONFIG}" ; then
-       LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
+    LOG4SHIB_CONFIG="${with_log4shib}"
+    if ! test -f "${LOG4SHIB_CONFIG}" ; then
+       LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
     fi
     ])
     fi
     ])
-if test -f "${LOG4CPP_CONFIG}"; then
-    LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
-    CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
+if test -f "${LOG4SHIB_CONFIG}"; then
+    LDFLAGS="`${LOG4SHIB_CONFIG} --libs` $LDFLAGS"
+    CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
 else
 else
-    AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
-    LIBS="-llog4cpp $LIBS"
+    AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
+    AC_MSG_WARN([will look for original log4cpp library])
+    
+       # log4cpp settings
+       AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
+       AC_ARG_WITH(log4cpp,
+           AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
+           [
+           LOG4CPP_CONFIG="${with_log4cpp}"
+           if ! test -f "${LOG4CPP_CONFIG}" ; then
+               LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
+           fi
+           ])
+       if test -f "${LOG4CPP_CONFIG}"; then
+               AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
+           LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
+           CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
+       else
+           AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
+       fi
+       AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
+       AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
+       AC_TRY_LINK(
+               [#include <log4cpp/Category.hh>],
+               [log4cpp::Category::getInstance("foo")],
+               [AC_DEFINE(XMLTOOLING_LOG4CPP,1,[Define if log4cpp library is used.])],
+               [AC_MSG_ERROR([unable to link with log4cpp])])
 fi
 fi
-AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
-AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
+AC_CHECK_HEADER([log4shib/Category.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
 AC_TRY_LINK(
 AC_TRY_LINK(
-       [#include <log4cpp/Category.hh>],
-       [log4cpp::Category::getInstance("foo")],
-       [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
-       [AC_MSG_ERROR([unable to link with log4cpp])])
+       [#include <log4shib/Category.hh>],
+       [log4shib::Category::getInstance("foo")],
+       [AC_DEFINE(XMLTOOLING_LOG4SHIB,1,[Define if log4shib library is used.])],
+       [AC_MSG_ERROR([unable to link with log4shib])])
 
 # Xerces settings
 AC_ARG_WITH(xerces, 
 
 # Xerces settings
 AC_ARG_WITH(xerces, 
index 3eee63a..7c73f3f 100644 (file)
 #include "exceptions.h"
 
 #include <algorithm>
 #include "exceptions.h"
 
 #include <algorithm>
-#include <log4cpp/Category.hh>
 
 using namespace xmltooling;
 
 AbstractXMLObject::AbstractXMLObject(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
 
 using namespace xmltooling;
 
 AbstractXMLObject::AbstractXMLObject(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
-    : m_log(log4cpp::Category::getInstance(XMLTOOLING_LOGCAT".XMLObject")), m_schemaLocation(NULL), m_noNamespaceSchemaLocation(NULL),
+    : m_log(logging::Category::getInstance(XMLTOOLING_LOGCAT".XMLObject")), m_schemaLocation(NULL), m_noNamespaceSchemaLocation(NULL),
         m_parent(NULL), m_elementQname(nsURI, localName, prefix), m_typeQname(NULL)
 {
     addNamespace(Namespace(nsURI, prefix));
         m_parent(NULL), m_elementQname(nsURI, localName, prefix), m_typeQname(NULL)
 {
     addNamespace(Namespace(nsURI, prefix));
index 80b2971..3b41d6d 100644 (file)
 #ifndef __xmltooling_abstractxmlobj_h__
 #define __xmltooling_abstractxmlobj_h__
 
 #ifndef __xmltooling_abstractxmlobj_h__
 #define __xmltooling_abstractxmlobj_h__
 
+#include <xmltooling/logging.h>
 #include <xmltooling/XMLObject.h>
 #include <xmltooling/util/DateTime.h>
 
 #include <xmltooling/XMLObject.h>
 #include <xmltooling/util/DateTime.h>
 
-#include <log4cpp/Category.hh>
-
 #if defined (_MSC_VER)
     #pragma warning( push )
     #pragma warning( disable : 4250 4251 )
 #if defined (_MSC_VER)
     #pragma warning( push )
     #pragma warning( disable : 4250 4251 )
@@ -195,7 +194,7 @@ namespace xmltooling {
         /**
          * Logging object.
          */
         /**
          * Logging object.
          */
-        log4cpp::Category& m_log;
+        logging::Category& m_log;
 
         /**
          * Stores off xsi:schemaLocation attribute.
 
         /**
          * Stores off xsi:schemaLocation attribute.
index a60d3a5..982f6a2 100644 (file)
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "XMLObjectBuilder.h"
 #include "util/NDC.h"
 #include "util/XMLHelper.h"
 
 #include "XMLObjectBuilder.h"
 #include "util/NDC.h"
 #include "util/XMLHelper.h"
 
-#include <log4cpp/Category.hh>
-
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 map<QName,XMLObjectBuilder*> XMLObjectBuilder::m_map;
 using namespace std;
 
 map<QName,XMLObjectBuilder*> XMLObjectBuilder::m_map;
index f4fc4d3..476f8f1 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "internal.h"
 #include "exceptions.h"
 
 #include "internal.h"
 #include "exceptions.h"
+#include "logging.h"
 #include "XMLToolingConfig.h"
 #include "encryption/Encryption.h"
 #include "encryption/Encrypter.h"
 #include "XMLToolingConfig.h"
 #include "encryption/Encryption.h"
 #include "encryption/Encrypter.h"
 #endif
 
 #include <stdexcept>
 #endif
 
 #include <stdexcept>
-#include <log4cpp/Category.hh>
-#include <log4cpp/PropertyConfigurator.hh>
-#include <log4cpp/OstreamAppender.hh>
+#if defined(XMLTOOLING_LOG4SHIB)
+# include <log4shib/PropertyConfigurator.hh>
+# include <log4shib/OstreamAppender.hh>
+#elif defined(XMLTOOLING_LOG4CPP)
+# include <log4cpp/PropertyConfigurator.hh>
+# include <log4cpp/OstreamAppender.hh>
+#endif
 #include <xercesc/util/PlatformUtils.hpp>
 #ifndef XMLTOOLING_NO_XMLSEC
 # include <curl/curl.h>
 #include <xercesc/util/PlatformUtils.hpp>
 #ifndef XMLTOOLING_NO_XMLSEC
 # include <curl/curl.h>
@@ -61,8 +66,8 @@
 using namespace soap11;
 using namespace xmlencryption;
 using namespace xmlsignature;
 using namespace soap11;
 using namespace xmlencryption;
 using namespace xmlsignature;
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 DECL_XMLTOOLING_EXCEPTION_FACTORY(XMLParserException,xmltooling);
 using namespace std;
 
 DECL_XMLTOOLING_EXCEPTION_FACTORY(XMLParserException,xmltooling);
index 45c9e8d..144d787 100644 (file)
@@ -5,5 +5,11 @@
    specialization. */
 #undef HAVE_GOOD_STL
 
    specialization. */
 #undef HAVE_GOOD_STL
 
+/* Define if log4shib library is used. */
+#undef XMLTOOLING_LOG4SHIB
+
+/* Define if log4cpp library is used. */
+#undef XMLTOOLING_LOG4CPP
+
 /* Define to 1 to disable XML-Security-dependent features. */
 #undef XMLTOOLING_NO_XMLSEC
 /* Define to 1 to disable XML-Security-dependent features. */
 #undef XMLTOOLING_NO_XMLSEC
index 75ac0f9..0c13ee2 100644 (file)
@@ -5,6 +5,12 @@
    specialization. */
 #define HAVE_GOOD_STL 1
 
    specialization. */
 #define HAVE_GOOD_STL 1
 
+/* Define if log4shib library is used. */
+#define XMLTOOLING_LOG4SHIB 1
+
+/* Define if log4cpp library is used. */
+/* #undef XMLTOOLING_LOG4CPP */
+
 /* Define to 1 to disable XML-Security-dependent features. */
 /* #undef XMLTOOLING_NO_XMLSEC */
 
 /* Define to 1 to disable XML-Security-dependent features. */
 /* #undef XMLTOOLING_NO_XMLSEC */
 
index 89a274b..47ed588 100644 (file)
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "encryption/Decrypter.h"
 #include "encryption/EncryptedKeyResolver.h"
 #include "security/Credential.h"
 #include "security/CredentialCriteria.h"
 #include "security/CredentialResolver.h"
 
 #include "encryption/Decrypter.h"
 #include "encryption/EncryptedKeyResolver.h"
 #include "security/Credential.h"
 #include "security/CredentialCriteria.h"
 #include "security/CredentialResolver.h"
 
-#include <log4cpp/Category.hh>
 #include <xsec/enc/XSECCryptoException.hpp>
 #include <xsec/framework/XSECException.hpp>
 #include <xsec/framework/XSECAlgorithmMapper.hpp>
 #include <xsec/enc/XSECCryptoException.hpp>
 #include <xsec/framework/XSECException.hpp>
 #include <xsec/framework/XSECAlgorithmMapper.hpp>
@@ -119,7 +119,7 @@ DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData,
             return decryptData(encryptedData, key);
         }
         catch(DecryptionException& ex) {
             return decryptData(encryptedData, key);
         }
         catch(DecryptionException& ex) {
-            log4cpp::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
+            logging::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
         }
     }
 
         }
     }
 
@@ -219,7 +219,7 @@ void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, co
             return decryptData(out, encryptedData, key);
         }
         catch(DecryptionException& ex) {
             return decryptData(out, encryptedData, key);
         }
         catch(DecryptionException& ex) {
-            log4cpp::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
+            logging::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
         }
     }
 
         }
     }
 
@@ -320,7 +320,7 @@ XSECCryptoKey* Decrypter::decryptKey(const EncryptedKey& encryptedKey, const XML
             }
         }
         catch(DecryptionException& ex) {
             }
         }
         catch(DecryptionException& ex) {
-            log4cpp::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
+            logging::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
         }
     }
     
         }
     }
     
index 3d2f11d..af0fd71 100644 (file)
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "util/NDC.h"
 #include "util/StorageService.h"
 #include "util/Threads.h"
 #include "util/XMLHelper.h"
 
 #include "util/NDC.h"
 #include "util/StorageService.h"
 #include "util/Threads.h"
 #include "util/XMLHelper.h"
 
-#include <log4cpp/Category.hh>
 #include <xercesc/util/XMLUniDefs.hpp>
 
 #include <xercesc/util/XMLUniDefs.hpp>
 
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 namespace xmltooling {
 using namespace std;
 
 namespace xmltooling {
index 5a6c2c9..af4d12e 100644 (file)
 
 #include "internal.h"
 #include "exceptions.h"
 
 #include "internal.h"
 #include "exceptions.h"
+#include "logging.h"
 #include "impl/UnknownElement.h"
 #include "util/NDC.h"
 #include "util/XMLHelper.h"
 
 #include "impl/UnknownElement.h"
 #include "util/NDC.h"
 #include "util/XMLHelper.h"
 
-#include <log4cpp/Category.hh>
 #include <xercesc/framework/MemBufInputSource.hpp>
 #include <xercesc/framework/Wrapper4InputSource.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 
 #include <xercesc/framework/MemBufInputSource.hpp>
 #include <xercesc/framework/Wrapper4InputSource.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 #ifndef XMLTOOLING_NO_XMLSEC
 using xmlsignature::Signature;
 using namespace std;
 #ifndef XMLTOOLING_NO_XMLSEC
 using xmlsignature::Signature;
diff --git a/xmltooling/logging.h b/xmltooling/logging.h
new file mode 100644 (file)
index 0000000..377db18
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ *  Copyright 2001-2007 Internet2
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file xmltooling/logging.h
+ * 
+ * Assist with logging portability.
+ */
+#ifndef __xmltooling_logging_h__
+#define __xmltooling_logging_h__
+
+#include <xmltooling/base.h>
+
+#if defined(XMLTOOLING_LOG4SHIB)
+# include <log4shib/Category.hh>
+# include <log4shib/CategoryStream.hh>
+namespace xmltooling {
+    namespace logging = log4shib;
+};
+#elif defined(XMLTOOLING_LOG4CPP)
+# include <log4cpp/Category.hh>
+# include <log4cpp/CategoryStream.hh>
+namespace xmltooling {
+    namespace logging = log4cpp;
+};
+#else
+# error "Supported logging library not available."
+#endif
+
+#endif /* __xmltooling_logging_h__ */
index 4ee5691..b98ce39 100644 (file)
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "security/AbstractPKIXTrustEngine.h"
 #include "signature/KeyInfo.h"
 
 #include "security/AbstractPKIXTrustEngine.h"
 #include "signature/KeyInfo.h"
 
-#include <log4cpp/Category.hh>
 #include <openssl/x509_vfy.h>
 #include <openssl/x509v3.h>
 #include <xmltooling/security/CredentialCriteria.h>
 #include <openssl/x509_vfy.h>
 #include <openssl/x509v3.h>
 #include <xmltooling/security/CredentialCriteria.h>
@@ -38,8 +38,8 @@
 #include <xsec/enc/OpenSSL/OpenSSLCryptoX509.hpp>
 
 using namespace xmlsignature;
 #include <xsec/enc/OpenSSL/OpenSSLCryptoX509.hpp>
 
 using namespace xmlsignature;
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 
 using namespace std;
 
 
index 312645e..72ce39f 100644 (file)
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "XMLToolingConfig.h"
 #include "security/CredentialResolver.h"
 #include "util/NDC.h"
 #include "util/XMLHelper.h"
 
 #include "XMLToolingConfig.h"
 #include "security/CredentialResolver.h"
 #include "util/NDC.h"
 #include "util/XMLHelper.h"
 
-#include <log4cpp/Category.hh>
 #include <xercesc/util/XMLUniDefs.hpp>
 
 #include <xercesc/util/XMLUniDefs.hpp>
 
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 namespace xmltooling {
 using namespace std;
 
 namespace xmltooling {
index eda259c..4b5aa2c 100644 (file)
 
 #include "internal.h"
 #include "exceptions.h"
 
 #include "internal.h"
 #include "exceptions.h"
+#include "logging.h"
 #include "security/ChainingTrustEngine.h"
 #include "util/XMLHelper.h"
 
 #include "security/ChainingTrustEngine.h"
 #include "util/XMLHelper.h"
 
-#include <log4cpp/Category.hh>
 #include <xercesc/util/XMLUniDefs.hpp>
 
 using namespace xmlsignature;
 #include <xercesc/util/XMLUniDefs.hpp>
 
 using namespace xmlsignature;
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 namespace xmltooling {
 using namespace std;
 
 namespace xmltooling {
index f7521a0..e229a06 100644 (file)
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "security/Credential.h"
 #include "security/CredentialCriteria.h"
 #include "security/KeyInfoResolver.h"
 
 #include "security/Credential.h"
 #include "security/CredentialCriteria.h"
 #include "security/KeyInfoResolver.h"
 
-#include <log4cpp/Category.hh>
 #include <openssl/dsa.h>
 #include <openssl/rsa.h>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
 #include <openssl/dsa.h>
 #include <openssl/rsa.h>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
@@ -75,7 +75,7 @@ bool CredentialCriteria::matches(const Credential& credential) const
 
     if (key1->getProviderName()!=DSIGConstants::s_unicodeStrPROVOpenSSL ||
         key2->getProviderName()!=DSIGConstants::s_unicodeStrPROVOpenSSL) {
 
     if (key1->getProviderName()!=DSIGConstants::s_unicodeStrPROVOpenSSL ||
         key2->getProviderName()!=DSIGConstants::s_unicodeStrPROVOpenSSL) {
-        log4cpp::Category::getInstance(XMLTOOLING_LOGCAT".Credential").warn("comparison of non-OpenSSL credentials are not supported");
+        logging::Category::getInstance(XMLTOOLING_LOGCAT".Credential").warn("comparison of non-OpenSSL credentials are not supported");
         return false;
     }
 
         return false;
     }
 
@@ -95,6 +95,6 @@ bool CredentialCriteria::matches(const Credential& credential) const
         return (BN_cmp(dsa1->pub_key,dsa2->pub_key) == 0);
     }
     
         return (BN_cmp(dsa1->pub_key,dsa2->pub_key) == 0);
     }
     
-    log4cpp::Category::getInstance(XMLTOOLING_LOGCAT".CredentialCriteria").warn("unsupported key type for comparison");
+    logging::Category::getInstance(XMLTOOLING_LOGCAT".CredentialCriteria").warn("unsupported key type for comparison");
     return false;
 }
     return false;
 }
index de1c6b3..bed55d5 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "security/Credential.h"
 #include "security/CredentialCriteria.h"
 #include "security/CredentialResolver.h"
 #include "security/Credential.h"
 #include "security/CredentialCriteria.h"
 #include "security/CredentialResolver.h"
 #include "signature/SignatureValidator.h"
 #include "util/NDC.h"
 
 #include "signature/SignatureValidator.h"
 #include "util/NDC.h"
 
-#include <log4cpp/Category.hh>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoX509.hpp>
 
 using namespace xmlsignature;
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoX509.hpp>
 
 using namespace xmlsignature;
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 namespace xmltooling {
 using namespace std;
 
 namespace xmltooling {
index 8e29e8d..bd63dae 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "security/BasicX509Credential.h"
 #include "security/CredentialCriteria.h"
 #include "security/CredentialResolver.h"
 #include "security/BasicX509Credential.h"
 #include "security/CredentialCriteria.h"
 #include "security/CredentialResolver.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <openssl/pkcs12.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <openssl/pkcs12.h>
-#include <log4cpp/Category.hh>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoX509.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
 
 using namespace xmlsignature;
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoX509.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp>
 #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
 
 using namespace xmlsignature;
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 // OpenSSL password callback...
 using namespace std;
 
 // OpenSSL password callback...
index 2c2e87d..126a6ea 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "security/BasicX509Credential.h"
 #include "security/KeyInfoCredentialContext.h"
 #include "security/KeyInfoResolver.h"
 #include "security/BasicX509Credential.h"
 #include "security/KeyInfoCredentialContext.h"
 #include "security/KeyInfoResolver.h"
@@ -31,7 +32,6 @@
 #include "util/XMLConstants.h"
 #include "validation/ValidatorSuite.h"
 
 #include "util/XMLConstants.h"
 #include "validation/ValidatorSuite.h"
 
-#include <log4cpp/Category.hh>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xsec/dsig/DSIGKeyInfoX509.hpp>
 #include <xsec/enc/XSECKeyInfoResolverDefault.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xsec/dsig/DSIGKeyInfoX509.hpp>
 #include <xsec/enc/XSECKeyInfoResolverDefault.hpp>
@@ -42,8 +42,8 @@
 #include <xsec/framework/XSECException.hpp>
 
 using namespace xmlsignature;
 #include <xsec/framework/XSECException.hpp>
 
 using namespace xmlsignature;
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 namespace xmltooling {
 using namespace std;
 
 namespace xmltooling {
index e3aaaac..938a684 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "internal.h"
 #include "exceptions.h"
 
 #include "internal.h"
 #include "exceptions.h"
+#include "logging.h"
 #include "impl/UnknownElement.h"
 #include "security/Credential.h"
 #include "signature/KeyInfo.h"
 #include "impl/UnknownElement.h"
 #include "security/Credential.h"
 #include "signature/KeyInfo.h"
@@ -30,7 +31,6 @@
 #include "util/XMLConstants.h"
 #include "util/XMLHelper.h"
 
 #include "util/XMLConstants.h"
 #include "util/XMLHelper.h"
 
-#include <log4cpp/Category.hh>
 #include <xercesc/framework/MemBufInputSource.hpp>
 #include <xercesc/framework/Wrapper4InputSource.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xercesc/framework/MemBufInputSource.hpp>
 #include <xercesc/framework/Wrapper4InputSource.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
@@ -45,8 +45,8 @@
 #include <xsec/transformers/TXFMOutputFile.hpp>
 
 using namespace xmlsignature;
 #include <xsec/transformers/TXFMOutputFile.hpp>
 
 using namespace xmlsignature;
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 using xmlconstants::XMLSIG_NS;
 using xmlconstants::XMLSIG_PREFIX;
 using namespace std;
 using xmlconstants::XMLSIG_NS;
 using xmlconstants::XMLSIG_PREFIX;
index f1a6022..48e1a9e 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "internal.h"
 #include "exceptions.h"
 
 #include "internal.h"
 #include "exceptions.h"
+#include "logging.h"
 #include "security/CredentialCriteria.h"
 #include "security/OpenSSLTrustEngine.h"
 #include "security/OpenSSLCredential.h"
 #include "security/CredentialCriteria.h"
 #include "security/OpenSSLTrustEngine.h"
 #include "security/OpenSSLCredential.h"
 
 #include <list>
 #include <curl/curl.h>
 
 #include <list>
 #include <curl/curl.h>
-#include <log4cpp/Category.hh>
 #include <openssl/x509_vfy.h>
 
 #include <openssl/x509_vfy.h>
 
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 namespace xmltooling {
 using namespace std;
 
 namespace xmltooling {
index 2a56979..23d9b8c 100644 (file)
 
 #include "internal.h"
 #include "exceptions.h"
 
 #include "internal.h"
 #include "exceptions.h"
+#include "logging.h"
 #include "soap/SOAP.h"
 #include "soap/SOAPClient.h"
 #include "util/XMLHelper.h"
 #include "validation/ValidatorSuite.h"
 
 #include <sstream>
 #include "soap/SOAP.h"
 #include "soap/SOAPClient.h"
 #include "util/XMLHelper.h"
 #include "validation/ValidatorSuite.h"
 
 #include <sstream>
-#include <log4cpp/Category.hh>
 
 using namespace soap11;
 
 using namespace soap11;
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 SOAPClient::~SOAPClient()
 using namespace std;
 
 SOAPClient::~SOAPClient()
diff --git a/xmltooling/util/CurlNetAccessor.cpp b/xmltooling/util/CurlNetAccessor.cpp
new file mode 100644 (file)
index 0000000..6224f20
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * $Id$
+ */
+
+#include "internal.h"
+
+#include <xercesc/util/XMLUniDefs.hpp>
+#include <xercesc/util/XMLUni.hpp>
+#include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/XMLExceptMsgs.hpp>
+#include <xmltooling/util/CurlURLInputStream.hpp>
+#include <xmltooling/util/CurlNetAccessor.hpp>
+
+using namespace xmltooling;
+
+const XMLCh CurlNetAccessor::fgMyName[] =
+{
+    chLatin_C, chLatin_u, chLatin_r, chLatin_l, chLatin_N, chLatin_e,
+    chLatin_t, chLatin_A, chLatin_c, chLatin_c, chLatin_e, chLatin_s,
+    chLatin_s, chLatin_o, chLatin_r, chNull
+};
+
+
+CurlNetAccessor::CurlNetAccessor()
+{
+       initCurl();
+}
+
+
+CurlNetAccessor::~CurlNetAccessor()
+{
+       cleanupCurl();
+}
+
+
+//
+// Global once-only init and cleanup of curl
+//
+// The init count used here is not thread protected; we assume
+// that creation of the CurlNetAccessor will be serialized by
+// the application. If the application is also using curl, then
+// care must be taken that curl is initialized only once, by some
+// other means, or by overloading these methods.
+//
+int CurlNetAccessor::fgCurlInitCount = 0;
+
+void
+CurlNetAccessor::initCurl()
+{
+       if (fgCurlInitCount++ == 0)
+               curl_global_init(       0
+                                                 | CURL_GLOBAL_ALL                     // Initialize all curl modules
+                                       //        | CURL_GLOBAL_WIN32           // Initialize Windows sockets first
+                                       //        | CURL_GLOBAL_SSL                     // Initialize SSL first
+                                                 );
+}
+
+
+void
+CurlNetAccessor::cleanupCurl()
+{
+       if (fgCurlInitCount > 0 && --fgCurlInitCount == 0)
+               curl_global_cleanup();
+}
+
+
+BinInputStream*
+CurlNetAccessor::makeNew(const XMLURL&  urlSource, const XMLNetHTTPInfo* httpInfo/*=0*/)
+{
+       // Just create a CurlURLInputStream
+       // We defer any checking of the url type for curl in CurlURLInputStream
+       CurlURLInputStream* retStrm =
+               new (urlSource.getMemoryManager()) CurlURLInputStream(urlSource, httpInfo);
+       return retStrm;            
+}
+
diff --git a/xmltooling/util/CurlNetAccessor.hpp b/xmltooling/util/CurlNetAccessor.hpp
new file mode 100644 (file)
index 0000000..4aabcea
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * $Id$
+ */
+
+#if !defined(XERCESC_INCLUDE_GUARD_CURLNETACCESSOR_HPP)
+#define XERCESC_INCLUDE_GUARD_CURLNETACCESSOR_HPP
+
+#include <xmltooling/base.h>
+
+#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/XMLURL.hpp>
+#include <xercesc/util/BinInputStream.hpp>
+#include <xercesc/util/XMLNetAccessor.hpp>
+
+namespace xmltooling {
+
+//
+// This class is the wrapper for the socket based code which
+// provides the ability to fetch a resource specified using
+// a HTTP or FTP URL.
+//
+
+class XMLTOOL_EXPORT CurlNetAccessor : public XMLNetAccessor
+{
+public :
+    CurlNetAccessor();
+    ~CurlNetAccessor();
+    
+    virtual BinInputStream* makeNew(const XMLURL&  urlSource, const XMLNetHTTPInfo* httpInfo=0);
+    virtual const XMLCh* getId() const;
+
+    virtual void initCurl(void);
+    virtual void cleanupCurl(void);
+
+private :
+       static int fgCurlInitCount;
+    static const XMLCh fgMyName[];
+
+    CurlNetAccessor(const CurlNetAccessor&);
+    CurlNetAccessor& operator=(const CurlNetAccessor&);
+
+}; // CurlNetAccessor
+
+
+inline const XMLCh* CurlNetAccessor::getId() const
+{
+    return fgMyName;
+}
+
+
+};
+
+#endif // CURLNETACCESSOR_HPP
+
+
diff --git a/xmltooling/util/CurlURLInputStream.cpp b/xmltooling/util/CurlURLInputStream.cpp
new file mode 100644 (file)
index 0000000..4b4c9d2
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * $Id$
+ */
+
+#include "internal.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+//#include <sys/types.h>
+//#include <sys/time.h>
+
+#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/XMLNetAccessor.hpp>
+#include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/XMLExceptMsgs.hpp>
+#include <xercesc/util/Janitor.hpp>
+#include <xercesc/util/XMLUniDefs.hpp>
+#include <xercesc/util/TransService.hpp>
+#include <xercesc/util/TranscodingException.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+
+#include <xmltooling/util/CurlURLInputStream.hpp>
+
+using namespace xmltooling;
+
+
+CurlURLInputStream::CurlURLInputStream(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo/*=0*/)
+      : fMulti(0)
+      , fEasy(0)
+      , fMemoryManager(urlSource.getMemoryManager())
+      , fURLSource(urlSource)
+      , fURL(0)
+      , fTotalBytesRead(0)
+      , fWritePtr(0)
+      , fBytesRead(0)
+      , fBytesToRead(0)
+      , fDataAvailable(false)
+      , fBufferHeadPtr(fBuffer)
+      , fBufferTailPtr(fBuffer)
+{
+       // Allocate the curl multi handle
+       fMulti = curl_multi_init();
+       
+       // Allocate the curl easy handle
+       fEasy = curl_easy_init();
+       
+       // Get the text of the URL we're going to use
+       fURL.reset(XMLString::transcode(fURLSource.getURLText(), fMemoryManager), fMemoryManager);
+
+       //printf("Curl trying to fetch %s\n", fURL.get());
+
+       // Set URL option
+       curl_easy_setopt(fEasy, CURLOPT_URL, fURL.get());
+       curl_easy_setopt(fEasy, CURLOPT_WRITEDATA, this);                                               // Pass this pointer to write function
+       curl_easy_setopt(fEasy, CURLOPT_WRITEFUNCTION, staticWriteCallback);    // Our static write function
+       
+       // Add easy handle to the multi stack
+       curl_multi_add_handle(fMulti, fEasy);
+}
+
+
+CurlURLInputStream::~CurlURLInputStream()
+{
+       // Remove the easy handle from the multi stack
+       curl_multi_remove_handle(fMulti, fEasy);
+       
+       // Cleanup the easy handle
+       curl_easy_cleanup(fEasy);
+       
+       // Cleanup the multi handle
+       curl_multi_cleanup(fMulti);
+}
+
+
+size_t
+CurlURLInputStream::staticWriteCallback(char *buffer,
+                                      size_t size,
+                                      size_t nitems,
+                                      void *outstream)
+{
+       return ((CurlURLInputStream*)outstream)->writeCallback(buffer, size, nitems);
+}
+
+
+
+size_t
+CurlURLInputStream::writeCallback(char *buffer,
+                                      size_t size,
+                                      size_t nitems)
+{
+       size_t cnt = size * nitems;
+       size_t totalConsumed = 0;
+               
+       // Consume as many bytes as possible immediately into the buffer
+       size_t consume = (cnt > fBytesToRead) ? fBytesToRead : cnt;
+       memcpy(fWritePtr, buffer, consume);
+       fWritePtr               += consume;
+       fBytesRead              += consume;
+       fTotalBytesRead += consume;
+       fBytesToRead    -= consume;
+
+       //printf("write callback consuming %d bytes\n", consume);
+
+       // If bytes remain, rebuffer as many as possible into our holding buffer
+       buffer                  += consume;
+       totalConsumed   += consume;
+       cnt                             -= consume;
+       if (cnt > 0)
+       {
+               size_t bufAvail = sizeof(fBuffer) - (fBufferHeadPtr - fBuffer);
+               consume = (cnt > bufAvail) ? bufAvail : cnt;
+               memcpy(fBufferHeadPtr, buffer, consume);
+               fBufferHeadPtr  += consume;
+               buffer                  += consume;
+               totalConsumed   += consume;
+               //printf("write callback rebuffering %d bytes\n", consume);
+       }
+       
+       // Return the total amount we've consumed. If we don't consume all the bytes
+       // then an error will be generated. Since our buffer size is equal to the
+       // maximum size that curl will write, this should never happen unless there
+       // is a logic error somewhere here.
+       return totalConsumed;
+}
+
+
+unsigned int
+CurlURLInputStream::readBytes(XMLByte* const          toFill
+                                     , const unsigned int maxToRead)
+{
+       fBytesRead = 0;
+       fBytesToRead = maxToRead;
+       fWritePtr = toFill;
+       
+       for (bool tryAgain = true; fBytesToRead > 0 && (tryAgain || fBytesRead == 0); )
+       {
+               // First, any buffered data we have available
+               size_t bufCnt = fBufferHeadPtr - fBufferTailPtr;
+               bufCnt = (bufCnt > fBytesToRead) ? fBytesToRead : bufCnt;
+               if (bufCnt > 0)
+               {
+                       memcpy(fWritePtr, fBufferTailPtr, bufCnt);
+                       fWritePtr               += bufCnt;
+                       fBytesRead              += bufCnt;
+                       fTotalBytesRead += bufCnt;
+                       fBytesToRead    -= bufCnt;
+                       
+                       fBufferTailPtr  += bufCnt;
+                       if (fBufferTailPtr == fBufferHeadPtr)
+                               fBufferHeadPtr = fBufferTailPtr = fBuffer;
+                               
+                       //printf("consuming %d buffered bytes\n", bufCnt);
+
+                       tryAgain = true;
+                       continue;
+               }
+       
+               // Ask the curl to do some work
+               int runningHandles = 0;
+               CURLMcode curlResult = curl_multi_perform(fMulti, &runningHandles);
+               tryAgain = (curlResult == CURLM_CALL_MULTI_PERFORM);
+               
+               // Process messages from curl
+               int msgsInQueue = 0;
+               for (CURLMsg* msg = NULL; (msg = curl_multi_info_read(fMulti, &msgsInQueue)) != NULL; )
+               {
+                       //printf("msg %d, %d from curl\n", msg->msg, msg->data.result);
+
+                       if (msg->msg != CURLMSG_DONE)
+                               continue;
+                               
+                       switch (msg->data.result)
+                       {
+                       case CURLE_OK:
+                               // We completed successfully. runningHandles should have dropped to zero, so we'll bail out below...
+                               break;
+                               
+                       case CURLE_UNSUPPORTED_PROTOCOL:
+                ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_UnsupportedProto, fMemoryManager);
+                break;
+
+            case CURLE_COULDNT_RESOLVE_HOST:
+            case CURLE_COULDNT_RESOLVE_PROXY:
+                ThrowXMLwithMemMgr1(NetAccessorException,  XMLExcepts::NetAcc_TargetResolution, fURLSource.getHost(), fMemoryManager);
+                break;
+                
+            case CURLE_COULDNT_CONNECT:
+                ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_ConnSocket, fURLSource.getURLText(), fMemoryManager);
+               
+            case CURLE_RECV_ERROR:
+                ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, fURLSource.getURLText(), fMemoryManager);
+                break;
+
+            default:
+                ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_InternalError, fURLSource.getURLText(), fMemoryManager);
+                               break;
+                       }
+               }
+               
+               // If nothing is running any longer, bail out
+               if (runningHandles == 0)
+                       break;
+               
+               // If there is no further data to read, and we haven't
+               // read any yet on this invocation, call select to wait for data
+               if (!tryAgain && fBytesRead == 0)
+               {
+                       fd_set readSet[16];
+                       fd_set writeSet[16];
+                       fd_set exceptSet[16];
+                       int fdcnt = 16;
+                       
+                       // As curl for the file descriptors to wait on
+                       (void) curl_multi_fdset(fMulti, readSet, writeSet, exceptSet, &fdcnt);
+                       
+                       // Wait on the file descriptors
+                       timeval tv;
+                       tv.tv_sec  = 2;
+                       tv.tv_usec = 0;
+                       (void) select(fdcnt, readSet, writeSet, exceptSet, &tv);
+               }
+       }
+       
+       return fBytesRead;
+}
+
diff --git a/xmltooling/util/CurlURLInputStream.hpp b/xmltooling/util/CurlURLInputStream.hpp
new file mode 100644 (file)
index 0000000..38e2391
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * $Id$
+ */
+
+#if !defined(XERCESC_INCLUDE_GUARD_CURLURLINPUTSTREAM_HPP)
+#define XERCESC_INCLUDE_GUARD_CURLURLINPUTSTREAM_HPP
+
+#include <xmltooling/base.h>
+
+#include <curl/curl.h>
+#include <curl/multi.h>
+#include <curl/easy.h>
+
+#include <xercesc/util/XMLURL.hpp>
+#include <xercesc/util/XMLExceptMsgs.hpp>
+#include <xercesc/util/Janitor.hpp>
+#include <xercesc/util/BinInputStream.hpp>
+#include <xercesc/util/XMLNetAccessor.hpp>
+
+namespace xmltooling {
+
+//
+// This class implements the BinInputStream interface specified by the XML
+// parser.
+//
+
+class XMLTOOL_EXPORT CurlURLInputStream : public BinInputStream
+{
+public :
+    CurlURLInputStream(const XMLURL&  urlSource, const XMLNetHTTPInfo* httpInfo=0);
+    ~CurlURLInputStream();
+
+    unsigned int curPos() const;
+    unsigned int readBytes
+    (
+                XMLByte* const  toFill
+        , const unsigned int       maxToRead
+    );
+
+
+private :
+    // -----------------------------------------------------------------------
+    //  Unimplemented constructors and operators
+    // -----------------------------------------------------------------------
+    CurlURLInputStream(const CurlURLInputStream&);
+    CurlURLInputStream& operator=(const CurlURLInputStream&);
+    
+    static size_t staticWriteCallback(char *buffer,
+                                      size_t size,
+                                      size_t nitems,
+                                      void *outstream);
+    size_t writeCallback(                        char *buffer,
+                                      size_t size,
+                                      size_t nitems);
+
+
+    // -----------------------------------------------------------------------
+    //  Private data members
+    //
+    //  fSocket
+    //      The socket representing the connection to the remote file.
+    //  fBytesProcessed
+    //      Its a rolling count of the number of bytes processed off this
+    //      input stream.
+    //  fBuffer
+    //      Holds the http header, plus the first part of the actual
+    //      data.  Filled at the time the stream is opened, data goes
+    //      out to user in response to readBytes().
+    //  fBufferPos, fBufferEnd
+    //      Pointers into fBuffer, showing start and end+1 of content
+    //      that readBytes must return.
+    // -----------------------------------------------------------------------
+       
+    CURLM*                             fMulti;
+    CURL*                              fEasy;
+    
+    MemoryManager*      fMemoryManager;
+    
+    XMLURL                             fURLSource;
+    ArrayJanitor<char> fURL;
+    
+    unsigned long       fTotalBytesRead;
+    XMLByte*                   fWritePtr;
+    unsigned long              fBytesRead;
+    unsigned long              fBytesToRead;
+    bool                               fDataAvailable;
+    
+    // Overflow buffer for when curl writes more data to us
+    // than we've asked for.
+    XMLByte                            fBuffer[CURL_MAX_WRITE_SIZE];
+    XMLByte*                   fBufferHeadPtr;
+    XMLByte*                   fBufferTailPtr;
+    
+}; // CurlURLInputStream
+
+
+inline unsigned int
+CurlURLInputStream::curPos() const
+{
+    return fTotalBytesRead;
+}
+
+};
+
+#endif // CURLURLINPUTSTREAM_HPP
+
index 249cc96..ac23379 100644 (file)
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "util/NDC.h"
 
 #include "util/NDC.h"
 
-#include <log4cpp/NDC.hh>
+#if defined(XMLTOOLING_LOG4SHIB)
+# include <log4shib/NDC.hh>
+#elif defined(XMLTOOLING_LOG4CPP)
+# include <log4cpp/NDC.hh>
+#endif
 
 using namespace xmltooling;
 
 NDC::NDC(const char* context)
 {
 
 using namespace xmltooling;
 
 NDC::NDC(const char* context)
 {
-    log4cpp::NDC::push(context);
+    logging::NDC::push(context);
 }
 
 NDC::NDC(const std::string& context)
 {
 }
 
 NDC::NDC(const std::string& context)
 {
-    log4cpp::NDC::push(context);
+    logging::NDC::push(context);
 }
 
 NDC::~NDC()
 {
 }
 
 NDC::~NDC()
 {
-    log4cpp::NDC::pop();
+    logging::NDC::pop();
 }
 }
index 3c8ffe1..18f27ea 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "internal.h"
 #include "exceptions.h"
 
 #include "internal.h"
 #include "exceptions.h"
+#include "logging.h"
 #include "util/NDC.h"
 #include "util/ParserPool.h"
 #include "util/XMLHelper.h"
 #include "util/NDC.h"
 #include "util/ParserPool.h"
 #include "util/XMLHelper.h"
@@ -30,7 +31,6 @@
 #include <functional>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <functional>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <log4cpp/Category.hh>
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xercesc/sax/SAXException.hpp>
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xercesc/sax/SAXException.hpp>
@@ -38,9 +38,9 @@
 #include <xercesc/framework/LocalFileInputSource.hpp>
 #include <xercesc/framework/Wrapper4InputSource.hpp>
 
 #include <xercesc/framework/LocalFileInputSource.hpp>
 #include <xercesc/framework/Wrapper4InputSource.hpp>
 
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace std;
 using namespace xmltooling;
 using namespace std;
-using namespace log4cpp;
 
 ParserPool::ParserPool(bool namespaceAware, bool schemaAware)
     : m_namespaceAware(namespaceAware), m_schemaAware(schemaAware), m_lock(Mutex::create()) {}
 
 ParserPool::ParserPool(bool namespaceAware, bool schemaAware)
     : m_namespaceAware(namespaceAware), m_schemaAware(schemaAware), m_lock(Mutex::create()) {}
index 6a35afa..5bdb545 100644 (file)
@@ -35,8 +35,8 @@
 #include <xercesc/framework/URLInputSource.hpp>\r
 #include <xercesc/util/XMLUniDefs.hpp>\r
 \r
 #include <xercesc/framework/URLInputSource.hpp>\r
 #include <xercesc/util/XMLUniDefs.hpp>\r
 \r
+using namespace xmltooling::logging;\r
 using namespace xmltooling;\r
 using namespace xmltooling;\r
-using namespace log4cpp;\r
 using namespace std;\r
 \r
 static const XMLCh uri[] =              UNICODE_LITERAL_3(u,r,i);\r
 using namespace std;\r
 \r
 static const XMLCh uri[] =              UNICODE_LITERAL_3(u,r,i);\r
index 2b96cb1..cb4c5c3 100644 (file)
 #ifndef __xmltooling_reloadable_h__
 #define __xmltooling_reloadable_h__
 
 #ifndef __xmltooling_reloadable_h__
 #define __xmltooling_reloadable_h__
 
+#include <xmltooling/logging.h>
 #include <xmltooling/Lockable.h>
 #include <xmltooling/util/Threads.h>
 
 #include <ctime>
 #include <string>
 #include <xercesc/dom/DOM.hpp>
 #include <xmltooling/Lockable.h>
 #include <xmltooling/util/Threads.h>
 
 #include <ctime>
 #include <string>
 #include <xercesc/dom/DOM.hpp>
-#include <log4cpp/Category.hh>
 
 namespace xmltooling {
 
 
 namespace xmltooling {
 
@@ -58,7 +58,7 @@ namespace xmltooling {
          * @param e     DOM to supply configuration
          * @param log   logging object to use
          */
          * @param e     DOM to supply configuration
          * @param log   logging object to use
          */
-        ReloadableXMLFile(const xercesc::DOMElement* e, log4cpp::Category& log);
+        ReloadableXMLFile(const xercesc::DOMElement* e, logging::Category& log);
     
         virtual ~ReloadableXMLFile() {
             delete m_lock;
     
         virtual ~ReloadableXMLFile() {
             delete m_lock;
@@ -103,7 +103,7 @@ namespace xmltooling {
         RWLock* m_lock;
         
         /** Logging object. */
         RWLock* m_lock;
         
         /** Logging object. */
-        log4cpp::Category& m_log;
+        logging::Category& m_log;
 
     public:
         Lockable* lock();
 
     public:
         Lockable* lock();
index 5018485..3bf6419 100644 (file)
  */
 
 #include "internal.h"
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "util/Threads.h"
 
 #include "util/Threads.h"
 
-#include <log4cpp/Category.hh>
-
 #ifndef WIN32
 # error "This implementation is for WIN32 platforms."
 #endif
 
 #ifndef WIN32
 # error "This implementation is for WIN32 platforms."
 #endif
 
+using namespace xmltooling::logging;
 using namespace xmltooling;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 // base error code for a routine to return on failure
 using namespace std;
 
 // base error code for a routine to return on failure
index 1d7df37..9094fa2 100644 (file)
@@ -62,7 +62,7 @@
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="wsock32.lib log4cppD.lib xerces-c_2D.lib"\r
+                               AdditionalDependencies="wsock32.lib log4shib1D.lib xerces-c_2D.lib"\r
                                OutputFile="$(OutDir)\$(ProjectName)1_0D.dll"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                OutputFile="$(OutDir)\$(ProjectName)1_0D.dll"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="wsock32.lib log4cpp.lib xerces-c_2.lib"\r
+                               AdditionalDependencies="wsock32.lib log4shib1.lib xerces-c_2.lib"\r
                                OutputFile="$(OutDir)\$(ProjectName)1_0.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                OutputFile="$(OutDir)\$(ProjectName)1_0.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
index e85d997..fc8628e 100644 (file)
@@ -62,7 +62,7 @@
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="wsock32.lib log4cppD.lib xerces-c_2D.lib xsec_1D.lib libeay32_0_9_8D.lib ssleay32_0_9_8D.lib libcurld_imp.lib"\r
+                               AdditionalDependencies="wsock32.lib log4shib1D.lib xerces-c_2D.lib xsec_1D.lib libeay32_0_9_8D.lib ssleay32_0_9_8D.lib libcurld_imp.lib"\r
                                OutputFile="$(OutDir)\$(ProjectName)1_0D.dll"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                OutputFile="$(OutDir)\$(ProjectName)1_0D.dll"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="wsock32.lib log4cpp.lib xerces-c_2.lib xsec_1.lib libeay32_0_9_8.lib ssleay32_0_9_8.lib libcurl_imp.lib"\r
+                               AdditionalDependencies="wsock32.lib log4shib1.lib xerces-c_2.lib xsec_1.lib libeay32_0_9_8.lib ssleay32_0_9_8.lib libcurl_imp.lib"\r
                                OutputFile="$(OutDir)\$(ProjectName)1_0.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                OutputFile="$(OutDir)\$(ProjectName)1_0.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                Name="util"\r
                                >\r
                                <File\r
                                Name="util"\r
                                >\r
                                <File\r
+                                       RelativePath=".\util\CurlNetAccessor.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath=".\util\CurlURLInputStream.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath=".\util\DateTime.cpp"\r
                                        >\r
                                </File>\r
                                        RelativePath=".\util\DateTime.cpp"\r
                                        >\r
                                </File>\r
                                Name="util"\r
                                >\r
                                <File\r
                                Name="util"\r
                                >\r
                                <File\r
+                                       RelativePath=".\util\CurlNetAccessor.hpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath=".\util\CurlURLInputStream.hpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath=".\util\DateTime.h"\r
                                        >\r
                                </File>\r
                                        RelativePath=".\util\DateTime.h"\r
                                        >\r
                                </File>\r