38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
@implementation OFPlugin
+ pluginFromFile: (OFString*)path
{
OFAutoreleasePool *pool;
OFMutableString *file;
of_plugin_handle_t handle;
OFPlugin *(*initPlugin)();
OFPlugin *plugin;
pool = [[OFAutoreleasePool alloc] init];
file = [OFMutableString stringWithString: path];
[file appendString: @PLUGIN_SUFFIX];
if ((handle = dlopen([file cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], RTLD_LAZY)) == NULL)
@throw [OFInitializationFailedException
exceptionWithClass: self];
[pool release];
initPlugin = (OFPlugin*(*)())dlsym(handle, "init_plugin");
if (initPlugin == NULL || (plugin = initPlugin()) == nil) {
dlclose(handle);
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
plugin->handle = handle;
|
|
|
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
@implementation OFPlugin
+ pluginFromFile: (OFString*)path
{
OFAutoreleasePool *pool;
OFMutableString *file;
of_plugin_handle_t handle;
OFPlugin *(*initPlugin)(void);
OFPlugin *plugin;
pool = [[OFAutoreleasePool alloc] init];
file = [OFMutableString stringWithString: path];
[file appendString: @PLUGIN_SUFFIX];
if ((handle = dlopen([file cStringWithEncoding:
OF_STRING_ENCODING_NATIVE], RTLD_LAZY)) == NULL)
@throw [OFInitializationFailedException
exceptionWithClass: self];
[pool release];
initPlugin = (OFPlugin*(*)(void))dlsym(handle, "init_plugin");
if (initPlugin == NULL || (plugin = initPlugin()) == nil) {
dlclose(handle);
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
plugin->handle = handle;
|