ObjFW
OFPlugin.h
1 /*
2  * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFObject.h"
17 
18 @class OFString;
19 
20 #ifndef OF_WINDOWS
21 # include <dlfcn.h>
22 # define OF_RTLD_LAZY RTLD_LAZY
23 # define OF_RTLD_NOW RTLD_NOW
24 typedef void *of_plugin_handle_t;
25 #else
26 # include <windows.h>
27 # define OF_RTLD_LAZY 0
28 # define OF_RTLD_NOW 0
29 typedef HMODULE of_plugin_handle_t;
30 #endif
31 
32 OF_ASSUME_NONNULL_BEGIN
33 
39 @interface OFPlugin: OFObject
40 {
41  of_plugin_handle_t _pluginHandle;
42  OF_RESERVE_IVARS(OFPlugin, 4)
43 }
44 
51 + (OF_KINDOF(OFPlugin *))pluginFromFile: (OFString *)path;
52 @end
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 extern of_plugin_handle_t of_dlopen(OFString *path, int flags);
58 extern void *of_dlsym(of_plugin_handle_t handle, const char *symbol);
59 extern OFString *_Nullable of_dlerror(void);
60 extern void of_dlclose(of_plugin_handle_t handle);
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 OF_ASSUME_NONNULL_END
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
Provides a system for loading plugins at runtime.
Definition: OFPlugin.h:40
A class for handling strings.
Definition: OFString.h:132