#include "dynamic.h" #include #ifdef _WIN32 #include #define DLOPEN(path) LoadLibraryA(path) #define DLCLOSE(handle) FreeLibrary((HMODULE)(handle)) #else #ifdef __APPLE__ #include #include #endif #include #define DLOPEN(path) dlopen(path, RTLD_LAZY | RTLD_GLOBAL) #define DLCLOSE(handle) dlclose(handle) #endif static int mlx_dynamic_open(mlx_dynamic_handle* handle, const char* path) { handle->ctx = (void*) DLOPEN(path); if (handle->ctx == NULL) { return 1; } return 0; } int mlx_dynamic_load(mlx_dynamic_handle* handle, const char *path) { return mlx_dynamic_open(handle, path); } void mlx_dynamic_unload(mlx_dynamic_handle* handle) { if (handle->ctx) { DLCLOSE(handle->ctx); handle->ctx = NULL; } }