forked from openrs2/openrs2
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
815 B
37 lines
815 B
#include "jaggl_X11_dri.h"
|
|
|
|
#if defined(__unix__)
|
|
#include <dlfcn.h>
|
|
#include <stddef.h>
|
|
|
|
static void *jaggl_dri_handle;
|
|
#endif
|
|
|
|
JNIEXPORT jboolean JNICALL Java_jaggl_X11_dri_open(JNIEnv *env, jclass cls, jstring path) {
|
|
#if defined(__unix__)
|
|
if (jaggl_dri_handle) {
|
|
dlclose(jaggl_dri_handle);
|
|
jaggl_dri_handle = NULL;
|
|
}
|
|
|
|
const char *path_str = (*env)->GetStringUTFChars(env, path, NULL);
|
|
jaggl_dri_handle = dlopen(path_str, RTLD_LAZY | RTLD_GLOBAL);
|
|
(*env)->ReleaseStringUTFChars(env, path, path_str);
|
|
|
|
return jaggl_dri_handle != NULL;
|
|
#else
|
|
return JNI_FALSE;
|
|
#endif
|
|
}
|
|
|
|
JNIEXPORT jboolean JNICALL Java_jaggl_X11_dri_close(JNIEnv *env, jclass cls) {
|
|
#if defined(__unix__)
|
|
if (jaggl_dri_handle) {
|
|
dlclose(jaggl_dri_handle);
|
|
jaggl_dri_handle = NULL;
|
|
return JNI_TRUE;
|
|
}
|
|
#endif
|
|
|
|
return JNI_FALSE;
|
|
}
|
|
|