1 /*
2  * uhub - A tiny ADC p2p connection hub
3  * Copyright (C) 2007-2014, Jan Vidar Krey
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 #ifndef HAVE_UHUB_PLUGIN_LOADER_H
21 #define HAVE_UHUB_PLUGIN_LOADER_H
22 
23 #include "plugin_api/handle.h"
24 
25 struct hub_config;
26 struct hub_info;
27 struct linked_list;
28 struct plugin_handle;
29 
30 struct uhub_plugin
31 {
32 	void* handle;
33 	plugin_unregister_f unregister;
34 	char* filename;
35 	void* internals;      // Hub-internal stuff (struct plugin_hub_internals)
36 };
37 
38 struct uhub_plugins
39 {
40 	struct linked_list* loaded;
41 };
42 
43 // High level plugin loader code
44 extern struct plugin_handle* plugin_load(const char* filename, const char* config, struct hub_info* hub);
45 extern void plugin_unload(struct plugin_handle* plugin);
46 
47 // extern void plugin_unload(struct plugin_handle*);
48 extern int plugin_initialize(struct hub_config* config, struct hub_info* hub);
49 extern void plugin_shutdown(struct uhub_plugins* handle);
50 
51 // Low level plugin loader code (used internally)
52 extern struct uhub_plugin* plugin_open(const char* filename);
53 extern void plugin_close(struct uhub_plugin*);
54 extern void* plugin_lookup_symbol(struct uhub_plugin*, const char* symbol);
55 
56 // Used internally only
57 struct plugin_hub_internals
58 {
59 	struct hub_info* hub;
60 	plugin_unregister_f unregister;             /* The unregister function. */
61 	struct plugin_callback_data* callback_data; /* callback data that is unique for the plugin */
62 };
63 
64 extern struct plugin_hub_internals* get_internals(struct plugin_handle*);
65 extern struct hub_info* plugin_get_hub(struct plugin_handle*);
66 
67 #endif /* HAVE_UHUB_PLUGIN_LOADER_H */
68