2004-12-17 12:22:16 -05:00
|
|
|
#include "../factor.h"
|
|
|
|
|
2004-12-25 18:08:20 -05:00
|
|
|
void ffi_dlopen(DLL* dll)
|
2004-12-17 12:22:16 -05:00
|
|
|
{
|
|
|
|
void* dllptr;
|
|
|
|
|
2004-12-25 18:08:20 -05:00
|
|
|
dllptr = dlopen(to_c_string(untag_string(dll->path)), RTLD_LAZY);
|
2004-12-17 12:22:16 -05:00
|
|
|
|
|
|
|
if(dllptr == NULL)
|
|
|
|
{
|
|
|
|
general_error(ERROR_FFI,tag_object(
|
|
|
|
from_c_string(dlerror())));
|
|
|
|
}
|
|
|
|
|
|
|
|
dll->dll = dllptr;
|
|
|
|
}
|
|
|
|
|
2004-12-25 05:49:30 -05:00
|
|
|
void *ffi_dlsym(DLL *dll, F_STRING *symbol)
|
2004-12-17 12:22:16 -05:00
|
|
|
{
|
2004-12-25 05:49:30 -05:00
|
|
|
void* sym = dlsym(dll ? dll->dll : NULL, to_c_string(symbol));
|
2004-12-17 12:22:16 -05:00
|
|
|
if(sym == NULL)
|
|
|
|
{
|
|
|
|
general_error(ERROR_FFI,tag_object(
|
|
|
|
from_c_string(dlerror())));
|
|
|
|
}
|
2004-12-25 05:49:30 -05:00
|
|
|
return sym;
|
2004-12-17 12:22:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-25 05:49:30 -05:00
|
|
|
void ffi_dlclose(DLL *dll)
|
2004-12-17 12:22:16 -05:00
|
|
|
{
|
|
|
|
if(dlclose(dll->dll) == -1)
|
|
|
|
{
|
|
|
|
general_error(ERROR_FFI,tag_object(
|
|
|
|
from_c_string(dlerror())));
|
|
|
|
}
|
|
|
|
dll->dll = NULL;
|
|
|
|
}
|