25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#import "OFPlugin.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFInitializationFailedException.h"
#ifdef _WIN32
# define dlsym(handle, symbol) GetProcAddress(handle, symbol)
# define dlclose(handle) FreeLibrary(handle)
#endif
typedef OFPlugin* (*init_plugin_t)(void);
@implementation OFPlugin
+ (id)pluginFromFile: (OFString*)path
{
void *pool = objc_autoreleasePoolPush();
of_plugin_handle_t handle;
init_plugin_t initPlugin;
OFPlugin *plugin;
path = [path stringByAppendingString: @PLUGIN_SUFFIX];
#ifndef _WIN32
if ((handle = dlopen([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]], RTLD_LAZY)) == NULL)
#else
if ((handle = LoadLibraryW([path UTF16String])) == NULL)
#endif
@throw [OFInitializationFailedException
exceptionWithClass: self];
|
|
|
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#import "OFPlugin.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFInitializationFailedException.h"
#ifdef OF_WINDOWS
# define dlsym(handle, symbol) GetProcAddress(handle, symbol)
# define dlclose(handle) FreeLibrary(handle)
#endif
typedef OFPlugin* (*init_plugin_t)(void);
@implementation OFPlugin
+ (id)pluginFromFile: (OFString*)path
{
void *pool = objc_autoreleasePoolPush();
of_plugin_handle_t handle;
init_plugin_t initPlugin;
OFPlugin *plugin;
path = [path stringByAppendingString: @PLUGIN_SUFFIX];
#ifndef OF_WINDOWS
if ((handle = dlopen([path cStringWithEncoding:
[OFSystemInfo native8BitEncoding]], RTLD_LAZY)) == NULL)
#else
if ((handle = LoadLibraryW([path UTF16String])) == NULL)
#endif
@throw [OFInitializationFailedException
exceptionWithClass: self];
|