summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2010-05-20 15:53:17 +0200
committerAndreas Baumann <abaumann@yahoo.com>2010-05-20 15:53:17 +0200
commit82c2b858633c9992ce7560a0b21f37329904a300 (patch)
tree6b806437ba79044cb3f5df11effa87314dc9beaf /src
parenteb26859dbd0240789ee8c5c02a65d784e664987a (diff)
downloadwolfbones-82c2b858633c9992ce7560a0b21f37329904a300.tar.gz
wolfbones-82c2b858633c9992ce7560a0b21f37329904a300.tar.bz2
got to first error message on Windows (library loader)
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.W327
-rw-r--r--src/library/loader.c47
2 files changed, 51 insertions, 3 deletions
diff --git a/src/Makefile.W32 b/src/Makefile.W32
index d0f7a99..d606df9 100644
--- a/src/Makefile.W32
+++ b/src/Makefile.W32
@@ -29,11 +29,16 @@ LOG_OBJS = \
SERVICE_OBJS = \
service\service.obj
+LIBRARY_OBJS = \
+ library\loader.obj
+
OBJS = \
+ errors.obj \
$(THREADING_OBJS) \
$(PORT_OBJS) \
$(LOG_OBJS) \
- $(SERVICE_OBJS)
+ $(SERVICE_OBJS) \
+ $(LIBRARY_OBJS)
local_all: $(LIBRARIES)
diff --git a/src/library/loader.c b/src/library/loader.c
index cf5f0e3..b8a3d1b 100644
--- a/src/library/loader.c
+++ b/src/library/loader.c
@@ -24,14 +24,24 @@
#include "port/gettext.h" /* for i18n */
#include "port/string.h" /* for strncpy */
-#ifdef HAVE_DLFCN
+#if defined HAVE_DLFCN
#include <dlfcn.h> /* for dlopen. dlclose functions */
#endif
+#if defined _WIN32
+#define WIN32_MEAN_AND_LEAN
+#include <windows.h>
+#endif
+
#define INTERNAL_ERRBUF_SIZE 256
struct wolf_library_t {
- void *handle; /**< the OS handle for the library */
+#if defined HAVE_DLFCN
+ void *handle; /**< the OS handle for a library */
+#endif
+#if defined _WIN32
+ HMODULE handle; /**< the windows handle for a library */
+#endif
char errbuf[INTERNAL_ERRBUF_SIZE]; /**< internal buffer to hold the error message
* we get with dlerror */
};
@@ -59,25 +69,50 @@ wolf_library_p wolf_library_load( const char *name, wolf_error_t *error ) {
return l;
}
#else
+#if defined _WIN32
+ l->handle = LoadLibrary( name );
+ if( l->handle == NULL ) {
+ strncpy( l->errbuf, "<TODO: GetLastError>", INTERNAL_ERRBUF_SIZE );
+ *error = WOLF_ERR_INTERNAL;
+ return l;
+ }
+#else
#error Not using DLFCN as shared loader. Port first!
#endif
+#endif
*error = WOLF_OK;
return l;
}
wolf_error_t wolf_library_unload( wolf_library_p l ) {
+#if !defined _WIN32
int res = 0;
+#else
+ BOOL res = FALSE;
+#endif
if( l == NULL || l->handle == NULL ) {
return WOLF_ERR_INVALID_STATE;
}
+#if defined HAVE_DLFCN
res = dlclose( l->handle );
if( res != 0 ) {
strncpy( l->errbuf, dlerror( ), INTERNAL_ERRBUF_SIZE );
return WOLF_ERR_INTERNAL;
}
+#else
+#if defined _WIN32
+ res = FreeLibrary( l->handle );
+ if( !res ) {
+ strncpy( l->errbuf, "<TODO: GetLastError>", INTERNAL_ERRBUF_SIZE );
+ return WOLF_ERR_INTERNAL;
+ }
+#else
+#error Not using DLFCN as shared loader. Port first!
+#endif
+#endif
free( l );
l = NULL;
@@ -98,7 +133,15 @@ char *wolf_library_errmsg( const wolf_error_t error, const wolf_library_p librar
void *wolf_library_get( const wolf_library_p l, const char *name, wolf_error_t *error ) {
void *ret;
+#if defined HAVE_DLFCN
ret = dlsym( l->handle, name );
+#else
+#if defined _WIN32
+
+#else
+#error Not using DLFCN as shared loader. Port first!
+#endif
+#endif
*error = WOLF_OK;
return ret;