MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / _GetPluginPtr

Function _GetPluginPtr

loader/loader.cpp:135–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135METAMOD_PLUGIN *_GetPluginPtr(const char *path, int fail_api)
136{
137 METAMOD_FN_ORIG_LOAD fn;
138 METAMOD_PLUGIN *pl;
139 int ret;
140
141 if (!(g_hCore=openlib(path)))
142 {
143#if defined __linux__ || defined __APPLE__
144 UTIL_Format(s_FailPlugin.error_buffer,
145 sizeof(s_FailPlugin.error_buffer),
146 "%s",
147 dlerror());
148#else
149 DWORD err = GetLastError();
150
151 if (FormatMessageA(
152 FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
153 NULL,
154 err,
155 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
156 s_FailPlugin.error_buffer,
157 sizeof(s_FailPlugin.error_buffer),
158 NULL)
159 == 0)
160 {
161 UTIL_Format(s_FailPlugin.error_buffer,
162 sizeof(s_FailPlugin.error_buffer),
163 "unknown error %x",
164 err);
165 }
166#endif
167
168 s_FailPlugin.fail_version = fail_api;
169
170 return (METAMOD_PLUGIN *)&s_FailPlugin;
171 }
172
173 if (!(fn=(METAMOD_FN_ORIG_LOAD)findsym(g_hCore, "CreateInterface")))
174 {
175 goto error;
176 }
177
178 pl = (METAMOD_PLUGIN *)fn(METAMOD_PLAPI_NAME, &ret);
179 if (!pl)
180 {
181 goto error;
182 }
183
184 return pl;
185error:
186 closelib(g_hCore);
187 g_hCore = NULL;
188 return NULL;
189}
190
191DLL_EXPORT METAMOD_PLUGIN *CreateInterface_MMS(const MetamodVersionInfo *mvi, const MetamodLoaderInfo *mli)
192{

Callers 1

loader.cppFile · 0.85

Calls 1

UTIL_FormatFunction · 0.70

Tested by

no test coverage detected