aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/dyn_load
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/dyn_load')
-rw-r--r--src/utils/dyn_load/dyn_load.cpp79
-rw-r--r--src/utils/dyn_load/dyn_load.h67
-rw-r--r--src/utils/dyn_load/info.txt24
3 files changed, 0 insertions, 170 deletions
diff --git a/src/utils/dyn_load/dyn_load.cpp b/src/utils/dyn_load/dyn_load.cpp
deleted file mode 100644
index 51afb1afe..000000000
--- a/src/utils/dyn_load/dyn_load.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
-* Dynamically Loaded Object
-* (C) 2010 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/internal/dyn_load.h>
-#include <botan/build.h>
-#include <stdexcept>
-
-#if defined(BOTAN_TARGET_OS_HAS_DLOPEN)
- #include <dlfcn.h>
-#elif defined(BOTAN_TARGET_OS_HAS_LOADLIBRARY)
- #include <windows.h>
-#endif
-
-namespace Botan {
-
-namespace {
-
-void raise_runtime_loader_exception(const std::string& lib_name,
- const char* msg)
- {
- throw std::runtime_error("Failed to load " + lib_name + ": " +
- (msg ? msg : "Unknown error"));
- }
-
-}
-
-Dynamically_Loaded_Library::Dynamically_Loaded_Library(
- const std::string& library) :
- lib_name(library), lib(nullptr)
- {
-#if defined(BOTAN_TARGET_OS_HAS_DLOPEN)
- lib = ::dlopen(lib_name.c_str(), RTLD_LAZY);
-
- if(!lib)
- raise_runtime_loader_exception(lib_name, dlerror());
-
-#elif defined(BOTAN_TARGET_OS_HAS_LOADLIBRARY)
- lib = ::LoadLibraryA(lib_name.c_str());
-
- if(!lib)
- raise_runtime_loader_exception(lib_name, "LoadLibrary failed");
-#endif
-
- if(!lib)
- raise_runtime_loader_exception(lib_name, "Dynamic load not supported");
- }
-
-Dynamically_Loaded_Library::~Dynamically_Loaded_Library()
- {
-#if defined(BOTAN_TARGET_OS_HAS_DLOPEN)
- ::dlclose(lib);
-#elif defined(BOTAN_TARGET_OS_HAS_LOADLIBRARY)
- ::FreeLibrary((HMODULE)lib);
-#endif
- }
-
-void* Dynamically_Loaded_Library::resolve_symbol(const std::string& symbol)
- {
- void* addr = nullptr;
-
-#if defined(BOTAN_TARGET_OS_HAS_DLOPEN)
- addr = ::dlsym(lib, symbol.c_str());
-#elif defined(BOTAN_TARGET_OS_HAS_LOADLIBRARY)
- addr = reinterpret_cast<void*>(::GetProcAddress((HMODULE)lib,
- symbol.c_str()));
-#endif
-
- if(!addr)
- throw std::runtime_error("Failed to resolve symbol " + symbol +
- " in " + lib_name);
-
- return addr;
- }
-
-}
diff --git a/src/utils/dyn_load/dyn_load.h b/src/utils/dyn_load/dyn_load.h
deleted file mode 100644
index 9edaed202..000000000
--- a/src/utils/dyn_load/dyn_load.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-* Dynamically Loaded Object
-* (C) 2010 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_DYNAMIC_LOADER_H__
-#define BOTAN_DYNAMIC_LOADER_H__
-
-#include <string>
-
-namespace Botan {
-
-/**
-* Represents a DLL or shared object
-*/
-class Dynamically_Loaded_Library
- {
- public:
- /**
- * Load a DLL (or fail with an exception)
- * @param lib_name name or path to a library
- *
- * If you don't use a full path, the search order will be defined
- * by whatever the system linker does by default. Always using fully
- * qualified pathnames can help prevent code injection attacks (eg
- * via manipulation of LD_LIBRARY_PATH on Linux)
- */
- Dynamically_Loaded_Library(const std::string& lib_name);
-
- /**
- * Unload the DLL
- * @warning Any pointers returned by resolve()/resolve_symbol()
- * should not be used after this destructor runs.
- */
- ~Dynamically_Loaded_Library();
-
- /**
- * Load a symbol (or fail with an exception)
- * @param symbol names the symbol to load
- * @return address of the loaded symbol
- */
- void* resolve_symbol(const std::string& symbol);
-
- /**
- * Convenience function for casting symbol to the right type
- * @param symbol names the symbol to load
- * @return address of the loaded symbol
- */
- template<typename T>
- T resolve(const std::string& symbol)
- {
- return reinterpret_cast<T>(resolve_symbol(symbol));
- }
-
- private:
- Dynamically_Loaded_Library(const Dynamically_Loaded_Library&);
- Dynamically_Loaded_Library& operator=(const Dynamically_Loaded_Library&);
-
- std::string lib_name;
- void* lib;
- };
-
-}
-
-#endif
diff --git a/src/utils/dyn_load/info.txt b/src/utils/dyn_load/info.txt
deleted file mode 100644
index c8d91dd75..000000000
--- a/src/utils/dyn_load/info.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-define DYNAMIC_LOADER 20131128
-
-<os>
-freebsd
-linux
-netbsd
-openbsd
-qnx
-solaris
-windows
-</os>
-
-<libs>
-linux -> dl
-solaris -> dl
-</libs>
-
-<source>
-dyn_load.cpp
-</source>
-
-<header:internal>
-dyn_load.h
-</header:internal>