diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-04-01 20:42:16 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-04-01 20:42:16 +0000 |
commit | f8c70c81e385fd549756b4f660b4b6860a3e913c (patch) | |
tree | fe040c2fb9621655f7389ff0ddf6c55c66ce536a /cpp/src | |
parent | initial check-in (diff) | |
download | ice-f8c70c81e385fd549756b4f660b4b6860a3e913c.tar.bz2 ice-f8c70c81e385fd549756b4f660b4b6860a3e913c.tar.xz ice-f8c70c81e385fd549756b4f660b4b6860a3e913c.zip |
adding DynamicLibrary
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/.depend | 1 | ||||
-rw-r--r-- | cpp/src/Ice/DynamicLibrary.cpp | 90 | ||||
-rw-r--r-- | cpp/src/Ice/Makefile | 3 |
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) |