Commit 3a7a7d82 authored by hpi1's avatar hpi1

Moved arch-specific stuff back to dl_dlopen()

parent c692f790
......@@ -29,7 +29,7 @@
// Note the dlopen takes just the name part. "aacs", internally we
// translate to "libaacs.so" "libaacs.dylib" or "aacs.dll".
BD_PRIVATE void *dl_dlopen ( const char* path );
BD_PRIVATE void *dl_dlopen ( const char* path, const char *version );
BD_PRIVATE void *dl_dlsym ( void* handle, const char* symbol );
BD_PRIVATE int dl_dlclose ( void* handle );
......
......@@ -25,18 +25,39 @@
#include "dl.h"
#include "util/macro.h"
#include "util/logging.h"
#include "util/strutl.h"
#include <stdlib.h>
#include <dlfcn.h>
#include <string.h>
void *dl_dlopen ( const char* path )
void *dl_dlopen ( const char* path, const char *version )
{
DEBUG(DBG_BDPLUS, "searching for library '%s' ...\n", path);
void *result = dlopen(path, RTLD_LAZY);
char *name;
void *result;
#if defined(__APPLE__)
static const char ext[] = ".dylib";
version = NULL;
#else
static const char ext[] = ".so";
#endif
if (version) {
name = str_printf("%s%s.%s", path, ext, version);
} else {
name = str_printf("%s%s", path, ext);
}
DEBUG(DBG_BDPLUS, "searching for library '%s' ...\n", name);
result = dlopen(name, RTLD_LAZY);
if (!result) {
DEBUG(DBG_FILE, "can't open library '%s': %s\n", path, dlerror());
DEBUG(DBG_FILE, "can't open library '%s': %s\n", name, dlerror());
}
X_FREE(name);
return result;
}
......@@ -45,7 +66,7 @@ void *dl_dlsym ( void* handle, const char* symbol )
void *result = dlsym(handle, symbol);
if (!result) {
DEBUG(DBG_FILE | DBG_CRIT, "dlsym(%p, '%s') failed: %s\n", handle, symbol, dlerror());
DEBUG(DBG_FILE | DBG_CRIT, "dlsym(%p, '%s') failed: %s\n", handle, symbol, dlerror());
}
return result;
......
......@@ -152,11 +152,7 @@ static int _open_m2ts(BLURAY *bd)
static int _libaacs_open(BLURAY *bd, const char *keyfile_path)
{
#ifdef USING_DLOPEN
#ifdef __APPLE__
if ((bd->h_libaacs = dl_dlopen("libaacs.dylib"))) {
#else
if ((bd->h_libaacs = dl_dlopen("libaacs.so.0"))) {
#endif
if ((bd->h_libaacs = dl_dlopen("libaacs", "0"))) {
DEBUG(DBG_BLURAY, "Downloaded libaacs (%p)\n", bd->h_libaacs);
fptr_p_void fptr = dl_dlsym(bd->h_libaacs, "aacs_open");
......@@ -211,11 +207,7 @@ static void _libbdplus_open(BLURAY *bd, const char *keyfile_path)
DEBUG(DBG_BDPLUS, "attempting to load libbdplus\n");
#ifdef USING_DLOPEN
#ifdef __APPLE__
if ((bd->h_libbdplus = dl_dlopen("libbdplus.dylib"))) {
#else
if ((bd->h_libbdplus = dl_dlopen("libbdplus.so.0"))) {
#endif
if ((bd->h_libbdplus = dl_dlopen("libbdplus", "0"))) {
DEBUG(DBG_BLURAY, "Downloaded libbdplus (%p)\n",
bd->h_libbdplus);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment