/src/mosquitto/src/plugin_v5.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | Copyright (c) 2016-2021 Roger Light <roger@atchoo.org> |
3 | | |
4 | | All rights reserved. This program and the accompanying materials |
5 | | are made available under the terms of the Eclipse Public License 2.0 |
6 | | and Eclipse Distribution License v1.0 which accompany this distribution. |
7 | | |
8 | | The Eclipse Public License is available at |
9 | | https://www.eclipse.org/legal/epl-2.0/ |
10 | | and the Eclipse Distribution License is available at |
11 | | http://www.eclipse.org/org/documents/edl-v10.php. |
12 | | |
13 | | SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause |
14 | | |
15 | | Contributors: |
16 | | Roger Light - initial implementation and documentation. |
17 | | */ |
18 | | |
19 | | #include "config.h" |
20 | | |
21 | | #include "mosquitto_broker_internal.h" |
22 | | #include "utlist.h" |
23 | | #include "lib_load.h" |
24 | | |
25 | | |
26 | | int plugin__load_v5(mosquitto_plugin_id_t *plugin, void *lib) |
27 | 0 | { |
28 | 0 | int rc; |
29 | |
|
30 | 0 | if(!(plugin->lib.plugin_init_v5 = (FUNC_plugin_init_v5)LIB_SYM(lib, "mosquitto_plugin_init"))){ |
31 | 0 | log__printf(NULL, MOSQ_LOG_ERR, |
32 | 0 | "Error: Unable to load plugin function mosquitto_plugin_init()."); |
33 | 0 | LIB_ERROR(); |
34 | 0 | LIB_CLOSE(lib); |
35 | 0 | return MOSQ_ERR_UNKNOWN; |
36 | 0 | } |
37 | | /* Optional function */ |
38 | 0 | plugin->lib.plugin_cleanup_v5 = (FUNC_plugin_cleanup_v5)LIB_SYM(lib, "mosquitto_plugin_cleanup"); |
39 | |
|
40 | 0 | plugin->lib.lib = lib; |
41 | 0 | plugin->lib.user_data = NULL; |
42 | 0 | plugin->lib.identifier = plugin; |
43 | |
|
44 | 0 | if(plugin->lib.plugin_init_v5){ |
45 | 0 | rc = plugin->lib.plugin_init_v5(plugin, &plugin->lib.user_data, plugin->config.options, plugin->config.option_count); |
46 | 0 | if(rc){ |
47 | 0 | log__printf(NULL, MOSQ_LOG_ERR, |
48 | 0 | "Error: Plugin returned %d when initialising.", rc); |
49 | 0 | return rc; |
50 | 0 | } |
51 | 0 | } |
52 | 0 | if(plugin->plugin_name && plugin->plugin_version){ |
53 | 0 | log__printf(NULL, MOSQ_LOG_INFO, |
54 | 0 | "Plugin %s version %s loaded.", plugin->plugin_name, plugin->plugin_version); |
55 | 0 | }else if(plugin->plugin_name){ |
56 | 0 | log__printf(NULL, MOSQ_LOG_INFO, |
57 | 0 | "Plugin %s loaded.", plugin->plugin_name); |
58 | 0 | } |
59 | |
|
60 | 0 | return 0; |
61 | 0 | } |