| 107 | #endif |
| 108 | |
| 109 | static void humblenet_LoadLibrary() |
| 110 | { |
| 111 | dllHandle = LoadObject(HUMBLENET_LIBRARY); |
| 112 | #ifdef __linux__ |
| 113 | if (!dllHandle) { |
| 114 | Dl_info dl_info; |
| 115 | if (dladdr((const void*)"", &dl_info) != 0) { |
| 116 | std::string buff(dl_info.dli_fname); |
| 117 | auto pos = buff.find_last_of('/'); |
| 118 | if (pos != buff.npos) { |
| 119 | buff.erase(pos); |
| 120 | buff += "/libhumblenet.so"; |
| 121 | dllHandle = LoadObject(buff.c_str()); |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | #endif |
| 126 | #ifdef __APPLE__ |
| 127 | // Special case for OS X. look for a bundle |
| 128 | if (!dllHandle) { |
| 129 | Dl_info dl_info; |
| 130 | if (dladdr((const void*)"", &dl_info) != 0) { |
| 131 | std::string buff(dl_info.dli_fname); |
| 132 | |
| 133 | size_t pos = buff.find("/humblenet_unity_editor.bundle"); |
| 134 | if (pos != buff.npos) { |
| 135 | buff.erase(pos); |
| 136 | buff += "/humblenet.bundle/Contents/MacOS/humblenet"; |
| 137 | |
| 138 | dllHandle = LoadObject(buff.c_str()); |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | #endif |
| 143 | #ifdef WIN32 |
| 144 | // Special case for Win32 |
| 145 | if (!dllHandle) { |
| 146 | char modFile[4096]; |
| 147 | GetModuleFileNameA((HMODULE)&__ImageBase, modFile, sizeof(modFile)); |
| 148 | |
| 149 | std::string buff(modFile); |
| 150 | auto pos = buff.find_last_of('\\'); |
| 151 | if (pos != buff.npos) { |
| 152 | buff.erase(pos); |
| 153 | buff += "\\humblenet.dll"; |
| 154 | |
| 155 | dllHandle = LoadObject(buff.c_str()); |
| 156 | } |
| 157 | } |
| 158 | #endif |
| 159 | if (dllHandle) { |
| 160 | void *procHandle = nullptr; |
| 161 | #define LOADER_PROC(rc,fn,params,args,ret) \ |
| 162 | procHandle = LoadFunction(dllHandle, #fn); \ |
| 163 | if (!procHandle) { humblenet_UnloadLibrary(); return; } \ |
| 164 | jump_table.fn = (humblenet_DYNFN_##fn)procHandle; |
| 165 | #include "humblenet_loader_procs.h" |
| 166 | #undef LOADER_PROC |
nothing calls this directly
no test coverage detected