SharedLibrary_HPUX.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // SharedLibrary_HPUX.cpp
  3. //
  4. // $Id: //poco/1.4/Foundation/src/SharedLibrary_HPUX.cpp#2 $
  5. //
  6. // Library: Foundation
  7. // Package: SharedLibrary
  8. // Module: SharedLibrary
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #include "Poco/SharedLibrary_HPUX.h"
  16. #include <dl.h>
  17. namespace Poco {
  18. FastMutex SharedLibraryImpl::_mutex;
  19. SharedLibraryImpl::SharedLibraryImpl()
  20. {
  21. _handle = 0;
  22. }
  23. SharedLibraryImpl::~SharedLibraryImpl()
  24. {
  25. }
  26. void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
  27. {
  28. FastMutex::ScopedLock lock(_mutex);
  29. if (_handle) throw LibraryAlreadyLoadedException(path);
  30. _handle = shl_load(path.c_str(), BIND_DEFERRED, 0);
  31. if (!_handle) throw LibraryLoadException(path);
  32. _path = path;
  33. }
  34. void SharedLibraryImpl::unloadImpl()
  35. {
  36. FastMutex::ScopedLock lock(_mutex);
  37. if (_handle)
  38. {
  39. shl_unload(_handle);
  40. _handle = 0;
  41. _path.clear();
  42. }
  43. }
  44. bool SharedLibraryImpl::isLoadedImpl() const
  45. {
  46. return _handle != 0;
  47. }
  48. void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
  49. {
  50. FastMutex::ScopedLock lock(_mutex);
  51. void* result = 0;
  52. if (_handle && shl_findsym(&_handle, name.c_str(), TYPE_UNDEFINED, &result) != -1)
  53. return result;
  54. else
  55. return 0;
  56. }
  57. const std::string& SharedLibraryImpl::getPathImpl() const
  58. {
  59. return _path;
  60. }
  61. std::string SharedLibraryImpl::suffixImpl()
  62. {
  63. #if defined(_DEBUG)
  64. return "d.sl";
  65. #else
  66. return ".sl";
  67. #endif
  68. }
  69. } // namespace Poco