| 1 | // LAF Base Library | 
|---|
| 2 | // Copyright (c) 2016 David Capello | 
|---|
| 3 | // | 
|---|
| 4 | // This file is released under the terms of the MIT license. | 
|---|
| 5 | // Read LICENSE.txt for more information. | 
|---|
| 6 |  | 
|---|
| 7 | #include "base/config.h" | 
|---|
| 8 | #include "base/string.h" | 
|---|
| 9 |  | 
|---|
| 10 | #ifdef HAVE_DLFCN_H | 
|---|
| 11 | #include <dlfcn.h> | 
|---|
| 12 | #else | 
|---|
| 13 | #error dlfcn.h is needed or include a file that defines dlopen/dlclose | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 | namespace base { | 
|---|
| 17 |  | 
|---|
| 18 | dll load_dll(const std::string& filename) | 
|---|
| 19 | { | 
|---|
| 20 | return dlopen(filename.c_str(), RTLD_LAZY | RTLD_GLOBAL); | 
|---|
| 21 | } | 
|---|
| 22 |  | 
|---|
| 23 | void unload_dll(dll lib) | 
|---|
| 24 | { | 
|---|
| 25 | dlclose(lib); | 
|---|
| 26 | } | 
|---|
| 27 |  | 
|---|
| 28 | dll_proc get_dll_proc_base(dll lib, const char* procName) | 
|---|
| 29 | { | 
|---|
| 30 | return dlsym(lib, procName); | 
|---|
| 31 | } | 
|---|
| 32 |  | 
|---|
| 33 | } // namespace base | 
|---|
| 34 |  | 
|---|