2011-02-16 19:02:11 +00:00
|
|
|
/*
|
|
|
|
* libscdl.c: wrappers for dlfcn() interfaces
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Martin Paljak <martin@martinpaljak.net>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2011-12-09 20:46:45 +00:00
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
2011-02-16 19:02:11 +00:00
|
|
|
|
2011-03-23 15:02:18 +00:00
|
|
|
#include "libscdl.h"
|
|
|
|
|
2015-09-09 12:51:09 +00:00
|
|
|
#ifdef _WIN32
|
2011-12-09 20:46:45 +00:00
|
|
|
#include <windows.h>
|
2011-02-16 19:02:11 +00:00
|
|
|
void *sc_dlopen(const char *filename)
|
|
|
|
{
|
2015-03-28 09:00:47 +00:00
|
|
|
return (void *)LoadLibraryA(filename);
|
2011-02-16 19:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *sc_dlsym(void *handle, const char *symbol)
|
|
|
|
{
|
2015-03-28 09:00:47 +00:00
|
|
|
return GetProcAddress((HMODULE)handle, symbol);
|
2011-02-16 19:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *sc_dlerror()
|
|
|
|
{
|
|
|
|
return "LoadLibrary/GetProcAddress failed";
|
|
|
|
}
|
|
|
|
|
|
|
|
int sc_dlclose(void *handle)
|
|
|
|
{
|
2015-03-28 09:00:47 +00:00
|
|
|
return FreeLibrary((HMODULE)handle);
|
2011-02-16 19:02:11 +00:00
|
|
|
}
|
2011-12-09 20:46:45 +00:00
|
|
|
#else
|
2011-02-16 19:02:11 +00:00
|
|
|
#include <dlfcn.h>
|
|
|
|
void *sc_dlopen(const char *filename)
|
|
|
|
{
|
2011-06-21 11:56:40 +00:00
|
|
|
return dlopen(filename, RTLD_LAZY);
|
2011-02-16 19:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *sc_dlsym(void *handle, const char *symbol)
|
|
|
|
{
|
|
|
|
return dlsym(handle, symbol);
|
|
|
|
}
|
|
|
|
|
2011-06-21 11:53:08 +00:00
|
|
|
const char *sc_dlerror(void)
|
2011-02-16 19:02:11 +00:00
|
|
|
{
|
|
|
|
return dlerror();
|
|
|
|
}
|
|
|
|
|
|
|
|
int sc_dlclose(void *handle)
|
|
|
|
{
|
|
|
|
return dlclose(handle);
|
|
|
|
}
|
|
|
|
#endif
|