dl_posix.c 767 Bytes
Newer Older
1 2 3 4
#if HAVE_CONFIG_H
#include "config.h"
#endif

5 6 7 8
#include "dl.h"
#include "util/macro.h"
#include "util/logging.h"

9 10
#include <stdlib.h>
#include <dlfcn.h>
11
#include <string.h>
12

13
void   *dl_dlopen  ( const char* path )
14 15
{
    DEBUG(DBG_BDPLUS, "searching for library '%s' ...\n", path);
16
    void *result = dlopen(path, RTLD_LAZY);
hpi1's avatar
hpi1 committed
17
    if (!result) {
hpi1's avatar
hpi1 committed
18
        DEBUG(DBG_FILE | DBG_CRIT, "can't open library '%s': %s\n", path, dlerror());
hpi1's avatar
hpi1 committed
19
    }
20 21 22 23 24
    return result;
}

void   *dl_dlsym   ( void* handle, const char* symbol )
{
hpi1's avatar
hpi1 committed
25 26 27
    void *result = dlsym(handle, symbol);

    if (!result) {
hpi1's avatar
hpi1 committed
28
      DEBUG(DBG_FILE | DBG_CRIT, "dlsym(%p, '%s') failed: %s\n", handle, symbol, dlerror());
hpi1's avatar
hpi1 committed
29 30 31
    }

    return result;
32 33 34 35 36 37
}

int     dl_dlclose ( void* handle )
{
    return dlclose(handle);
}