summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/.depend1
-rw-r--r--cpp/src/Ice/DynamicLibrary.cpp90
-rw-r--r--cpp/src/Ice/Makefile3
3 files changed, 93 insertions, 1 deletions
diff --git a/cpp/src/Ice/.depend b/cpp/src/Ice/.depend
index aa80122d3ff..196f4c644aa 100644
--- a/cpp/src/Ice/.depend
+++ b/cpp/src/Ice/.depend
@@ -89,3 +89,4 @@ OpenSSLUtils.o: OpenSSLUtils.cpp ../Ice/OpenSSLUtils.h ../Ice/SystemInternalF.h
DefaultCertificateVerifier.o: DefaultCertificateVerifier.cpp ../Ice/OpenSSL.h ../Ice/DefaultCertificateVerifier.h ../../include/IceUtil/Config.h ../../include/Ice/Logger.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../Ice/TraceLevels.h ../Ice/TraceLevelsF.h ../../include/Ice/PropertiesF.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/Ice/InstanceF.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LoggerF.h ../Ice/RouterInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/SystemF.h ../Ice/SystemInternalF.h ../../include/Ice/CertificateVerifierOpenSSL.h ../../include/Ice/CertificateVerifier.h ../Ice/OpenSSLUtils.h
SingleCertificateVerifier.o: SingleCertificateVerifier.cpp ../Ice/SingleCertificateVerifier.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/CertificateVerifierOpenSSL.h ../../include/Ice/CertificateVerifier.h ../Ice/SslIceUtils.h
UdpTransceiver.o: UdpTransceiver.cpp ../Ice/UdpTransceiver.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../Ice/Transceiver.h ../Ice/TransceiverF.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../Ice/RouterInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/SystemF.h ../Ice/SystemInternalF.h ../Ice/TraceLevels.h ../../include/Ice/LoggerUtil.h ../../include/Ice/Buffer.h ../Ice/Network.h
+DynamicLibrary.o: DynamicLibrary.cpp ../../include/Ice/DynamicLibrary.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/IceUtil/Shared.h
diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp
new file mode 100644
index 00000000000..d62154f43ec
--- /dev/null
+++ b/cpp/src/Ice/DynamicLibrary.cpp
@@ -0,0 +1,90 @@
+// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#include <Ice/DynamicLibrary.h>
+
+#ifndef WIN32
+# include <dlfcn.h>
+#endif
+
+using namespace Ice;
+using namespace IceInternal;
+using namespace std;
+
+void IceInternal::incRef(DynamicLibrary* p) { p->__incRef(); }
+void IceInternal::decRef(DynamicLibrary* p) { p->__decRef(); }
+
+IceInternal::DynamicLibrary::DynamicLibrary()
+ : _hnd(0)
+{
+}
+
+IceInternal::DynamicLibrary::~DynamicLibrary()
+{
+ if(_hnd != 0)
+ {
+#ifdef WIN32
+ FreeLibrary(_hnd);
+#else
+ dlclose(_hnd);
+#endif
+ }
+}
+
+bool
+IceInternal::DynamicLibrary::load(const string& lib)
+{
+#ifdef WIN32
+ _hnd = LoadLibrary(lib.c_str());
+#else
+ _hnd = dlopen(lib.c_str(), RTLD_NOW);
+ if (_hnd == 0)
+ {
+ //
+ // Remember the most recent error in _err.
+ //
+ const char* err = dlerror();
+ if (err)
+ {
+ _err = err;
+ }
+ }
+#endif
+ return _hnd != 0;
+}
+
+IceInternal::DynamicLibrary::symbol_type
+IceInternal::DynamicLibrary::getSymbol(const string& name)
+{
+ assert(_hnd != 0);
+#ifdef WIN32
+ return GetProcAddress(_hnd, name.c_str());
+#else
+ symbol_type result = dlsym(_hnd, name.c_str());
+ if (result == 0)
+ {
+ //
+ // Remember the most recent error in _err.
+ //
+ const char* err = dlerror();
+ if (err)
+ {
+ _err = err;
+ }
+ }
+ return result;
+#endif
+}
+
+const string&
+IceInternal::DynamicLibrary::getErrorMessage() const
+{
+ return _err;
+}
diff --git a/cpp/src/Ice/Makefile b/cpp/src/Ice/Makefile
index 6271fae3bb0..cb655b08f97 100644
--- a/cpp/src/Ice/Makefile
+++ b/cpp/src/Ice/Makefile
@@ -108,7 +108,8 @@ OBJS = Initialize.o \
OpenSSLUtils.o \
DefaultCertificateVerifier.o \
SingleCertificateVerifier.o \
- UdpTransceiver.o
+ UdpTransceiver.o \
+ DynamicLibrary.o
SRCS = $(OBJS:.o=.cpp)