Index: src/OFPlugin.h ================================================================== --- src/OFPlugin.h +++ src/OFPlugin.h @@ -10,16 +10,23 @@ */ #import "OFObject.h" #import "OFString.h" +#ifndef _WIN32 +typedef void* of_plugin_handle_t; +#else +#include +typedef HMODULE of_plugin_handle_t; +#endif + /** * The OFPlugin class provides a system for loading plugins at runtime. */ @interface OFPlugin: OFObject { - void *handle; + of_plugin_handle_t handle; } /** * Loads an OFPlugin from a file. * Index: src/OFPlugin.m ================================================================== --- src/OFPlugin.m +++ src/OFPlugin.m @@ -11,22 +11,31 @@ #include "config.h" #include #include + +#ifndef _WIN32 #include +#endif #import "OFPlugin.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" + +#ifdef _WIN32 +#define dlopen(file, mode) LoadLibrary(file) +#define dlsym(handle, symbol) GetProcAddress(handle, symbol) +#define dlclose(handle) FreeLibrary(handle) +#endif @implementation OFPlugin + pluginFromFile: (OFString*)path { OFAutoreleasePool *pool; OFString *file; - void *handle; + of_plugin_handle_t handle; OFPlugin *(*init_plugin)(); OFPlugin *plugin; pool = [[OFAutoreleasePool alloc] init]; file = [OFMutableString stringWithString: path]; @@ -35,12 +44,12 @@ if ((handle = dlopen([file cString], RTLD_LAZY)) == NULL) @throw [OFInitializationFailedException newWithClass: self]; [pool release]; - if ((init_plugin = dlsym(handle, "init_plugin")) == NULL || - (plugin = init_plugin()) == nil) { + init_plugin = (OFPlugin*(*)())dlsym(handle, "init_plugin"); + if (init_plugin == NULL || (plugin = init_plugin()) == nil) { dlclose(handle); @throw [OFInitializationFailedException newWithClass: self]; } plugin->handle = handle;