Wrap dlopen/dlsym
This commit is contained in:
22
src/FFI/getFunction.c
Normal file
22
src/FFI/getFunction.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
// TODO: Windows support
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
void* _GroundFFIGetFunction(void* handle, char* id) {
|
||||
#ifdef _WIN32
|
||||
// TODO: Windows support
|
||||
#else
|
||||
void* function = dlsym(handle, id);
|
||||
char* error = dlerror();
|
||||
if (error != NULL) {
|
||||
Ground.Log.Error(error);
|
||||
Ground.Flags.error = true;
|
||||
return NULL;
|
||||
}
|
||||
return function;
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user