/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Mupen64plus-core - osal/dynamiclib_unix.c *
+ * Mupen64plus-video-glide64mk2 - osal_dynamiclib_unix.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdlib.h>
+#include <string.h>
#include <stdio.h>
#include <dlfcn.h>
#include "m64p_types.h"
+#include "m64p.h"
#include "osal_dynamiclib.h"
+m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibraryPath)
+{
+ if (pLibHandle == NULL || pccLibraryPath == NULL)
+ return M64ERR_INPUT_ASSERT;
+
+ *pLibHandle = dlopen(pccLibraryPath, RTLD_NOW);
+
+ if (*pLibHandle == NULL)
+ {
+ /* only print an error message if there is a directory separator (/) in the pathname */
+ /* this prevents us from throwing an error for the use case where Mupen64Plus is not installed */
+ if (strchr(pccLibraryPath, '/') != NULL)
+ WriteLog(M64MSG_ERROR, "dlopen('%s') failed: %s", pccLibraryPath, dlerror());
+ return M64ERR_INPUT_NOT_FOUND;
+ }
+
+ return M64ERR_SUCCESS;
+}
+
void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName)
{
if (pccProcedureName == NULL)
return dlsym(LibHandle, pccProcedureName);
}
+m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle)
+{
+ int rval = dlclose(LibHandle);
+
+ if (rval != 0)
+ {
+ WriteLog(M64MSG_ERROR, "dlclose() failed: %s", dlerror());
+ return M64ERR_INTERNAL;
+ }
+
+ return M64ERR_SUCCESS;
+}
+