MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / getLibraryFunction

Function getLibraryFunction

SRC/api/packages.cpp:55–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53#endif
54
55int
56getLibraryFunction(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);

Callers 11

OPS_GetElementTypeFunction · 0.70
OPS_GetMaterialTypeFunction · 0.70
OPS_GetLimitCurveTypeFunction · 0.70
TclAddDatabaseFunction · 0.50
TclCommand_PackageFunction · 0.50
specifySOEFunction · 0.50
specifyIntegratorFunction · 0.50
Tcl_AddLimitCurveCommandFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected