diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-04-30 19:38:18 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-04-30 19:38:18 +0000 |
commit | 14ffacaad81b6a3eb707f44dc3a8ab304c0ccc2b (patch) | |
tree | 235684663edfa11221ffaafa293b1f599707474e /cpp/src/Ice/DynamicLibrary.cpp | |
parent | fixing option bug (diff) | |
download | ice-14ffacaad81b6a3eb707f44dc3a8ab304c0ccc2b.tar.bz2 ice-14ffacaad81b6a3eb707f44dc3a8ab304c0ccc2b.tar.xz ice-14ffacaad81b6a3eb707f44dc3a8ab304c0ccc2b.zip |
refactoring DLL entry point support
Diffstat (limited to 'cpp/src/Ice/DynamicLibrary.cpp')
-rw-r--r-- | cpp/src/Ice/DynamicLibrary.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp index c0b197dcfdb..e713ea2e5f0 100644 --- a/cpp/src/Ice/DynamicLibrary.cpp +++ b/cpp/src/Ice/DynamicLibrary.cpp @@ -38,6 +38,58 @@ IceInternal::DynamicLibrary::~DynamicLibrary() } } +IceInternal::DynamicLibrary::symbol_type +IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint) +{ + string::size_type colon = entryPoint.rfind(':'); + string::size_type comma = entryPoint.find(','); + if (colon == string::npos || colon == entryPoint.size() - 1 || + (comma != string::npos && (comma > colon || comma == colon - 1))) + { + _err = "invalid entry point format `" + entryPoint + "'"; + return 0; + } + string libSpec = entryPoint.substr(0, colon); + string funcName = entryPoint.substr(colon + 1); + string libName, version, debug; + if (comma == string::npos) + { + libName = libSpec; + version = ICE_STRING_VERSION; + } + else + { + libName = libSpec.substr(0, comma); + version = libSpec.substr(comma + 1); + } + + string lib; + +#ifdef _WIN32 + lib = libName; + for (string::size_type n = 0; n < version.size(); n++) + { + if (version[n] != '.') // Remove periods + { + lib += version[n]; + } + } +# ifdef _DEBUG + lib += 'd'; +# endif + lib += ".dll"; +#else + lib = "lib" + libName + ".so." + version; +#endif + + if (!load(lib)) + { + return 0; + } + + return getSymbol(funcName); +} + bool IceInternal::DynamicLibrary::load(const string& lib) { |