| 53 | #endif |
| 54 | |
| 55 | int |
| 56 | getLibraryFunction(const char* libName, const char* funcName, void** libHandle, void** funcHandle) { |
| 57 | |
| 58 | int result = 0; |
| 59 | |
| 60 | *libHandle = NULL; |
| 61 | *funcHandle = NULL; |
| 62 | |
| 63 | //struct stat stFileInfo; |
| 64 | //bool blnReturn; |
| 65 | //int intStat; |
| 66 | |
| 67 | #ifdef _WIN32 |
| 68 | |
| 69 | // |
| 70 | // first try and open dll |
| 71 | // |
| 72 | |
| 73 | int libNameLength = (int)strlen(libName); |
| 74 | char* localLibName = new char[libNameLength + 5]; |
| 75 | strcpy(localLibName, libName); |
| 76 | strcpy(&localLibName[libNameLength], ".dll"); |
| 77 | |
| 78 | HINSTANCE hLib = LoadLibrary(localLibName); |
| 79 | |
| 80 | delete[] localLibName; |
| 81 | |
| 82 | if (hLib != NULL) { |
| 83 | |
| 84 | char mod[124]; |
| 85 | GetModuleFileName((HMODULE)hLib, (LPTSTR)mod, 124); |
| 86 | |
| 87 | // |
| 88 | // Now look for function with funcName |
| 89 | // |
| 90 | |
| 91 | (*funcHandle) = (void*)GetProcAddress((HMODULE)hLib, funcName); |
| 92 | |
| 93 | if (*funcHandle == NULL) { |
| 94 | char* underscoreFunctionName = new char[strlen(funcName) + 2]; |
| 95 | strcpy(underscoreFunctionName, funcName); |
| 96 | strcpy(&underscoreFunctionName[strlen(funcName)], "_"); |
| 97 | (*funcHandle) = (void*)GetProcAddress((HMODULE)hLib, underscoreFunctionName); |
| 98 | delete[] underscoreFunctionName; |
| 99 | } |
| 100 | |
| 101 | |
| 102 | if (*funcHandle == NULL) { |
| 103 | FreeLibrary((HMODULE)hLib); |
| 104 | return -2; |
| 105 | } |
| 106 | |
| 107 | // |
| 108 | // we need to set the OpenSees pointer global variables if function there |
| 109 | // |
| 110 | |
| 111 | typedef int(_cdecl* LocalInitPtrType)(); |
| 112 | typedef int(_cdecl* OPS_ErrorPtrType)(char*, int); |
no outgoing calls
no test coverage detected