dl_posix.c 2.15 KB
Newer Older
1 2 3 4 5
/*
 * This file is part of libbluray
 * Copyright (C) 2009-2010  cRTrn13
 * Copyright (C) 2009-2010  John Stebbins
 *
gates's avatar
gates committed
6 7 8 9
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
10
 *
gates's avatar
gates committed
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
gates's avatar
gates committed
13 14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
15
 *
gates's avatar
gates committed
16 17 18
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * <http://www.gnu.org/licenses/>.
19 20 21 22 23 24 25 26 27 28 29 30
 *
 * In addition, as a special exception, the copyright holders of libbluray
 * gives permission to link the code of its release of libbluray with the
 * OpenSSL project's "OpenSSL" library (or with modified versions of it
 * that use the same license as the "OpenSSL" library), and distribute
 * the linked executables.  You must obey the GNU General Public License
 * in all respects for all of the code used other than "OpenSSL".  If you
 * modify this file, you may extend this exception to your version of the
 * file, but you are not obligated to do so.  If you do not wish to do
 * so, delete this exception statement from your version.
 */

31 32 33 34
#if HAVE_CONFIG_H
#include "config.h"
#endif

35 36 37 38
#include "dl.h"
#include "util/macro.h"
#include "util/logging.h"

39 40
#include <stdlib.h>
#include <dlfcn.h>
41
#include <string.h>
42

43
void   *dl_dlopen  ( const char* path )
44 45
{
    DEBUG(DBG_BDPLUS, "searching for library '%s' ...\n", path);
46
    void *result = dlopen(path, RTLD_LAZY);
hpi1's avatar
hpi1 committed
47
    if (!result) {
hpi1's avatar
hpi1 committed
48
        DEBUG(DBG_FILE | DBG_CRIT, "can't open library '%s': %s\n", path, dlerror());
hpi1's avatar
hpi1 committed
49
    }
50 51 52 53 54
    return result;
}

void   *dl_dlsym   ( void* handle, const char* symbol )
{
hpi1's avatar
hpi1 committed
55 56 57
    void *result = dlsym(handle, symbol);

    if (!result) {
hpi1's avatar
hpi1 committed
58
      DEBUG(DBG_FILE | DBG_CRIT, "dlsym(%p, '%s') failed: %s\n", handle, symbol, dlerror());
hpi1's avatar
hpi1 committed
59 60 61
    }

    return result;
62 63 64 65 66 67
}

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